Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
refactor: move common TS logic to new package
@volar/vue-typescript
(…
…#1004) * refactor: ignore css stylesheet from imports * refactor: get stylesheet on-demand and move out from source map * refactor: get html document on-demand and move out from source map * refactor: get json document on-demand and move out from source map * refactor: get pug document on-demand and move out from source map * refactor: reduce sub-types of source maps * refactor: calculate css class names on-demand * refactor: reduce depends pass * refactor: split context type * refactor: dependency injection for SFC template compile * refactor: remove context depend in vue document * refactor: rename runtime context type name * refactor: split ts plugin / ts program proxy logic * refactor: move ts plugin / ts program project logic into vue-tsc and typescript-vue-plugin * refactor: remove basic TS logic to `@volar/vue-typescript` * fix: project references missing
- Loading branch information
1 parent
edcff74
commit 01adff9
Showing
82 changed files
with
1,741 additions
and
1,555 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
4 changes: 2 additions & 2 deletions
4
...e-vue-languageservice/src/tsPluginApis.ts → packages/typescript-vue-plugin/src/apis.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
77 changes: 77 additions & 0 deletions
77
packages/vscode-vue-languageservice/src/documentService.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,77 @@ | ||
import { TextDocument } from 'vscode-languageserver-textdocument'; | ||
import * as autoClosingTags from './services/autoClosingTags'; | ||
import * as autoCreateQuotes from './services/autoCreateQuotes'; | ||
import * as autoWrapBrackets from './services/autoWrapParentheses'; | ||
import * as colorPresentations from './services/colorPresentation'; | ||
import * as documentColor from './services/documentColor'; | ||
import * as documentSymbol from './services/documentSymbol'; | ||
import * as foldingRanges from './services/foldingRanges'; | ||
import * as formatting from './services/formatting'; | ||
import * as linkedEditingRanges from './services/linkedEditingRange'; | ||
import * as selectionRanges from './services/selectionRanges'; | ||
import { createSourceFile, SourceFile } from '@volar/vue-typescript'; | ||
import { DocumentServiceRuntimeContext, LanguageServiceHost } from './types'; | ||
import { createBasicRuntime } from '@volar/vue-typescript'; | ||
|
||
import type * as _0 from 'vscode-languageserver-protocol'; | ||
|
||
export interface DocumentService extends ReturnType<typeof getDocumentService> { } | ||
|
||
export function getDocumentService( | ||
{ typescript: ts }: { typescript: typeof import('typescript/lib/tsserverlibrary') }, | ||
getPreferences: LanguageServiceHost['getPreferences'], | ||
getFormatOptions: LanguageServiceHost['getFormatOptions'], | ||
formatters: Parameters<typeof formatting['register']>[3], | ||
) { | ||
const vueDocuments = new WeakMap<TextDocument, SourceFile>(); | ||
const services = createBasicRuntime(); | ||
const context: DocumentServiceRuntimeContext = { | ||
compilerOptions: {}, | ||
typescript: ts, | ||
...services, | ||
getVueDocument, | ||
}; | ||
return { | ||
doFormatting: formatting.register(context, getPreferences, getFormatOptions, formatters), | ||
getFoldingRanges: foldingRanges.register(context, getPreferences, getFormatOptions), | ||
getSelectionRanges: selectionRanges.register(context, getPreferences, getFormatOptions), | ||
doQuoteComplete: autoCreateQuotes.register(context), | ||
doTagComplete: autoClosingTags.register(context), | ||
doParentheseWrap: autoWrapBrackets.register(context), | ||
findLinkedEditingRanges: linkedEditingRanges.register(context), | ||
findDocumentSymbols: documentSymbol.register(context, getPreferences, getFormatOptions), | ||
findDocumentColors: documentColor.register(context), | ||
getColorPresentations: colorPresentations.register(context), | ||
} | ||
function getVueDocument(document: TextDocument) { | ||
|
||
if (document.languageId !== 'vue') | ||
return; | ||
|
||
const cacheVueDoc = vueDocuments.get(document); | ||
if (cacheVueDoc) { | ||
|
||
const oldText = cacheVueDoc.getTextDocument().getText(); | ||
const newText = document.getText(); | ||
|
||
if (oldText.length !== newText.length || oldText !== newText) { | ||
cacheVueDoc.update(document.getText(), document.version.toString()); | ||
} | ||
|
||
return cacheVueDoc; | ||
} | ||
const vueDoc = createSourceFile( | ||
document.uri, | ||
document.getText(), | ||
document.version.toString(), | ||
context.htmlLs, | ||
context.compileTemplate, | ||
context.compilerOptions, | ||
context.typescript, | ||
context.getCssVBindRanges, | ||
context.getCssClasses, | ||
); | ||
vueDocuments.set(document, vueDoc); | ||
return vueDoc; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.