Skip to content

Commit

Permalink
Refactored: Moved searchPath from lib/ to src/lib/; Added new error h…
Browse files Browse the repository at this point in the history
…andlers for improved robustness
  • Loading branch information
vinzbarbuto committed Aug 20, 2024
1 parent 2bb5a7d commit 7c60934
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 8 deletions.
2 changes: 1 addition & 1 deletion src/extension_version.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
'use strict';
// This is a generated file. Do not edit.
export const version = "df4ce25f16c01173e9d4c0ce64a3b2299b52505d";
export const version = "2e65200594b16d40b836b81aed3a244a488df151";
30 changes: 23 additions & 7 deletions src/lfview/lf-data-provider.ts
Original file line number Diff line number Diff line change
Expand Up @@ -120,8 +120,8 @@ export class LFDataProvider implements vscode.TreeDataProvider<LFDataProviderNod
) {

this.type = type;
this.path_offset = type === LFDataProviderNodeType.LOCAL ? 3 : 6;
this.searchPath = type === LFDataProviderNodeType.LOCAL ? '**/lib/*.lf' : '**/target/lfc_include/**/lib/*.lf';
this.path_offset = type === LFDataProviderNodeType.LOCAL ? 4 : 7;
this.searchPath = type === LFDataProviderNodeType.LOCAL ? '**/src/lib/*.lf' : '**/target/lfc_include/**/src/lib/*.lf';
this.exclude_path = type === LFDataProviderNodeType.LOCAL ? '**/target/**' : null;
this.watcher = vscode.workspace.createFileSystemWatcher(this.searchPath);

Expand Down Expand Up @@ -212,9 +212,7 @@ export class LFDataProvider implements vscode.TreeDataProvider<LFDataProviderNod
) {
element.collapsibleState = vscode.TreeItemCollapsibleState.Collapsed;
element.iconPath = new vscode.ThemeIcon('root-folder');
element.children?.forEach( (element: LFDataProviderNode) => {
this._onDidChangeTreeData.fire(element);
})
this._onDidChangeTreeData.fire(element);
}
}

Expand All @@ -229,9 +227,17 @@ 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 => {
if (node) {
if(node){
this.addDataItem(node as LFDataProviderNode);
}
else if(node === null){
vscode.window.showErrorMessage('Error retrieving data from the Language Server', ...['Try again', 'Cancel']).then(selection => {
if(selection === 'Try again'){
this.refreshTree();
}
});
return;
}
});
});
});
Expand Down Expand Up @@ -455,7 +461,17 @@ export class LFDataProvider implements vscode.TreeDataProvider<LFDataProviderNod
*/
async getTargetPosition(uri: vscode.Uri): Promise<NodePosition | undefined> {
return this.client.onReady().then(() => {
return this.client.sendRequest('generator/getTargetPosition', uri.toString());
return this.client.sendRequest('generator/getTargetPosition', uri.toString()).then(position => {
if (!position) {
vscode.window.showErrorMessage('Error retrieving data from the Language Server', ...['Try Again', 'Cancel']).then(selection => {
if (selection == 'Try Again') {
return this.getTargetPosition(uri);
}
});
return undefined;
}
return position as NodePosition;
});
});
}

Expand Down

0 comments on commit 7c60934

Please sign in to comment.