2018-01-28 01:19:06 -05:00
|
|
|
import { languages, workspace } from "vscode";
|
2018-01-27 20:30:03 -05:00
|
|
|
import { ExtensionContext, WorkspaceConfiguration } from "vscode";
|
|
|
|
|
2018-01-28 01:19:06 -05:00
|
|
|
import { XmlFormatter } from "./formatting/xml-formatter";
|
|
|
|
import { XmlFormattingEditProvider } from "./formatting/xml-formatting-edit-provider";
|
|
|
|
import { ClassicXmlFormatter } from "./formatting/formatters/classic-xml-formatter";
|
|
|
|
import { V2XmlFormatter } from "./formatting/formatters/v2-xml-formatter";
|
2018-01-27 20:51:15 -05:00
|
|
|
|
2018-01-28 01:19:06 -05:00
|
|
|
import * as constants from "./constants";
|
2018-01-27 20:30:03 -05:00
|
|
|
|
|
|
|
export function activate(context: ExtensionContext) {
|
2018-01-28 01:19:06 -05:00
|
|
|
const config = workspace.getConfiguration(constants.extensionPrefix);
|
2018-01-27 20:30:03 -05:00
|
|
|
|
2018-01-28 01:19:06 -05:00
|
|
|
/* Formatting Features */
|
|
|
|
const xmlFormatterImplementationSetting = config.get<string>("xmlFormatterImplementation");
|
|
|
|
let xmlFormatterImplementation: XmlFormatter;
|
2018-01-27 17:50:50 -05:00
|
|
|
|
2018-01-28 01:19:06 -05:00
|
|
|
switch (xmlFormatterImplementationSetting) {
|
|
|
|
case "v2": xmlFormatterImplementation = new V2XmlFormatter(); break;
|
|
|
|
case "classic": default: xmlFormatterImplementation = new ClassicXmlFormatter(); break;
|
|
|
|
}
|
2018-01-27 20:30:03 -05:00
|
|
|
|
2018-01-28 01:19:06 -05:00
|
|
|
const xmlFormattingEditProvider = new XmlFormattingEditProvider(config, xmlFormatterImplementation);
|
2018-01-27 20:30:03 -05:00
|
|
|
|
2018-01-28 01:19:06 -05:00
|
|
|
context.subscriptions.push(
|
|
|
|
languages.registerDocumentFormattingEditProvider("xml", xmlFormattingEditProvider),
|
|
|
|
languages.registerDocumentRangeFormattingEditProvider("xml", xmlFormattingEditProvider)
|
|
|
|
);
|
2018-01-27 20:30:03 -05:00
|
|
|
}
|
|
|
|
|
2018-01-28 01:19:06 -05:00
|
|
|
export function deactivate() {
|
|
|
|
// do nothing
|
|
|
|
}
|