[html] add razor

This commit is contained in:
Martin Aeschlimann
2016-09-14 16:39:14 +02:00
parent 21c9ad57a6
commit 2a4e5b023d
13 changed files with 1545 additions and 962 deletions

View File

@@ -0,0 +1,39 @@
/*---------------------------------------------------------------------------------------------
* 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 {IHTMLTagProvider} from './htmlTags';
export function getRazorTagProvider() : IHTMLTagProvider {
var customTags : { [tag:string]: string[]} = {
a: ['asp-action', 'asp-controller', 'asp-fragment', 'asp-host', 'asp-protocol', 'asp-route'],
div: ['asp-validation-summary'],
form: ['asp-action', 'asp-controller', 'asp-anti-forgery'],
input: ['asp-for', 'asp-format'],
label: ['asp-for'],
select: ['asp-for', 'asp-items'],
span: ['asp-validation-for']
};
return {
getId: () => 'razor',
isApplicable: (languageId) => languageId === 'razor',
collectTags: (collector: (tag: string) => void) => {
// no extra tags
},
collectAttributes: (tag: string, collector: (attribute: string, type: string) => void) => {
if (tag) {
var attributes = customTags[tag];
if (attributes) {
attributes.forEach(a => collector(a, null));
}
}
},
collectValues: (tag: string, attribute: string, collector: (value: string) => void) => {
// no values
}
};
}

View File

@@ -8,12 +8,14 @@ import { TextDocument, Position, CompletionList, CompletionItemKind, Range } fro
import { HTMLDocument } from '../parser/htmlParser';
import { TokenType, createScanner, ScannerState } from '../parser/htmlScanner';
import { getHTML5TagProvider, getAngularTagProvider, getIonicTagProvider } from '../parser/htmlTags';
import { getRazorTagProvider } from '../parser/razorTags';
import { CompletionConfiguration } from '../htmlLanguageService';
let allTagProviders = [
getHTML5TagProvider(),
getAngularTagProvider(),
getIonicTagProvider()
getIonicTagProvider(),
getRazorTagProvider()
];
export function doComplete(document: TextDocument, position: Position, doc: HTMLDocument, settings?: CompletionConfiguration): CompletionList {