Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Handles diagnostic with invalid location, and semantic tokens for unscoped file #1286

Merged
merged 2 commits into from
Aug 19, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 5 additions & 1 deletion src/DiagnosticCollection.ts
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,11 @@ export class DiagnosticCollection {
const keys = {};
//build the full current set of diagnostics by file
for (let diagnostic of diagnostics) {
const fileUri = diagnostic.location.uri;
const fileUri = diagnostic?.location?.uri;
if (!fileUri) {
continue;
}

//ensure the file entry exists
if (!result[fileUri]) {
result[fileUri] = [];
Expand Down
2 changes: 1 addition & 1 deletion src/DiagnosticManager.ts
Original file line number Diff line number Diff line change
Expand Up @@ -166,7 +166,7 @@ export class DiagnosticManager {
public clearForFile(fileSrcPath: string) {
const fileSrcPathUri = util.pathToUri(fileSrcPath).toLowerCase();
for (const [key, cachedData] of this.diagnosticsCache.entries()) {
if (cachedData.diagnostic.location.uri.toLowerCase() === fileSrcPathUri) {
if (cachedData.diagnostic.location?.uri.toLowerCase() === fileSrcPathUri) {
this.diagnosticsCache.delete(key);
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,9 @@ export class BrsFileSemanticTokensProcessor {
public process() {
const scope = this.event.scopes[0];
this.result.clear();
scope.linkSymbolTable();
if (scope) {
scope.linkSymbolTable();
}

this.event.file.ast.walk(createVisitor({
VariableExpression: (node) => {
Expand Down Expand Up @@ -57,7 +59,9 @@ export class BrsFileSemanticTokensProcessor {
walkMode: WalkMode.visitAllRecursive
});

scope.unlinkSymbolTable();
if (scope) {
scope.unlinkSymbolTable();
}

//add all tokens to the event
this.event.semanticTokens.push(
Expand Down