Skip to content

Commit

Permalink
Refined diagnostics reporting
Browse files Browse the repository at this point in the history
Signed-off-by: kshitij79 <[email protected]>
  • Loading branch information
kshitij79 committed Aug 25, 2024
1 parent 7808bc8 commit f2f79b8
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 4 deletions.
2 changes: 1 addition & 1 deletion server/src/commands/commandHandler.ts
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ export async function loadModels() {
log(`Document count: ${GLOBAL_STATE.documents.all().length}`);
GLOBAL_STATE.documents.all().forEach(async document => {
const change: TextDocumentChangeEvent<TextDocument> = { document };
handleConcertoDocumentChange(GLOBAL_STATE, change);
await handleConcertoDocumentChange(GLOBAL_STATE, change);
});
} else {
log('GLOBAL_STATE.connection is null');
Expand Down
13 changes: 10 additions & 3 deletions server/src/documents/concertoHandler.ts
Original file line number Diff line number Diff line change
Expand Up @@ -89,8 +89,13 @@ export async function handleConcertoDocumentChange(state:LanguageServerState, ch
catch (error: any) {
if(!state.isLoading) {
// we may be offline? Validate without external models
state.modelManager.validateModelFiles();
state.diagnostics.pushDiagnostic(DiagnosticSeverity.Warning, change.document, error, 'model');
if (!navigator.onLine){
state.modelManager.validateModelFiles();
}
// we only report errors for the document that changed, if error has a fileName
if(change.document.uri == error.fileName || !error.fileName){
state.diagnostics.pushDiagnostic(DiagnosticSeverity.Warning, change.document, error, 'model');
}
}
else {
log(`Ignored model validation error while initializing ${change.document.uri}`);
Expand All @@ -99,7 +104,9 @@ export async function handleConcertoDocumentChange(state:LanguageServerState, ch
}
catch (error: any) {
if(!state.isLoading) {
state.diagnostics.pushDiagnostic(DiagnosticSeverity.Error, change.document, error, 'model');
if(change.document.uri == error.fileName || !error.fileName){
state.diagnostics.pushDiagnostic(DiagnosticSeverity.Error, change.document, error, 'model');
}
}
else {
log(`Ignored model validation error while initializing ${change.document.uri}`);
Expand Down

0 comments on commit f2f79b8

Please sign in to comment.