Move emmet from html extenstion to emmet extension

This commit is contained in:
Ramya Achutha Rao
2018-04-22 12:29:13 -07:00
parent 147ca542e6
commit c314388da2
12 changed files with 17 additions and 174 deletions

View File

@@ -6,11 +6,10 @@
import { LanguageModelCache, getLanguageModelCache } from '../languageModelCache';
import { TextDocument, Position, Range, CompletionList } from 'vscode-languageserver-types';
import { getCSSLanguageService, Stylesheet, ICompletionParticipant, FoldingRange } from 'vscode-css-languageservice';
import { getCSSLanguageService, Stylesheet, FoldingRange } from 'vscode-css-languageservice';
import { LanguageMode, Workspace } from './languageModes';
import { HTMLDocumentRegions, CSS_STYLE_RULE } from './embeddedSupport';
import { Color } from 'vscode-languageserver';
import { extractAbbreviation } from 'vscode-emmet-helper';
export function getCSSMode(documentRegions: LanguageModelCache<HTMLDocumentRegions>, workspace: Workspace): LanguageMode {
let cssLanguageService = getCSSLanguageService();
@@ -25,26 +24,9 @@ export function getCSSMode(documentRegions: LanguageModelCache<HTMLDocumentRegio
let embedded = embeddedCSSDocuments.get(document);
return cssLanguageService.doValidation(embedded, cssStylesheets.get(embedded), settings && settings.css);
},
doComplete(document: TextDocument, position: Position, settings = workspace.settings, registeredCompletionParticipants?: ICompletionParticipant[]) {
doComplete(document: TextDocument, position: Position, settings = workspace.settings) {
let embedded = embeddedCSSDocuments.get(document);
const stylesheet = cssStylesheets.get(embedded);
const nonEmmetCompletionParticipants = [];
if (registeredCompletionParticipants) {
// Css Emmet completions in html files are provided no matter where the cursor is inside the embedded css document
// Mimic the same here, until we solve the issue of css language service not able to parse complete embedded documents when there are errors
for (let i = 0; i < registeredCompletionParticipants.length; i++) {
if (typeof (<any>registeredCompletionParticipants[i]).getId === 'function' && (<any>registeredCompletionParticipants[i]).getId() === 'emmet') {
const extractedResults = extractAbbreviation(document, position, { lookAhead: false, syntax: 'css' });
if (extractedResults && extractedResults.abbreviation) {
registeredCompletionParticipants[i].onCssProperty!({ propertyName: extractedResults.abbreviation, range: extractedResults.abbreviationRange });
}
} else {
nonEmmetCompletionParticipants.push(registeredCompletionParticipants[i]);
}
}
}
cssLanguageService.setCompletionParticipants(nonEmmetCompletionParticipants);
return cssLanguageService.doComplete(embedded, position, stylesheet) || CompletionList.create();
},
doHover(document: TextDocument, position: Position) {