-
Notifications
You must be signed in to change notification settings - Fork 62
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: add diagnostics feature to the language server VSCODE-375 (#493)
* feat: add diagnostics feature to the language server VSCODE-375 * test: add diagnostic suite and hopefully fix telemetry suit * test: try to replace property with sandbox * test: simplify the agg exported telemetry test * refactor: provide fix for new dbs and address other pr comments * refactor: remove unused function * fix: do not highlight use in the middle of the string * refactor: remove trim * fix: remove extra space * fix: do not find use diagnostic issue when use in the middle of other command * refactor: checking for multiple conditions with startsWith
- Loading branch information
1 parent
3467e40
commit c31a9c5
Showing
14 changed files
with
888 additions
and
252 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -43,7 +43,7 @@ jobs: | |
uses: actions/[email protected] | ||
with: | ||
# Version Spec of the version to use. Examples: 12.x, 10.15.1, >=10.15.0 | ||
node-version: ^14.17.5 | ||
node-version: ^16.16.0 | ||
|
||
- name: Run node-gyp bug workaround script | ||
run: | | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,89 @@ | ||
import * as vscode from 'vscode'; | ||
|
||
import type { Diagnostic } from 'vscode-languageserver/node'; | ||
|
||
import EXTENSION_COMMANDS from '../commands'; | ||
import DIAGNOSTIC_CODES from './../language/diagnosticCodes'; | ||
|
||
export default class PlaygroundDiagnosticsCodeActionProvider | ||
implements vscode.CodeActionProvider | ||
{ | ||
_onDidChangeCodeCodeAction: vscode.EventEmitter<void> = | ||
new vscode.EventEmitter<void>(); | ||
|
||
static readonly providedCodeActionKinds = [vscode.CodeActionKind.QuickFix]; | ||
|
||
constructor() { | ||
vscode.workspace.onDidChangeConfiguration(() => { | ||
this._onDidChangeCodeCodeAction.fire(); | ||
}); | ||
} | ||
|
||
readonly onDidChangeCodeLenses: vscode.Event<void> = | ||
this._onDidChangeCodeCodeAction.event; | ||
|
||
provideCodeActions( | ||
document: vscode.TextDocument, | ||
_range: vscode.Range | vscode.Selection, | ||
context: vscode.CodeActionContext | ||
): vscode.ProviderResult<(vscode.CodeAction | vscode.Command)[]> { | ||
const fixCodeActions: vscode.CodeAction[] = []; | ||
const diagnostics = context.diagnostics as unknown as Diagnostic[]; | ||
|
||
for (const diagnostic of diagnostics) { | ||
switch (diagnostic.code) { | ||
case DIAGNOSTIC_CODES.invalidInteractiveSyntaxes: | ||
{ | ||
const fix = new vscode.CodeAction( | ||
'Fix this interactive syntax problem', | ||
vscode.CodeActionKind.QuickFix | ||
); | ||
fix.command = { | ||
command: | ||
EXTENSION_COMMANDS.MDB_FIX_THIS_INVALID_INTERACTIVE_SYNTAX, | ||
title: 'Fix invalid interactive syntax', | ||
arguments: [ | ||
{ | ||
documentUri: document.uri, | ||
range: diagnostic.range, | ||
fix: diagnostic.data?.fix, | ||
}, | ||
], | ||
}; | ||
fixCodeActions.push(fix); | ||
} | ||
break; | ||
default: | ||
break; | ||
} | ||
} | ||
|
||
const allDiagnostics = vscode.languages | ||
.getDiagnostics(document.uri) | ||
.filter((d) => d.code === DIAGNOSTIC_CODES.invalidInteractiveSyntaxes); | ||
|
||
if (allDiagnostics.length > 1) { | ||
const fix = new vscode.CodeAction( | ||
'Fix all interactive syntax problems', | ||
vscode.CodeActionKind.QuickFix | ||
); | ||
|
||
fix.command = { | ||
command: EXTENSION_COMMANDS.MDB_FIX_ALL_INVALID_INTERACTIVE_SYNTAX, | ||
title: 'Fix invalid interactive syntax', | ||
arguments: [ | ||
{ | ||
documentUri: document.uri, | ||
diagnostics: allDiagnostics.map((d) => ({ | ||
range: d.range, | ||
fix: (d as Diagnostic).data?.fix, | ||
})), | ||
}, | ||
], | ||
}; | ||
fixCodeActions.push(fix); | ||
} | ||
|
||
return fixCodeActions; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
enum DIAGNOSTIC_CODES { | ||
invalidInteractiveSyntaxes = 'playground.invalidInteractiveSyntaxes', | ||
} | ||
|
||
export default DIAGNOSTIC_CODES; |
Oops, something went wrong.