Skip to content

Commit

Permalink
chore: cssLanguageService -> cssLs
Browse files Browse the repository at this point in the history
  • Loading branch information
johnsoncodehk committed Jun 6, 2021
1 parent 52ce0e4 commit 7df5705
Show file tree
Hide file tree
Showing 11 changed files with 34 additions and 34 deletions.
6 changes: 3 additions & 3 deletions packages/vscode-vue-languageservice/src/parsers/cssClasses.ts
Expand Up @@ -39,9 +39,9 @@ export function parse(
}
function findClassNames(doc: TextDocument, ss: css.Stylesheet) {
const result = new Map<string, Set<[number, number]>>();
const cssLanguageService = sharedLs.getCssLs(doc.languageId);
if (!cssLanguageService) return result;
const symbols = cssLanguageService.findDocumentSymbols(doc, ss);
const cssLs = sharedLs.getCssLs(doc.languageId);
if (!cssLs) return result;
const symbols = cssLs.findDocumentSymbols(doc, ss);
const usedNodes = new Set<number>();
for (const s of symbols) {
if (s.kind === css.SymbolKind.Class) {
Expand Down
Expand Up @@ -19,11 +19,11 @@ export function register({ sourceFiles }: TsApiRegisterOptions) {
function getCssResult(sourceFile: SourceFile) {
let result: ColorPresentation[] = [];
for (const sourceMap of sourceFile.getCssSourceMaps()) {
const cssLanguageService = sharedLs.getCssLs(sourceMap.mappedDocument.languageId);
if (!cssLanguageService || !sourceMap.stylesheet) continue;
const cssLs = sharedLs.getCssLs(sourceMap.mappedDocument.languageId);
if (!cssLs || !sourceMap.stylesheet) continue;
const cssRanges = sourceMap.getMappedRanges(range.start, range.end);
for (const cssRange of cssRanges) {
const _result = cssLanguageService.getColorPresentations(sourceMap.mappedDocument, sourceMap.stylesheet, color, cssRange);
const _result = cssLs.getColorPresentations(sourceMap.mappedDocument, sourceMap.stylesheet, color, cssRange);
for (const item of _result) {
if (item.textEdit) {
if (TextEdit.is(item.textEdit)) {
Expand Down
Expand Up @@ -489,12 +489,12 @@ export function register({ sourceFiles, tsLanguageService, documentContext, vueH
items: [],
};
}
const cssLanguageService = sharedLs.getCssLs(sourceMap.mappedDocument.languageId);
if (!cssLanguageService || !sourceMap.stylesheet) continue;
const cssLs = sharedLs.getCssLs(sourceMap.mappedDocument.languageId);
if (!cssLs || !sourceMap.stylesheet) continue;
const wordPattern = wordPatterns[sourceMap.mappedDocument.languageId] ?? wordPatterns.css;
const wordStart = getWordRange(wordPattern, cssRange.end, sourceMap.mappedDocument)?.start; // TODO: use end?
const wordRange: Range = wordStart ? { start: wordStart, end: cssRange.end } : cssRange;
const cssResult = await cssLanguageService.doComplete2(sourceMap.mappedDocument, cssRange.start, sourceMap.stylesheet, documentContext);
const cssResult = await cssLs.doComplete2(sourceMap.mappedDocument, cssRange.start, sourceMap.stylesheet, documentContext);
if (cssResult.isIncomplete) {
result.isIncomplete = true;
}
Expand Down
Expand Up @@ -15,9 +15,9 @@ export function register({ sourceFiles }: TsApiRegisterOptions) {
const result: ColorInformation[] = [];
const sourceMaps = sourceFile.getCssSourceMaps();
for (const sourceMap of sourceMaps) {
const cssLanguageService = sharedLs.getCssLs(sourceMap.mappedDocument.languageId);
if (!cssLanguageService || !sourceMap.stylesheet) continue;
let colors = cssLanguageService.findDocumentColors(sourceMap.mappedDocument, sourceMap.stylesheet);
const cssLs = sharedLs.getCssLs(sourceMap.mappedDocument.languageId);
if (!cssLs || !sourceMap.stylesheet) continue;
let colors = cssLs.findDocumentColors(sourceMap.mappedDocument, sourceMap.stylesheet);
for (const color of colors) {
const vueRange = sourceMap.getSourceRange(color.range.start, color.range.end);
if (vueRange) {
Expand Down
Expand Up @@ -62,10 +62,10 @@ export function register({ sourceFiles, tsLanguageService }: TsApiRegisterOption
function getCssResult(sourceFile: SourceFile) {
const result: DocumentHighlight[] = [];
for (const sourceMap of sourceFile.getCssSourceMaps()) {
const cssLanguageService = sharedLs.getCssLs(sourceMap.mappedDocument.languageId);
if (!cssLanguageService || !sourceMap.stylesheet) continue;
const cssLs = sharedLs.getCssLs(sourceMap.mappedDocument.languageId);
if (!cssLs || !sourceMap.stylesheet) continue;
for (const cssRange of sourceMap.getMappedRanges(position)) {
const highlights = cssLanguageService.findDocumentHighlights(sourceMap.mappedDocument, cssRange.start, sourceMap.stylesheet);
const highlights = cssLs.findDocumentHighlights(sourceMap.mappedDocument, cssRange.start, sourceMap.stylesheet);
for (const highlight of highlights) {
const vueRange = sourceMap.getSourceRange(highlight.range.start, highlight.range.end);
if (vueRange) {
Expand Down
Expand Up @@ -153,9 +153,9 @@ export function register({ documentContext, sourceFiles, vueHost }: TsApiRegiste
const sourceMaps = sourceFile.getCssSourceMaps();
const result: DocumentLink[] = [];
for (const sourceMap of sourceMaps) {
const cssLanguageService = sharedLs.getCssLs(sourceMap.mappedDocument.languageId);
if (!cssLanguageService || !sourceMap.stylesheet) continue;
const links = await cssLanguageService.findDocumentLinks2(sourceMap.mappedDocument, sourceMap.stylesheet, documentContext);
const cssLs = sharedLs.getCssLs(sourceMap.mappedDocument.languageId);
if (!cssLs || !sourceMap.stylesheet) continue;
const links = await cssLs.findDocumentLinks2(sourceMap.mappedDocument, sourceMap.stylesheet, documentContext);
for (const link of links) {
const vueRange = sourceMap.getSourceRange(link.range.start, link.range.end);
if (vueRange) {
Expand Down
Expand Up @@ -132,9 +132,9 @@ export function register({ sourceFiles, tsLanguageService }: TsApiRegisterOption
const result: SymbolInformation[] = [];
const sourceMaps = sourceFile.getCssSourceMaps();
for (const sourceMap of sourceMaps) {
const cssLanguageService = sharedLs.getCssLs(sourceMap.mappedDocument.languageId);
if (!cssLanguageService || !sourceMap.stylesheet) continue;
let symbols = cssLanguageService.findDocumentSymbols(sourceMap.mappedDocument, sourceMap.stylesheet);
const cssLs = sharedLs.getCssLs(sourceMap.mappedDocument.languageId);
if (!cssLs || !sourceMap.stylesheet) continue;
let symbols = cssLs.findDocumentSymbols(sourceMap.mappedDocument, sourceMap.stylesheet);
if (!symbols) continue;
for (const s of symbols) {
const vueRange = sourceMap.getSourceRange(s.location.range.start, s.location.range.end);
Expand Down
Expand Up @@ -63,9 +63,9 @@ export function register({ ts }: HtmlApiRegisterOptions) {
let result: FoldingRange[] = [];
for (const sourceMap of sourceFile.getCssSourceMaps()) {
if (!sourceMap.capabilities.foldingRanges) continue;
const cssLanguageService = sharedLs.getCssLs(sourceMap.mappedDocument.languageId);
if (!cssLanguageService) continue;
const foldingRanges = cssLanguageService.getFoldingRanges(sourceMap.mappedDocument);
const cssLs = sharedLs.getCssLs(sourceMap.mappedDocument.languageId);
if (!cssLs) continue;
const foldingRanges = cssLs.getFoldingRanges(sourceMap.mappedDocument);
result = result.concat(toVueFoldingRanges(foldingRanges, sourceMap));
}
return result;
Expand Down
Expand Up @@ -63,10 +63,10 @@ export function register({ sourceFiles, tsLanguageService }: TsApiRegisterOption
let result: SelectionRange[] = [];
for (const position of positions) {
for (const sourceMap of sourceFile.getCssSourceMaps()) {
const cssLanguageService = sharedLs.getCssLs(sourceMap.mappedDocument.languageId);
if (!cssLanguageService || !sourceMap.stylesheet) continue;
const cssLs = sharedLs.getCssLs(sourceMap.mappedDocument.languageId);
if (!cssLs || !sourceMap.stylesheet) continue;
for (const cssRange of sourceMap.getMappedRanges(position)) {
const selectRanges = cssLanguageService.getSelectionRanges(sourceMap.mappedDocument, [cssRange.start], sourceMap.stylesheet);
const selectRanges = cssLs.getSelectionRanges(sourceMap.mappedDocument, [cssRange.start], sourceMap.stylesheet);
for (const selectRange of selectRanges) {
const vueRange = sourceMap.getSourceRange(selectRange.range.start, selectRange.range.end);
if (vueRange) {
Expand Down
6 changes: 3 additions & 3 deletions packages/vscode-vue-languageservice/src/sourceFile.ts
Expand Up @@ -691,9 +691,9 @@ export function createSourceFile(
const errors = computed(() => {
let result = new Map<string, css.Diagnostic[]>();
for (const { textDocument, stylesheet } of documents.value) {
const cssLanguageService = sharedLs.getCssLs(textDocument.languageId);
if (!cssLanguageService || !stylesheet) continue;
const errs = cssLanguageService.doValidation(textDocument, stylesheet);
const cssLs = sharedLs.getCssLs(textDocument.languageId);
if (!cssLs || !stylesheet) continue;
const errs = cssLs.doValidation(textDocument, stylesheet);
if (errs) result.set(textDocument.uri, errs);
}
return result;
Expand Down
Expand Up @@ -38,10 +38,10 @@ export function useStylesRaw(
stylesheet: css.Stylesheet,
}[] = [];
let stylesheet: css.Stylesheet | undefined = undefined;
const cssLanguageService = sharedLs.getCssLs(lang);
if (cssLanguageService) {
stylesheet = cssLanguageService.parseStylesheet(document);
findLinks(cssLanguageService, document, stylesheet);
const cssLs = sharedLs.getCssLs(lang);
if (cssLs) {
stylesheet = cssLs.parseStylesheet(document);
findLinks(cssLs, document, stylesheet);
}
documents.push({
textDocument: document,
Expand Down

0 comments on commit 7df5705

Please sign in to comment.