diff --git a/src/harness/fourslash.ts b/src/harness/fourslash.ts index 2b4373d79fa..41471ed9a03 100644 --- a/src/harness/fourslash.ts +++ b/src/harness/fourslash.ts @@ -598,38 +598,6 @@ namespace FourSlash { } } - public verifyImportModuleCompletionListItemsCountIsGreaterThan(count: number, negative: boolean) { - const completions = this.getImportModuleCompletionListAtCaret(); - const itemsCount = completions.entries.length; - - if (negative) { - if (itemsCount > count) { - this.raiseError(`Expected import module completion list items count to not be greater than ${count}, but is actually ${itemsCount}`); - } - } - else { - if (itemsCount <= count) { - this.raiseError(`Expected import module completion list items count to be greater than ${count}, but is actually ${itemsCount}`); - } - } - } - - public verifyImportModuleCompletionListIsEmpty(negative: boolean) { - const completions = this.getImportModuleCompletionListAtCaret(); - if ((!completions || completions.entries.length === 0) && negative) { - this.raiseError("Completion list is empty at caret at position " + this.activeFile.fileName + " " + this.currentCaretPosition); - } - else if (completions && completions.entries.length !== 0 && !negative) { - let errorMsg = "\n" + "Completion List contains: [" + completions.entries[0].name; - for (let i = 1; i < completions.entries.length; i++) { - errorMsg += ", " + completions.entries[i].name; - } - errorMsg += "]\n"; - - this.raiseError("Completion list is not empty at caret at position " + this.activeFile.fileName + " " + this.currentCaretPosition + errorMsg); - } - } - public verifyCompletionListStartsWithItemsInOrder(items: string[]): void { if (items.length === 0) { return; @@ -701,10 +669,10 @@ namespace FourSlash { } } - public verifyCompletionListContains(symbol: string, text?: string, documentation?: string, kind?: string) { + public verifyCompletionListContains(symbol: string, text?: string, documentation?: string, kind?: string, spanIndex?: number) { const completions = this.getCompletionListAtCaret(); if (completions) { - this.assertItemInCompletionList(completions.entries, symbol, text, documentation, kind); + this.assertItemInCompletionList(completions.entries, symbol, text, documentation, kind, spanIndex); } else { this.raiseError(`No completions at position '${this.currentCaretPosition}' when looking for '${symbol}'.`); @@ -720,25 +688,32 @@ namespace FourSlash { * @param expectedText the text associated with the symbol * @param expectedDocumentation the documentation text associated with the symbol * @param expectedKind the kind of symbol (see ScriptElementKind) + * @param spanIndex the index of the range that the completion item's replacement text span should match */ - public verifyCompletionListDoesNotContain(symbol: string, expectedText?: string, expectedDocumentation?: string, expectedKind?: string) { + public verifyCompletionListDoesNotContain(symbol: string, expectedText?: string, expectedDocumentation?: string, expectedKind?: string, spanIndex?: number) { const that = this; + let replacementSpan: ts.TextSpan; + if (spanIndex !== undefined) { + replacementSpan = this.getTextSpanForRangeAtIndex(spanIndex); + } + function filterByTextOrDocumentation(entry: ts.CompletionEntry) { const details = that.getCompletionEntryDetails(entry.name); const documentation = ts.displayPartsToString(details.documentation); const text = ts.displayPartsToString(details.displayParts); - if (expectedText && expectedDocumentation) { - return (documentation === expectedDocumentation && text === expectedText) ? true : false; + + // If any of the expected values are undefined, assume that users don't + // care about them. + if (replacementSpan && !TestState.textSpansEqual(replacementSpan, entry.replacementSpan)) { + return false; } - else if (expectedText && !expectedDocumentation) { - return text === expectedText ? true : false; + else if (expectedText && text !== expectedText) { + return false; } - else if (expectedDocumentation && !expectedText) { - return documentation === expectedDocumentation ? true : false; + else if (expectedDocumentation && documentation !== expectedDocumentation) { + return false; } - // Because expectedText and expectedDocumentation are undefined, we assume that - // users don"t care to compare them so we will treat that entry as if the entry has matching text and documentation - // and keep it in the list of filtered entry. + return true; } @@ -762,49 +737,15 @@ namespace FourSlash { if (expectedKind) { error += "Expected kind: " + expectedKind + " to equal: " + filterCompletions[0].kind + "."; } + if (replacementSpan) { + const spanText = filterCompletions[0].replacementSpan ? stringify(filterCompletions[0].replacementSpan) : undefined; + error += "Expected replacement span: " + stringify(replacementSpan) + " to equal: " + spanText + "."; + } this.raiseError(error); } } } - public verifyImportModuleCompletionListContains(symbol: string, rangeIndex?: number) { - const completions = this.getImportModuleCompletionListAtCaret(); - if (completions) { - const completion = ts.forEach(completions.entries, completion => completion.name === symbol ? completion : undefined); - if (!completion) { - const itemsString = completions.entries.map(item => item.name).join(",\n"); - this.raiseError(`Expected "${symbol}" to be in list [${itemsString}]`); - } - else if (rangeIndex !== undefined) { - const ranges = this.getRanges(); - if (ranges && ranges.length > rangeIndex) { - const range = ranges[rangeIndex]; - - const start = completion.replacementSpan.start; - const end = start + completion.replacementSpan.length; - if (range.start !== start || range.end !== end) { - this.raiseError(`Expected completion span for '${symbol}', ${stringify(completion.replacementSpan)}, to cover range ${stringify(range)}`); - } - } - else { - this.raiseError(`Expected completion span for '${symbol}' to cover range at index ${rangeIndex}, but no range was found at that index`); - } - } - } - else { - this.raiseError(`No import module completions at position '${this.currentCaretPosition}' when looking for '${symbol}'.`); - } - } - - public verifyImportModuleCompletionListDoesNotContain(symbol: string) { - const completions = this.getImportModuleCompletionListAtCaret(); - if (completions) { - if (ts.forEach(completions.entries, completion => completion.name === symbol)) { - this.raiseError(`Import module completion list did contain ${symbol}`); - } - } - } - public verifyCompletionEntryDetails(entryName: string, expectedText: string, expectedDocumentation?: string, kind?: string) { const details = this.getCompletionEntryDetails(entryName); @@ -891,10 +832,6 @@ namespace FourSlash { return this.languageService.getCompletionsAtPosition(this.activeFile.fileName, this.currentCaretPosition); } - private getImportModuleCompletionListAtCaret() { - return this.languageService.getCompletionsAtPosition(this.activeFile.fileName, this.currentCaretPosition); - } - private getCompletionEntryDetails(entryName: string) { return this.languageService.getCompletionEntryDetails(this.activeFile.fileName, this.currentCaretPosition, entryName); } @@ -2241,7 +2178,7 @@ namespace FourSlash { return text.substring(startPos, endPos); } - private assertItemInCompletionList(items: ts.CompletionEntry[], name: string, text?: string, documentation?: string, kind?: string) { + private assertItemInCompletionList(items: ts.CompletionEntry[], name: string, text?: string, documentation?: string, kind?: string, spanIndex?: number) { for (let i = 0; i < items.length; i++) { const item = items[i]; if (item.name === name) { @@ -2260,6 +2197,11 @@ namespace FourSlash { assert.equal(item.kind, kind, this.assertionMessageAtLastKnownMarker("completion item kind for " + name)); } + if (spanIndex !== undefined) { + const span = this.getTextSpanForRangeAtIndex(spanIndex); + assert.isTrue(TestState.textSpansEqual(span, item.replacementSpan), this.assertionMessageAtLastKnownMarker(stringify(span) + " does not equal " + stringify(item.replacementSpan) + " replacement span for " + name)); + } + return; } } @@ -2316,6 +2258,17 @@ namespace FourSlash { return `line ${(pos.line + 1)}, col ${pos.character}`; } + private getTextSpanForRangeAtIndex(index: number): ts.TextSpan { + const ranges = this.getRanges(); + if (ranges && ranges.length > index) { + const range = ranges[index]; + return { start: range.start, length: range.end - range.start }; + } + else { + this.raiseError("Supplied span index: " + index + " does not exist in range list of size: " + (ranges ? 0 : ranges.length)); + } + } + public getMarkerByName(markerName: string) { const markerPos = this.testData.markerPositions[markerName]; if (markerPos === undefined) { @@ -2339,6 +2292,10 @@ namespace FourSlash { public resetCancelled(): void { this.cancellationToken.resetCancelled(); } + + private static textSpansEqual(a: ts.TextSpan, b: ts.TextSpan) { + return a && b && a.start === b.start && a.length === b.length; + } } export function runFourSlashTest(basePath: string, testType: FourSlashTestType, fileName: string) { @@ -2909,12 +2866,12 @@ namespace FourSlashInterface { // Verifies the completion list contains the specified symbol. The // completion list is brought up if necessary - public completionListContains(symbol: string, text?: string, documentation?: string, kind?: string) { + public completionListContains(symbol: string, text?: string, documentation?: string, kind?: string, spanIndex?: number) { if (this.negative) { - this.state.verifyCompletionListDoesNotContain(symbol, text, documentation, kind); + this.state.verifyCompletionListDoesNotContain(symbol, text, documentation, kind, spanIndex); } else { - this.state.verifyCompletionListContains(symbol, text, documentation, kind); + this.state.verifyCompletionListContains(symbol, text, documentation, kind, spanIndex); } } @@ -2924,23 +2881,6 @@ namespace FourSlashInterface { this.state.verifyCompletionListItemsCountIsGreaterThan(count, this.negative); } - public importModuleCompletionListContains(symbol: string, rangeIndex?: number): void { - if (this.negative) { - this.state.verifyImportModuleCompletionListDoesNotContain(symbol); - } - else { - this.state.verifyImportModuleCompletionListContains(symbol, rangeIndex); - } - } - - public importModuleCompletionListItemsCountIsGreaterThan(count: number): void { - this.state.verifyImportModuleCompletionListItemsCountIsGreaterThan(count, this.negative); - } - - public importModuleCompletionListIsEmpty(): void { - this.state.verifyImportModuleCompletionListIsEmpty(this.negative); - } - public assertHasRanges(ranges: FourSlash.Range[]) { assert(ranges.length !== 0, "Array of ranges is expected to be non-empty"); } diff --git a/src/services/services.ts b/src/services/services.ts index 66e450bf830..0bbaa9b5c3e 100644 --- a/src/services/services.ts +++ b/src/services/services.ts @@ -4236,9 +4236,8 @@ namespace ts { const sourceFile = getValidSourceFile(fileName); - const importCompletionInfo = getImportModuleCompletionsAtPosition(fileName, position); - if (importCompletionInfo && importCompletionInfo.entries.length !== 0) { - return importCompletionInfo; + if (isInReferenceComment(sourceFile, position)) { + return getTripleSlashReferenceCompletion(sourceFile, position); } if (isInString(sourceFile, position)) { @@ -4410,6 +4409,13 @@ namespace ts { // a['/*completion position*/'] return getStringLiteralCompletionEntriesFromElementAccess(node.parent); } + else if (node.parent.kind === SyntaxKind.ImportDeclaration || isExpressionOfExternalModuleImportEqualsDeclaration(node) || isRequireCall(node.parent, false)) { + // Get all known external module names or complete a path to a module + // i.e. import * as ns from "/*completion position*/"; + // import x = require("/*completion position*/"); + // var y = require("/*completion position*/"); + return getStringLiteralCompletionEntriesFromModuleNames(node); + } else { const argumentInfo = SignatureHelp.getContainingArgumentInfo(node, position, sourceFile); if (argumentInfo) { @@ -4502,55 +4508,35 @@ namespace ts { } } } - } - function getImportModuleCompletionsAtPosition(fileName: string, position: number): CompletionInfo { - synchronizeHostData(); - - const sourceFile = getValidSourceFile(fileName); - if (isInReferenceComment(sourceFile, position)) { - return getTripleSlashReferenceCompletion(sourceFile, position); - } - else if (isInString(sourceFile, position)) { - const node = findPrecedingToken(position, sourceFile); - if (!node || node.kind !== SyntaxKind.StringLiteral) { - return undefined; - } - - if (node.parent.kind === SyntaxKind.ImportDeclaration || isExpressionOfExternalModuleImportEqualsDeclaration(node) || isRequireCall(node.parent, false)) { - // Get all known external module names or complete a path to a module - return { - isMemberCompletion: false, - isNewIdentifierLocation: true, - entries: getStringLiteralCompletionEntriesFromModuleNames(node) - }; - } - } - - return undefined; - - function getStringLiteralCompletionEntriesFromModuleNames(node: StringLiteral) { + function getStringLiteralCompletionEntriesFromModuleNames(node: StringLiteral): CompletionInfo { const literalValue = normalizeSlashes(node.text); const scriptPath = node.getSourceFile().path; const scriptDirectory = getDirectoryPath(scriptPath); const span = getDirectoryFragmentTextSpan((node).text, node.getStart() + 1); + let entries: CompletionEntry[]; if (isPathRelativeToScript(literalValue) || isRootedDiskPath(literalValue)) { const compilerOptions = program.getCompilerOptions(); if (compilerOptions.rootDirs) { - return getCompletionEntriesForDirectoryFragmentWithRootDirs( + entries = getCompletionEntriesForDirectoryFragmentWithRootDirs( compilerOptions.rootDirs, literalValue, scriptDirectory, getSupportedExtensions(program.getCompilerOptions()), /*includeExtensions*/false, span, scriptPath); } else { - return getCompletionEntriesForDirectoryFragment( + entries = getCompletionEntriesForDirectoryFragment( literalValue, scriptDirectory, getSupportedExtensions(program.getCompilerOptions()), /*includeExtensions*/false, span, scriptPath); } } else { // Check for node modules - return getCompletionEntriesForNonRelativeModules(literalValue, scriptDirectory, span); + entries = getCompletionEntriesForNonRelativeModules(literalValue, scriptDirectory, span); } + return { + isMemberCompletion: false, + isNewIdentifierLocation: true, + entries + }; } /** diff --git a/tests/cases/fourslash/completionForStringLiteralImport1.ts b/tests/cases/fourslash/completionForStringLiteralImport1.ts index 482726f6305..4cdee889538 100644 --- a/tests/cases/fourslash/completionForStringLiteralImport1.ts +++ b/tests/cases/fourslash/completionForStringLiteralImport1.ts @@ -21,13 +21,13 @@ //// export var x = 9; goTo.marker("0"); -verify.importModuleCompletionListContains("someFile1", 0); +verify.completionListContains("someFile1", undefined, undefined, undefined, 0); goTo.marker("1"); -verify.importModuleCompletionListContains("someFile2", 1); +verify.completionListContains("someFile2", undefined, undefined, undefined, 1); goTo.marker("2"); -verify.importModuleCompletionListContains("some-module", 2); +verify.completionListContains("some-module", undefined, undefined, undefined, 2); goTo.marker("3"); -verify.importModuleCompletionListContains("fourslash", 3); \ No newline at end of file +verify.completionListContains("fourslash", undefined, undefined, undefined, 3); \ No newline at end of file diff --git a/tests/cases/fourslash/completionForStringLiteralImport2.ts b/tests/cases/fourslash/completionForStringLiteralImport2.ts index 43896f1f392..25de3d2240a 100644 --- a/tests/cases/fourslash/completionForStringLiteralImport2.ts +++ b/tests/cases/fourslash/completionForStringLiteralImport2.ts @@ -21,13 +21,13 @@ //// export var x = 9; goTo.marker("0"); -verify.importModuleCompletionListContains("someFile.ts", 0); +verify.completionListContains("someFile.ts", undefined, undefined, undefined, 0); goTo.marker("1"); -verify.importModuleCompletionListContains("some-module", 1); +verify.completionListContains("some-module", undefined, undefined, undefined, 1); goTo.marker("2"); -verify.importModuleCompletionListContains("someOtherFile.ts", 2); +verify.completionListContains("someOtherFile.ts", undefined, undefined, undefined, 2); goTo.marker("3"); -verify.importModuleCompletionListContains("some-module", 3); \ No newline at end of file +verify.completionListContains("some-module", undefined, undefined, undefined, 3); \ No newline at end of file diff --git a/tests/cases/fourslash/completionForStringLiteralNonrelativeImport1.ts b/tests/cases/fourslash/completionForStringLiteralNonrelativeImport1.ts index d6f38431ce1..c0e5ebbcd90 100644 --- a/tests/cases/fourslash/completionForStringLiteralNonrelativeImport1.ts +++ b/tests/cases/fourslash/completionForStringLiteralNonrelativeImport1.ts @@ -45,19 +45,19 @@ const kinds = ["import_as", "import_equals", "require"]; for (const kind of kinds) { goTo.marker(kind + "0"); - verify.importModuleCompletionListContains("fake-module"); - verify.importModuleCompletionListContains("fake-module-dev"); - verify.not.importModuleCompletionListItemsCountIsGreaterThan(2); + verify.completionListContains("fake-module"); + verify.completionListContains("fake-module-dev"); + verify.not.completionListItemsCountIsGreaterThan(2); goTo.marker(kind + "1"); - verify.importModuleCompletionListContains("index"); - verify.importModuleCompletionListContains("ts"); - verify.importModuleCompletionListContains("dts"); - verify.importModuleCompletionListContains("tsx"); - verify.not.importModuleCompletionListItemsCountIsGreaterThan(4); + verify.completionListContains("index"); + verify.completionListContains("ts"); + verify.completionListContains("dts"); + verify.completionListContains("tsx"); + verify.not.completionListItemsCountIsGreaterThan(4); goTo.marker(kind + "2"); - verify.importModuleCompletionListContains("fake-module"); - verify.importModuleCompletionListContains("fake-module-dev"); - verify.not.importModuleCompletionListItemsCountIsGreaterThan(2); + verify.completionListContains("fake-module"); + verify.completionListContains("fake-module-dev"); + verify.not.completionListItemsCountIsGreaterThan(2); } \ No newline at end of file diff --git a/tests/cases/fourslash/completionForStringLiteralNonrelativeImport10.ts b/tests/cases/fourslash/completionForStringLiteralNonrelativeImport10.ts index aa9fd976644..24a323bc6e5 100644 --- a/tests/cases/fourslash/completionForStringLiteralNonrelativeImport10.ts +++ b/tests/cases/fourslash/completionForStringLiteralNonrelativeImport10.ts @@ -28,8 +28,8 @@ const kinds = ["import_as", "import_equals", "require"]; for (const kind of kinds) { goTo.marker(kind + "0"); - verify.importModuleCompletionListIsEmpty(); + verify.completionListIsEmpty(); goTo.marker(kind + "1"); - verify.importModuleCompletionListIsEmpty(); + verify.completionListIsEmpty(); } \ No newline at end of file diff --git a/tests/cases/fourslash/completionForStringLiteralNonrelativeImport11.ts b/tests/cases/fourslash/completionForStringLiteralNonrelativeImport11.ts index 70d39182a8a..7b81c4da106 100644 --- a/tests/cases/fourslash/completionForStringLiteralNonrelativeImport11.ts +++ b/tests/cases/fourslash/completionForStringLiteralNonrelativeImport11.ts @@ -28,11 +28,11 @@ const kinds = ["import_as", "import_equals", "require"]; for (const kind of kinds) { goTo.marker(kind + "0"); - verify.importModuleCompletionListContains("module"); - verify.not.importModuleCompletionListItemsCountIsGreaterThan(1); + verify.completionListContains("module"); + verify.not.completionListItemsCountIsGreaterThan(1); goTo.marker(kind + "1"); - verify.importModuleCompletionListContains("index"); - verify.not.importModuleCompletionListItemsCountIsGreaterThan(1); + verify.completionListContains("index"); + verify.not.completionListItemsCountIsGreaterThan(1); } diff --git a/tests/cases/fourslash/completionForStringLiteralNonrelativeImport12.ts b/tests/cases/fourslash/completionForStringLiteralNonrelativeImport12.ts index 92db8d5a50e..ed202d68ec1 100644 --- a/tests/cases/fourslash/completionForStringLiteralNonrelativeImport12.ts +++ b/tests/cases/fourslash/completionForStringLiteralNonrelativeImport12.ts @@ -20,9 +20,9 @@ const kinds = ["import_as", "import_equals", "require"]; for (const kind of kinds) { goTo.marker(kind + "0"); - verify.importModuleCompletionListContains("module"); - verify.importModuleCompletionListContains("dev-module"); - verify.importModuleCompletionListContains("optional-module"); - verify.importModuleCompletionListContains("peer-module"); - verify.not.importModuleCompletionListItemsCountIsGreaterThan(4); + verify.completionListContains("module"); + verify.completionListContains("dev-module"); + verify.completionListContains("optional-module"); + verify.completionListContains("peer-module"); + verify.not.completionListItemsCountIsGreaterThan(4); } diff --git a/tests/cases/fourslash/completionForStringLiteralNonrelativeImport2.ts b/tests/cases/fourslash/completionForStringLiteralNonrelativeImport2.ts index bc2529e86f9..bac5c54ff23 100644 --- a/tests/cases/fourslash/completionForStringLiteralNonrelativeImport2.ts +++ b/tests/cases/fourslash/completionForStringLiteralNonrelativeImport2.ts @@ -31,7 +31,7 @@ const kinds = ["import_as", "import_equals", "require"]; for (const kind of kinds) { goTo.marker(kind + "0"); - verify.importModuleCompletionListContains("repeated"); - verify.importModuleCompletionListContains("other"); - verify.not.importModuleCompletionListItemsCountIsGreaterThan(2); + verify.completionListContains("repeated"); + verify.completionListContains("other"); + verify.not.completionListItemsCountIsGreaterThan(2); } diff --git a/tests/cases/fourslash/completionForStringLiteralNonrelativeImport3.ts b/tests/cases/fourslash/completionForStringLiteralNonrelativeImport3.ts index 9b1fd451185..d2103f6f10c 100644 --- a/tests/cases/fourslash/completionForStringLiteralNonrelativeImport3.ts +++ b/tests/cases/fourslash/completionForStringLiteralNonrelativeImport3.ts @@ -31,8 +31,8 @@ const kinds = ["import_as", "import_equals", "require"]; for (const kind of kinds) { goTo.marker(kind + "0"); - verify.importModuleCompletionListContains("ts"); - verify.importModuleCompletionListContains("tsx"); - verify.importModuleCompletionListContains("dts"); - verify.not.importModuleCompletionListItemsCountIsGreaterThan(3); + verify.completionListContains("ts"); + verify.completionListContains("tsx"); + verify.completionListContains("dts"); + verify.not.completionListItemsCountIsGreaterThan(3); } diff --git a/tests/cases/fourslash/completionForStringLiteralNonrelativeImport4.ts b/tests/cases/fourslash/completionForStringLiteralNonrelativeImport4.ts index b9be9f90213..b95fd96f380 100644 --- a/tests/cases/fourslash/completionForStringLiteralNonrelativeImport4.ts +++ b/tests/cases/fourslash/completionForStringLiteralNonrelativeImport4.ts @@ -27,8 +27,8 @@ const kinds = ["import_as", "import_equals", "require"]; for (const kind of kinds) { goTo.marker(kind + "0"); - verify.importModuleCompletionListContains("fake-module"); - verify.importModuleCompletionListContains("fake-module2"); - verify.importModuleCompletionListContains("fake-module3"); - verify.not.importModuleCompletionListItemsCountIsGreaterThan(3); + verify.completionListContains("fake-module"); + verify.completionListContains("fake-module2"); + verify.completionListContains("fake-module3"); + verify.not.completionListItemsCountIsGreaterThan(3); } \ No newline at end of file diff --git a/tests/cases/fourslash/completionForStringLiteralNonrelativeImport5.ts b/tests/cases/fourslash/completionForStringLiteralNonrelativeImport5.ts index 4afa5854bf8..c8c9a18ff85 100644 --- a/tests/cases/fourslash/completionForStringLiteralNonrelativeImport5.ts +++ b/tests/cases/fourslash/completionForStringLiteralNonrelativeImport5.ts @@ -26,14 +26,14 @@ const kinds = ["import_as", "import_equals", "require"]; for (const kind of kinds) { goTo.marker(kind + "0"); - verify.importModuleCompletionListContains("ambientModule"); - verify.importModuleCompletionListContains("otherAmbientModule"); - verify.importModuleCompletionListContains("otherOtherAmbientModule"); - verify.not.importModuleCompletionListItemsCountIsGreaterThan(3); + verify.completionListContains("ambientModule"); + verify.completionListContains("otherAmbientModule"); + verify.completionListContains("otherOtherAmbientModule"); + verify.not.completionListItemsCountIsGreaterThan(3); goTo.marker(kind + "1"); - verify.importModuleCompletionListContains("ambientModule"); - verify.not.importModuleCompletionListItemsCountIsGreaterThan(1); + verify.completionListContains("ambientModule"); + verify.not.completionListItemsCountIsGreaterThan(1); } diff --git a/tests/cases/fourslash/completionForStringLiteralNonrelativeImport7.ts b/tests/cases/fourslash/completionForStringLiteralNonrelativeImport7.ts index eca5a3e5412..57ba6e440cf 100644 --- a/tests/cases/fourslash/completionForStringLiteralNonrelativeImport7.ts +++ b/tests/cases/fourslash/completionForStringLiteralNonrelativeImport7.ts @@ -24,7 +24,7 @@ const kinds = ["import_as", "import_equals", "require"]; for (const kind of kinds) { goTo.marker(kind + "0"); - verify.importModuleCompletionListContains("module"); - verify.importModuleCompletionListContains("module-from-node"); - verify.not.importModuleCompletionListItemsCountIsGreaterThan(2); + verify.completionListContains("module"); + verify.completionListContains("module-from-node"); + verify.not.completionListItemsCountIsGreaterThan(2); } diff --git a/tests/cases/fourslash/completionForStringLiteralNonrelativeImport8.ts b/tests/cases/fourslash/completionForStringLiteralNonrelativeImport8.ts index 54893991432..603e8d1104d 100644 --- a/tests/cases/fourslash/completionForStringLiteralNonrelativeImport8.ts +++ b/tests/cases/fourslash/completionForStringLiteralNonrelativeImport8.ts @@ -45,11 +45,11 @@ const kinds = ["import_as", "import_equals", "require"]; for (const kind of kinds) { goTo.marker(kind + "0"); - verify.importModuleCompletionListContains("0test"); + verify.completionListContains("0test"); goTo.marker(kind + "1"); - verify.importModuleCompletionListContains("1test"); + verify.completionListContains("1test"); goTo.marker(kind + "2"); - verify.importModuleCompletionListContains("2test"); + verify.completionListContains("2test"); } diff --git a/tests/cases/fourslash/completionForStringLiteralNonrelativeImport9.ts b/tests/cases/fourslash/completionForStringLiteralNonrelativeImport9.ts index bcdb731d1f1..8703c608462 100644 --- a/tests/cases/fourslash/completionForStringLiteralNonrelativeImport9.ts +++ b/tests/cases/fourslash/completionForStringLiteralNonrelativeImport9.ts @@ -30,7 +30,7 @@ const kinds = ["import_as", "import_equals", "require"]; for (const kind of kinds) { goTo.marker(kind + "0"); - verify.importModuleCompletionListContains("module1"); - verify.importModuleCompletionListContains("module2"); - verify.not.importModuleCompletionListItemsCountIsGreaterThan(2); + verify.completionListContains("module1"); + verify.completionListContains("module2"); + verify.not.completionListItemsCountIsGreaterThan(2); } diff --git a/tests/cases/fourslash/completionForStringLiteralNonrelativeImportTypings1.ts b/tests/cases/fourslash/completionForStringLiteralNonrelativeImportTypings1.ts index 9cf2af9c875..687103629e2 100644 --- a/tests/cases/fourslash/completionForStringLiteralNonrelativeImportTypings1.ts +++ b/tests/cases/fourslash/completionForStringLiteralNonrelativeImportTypings1.ts @@ -28,8 +28,8 @@ const kinds = ["types_ref", "import_as", "import_equals", "require"]; for (const kind of kinds) { goTo.marker(kind + "0"); - verify.importModuleCompletionListContains("module-x"); - verify.importModuleCompletionListContains("module-y"); - verify.importModuleCompletionListContains("module-z"); - verify.not.importModuleCompletionListItemsCountIsGreaterThan(3); + verify.completionListContains("module-x"); + verify.completionListContains("module-y"); + verify.completionListContains("module-z"); + verify.not.completionListItemsCountIsGreaterThan(3); } diff --git a/tests/cases/fourslash/completionForStringLiteralNonrelativeImportTypings2.ts b/tests/cases/fourslash/completionForStringLiteralNonrelativeImportTypings2.ts index 1452c6c1c61..12a4fcf243f 100644 --- a/tests/cases/fourslash/completionForStringLiteralNonrelativeImportTypings2.ts +++ b/tests/cases/fourslash/completionForStringLiteralNonrelativeImportTypings2.ts @@ -26,7 +26,7 @@ const kinds = ["types_ref", "import_as", "import_equals", "require"]; for (const kind of kinds) { goTo.marker(kind + "0"); - verify.importModuleCompletionListContains("module-x"); - verify.importModuleCompletionListContains("module-z"); - verify.not.importModuleCompletionListItemsCountIsGreaterThan(2); + verify.completionListContains("module-x"); + verify.completionListContains("module-z"); + verify.not.completionListItemsCountIsGreaterThan(2); } diff --git a/tests/cases/fourslash/completionForStringLiteralNonrelativeImportTypings3.ts b/tests/cases/fourslash/completionForStringLiteralNonrelativeImportTypings3.ts index f4a4dbaaa99..14cf71ad0dc 100644 --- a/tests/cases/fourslash/completionForStringLiteralNonrelativeImportTypings3.ts +++ b/tests/cases/fourslash/completionForStringLiteralNonrelativeImportTypings3.ts @@ -22,7 +22,7 @@ const kinds = ["types_ref", "import_as", "import_equals", "require"]; for (const kind of kinds) { goTo.marker(kind + "0"); - verify.importModuleCompletionListContains("module-x"); - verify.importModuleCompletionListContains("module-y"); - verify.not.importModuleCompletionListItemsCountIsGreaterThan(2); + verify.completionListContains("module-x"); + verify.completionListContains("module-y"); + verify.not.completionListItemsCountIsGreaterThan(2); } diff --git a/tests/cases/fourslash/completionForStringLiteralRelativeImport1.ts b/tests/cases/fourslash/completionForStringLiteralRelativeImport1.ts index 909e2c6b14d..3ba82fb0acf 100644 --- a/tests/cases/fourslash/completionForStringLiteralRelativeImport1.ts +++ b/tests/cases/fourslash/completionForStringLiteralRelativeImport1.ts @@ -47,24 +47,24 @@ const kinds = ["import_as", "import_equals", "require"]; for (const kind of kinds) { goTo.marker(kind + "0"); - verify.importModuleCompletionListIsEmpty(); + verify.completionListIsEmpty(); goTo.marker(kind + "1"); - verify.importModuleCompletionListContains("f1"); - verify.importModuleCompletionListContains("f2"); - verify.importModuleCompletionListContains("e1"); - verify.importModuleCompletionListContains("folder"); - verify.importModuleCompletionListContains("parentTest"); - verify.not.importModuleCompletionListItemsCountIsGreaterThan(5); + verify.completionListContains("f1"); + verify.completionListContains("f2"); + verify.completionListContains("e1"); + verify.completionListContains("folder"); + verify.completionListContains("parentTest"); + verify.not.completionListItemsCountIsGreaterThan(5); goTo.marker(kind + "2"); - verify.importModuleCompletionListContains("f3"); - verify.importModuleCompletionListContains("h1"); - verify.not.importModuleCompletionListItemsCountIsGreaterThan(2); + verify.completionListContains("f3"); + verify.completionListContains("h1"); + verify.not.completionListItemsCountIsGreaterThan(2); goTo.marker(kind + "3"); - verify.importModuleCompletionListContains("f4"); - verify.importModuleCompletionListContains("g1"); - verify.importModuleCompletionListContains("sub"); - verify.not.importModuleCompletionListItemsCountIsGreaterThan(3); + verify.completionListContains("f4"); + verify.completionListContains("g1"); + verify.completionListContains("sub"); + verify.not.completionListItemsCountIsGreaterThan(3); } \ No newline at end of file diff --git a/tests/cases/fourslash/completionForStringLiteralRelativeImport2.ts b/tests/cases/fourslash/completionForStringLiteralRelativeImport2.ts index 8c8cb405cd3..18a80ab3481 100644 --- a/tests/cases/fourslash/completionForStringLiteralRelativeImport2.ts +++ b/tests/cases/fourslash/completionForStringLiteralRelativeImport2.ts @@ -34,20 +34,20 @@ const kinds = ["import_as", "import_equals", "require"]; for (const kind of kinds) { goTo.marker(kind + "0"); - verify.importModuleCompletionListContains("f1"); - verify.importModuleCompletionListContains("f2"); - verify.importModuleCompletionListContains("f3"); - verify.importModuleCompletionListContains("f4"); - verify.importModuleCompletionListContains("e1"); - verify.importModuleCompletionListContains("e2"); - verify.not.importModuleCompletionListItemsCountIsGreaterThan(6); + verify.completionListContains("f1"); + verify.completionListContains("f2"); + verify.completionListContains("f3"); + verify.completionListContains("f4"); + verify.completionListContains("e1"); + verify.completionListContains("e2"); + verify.not.completionListItemsCountIsGreaterThan(6); goTo.marker(kind + "1"); - verify.importModuleCompletionListContains("f1"); - verify.importModuleCompletionListContains("f2"); - verify.importModuleCompletionListContains("f3"); - verify.importModuleCompletionListContains("f4"); - verify.importModuleCompletionListContains("e1"); - verify.importModuleCompletionListContains("e2"); - verify.not.importModuleCompletionListItemsCountIsGreaterThan(6); + verify.completionListContains("f1"); + verify.completionListContains("f2"); + verify.completionListContains("f3"); + verify.completionListContains("f4"); + verify.completionListContains("e1"); + verify.completionListContains("e2"); + verify.not.completionListItemsCountIsGreaterThan(6); } \ No newline at end of file diff --git a/tests/cases/fourslash/completionForStringLiteralRelativeImport3.ts b/tests/cases/fourslash/completionForStringLiteralRelativeImport3.ts index 82c3ea7d1e4..915cebdf6e7 100644 --- a/tests/cases/fourslash/completionForStringLiteralRelativeImport3.ts +++ b/tests/cases/fourslash/completionForStringLiteralRelativeImport3.ts @@ -34,18 +34,18 @@ const kinds = ["import_as", "import_equals", "require"]; for (const kind of kinds) { goTo.marker(kind + "0"); - verify.importModuleCompletionListContains("fourslash"); - verify.not.importModuleCompletionListItemsCountIsGreaterThan(1); + verify.completionListContains("fourslash"); + verify.not.completionListItemsCountIsGreaterThan(1); goTo.marker(kind + "1"); - verify.importModuleCompletionListContains("fourslash"); - verify.not.importModuleCompletionListItemsCountIsGreaterThan(1); + verify.completionListContains("fourslash"); + verify.not.completionListItemsCountIsGreaterThan(1); goTo.marker(kind + "2"); - verify.importModuleCompletionListContains("f1"); - verify.importModuleCompletionListContains("f2"); - verify.importModuleCompletionListContains("e1"); - verify.importModuleCompletionListContains("folder"); - verify.importModuleCompletionListContains("tests"); - verify.not.importModuleCompletionListItemsCountIsGreaterThan(5); + verify.completionListContains("f1"); + verify.completionListContains("f2"); + verify.completionListContains("e1"); + verify.completionListContains("folder"); + verify.completionListContains("tests"); + verify.not.completionListItemsCountIsGreaterThan(5); } \ No newline at end of file diff --git a/tests/cases/fourslash/completionForStringLiteralRelativeImport4.ts b/tests/cases/fourslash/completionForStringLiteralRelativeImport4.ts index ba9f95a08c2..b9750de9c17 100644 --- a/tests/cases/fourslash/completionForStringLiteralRelativeImport4.ts +++ b/tests/cases/fourslash/completionForStringLiteralRelativeImport4.ts @@ -42,11 +42,11 @@ const kinds = ["import_as", "import_equals", "require"]; for (const kind of kinds) { goTo.marker(kind + "0"); - verify.importModuleCompletionListContains("module0"); - verify.importModuleCompletionListContains("module1"); - verify.importModuleCompletionListContains("module2"); - verify.importModuleCompletionListContains("more"); + verify.completionListContains("module0"); + verify.completionListContains("module1"); + verify.completionListContains("module2"); + verify.completionListContains("more"); // Should not contain itself - verify.not.importModuleCompletionListItemsCountIsGreaterThan(4); + verify.not.completionListItemsCountIsGreaterThan(4); } \ No newline at end of file diff --git a/tests/cases/fourslash/completionForTripleSlashReference1.ts b/tests/cases/fourslash/completionForTripleSlashReference1.ts index f8ea7fc4d44..2ce4de2e72e 100644 --- a/tests/cases/fourslash/completionForTripleSlashReference1.ts +++ b/tests/cases/fourslash/completionForTripleSlashReference1.ts @@ -32,20 +32,20 @@ for (let i = 0; i < 5; i++) { goTo.marker("" + i); - verify.importModuleCompletionListContains("f1.ts"); - verify.importModuleCompletionListContains("f1.d.ts"); - verify.importModuleCompletionListContains("f2.tsx"); - verify.importModuleCompletionListContains("e1.ts"); - verify.importModuleCompletionListContains("parentTest"); - verify.not.importModuleCompletionListItemsCountIsGreaterThan(5); + verify.completionListContains("f1.ts"); + verify.completionListContains("f1.d.ts"); + verify.completionListContains("f2.tsx"); + verify.completionListContains("e1.ts"); + verify.completionListContains("parentTest"); + verify.not.completionListItemsCountIsGreaterThan(5); } goTo.marker("5"); -verify.importModuleCompletionListContains("g1.ts"); -verify.importModuleCompletionListContains("sub"); -verify.not.importModuleCompletionListItemsCountIsGreaterThan(2); +verify.completionListContains("g1.ts"); +verify.completionListContains("sub"); +verify.not.completionListItemsCountIsGreaterThan(2); goTo.marker("6"); -verify.importModuleCompletionListContains("g1.ts"); -verify.importModuleCompletionListContains("sub"); -verify.not.importModuleCompletionListItemsCountIsGreaterThan(2); \ No newline at end of file +verify.completionListContains("g1.ts"); +verify.completionListContains("sub"); +verify.not.completionListItemsCountIsGreaterThan(2); \ No newline at end of file diff --git a/tests/cases/fourslash/completionForTripleSlashReference2.ts b/tests/cases/fourslash/completionForTripleSlashReference2.ts index 0530e5e4093..e6553ce8e73 100644 --- a/tests/cases/fourslash/completionForTripleSlashReference2.ts +++ b/tests/cases/fourslash/completionForTripleSlashReference2.ts @@ -24,10 +24,10 @@ for (let i = 0; i < 5; i++) { goTo.marker("" + i); - verify.importModuleCompletionListContains("f1.ts"); - verify.importModuleCompletionListContains("f1.js"); - verify.importModuleCompletionListContains("f1.d.ts"); - verify.importModuleCompletionListContains("f2.tsx"); - verify.importModuleCompletionListContains("f4.jsx"); - verify.not.importModuleCompletionListItemsCountIsGreaterThan(5); + verify.completionListContains("f1.ts"); + verify.completionListContains("f1.js"); + verify.completionListContains("f1.d.ts"); + verify.completionListContains("f2.tsx"); + verify.completionListContains("f4.jsx"); + verify.not.completionListItemsCountIsGreaterThan(5); } \ No newline at end of file diff --git a/tests/cases/fourslash/completionForTripleSlashReference3.ts b/tests/cases/fourslash/completionForTripleSlashReference3.ts index d27d0e658c2..798e556be58 100644 --- a/tests/cases/fourslash/completionForTripleSlashReference3.ts +++ b/tests/cases/fourslash/completionForTripleSlashReference3.ts @@ -27,17 +27,17 @@ //// /*e2*/ goTo.marker("0"); -verify.importModuleCompletionListContains("fourslash"); -verify.not.importModuleCompletionListItemsCountIsGreaterThan(1); +verify.completionListContains("fourslash"); +verify.not.completionListItemsCountIsGreaterThan(1); goTo.marker("1"); -verify.importModuleCompletionListContains("fourslash"); -verify.not.importModuleCompletionListItemsCountIsGreaterThan(1); +verify.completionListContains("fourslash"); +verify.not.completionListItemsCountIsGreaterThan(1); goTo.marker("2"); -verify.importModuleCompletionListContains("f1.ts"); -verify.importModuleCompletionListContains("f2.tsx"); -verify.importModuleCompletionListContains("e1.ts"); -verify.importModuleCompletionListContains("folder"); -verify.importModuleCompletionListContains("tests"); -verify.not.importModuleCompletionListItemsCountIsGreaterThan(5); \ No newline at end of file +verify.completionListContains("f1.ts"); +verify.completionListContains("f2.tsx"); +verify.completionListContains("e1.ts"); +verify.completionListContains("folder"); +verify.completionListContains("tests"); +verify.not.completionListItemsCountIsGreaterThan(5); \ No newline at end of file diff --git a/tests/cases/fourslash/completionForTripleSlashReference4.ts b/tests/cases/fourslash/completionForTripleSlashReference4.ts index 9cedf4932b2..2eb58646675 100644 --- a/tests/cases/fourslash/completionForTripleSlashReference4.ts +++ b/tests/cases/fourslash/completionForTripleSlashReference4.ts @@ -38,6 +38,6 @@ goTo.marker("0"); -verify.importModuleCompletionListContains("module0.ts"); +verify.completionListContains("module0.ts"); -verify.not.importModuleCompletionListItemsCountIsGreaterThan(1); \ No newline at end of file +verify.not.completionListItemsCountIsGreaterThan(1); \ No newline at end of file diff --git a/tests/cases/fourslash/fourslash.ts b/tests/cases/fourslash/fourslash.ts index 948477b78dd..525fcc608f5 100644 --- a/tests/cases/fourslash/fourslash.ts +++ b/tests/cases/fourslash/fourslash.ts @@ -121,13 +121,10 @@ declare namespace FourSlashInterface { constructor(negative?: boolean); memberListContains(symbol: string, text?: string, documenation?: string, kind?: string): void; memberListCount(expectedCount: number): void; - completionListContains(symbol: string, text?: string, documentation?: string, kind?: string): void; + completionListContains(symbol: string, text?: string, documentation?: string, kind?: string, spanIndex?: number): void; completionListItemsCountIsGreaterThan(count: number): void; completionListIsEmpty(): void; completionListAllowsNewIdentifier(): void; - importModuleCompletionListContains(symbol: string, rangeIndex?: number): void; - importModuleCompletionListItemsCountIsGreaterThan(count: number): void; - importModuleCompletionListIsEmpty(): void; memberListIsEmpty(): void; signatureHelpPresent(): void; errorExistsBetweenMarkers(startMarker: string, endMarker: string): void;