Merge pull request #225 from KWeaver87/xqlint-vscode-1.26

Uses a singleton diagnostic collection rather than creating a new collection with each refresh.
This commit is contained in:
Josh Johnson 2018-09-15 21:41:40 -04:00 committed by GitHub
commit da21b2978c
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 6 additions and 4 deletions

View File

@ -1,6 +1,6 @@
import {
commands, languages, window, workspace, ExtensionContext, Memento,
TextEditor, TextEditorSelectionChangeEvent, TextEditorSelectionChangeKind
TextEditor, TextEditorSelectionChangeEvent, TextEditorSelectionChangeKind, DiagnosticCollection
} from "vscode";
import { createDocumentSelector, ExtensionState, Configuration } from "./common";
@ -14,6 +14,8 @@ import { executeXQuery } from "./xquery-execution/commands";
import * as constants from "./constants";
let diagnosticCollectionXQuery: DiagnosticCollection;
export function activate(context: ExtensionContext) {
ExtensionState.configure(context);
@ -36,7 +38,9 @@ export function activate(context: ExtensionContext) {
);
/* Linting Features */
diagnosticCollectionXQuery = languages.createDiagnosticCollection(constants.diagnosticCollections.xquery);
context.subscriptions.push(
diagnosticCollectionXQuery,
window.onDidChangeActiveTextEditor(_handleChangeActiveTextEditor),
window.onDidChangeTextEditorSelection(_handleChangeTextEditorSelection)
);
@ -85,9 +89,7 @@ function _handleContextChange(editor: TextEditor): void {
switch (editor.document.languageId) {
case constants.languageIds.xquery:
languages
.createDiagnosticCollection(constants.diagnosticCollections.xquery)
.set(editor.document.uri, new XQueryLinter().lint(editor.document.getText()));
diagnosticCollectionXQuery.set(editor.document.uri, new XQueryLinter().lint(editor.document.getText()));
break;
}
}