have intellisense for modes

This commit is contained in:
Benjamin Pasero
2016-03-04 17:36:31 +01:00
parent 3ff5de1e0a
commit 3041b376a0
3 changed files with 75 additions and 58 deletions

View File

@@ -13,18 +13,20 @@ import * as nls from 'vscode-nls';
const localize = nls.loadMessageBundle();
let globProperties: CompletionItem[] = [
{ kind: CompletionItemKind.Value, label: localize('assocLabel', "Files with Extension"), insertText: '"*.{{extension}}": "{{language}}"', documentation: localize('assocDescription', "Map all files matching the given pattern to the language with the given id.") },
];
let globValues: CompletionItem[] = [
{ kind: CompletionItemKind.Value, label: localize('languageId', "Language Identifier"), insertText: '"{{language}}"', documentation: localize('languageDescription', "The identifier of the language to associate with the file name pattern.") },
{ kind: CompletionItemKind.Value, label: localize('assocLabelFile', "Files with Extension"), insertText: '"*.{{extension}}": "{{language}}"', documentation: localize('assocDescriptionFile', "Map all files matching the glob pattern in their filename to the language with the given id.") },
{ kind: CompletionItemKind.Value, label: localize('assocLabelPath', "Files with Path"), insertText: '"{{folder}}/*.{{extension}}": "{{language}}"', documentation: localize('assocDescriptionPath', "Map all files matching the glob pattern in their full path to the language with the given id.") }
];
export class FileAssociationContribution implements IJSONWorkerContribution {
private languageIds:string[];
constructor() {
}
public setLanguageIds(ids:string[]): void {
this.languageIds = ids;
}
private isSettingsFile(resource: string): boolean {
return Strings.endsWith(resource, '/settings.json');
}
@@ -43,7 +45,13 @@ export class FileAssociationContribution implements IJSONWorkerContribution {
public collectValueSuggestions(resource: string, location: JSONLocation, currentKey: string, result: ISuggestionsCollector): Thenable<any> {
if (this.isSettingsFile(resource) && location.matches(['files.associations'])) {
globValues.forEach((e) => result.add(e));
this.languageIds.forEach(l => {
result.add({
kind: CompletionItemKind.Value,
label: l,
insertText: '"{{' + l + '}}"',
});
});
}
return null;