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:
		
						commit
						da21b2978c
					
				
					 1 changed files with 6 additions and 4 deletions
				
			
		| 
						 | 
				
			
			@ -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;
 | 
			
		||||
    }
 | 
			
		||||
}
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
		Loading…
	
	Add table
		
		Reference in a new issue