diff --git a/packages/language-server/src/plugins/typescript/features/CompletionProvider.ts b/packages/language-server/src/plugins/typescript/features/CompletionProvider.ts index 56ebdd059..9ade57549 100644 --- a/packages/language-server/src/plugins/typescript/features/CompletionProvider.ts +++ b/packages/language-server/src/plugins/typescript/features/CompletionProvider.ts @@ -14,7 +14,7 @@ import { mapCompletionItemToOriginal, mapRangeToOriginal, } from '../../../lib/documents'; -import { isNotNullOrUndefined, pathToUrl } from '../../../utils'; +import { pathToUrl } from '../../../utils'; import { AppCompletionItem, AppCompletionList, CompletionsProvider } from '../../interfaces'; import { SvelteSnapshotFragment } from '../DocumentSnapshot'; import { LSAndTSDocResolver } from '../LSAndTSDocResolver'; @@ -92,27 +92,18 @@ export class CompletionsProviderImpl implements CompletionsProvider - this.toCompletionItem(fragment, comp, pathToUrl(tsDoc.filePath), position), - ) - .filter(isNotNullOrUndefined) + .map((comp) => this.toCompletionItem(comp, pathToUrl(tsDoc.filePath), position)) .map((comp) => mapCompletionItemToOriginal(fragment, comp)); return CompletionList.create(completionItems, !!tsDoc.parserError); } private toCompletionItem( - fragment: SvelteSnapshotFragment, comp: ts.CompletionEntry, uri: string, position: Position, - ): AppCompletionItem | null { - const result = this.getCompletionLabelAndInsert(fragment, comp); - if (!result) { - return null; - } - - const { label, insertText, isSvelteComp } = result; + ): AppCompletionItem { + const { label, insertText, isSvelteComp } = this.getCompletionLabelAndInsert(comp); return { label, @@ -131,22 +122,11 @@ export class CompletionsProviderImpl implements CompletionsProvider, @@ -260,10 +225,6 @@ export class CompletionsProviderImpl implements CompletionsProvider `import ${this.changeSvelteComponentName(componentMatch)} from `, - ); - } - - private changeSvelteComponentName(name: string) { - const newName = name.replace(/(\w+)Svelte$/, '$1'); - // make sure first letter is uppercase - return newName[0].toUpperCase() + newName.substr(1); - } } const beginOfDocumentRange = Range.create(Position.create(0, 0), Position.create(0, 0));