[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

@@ -30,7 +30,7 @@ export function activate(context: ExtensionContext) {
// Options to control the language client
let clientOptions: LanguageClientOptions = {
// Register the server for json documents
documentSelector: ['html', 'handlebars'],
documentSelector: ['html', 'handlebars', 'razor'],
synchronize: {
// Synchronize the setting section 'html' to the server
configurationSection: ['html'],

View File

@@ -7,7 +7,8 @@
},
"activationEvents": [
"onLanguage:html",
"onLanguage:handlebars"
"onLanguage:handlebars",
"onLanguage:razor"
],
"main": "./client/out/htmlMain",
"scripts": {
@@ -83,6 +84,21 @@
],
"default": "head, body, /html",
"description": "List of tags, comma separated, that should have an extra newline before them. 'null' defaults to \"head, body, /html\"."
},
"html.suggest.angular1": {
"type": "boolean",
"default": true,
"description": "Configures if the built-in HTML language support suggests Angular V1 tags and properties."
},
"html.suggest.ionic": {
"type": "boolean",
"default": true,
"description": "Configures if the built-in HTML language support suggests Ionic tags, properties and values."
},
"html.suggest.html5": {
"type": "boolean",
"default": true,
"description": "Configures if the built-in HTML language support suggests HTML5 tags, properties and values."
}
}
}

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 {