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