2016-01-06 15:55:11 -05:00
|
|
|
'use strict';
|
|
|
|
|
|
|
|
import * as vsc from 'vscode';
|
|
|
|
import { TextEditorCommands } from './Commands';
|
|
|
|
import { XmlDocumentFormattingEditProvider, XmlRangeFormattingEditProvider } from './providers/Formatting';
|
|
|
|
|
|
|
|
export var GlobalState: vsc.Memento;
|
|
|
|
export var WorkspaceState: vsc.Memento;
|
|
|
|
|
|
|
|
const LANG_XML: string = 'xml';
|
2016-01-07 11:19:29 -05:00
|
|
|
const MEM_QUERY_HISTORY: string = 'xpathQueryHistory';
|
2016-01-06 15:55:11 -05:00
|
|
|
|
|
|
|
export function activate(ctx: vsc.ExtensionContext) {
|
|
|
|
// expose global and workspace state to the entire extension
|
|
|
|
GlobalState = ctx.globalState;
|
|
|
|
WorkspaceState = ctx.workspaceState;
|
|
|
|
|
|
|
|
// register palette commands
|
|
|
|
ctx.subscriptions.push(
|
|
|
|
vsc.commands.registerTextEditorCommand('xmlTools.minifyXml', TextEditorCommands.minifyXml),
|
|
|
|
vsc.commands.registerTextEditorCommand('xmlTools.formatXml', TextEditorCommands.formatXml),
|
|
|
|
vsc.commands.registerTextEditorCommand('xmlTools.evaluateXPath', TextEditorCommands.evaluateXPath)
|
|
|
|
);
|
|
|
|
|
|
|
|
// register language feature providers
|
|
|
|
ctx.subscriptions.push(
|
|
|
|
vsc.languages.registerDocumentFormattingEditProvider(LANG_XML, new XmlDocumentFormattingEditProvider()),
|
|
|
|
vsc.languages.registerDocumentRangeFormattingEditProvider(LANG_XML, new XmlRangeFormattingEditProvider())
|
|
|
|
);
|
2016-01-07 11:19:29 -05:00
|
|
|
}
|
|
|
|
|
|
|
|
export function deactivate() {
|
|
|
|
// clean up xpath history
|
|
|
|
let memento: vsc.Memento = WorkspaceState || GlobalState;
|
|
|
|
let history = memento.get<any[]>(MEM_QUERY_HISTORY, []);
|
|
|
|
history.splice(0);
|
|
|
|
memento.update(MEM_QUERY_HISTORY, history);
|
2016-01-06 15:55:11 -05:00
|
|
|
}
|