move window.title config helper out to extension (for #20049)

This commit is contained in:
Benjamin Pasero
2017-02-07 12:23:58 +01:00
parent 7c8d8e822f
commit bcff7c60e5
4 changed files with 41 additions and 61 deletions

View File

@@ -19,7 +19,6 @@ import Strings = require('./utils/strings');
import { JSONDocument, JSONSchema, LanguageSettings, getLanguageService } from 'vscode-json-languageservice';
import { ProjectJSONContribution } from './jsoncontributions/projectJSONContribution';
import { GlobPatternContribution } from './jsoncontributions/globPatternContribution';
import { WindowTitleContribution } from './jsoncontributions/windowTitleContribution';
import { FileAssociationContribution } from './jsoncontributions/fileAssociationContribution';
import { getLanguageModelCache } from './languageModelCache';
@@ -129,7 +128,6 @@ let languageService = getLanguageService({
contributions: [
new ProjectJSONContribution(),
new GlobPatternContribution(),
new WindowTitleContribution(),
filesAssociationContribution
]
});

View File

@@ -1,51 +0,0 @@
/*---------------------------------------------------------------------------------------------
* Copyright (c) Microsoft Corporation. All rights reserved.
* Licensed under the MIT License. See License.txt in the project root for license information.
*--------------------------------------------------------------------------------------------*/
'use strict';
import { MarkedString } from 'vscode-languageserver';
import Strings = require('../utils/strings');
import { JSONWorkerContribution, JSONPath, CompletionsCollector } from 'vscode-json-languageservice';
import * as nls from 'vscode-nls';
const localize = nls.loadMessageBundle();
export class WindowTitleContribution implements JSONWorkerContribution {
constructor() {
}
private isSettingsFile(resource: string): boolean {
return Strings.endsWith(resource, '/settings.json');
}
public collectDefaultCompletions(resource: string, result: CompletionsCollector): Thenable<any> {
return null;
}
public collectPropertyCompletions(resource: string, location: JSONPath, currentWord: string, addValue: boolean, isLast: boolean, result: CompletionsCollector): Thenable<any> {
return null;
}
public collectValueCompletions(resource: string, location: JSONPath, currentKey: string, result: CompletionsCollector): Thenable<any> {
return null;
}
public getInfoContribution(resource: string, location: JSONPath): Thenable<MarkedString[]> {
if (this.isSettingsFile(resource) && location.length === 1 && location[0] === 'window.title') {
return Promise.resolve([
MarkedString.fromPlainText(localize('windowTitle.description', "Controls the window title based on the active editor. Variables are substituted based on the context:")),
MarkedString.fromPlainText(localize('windowTitle.activeEditorName', "${activeEditorName}: e.g. myFile.txt")),
MarkedString.fromPlainText(localize('windowTitle.activeFilePath', "${activeFilePath}: e.g. /Users/Development/myProject/myFile.txt")),
MarkedString.fromPlainText(localize('windowTitle.rootName', "${rootName}: e.g. myProject")),
MarkedString.fromPlainText(localize('windowTitle.rootPath', "${rootPath}: e.g. /Users/Development/myProject")),
MarkedString.fromPlainText(localize('windowTitle.appName', "${appName}: e.g. VS Code")),
MarkedString.fromPlainText(localize('windowTitle.dirty', "${dirty}: a dirty indicator if the active editor is dirty")),
MarkedString.fromPlainText(localize('windowTitle.separator', "${separator}: a conditional separator (\" - \") that only shows when surrounded by variables with values"))
]);
}
return null;
}
}