diff --git a/packages/typecheck/src/cli.ts b/packages/typecheck/src/cli.ts index 5b6075d3..bf7c26e1 100644 --- a/packages/typecheck/src/cli.ts +++ b/packages/typecheck/src/cli.ts @@ -62,8 +62,8 @@ function formatLocation( start: TS.server.protocol.Location, ): string { const relativeFileName = convertToRelativePath(fileName) - const line = start.line + 1 - const column = start.offset + 1 + const line = start.line + const column = start.offset let output = '' output += chalk.cyan(relativeFileName) diff --git a/packages/typescript-plugin-vue/src/contracts/TypeScript.ts b/packages/typescript-plugin-vue/src/contracts/TypeScript.ts index 475924f2..cb569e34 100644 --- a/packages/typescript-plugin-vue/src/contracts/TypeScript.ts +++ b/packages/typescript-plugin-vue/src/contracts/TypeScript.ts @@ -4,11 +4,7 @@ import type { TS_LANGUAGE_SERVICE } from '../constants' export { TypeScript } export type TSLanguageService = TypeScript.LanguageService export type TSLanguageServiceHost = TypeScript.LanguageServiceHost -export type TSProject = TypeScript.server.Project & { - getParsedCommandLine?( - fileName: string, - ): TypeScript.ParsedCommandLine | undefined -} +export type TSProject = TypeScript.server.Project export type TSServerHost = TypeScript.server.ServerHost export interface ExtendedTSLanguageService extends TSLanguageService { [TS_LANGUAGE_SERVICE](): TSLanguageService diff --git a/packages/typescript-plugin-vue/src/features/TemplateCompletionsService.ts b/packages/typescript-plugin-vue/src/features/TemplateCompletionsService.ts deleted file mode 100644 index 8f2c304c..00000000 --- a/packages/typescript-plugin-vue/src/features/TemplateCompletionsService.ts +++ /dev/null @@ -1,129 +0,0 @@ -import { getComponentName } from '@vuedx/shared' -import { - ElementNode, - findTemplateNodeAt, - isElementNode, -} from '@vuedx/template-ast-types' -import { inject, injectable } from 'inversify' -import * as Path from 'path' -import type { CompletionItem, Range } from 'vscode-languageserver-types' -import { FilesystemService } from '../services/FilesystemService' -import { LoggerService } from '../services/LoggerService' -import { TypescriptContextService } from '../services/TypescriptContextService' - -@injectable() -export class TemplateCompletionsService { - private readonly logger = LoggerService.getLogger('Completions') - private readonly cache = new Map() - - constructor( - @inject(TypescriptContextService) - private readonly ts: TypescriptContextService, - @inject(FilesystemService) - private readonly fs: FilesystemService, - ) { - this.logger.debug('TepmlateCompletion') - } - - public getLocalComponents( - fileName: string, - position: number, - ): CompletionItem[] | undefined { - const vueFile = this.fs.getVueFile(fileName) - const program = this.ts.service.getProgram() - const tsProject = this.ts.getProjectFor(fileName) - if (program == null || tsProject == null || vueFile == null) { - return undefined - } - const key = `components:${fileName}:${tsProject.getScriptVersion( - fileName, - )}:${position}` - if (this.cache.has(key)) return this.cache.get(key) - - const dir = Path.posix.dirname(fileName) - - const content = vueFile.getText() - const openTagIndex = content.substr(0, position).lastIndexOf('<') - if (openTagIndex < 0) return [] - const lastTag = content.substring(openTagIndex, position) - if (/[\s\n]/.test(lastTag)) return [] - const isClosingTag = lastTag.startsWith(' { - if (isElementNode(node)) { - const tag = `` - completions.push({ - label: tag, - kind: 1, - preselect: true, - sortText: '0', - textEdit: { - range: replacementRange, - newText: tag, - }, - }) - } - }) - } - } else { - // const { tagCase } = this.ts.getVueProjectFor( - // fileName, - // ).config.preferences.template - - program.getSourceFiles().forEach(({ fileName }) => { - if (!this.fs.isVueFile(fileName)) return - const sortText = this.getRelativeFileName(dir, fileName) - const name = getComponentName(fileName) - - // TODO: Support