Skip to content

Commit

Permalink
Add proper types instead of using any; Moved commandPalette in the ri…
Browse files Browse the repository at this point in the history
…ght position
  • Loading branch information
vinzbarbuto committed Jul 18, 2024
1 parent 9a74383 commit fc33abc
Show file tree
Hide file tree
Showing 2 changed files with 26 additions and 38 deletions.
14 changes: 7 additions & 7 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -198,6 +198,12 @@
"command": "linguafranca.createNewFile"
}
],
"commandPalette": [
{
"command": "linguafranca.getVersion",
"when": "false"
}
],
"view/title": [
{
"command": "linguafranca.refreshEntries",
Expand Down Expand Up @@ -282,13 +288,7 @@
"name": "Lingo Libraries"
}
]
},
"commandPalette": [
{
"command": "linguafranca.getVersion",
"when": "false"
}
]
}
},
"devDependencies": {
"@types/chai": "^4.3.1",
Expand Down
50 changes: 19 additions & 31 deletions src/lfview/lf-data-provider.ts
Original file line number Diff line number Diff line change
Expand Up @@ -59,20 +59,6 @@ export class LFDataProviderNode extends vscode.TreeItem {
this.iconPath = new vscode.ThemeIcon(icon);
this.contextValue = role;
if (position) { this.position = position; }

// this.registerNodeCommand();

}

/**
* Registers a command for the node based on its role and type.
*/
registerNodeCommand(): void {
this.command = this.role === LFDataProviderNodeRole.REACTOR ? {
title: "",
command: this.type == LFDataProviderNodeType.LOCAL ? "linguafranca.goToFile" : "linguafranca.goToLibraryFile",
arguments: [this]
} : undefined;
}
}

Expand Down Expand Up @@ -241,7 +227,9 @@ export class LFDataProvider implements vscode.TreeDataProvider<LFDataProviderNod
vscode.workspace.findFiles(this.searchPath, this.exclude_path ? this.exclude_path : null).then(uris => {
uris.forEach(uri => {
this.client.sendRequest('generator/getLibraryReactors', uri.toString()).then(node => {
this.addDataItem(node);
if (node) {
this.addDataItem(node as LFDataProviderNode);
}
});
});
});
Expand All @@ -254,7 +242,7 @@ export class LFDataProvider implements vscode.TreeDataProvider<LFDataProviderNod
* Adds a new data item to the LFDataProvider tree.
* @param dataNode - The data node to add to the tree.
*/
addDataItem(dataNode: any) {
addDataItem(dataNode: LFDataProviderNode) {
if (this.type === LFDataProviderNodeType.LOCAL) {
this.addDataItemLocal(dataNode);
} else {
Expand All @@ -266,14 +254,14 @@ export class LFDataProvider implements vscode.TreeDataProvider<LFDataProviderNod
* Adds a data item to the Local Libraries view.
* @param dataNode - The data node to add.
*/
addDataItemLocal(dataNode: any) {
const root = this.buildRoot(dataNode.uri);
let node = new LFDataProviderNode(dataNode.label, dataNode.uri, LFDataProviderNodeRole.FILE, this.type, []);
addDataItemLocal(dataNode: LFDataProviderNode) {
const root = this.buildRoot(dataNode.uri.toString());
let node = new LFDataProviderNode(dataNode.label!.toString(), dataNode.uri.toString(), LFDataProviderNodeRole.FILE, this.type, []);
root.children!.push(node);
if (dataNode.children.length > 0) {
dataNode.children.forEach((child: any) => {
node.children!.push(new LFDataProviderNode(child.label,
child.uri,
if (dataNode.children!.length > 0) {
dataNode.children!.forEach((child: LFDataProviderNode) => {
node.children!.push(new LFDataProviderNode(child.label!.toString(),
child.uri.toString(),
LFDataProviderNodeRole.REACTOR,
this.type, [],
child.position
Expand All @@ -287,14 +275,14 @@ export class LFDataProvider implements vscode.TreeDataProvider<LFDataProviderNod
* Adds a data item to the Lingo Libraries view.
* @param dataNode - The data node to add.
*/
addDataItemLibrary(dataNode: any) {
const root = this.buildRoot(dataNode.uri);
const library_root = this.buildLibraryRoot(dataNode.uri, root);
let node = new LFDataProviderNode(dataNode.label, dataNode.uri, LFDataProviderNodeRole.FILE, this.type, []);
if (dataNode.children.length > 0) {
dataNode.children.forEach((child: any) => {
node.children!.push(new LFDataProviderNode(child.label,
child.uri,
addDataItemLibrary(dataNode: LFDataProviderNode) {
const root = this.buildRoot(dataNode.uri.toString());
const library_root = this.buildLibraryRoot(dataNode.uri.toString(), root);
let node = new LFDataProviderNode(dataNode.label!.toString(), dataNode.uri.toString(), LFDataProviderNodeRole.FILE, this.type, []);
if (dataNode.children!.length > 0) {
dataNode.children!.forEach((child: LFDataProviderNode) => {
node.children!.push(new LFDataProviderNode(child.label!.toString(),
child.uri.toString(),
LFDataProviderNodeRole.REACTOR,
this.type, [],
child.position
Expand Down

0 comments on commit fc33abc

Please sign in to comment.