diff --git a/src/harness/fourslash.ts b/src/harness/fourslash.ts index 406985f1efa4c..82ef60e7fbc73 100644 --- a/src/harness/fourslash.ts +++ b/src/harness/fourslash.ts @@ -729,97 +729,6 @@ namespace FourSlash { }); } - public verifyCompletionListCount(expectedCount: number, negative: boolean) { - if (expectedCount === 0 && negative) { - this.verifyCompletionListIsEmpty(/*negative*/ false); - return; - } - - const members = this.getCompletionListAtCaret(); - - if (members) { - const match = members.entries.length === expectedCount; - - if ((!match && !negative) || (match && negative)) { - this.raiseError("Member list count was " + members.entries.length + ". Expected " + expectedCount); - } - } - else if (expectedCount) { - this.raiseError("Member list count was 0. Expected " + expectedCount); - } - } - - public verifyCompletionListItemsCountIsGreaterThan(count: number, negative: boolean) { - const completions = this.getCompletionListAtCaret(); - const itemsCount = completions ? completions.entries.length : 0; - - if (negative) { - if (itemsCount > count) { - this.raiseError(`Expected completion list items count to not be greater than ${count}, but is actually ${itemsCount}`); - } - } - else { - if (itemsCount <= count) { - this.raiseError(`Expected completion list items count to be greater than ${count}, but is actually ${itemsCount}`); - } - } - } - - public verifyCompletionListStartsWithItemsInOrder(items: string[]): void { - if (items.length === 0) { - return; - } - - const entries = this.getCompletionListAtCaret()!.entries; - assert.isTrue(items.length <= entries.length, `Amount of expected items in completion list [ ${items.length} ] is greater than actual number of items in list [ ${entries.length} ]`); - ts.zipWith(entries, items, (entry, item) => { - assert.equal(entry.name, item, `Unexpected item in completion list`); - }); - } - - public noItemsWithSameNameButDifferentKind(): void { - const completions = this.getCompletionListAtCaret()!; - const uniqueItems = ts.createMap(); - for (const item of completions.entries) { - const uniqueItem = uniqueItems.get(item.name); - if (!uniqueItem) { - uniqueItems.set(item.name, item.kind); - } - else { - assert.equal(item.kind, uniqueItem, `Items should have the same kind, got ${item.kind} and ${uniqueItem}`); - } - } - } - - public verifyCompletionListIsEmpty(negative: boolean) { - const completions = this.getCompletionListAtCaret(); - 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) { - this.raiseError(`Completion list is not empty at caret at position ${this.activeFile.fileName} ${this.currentCaretPosition}\n` + - `Completion List contains: ${stringify(completions.entries.map(e => e.name))}`); - } - } - - public verifyCompletionListAllowsNewIdentifier(negative: boolean) { - const completions = this.getCompletionListAtCaret(); - - if ((completions && !completions.isNewIdentifierLocation) && !negative) { - this.raiseError("Expected builder completion entry"); - } - else if ((completions && completions.isNewIdentifierLocation) && negative) { - this.raiseError("Un-expected builder completion entry"); - } - } - - public verifyCompletionListIsGlobal(expected: boolean) { - const completions = this.getCompletionListAtCaret(); - if (completions && completions.isGlobalCompletion !== expected) { - this.raiseError(`verifyCompletionListIsGlobal failed - expected result to be ${completions.isGlobalCompletion}`); - } - } - public verifyCompletions(options: FourSlashInterface.VerifyCompletionsOptions) { if (options.marker === undefined) { this.verifyCompletionsWorker(options); @@ -843,13 +752,21 @@ namespace FourSlash { this.raiseError(`Expected 'isNewIdentifierLocation' to be ${options.isNewIdentifierLocation || false}, got ${actualCompletions.isNewIdentifierLocation}`); } - const actualByName = ts.createMap(); + if ("isGlobalCompletion" in options && actualCompletions.isGlobalCompletion !== options.isGlobalCompletion) { + this.raiseError(`Expected 'isGlobalCompletion to be ${options.isGlobalCompletion}, got ${actualCompletions.isGlobalCompletion}`); + } + + const nameToEntries = ts.createMap(); for (const entry of actualCompletions.entries) { - if (actualByName.has(entry.name)) { - this.raiseError(`Duplicate (${actualCompletions.entries.filter(a => a.name === entry.name).length}) completions for ${entry.name}`); + const entries = nameToEntries.get(entry.name); + if (!entries) { + nameToEntries.set(entry.name, [entry]); } else { - actualByName.set(entry.name, entry); + if (entries.some(e => e.source === entry.source)) { + this.raiseError(`Duplicate completions for ${entry.name}`); + } + entries.push(entry); } } @@ -862,23 +779,16 @@ namespace FourSlash { if (options.includes) { for (const include of toArray(options.includes)) { const name = typeof include === "string" ? include : include.name; - const found = actualByName.get(name); + const found = nameToEntries.get(name); if (!found) throw this.raiseError(`No completion ${name} found`); - this.verifyCompletionEntry(found, include); + assert(found.length === 1); // Must use 'exact' for multiple completions with same name + this.verifyCompletionEntry(ts.first(found), include); } } if (options.excludes) { for (const exclude of toArray(options.excludes)) { - if (typeof exclude === "string") { - if (actualByName.has(exclude)) { - this.raiseError(`Did not expect to get a completion named ${exclude}`); - } - } - else { - const found = actualByName.get(exclude.name); - if (found && found.source === exclude.source) { - this.raiseError(`Did not expect to get a completion named ${exclude.name} with source ${exclude.source}`); - } + if (nameToEntries.has(exclude)) { + this.raiseError(`Did not expect to get a completion named ${exclude}`); } } } @@ -902,6 +812,7 @@ namespace FourSlash { } if (kind !== undefined) assert.equal(actual.kind, kind); + if (typeof expected !== "string" && "kindModifiers" in expected) assert.equal(actual.kindModifiers, expected.kindModifiers); assert.equal(actual.hasAction, hasAction); assert.equal(actual.isRecommended, isRecommended); @@ -923,9 +834,8 @@ namespace FourSlash { } private verifyCompletionsAreExactly(actual: ReadonlyArray, expected: ReadonlyArray) { - if (actual.length !== expected.length) { - this.raiseError(`Expected ${expected.length} completions, got ${actual.length} (${actual.map(a => a.name)}).`); - } + // First pass: test that names are right. Then we'll test details. + assert.deepEqual(actual.map(a => a.name), expected.map(e => typeof e === "string" ? e : e.name)); ts.zipWith(actual, expected, (completion, expectedCompletion, index) => { const name = typeof expectedCompletion === "string" ? expectedCompletion : expectedCompletion.name; @@ -936,117 +846,6 @@ namespace FourSlash { }); } - public verifyCompletionsAt(markerName: string | ReadonlyArray, expected: ReadonlyArray, options?: FourSlashInterface.CompletionsAtOptions) { - this.verifyCompletions({ - marker: markerName, - exact: expected, - isNewIdentifierLocation: options && options.isNewIdentifierLocation, - preferences: options, - triggerCharacter: options && options.triggerCharacter, - }); - } - - public verifyCompletionListContains(entryId: ts.Completions.CompletionEntryIdentifier, text?: string, documentation?: string, kind?: string | { kind?: string, kindModifiers?: string }, spanIndex?: number, hasAction?: boolean, options?: FourSlashInterface.VerifyCompletionListContainsOptions) { - const completions = this.getCompletionListAtCaret(options); - if (completions) { - this.assertItemInCompletionList(completions.entries, entryId, text, documentation, kind, spanIndex, hasAction, options); - } - else { - this.raiseError(`No completions at position '${this.currentCaretPosition}' when looking for '${JSON.stringify(entryId)}'.`); - } - } - - /** - * Verify that the completion list does NOT contain the given symbol. - * The symbol is considered matched with the symbol in the list if and only if all given parameters must matched. - * When any parameter is omitted, the parameter is ignored during comparison and assumed that the parameter with - * that property of the symbol in the list. - * @param symbol the name of symbol - * @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(entryId: ts.Completions.CompletionEntryIdentifier, expectedText?: string, expectedDocumentation?: string, expectedKind?: string | { kind?: string, kindModifiers?: string }, spanIndex?: number, options?: FourSlashInterface.CompletionsAtOptions) { - let replacementSpan: ts.TextSpan | undefined; - if (spanIndex !== undefined) { - replacementSpan = this.getTextSpanForRangeAtIndex(spanIndex); - } - - const completions = this.getCompletionListAtCaret(options); - if (completions) { - let filterCompletions = completions.entries.filter(e => e.name === entryId.name && e.source === entryId.source); - filterCompletions = expectedKind ? filterCompletions.filter(e => e.kind === expectedKind || (typeof expectedKind === "object" && e.kind === expectedKind.kind)) : filterCompletions; - filterCompletions = filterCompletions.filter(entry => { - const details = this.getCompletionEntryDetails(entry.name); - const documentation = details && ts.displayPartsToString(details.documentation); - const text = details && ts.displayPartsToString(details.displayParts); - - // If any of the expected values are undefined, assume that users don't - // care about them. - if (replacementSpan && !ts.textSpansEqual(replacementSpan, entry.replacementSpan)) { - return false; - } - else if (expectedText && text !== expectedText) { - return false; - } - else if (expectedDocumentation && documentation !== expectedDocumentation) { - return false; - } - - return true; - }); - if (filterCompletions.length !== 0) { - // After filtered using all present criterion, if there are still symbol left in the list - // then these symbols must meet the criterion for Not supposed to be in the list. So we - // raise an error - let error = `Completion list did contain '${JSON.stringify(entryId)}\'.`; - const details = this.getCompletionEntryDetails(filterCompletions[0].name)!; - if (expectedText) { - error += "Expected text: " + expectedText + " to equal: " + ts.displayPartsToString(details.displayParts) + "."; - } - if (expectedDocumentation) { - error += "Expected documentation: " + expectedDocumentation + " to equal: " + ts.displayPartsToString(details.documentation) + "."; - } - if (expectedKind) { - error += "Expected kind: " + expectedKind + " to equal: " + filterCompletions[0].kind + "."; - } - else { - error += "kind: " + 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 verifyCompletionEntryDetails(entryName: string, expectedText: string, expectedDocumentation?: string, kind?: string, tags?: ts.JSDocTagInfo[]) { - const details = this.getCompletionEntryDetails(entryName)!; - - assert(details, "no completion entry available"); - - assert.equal(ts.displayPartsToString(details.displayParts), expectedText, this.assertionMessageAtLastKnownMarker("completion entry details text")); - - if (expectedDocumentation !== undefined) { - assert.equal(ts.displayPartsToString(details.documentation), expectedDocumentation, this.assertionMessageAtLastKnownMarker("completion entry documentation")); - } - - if (kind !== undefined) { - assert.equal(details.kind, kind, this.assertionMessageAtLastKnownMarker("completion entry kind")); - } - - if (tags !== undefined) { - assert.equal(details.tags!.length, tags.length, this.messageAtLastKnownMarker("QuickInfo tags")); - ts.zipWith(tags, details.tags!, (expectedTag, actualTag) => { - assert.equal(actualTag.name, expectedTag.name); - assert.equal(actualTag.text, expectedTag.text, this.messageAtLastKnownMarker("QuickInfo tag " + actualTag.name)); - }); - } - } - /** Use `getProgram` instead of accessing this directly. */ private _program: ts.Program; /** Use `getChecker` instead of accessing this directly. */ @@ -3172,74 +2971,6 @@ Actual: ${stringify(fullActual)}`); return text.substring(startPos, endPos); } - private assertItemInCompletionList( - items: ts.CompletionEntry[], - entryId: ts.Completions.CompletionEntryIdentifier, - text: string | undefined, - documentation: string | undefined, - kind: string | undefined | { kind?: string, kindModifiers?: string }, - spanIndex: number | undefined, - hasAction: boolean | undefined, - options: FourSlashInterface.VerifyCompletionListContainsOptions | undefined, - ) { - const eq = (a: T, b: T, msg: string) => { - assert.deepEqual(a, b, this.assertionMessageAtLastKnownMarker(msg + " for " + stringify(entryId))); - }; - const matchingItems = items.filter(item => item.name === entryId.name && item.source === entryId.source); - if (matchingItems.length === 0) { - const itemsString = items.map(item => stringify({ name: item.name, source: item.source, kind: item.kind })).join(",\n"); - this.raiseError(`Expected "${stringify({ entryId, text, documentation, kind })}" to be in list [${itemsString}]`); - } - else if (matchingItems.length > 1) { - this.raiseError(`Found duplicate completion items for ${stringify(entryId)}`); - } - const item = matchingItems[0]; - - if (documentation !== undefined || text !== undefined || entryId.source !== undefined) { - const details = this.getCompletionEntryDetails(item.name, item.source)!; - - if (documentation !== undefined) { - eq(ts.displayPartsToString(details.documentation), documentation, "completion item documentation"); - } - if (text !== undefined) { - eq(ts.displayPartsToString(details.displayParts), text, "completion item detail text"); - } - - if (entryId.source === undefined) { - eq(options && options.sourceDisplay, /*b*/ undefined, "source display"); - } - else { - eq(details.source, [ts.textPart(options!.sourceDisplay)], "source display"); - } - } - - if (kind !== undefined) { - if (typeof kind === "string") { - eq(item.kind, kind, "completion item kind"); - } - else { - if (kind.kind) { - eq(item.kind, kind.kind, "completion item kind"); - } - if (kind.kindModifiers !== undefined) { - eq(item.kindModifiers, kind.kindModifiers, "completion item kindModifiers"); - } - } - } - - - - if (spanIndex !== undefined) { - const span = this.getTextSpanForRangeAtIndex(spanIndex); - assert.isTrue(ts.textSpansEqual(span, item.replacementSpan), this.assertionMessageAtLastKnownMarker(stringify(span) + " does not equal " + stringify(item.replacementSpan) + " replacement span for " + stringify(entryId))); - } - - eq(item.hasAction, hasAction, "hasAction"); - eq(item.isRecommended, options && options.isRecommended, "isRecommended"); - eq(item.insertText, options && options.insertText, "insertText"); - eq(item.replacementSpan, options && options.replacementSpan && ts.createTextSpanFromRange(options.replacementSpan), "replacementSpan"); - } - private findFile(indexOrName: string | number): FourSlashFile { if (typeof indexOrName === "number") { const index = indexOrName; @@ -3289,16 +3020,6 @@ Actual: ${stringify(fullActual)}`); return `line ${(pos.line + 1)}, col ${pos.character}`; } - private getTextSpanForRangeAtIndex(index: number): ts.TextSpan { - const ranges = this.getRanges(); - if (ranges.length > index) { - return ts.createTextSpanFromRange(ranges[index]); - } - else { - throw this.raiseError("Supplied span index: " + index + " does not exist in range list of size: " + ranges.length); - } - } - public getMarkerByName(markerName: string) { const markerPos = this.testData.markerPositions.get(markerName); if (markerPos === undefined) { @@ -3418,7 +3139,7 @@ Actual: ${stringify(fullActual)}`); function runCode(code: string, state: TestState): void { // Compile and execute the test const wrappedCode = - `(function(test, goTo, verify, edit, debug, format, cancellation, classification, verifyOperationIsCancelled) { + `(function(test, goTo, verify, edit, debug, format, cancellation, classification, completion, verifyOperationIsCancelled) { ${code} })`; try { @@ -3430,7 +3151,7 @@ ${code} const format = new FourSlashInterface.Format(state); const cancellation = new FourSlashInterface.Cancellation(state); const f = eval(wrappedCode); - f(test, goTo, verify, edit, debug, format, cancellation, FourSlashInterface.Classification, verifyOperationIsCancelled); + f(test, goTo, verify, edit, debug, format, cancellation, FourSlashInterface.Classification, FourSlashInterface.Completion, verifyOperationIsCancelled); } catch (err) { throw err; @@ -3997,24 +3718,6 @@ namespace FourSlashInterface { export class VerifyNegatable { public not: VerifyNegatable; - public allowedClassElementKeywords = [ - "public", - "private", - "protected", - "static", - "abstract", - "readonly", - "get", - "set", - "constructor", - "async" - ]; - public allowedConstructorParameterKeywords = [ - "public", - "private", - "protected", - "readonly", - ]; constructor(protected state: FourSlash.TestState, private negative = false) { if (!negative) { @@ -4022,58 +3725,10 @@ namespace FourSlashInterface { } } - public completionListCount(expectedCount: number) { - this.state.verifyCompletionListCount(expectedCount, this.negative); - } - - // Verifies the completion list contains the specified symbol. The - // completion list is brought up if necessary - public completionListContains(entryId: string | ts.Completions.CompletionEntryIdentifier, text?: string, documentation?: string, kind?: string | { kind?: string, kindModifiers?: string }, spanIndex?: number, hasAction?: boolean, options?: VerifyCompletionListContainsOptions) { - if (typeof entryId === "string") { - entryId = { name: entryId, source: undefined }; - } - if (this.negative) { - this.state.verifyCompletionListDoesNotContain(entryId, text, documentation, kind, spanIndex, options); - } - else { - this.state.verifyCompletionListContains(entryId, text, documentation, kind, spanIndex, hasAction, options); - } - } - - // Verifies the completion list items count to be greater than the specified amount. The - // completion list is brought up if necessary - public completionListItemsCountIsGreaterThan(count: number) { - this.state.verifyCompletionListItemsCountIsGreaterThan(count, this.negative); - } - public assertHasRanges(ranges: FourSlash.Range[]) { assert(ranges.length !== 0, "Array of ranges is expected to be non-empty"); } - public completionListIsEmpty() { - this.state.verifyCompletionListIsEmpty(this.negative); - } - - public completionListContainsClassElementKeywords() { - for (const keyword of this.allowedClassElementKeywords) { - this.completionListContains(keyword, keyword, /*documentation*/ undefined, "keyword"); - } - } - - public completionListContainsConstructorParameterKeywords() { - for (const keyword of this.allowedConstructorParameterKeywords) { - this.completionListContains(keyword, keyword, /*documentation*/ undefined, "keyword"); - } - } - - public completionListIsGlobal(expected: boolean) { - this.state.verifyCompletionListIsGlobal(expected); - } - - public completionListAllowsNewIdentifier() { - this.state.verifyCompletionListAllowsNewIdentifier(this.negative); - } - public noSignatureHelp(...markers: string[]): void { this.state.verifySignatureHelpPresence(/*expectPresent*/ false, /*triggerReason*/ undefined, markers); } @@ -4160,10 +3815,6 @@ namespace FourSlashInterface { super(state); } - public completionsAt(markerName: ArrayOrSingle, completions: ReadonlyArray, options?: CompletionsAtOptions) { - this.state.verifyCompletionsAt(markerName, completions, options); - } - public completions(...optionsArray: VerifyCompletionsOptions[]) { for (const options of optionsArray) { this.state.verifyCompletions(options); @@ -4413,10 +4064,6 @@ namespace FourSlashInterface { this.state.verifyNoDocumentHighlights(startRange); } - public completionEntryDetailIs(entryName: string, text: string, documentation?: string, kind?: string, tags?: ts.JSDocTagInfo[]) { - this.state.verifyCompletionEntryDetails(entryName, text, documentation, kind, tags); - } - /** * This method *requires* a contiguous, complete, and ordered stream of classifications for a file. */ @@ -4761,6 +4408,477 @@ namespace FourSlashInterface { return { classificationType, text, textSpan }; } } + export namespace Completion { + const res: string[] = []; + for (let i = ts.SyntaxKind.FirstKeyword; i <= ts.SyntaxKind.LastKeyword; i++) { + res.push(ts.Debug.assertDefined(ts.tokenToString(i))); + } + export const keywordsWithUndefined: ReadonlyArray = res; + export const keywords: ReadonlyArray = keywordsWithUndefined.filter(k => k !== "undefined"); + + export const typeKeywords: ReadonlyArray = + ["false", "null", "true", "void", "any", "boolean", "keyof", "never", "number", "object", "string", "symbol", "undefined", "unique", "unknown"]; + + const globalTypeDecls = [ + "Symbol", + "PropertyKey", + "PropertyDescriptor", + "PropertyDescriptorMap", + "Object", + "ObjectConstructor", + "Function", + "FunctionConstructor", + "CallableFunction", + "NewableFunction", + "IArguments", + "String", + "StringConstructor", + "Boolean", + "BooleanConstructor", + "Number", + "NumberConstructor", + "TemplateStringsArray", + "ImportMeta", + "Math", + "Date", + "DateConstructor", + "RegExpMatchArray", + "RegExpExecArray", + "RegExp", + "RegExpConstructor", + "Error", + "ErrorConstructor", + "EvalError", + "EvalErrorConstructor", + "RangeError", + "RangeErrorConstructor", + "ReferenceError", + "ReferenceErrorConstructor", + "SyntaxError", + "SyntaxErrorConstructor", + "TypeError", + "TypeErrorConstructor", + "URIError", + "URIErrorConstructor", + "JSON", + "ReadonlyArray", + "ConcatArray", + "Array", + "ArrayConstructor", + "TypedPropertyDescriptor", + "ClassDecorator", + "PropertyDecorator", + "MethodDecorator", + "ParameterDecorator", + "PromiseConstructorLike", + "PromiseLike", + "Promise", + "ArrayLike", + "Partial", + "Required", + "Readonly", + "Pick", + "Record", + "Exclude", + "Extract", + "NonNullable", + "Parameters", + "ConstructorParameters", + "ReturnType", + "InstanceType", + "ThisType", + "ArrayBuffer", + "ArrayBufferTypes", + "ArrayBufferLike", + "ArrayBufferConstructor", + "ArrayBufferView", + "DataView", + "DataViewConstructor", + "Int8Array", + "Int8ArrayConstructor", + "Uint8Array", + "Uint8ArrayConstructor", + "Uint8ClampedArray", + "Uint8ClampedArrayConstructor", + "Int16Array", + "Int16ArrayConstructor", + "Uint16Array", + "Uint16ArrayConstructor", + "Int32Array", + "Int32ArrayConstructor", + "Uint32Array", + "Uint32ArrayConstructor", + "Float32Array", + "Float32ArrayConstructor", + "Float64Array", + "Float64ArrayConstructor", + "Intl", + ]; + + export const globalTypes = globalTypesPlus([]); + + export function globalTypesPlus(plus: ReadonlyArray): ReadonlyArray { + return [ + ...globalTypeDecls, + ...plus, + ...typeKeywords, + ]; + } + + export const classElementKeywords: ReadonlyArray = + ["private", "protected", "public", "static", "abstract", "async", "constructor", "get", "readonly", "set"]; + + export const constructorParameterKeywords: ReadonlyArray = + ["private", "protected", "public", "readonly"].map((name): ExpectedCompletionEntry => ({ name, kind: "keyword" })); + + export const functionMembers: ReadonlyArray = [ + "apply", + "call", + "bind", + "toString", + "length", + { name: "arguments", text: "(property) Function.arguments: any" }, + "caller" + ]; + + export const stringMembers: ReadonlyArray = [ + "toString", + "charAt", + "charCodeAt", + "concat", + "indexOf", + "lastIndexOf", + "localeCompare", + "match", + "replace", + "search", + "slice", + "split", + "substring", + "toLowerCase", + "toLocaleLowerCase", + "toUpperCase", + "toLocaleUpperCase", + "trim", + "length", + "substr", + "valueOf", + ]; + + export const functionMembersWithPrototype: ReadonlyArray = [ + ...functionMembers.slice(0, 4), + "prototype", + ...functionMembers.slice(4), + ]; + + // TODO: Shouldn't propose type keywords in statement position + export const statementKeywordsWithTypes: ReadonlyArray = [ + "break", + "case", + "catch", + "class", + "const", + "continue", + "debugger", + "default", + "delete", + "do", + "else", + "enum", + "export", + "extends", + "false", + "finally", + "for", + "function", + "if", + "import", + "in", + "instanceof", + "new", + "null", + "return", + "super", + "switch", + "this", + "throw", + "true", + "try", + "typeof", + "var", + "void", + "while", + "with", + "implements", + "interface", + "let", + "package", + "private", + "protected", + "public", + "static", + "yield", + "abstract", + "as", + "any", + "async", + "await", + "boolean", + "constructor", + "declare", + "get", + "infer", + "is", + "keyof", + "module", + "namespace", + "never", + "readonly", + "require", + "number", + "object", + "set", + "string", + "symbol", + "type", + "unique", + "unknown", + "from", + "global", + "of", + ]; + + export const statementKeywords: ReadonlyArray = statementKeywordsWithTypes.filter(k => + k === "false" || k === "true" || k === "null" || k === "void" || !ts.contains(typeKeywords, k) && k !== "declare" && k !== "module"); + + export const globalsVars: ReadonlyArray = [ + "eval", + "parseInt", + "parseFloat", + "isNaN", + "isFinite", + "decodeURI", + "decodeURIComponent", + "encodeURI", + "encodeURIComponent", + "escape", + "unescape", + "NaN", + "Infinity", + "Object", + "Function", + "String", + "Boolean", + "Number", + "Math", + "Date", + "RegExp", + "Error", + "EvalError", + "RangeError", + "ReferenceError", + "SyntaxError", + "TypeError", + "URIError", + "JSON", + "Array", + "ArrayBuffer", + "DataView", + "Int8Array", + "Uint8Array", + "Uint8ClampedArray", + "Int16Array", + "Uint16Array", + "Int32Array", + "Uint32Array", + "Float32Array", + "Float64Array", + "Intl", + ]; + + // TODO: many of these are inappropriate to always provide + export const globalsInsideFunction = (plus: ReadonlyArray): ReadonlyArray => [ + "arguments", + ...plus, + ...globalsVars, + "undefined", + "break", + "case", + "catch", + "class", + "const", + "continue", + "debugger", + "default", + "delete", + "do", + "else", + "enum", + "export", + "extends", + "false", + "finally", + "for", + "function", + "if", + "import", + "in", + "instanceof", + "new", + "null", + "return", + "super", + "switch", + "this", + "throw", + "true", + "try", + "typeof", + "var", + "void", + "while", + "with", + "implements", + "interface", + "let", + "package", + "yield", + "async", + ]; + + // TODO: many of these are inappropriate to always provide + export const globalKeywords: ReadonlyArray = [ + "break", + "case", + "catch", + "class", + "const", + "continue", + "debugger", + "default", + "delete", + "do", + "else", + "enum", + "export", + "extends", + "false", + "finally", + "for", + "function", + "if", + "import", + "in", + "instanceof", + "new", + "null", + "return", + "super", + "switch", + "this", + "throw", + "true", + "try", + "typeof", + "var", + "void", + "while", + "with", + "implements", + "interface", + "let", + "package", + "private", + "protected", + "public", + "static", + "yield", + "abstract", + "as", + "any", + "async", + "await", + "boolean", + "constructor", + "declare", + "get", + "infer", + "is", + "keyof", + "module", + "namespace", + "never", + "readonly", + "require", + "number", + "object", + "set", + "string", + "symbol", + "type", + "unique", + "unknown", + "from", + "global", + "of", + ]; + + export const insideMethodKeywords: ReadonlyArray = [ + "break", + "case", + "catch", + "class", + "const", + "continue", + "debugger", + "default", + "delete", + "do", + "else", + "enum", + "export", + "extends", + "false", + "finally", + "for", + "function", + "if", + "import", + "in", + "instanceof", + "new", + "null", + "return", + "super", + "switch", + "this", + "throw", + "true", + "try", + "typeof", + "var", + "void", + "while", + "with", + "implements", + "interface", + "let", + "package", + "yield", + "async", + ]; + + export const globalKeywordsPlusUndefined: ReadonlyArray = (() => { + const i = globalKeywords.indexOf("unique"); + return [...globalKeywords.slice(0, i), "undefined", ...globalKeywords.slice(i)]; + })(); + + export const globals: ReadonlyArray = [...globalsVars, "undefined", ...globalKeywords]; + + export function globalsPlus(plus: ReadonlyArray): ReadonlyArray { + return [...globalsVars, ...plus, "undefined", ...globalKeywords]; + } + } export interface ReferenceGroup { definition: ReferenceGroupDefinition; @@ -4784,22 +4902,20 @@ namespace FourSlashInterface { readonly hasAction?: boolean, // If not specified, will assert that this is false. readonly isRecommended?: boolean; // If not specified, will assert that this is false. readonly kind?: string, // If not specified, won't assert about this - readonly text: string; - readonly documentation: string; + readonly kindModifiers?: string; + readonly text?: string; + readonly documentation?: string; readonly sourceDisplay?: string; readonly tags?: ReadonlyArray; }; - export interface CompletionsAtOptions extends Partial { - triggerCharacter?: ts.CompletionsTriggerCharacter; - isNewIdentifierLocation?: boolean; - } export interface VerifyCompletionsOptions { readonly marker?: ArrayOrSingle; - readonly isNewIdentifierLocation?: boolean; + readonly isNewIdentifierLocation?: boolean; // Always tested + readonly isGlobalCompletion?: boolean; // Only tested if set readonly exact?: ArrayOrSingle; readonly includes?: ArrayOrSingle; - readonly excludes?: ArrayOrSingle; + readonly excludes?: ArrayOrSingle; readonly preferences?: ts.UserPreferences; readonly triggerCharacter?: ts.CompletionsTriggerCharacter; } diff --git a/tests/cases/fourslash/argumentsAreAvailableAfterEditsAtEndOfFunction.ts b/tests/cases/fourslash/argumentsAreAvailableAfterEditsAtEndOfFunction.ts index 8a1efef397e4c..de2b99f2165b9 100644 --- a/tests/cases/fourslash/argumentsAreAvailableAfterEditsAtEndOfFunction.ts +++ b/tests/cases/fourslash/argumentsAreAvailableAfterEditsAtEndOfFunction.ts @@ -12,4 +12,4 @@ goTo.marker(); var text = "this.children = ch"; edit.insert(text); -verify.completionListContains("children", "(parameter) children: string[]"); \ No newline at end of file +verify.completions({ includes: { name: "children", text: "(parameter) children: string[]" }, isNewIdentifierLocation: true }); diff --git a/tests/cases/fourslash/asOperatorCompletion.ts b/tests/cases/fourslash/asOperatorCompletion.ts index 2eaaae7e75dc2..35ed2c5ebfaf1 100644 --- a/tests/cases/fourslash/asOperatorCompletion.ts +++ b/tests/cases/fourslash/asOperatorCompletion.ts @@ -4,5 +4,5 @@ //// var x; //// var y = x as /**/ -goTo.marker(); -verify.completionListContains('T'); +verify.completions({ marker: "", includes: "T" }); + diff --git a/tests/cases/fourslash/augmentedTypesClass2.ts b/tests/cases/fourslash/augmentedTypesClass2.ts index 90be770272b29..89df22f28db82 100644 --- a/tests/cases/fourslash/augmentedTypesClass2.ts +++ b/tests/cases/fourslash/augmentedTypesClass2.ts @@ -6,8 +6,6 @@ ////var r = new c5b(); ////r./*2*/ -goTo.marker('1'); -verify.not.completionListContains('y', 'var y: number'); +verify.completions({ marker: "1", excludes: ["y"] }); edit.backspace(4); -goTo.marker('2'); -verify.completionListContains('foo', '(method) c5b.foo(): void'); \ No newline at end of file +verify.completions({ marker: "2", exact: { name: "foo", text: "(method) c5b.foo(): void" } }); diff --git a/tests/cases/fourslash/augmentedTypesClass3.ts b/tests/cases/fourslash/augmentedTypesClass3.ts index 65e599a574443..ec53a1bee9f5a 100644 --- a/tests/cases/fourslash/augmentedTypesClass3.ts +++ b/tests/cases/fourslash/augmentedTypesClass3.ts @@ -8,6 +8,4 @@ verify.quickInfos({ 1: "class c5b\nnamespace c5b", 2: "class c5b\nnamespace c5b" }); - -goTo.marker('3'); -verify.completionListContains("c5b", "class c5b\nnamespace c5b"); \ No newline at end of file +verify.completions({ marker: "3", includes: { name: "c5b", text: "class c5b\nnamespace c5b" }}) diff --git a/tests/cases/fourslash/augmentedTypesModule1.ts b/tests/cases/fourslash/augmentedTypesModule1.ts index 6c518c163450d..8b9f1e315e8ee 100644 --- a/tests/cases/fourslash/augmentedTypesModule1.ts +++ b/tests/cases/fourslash/augmentedTypesModule1.ts @@ -7,8 +7,5 @@ ////var x: m1c./*1*/; ////var /*2*/r = m1c; -goTo.marker('1'); -verify.completionListContains('I'); -verify.not.completionListContains('foo'); - +verify.completions({ marker: "1", exact: "I" }); verify.quickInfoAt("2", "var r: number"); diff --git a/tests/cases/fourslash/augmentedTypesModule2.ts b/tests/cases/fourslash/augmentedTypesModule2.ts index 8cab9a42700fd..a61b6586af1cc 100644 --- a/tests/cases/fourslash/augmentedTypesModule2.ts +++ b/tests/cases/fourslash/augmentedTypesModule2.ts @@ -7,11 +7,10 @@ verify.quickInfoAt("11", "function m2f(x: number): void\nnamespace m2f"); -goTo.marker('1'); -verify.completionListContains('I'); +verify.completions({ marker: "1", exact: "I" }); edit.insert('I.'); -verify.not.completionListContains('foo'); +verify.completions({ exact: undefined }); edit.backspace(1); verify.quickInfoAt("2", "var r: (x: number) => void"); diff --git a/tests/cases/fourslash/augmentedTypesModule3.ts b/tests/cases/fourslash/augmentedTypesModule3.ts index 9ab9850f99352..42d45e8c7c878 100644 --- a/tests/cases/fourslash/augmentedTypesModule3.ts +++ b/tests/cases/fourslash/augmentedTypesModule3.ts @@ -5,11 +5,10 @@ ////var x: m2g./*1*/; ////var /*2*/r = m2g/*3*/; -goTo.marker('1'); -verify.completionListContains('C'); +verify.completions({ marker: "1", exact: "C" }); edit.insert('C.'); -verify.not.completionListContains('foo'); +verify.completions({ exact: undefined }); edit.backspace(1); verify.quickInfoAt("2", "var r: typeof m2g"); diff --git a/tests/cases/fourslash/augmentedTypesModule4.ts b/tests/cases/fourslash/augmentedTypesModule4.ts index 7a7ecb5521943..de40dcc3d5b63 100644 --- a/tests/cases/fourslash/augmentedTypesModule4.ts +++ b/tests/cases/fourslash/augmentedTypesModule4.ts @@ -1,6 +1,6 @@ /// -////module m3d { export var y = 2; } +////module m3d { export var y = 2; } ////declare class m3d { foo(): void } ////var /*1*/r = new m3d(); ////r./*2*/ @@ -8,12 +8,10 @@ verify.quickInfoAt("1", "var r: m3d"); -goTo.marker('2'); -verify.completionListContains('foo'); +verify.completions({ marker: "2", exact: "foo" }); edit.insert('foo();'); -goTo.marker('3'); -verify.completionListContains('y'); +verify.completions({ marker: "3", includes: "y" }); edit.insert('y;'); verify.quickInfoAt("4", "var r2: number"); diff --git a/tests/cases/fourslash/augmentedTypesModule5.ts b/tests/cases/fourslash/augmentedTypesModule5.ts index 9f38e4d34b851..4203fd2d810e9 100644 --- a/tests/cases/fourslash/augmentedTypesModule5.ts +++ b/tests/cases/fourslash/augmentedTypesModule5.ts @@ -1,6 +1,6 @@ /// -////declare class m3e { foo(): void } +////declare class m3e { foo(): void } ////module m3e { export var y = 2; } ////var /*1*/r = new m3e(); ////r./*2*/ @@ -8,13 +8,11 @@ verify.quickInfoAt("1", "var r: m3e"); -goTo.marker('2'); -verify.completionListContains('foo'); +verify.completions({ marker: "2", exact: "foo" }); edit.insert('foo();'); -goTo.marker('3'); -verify.completionListContains('y'); +verify.completions({ marker: "3", includes: "y" }); edit.insert('y;'); verify.quickInfoAt("4", "var r2: number"); diff --git a/tests/cases/fourslash/basicClassMembers.ts b/tests/cases/fourslash/basicClassMembers.ts index 9fad673197337..cecef90f4b1de 100644 --- a/tests/cases/fourslash/basicClassMembers.ts +++ b/tests/cases/fourslash/basicClassMembers.ts @@ -7,6 +7,4 @@ goTo.eof(); edit.insert('t.'); -verify.completionListContains('x'); -verify.completionListContains('y'); -verify.not.completionListContains('z'); +verify.completions({ includes: ["x", "y"], excludes: "z" }); diff --git a/tests/cases/fourslash/cloduleAsBaseClass.ts b/tests/cases/fourslash/cloduleAsBaseClass.ts index 96b258aed44c8..15b991f863379 100644 --- a/tests/cases/fourslash/cloduleAsBaseClass.ts +++ b/tests/cases/fourslash/cloduleAsBaseClass.ts @@ -23,23 +23,8 @@ ////d./*1*/ ////D./*2*/ -goTo.marker('1'); -verify.completionListContains('foo'); -verify.completionListContains('foo2'); -verify.not.completionListContains('bar'); -verify.not.completionListContains('bar2'); -verify.not.completionListContains('baz'); -verify.not.completionListContains('x'); - +verify.completions({ marker: "1", exact: ["foo2", "foo"] }); edit.insert('foo()'); - -goTo.marker('2'); -verify.not.completionListContains('foo'); -verify.not.completionListContains('foo2'); -verify.completionListContains('bar'); -verify.completionListContains('bar2'); -verify.completionListContains('baz'); -verify.completionListContains('x'); +verify.completions({ marker: "2", exact: ["prototype", "bar2", "bar", "baz", "x", ...completion.functionMembers] }); edit.insert('bar()'); - -verify.noErrors(); \ No newline at end of file +verify.noErrors(); diff --git a/tests/cases/fourslash/closedCommentsInConstructor.ts b/tests/cases/fourslash/closedCommentsInConstructor.ts index 8a168a58354a0..ea39826172fc7 100644 --- a/tests/cases/fourslash/closedCommentsInConstructor.ts +++ b/tests/cases/fourslash/closedCommentsInConstructor.ts @@ -4,5 +4,4 @@ //// constructor(/* /**/ */) { } ////} -goTo.marker(); -verify.completionListIsEmpty(); \ No newline at end of file +verify.completions({ marker: "", exact: undefined }); diff --git a/tests/cases/fourslash/codeCompletionEscaping.ts b/tests/cases/fourslash/codeCompletionEscaping.ts index 5061a87e5b636..e582171575f6c 100644 --- a/tests/cases/fourslash/codeCompletionEscaping.ts +++ b/tests/cases/fourslash/codeCompletionEscaping.ts @@ -4,6 +4,10 @@ // @allowJs: true ////___foo; __foo;/**/ -goTo.marker(); -verify.completionListContains("__foo", undefined, undefined, "warning"); -verify.completionListContains("___foo", undefined, undefined, "warning"); +verify.completions({ + marker: "", + includes: [ + { name: "__foo", kind: "warning" }, + { name: "___foo", kind: "warning" }, + ], +}); diff --git a/tests/cases/fourslash/commentsClass.ts b/tests/cases/fourslash/commentsClass.ts index 87e9b9d3a48c1..12ebed64b53af 100644 --- a/tests/cases/fourslash/commentsClass.ts +++ b/tests/cases/fourslash/commentsClass.ts @@ -106,22 +106,26 @@ verify.quickInfos({ 25: ["class c6", "class with statics and constructor"] }); -goTo.marker('26'); -verify.completionListContains("c2", "class c2", "This is class c2 without constructor"); -verify.completionListContains("i2", "var i2: c2", ""); -verify.completionListContains("i2_c", "var i2_c: typeof c2", ""); -verify.completionListContains("c3", "class c3", ""); -verify.completionListContains("i3", "var i3: c3", ""); -verify.completionListContains("i3_c", "var i3_c: typeof c3", ""); -verify.completionListContains("c4", "class c4", "Class comment"); -verify.completionListContains("i4", "var i4: c4", ""); -verify.completionListContains("i4_c", "var i4_c: typeof c4", ""); -verify.completionListContains("c5", "class c5", "Class with statics"); -verify.completionListContains("i5", "var i5: c5", ""); -verify.completionListContains("i5_c", "var i5_c: typeof c5"); -verify.completionListContains("c6", "class c6", "class with statics and constructor"); -verify.completionListContains("i6", "var i6: c6", ""); -verify.completionListContains("i6_c", "var i6_c: typeof c6", ""); +verify.completions({ + marker: "26", + includes: [ + { name: "c2", text: "class c2", documentation: "This is class c2 without constructor" }, + { name: "i2", text: "var i2: c2" }, + { name: "i2_c", text: "var i2_c: typeof c2" }, + { name: "c3", text: "class c3" }, + { name: "i3", text: "var i3: c3" }, + { name: "i3_c", text: "var i3_c: typeof c3" }, + { name: "c4", text: "class c4", documentation: "Class comment" }, + { name: "i4", text: "var i4: c4" }, + { name: "i4_c", text: "var i4_c: typeof c4" }, + { name: "c5", text: "class c5", documentation: "Class with statics" }, + { name: "i5", text: "var i5: c5" }, + { name: "i5_c", text: "var i5_c: typeof c5" }, + { name: "c6", text: "class c6", documentation: "class with statics and constructor" }, + { name: "i6", text: "var i6: c6" }, + { name: "i6_c", text: "var i6_c: typeof c6" }, + ], +}); verify.signatureHelp({ marker: "27", diff --git a/tests/cases/fourslash/commentsClassMembers.ts b/tests/cases/fourslash/commentsClassMembers.ts index b0ed3e9e48bf6..4457dc617cddc 100644 --- a/tests/cases/fourslash/commentsClassMembers.ts +++ b/tests/cases/fourslash/commentsClassMembers.ts @@ -132,342 +132,163 @@ //// } ////} +const publicProperties: ReadonlyArray = [ + { name: "p1", text: "(property) c1.p1: number", documentation: "p1 is property of c1" }, + { name: "p2", text: "(method) c1.p2(b: number): number", documentation: "sum with property" }, + { name: "p3", text: "(property) c1.p3: number", documentation: "getter property 1\nsetter property 1" }, +]; +const publicNcProperties: ReadonlyArray = [ + { name: "nc_p1", text: "(property) c1.nc_p1: number" }, + { name: "nc_p2", text: "(method) c1.nc_p2(b: number): number" }, + { name: "nc_p3", text: "(property) c1.nc_p3: number" }, +]; +const locals: ReadonlyArray = [ + { name: "c1", text: "class c1", documentation: "This is comment for c1" }, + { name: "i1", text: "var i1: c1" }, + { name: "i1_p", text: "var i1_p: number" }, + { name: "i1_f", text: "var i1_f: (b: number) => number" }, + { name: "i1_r", text: "var i1_r: number" }, + { name: "i1_prop", text: "var i1_prop: number" }, + { name: "i1_nc_p", text: "var i1_nc_p: number" }, + { name: "i1_ncf", text: "var i1_ncf: (b: number) => number" }, + { name: "i1_ncr", text: "var i1_ncr: number" }, + { name: "i1_ncprop", text: "var i1_ncprop: number" }, + { name: "i1_s_p", text: "var i1_s_p: number" }, + { name: "i1_s_f", text: "var i1_s_f: (b: number) => number" }, + { name: "i1_s_r", text: "var i1_s_r: number" }, + { name: "i1_s_prop", text: "var i1_s_prop: number" }, + { name: "i1_s_nc_p", text: "var i1_s_nc_p: number" }, + { name: "i1_s_ncf", text: "var i1_s_ncf: (b: number) => number" }, + { name: "i1_s_ncr", text: "var i1_s_ncr: number" }, + { name: "i1_s_ncprop", text: "var i1_s_ncprop: number" }, + { name: "i1_c", text: "var i1_c: typeof c1" }, +]; + +verify.completions( + { + marker: ["4", "7", "9", "11", "12", "16", "19", "21", "23", "24"], + exact: [ + ...publicProperties, + { name: "pp1", text: "(property) c1.pp1: number", documentation: "pp1 is property of c1" }, + { name: "pp2", text: "(method) c1.pp2(b: number): number", documentation: "sum with property" }, + { name: "pp3", text: "(property) c1.pp3: number", documentation: "getter property 2\nsetter property 2" }, + ...publicNcProperties, + { name: "nc_pp1", text: "(property) c1.nc_pp1: number" }, + { name: "nc_pp2", text: "(method) c1.nc_pp2(b: number): number" }, + { name: "nc_pp3", text: "(property) c1.nc_pp3: number" }, + ], + }, + { + marker: ["5", "17"], + includes: { name: "b", text: "(parameter) b: number", documentation: "number to add" }, + }, + { + marker: ["13", "25"], + includes: [{ name: "value", text: "(parameter) value: number", documentation: "this is value" }], + isNewIdentifierLocation: true, + }, + { + marker: ["30", "34", "36", "39", "41", "88"], + exact: [ + "prototype", + { name: "s1", text: "(property) c1.s1: number", documentation: "s1 is static property of c1" }, + { name: "s2", text: "(method) c1.s2(b: number): number", documentation: "static sum with property" }, + { name: "s3", text: "(property) c1.s3: number", documentation: "static getter property\nsetter property 3" }, + { name: "nc_s1", text: "(property) c1.nc_s1: number" }, + { name: "nc_s2", text: "(method) c1.nc_s2(b: number): number" }, + { name: "nc_s3", text: "(property) c1.nc_s3: number" }, + ...completion.functionMembers, + ], + }, + { marker: ["29", "33", "38", "109"], includes: locals }, + { marker: ["35", "40", "87"], includes: locals, isNewIdentifierLocation: true }, + { marker: "31", includes: { name: "b", text: "(parameter) b: number", documentation: "number to add" } }, + { marker: "42", includes: { name: "value", text: "(parameter) value: number", documentation: "this is value" }, isNewIdentifierLocation: true }, + { marker: ["45", "52", "59"], includes: { name: "b", text: "(parameter) b: number" } }, + { marker: ["49", "56", "63"], includes: { name: "value", text: "(parameter) value: number" }, isNewIdentifierLocation: true }, + { marker: "67", exact: [...publicProperties, ...publicNcProperties] }, + { + marker: "110", + includes: [ + { name: "p1", text: "(property) cProperties.p1: number", documentation: "getter only property" }, + { name: "p2", text: "(property) cProperties.p2: number", documentation: "setter only property" }, + { name: "nc_p1", text: "(property) cProperties.nc_p1: number" }, + { name: "nc_p2", text: "(property) cProperties.nc_p2: number" }, + ], + }, + { + marker: "114", + includes: { + name: "a", + text: "(property) cWithConstructorProperty.a: number", + documentation: "more info about a\nthis is first parameter a", + tags: [{ name: "param", text: "a this is first parameter a" }], + }, + }, + { + marker: "115", + includes: { + name: "a", + text: "(parameter) a: number", + documentation: "more info about a\nthis is first parameter a", + tags: [{ name: "param", text: "a this is first parameter a" }], + }, + isNewIdentifierLocation: true, + }, +); + +verify.signatureHelp( + { marker: ["8", "13", "20", "25", "71"], docComment: "sum with property", parameterDocComment: "number to add" }, + { marker: ["35", "42", "92"], docComment: "static sum with property", parameterDocComment: "number to add" }, + { marker: ["47", "49", "54", "56", "61", "63", "81", "102"], docComment: "" }, + { marker: "65", docComment: "Constructor method" }, +); + verify.quickInfos({ 1: ["class c1", "This is comment for c1"], 2: ["(property) c1.p1: number", "p1 is property of c1"], - 3: ["(method) c1.p2(b: number): number", "sum with property"] -}); - -goTo.marker('4'); -verify.completionListContains("p1", "(property) c1.p1: number", "p1 is property of c1"); -verify.completionListContains("p2", "(method) c1.p2(b: number): number", "sum with property"); -verify.completionListContains("p3", "(property) c1.p3: number", "getter property 1\nsetter property 1"); -verify.completionListContains("pp1", "(property) c1.pp1: number", "pp1 is property of c1"); -verify.completionListContains("pp2", "(method) c1.pp2(b: number): number", "sum with property"); -verify.completionListContains("pp3", "(property) c1.pp3: number", "getter property 2\nsetter property 2"); -verify.completionListContains("nc_p1", "(property) c1.nc_p1: number", ""); -verify.completionListContains("nc_p2", "(method) c1.nc_p2(b: number): number", ""); -verify.completionListContains("nc_p3", "(property) c1.nc_p3: number", ""); -verify.completionListContains("nc_pp1", "(property) c1.nc_pp1: number", ""); -verify.completionListContains("nc_pp2", "(method) c1.nc_pp2(b: number): number", ""); -verify.completionListContains("nc_pp3", "(property) c1.nc_pp3: number", ""); - -goTo.marker('5'); -verify.completionListContains("b", "(parameter) b: number", "number to add"); - -verify.quickInfoAt("6", "(property) c1.p3: number", "getter property 1\nsetter property 1"); - -goTo.marker('7'); -verify.completionListContains("p1", "(property) c1.p1: number", "p1 is property of c1"); -verify.completionListContains("p2", "(method) c1.p2(b: number): number", "sum with property"); -verify.completionListContains("p3", "(property) c1.p3: number", "getter property 1\nsetter property 1"); -verify.completionListContains("pp1", "(property) c1.pp1: number", "pp1 is property of c1"); -verify.completionListContains("pp2", "(method) c1.pp2(b: number): number", "sum with property"); -verify.completionListContains("pp3", "(property) c1.pp3: number", "getter property 2\nsetter property 2"); -verify.completionListContains("nc_p1", "(property) c1.nc_p1: number", ""); -verify.completionListContains("nc_p2", "(method) c1.nc_p2(b: number): number", ""); -verify.completionListContains("nc_p3", "(property) c1.nc_p3: number", ""); -verify.completionListContains("nc_pp1", "(property) c1.nc_pp1: number", ""); -verify.completionListContains("nc_pp2", "(method) c1.nc_pp2(b: number): number", ""); -verify.completionListContains("nc_pp3", "(property) c1.nc_pp3: number", ""); - -verify.signatureHelp({ marker: "8", docComment: "sum with property", parameterDocComment: "number to add" }); -verify.quickInfoAt("8q", "(method) c1.p2(b: number): number", "sum with property"); - -goTo.marker('9'); -verify.completionListContains("p1", "(property) c1.p1: number", "p1 is property of c1"); -verify.completionListContains("p2", "(method) c1.p2(b: number): number", "sum with property"); -verify.completionListContains("p3", "(property) c1.p3: number", "getter property 1\nsetter property 1"); -verify.completionListContains("pp1", "(property) c1.pp1: number", "pp1 is property of c1"); -verify.completionListContains("pp2", "(method) c1.pp2(b: number): number", "sum with property"); -verify.completionListContains("pp3", "(property) c1.pp3: number", "getter property 2\nsetter property 2"); -verify.completionListContains("nc_p1", "(property) c1.nc_p1: number", ""); -verify.completionListContains("nc_p2", "(method) c1.nc_p2(b: number): number", ""); -verify.completionListContains("nc_p3", "(property) c1.nc_p3: number", ""); -verify.completionListContains("nc_pp1", "(property) c1.nc_pp1: number", ""); -verify.completionListContains("nc_pp2", "(method) c1.nc_pp2(b: number): number", ""); -verify.completionListContains("nc_pp3", "(property) c1.nc_pp3: number", ""); - -verify.quickInfoAt("10", "(property) c1.p3: number", "getter property 1\nsetter property 1"); - -goTo.marker('11'); -verify.completionListContains("p1", "(property) c1.p1: number", "p1 is property of c1"); -verify.completionListContains("p2", "(method) c1.p2(b: number): number", "sum with property"); -verify.completionListContains("p3", "(property) c1.p3: number", "getter property 1\nsetter property 1"); -verify.completionListContains("pp1", "(property) c1.pp1: number", "pp1 is property of c1"); -verify.completionListContains("pp2", "(method) c1.pp2(b: number): number", "sum with property"); -verify.completionListContains("pp3", "(property) c1.pp3: number", "getter property 2\nsetter property 2"); -verify.completionListContains("nc_p1", "(property) c1.nc_p1: number", ""); -verify.completionListContains("nc_p2", "(method) c1.nc_p2(b: number): number", ""); -verify.completionListContains("nc_p3", "(property) c1.nc_p3: number", ""); -verify.completionListContains("nc_pp1", "(property) c1.nc_pp1: number", ""); -verify.completionListContains("nc_pp2", "(method) c1.nc_pp2(b: number): number", ""); -verify.completionListContains("nc_pp3", "(property) c1.nc_pp3: number", ""); - -goTo.marker('12'); -verify.completionListContains("p1", "(property) c1.p1: number", "p1 is property of c1"); -verify.completionListContains("p2", "(method) c1.p2(b: number): number", "sum with property"); -verify.completionListContains("p3", "(property) c1.p3: number", "getter property 1\nsetter property 1"); -verify.completionListContains("pp1", "(property) c1.pp1: number", "pp1 is property of c1"); -verify.completionListContains("pp2", "(method) c1.pp2(b: number): number", "sum with property"); -verify.completionListContains("pp3", "(property) c1.pp3: number", "getter property 2\nsetter property 2"); -verify.completionListContains("nc_p1", "(property) c1.nc_p1: number", ""); -verify.completionListContains("nc_p2", "(method) c1.nc_p2(b: number): number", ""); -verify.completionListContains("nc_p3", "(property) c1.nc_p3: number", ""); -verify.completionListContains("nc_pp1", "(property) c1.nc_pp1: number", ""); -verify.completionListContains("nc_pp2", "(method) c1.nc_pp2(b: number): number", ""); -verify.completionListContains("nc_pp3", "(property) c1.nc_pp3: number", ""); - -verify.signatureHelp({ marker: "13", docComment: "sum with property", parameterDocComment: "number to add" }); -verify.completionListContains("value", "(parameter) value: number", "this is value"); - -verify.quickInfos({ + 3: ["(method) c1.p2(b: number): number", "sum with property"], + 6: ["(property) c1.p3: number", "getter property 1\nsetter property 1"], + "8q": ["(method) c1.p2(b: number): number", "sum with property"], + 10: ["(property) c1.p3: number", "getter property 1\nsetter property 1"], "13q": ["(method) c1.p2(b: number): number", "sum with property"], 14: ["(property) c1.pp1: number", "pp1 is property of c1"], - 15: ["(method) c1.pp2(b: number): number", "sum with property"] -}); - -goTo.marker('16'); -verify.completionListContains("p1", "(property) c1.p1: number", "p1 is property of c1"); -verify.completionListContains("p2", "(method) c1.p2(b: number): number", "sum with property"); -verify.completionListContains("p3", "(property) c1.p3: number", "getter property 1\nsetter property 1"); -verify.completionListContains("pp1", "(property) c1.pp1: number", "pp1 is property of c1"); -verify.completionListContains("pp2", "(method) c1.pp2(b: number): number", "sum with property"); -verify.completionListContains("pp3", "(property) c1.pp3: number", "getter property 2\nsetter property 2"); -verify.completionListContains("nc_p1", "(property) c1.nc_p1: number", ""); -verify.completionListContains("nc_p2", "(method) c1.nc_p2(b: number): number", ""); -verify.completionListContains("nc_p3", "(property) c1.nc_p3: number", ""); -verify.completionListContains("nc_pp1", "(property) c1.nc_pp1: number", ""); -verify.completionListContains("nc_pp2", "(method) c1.nc_pp2(b: number): number", ""); -verify.completionListContains("nc_pp3", "(property) c1.nc_pp3: number", ""); - -goTo.marker('17'); -verify.completionListContains("b", "(parameter) b: number", "number to add"); - -verify.quickInfoAt("18", "(property) c1.pp3: number", "getter property 2\nsetter property 2"); - -goTo.marker('19'); -verify.completionListContains("p1", "(property) c1.p1: number", "p1 is property of c1"); -verify.completionListContains("p2", "(method) c1.p2(b: number): number", "sum with property"); -verify.completionListContains("p3", "(property) c1.p3: number", "getter property 1\nsetter property 1"); -verify.completionListContains("pp1", "(property) c1.pp1: number", "pp1 is property of c1"); -verify.completionListContains("pp2", "(method) c1.pp2(b: number): number", "sum with property"); -verify.completionListContains("pp3", "(property) c1.pp3: number", "getter property 2\nsetter property 2"); -verify.completionListContains("nc_p1", "(property) c1.nc_p1: number", ""); -verify.completionListContains("nc_p2", "(method) c1.nc_p2(b: number): number", ""); -verify.completionListContains("nc_p3", "(property) c1.nc_p3: number", ""); -verify.completionListContains("nc_pp1", "(property) c1.nc_pp1: number", ""); -verify.completionListContains("nc_pp2", "(method) c1.nc_pp2(b: number): number", ""); -verify.completionListContains("nc_pp3", "(property) c1.nc_pp3: number", ""); - -verify.signatureHelp({ marker: "20", docComment: "sum with property", parameterDocComment: "number to add" }); -verify.quickInfoAt("20q", "(method) c1.pp2(b: number): number", "sum with property"); - -goTo.marker('21'); -verify.completionListContains("p1", "(property) c1.p1: number", "p1 is property of c1"); -verify.completionListContains("p2", "(method) c1.p2(b: number): number", "sum with property"); -verify.completionListContains("p3", "(property) c1.p3: number", "getter property 1\nsetter property 1"); -verify.completionListContains("pp1", "(property) c1.pp1: number", "pp1 is property of c1"); -verify.completionListContains("pp2", "(method) c1.pp2(b: number): number", "sum with property"); -verify.completionListContains("pp3", "(property) c1.pp3: number", "getter property 2\nsetter property 2"); -verify.completionListContains("nc_p1", "(property) c1.nc_p1: number", ""); -verify.completionListContains("nc_p2", "(method) c1.nc_p2(b: number): number", ""); -verify.completionListContains("nc_p3", "(property) c1.nc_p3: number", ""); -verify.completionListContains("nc_pp1", "(property) c1.nc_pp1: number", ""); -verify.completionListContains("nc_pp2", "(method) c1.nc_pp2(b: number): number", ""); -verify.completionListContains("nc_pp3", "(property) c1.nc_pp3: number", ""); - -verify.quickInfoAt("22", "(property) c1.pp3: number", "getter property 2\nsetter property 2"); - -goTo.marker('23'); -verify.completionListContains("p1", "(property) c1.p1: number", "p1 is property of c1"); -verify.completionListContains("p2", "(method) c1.p2(b: number): number", "sum with property"); -verify.completionListContains("p3", "(property) c1.p3: number", "getter property 1\nsetter property 1"); -verify.completionListContains("pp1", "(property) c1.pp1: number", "pp1 is property of c1"); -verify.completionListContains("pp2", "(method) c1.pp2(b: number): number", "sum with property"); -verify.completionListContains("pp3", "(property) c1.pp3: number", "getter property 2\nsetter property 2"); -verify.completionListContains("nc_p1", "(property) c1.nc_p1: number", ""); -verify.completionListContains("nc_p2", "(method) c1.nc_p2(b: number): number", ""); -verify.completionListContains("nc_p3", "(property) c1.nc_p3: number", ""); -verify.completionListContains("nc_pp1", "(property) c1.nc_pp1: number", ""); -verify.completionListContains("nc_pp2", "(method) c1.nc_pp2(b: number): number", ""); -verify.completionListContains("nc_pp3", "(property) c1.nc_pp3: number", ""); - -goTo.marker('24'); -verify.completionListContains("p1", "(property) c1.p1: number", "p1 is property of c1"); -verify.completionListContains("p2", "(method) c1.p2(b: number): number", "sum with property"); -verify.completionListContains("p3", "(property) c1.p3: number", "getter property 1\nsetter property 1"); -verify.completionListContains("pp1", "(property) c1.pp1: number", "pp1 is property of c1"); -verify.completionListContains("pp2", "(method) c1.pp2(b: number): number", "sum with property"); -verify.completionListContains("pp3", "(property) c1.pp3: number", "getter property 2\nsetter property 2"); -verify.completionListContains("nc_p1", "(property) c1.nc_p1: number", ""); -verify.completionListContains("nc_p2", "(method) c1.nc_p2(b: number): number", ""); -verify.completionListContains("nc_p3", "(property) c1.nc_p3: number", ""); -verify.completionListContains("nc_pp1", "(property) c1.nc_pp1: number", ""); -verify.completionListContains("nc_pp2", "(method) c1.nc_pp2(b: number): number", ""); -verify.completionListContains("nc_pp3", "(property) c1.nc_pp3: number", ""); - -verify.signatureHelp({ marker: "25", docComment: "sum with property", parameterDocComment: "number to add" }); -verify.completionListContains("value", "(parameter) value: number", "this is value"); - -verify.quickInfos({ + 15: ["(method) c1.pp2(b: number): number", "sum with property"], + 18: ["(property) c1.pp3: number", "getter property 2\nsetter property 2"], + "20q": ["(method) c1.pp2(b: number): number", "sum with property"], + 22: ["(property) c1.pp3: number", "getter property 2\nsetter property 2"], "25q": ["(method) c1.pp2(b: number): number", "sum with property"], 26: ["constructor c1(): c1", "Constructor method"], 27: ["(property) c1.s1: number", "s1 is static property of c1"], - 28: ["(method) c1.s2(b: number): number", "static sum with property"] -}); - -goTo.marker('29'); -verify.completionListContains("c1", "class c1", "This is comment for c1"); - -goTo.marker('30'); -verify.completionListContains("s1", "(property) c1.s1: number", "s1 is static property of c1"); -verify.completionListContains("s2", "(method) c1.s2(b: number): number", "static sum with property"); -verify.completionListContains("s3", "(property) c1.s3: number", "static getter property\nsetter property 3"); -verify.completionListContains("nc_s1", "(property) c1.nc_s1: number", ""); -verify.completionListContains("nc_s2", "(method) c1.nc_s2(b: number): number", ""); -verify.completionListContains("nc_s3", "(property) c1.nc_s3: number", ""); - -goTo.marker('31'); -verify.completionListContains("b", "(parameter) b: number", "number to add"); - -verify.quickInfoAt("32", "(property) c1.s3: number", "static getter property\nsetter property 3"); - -goTo.marker('33'); -verify.completionListContains("c1", "class c1", "This is comment for c1"); - -goTo.marker('34'); -verify.completionListContains("s1", "(property) c1.s1: number", "s1 is static property of c1"); -verify.completionListContains("s2", "(method) c1.s2(b: number): number", "static sum with property"); -verify.completionListContains("s3", "(property) c1.s3: number", "static getter property\nsetter property 3"); -verify.completionListContains("nc_s1", "(property) c1.nc_s1: number", ""); -verify.completionListContains("nc_s2", "(method) c1.nc_s2(b: number): number", ""); -verify.completionListContains("nc_s3", "(property) c1.nc_s3: number", ""); - -verify.signatureHelp({ marker: "35", docComment: "static sum with property", parameterDocComment: "number to add" }); -verify.completionListContains("c1", "class c1", "This is comment for c1"); -verify.quickInfoAt("35q", "(method) c1.s2(b: number): number", "static sum with property"); - -goTo.marker('36'); -verify.completionListContains("s1", "(property) c1.s1: number", "s1 is static property of c1"); -verify.completionListContains("s2", "(method) c1.s2(b: number): number", "static sum with property"); -verify.completionListContains("s3", "(property) c1.s3: number", "static getter property\nsetter property 3"); -verify.completionListContains("nc_s1", "(property) c1.nc_s1: number", ""); -verify.completionListContains("nc_s2", "(method) c1.nc_s2(b: number): number", ""); -verify.completionListContains("nc_s3", "(property) c1.nc_s3: number", ""); - -verify.quickInfoAt("37", "(property) c1.s3: number", "static getter property\nsetter property 3"); - -goTo.marker('38'); -verify.completionListContains("c1", "class c1", "This is comment for c1"); - -goTo.marker('39'); -verify.completionListContains("s1", "(property) c1.s1: number", "s1 is static property of c1"); -verify.completionListContains("s2", "(method) c1.s2(b: number): number", "static sum with property"); -verify.completionListContains("s3", "(property) c1.s3: number", "static getter property\nsetter property 3"); -verify.completionListContains("nc_s1", "(property) c1.nc_s1: number", ""); -verify.completionListContains("nc_s2", "(method) c1.nc_s2(b: number): number", ""); -verify.completionListContains("nc_s3", "(property) c1.nc_s3: number", ""); - -goTo.marker('40'); -verify.completionListContains("c1", "class c1", "This is comment for c1"); - -goTo.marker('41'); -verify.completionListContains("s1", "(property) c1.s1: number", "s1 is static property of c1"); -verify.completionListContains("s2", "(method) c1.s2(b: number): number", "static sum with property"); -verify.completionListContains("s3", "(property) c1.s3: number", "static getter property\nsetter property 3"); -verify.completionListContains("nc_s1", "(property) c1.nc_s1: number", ""); -verify.completionListContains("nc_s2", "(method) c1.nc_s2(b: number): number", ""); -verify.completionListContains("nc_s3", "(property) c1.nc_s3: number", ""); - -verify.signatureHelp({ marker: "42", docComment: "static sum with property", parameterDocComment: "number to add" }); -verify.completionListContains("value", "(parameter) value: number", "this is value"); -verify.quickInfos({ + 28: ["(method) c1.s2(b: number): number", "static sum with property"], + 32: ["(property) c1.s3: number", "static getter property\nsetter property 3"], + "35q": ["(method) c1.s2(b: number): number", "static sum with property"], + 37: ["(property) c1.s3: number", "static getter property\nsetter property 3"], "42q": ["(method) c1.s2(b: number): number", "static sum with property"], 43: "(property) c1.nc_p1: number", - 44: "(method) c1.nc_p2(b: number): number" -}); - -goTo.marker('45'); -verify.completionListContains("b", "(parameter) b: number", ""); - -verify.quickInfoAt("46", "(property) c1.nc_p3: number"); - -verify.signatureHelp({ marker: "47", docComment: "" }); -verify.quickInfos({ + 44: "(method) c1.nc_p2(b: number): number", + 46: "(property) c1.nc_p3: number", "47q": "(method) c1.nc_p2(b: number): number", - 48: "(property) c1.nc_p3: number" -}); - -verify.signatureHelp({ marker: "49", docComment: "" }); -verify.completionListContains("value", "(parameter) value: number", ""); -verify.quickInfos({ + 48: "(property) c1.nc_p3: number", "49q": "(method) c1.nc_p2(b: number): number", 50: "(property) c1.nc_pp1: number", - 51: "(method) c1.nc_pp2(b: number): number" -}); - -goTo.marker('52'); -verify.completionListContains("b", "(parameter) b: number", ""); - -verify.quickInfoAt("53", "(property) c1.nc_pp3: number"); - -verify.signatureHelp({ marker: "54", docComment: "" }); -verify.quickInfos({ + 51: "(method) c1.nc_pp2(b: number): number", + 53: "(property) c1.nc_pp3: number", "54q": "(method) c1.nc_pp2(b: number): number", - 55: "(property) c1.nc_pp3: number" -}); - -verify.signatureHelp({ marker: "56", docComment: "" }); -verify.completionListContains("value", "(parameter) value: number", ""); -verify.quickInfos({ + 55: "(property) c1.nc_pp3: number", "56q": "(method) c1.nc_pp2(b: number): number", 57: "(property) c1.nc_s1: number", - 58: "(method) c1.nc_s2(b: number): number" -}); - -goTo.marker('59'); -verify.completionListContains("b", "(parameter) b: number", ""); - -verify.quickInfoAt("60", "(property) c1.nc_s3: number"); - -verify.signatureHelp({ marker: "61", docComment: "" }); -verify.quickInfos({ + 58: "(method) c1.nc_s2(b: number): number", + 60: "(property) c1.nc_s3: number", "61q": "(method) c1.nc_s2(b: number): number", - 62: "(property) c1.nc_s3: number" -}); - -verify.signatureHelp({ marker: "63", docComment: "" }); -verify.completionListContains("value", "(parameter) value: number", ""); -verify.quickInfos({ + 62: "(property) c1.nc_s3: number", "63q": "(method) c1.nc_s2(b: number): number", - 64: "var i1: c1" -}); - -verify.signatureHelp({ marker: "65", docComment: "Constructor method" }); -verify.quickInfos({ + 64: "var i1: c1", "65q": ["constructor c1(): c1", "Constructor method"], - 66: "var i1_p: number" -}); - -goTo.marker("67"); -verify.quickInfoIs("(property) c1.p1: number", "p1 is property of c1"); -verify.completionListContains("p1", "(property) c1.p1: number", "p1 is property of c1"); -verify.completionListContains("p2", "(method) c1.p2(b: number): number", "sum with property"); -verify.completionListContains("p3", "(property) c1.p3: number", "getter property 1\nsetter property 1"); -verify.completionListContains("nc_p1", "(property) c1.nc_p1: number", ""); -verify.completionListContains("nc_p2", "(method) c1.nc_p2(b: number): number", ""); -verify.completionListContains("nc_p3", "(property) c1.nc_p3: number", ""); - -verify.quickInfos({ + 66: "var i1_p: number", 68: "var i1_f: (b: number) => number", 69: ["(method) c1.p2(b: number): number", "sum with property"], - 70: "var i1_r: number" -}); - -verify.signatureHelp({ marker: "71", docComment: "sum with property", parameterDocComment: "number to add" }); - -verify.quickInfos({ + 70: "var i1_r: number", "71q": ["(method) c1.p2(b: number): number", "sum with property"], 72: "var i1_prop: number", 73: ["(property) c1.p3: number", "getter property 1\nsetter property 1"], @@ -477,42 +298,17 @@ verify.quickInfos({ 77: "(property) c1.nc_p1: number", 78: "var i1_ncf: (b: number) => number", 79: "(method) c1.nc_p2(b: number): number", - 80: "var i1_ncr: number" -}); - -verify.signatureHelp({ marker: "81", docComment: "" }); - -verify.quickInfos({ + 80: "var i1_ncr: number", "81q": "(method) c1.nc_p2(b: number): number", 82: "var i1_ncprop: number", 83: "(property) c1.nc_p3: number", 84: "(property) c1.nc_p3: number", 85: "var i1_ncprop: number", - 86: "var i1_s_p: number" -}); - -goTo.marker('87'); -verify.quickInfoIs("class c1", "This is comment for c1"); -verify.completionListContains("c1", "class c1", "This is comment for c1"); - -goTo.marker('88'); -verify.quickInfoIs("(property) c1.s1: number", "s1 is static property of c1"); -verify.completionListContains("s1", "(property) c1.s1: number", "s1 is static property of c1"); -verify.completionListContains("s2", "(method) c1.s2(b: number): number", "static sum with property"); -verify.completionListContains("s3", "(property) c1.s3: number", "static getter property\nsetter property 3"); -verify.completionListContains("nc_s1", "(property) c1.nc_s1: number", ""); -verify.completionListContains("nc_s2", "(method) c1.nc_s2(b: number): number", ""); -verify.completionListContains("nc_s3", "(property) c1.nc_s3: number", ""); - -verify.quickInfos({ + 86: "var i1_s_p: number", + 87: ["class c1", "This is comment for c1"], 89: "var i1_s_f: (b: number) => number", 90: ["(method) c1.s2(b: number): number", "static sum with property"], - 91: "var i1_s_r: number" -}); - -verify.signatureHelp({ marker: "92", docComment: "static sum with property", parameterDocComment: "number to add" }); - -verify.quickInfos({ + 91: "var i1_s_r: number", "92q": ["(method) c1.s2(b: number): number", "static sum with property"], 93: "var i1_s_prop: number", 94: ["(property) c1.s3: number", "static getter property\nsetter property 3"], @@ -522,69 +318,25 @@ verify.quickInfos({ 98: "(property) c1.nc_s1: number", 99: "var i1_s_ncf: (b: number) => number", 100: "(method) c1.nc_s2(b: number): number", - 101: "var i1_s_ncr: number" -}); - -verify.signatureHelp({ marker: "102", docComment: "" }); -verify.quickInfos({ + 101: "var i1_s_ncr: number", "102q": "(method) c1.nc_s2(b: number): number", 103: "var i1_s_ncprop: number", 104: "(property) c1.nc_s3: number", 105: "(property) c1.nc_s3: number", 106: "var i1_s_ncprop: number", 107: "var i1_c: typeof c1", - 108: ["class c1", "This is comment for c1"] -}); - -goTo.marker('109'); -verify.completionListContains("c1", "class c1", "This is comment for c1"); -verify.completionListContains("i1", "var i1: c1", ""); -verify.completionListContains("i1_p", "var i1_p: number", ""); -verify.completionListContains("i1_f", "var i1_f: (b: number) => number", ""); -verify.completionListContains("i1_r", "var i1_r: number", ""); -verify.completionListContains("i1_prop", "var i1_prop: number", ""); -verify.completionListContains("i1_nc_p", "var i1_nc_p: number", ""); -verify.completionListContains("i1_ncf", "var i1_ncf: (b: number) => number", ""); -verify.completionListContains("i1_ncr", "var i1_ncr: number", ""); -verify.completionListContains("i1_ncprop", "var i1_ncprop: number", ""); -verify.completionListContains("i1_s_p", "var i1_s_p: number", ""); -verify.completionListContains("i1_s_f", "var i1_s_f: (b: number) => number", ""); -verify.completionListContains("i1_s_r", "var i1_s_r: number", ""); -verify.completionListContains("i1_s_prop", "var i1_s_prop: number", ""); -verify.completionListContains("i1_s_nc_p", "var i1_s_nc_p: number", ""); -verify.completionListContains("i1_s_ncf", "var i1_s_ncf: (b: number) => number", ""); -verify.completionListContains("i1_s_ncr", "var i1_s_ncr: number", ""); -verify.completionListContains("i1_s_ncprop", "var i1_s_ncprop: number", ""); - -verify.completionListContains("i1_c", "var i1_c: typeof c1", ""); - -goTo.marker('110'); -verify.quickInfoIs("(property) cProperties.p2: number", "setter only property"); -verify.completionListContains("p1", "(property) cProperties.p1: number", "getter only property"); -verify.completionListContains("p2", "(property) cProperties.p2: number", "setter only property"); -verify.completionListContains("nc_p1", "(property) cProperties.nc_p1: number", ""); -verify.completionListContains("nc_p2", "(property) cProperties.nc_p2: number", ""); - -verify.quickInfos({ + 108: ["class c1", "This is comment for c1"], + 110: ["(property) cProperties.p2: number", "setter only property"], 111: ["(property) cProperties.p1: number", "getter only property"], 112: "(property) cProperties.nc_p2: number", - 113: "(property) cProperties.nc_p1: number" -}); - -goTo.marker('114'); -verify.completionListContains("a", "(property) cWithConstructorProperty.a: number", "more info about a\nthis is first parameter a"); -verify.quickInfoIs("(property) cWithConstructorProperty.a: number", "more info about a\nthis is first parameter a"); - -goTo.marker('115'); -verify.completionListContains("a", "(parameter) a: number", "more info about a\nthis is first parameter a"); -verify.quickInfoIs("(parameter) a: number", "more info about a\nthis is first parameter a"); - -verify.quickInfos({ + 113: "(property) cProperties.nc_p1: number", + 114: ["(property) cWithConstructorProperty.a: number", "more info about a\nthis is first parameter a"], + 115: ["(parameter) a: number", "more info about a\nthis is first parameter a"], 116: "this: this", 117: "(local var) bbbb: number", 118: "(local var) bbbb: number", 119: [ "constructor cWithConstructorProperty(a: number): cWithConstructorProperty", "this is class cWithConstructorProperty's constructor" - ] + ], }); diff --git a/tests/cases/fourslash/commentsCommentParsing.ts b/tests/cases/fourslash/commentsCommentParsing.ts index 8f7d35ce0f976..fe3d44d3e6aa5 100644 --- a/tests/cases/fourslash/commentsCommentParsing.ts +++ b/tests/cases/fourslash/commentsCommentParsing.ts @@ -280,10 +280,13 @@ verify.signatureHelp({ }); verify.quickInfoAt("17aq", "(parameter) b: number", "second number"); -goTo.marker('18'); -verify.quickInfoIs("(parameter) a: number", "first number"); -verify.completionListContains("a", "(parameter) a: number", "first number"); -verify.completionListContains("b", "(parameter) b: number", "second number"); +verify.completions({ + marker: "18", + includes: [ + { name: "a", text: "(parameter) a: number", documentation: "first number", tags: [{ name: "param", text: "a first number" }] }, + { name: "b", text: "(parameter) b: number", documentation: "second number", tags: [{ name: "param", text: "b second number" }] }, + ], +}); const multiplyTags: ReadonlyArray = [ { name: "param", text: "" }, @@ -316,9 +319,18 @@ verify.quickInfoAt("22aq", "(parameter) d: any"); verify.signatureHelp({ marker: "23", docComment: "This is multiplication function", parameterDocComment: "LastParam", tags: multiplyTags }); verify.quickInfoAt("23aq", "(parameter) e: any", "LastParam"); -goTo.marker('24'); -verify.completionListContains("aOrb", "(parameter) aOrb: any", ""); -verify.completionListContains("opt", "(parameter) opt: any", "optional parameter"); +verify.completions({ + marker: "24", + includes: [ + { name: "aOrb", text: "(parameter) aOrb: any" }, + { + name: "opt", + text: "(parameter) opt: any", + documentation: "optional parameter", + tags: [{ name: "param", text: "opt optional parameter" }], + }, + ] +}); verify.signatureHelp({ marker: "25", @@ -337,9 +349,32 @@ verify.quickInfos({ "26aq": "(parameter) b: string" }); -goTo.marker('27'); -verify.completionListContains("multiply", "function multiply(a: number, b: number, c?: number, d?: any, e?: any): void", "This is multiplication function"); -verify.completionListContains("f1", "function f1(a: number): any (+1 overload)", "fn f1 with number"); +verify.completions({ + marker: "27", + includes: [ + { + name: "multiply", + text: "function multiply(a: number, b: number, c?: number, d?: any, e?: any): void", + documentation: "This is multiplication function", + tags: [ + { name: "param", text: "" }, + { name: "param", text: "a first number" }, + { name: "param", text: "b" }, + { name: "param", text: "c" }, + { name: "param", text: "d" }, + { name: "anotherTag", text: undefined }, + { name: "param", text: "e LastParam" }, + { name: "anotherTag", text: undefined }, + ], + }, + { + name: "f1", + text: "function f1(a: number): any (+1 overload)", + documentation: "fn f1 with number", + tags: [{ name: "param", text: "b about b" }], + }, + ], +}); const subtractDoc = "This is subtract function"; const subtractTags: ReadonlyArray = [ @@ -429,11 +464,25 @@ verify.quickInfos({ verify.signatureHelp({ marker: "38", docComment: concatDoc, parameterDocComment: "is second string", tags: concatTags }); verify.quickInfoAt("38aq", "(parameter) bar: string", "is second string"); -goTo.marker('39'); -verify.completionListContains("a", "(parameter) a: number", "this is inline comment for a\nit is first parameter"); -verify.completionListContains("b", "(parameter) b: number", "this is inline comment for b"); -verify.completionListContains("c", "(parameter) c: number", "it is third parameter"); -verify.completionListContains("d", "(parameter) d: number", ""); +verify.completions({ + marker: "39", + includes: [ + { + name: "a", + text: "(parameter) a: number", + documentation: "this is inline comment for a\nit is first parameter", + tags: [{ name: "param", text: "a it is first parameter" }], + }, + { name: "b", text: "(parameter) b: number", documentation: "this is inline comment for b" }, + { + name: "c", + text: "(parameter) c: number", + documentation: "it is third parameter", + tags: [{ name: "param", text: "c it is third parameter" }], + }, + { name: "d", text: "(parameter) d: number" }, + ], +}); const jsdocTestDocComment = "this is jsdoc style function with param tag as well as inline parameter help"; const jsdocTestTags: ReadonlyArray = [ @@ -461,10 +510,22 @@ verify.quickInfoAt("42aq", "(parameter) c: number", "it is third parameter"); verify.signatureHelp({ marker: "43", docComment: jsdocTestDocComment, tags: jsdocTestTags }); verify.quickInfoAt("43aq", "(parameter) d: number"); -goTo.marker('44'); -verify.completionListContains("jsDocParamTest", "function jsDocParamTest(a: number, b: number, c: number, d: number): number", jsdocTestDocComment); -verify.completionListContains("x", "var x: any", "This is a comment"); -verify.completionListContains("y", "var y: any", "This is a comment"); +verify.completions({ + marker: "44", + includes: [ + { + name: "jsDocParamTest", + text: "function jsDocParamTest(a: number, b: number, c: number, d: number): number", + documentation: jsdocTestDocComment, + tags: [ + { name: "param", text: "a it is first parameter" }, + { name: "param", text: "c it is third parameter" }, + ], + }, + { name: "x", text: "var x: any", documentation: "This is a comment" }, + { name: "y", text: "var y: any", documentation: "This is a comment" }, + ], +}); verify.signatureHelp({ marker: "45", docComment: "This is function comment\nAnd properly aligned comment" }); verify.quickInfoAt("45q", "function jsDocCommentAlignmentTest1(): void", "This is function comment\nAnd properly aligned comment"); diff --git a/tests/cases/fourslash/commentsEnums.ts b/tests/cases/fourslash/commentsEnums.ts index 9fb29d4442b33..54a5af1e83755 100644 --- a/tests/cases/fourslash/commentsEnums.ts +++ b/tests/cases/fourslash/commentsEnums.ts @@ -14,22 +14,23 @@ verify.quickInfos({ 1: ["enum Colors", "Enum of colors"], 2: ["(enum member) Colors.Cornflower = 0", "Fancy name for 'blue'"], 3: ["(enum member) Colors.FancyPink = 1", "Fancy name for 'pink'"], - 4: "var x: Colors" + 4: "var x: Colors", + 5: ["enum Colors", "Enum of colors"], + 6: ["(enum member) Colors.Cornflower = 0", "Fancy name for 'blue'"], + 7: ["(enum member) Colors.FancyPink = 1", "Fancy name for 'pink'"], }); -verify.completions({ - marker: "5", - includes: { name: "Colors", text: "enum Colors", documentation: "Enum of colors" }, - isNewIdentifierLocation: true, -}); -verify.quickInfoIs("enum Colors", "Enum of colors"); - -const completions = [ - { name: "Cornflower", text: "(enum member) Colors.Cornflower = 0", documentation: "Fancy name for 'blue'" }, - { name: "FancyPink", text: "(enum member) Colors.FancyPink = 1", documentation: "Fancy name for 'pink'" }, -]; -verify.completions({ marker: "6", includes: completions }); -verify.quickInfoIs("(enum member) Colors.Cornflower = 0", "Fancy name for 'blue'"); - -verify.completions({ marker: "7", includes: completions }); -verify.quickInfoIs("(enum member) Colors.FancyPink = 1", "Fancy name for 'pink'"); \ No newline at end of file +verify.completions( + { + marker: "5", + includes: { name: "Colors", text: "enum Colors", documentation: "Enum of colors" }, + isNewIdentifierLocation: true, + }, + { + marker: ["6", "7"], + exact: [ + { name: "Cornflower", text: "(enum member) Colors.Cornflower = 0", documentation: "Fancy name for 'blue'" }, + { name: "FancyPink", text: "(enum member) Colors.FancyPink = 1", documentation: "Fancy name for 'pink'" }, + ] + }, +); diff --git a/tests/cases/fourslash/commentsExternalModules.ts b/tests/cases/fourslash/commentsExternalModules.ts index c1c12d8a3ce8e..25dc25b0331d5 100644 --- a/tests/cases/fourslash/commentsExternalModules.ts +++ b/tests/cases/fourslash/commentsExternalModules.ts @@ -34,49 +34,75 @@ goTo.file("commentsExternalModules_file0.ts"); verify.quickInfoAt("1", "namespace m1", "Namespace comment"); -goTo.marker('2'); -verify.completionListContains("b", "var b: number", "b's comment"); -verify.completionListContains("foo", "function foo(): number", "foo's comment"); +verify.completions({ + marker: "2", + includes: [ + { name: "b", text: "var b: number", documentation: "b's comment" }, + { name: "foo", text: "function foo(): number", documentation: "foo's comment" }, + ] +}); verify.signatureHelp({ marker: "3", docComment: "foo's comment" }); verify.quickInfoAt("3q", "function foo(): number", "foo's comment"); -goTo.marker('4'); -verify.completionListContains("m1", "namespace m1", "Namespace comment"); +verify.completions({ + marker: "4", + includes: { name: "m1", text: "namespace m1", documentation: "Namespace comment" }, +}); -goTo.marker('5'); -verify.completionListContains("b", "var m1.b: number", "b's comment"); -verify.completionListContains("fooExport", "function m1.fooExport(): number", "exported function"); -verify.completionListContains("m2", "namespace m1.m2"); +verify.completions({ + marker: "5", + includes: [ + { name: "b", text: "var m1.b: number", documentation: "b's comment" }, + { name: "fooExport", text: "function m1.fooExport(): number", documentation: "exported function" }, + { name: "m2", text: "namespace m1.m2", documentation: "m2 comments" }, + ], +}); verify.signatureHelp({ marker: "6", docComment: "exported function" }); verify.quickInfoAt("6q", "function m1.fooExport(): number", "exported function"); verify.quickInfoAt("7", "var myvar: m1.m2.c"); -goTo.marker('8'); -verify.completionListContains("c", "constructor m1.m2.c(): m1.m2.c", "class comment;"); -verify.completionListContains("i", "var m1.m2.i: m1.m2.c", "i"); +verify.completions({ + marker: "8", + includes: [ + { name: "c", text: "constructor m1.m2.c(): m1.m2.c", documentation: "class comment;" }, + { name: "i", text: "var m1.m2.i: m1.m2.c", documentation: "i" }, + ], +}); goTo.file("commentsExternalModules_file1.ts"); verify.quickInfoAt("9", 'import extMod = require("./commentsExternalModules_file0")', "This is on import declaration"); -goTo.marker('10'); -verify.completionListContains("extMod", 'import extMod = require("./commentsExternalModules_file0")', "This is on import declaration"); - -goTo.marker('11'); -verify.completionListContains("m1", "namespace extMod.m1"); - -goTo.marker('12'); -verify.completionListContains("b", "var extMod.m1.b: number", "b's comment"); -verify.completionListContains("fooExport", "function extMod.m1.fooExport(): number", "exported function"); -verify.completionListContains("m2", "namespace extMod.m1.m2"); +verify.completions( + { + marker: "10", + includes: { name: "extMod", text: 'import extMod = require("./commentsExternalModules_file0")', documentation: "This is on import declaration" }, + }, + { + marker: "11", + includes: { name: "m1", text: "namespace extMod.m1", documentation: "Namespace comment" }, + }, + { + marker: "12", + includes: [ + { name: "b", text: "var extMod.m1.b: number", documentation: "b's comment" }, + { name: "fooExport", text: "function extMod.m1.fooExport(): number", documentation: "exported function" }, + { name: "m2", text: "namespace extMod.m1.m2", documentation: "m2 comments" }, + ], + }, +); verify.signatureHelp({ marker: "13", docComment: "exported function" }); verify.quickInfoAt("13q", "function extMod.m1.fooExport(): number", "exported function"); verify.quickInfoAt("14", "var newVar: extMod.m1.m2.c"); -goTo.marker('15'); -verify.completionListContains("c", "constructor extMod.m1.m2.c(): extMod.m1.m2.c", "class comment;"); -verify.completionListContains("i", "var extMod.m1.m2.i: extMod.m1.m2.c", "i"); +verify.completions({ + marker: "15", + exact: [ + { name: "c", text: "constructor extMod.m1.m2.c(): extMod.m1.m2.c", documentation: "class comment;" }, + { name: "i", text: "var extMod.m1.m2.i: extMod.m1.m2.c", documentation: "i" }, + ], +}); diff --git a/tests/cases/fourslash/commentsFunctionDeclaration.ts b/tests/cases/fourslash/commentsFunctionDeclaration.ts index 7ecb46fb042a6..609621f633623 100644 --- a/tests/cases/fourslash/commentsFunctionDeclaration.ts +++ b/tests/cases/fourslash/commentsFunctionDeclaration.ts @@ -24,8 +24,7 @@ verify.quickInfoAt("1", "function foo(): void", "This comment should appear for verify.quickInfoAt("2", "function foo(): void", "This comment should appear for foo"); -goTo.marker('3'); -verify.completionListContains('foo', 'function foo(): void', 'This comment should appear for foo'); +verify.completions({ marker: "3", includes: { name: "foo", text: "function foo(): void", documentation: "This comment should appear for foo" }}) verify.signatureHelp({ marker: "4", docComment: "This comment should appear for foo" }); @@ -33,14 +32,22 @@ verify.quickInfoAt("5", "function fooWithParameters(a: string, b: number): void" verify.quickInfoAt("6", "(local var) d: string"); -goTo.marker('7'); -verify.completionListContains('a', '(parameter) a: string', 'this is comment about a'); -verify.completionListContains('b', '(parameter) b: number', 'this is comment for b'); +verify.completions({ + marker: "7", + includes: [ + { name: "a", text: "(parameter) a: string", documentation: "this is comment about a" }, + { name: "b", text: "(parameter) b: number", documentation: "this is comment for b" }, + ], + isNewIdentifierLocation: true, +}); verify.quickInfoAt("8", "function fooWithParameters(a: string, b: number): void", "This is comment for function signature"); goTo.marker('9'); -verify.completionListContains('fooWithParameters', 'function fooWithParameters(a: string, b: number): void', 'This is comment for function signature'); +verify.completions({ + marker: "9", + includes: { name: "fooWithParameters", text: "function fooWithParameters(a: string, b: number): void", documentation: "This is comment for function signature" } +}) verify.signatureHelp( { marker: "10", docComment: "This is comment for function signature", parameterDocComment: "this is comment about a" }, diff --git a/tests/cases/fourslash/commentsFunctionExpression.ts b/tests/cases/fourslash/commentsFunctionExpression.ts index f62572a466616..01bbf40045ca0 100644 --- a/tests/cases/fourslash/commentsFunctionExpression.ts +++ b/tests/cases/fourslash/commentsFunctionExpression.ts @@ -34,16 +34,24 @@ verify.quickInfoAt("1", "var lambdaFoo: (a: number, b: number) => number", "this is lambda comment\nlambdaFoo var comment"); -goTo.marker('2'); -verify.completionListContains('a', '(parameter) a: number', 'param a'); -verify.completionListContains('b', '(parameter) b: number', 'param b'); +verify.completions({ + marker: "2", + includes: [ + { name: "a", text: "(parameter) a: number", documentation: "param a" }, + { name: "b", text: "(parameter) b: number", documentation: "param b" }, + ], +}); // pick up doccomments from the lambda itself verify.quickInfoAt("3", "var lambddaNoVarComment: (a: number, b: number) => number", "this is lambda multiplication"); -goTo.marker('4'); -verify.completionListContains('lambdaFoo', 'var lambdaFoo: (a: number, b: number) => number', "this is lambda comment\nlambdaFoo var comment"); -verify.completionListContains('lambddaNoVarComment', 'var lambddaNoVarComment: (a: number, b: number) => number', 'this is lambda multiplication'); +verify.completions({ + marker: "4", + includes: [ + { name: "lambdaFoo", text: "var lambdaFoo: (a: number, b: number) => number", documentation: "this is lambda comment\nlambdaFoo var comment" }, + { name: "lambddaNoVarComment", text: "var lambddaNoVarComment: (a: number, b: number) => number", documentation: "this is lambda multiplication" }, + ] +}); verify.signatureHelp( { @@ -73,11 +81,33 @@ verify.quickInfos({ ] }); -goTo.marker('15'); -verify.completionListContains('s', '(parameter) s: string', "On parameter\nparam on expression\nthe first parameter!"); +verify.completions({ + marker: "15", + includes: { + name: "s", + text: "(parameter) s: string", + documentation: "On parameter\nparam on expression\nthe first parameter!", + tags: [ + { name: "param", text: "s param on expression" }, + { name: "param", text: "s the first parameter!" }, + ], + }, +}); verify.quickInfoAt("16", "var assigned: (s: string) => number", "Summary on expression\nOn variable"); -goTo.marker('17'); -verify.completionListContains("assigned", "var assigned: (s: string) => number", "Summary on expression\nOn variable"); +verify.completions({ + marker: "17", + includes: [{ + name: "assigned", + text: "var assigned: (s: string) => number", + documentation: "Summary on expression\nOn variable", + tags: [ + { name: "param", text: "s param on expression" }, + { name: "returns", text: "return on expression" }, + { name: "param", text: "s the first parameter!" }, + { name: "returns", text: "the parameter's length" }, + ], + }, +]}); verify.signatureHelp({ marker: "18", docComment: "Summary on expression\nOn variable", diff --git a/tests/cases/fourslash/commentsInheritance.ts b/tests/cases/fourslash/commentsInheritance.ts index aac3cf287f4fe..d5111e04a47a3 100644 --- a/tests/cases/fourslash/commentsInheritance.ts +++ b/tests/cases/fourslash/commentsInheritance.ts @@ -220,19 +220,23 @@ //// } ////} -goTo.marker('1'); -verify.completionListContains("i1_p1", "(property) i1.i1_p1: number", "i1_p1"); -verify.completionListContains("i1_f1", "(method) i1.i1_f1(): void", "i1_f1"); -verify.completionListContains("i1_l1", "(property) i1.i1_l1: () => void", "i1_l1"); -verify.completionListContains("i1_nc_p1", "(property) i1.i1_nc_p1: number", ""); -verify.completionListContains("i1_nc_f1", "(method) i1.i1_nc_f1(): void", ""); -verify.completionListContains("i1_nc_l1", "(property) i1.i1_nc_l1: () => void", ""); -verify.completionListContains("p1", "(property) i1.p1: number", ""); -verify.completionListContains("f1", "(method) i1.f1(): void", ""); -verify.completionListContains("l1", "(property) i1.l1: () => void", ""); -verify.completionListContains("nc_p1", "(property) i1.nc_p1: number", ""); -verify.completionListContains("nc_f1", "(method) i1.nc_f1(): void", ""); -verify.completionListContains("nc_l1", "(property) i1.nc_l1: () => void", ""); +verify.completions({ + marker: ["1", "11"], + includes: [ + { name: "i1_p1", text: "(property) i1.i1_p1: number", documentation: "i1_p1" }, + { name: "i1_f1", text: "(method) i1.i1_f1(): void", documentation: "i1_f1" }, + { name: "i1_l1", text: "(property) i1.i1_l1: () => void", documentation: "i1_l1" }, + { name: "i1_nc_p1", text: "(property) i1.i1_nc_p1: number" }, + { name: "i1_nc_f1", text: "(method) i1.i1_nc_f1(): void" }, + { name: "i1_nc_l1", text: "(property) i1.i1_nc_l1: () => void" }, + { name: "p1", text: "(property) i1.p1: number" }, + { name: "f1", text: "(method) i1.f1(): void" }, + { name: "l1", text: "(property) i1.l1: () => void" }, + { name: "nc_p1", text: "(property) i1.nc_p1: number" }, + { name: "nc_f1", text: "(method) i1.nc_f1(): void" }, + { name: "nc_l1", text: "(property) i1.nc_l1: () => void" }, + ], +}); verify.signatureHelp( { marker: "2", docComment: "i1_f1" }, { marker: ["3", "4", "5", "l2", "l3", "l4", "l5"], docComment: "" }, @@ -250,19 +254,23 @@ verify.quickInfos({ l5q: "(property) i1.nc_l1: () => void" }); -goTo.marker('6'); -verify.completionListContains("i1_p1", "(property) c1.i1_p1: number", "i1_p1"); -verify.completionListContains("i1_f1", "(method) c1.i1_f1(): void", "i1_f1"); -verify.completionListContains("i1_l1", "(property) c1.i1_l1: () => void", "i1_l1"); -verify.completionListContains("i1_nc_p1", "(property) c1.i1_nc_p1: number", ""); -verify.completionListContains("i1_nc_f1", "(method) c1.i1_nc_f1(): void", ""); -verify.completionListContains("i1_nc_l1", "(property) c1.i1_nc_l1: () => void", ""); -verify.completionListContains("p1", "(property) c1.p1: number", "c1_p1"); -verify.completionListContains("f1", "(method) c1.f1(): void", "c1_f1"); -verify.completionListContains("l1", "(property) c1.l1: () => void", "c1_l1"); -verify.completionListContains("nc_p1", "(property) c1.nc_p1: number", "c1_nc_p1"); -verify.completionListContains("nc_f1", "(method) c1.nc_f1(): void", "c1_nc_f1"); -verify.completionListContains("nc_l1", "(property) c1.nc_l1: () => void", "c1_nc_l1"); +verify.completions({ + marker: "6", + includes: [ + { name: "i1_p1", text: "(property) c1.i1_p1: number", documentation: "i1_p1" }, + { name: "i1_f1", text: "(method) c1.i1_f1(): void", documentation: "i1_f1" }, + { name: "i1_l1", text: "(property) c1.i1_l1: () => void", documentation: "i1_l1" }, + { name: "i1_nc_p1", text: "(property) c1.i1_nc_p1: number" }, + { name: "i1_nc_f1", text: "(method) c1.i1_nc_f1(): void" }, + { name: "i1_nc_l1", text: "(property) c1.i1_nc_l1: () => void" }, + { name: "p1", text: "(property) c1.p1: number", documentation: "c1_p1" }, + { name: "f1", text: "(method) c1.f1(): void", documentation: "c1_f1" }, + { name: "l1", text: "(property) c1.l1: () => void", documentation: "c1_l1" }, + { name: "nc_p1", text: "(property) c1.nc_p1: number", documentation: "c1_nc_p1" }, + { name: "nc_f1", text: "(method) c1.nc_f1(): void", documentation: "c1_nc_f1" }, + { name: "nc_l1", text: "(property) c1.nc_l1: () => void", documentation: "c1_nc_l1" }, + ], +}); verify.signatureHelp( { marker: "7", docComment: "i1_f1" }, { marker: "9", docComment: "c1_f1" }, @@ -284,19 +292,23 @@ verify.quickInfos({ l10q: ["(property) c1.nc_l1: () => void", "c1_nc_l1"], }); -goTo.marker('11'); -verify.completionListContains("i1_p1", "(property) i1.i1_p1: number", "i1_p1"); -verify.completionListContains("i1_f1", "(method) i1.i1_f1(): void", "i1_f1"); -verify.completionListContains("i1_l1", "(property) i1.i1_l1: () => void", "i1_l1"); -verify.completionListContains("i1_nc_p1", "(property) i1.i1_nc_p1: number", ""); -verify.completionListContains("i1_nc_f1", "(method) i1.i1_nc_f1(): void", ""); -verify.completionListContains("i1_nc_l1", "(property) i1.i1_nc_l1: () => void", ""); -verify.completionListContains("p1", "(property) i1.p1: number", ""); -verify.completionListContains("f1", "(method) i1.f1(): void", ""); -verify.completionListContains("l1", "(property) i1.l1: () => void", ""); -verify.completionListContains("nc_p1", "(property) i1.nc_p1: number", ""); -verify.completionListContains("nc_f1", "(method) i1.nc_f1(): void", ""); -verify.completionListContains("nc_l1", "(property) i1.nc_l1: () => void", ""); +verify.completions({ + marker: "11", + includes: [ + { name: "i1_p1", text: "(property) i1.i1_p1: number", documentation: "i1_p1" }, + { name: "i1_f1", text: "(method) i1.i1_f1(): void", documentation: "i1_f1" }, + { name: "i1_l1", text: "(property) i1.i1_l1: () => void", documentation: "i1_l1" }, + { name: "i1_nc_p1", text: "(property) i1.i1_nc_p1: number" }, + { name: "i1_nc_f1", text: "(method) i1.i1_nc_f1(): void" }, + { name: "i1_nc_l1", text: "(property) i1.i1_nc_l1: () => void" }, + { name: "p1", text: "(property) i1.p1: number" }, + { name: "f1", text: "(method) i1.f1(): void" }, + { name: "l1", text: "(property) i1.l1: () => void" }, + { name: "nc_p1", text: "(property) i1.nc_p1: number" }, + { name: "nc_f1", text: "(method) i1.nc_f1(): void" }, + { name: "nc_l1", text: "(property) i1.nc_l1: () => void" }, + ], +}); verify.signatureHelp( { marker: "12", docComment: "i1_f1" }, { marker: ["13", "14", "15", "l12", "l13", "l14", "l15"], docComment: "" }, @@ -313,14 +325,21 @@ verify.quickInfos({ l15q: "(property) i1.nc_l1: () => void", }); -goTo.marker('16'); -verify.not.completionListContains("i1", "interface i1", "i1 is interface with properties"); -verify.completionListContains("i1_i", "var i1_i: i1", ""); -verify.completionListContains("c1", "class c1", ""); -verify.completionListContains("c1_i", "var c1_i: c1", ""); - -goTo.marker('16i'); -verify.completionListContains("i1", "interface i1", "i1 is interface with properties"); +verify.completions( + { + marker: "16", + includes: [ + { name: "i1_i", text: "var i1_i: i1" }, + { name: "c1", text: "class c1" }, + { name: "c1_i", text: "var c1_i: c1" }, + ], + excludes: "i1", + }, + { + marker: "16i", + includes: { name: "i1", text: "interface i1", documentation: "i1 is interface with properties" }, + }, +); verify.quickInfos({ "17iq": "var c2_i: c2", @@ -342,19 +361,23 @@ verify.quickInfos({ "18q": "constructor c3(): c3" }); -goTo.marker('19'); -verify.completionListContains("c2_p1", "(property) c2.c2_p1: number", "c2 c2_p1"); -verify.completionListContains("c2_f1", "(method) c2.c2_f1(): void", "c2 c2_f1"); -verify.completionListContains("c2_prop", "(property) c2.c2_prop: number", "c2 c2_prop"); -verify.completionListContains("c2_nc_p1", "(property) c2.c2_nc_p1: number", ""); -verify.completionListContains("c2_nc_f1", "(method) c2.c2_nc_f1(): void", ""); -verify.completionListContains("c2_nc_prop", "(property) c2.c2_nc_prop: number", ""); -verify.completionListContains("p1", "(property) c2.p1: number", "c2 p1"); -verify.completionListContains("f1", "(method) c2.f1(): void", "c2 f1"); -verify.completionListContains("prop", "(property) c2.prop: number", "c2 prop"); -verify.completionListContains("nc_p1", "(property) c2.nc_p1: number", ""); -verify.completionListContains("nc_f1", "(method) c2.nc_f1(): void", ""); -verify.completionListContains("nc_prop", "(property) c2.nc_prop: number", ""); +verify.completions({ + marker: ["19", "29"], + includes: [ + { name: "c2_p1", text: "(property) c2.c2_p1: number", documentation: "c2 c2_p1" }, + { name: "c2_f1", text: "(method) c2.c2_f1(): void", documentation: "c2 c2_f1" }, + { name: "c2_prop", text: "(property) c2.c2_prop: number", documentation: "c2 c2_prop" }, + { name: "c2_nc_p1", text: "(property) c2.c2_nc_p1: number" }, + { name: "c2_nc_f1", text: "(method) c2.c2_nc_f1(): void" }, + { name: "c2_nc_prop", text: "(property) c2.c2_nc_prop: number" }, + { name: "p1", text: "(property) c2.p1: number", documentation: "c2 p1" }, + { name: "f1", text: "(method) c2.f1(): void", documentation: "c2 f1" }, + { name: "prop", text: "(property) c2.prop: number", documentation: "c2 prop" }, + { name: "nc_p1", text: "(property) c2.nc_p1: number" }, + { name: "nc_f1", text: "(method) c2.nc_f1(): void" }, + { name: "nc_prop", text: "(property) c2.nc_prop: number" }, + ], +}); verify.signatureHelp( { marker: "20", docComment: "c2 c2_f1" }, { marker: "22", docComment: "c2 f1" }, @@ -368,19 +391,23 @@ verify.quickInfos({ "23q": "(method) c2.nc_f1(): void" }); -goTo.marker('24'); -verify.completionListContains("c2_p1", "(property) c2.c2_p1: number", "c2 c2_p1"); -verify.completionListContains("c2_f1", "(method) c2.c2_f1(): void", "c2 c2_f1"); -verify.completionListContains("c2_prop", "(property) c2.c2_prop: number", "c2 c2_prop"); -verify.completionListContains("c2_nc_p1", "(property) c2.c2_nc_p1: number", ""); -verify.completionListContains("c2_nc_f1", "(method) c2.c2_nc_f1(): void", ""); -verify.completionListContains("c2_nc_prop", "(property) c2.c2_nc_prop: number", ""); -verify.completionListContains("p1", "(property) c3.p1: number", "c3 p1"); -verify.completionListContains("f1", "(method) c3.f1(): void", "c3 f1"); -verify.completionListContains("prop", "(property) c3.prop: number", "c3 prop"); -verify.completionListContains("nc_p1", "(property) c3.nc_p1: number", ""); -verify.completionListContains("nc_f1", "(method) c3.nc_f1(): void", ""); -verify.completionListContains("nc_prop", "(property) c3.nc_prop: number", ""); +verify.completions({ + marker: "24", + includes: [ + { name: "c2_p1", text: "(property) c2.c2_p1: number", documentation: "c2 c2_p1" }, + { name: "c2_f1", text: "(method) c2.c2_f1(): void", documentation: "c2 c2_f1" }, + { name: "c2_prop", text: "(property) c2.c2_prop: number", documentation: "c2 c2_prop" }, + { name: "c2_nc_p1", text: "(property) c2.c2_nc_p1: number" }, + { name: "c2_nc_f1", text: "(method) c2.c2_nc_f1(): void" }, + { name: "c2_nc_prop", text: "(property) c2.c2_nc_prop: number" }, + { name: "p1", text: "(property) c3.p1: number", documentation: "c3 p1" }, + { name: "f1", text: "(method) c3.f1(): void", documentation: "c3 f1" }, + { name: "prop", text: "(property) c3.prop: number", documentation: "c3 prop" }, + { name: "nc_p1", text: "(property) c3.nc_p1: number" }, + { name: "nc_f1", text: "(method) c3.nc_f1(): void" }, + { name: "nc_prop", text: "(property) c3.nc_prop: number" }, + ], +}); verify.signatureHelp( { marker: "25", docComment: "c2 c2_f1" }, { marker: "27", docComment: "c3 f1" }, @@ -394,19 +421,6 @@ verify.quickInfos({ "28q": "(method) c3.nc_f1(): void" }); -goTo.marker('29'); -verify.completionListContains("c2_p1", "(property) c2.c2_p1: number", "c2 c2_p1"); -verify.completionListContains("c2_f1", "(method) c2.c2_f1(): void", "c2 c2_f1"); -verify.completionListContains("c2_prop", "(property) c2.c2_prop: number", "c2 c2_prop"); -verify.completionListContains("c2_nc_p1", "(property) c2.c2_nc_p1: number", ""); -verify.completionListContains("c2_nc_f1", "(method) c2.c2_nc_f1(): void", ""); -verify.completionListContains("c2_nc_prop", "(property) c2.c2_nc_prop: number"); -verify.completionListContains("p1", "(property) c2.p1: number", "c2 p1"); -verify.completionListContains("f1", "(method) c2.f1(): void", "c2 f1"); -verify.completionListContains("prop", "(property) c2.prop: number", "c2 prop"); -verify.completionListContains("nc_p1", "(property) c2.nc_p1: number", ""); -verify.completionListContains("nc_f1", "(method) c2.nc_f1(): void", ""); -verify.completionListContains("nc_prop", "(property) c2.nc_prop: number", ""); verify.signatureHelp( { marker: "30", docComment: "c2 c2_f1" }, { marker: "32", docComment: "c2 f1" }, @@ -426,27 +440,36 @@ verify.quickInfos({ "34q": ["constructor c4(a: number): c4", "c2 constructor"] }); -goTo.marker('35'); -verify.completionListContains("c2", "class c2", ""); -verify.completionListContains("c2_i", "var c2_i: c2", ""); -verify.completionListContains("c3", "class c3", ""); -verify.completionListContains("c3_i", "var c3_i: c3", ""); -verify.completionListContains("c4", "class c4", ""); -verify.completionListContains("c4_i", "var c4_i: c4", ""); - -goTo.marker('36'); -verify.completionListContains("i2_p1", "(property) i2.i2_p1: number", "i2_p1"); -verify.completionListContains("i2_f1", "(method) i2.i2_f1(): void", "i2_f1"); -verify.completionListContains("i2_l1", "(property) i2.i2_l1: () => void", "i2_l1"); -verify.completionListContains("i2_nc_p1", "(property) i2.i2_nc_p1: number", ""); -verify.completionListContains("i2_nc_f1", "(method) i2.i2_nc_f1(): void", ""); -verify.completionListContains("i2_nc_l1", "(property) i2.i2_nc_l1: () => void", ""); -verify.completionListContains("p1", "(property) i2.p1: number", "i2 p1"); -verify.completionListContains("f1", "(method) i2.f1(): void", "i2 f1"); -verify.completionListContains("l1", "(property) i2.l1: () => void", "i2 l1"); -verify.completionListContains("nc_p1", "(property) i2.nc_p1: number", ""); -verify.completionListContains("nc_f1", "(method) i2.nc_f1(): void", ""); -verify.completionListContains("nc_l1", "(property) i2.nc_l1: () => void", ""); +verify.completions( + { + marker: "35", + includes: [ + { name: "c2", text: "class c2" }, + { name: "c2_i", text: "var c2_i: c2" }, + { name: "c3", text: "class c3" }, + { name: "c3_i", text: "var c3_i: c3" }, + { name: "c4", text: "class c4" }, + { name: "c4_i", text: "var c4_i: c4" }, + ], + }, + { + marker: ["36", "46"], + includes: [ + { name: "i2_p1", text: "(property) i2.i2_p1: number", documentation: "i2_p1" }, + { name: "i2_f1", text: "(method) i2.i2_f1(): void", documentation: "i2_f1" }, + { name: "i2_l1", text: "(property) i2.i2_l1: () => void", documentation: "i2_l1" }, + { name: "i2_nc_p1", text: "(property) i2.i2_nc_p1: number" }, + { name: "i2_nc_f1", text: "(method) i2.i2_nc_f1(): void" }, + { name: "i2_nc_l1", text: "(property) i2.i2_nc_l1: () => void" }, + { name: "p1", text: "(property) i2.p1: number", documentation: "i2 p1" }, + { name: "f1", text: "(method) i2.f1(): void", documentation: "i2 f1" }, + { name: "l1", text: "(property) i2.l1: () => void", documentation: "i2 l1" }, + { name: "nc_p1", text: "(property) i2.nc_p1: number" }, + { name: "nc_f1", text: "(method) i2.nc_f1(): void" }, + { name: "nc_l1", text: "(property) i2.nc_l1: () => void" }, + ], + }, +); verify.signatureHelp( { marker: "37", docComment: "i2_f1" }, { marker: "39", docComment: "i2 f1" }, @@ -466,19 +489,23 @@ verify.quickInfos({ "l40q": "(property) i2.nc_l1: () => void", }); -goTo.marker('41'); -verify.completionListContains("i2_p1", "(property) i2.i2_p1: number", "i2_p1"); -verify.completionListContains("i2_f1", "(method) i2.i2_f1(): void", "i2_f1"); -verify.completionListContains("i2_l1", "(property) i2.i2_l1: () => void", "i2_l1"); -verify.completionListContains("i2_nc_p1", "(property) i2.i2_nc_p1: number", ""); -verify.completionListContains("i2_nc_f1", "(method) i2.i2_nc_f1(): void", ""); -verify.completionListContains("i2_nc_l1", "(property) i2.i2_nc_l1: () => void", ""); -verify.completionListContains("p1", "(property) i3.p1: number", "i3 p1"); -verify.completionListContains("f1", "(method) i3.f1(): void", "i3 f1"); -verify.completionListContains("l1", "(property) i3.l1: () => void", "i3 l1"); -verify.completionListContains("nc_p1", "(property) i3.nc_p1: number", ""); -verify.completionListContains("nc_f1", "(method) i3.nc_f1(): void", ""); -verify.completionListContains("nc_l1", "(property) i3.nc_l1: () => void", ""); +verify.completions({ + marker: "41", + includes: [ + { name: "i2_p1", text: "(property) i2.i2_p1: number", documentation: "i2_p1" }, + { name: "i2_f1", text: "(method) i2.i2_f1(): void", documentation: "i2_f1" }, + { name: "i2_l1", text: "(property) i2.i2_l1: () => void", documentation: "i2_l1" }, + { name: "i2_nc_p1", text: "(property) i2.i2_nc_p1: number" }, + { name: "i2_nc_f1", text: "(method) i2.i2_nc_f1(): void" }, + { name: "i2_nc_l1", text: "(property) i2.i2_nc_l1: () => void" }, + { name: "p1", text: "(property) i3.p1: number", documentation: "i3 p1" }, + { name: "f1", text: "(method) i3.f1(): void", documentation: "i3 f1" }, + { name: "l1", text: "(property) i3.l1: () => void", documentation: "i3 l1" }, + { name: "nc_p1", text: "(property) i3.nc_p1: number" }, + { name: "nc_f1", text: "(method) i3.nc_f1(): void" }, + { name: "nc_l1", text: "(property) i3.nc_l1: () => void" }, + ], +}); verify.signatureHelp( { marker: "42", docComment: "i2_f1" }, { marker: "44", docComment: "i3 f1" }, @@ -496,19 +523,23 @@ verify.quickInfos({ l45q: "(property) i3.nc_l1: () => void" }); -goTo.marker('46'); -verify.completionListContains("i2_p1", "(property) i2.i2_p1: number", "i2_p1"); -verify.completionListContains("i2_f1", "(method) i2.i2_f1(): void", "i2_f1"); -verify.completionListContains("i2_l1", "(property) i2.i2_l1: () => void", "i2_l1"); -verify.completionListContains("i2_nc_p1", "(property) i2.i2_nc_p1: number", ""); -verify.completionListContains("i2_nc_f1", "(method) i2.i2_nc_f1(): void", ""); -verify.completionListContains("i2_nc_l1", "(property) i2.i2_nc_l1: () => void", ""); -verify.completionListContains("p1", "(property) i2.p1: number", "i2 p1"); -verify.completionListContains("f1", "(method) i2.f1(): void", "i2 f1"); -verify.completionListContains("l1", "(property) i2.l1: () => void", "i2 l1"); -verify.completionListContains("nc_p1", "(property) i2.nc_p1: number", ""); -verify.completionListContains("nc_f1", "(method) i2.nc_f1(): void", ""); -verify.completionListContains("nc_l1", "(property) i2.nc_l1: () => void", ""); +verify.completions({ + marker: "46", + includes: [ + { name: "i2_p1", text: "(property) i2.i2_p1: number", documentation: "i2_p1" }, + { name: "i2_f1", text: "(method) i2.i2_f1(): void", documentation: "i2_f1" }, + { name: "i2_l1", text: "(property) i2.i2_l1: () => void", documentation: "i2_l1" }, + { name: "i2_nc_p1", text: "(property) i2.i2_nc_p1: number" }, + { name: "i2_nc_f1", text: "(method) i2.i2_nc_f1(): void" }, + { name: "i2_nc_l1", text: "(property) i2.i2_nc_l1: () => void" }, + { name: "p1", text: "(property) i2.p1: number", documentation: "i2 p1" }, + { name: "f1", text: "(method) i2.f1(): void", documentation: "i2 f1" }, + { name: "l1", text: "(property) i2.l1: () => void", documentation: "i2 l1" }, + { name: "nc_p1", text: "(property) i2.nc_p1: number" }, + { name: "nc_f1", text: "(method) i2.nc_f1(): void" }, + { name: "nc_l1", text: "(property) i2.nc_l1: () => void" }, + ], +}); verify.signatureHelp( { marker: "47", docComment: "i2_f1" }, { marker: "49", docComment: "i2 f1" }, @@ -526,15 +557,23 @@ verify.quickInfos({ l40q: "(property) i2.nc_l1: () => void" }); -goTo.marker('51'); -verify.not.completionListContains("i2", "interface i2", ""); -verify.completionListContains("i2_i", "var i2_i: i2", ""); -verify.not.completionListContains("i3", "interface i3", ""); -verify.completionListContains("i3_i", "var i3_i: i3", ""); - -goTo.marker('51i'); -verify.completionListContains("i2", "interface i2", ""); -verify.completionListContains("i3", "interface i3", ""); +verify.completions( + { + marker: "51", + includes: [ + { name: "i2_i", text: "var i2_i: i2" }, + { name: "i3_i", text: "var i3_i: i3" }, + ], + excludes: ["i2", "i3"], + }, + { + marker: "51i", + includes: [ + { name: "i2", text: "interface i2" }, + { name: "i3", text: "interface i3" }, + ], + }, +); verify.quickInfos({ 52: ["constructor c5(): c5", "c5 class"], diff --git a/tests/cases/fourslash/commentsInterface.ts b/tests/cases/fourslash/commentsInterface.ts index fdeeb8bb3eb9c..3071ae47d5639 100644 --- a/tests/cases/fourslash/commentsInterface.ts +++ b/tests/cases/fourslash/commentsInterface.ts @@ -7,7 +7,7 @@ ////interface nc_/*3*/i1 { ////} ////var nc_/*4*/i1_i: nc_i1; -/////** this is interface 2 with memebers*/ +/////** this is interface 2 with members*/ ////interface i/*5*/2 { //// /** this is x*/ //// x: number; @@ -73,19 +73,25 @@ verify.quickInfos({ 2: "var i1_i: i1", 3: "interface nc_i1", 4: "var nc_i1_i: nc_i1", - 5: ["interface i2", "this is interface 2 with memebers"], + 5: ["interface i2", "this is interface 2 with members"], 6: "var i2_i: i2", 7: "var i2_i_x: number" }); -goTo.marker('8'); -verify.quickInfoIs("(property) i2.x: number", "this is x"); -verify.completionListContains("x", "(property) i2.x: number", "this is x"); -verify.completionListContains("foo", "(property) i2.foo: (b: number) => string", "this is foo"); -verify.completionListContains("nc_x", "(property) i2.nc_x: number", ""); -verify.completionListContains("nc_foo", "(property) i2.nc_foo: (b: number) => string", ""); -verify.completionListContains("fnfoo", "(method) i2.fnfoo(b: number): string", "this is fnfoo"); -verify.completionListContains("nc_fnfoo", "(method) i2.nc_fnfoo(b: number): string", ""); +verify.quickInfoAt("8", "(property) i2.x: number", "this is x"); +verify.completions({ + marker: "8", + exact: [ + { name: "x", text: "(property) i2.x: number", documentation: "this is x" }, + { name: "foo", text: "(property) i2.foo: (b: number) => string", documentation: "this is foo" }, + { name: "nc_x", text: "(property) i2.nc_x: number" }, + { name: "nc_foo", text: "(property) i2.nc_foo: (b: number) => string" }, + { name: "fnfoo", text: "(method) i2.fnfoo(b: number): string", documentation: "this is fnfoo" }, + { name: "nc_fnfoo", text: "(method) i2.nc_fnfoo(b: number): string" }, + ...completion.functionMembersWithPrototype, + ], + isNewIdentifierLocation: true, +}); verify.quickInfos({ 9: "var i2_i_foo: (b: number) => string", @@ -148,49 +154,59 @@ verify.quickInfos({ verify.signatureHelp({ marker: "33", docComment: "" }); verify.quickInfoAt("33q", "(method) i2.nc_fnfoo(b: number): string"); -goTo.marker('34'); -verify.not.completionListContains("i1", "interface i1", "this is interface 1"); -verify.completionListContains("i1_i", "var i1_i: i1", ""); -verify.not.completionListContains("nc_i1", "interface nc_i1", ""); -verify.completionListContains("nc_i1_i", "var nc_i1_i: nc_i1", ""); -verify.not.completionListContains("i2", "interface i2", "this is interface 2 with memebers"); -verify.completionListContains("i2_i", "var i2_i: i2", ""); -verify.completionListContains("i2_i_x", "var i2_i_x: number", ""); -verify.completionListContains("i2_i_foo", "var i2_i_foo: (b: number) => string", ""); -verify.completionListContains("i2_i_foo_r", "var i2_i_foo_r: string", ""); -verify.completionListContains("i2_i_i2_si", "var i2_i_i2_si: number", ""); -verify.completionListContains("i2_i_i2_ii", "var i2_i_i2_ii: number", ""); -verify.completionListContains("i2_i_n", "var i2_i_n: any", ""); -verify.completionListContains("i2_i_nc_x", "var i2_i_nc_x: number", ""); -verify.completionListContains("i2_i_nc_foo", "var i2_i_nc_foo: (b: number) => string", ""); -verify.completionListContains("i2_i_nc_foo_r", "var i2_i_nc_foo_r: string", ""); -verify.completionListContains("i2_i_r", "var i2_i_r: number", ""); -verify.completionListContains("i2_i_fnfoo", "var i2_i_fnfoo: (b: number) => string", ""); -verify.completionListContains("i2_i_fnfoo_r", "var i2_i_fnfoo_r: string", ""); -verify.completionListContains("i2_i_nc_fnfoo", "var i2_i_nc_fnfoo: (b: number) => string", ""); -verify.completionListContains("i2_i_nc_fnfoo_r", "var i2_i_nc_fnfoo_r: string", ""); - -goTo.marker('34i'); -verify.completionListContains("i1", "interface i1", "this is interface 1"); -verify.completionListContains("nc_i1", "interface nc_i1", ""); -verify.completionListContains("i2", "interface i2", "this is interface 2 with memebers"); - -goTo.marker('36'); -verify.completionListContains("a", "(parameter) a: number", "i3_i a"); +verify.completions( + { + marker: "34", + includes: [ + { name: "i1_i", text: "var i1_i: i1" }, + { name: "nc_i1_i", text: "var nc_i1_i: nc_i1", documentation: "" }, + { name: "i2_i", text: "var i2_i: i2" }, + { name: "i2_i_x", text: "var i2_i_x: number" }, + { name: "i2_i_foo", text: "var i2_i_foo: (b: number) => string" }, + { name: "i2_i_foo_r", text: "var i2_i_foo_r: string" }, + { name: "i2_i_i2_si", text: "var i2_i_i2_si: number" }, + { name: "i2_i_i2_ii", text: "var i2_i_i2_ii: number" }, + { name: "i2_i_n", text: "var i2_i_n: any" }, + { name: "i2_i_nc_x", text: "var i2_i_nc_x: number" }, + { name: "i2_i_nc_foo", text: "var i2_i_nc_foo: (b: number) => string" }, + { name: "i2_i_nc_foo_r", text: "var i2_i_nc_foo_r: string" }, + { name: "i2_i_r", text: "var i2_i_r: number" }, + { name: "i2_i_fnfoo", text: "var i2_i_fnfoo: (b: number) => string" }, + { name: "i2_i_fnfoo_r", text: "var i2_i_fnfoo_r: string" }, + { name: "i2_i_nc_fnfoo", text: "var i2_i_nc_fnfoo: (b: number) => string" }, + { name: "i2_i_nc_fnfoo_r", text: "var i2_i_nc_fnfoo_r: string" }, + ], + excludes: ["i1", "nc_i1", "i2"], + }, + { + marker: "34i", + includes: [ + { name: "i1", text: "interface i1", documentation: "this is interface 1" }, + { name: "nc_i1", text: "interface nc_i1" }, + { name: "i2", text: "interface i2", documentation: "this is interface 2 with members" }, + ], + }, + { + marker: "36", includes: { name: "a", text: "(parameter) a: number", documentation: "i3_i a" }, + } +); verify.quickInfoAt("40q", "var i3_i: i3"); -goTo.marker('40'); -verify.not.completionListContains("i3", "interface i3", ""); -verify.completionListContains("i3_i", "var i3_i: i3", ""); +verify.completions({ marker: "40", includes: { name: "i3_i", text: "var i3_i: i3" }, excludes: "i3" }); goTo.marker('41'); verify.quickInfoIs("(method) i3.f(a: number): string", "Function i3 f"); -verify.completionListContains("f", "(method) i3.f(a: number): string", "Function i3 f"); -verify.completionListContains("l", "(property) i3.l: (b: number) => string", "i3 l"); -verify.completionListContains("x", "(property) i3.x: number", "Comment i3 x"); -verify.completionListContains("nc_f", "(method) i3.nc_f(a: number): string", ""); -verify.completionListContains("nc_l", "(property) i3.nc_l: (b: number) => string", ""); -verify.completionListContains("nc_x", "(property) i3.nc_x: number", ""); +verify.completions({ + marker: "41", + exact: [ + { name: "x", text: "(property) i3.x: number", documentation: "Comment i3 x" }, + { name: "f", text: "(method) i3.f(a: number): string", documentation: "Function i3 f" }, + { name: "l", text: "(property) i3.l: (b: number) => string", documentation: "i3 l" }, + { name: "nc_x", text: "(property) i3.nc_x: number" }, + { name: "nc_f", text: "(method) i3.nc_f(a: number): string" }, + { name: "nc_l", text: "(property) i3.nc_l: (b: number) => string" }, + ], +}); verify.signatureHelp({ marker: "42", docComment: "Function i3 f", parameterDocComment: "number parameter" }); diff --git a/tests/cases/fourslash/commentsModules.ts b/tests/cases/fourslash/commentsModules.ts index 545c1569096b4..c9e9806aa9b1c 100644 --- a/tests/cases/fourslash/commentsModules.ts +++ b/tests/cases/fourslash/commentsModules.ts @@ -98,134 +98,84 @@ verify.quickInfoAt("1", "namespace m1", "Namespace comment"); -goTo.marker('2'); -verify.completionListContains("b", "var b: number", "b's comment"); -verify.completionListContains("foo", "function foo(): number", "foo's comment"); +verify.completions({ + marker: "2", + includes: [ + { name: "b", text: "var b: number", documentation: "b's comment" }, + { name: "foo", text: "function foo(): number", documentation: "foo's comment" }, + ], +}); verify.signatureHelp({ marker: "3", docComment: "foo's comment" }); verify.quickInfoAt("3q", "function foo(): number", "foo's comment"); -goTo.marker('4'); -verify.completionListContains("m1", "namespace m1", "Namespace comment"); +verify.completions( + { marker: "4", includes: { name: "m1", text: "namespace m1", documentation: "Namespace comment" } }, + { + marker: "5", + includes: [ + { name: "b", text: "var m1.b: number", documentation: "b's comment" }, + { name: "fooExport", text: "function m1.fooExport(): number", documentation: "exported function" }, + { name: "m2", text: "namespace m1.m2", documentation: "m2 comments" }, + ], + }, +); -goTo.marker('5'); -verify.completionListContains("b", "var m1.b: number", "b's comment"); -verify.completionListContains("fooExport", "function m1.fooExport(): number", "exported function"); -verify.completionListContains("m2", "namespace m1.m2"); -verify.quickInfoIs("function m1.fooExport(): number", "exported function"); +verify.quickInfoAt("5", "function m1.fooExport(): number", "exported function"); verify.signatureHelp({ marker: "6", docComment: "exported function" }); verify.quickInfoAt("7", "var myvar: m1.m2.c"); -goTo.marker('8'); -verify.quickInfoIs("constructor m1.m2.c(): m1.m2.c", "class comment;"); -verify.completionListContains("c", "constructor m1.m2.c(): m1.m2.c", "class comment;"); -verify.completionListContains("i", "var m1.m2.i: m1.m2.c", "i"); - -goTo.marker('9'); -verify.completionListContains("m2", "namespace m2", "namespace comment of m2.m3"); -verify.quickInfoIs("namespace m2", "namespace comment of m2.m3"); - -goTo.marker('10'); -verify.completionListContains("m3", "namespace m2.m3"); -verify.quickInfoIs("namespace m2.m3", "namespace comment of m2.m3"); - -goTo.marker('11'); -verify.quickInfoIs("constructor m2.m3.c(): m2.m3.c", "Exported class comment"); -verify.completionListContains("c", "constructor m2.m3.c(): m2.m3.c", "Exported class comment"); - -goTo.marker('12'); -verify.completionListContains("m3", "namespace m3", "namespace comment of m3.m4.m5"); -verify.quickInfoIs("namespace m3", "namespace comment of m3.m4.m5"); - -goTo.marker('13'); -verify.completionListContains("m4", "namespace m3.m4", "namespace comment of m3.m4.m5"); -verify.quickInfoIs("namespace m3.m4", "namespace comment of m3.m4.m5"); - -goTo.marker('14'); -verify.completionListContains("m5", "namespace m3.m4.m5"); -verify.quickInfoIs("namespace m3.m4.m5", "namespace comment of m3.m4.m5"); - -goTo.marker('15'); -verify.quickInfoIs("constructor m3.m4.m5.c(): m3.m4.m5.c", "Exported class comment"); -verify.completionListContains("c", "constructor m3.m4.m5.c(): m3.m4.m5.c", "Exported class comment"); - -goTo.marker('16'); -verify.completionListContains("m4", "namespace m4", "namespace comment of m4.m5.m6"); -verify.quickInfoIs("namespace m4", "namespace comment of m4.m5.m6"); - -goTo.marker('17'); -verify.completionListContains("m5", "namespace m4.m5", "namespace comment of m4.m5.m6"); -verify.quickInfoIs("namespace m4.m5", "namespace comment of m4.m5.m6"); - -goTo.marker('18'); -verify.completionListContains("m6", "namespace m4.m5.m6"); -verify.quickInfoIs("namespace m4.m5.m6", "namespace comment of m4.m5.m6"); - -goTo.marker('19'); -verify.completionListContains("m7", "namespace m4.m5.m6.m7"); -verify.quickInfoIs("namespace m4.m5.m6.m7"); - -goTo.marker('20'); -verify.completionListContains("c", "constructor m4.m5.m6.m7.c(): m4.m5.m6.m7.c", "Exported class comment"); -verify.quickInfoIs("constructor m4.m5.m6.m7.c(): m4.m5.m6.m7.c", "Exported class comment"); - -goTo.marker('21'); -verify.completionListContains("m5", "namespace m5"); -verify.quickInfoIs("namespace m5", "namespace comment of m5.m6.m7"); - -goTo.marker('22'); -verify.completionListContains("m6", "namespace m5.m6"); -verify.quickInfoIs("namespace m5.m6", "namespace comment of m5.m6.m7"); - -goTo.marker('23'); -verify.completionListContains("m7", "namespace m5.m6.m7"); -verify.quickInfoIs("namespace m5.m6.m7", "namespace comment of m5.m6.m7"); - -goTo.marker('24'); -verify.completionListContains("m8", "namespace m5.m6.m7.m8"); -verify.quickInfoIs("namespace m5.m6.m7.m8", "namespace m8 comment"); - -goTo.marker('25'); -verify.completionListContains("c", "constructor m5.m6.m7.m8.c(): m5.m6.m7.m8.c", "Exported class comment"); -verify.quickInfoIs("constructor m5.m6.m7.m8.c(): m5.m6.m7.m8.c", "Exported class comment"); - -goTo.marker('26'); -verify.completionListContains("m6", "namespace m6"); -verify.quickInfoIs("namespace m6"); - -goTo.marker('27'); -verify.completionListContains("m7", "namespace m6.m7"); -verify.quickInfoIs("namespace m6.m7"); - -goTo.marker('28'); -verify.completionListContains("m8", "namespace m6.m7.m8"); -verify.quickInfoIs("namespace m6.m7.m8"); - -goTo.marker('29'); -verify.completionListContains("c", "constructor m6.m7.m8.c(): m6.m7.m8.c", "Exported class comment"); -verify.quickInfoIs("constructor m6.m7.m8.c(): m6.m7.m8.c", "Exported class comment"); - -goTo.marker('30'); -verify.completionListContains("m7", "namespace m7"); -verify.quickInfoIs("namespace m7"); - -goTo.marker('31'); -verify.completionListContains("m8", "namespace m7.m8"); -verify.quickInfoIs("namespace m7.m8"); - -goTo.marker('32'); -verify.completionListContains("m9", "namespace m7.m8.m9"); -verify.quickInfoIs("namespace m7.m8.m9", "namespace m9 comment"); - -goTo.marker('33'); -verify.completionListContains("c", "constructor m7.m8.m9.c(): m7.m8.m9.c", "Exported class comment"); -verify.quickInfoIs("constructor m7.m8.m9.c(): m7.m8.m9.c", "Exported class comment"); - -goTo.marker('34'); -verify.completionListContains("c", 'class c', ""); -verify.quickInfoIs('class c'); +verify.quickInfoAt("8", "constructor m1.m2.c(): m1.m2.c", "class comment;"); +verify.completions( + { + marker: "8", + includes: [ + { name: "c", text: "constructor m1.m2.c(): m1.m2.c", documentation: "class comment;" }, + { name: "i", text: "var m1.m2.i: m1.m2.c", documentation: "i" }, + ], + } +); + +function both(marker: string, name: string, text: string, documentation?: string) { + verify.completions({ marker, includes: { name, text, documentation } }); + verify.quickInfoAt(marker, text, documentation); +} + +both("9", "m2", "namespace m2", "namespace comment of m2.m3"); +both("10", "m3", "namespace m2.m3", "namespace comment of m2.m3"); +both("11", "c", "constructor m2.m3.c(): m2.m3.c", "Exported class comment"); +both("12", "m3", "namespace m3", "namespace comment of m3.m4.m5"); +both("13", "m4", "namespace m3.m4", "namespace comment of m3.m4.m5"); +both("14", "m5", "namespace m3.m4.m5", "namespace comment of m3.m4.m5"); +both("15", "c", "constructor m3.m4.m5.c(): m3.m4.m5.c", "Exported class comment"); + +both("16", "m4", "namespace m4", "namespace comment of m4.m5.m6"); +both("17", "m5", "namespace m4.m5", "namespace comment of m4.m5.m6"); +both("18", "m6", "namespace m4.m5.m6", "namespace comment of m4.m5.m6"); +both("19", "m7", "namespace m4.m5.m6.m7"); + +verify.completions({ + marker: "20", + includes: { name: "c", text: "constructor m4.m5.m6.m7.c(): m4.m5.m6.m7.c", documentation: "Exported class comment" }, +}); +verify.quickInfoAt("20", "constructor m4.m5.m6.m7.c(): m4.m5.m6.m7.c", "Exported class comment"); + +both("21", "m5", "namespace m5", "namespace comment of m5.m6.m7"); +both("22", "m6", "namespace m5.m6", "namespace comment of m5.m6.m7"); +both("23", "m7", "namespace m5.m6.m7", "namespace comment of m5.m6.m7"); +both("24", "m8", "namespace m5.m6.m7.m8", "namespace m8 comment"); +both("25", "c", "constructor m5.m6.m7.m8.c(): m5.m6.m7.m8.c", "Exported class comment"); +both("26", "m6", "namespace m6"); +both("27", "m7", "namespace m6.m7"); +both("28", "m8", "namespace m6.m7.m8"); +both("29", "c", "constructor m6.m7.m8.c(): m6.m7.m8.c", "Exported class comment"); +both("30", "m7", "namespace m7"); +both("31", "m8", "namespace m7.m8"); +both("32", "m9", "namespace m7.m8.m9", "namespace m9 comment"); +both("33", "c", "constructor m7.m8.m9.c(): m7.m8.m9.c", "Exported class comment"); +both("34", "c", "class c"); verify.quickInfos({ 35: "var myComplexVal: number", diff --git a/tests/cases/fourslash/commentsMultiModuleMultiFile.ts b/tests/cases/fourslash/commentsMultiModuleMultiFile.ts index 00256ec133404..ec7ec032ed9f2 100644 --- a/tests/cases/fourslash/commentsMultiModuleMultiFile.ts +++ b/tests/cases/fourslash/commentsMultiModuleMultiFile.ts @@ -28,12 +28,11 @@ const comment = "this is multi declare namespace\nthi is multi namespace 2\nthis is multi namespace 3 comment"; -goTo.marker('1'); -verify.completionListContains("multiM", "namespace multiM", comment); +verify.completions({ + marker: ["1", "7"], + includes: { name: "multiM", text: "namespace multiM", documentation: comment }, +}); for (const marker of ["2", "3", "4", "5", "6", "8"]) { verify.quickInfoAt(marker, "namespace multiM", comment); } - -goTo.marker('7'); -verify.completionListContains("multiM", "namespace multiM", comment); diff --git a/tests/cases/fourslash/commentsMultiModuleSingleFile.ts b/tests/cases/fourslash/commentsMultiModuleSingleFile.ts index dd10fb5a70756..e5fb0f055a98a 100644 --- a/tests/cases/fourslash/commentsMultiModuleSingleFile.ts +++ b/tests/cases/fourslash/commentsMultiModuleSingleFile.ts @@ -18,8 +18,7 @@ const comment = "this is multi declare namespace\nthi is multi namespace 2"; -goTo.marker('1'); -verify.completionListContains("multiM", "namespace multiM", comment); +verify.completions({ marker: "1", includes: { name: "multiM", text: "namespace multiM", documentation: comment } }); for (const marker of ["2", "3", "4", "5"]) { verify.quickInfoAt(marker, "namespace multiM", comment); diff --git a/tests/cases/fourslash/commentsOverloads.ts b/tests/cases/fourslash/commentsOverloads.ts index 372eedbb2da8b..630d1d9cdee6f 100644 --- a/tests/cases/fourslash/commentsOverloads.ts +++ b/tests/cases/fourslash/commentsOverloads.ts @@ -272,21 +272,27 @@ verify.signatureHelp( { marker: "o16", overloadsCount: 2, docComment: "this is signature 4 - with number parameter", parameterDocComment: "param a" }, ); -goTo.marker('17'); -verify.completionListContains('f1', 'function f1(a: number): number (+1 overload)', 'this is signature 1'); -verify.completionListContains('f2', 'function f2(a: number): number (+1 overload)', 'this is signature 2\nthis is f2 var comment'); -verify.completionListContains('f3', 'function f3(a: number): number (+1 overload)', ''); -verify.completionListContains('f4', 'function f4(a: number): number (+1 overload)', 'this is signature 4 - with number parameter'); - -goTo.marker('18'); -verify.not.completionListContains('i1', 'interface i1', ''); -verify.completionListContains('i1_i', 'var i1_i: i1\nnew (b: number) => any (+1 overload)', ''); -verify.not.completionListContains('i2', 'interface i2', ''); -verify.completionListContains('i2_i', 'var i2_i: i2\nnew (a: string) => any (+1 overload)', ''); -verify.not.completionListContains('i3', 'interface i3', ''); -verify.completionListContains('i3_i', 'var i3_i: i3\nnew (a: string) => any (+1 overload)', 'new 1'); -verify.not.completionListContains('i4', 'interface i4', ''); -verify.completionListContains('i4_i', 'var i4_i: i4\nnew (a: string) => any (+1 overload)', ''); +verify.completions( + { + marker: "17", + includes: [ + { name: "f1", text: "function f1(a: number): number (+1 overload)", documentation: "this is signature 1" }, + { name: "f2", text: "function f2(a: number): number (+1 overload)", documentation: "this is signature 2\nthis is f2 var comment" }, + { name: "f3", text: "function f3(a: number): number (+1 overload)" }, + { name: "f4", text: "function f4(a: number): number (+1 overload)", documentation: "this is signature 4 - with number parameter" }, + ], + }, + { + marker: "18", + includes: [ + { name: "i1_i", text: "var i1_i: i1\nnew (b: number) => any (+1 overload)" }, + { name: "i2_i", text: "var i2_i: i2\nnew (a: string) => any (+1 overload)" }, + { name: "i3_i", text: "var i3_i: i3\nnew (a: string) => any (+1 overload)", documentation: "new 1" }, + { name: "i4_i", text: "var i4_i: i4\nnew (a: string) => any (+1 overload)" }, + ], + excludes: ["i1", "i2", "i3", "i4"], + }, +); verify.signatureHelp({ marker: "19", overloadsCount: 2 }); verify.quickInfoAt("19q", "var i1_i: i1\nnew (b: number) => any (+1 overload)"); @@ -301,11 +307,15 @@ verify.signatureHelp({ marker: "22", overloadsCount: 2, docComment: "this is sig goTo.marker('22q'); verify.quickInfoAt("22q", "var i1_i: i1\n(b: string) => number (+1 overload)", "this is signature 2"); -goTo.marker('23'); -verify.completionListContains('foo', '(method) i1.foo(a: number): number (+1 overload)', 'foo 1'); -verify.completionListContains('foo2', '(method) i1.foo2(a: number): number (+1 overload)', 'foo2 2'); -verify.completionListContains('foo3', '(method) i1.foo3(a: number): number (+1 overload)', ''); -verify.completionListContains('foo4', '(method) i1.foo4(a: number): number (+1 overload)', 'foo4 1'); +verify.completions({ + marker: "23", + includes: [ + { name: "foo" , text: "(method) i1.foo(a: number): number (+1 overload)", documentation: "foo 1" }, + { name: "foo2", text: "(method) i1.foo2(a: number): number (+1 overload)", documentation: "foo2 2" }, + { name: "foo3", text: "(method) i1.foo3(a: number): number (+1 overload)" }, + { name: "foo4", text: "(method) i1.foo4(a: number): number (+1 overload)", documentation: "foo4 1" }, + ], +}); verify.signatureHelp({ marker: "24", overloadsCount: 2, docComment: "foo 1" }); verify.quickInfoAt("24q", "(method) i1.foo(a: number): number (+1 overload)", "foo 1"); @@ -367,12 +377,16 @@ verify.quickInfoAt("42q", "var i4_i: i4\n(a: number) => number (+1 overload)"); verify.signatureHelp({ marker: "43", overloadsCount: 2 }); verify.quickInfoAt("43q", "var i4_i: i4\n(b: string) => number (+1 overload)"); -goTo.marker('44'); -verify.completionListContains('prop1', '(method) c.prop1(a: number): number (+1 overload)', ''); -verify.completionListContains('prop2', '(method) c.prop2(a: number): number (+1 overload)', 'prop2 1'); -verify.completionListContains('prop3', '(method) c.prop3(a: number): number (+1 overload)', 'prop3 2'); -verify.completionListContains('prop4', '(method) c.prop4(a: number): number (+1 overload)', 'prop4 1'); -verify.completionListContains('prop5', '(method) c.prop5(a: number): number (+1 overload)', 'prop5 1'); +verify.completions({ + marker: "44", + exact: [ + { name: "prop1", text: "(method) c.prop1(a: number): number (+1 overload)" }, + { name: "prop2", text: "(method) c.prop2(a: number): number (+1 overload)", documentation: "prop2 1" }, + { name: "prop3", text: "(method) c.prop3(a: number): number (+1 overload)", documentation: "prop3 2" }, + { name: "prop4", text: "(method) c.prop4(a: number): number (+1 overload)", documentation: "prop4 1" }, + { name: "prop5", text: "(method) c.prop5(a: number): number (+1 overload)", documentation: "prop5 1" }, + ], +}); verify.signatureHelp({ marker: "45", overloadsCount: 2 }); verify.quickInfoAt("45q", "(method) c.prop1(a: number): number (+1 overload)"); @@ -434,26 +448,30 @@ verify.quickInfoAt("63q", "constructor c5(a: number): c5 (+1 overload)", "c5 1") verify.signatureHelp({ marker: "64", overloadsCount: 2, docComment: "c5 2" }); verify.quickInfoAt("64q", "constructor c5(b: string): c5 (+1 overload)", "c5 2"); -goTo.marker('65'); -verify.completionListContains("c", "class c", ""); -verify.completionListContains("c1", "class c1", ""); -verify.completionListContains("c2", "class c2", ""); -verify.completionListContains("c3", "class c3", ""); -verify.completionListContains("c4", "class c4", ""); -verify.completionListContains("c5", "class c5", ""); -verify.completionListContains("c_i", "var c_i: c", ""); -verify.completionListContains("c1_i_1", "var c1_i_1: c1", ""); -verify.completionListContains("c2_i_1", "var c2_i_1: c2", ""); -verify.completionListContains("c3_i_1", "var c3_i_1: c3", ""); -verify.completionListContains("c4_i_1", "var c4_i_1: c4", ""); -verify.completionListContains("c5_i_1", "var c5_i_1: c5", ""); -verify.completionListContains("c1_i_2", "var c1_i_2: c1", ""); -verify.completionListContains("c2_i_2", "var c2_i_2: c2", ""); -verify.completionListContains("c3_i_2", "var c3_i_2: c3", ""); -verify.completionListContains("c4_i_2", "var c4_i_2: c4", ""); -verify.completionListContains("c5_i_2", "var c5_i_2: c5", ""); -verify.completionListContains('multiOverload', 'function multiOverload(a: number): string (+2 overloads)', 'This is multiOverload F1 1'); -verify.completionListContains('ambientF1', 'function ambientF1(a: number): string (+2 overloads)', 'This is ambient F1 1'); +verify.completions({ + marker: "65", + includes: [ + { name: "c", text: "class c" }, + { name: "c1", text: "class c1" }, + { name: "c2", text: "class c2" }, + { name: "c3", text: "class c3" }, + { name: "c4", text: "class c4" }, + { name: "c5", text: "class c5" }, + { name: "c_i", text: "var c_i: c" }, + { name: "c1_i_1", text: "var c1_i_1: c1" }, + { name: "c2_i_1", text: "var c2_i_1: c2" }, + { name: "c3_i_1", text: "var c3_i_1: c3" }, + { name: "c4_i_1", text: "var c4_i_1: c4" }, + { name: "c5_i_1", text: "var c5_i_1: c5" }, + { name: "c1_i_2", text: "var c1_i_2: c1" }, + { name: "c2_i_2", text: "var c2_i_2: c2" }, + { name: "c3_i_2", text: "var c3_i_2: c3" }, + { name: "c4_i_2", text: "var c4_i_2: c4" }, + { name: "c5_i_2", text: "var c5_i_2: c5" }, + { name: "multiOverload", text: "function multiOverload(a: number): string (+2 overloads)", documentation: "This is multiOverload F1 1" }, + { name: "ambientF1", text: "function ambientF1(a: number): string (+2 overloads)", documentation: "This is ambient F1 1" }, + ], +}); verify.quickInfos({ 66: "var c1_i_1: c1", diff --git a/tests/cases/fourslash/completionAfterAtChar.ts b/tests/cases/fourslash/completionAfterAtChar.ts index 4f3581cd48322..dbdfc89a27ca6 100644 --- a/tests/cases/fourslash/completionAfterAtChar.ts +++ b/tests/cases/fourslash/completionAfterAtChar.ts @@ -2,5 +2,4 @@ ////@a/**/ -goTo.marker(); -verify.not.completionListIsEmpty(); \ No newline at end of file +verify.completions({ marker: "", exact: completion.globals }); diff --git a/tests/cases/fourslash/completionAfterBackslashFollowingString.ts b/tests/cases/fourslash/completionAfterBackslashFollowingString.ts index 2e8587ffd1fa9..f3b1b6b195bf1 100644 --- a/tests/cases/fourslash/completionAfterBackslashFollowingString.ts +++ b/tests/cases/fourslash/completionAfterBackslashFollowingString.ts @@ -2,5 +2,4 @@ ////Harness.newLine = ""\n/**/ -goTo.marker(); -verify.not.completionListIsEmpty(); \ No newline at end of file +verify.completions({ marker: "", exact: completion.globals }); diff --git a/tests/cases/fourslash/completionAfterBrace.ts b/tests/cases/fourslash/completionAfterBrace.ts index ec6cc13689d31..b9951459137c1 100644 --- a/tests/cases/fourslash/completionAfterBrace.ts +++ b/tests/cases/fourslash/completionAfterBrace.ts @@ -1,9 +1,7 @@ /// -//// +//// //// }/**/ -//// +//// - -goTo.marker(); -verify.not.completionListIsEmpty(); \ No newline at end of file +verify.completions({ marker: "", exact: completion.globals }); diff --git a/tests/cases/fourslash/completionAfterDotDotDot.ts b/tests/cases/fourslash/completionAfterDotDotDot.ts index 10c2d39b8cb71..fc9ab05bbaede 100644 --- a/tests/cases/fourslash/completionAfterDotDotDot.ts +++ b/tests/cases/fourslash/completionAfterDotDotDot.ts @@ -2,5 +2,4 @@ ////.../**/ -goTo.marker(); -verify.not.completionListIsEmpty(); \ No newline at end of file +verify.completions({ marker: "", exact: completion.globals }); diff --git a/tests/cases/fourslash/completionAwaitKeyword.ts b/tests/cases/fourslash/completionAwaitKeyword.ts deleted file mode 100644 index 3cb565cf88bd3..0000000000000 --- a/tests/cases/fourslash/completionAwaitKeyword.ts +++ /dev/null @@ -1,4 +0,0 @@ -//// /**/ - -goTo.marker("") -verify.completionListContains("await"); \ No newline at end of file diff --git a/tests/cases/fourslash/completionBeforeSemanticDiagnosticsInArrowFunction1.ts b/tests/cases/fourslash/completionBeforeSemanticDiagnosticsInArrowFunction1.ts index d66c16207518d..3e7c5ddf1f317 100644 --- a/tests/cases/fourslash/completionBeforeSemanticDiagnosticsInArrowFunction1.ts +++ b/tests/cases/fourslash/completionBeforeSemanticDiagnosticsInArrowFunction1.ts @@ -11,8 +11,7 @@ edit.insert("A"); // Bring up completion to force a pull resolve. This will end up resolving several symbols and // producing unreported diagnostics (i.e. that 'V' wasn't found). -verify.completionListContains("T"); -verify.completionEntryDetailIs("T", "(type parameter) T in (x: any): void"); +verify.completions({ includes: { name: "T", text: "(type parameter) T in (x: any): void" } }); // There should now be a single error. verify.numberOfErrorsInCurrentFile(1); diff --git a/tests/cases/fourslash/completionEntryForClassMembers.ts b/tests/cases/fourslash/completionEntryForClassMembers.ts index 8945245a286ed..9da74be0bb1bd 100644 --- a/tests/cases/fourslash/completionEntryForClassMembers.ts +++ b/tests/cases/fourslash/completionEntryForClassMembers.ts @@ -1,5 +1,7 @@ /// +// @noLib: true + ////abstract class B { //// private privateMethod() { } //// protected protectedMethod() { }; @@ -114,149 +116,111 @@ ////} ////class O extends B { //// constructor(public a) { -//// }, +//// }, //// /*classElementAfterConstructorSeparatedByComma*/ ////} -const allowedKeywordCount = verify.allowedClassElementKeywords.length; -type CompletionInfo = [string, string]; -type CompletionInfoVerifier = { validMembers: CompletionInfo[], invalidMembers: CompletionInfo[] }; - -function verifyClassElementLocations({ validMembers, invalidMembers }: CompletionInfoVerifier, classElementCompletionLocations: string[]) { - for (const marker of classElementCompletionLocations) { - goTo.marker(marker); - verifyCompletionInfo(validMembers, verify); - verifyCompletionInfo(invalidMembers, verify.not); - verify.completionListContainsClassElementKeywords(); - verify.completionListCount(allowedKeywordCount + validMembers.length); - } -} - -function verifyCompletionInfo(memberInfo: CompletionInfo[], verify: FourSlashInterface.verifyNegatable) { - for (const [symbol, text] of memberInfo) { - verify.completionListContains(symbol, text, /*documentation*/ undefined, "method"); - } -} - -const allMembersOfBase: CompletionInfo[] = [ - ["getValue", "(method) B.getValue(): number"], - ["protectedMethod", "(method) B.protectedMethod(): void"], - ["privateMethod", "(method) B.privateMethod(): void"], - ["staticMethod", "(method) B.staticMethod(): void"] -]; -const publicCompletionInfoOfD1: CompletionInfo[] = [ - ["getValue1", "(method) D1.getValue1(): number"] -]; -const publicCompletionInfoOfD2: CompletionInfo[] = [ - ["protectedMethod", "(method) D2.protectedMethod(): void"] -]; -function filterCompletionInfo(fn: (a: CompletionInfo) => boolean): CompletionInfoVerifier { - const validMembers: CompletionInfo[] = []; - const invalidMembers: CompletionInfo[] = []; - for (const member of allMembersOfBase) { - if (fn(member)) { - validMembers.push(member); - } - else { - invalidMembers.push(member); - } - } - return { validMembers, invalidMembers }; -} - - -const instanceMemberInfo = filterCompletionInfo(([a]: CompletionInfo) => a === "getValue" || a === "protectedMethod"); -const staticMemberInfo = filterCompletionInfo(([a]: CompletionInfo) => a === "staticMethod"); -const instanceWithoutProtectedMemberInfo = filterCompletionInfo(([a]: CompletionInfo) => a === "getValue"); -const instanceWithoutPublicMemberInfo = filterCompletionInfo(([a]: CompletionInfo) => a === "protectedMethod"); - -const instanceMemberInfoD1: CompletionInfoVerifier = { - validMembers: instanceMemberInfo.validMembers.concat(publicCompletionInfoOfD1), - invalidMembers: instanceMemberInfo.invalidMembers -}; -const instanceMemberInfoD2: CompletionInfoVerifier = { - validMembers: instanceWithoutProtectedMemberInfo.validMembers.concat(publicCompletionInfoOfD2), - invalidMembers: instanceWithoutProtectedMemberInfo.invalidMembers -}; -const staticMemberInfoDn: CompletionInfoVerifier = { - validMembers: staticMemberInfo.validMembers, - invalidMembers: staticMemberInfo.invalidMembers.concat(publicCompletionInfoOfD1, publicCompletionInfoOfD2) -}; - -// Not a class element declaration location -const nonClassElementMarkers = [ - "InsideMethod" -]; -for (const marker of nonClassElementMarkers) { - goTo.marker(marker); - verifyCompletionInfo(allMembersOfBase, verify.not); - verify.not.completionListIsEmpty(); -} - -// Only keywords allowed at this position since they dont extend the class or are private -const onlyClassElementKeywordLocations = [ - "abstractClass", - "classThatDoesNotExtendAnotherClass", - "classThatHasWrittenPrivateKeyword", - "classElementContainingPrivateStatic", - "classThatStartedWritingIdentifierAfterPrivateModifier", - "classThatStartedWritingIdentifierAfterPrivateStaticModifier" -]; -verifyClassElementLocations({ validMembers: [], invalidMembers: allMembersOfBase }, onlyClassElementKeywordLocations); - -// Instance base members and class member keywords allowed -const classInstanceElementLocations = [ - "classThatIsEmptyAndExtendingAnotherClass", - "classThatHasDifferentMethodThanBase", - "classThatHasDifferentMethodThanBaseAfterMethod", - "classThatHasWrittenPublicKeyword", - "classThatStartedWritingIdentifier", - "propDeclarationWithoutSemicolon", - "propDeclarationWithSemicolon", - "propAssignmentWithSemicolon", - "propAssignmentWithoutSemicolon", - "methodSignatureWithoutSemicolon", - "methodSignatureWithSemicolon", - "methodImplementation", - "accessorSignatureWithoutSemicolon", - "accessorSignatureImplementation", - "classThatHasWrittenGetKeyword", - "classThatHasWrittenSetKeyword", - "classThatStartedWritingIdentifierOfGetAccessor", - "classThatStartedWritingIdentifierOfSetAccessor", - "classThatStartedWritingIdentifierAfterModifier", - "classThatHasWrittenAsyncKeyword", - "classElementAfterConstructorSeparatedByComma" -]; -verifyClassElementLocations(instanceMemberInfo, classInstanceElementLocations); - -// Static Base members and class member keywords allowed -const staticClassLocations = [ - "classElementContainingStatic", - "classThatStartedWritingIdentifierAfterStaticModifier" -]; -verifyClassElementLocations(staticMemberInfo, staticClassLocations); - -const classInstanceElementWithoutPublicMethodLocations = [ - "classThatHasAlreadyImplementedAnotherClassMethod", - "classThatHasAlreadyImplementedAnotherClassMethodAfterMethod", -]; -verifyClassElementLocations(instanceWithoutPublicMemberInfo, classInstanceElementWithoutPublicMethodLocations); - -const classInstanceElementWithoutProtectedMethodLocations = [ - "classThatHasAlreadyImplementedAnotherClassProtectedMethod", - "classThatHasDifferentMethodThanBaseAfterProtectedMethod", -]; -verifyClassElementLocations(instanceWithoutProtectedMemberInfo, classInstanceElementWithoutProtectedMethodLocations); - -// instance memebers in D1 and base class are shown -verifyClassElementLocations(instanceMemberInfoD1, ["classThatExtendsClassExtendingAnotherClass"]); - -// instance memebers in D2 and base class are shown -verifyClassElementLocations(instanceMemberInfoD2, ["classThatExtendsClassExtendingAnotherClassWithOverridingMember"]); - -// static base members and class member keywords allowed -verifyClassElementLocations(staticMemberInfoDn, [ - "classThatExtendsClassExtendingAnotherClassAndTypesStatic", - "classThatExtendsClassExtendingAnotherClassWithOverridingMemberAndTypesStatic" -]); \ No newline at end of file +const getValue: FourSlashInterface.ExpectedCompletionEntry = { name: "getValue", text: "(method) B.getValue(): number" }; +const protectedMethod: FourSlashInterface.ExpectedCompletionEntry = { name: "protectedMethod", text: "(method) B.protectedMethod(): void" }; +const staticMethod: FourSlashInterface.ExpectedCompletionEntry = { name: "staticMethod", text: "(method) B.staticMethod(): void" }; + +verify.completions( + { + // Not a class element declaration location + marker: "InsideMethod", + exact: [ + "arguments", + "B", "C", "D", "D1", "D2", "D3", "D4", "D5", "D6", "E", "F", "F2", "G", "G2", "H", "I", "J", "K", "L", "L2", "M", "N", "O", + "undefined", + ...completion.insideMethodKeywords, + ], + }, + { + // Only keywords allowed at this position since they dont extend the class or are private + marker: [ + "abstractClass", + "classThatDoesNotExtendAnotherClass", + "classThatHasWrittenPrivateKeyword", + "classElementContainingPrivateStatic", + "classThatStartedWritingIdentifierAfterPrivateModifier", + "classThatStartedWritingIdentifierAfterPrivateStaticModifier", + ], + exact: ["private", "protected", "public", "static", "abstract", "async", "constructor", "get", "readonly", "set"], + isNewIdentifierLocation: true, + }, + { + // Instance base members and class member keywords allowed + marker:[ + "classThatIsEmptyAndExtendingAnotherClass", + "classThatHasDifferentMethodThanBase", + "classThatHasDifferentMethodThanBaseAfterMethod", + "classThatHasWrittenPublicKeyword", + "classThatStartedWritingIdentifier", + "propDeclarationWithoutSemicolon", + "propDeclarationWithSemicolon", + "propAssignmentWithSemicolon", + "propAssignmentWithoutSemicolon", + "methodSignatureWithoutSemicolon", + "methodSignatureWithSemicolon", + "methodImplementation", + "accessorSignatureWithoutSemicolon", + "accessorSignatureImplementation", + "classThatHasWrittenGetKeyword", + "classThatHasWrittenSetKeyword", + "classThatStartedWritingIdentifierOfGetAccessor", + "classThatStartedWritingIdentifierOfSetAccessor", + "classThatStartedWritingIdentifierAfterModifier", + "classThatHasWrittenAsyncKeyword", + "classElementAfterConstructorSeparatedByComma", + ], + exact: [protectedMethod, getValue, ...completion.classElementKeywords], + isNewIdentifierLocation: true, + }, + { + // Static Base members and class member keywords allowed + marker: ["classElementContainingStatic", "classThatStartedWritingIdentifierAfterStaticModifier"], + exact: [staticMethod, ...completion.classElementKeywords], + isNewIdentifierLocation: true, + }, + { + marker: [ + "classThatHasAlreadyImplementedAnotherClassMethod", + "classThatHasAlreadyImplementedAnotherClassMethodAfterMethod", + ], + exact: [protectedMethod, ...completion.classElementKeywords], + isNewIdentifierLocation: true, + }, + { + marker: [ + "classThatHasAlreadyImplementedAnotherClassProtectedMethod", + "classThatHasDifferentMethodThanBaseAfterProtectedMethod", + ], + exact: [getValue, ...completion.classElementKeywords], + isNewIdentifierLocation: true, + }, + { + // instance memebers in D1 and base class are shown + marker: "classThatExtendsClassExtendingAnotherClass", + exact: ["getValue1", "protectedMethod", "getValue", ...completion.classElementKeywords], + isNewIdentifierLocation: true, + }, + { + // instance memebers in D2 and base class are shown + marker: "classThatExtendsClassExtendingAnotherClassWithOverridingMember", + exact: [ + { name: "protectedMethod", text: "(method) D2.protectedMethod(): void" }, + getValue, + ...completion.classElementKeywords, + ], + isNewIdentifierLocation: true, + }, + { + // static base members and class member keywords allowed + marker: [ + "classThatExtendsClassExtendingAnotherClassAndTypesStatic", + "classThatExtendsClassExtendingAnotherClassWithOverridingMemberAndTypesStatic" + ], + exact: [staticMethod, ...completion.classElementKeywords], + isNewIdentifierLocation: true, + }, +); diff --git a/tests/cases/fourslash/completionEntryForClassMembers2.ts b/tests/cases/fourslash/completionEntryForClassMembers2.ts index 9d2d158cd554b..1048b5b47d07a 100644 --- a/tests/cases/fourslash/completionEntryForClassMembers2.ts +++ b/tests/cases/fourslash/completionEntryForClassMembers2.ts @@ -188,268 +188,216 @@ //// static /*extendsB0AndImplementsI6ThatExtendsB0AndHasStaticMethodOfB0TypesStatic*/ ////} -const allowedKeywordCount = verify.allowedClassElementKeywords.length; -type CompletionInfo = [string, string]; -type CompletionInfoVerifier = { validMembers: CompletionInfo[], invalidMembers: CompletionInfo[] }; - -function verifyClassElementLocations({ validMembers, invalidMembers }: CompletionInfoVerifier, classElementCompletionLocations: string[]) { - for (const marker of classElementCompletionLocations) { - goTo.marker(marker); - verifyCompletionInfo(validMembers, verify); - verifyCompletionInfo(invalidMembers, verify.not); - verify.completionListContainsClassElementKeywords(); - verify.completionListCount(allowedKeywordCount + validMembers.length); - } -} - -function verifyCompletionInfo(memberInfo: CompletionInfo[], verify: FourSlashInterface.verifyNegatable) { - for (const [symbol, text] of memberInfo) { - verify.completionListContains(symbol, text, /*documentation*/ undefined, "method"); - } -} - -const validInstanceMembersOfBaseClassB: CompletionInfo[] = [ - ["getValue", "(method) B.getValue(): string | boolean"], - ["protectedMethod", "(method) B.protectedMethod(): void"], +const validInstanceMembersOfBaseClassB: ReadonlyArray = [ + { name: "protectedMethod", text: "(method) B.protectedMethod(): void" }, + { name: "getValue", text: "(method) B.getValue(): string | boolean" }, ]; -const validStaticMembersOfBaseClassB: CompletionInfo[] = [ - ["staticMethod", "(method) B.staticMethod(): void"] +const validStaticMembersOfBaseClassB: ReadonlyArray = [ + { name: "staticMethod", text: "(method) B.staticMethod(): void" }, ]; -const privateMembersOfBaseClassB: CompletionInfo[] = [ - ["privateMethod", "(method) B.privateMethod(): void"], +const privateMembersOfBaseClassB: ReadonlyArray = [ + { name: "privateMethod", text: "(method) B.privateMethod(): void" }, ]; -const protectedPropertiesOfBaseClassB0: CompletionInfo[] = [ - ["protectedMethod", "(method) B0.protectedMethod(): void"], - ["protectedMethod1", "(method) B0.protectedMethod1(): void"], +const protectedPropertiesOfBaseClassB0: ReadonlyArray = [ + { name: "protectedMethod", text: "(method) B0.protectedMethod(): void" }, + { name: "protectedMethod1", text: "(method) B0.protectedMethod1(): void" }, ]; -const publicPropertiesOfBaseClassB0: CompletionInfo[] = [ - ["getValue", "(method) B0.getValue(): string | boolean"], - ["getValue1", "(method) B0.getValue1(): string | boolean"], +const publicPropertiesOfBaseClassB0: ReadonlyArray = [ + { name: "getValue", text: "(method) B0.getValue(): string | boolean" }, + { name: "getValue1", text: "(method) B0.getValue1(): string | boolean" }, ]; -const validInstanceMembersOfBaseClassB0: CompletionInfo[] = protectedPropertiesOfBaseClassB0.concat(publicPropertiesOfBaseClassB0); -const validStaticMembersOfBaseClassB0: CompletionInfo[] = [ - ["staticMethod", "(method) B0.staticMethod(): void"], - ["staticMethod1", "(method) B0.staticMethod1(): void"] +const validInstanceMembersOfBaseClassB0: ReadonlyArray = protectedPropertiesOfBaseClassB0.concat(publicPropertiesOfBaseClassB0); +const validInstanceMembersOfBaseClassB0_2 : ReadonlyArray = [ + protectedPropertiesOfBaseClassB0[0], + publicPropertiesOfBaseClassB0[0], + protectedPropertiesOfBaseClassB0[1], + publicPropertiesOfBaseClassB0[1], ]; -const privateMembersOfBaseClassB0: CompletionInfo[] = [ - ["privateMethod", "(method) B0.privateMethod(): void"], - ["privateMethod1", "(method) B0.privateMethod1(): void"], +const validStaticMembersOfBaseClassB0: ReadonlyArray = [ + { name: "staticMethod", text: "(method) B0.staticMethod(): void" }, + { name: "staticMethod1", text: "(method) B0.staticMethod1(): void" }, ]; -const membersOfI: CompletionInfo[] = [ - ["methodOfInterface", "(method) I.methodOfInterface(): number"], +const privateMembersOfBaseClassB0: ReadonlyArray = [ + { name: "privateMethod", text: "(method) B0.privateMethod(): void" }, + { name: "privateMethod1", text: "(method) B0.privateMethod1(): void" }, ]; -const membersOfI2: CompletionInfo[] = [ - ["methodOfInterface2", "(method) I2.methodOfInterface2(): number"], +const membersOfI: ReadonlyArray = [ + { name: "methodOfInterface", text: "(method) I.methodOfInterface(): number" }, ]; -const membersOfI3: CompletionInfo[] = [ - ["getValue", "(method) I3.getValue(): string"], - ["method", "(method) I3.method(): string"], +const membersOfI2: ReadonlyArray = [ + { name: "methodOfInterface2", text: "(method) I2.methodOfInterface2(): number" }, ]; -const membersOfI4: CompletionInfo[] = [ - ["staticMethod", "(method) I4.staticMethod(): void"], - ["method", "(method) I4.method(): string"], +const membersOfI3: ReadonlyArray = [ + { name: "getValue", text: "(method) I3.getValue(): string" }, + { name: "method", text: "(method) I3.method(): string" }, ]; -const membersOfI5: CompletionInfo[] = publicPropertiesOfBaseClassB0.concat([ - ["methodOfInterface5", "(method) I5.methodOfInterface5(): number"] -]); -const membersOfI6: CompletionInfo[] = publicPropertiesOfBaseClassB0.concat([ - ["staticMethod", "(method) I6.staticMethod(): void"], - ["methodOfInterface6", "(method) I6.methodOfInterface6(): number"] +const membersOfI4: ReadonlyArray = [ + { name: "staticMethod", text: "(method) I4.staticMethod(): void" }, + { name: "method", text: "(method) I4.method(): string" }, +]; +const membersOfI5: ReadonlyArray = publicPropertiesOfBaseClassB0.concat([ + { name: "methodOfInterface5", text: "(method) I5.methodOfInterface5(): number" }, ]); -const membersOfI7: CompletionInfo[] = membersOfI.concat([ - ["methodOfInterface7", "(method) I7.methodOfInterface7(): number"] +const membersOfJustI5: ReadonlyArray = [ + { name: "methodOfInterface5", text: "(method) I5.methodOfInterface5(): number" }, +]; +const membersOfI6: ReadonlyArray = publicPropertiesOfBaseClassB0.concat([ + { name: "staticMethod", text: "(method) I6.staticMethod(): void" }, + { name: "methodOfInterface6", text: "(method) I6.methodOfInterface6(): number" }, ]); +const membersOfI7: ReadonlyArray = [ + { name: "methodOfInterface7", text: "(method) I7.methodOfInterface7(): number" }, + ...membersOfI, +]; +const membersOfI7_2: ReadonlyArray = [ + ...membersOfI, + { name: "methodOfInterface7", text: "(method) I7.methodOfInterface7(): number" }, +]; -function getCompletionInfoVerifier( - validMembers: CompletionInfo[], - invalidMembers: CompletionInfo[], - arrayToDistribute: CompletionInfo[], - isValidDistributionCriteria: (v: CompletionInfo) => boolean): CompletionInfoVerifier { - if (arrayToDistribute) { - validMembers = validMembers.concat(arrayToDistribute.filter(isValidDistributionCriteria)); - invalidMembers = invalidMembers.concat(arrayToDistribute.filter(v => !isValidDistributionCriteria(v))); - } - return { - validMembers, - invalidMembers - } -} - -const noMembers: CompletionInfo[] = []; -const membersOfIAndI2 = membersOfI.concat(membersOfI2); +const noMembers: ReadonlyArray = []; +const membersOfIAndI2 = [...membersOfI, ...membersOfI2]; const invalidMembersOfBAtInstanceLocation = privateMembersOfBaseClassB.concat(validStaticMembersOfBaseClassB); -// members of I and I2 -verifyClassElementLocations({ validMembers: membersOfIAndI2, invalidMembers: noMembers }, [ - "implementsIAndI2", - "implementsIAndI2AndWritingMethodNameOfI" -]); - -// Static location so no members of I and I2 -verifyClassElementLocations({ validMembers: noMembers, invalidMembers: membersOfIAndI2 }, - ["implementsIAndI2AndWritingStatic"]); - -const allInstanceBAndIAndI2 = membersOfIAndI2.concat(validInstanceMembersOfBaseClassB); -// members of instance B, I and I2 -verifyClassElementLocations({ - validMembers: allInstanceBAndIAndI2, - invalidMembers: invalidMembersOfBAtInstanceLocation -}, ["extendsBAndImplementsIAndI2"]); - -// static location so only static members of B and no members of instance B, I and I2 -verifyClassElementLocations({ - validMembers: validStaticMembersOfBaseClassB, - invalidMembers: privateMembersOfBaseClassB.concat(allInstanceBAndIAndI2) -}, [ - "extendsBAndImplementsIAndI2AndWritingStatic", - "extendsBAndImplementsIAndI2WithMethodFromBAndIAndTypesStatic" - ]); -// instance members of B without protectedMethod, I and I2 -verifyClassElementLocations( - getCompletionInfoVerifier( - /*validMembers*/ membersOfIAndI2, - /*invalidMembers*/ invalidMembersOfBAtInstanceLocation, - /*arrayToDistribute*/ validInstanceMembersOfBaseClassB, - value => value[0] !== "protectedMethod"), - ["extendsBAndImplementsIAndI2WithMethodFromB"]); +const allInstanceBAndIAndI2 = [...validInstanceMembersOfBaseClassB, ...membersOfIAndI2]; -// instance members of B, members of T without methodOfInterface and I2 -verifyClassElementLocations( - getCompletionInfoVerifier( - /*validMembers*/ membersOfI2.concat(validInstanceMembersOfBaseClassB), - /*invalidMembers*/ invalidMembersOfBAtInstanceLocation, - /*arrayToDistribute*/ membersOfI, - value => value[0] !== "methodOfInterface"), - ["extendsBAndImplementsIAndI2WithMethodFromI"]); - -// instance members of B without protectedMethod, members of T without methodOfInterface and I2 -verifyClassElementLocations( - getCompletionInfoVerifier( - /*validMembers*/ membersOfI2, - /*invalidMembers*/ invalidMembersOfBAtInstanceLocation, - /*arrayToDistribute*/ membersOfI.concat(validInstanceMembersOfBaseClassB), - value => value[0] !== "methodOfInterface" && value[0] !== "protectedMethod"), - ["extendsBAndImplementsIAndI2WithMethodFromBAndI"]); - -// members of B and members of I3 that are not same as name of method in B -verifyClassElementLocations( - getCompletionInfoVerifier( - /*validMembers*/ validInstanceMembersOfBaseClassB, - /*invalidMembers*/ invalidMembersOfBAtInstanceLocation, - /*arrayToDistribute*/ membersOfI3, - value => value[0] !== "getValue"), - ["extendsBAndImplementsI3WithSameNameMembers"]); - -// members of B (without getValue since its implemented) and members of I3 that are not same as name of method in B -verifyClassElementLocations( - getCompletionInfoVerifier( - /*validMembers*/ noMembers, - /*invalidMembers*/ invalidMembersOfBAtInstanceLocation, - /*arrayToDistribute*/ membersOfI3.concat(validInstanceMembersOfBaseClassB), - value => value[0] !== "getValue"), - ["extendsBAndImplementsI3WithSameNameMembersAndHasImplementedTheMember"]); - -const invalidMembersOfB0AtInstanceSide = privateMembersOfBaseClassB0.concat(validStaticMembersOfBaseClassB0); -const invalidMembersOfB0AtStaticSide = privateMembersOfBaseClassB0.concat(validInstanceMembersOfBaseClassB0); -// members of B0 and members of I4 -verifyClassElementLocations({ - validMembers: validInstanceMembersOfBaseClassB0.concat(membersOfI4), - invalidMembers: invalidMembersOfB0AtInstanceSide -}, [ - "extendsB0ThatExtendsAndImplementsI4WithStaticMethod", - "extendsB0ThatExtendsAndImplementsI4WithStaticMethodAndImplementedAnotherMethod", - "extendsB0ThatExtendsAndImplementsI4WithStaticMethodAndImplementedThatMethodAsStatic" - ]); - -// members of B0 and members of I4 that are not staticMethod -verifyClassElementLocations( - getCompletionInfoVerifier( - /*validMembers*/ validInstanceMembersOfBaseClassB0, - /*invalidMembers*/ invalidMembersOfB0AtInstanceSide, - /*arrayToDistribute*/ membersOfI4, - value => value[0] !== "staticMethod" - ), [ - "extendsB0ThatExtendsAndImplementsI4WithStaticMethodAndImplementedThatMethod", - "extendsB0ThatExtendsAndImplementsI4WithStaticMethodAndImplementedThatMethodAsBoth" - ]); - -// static members of B0 -verifyClassElementLocations({ - validMembers: validStaticMembersOfBaseClassB0, - invalidMembers: invalidMembersOfB0AtStaticSide.concat(membersOfI4) -}, [ - "extendsB0ThatExtendsAndImplementsI4WithStaticMethodWritingStatic", - "extendsB0ThatExtendsAndImplementsI4WithStaticMethodAndImplementedAnotherMethodWritingStatic", - "extendsB0ThatExtendsAndImplementsI4WithStaticMethodAndImplementedThatMethodWritingStatic" - ]); - -// static members of B0 without staticMethod -verifyClassElementLocations( - getCompletionInfoVerifier( - /*validMembers*/ noMembers, - /*invalidMembers*/ invalidMembersOfB0AtStaticSide.concat(membersOfI4), - /*arrayToDistribute*/ validStaticMembersOfBaseClassB0, - value => value[0] !== "staticMethod" - ), [ - "extendsB0ThatExtendsAndImplementsI4WithStaticMethodAndImplementedThatMethodAsStaticWritingStatic", - "extendsB0ThatExtendsAndImplementsI4WithStaticMethodAndImplementedThatMethodAsBothWritingStatic" - ]); - -// members of I7 extends I -verifyClassElementLocations({ validMembers: membersOfI7, invalidMembers: noMembers }, [ - "implementsI7whichExtendsI", - "implementsI7whichExtendsIAndAlsoImplementsI", - "implementsIAndAlsoImplementsI7whichExtendsI" -]); +const invalidMembersOfB0AtInstanceSide = [...privateMembersOfBaseClassB0, ...validStaticMembersOfBaseClassB0]; +const invalidMembersOfB0AtStaticSide = [...privateMembersOfBaseClassB0, validInstanceMembersOfBaseClassB0]; const invalidMembersOfB0AtInstanceSideFromInterfaceExtendingB0 = invalidMembersOfB0AtInstanceSide; -// members of I5 extends B0 -verifyClassElementLocations({ - validMembers: membersOfI5.concat(protectedPropertiesOfBaseClassB0), - invalidMembers: invalidMembersOfB0AtInstanceSideFromInterfaceExtendingB0 -}, [ - "implementsI5ThatExtendsB0", - ]); - -// members of I6 extends B0 -verifyClassElementLocations({ - validMembers: membersOfI6.concat(protectedPropertiesOfBaseClassB0), - invalidMembers: invalidMembersOfB0AtInstanceSideFromInterfaceExtendingB0 -}, [ - "implementsI6ThatExtendsB0AndHasStaticMethodOfB0", - ]); -// members of B0 and I5 that extends B0 -verifyClassElementLocations({ - validMembers: membersOfI5.concat(protectedPropertiesOfBaseClassB0), - invalidMembers: invalidMembersOfB0AtInstanceSide -}, [ - "extendsB0AndImplementsI5ThatExtendsB0" - ]); - -// members of B0 and I6 that extends B0 -verifyClassElementLocations({ - validMembers: membersOfI6.concat(protectedPropertiesOfBaseClassB0), - invalidMembers: invalidMembersOfB0AtInstanceSide -}, [ - "extendsB0AndImplementsI6ThatExtendsB0AndHasStaticMethodOfB0" - ]); - -// nothing on static side as these do not extend any other class -verifyClassElementLocations({ - validMembers: [], - invalidMembers: membersOfI5.concat(membersOfI6, invalidMembersOfB0AtStaticSide) -}, [ - "implementsI5ThatExtendsB0TypesStatic", - "implementsI6ThatExtendsB0AndHasStaticMethodOfB0TypesStatic" - ]); +const tests: ReadonlyArray<{ readonly marker: string | ReadonlyArray, readonly members: ReadonlyArray }> = [ + // members of I and I2 + { marker: ["implementsIAndI2", "implementsIAndI2AndWritingMethodNameOfI"], members: membersOfIAndI2 }, + // Static location so no members of I and I2 + { marker: "implementsIAndI2AndWritingStatic", members: [] }, + // members of instance B, I and I2 + { marker: "extendsBAndImplementsIAndI2", members: allInstanceBAndIAndI2 }, + // static location so only static members of B and no members of instance B, I and I2 + { + marker: [ + "extendsBAndImplementsIAndI2AndWritingStatic", + "extendsBAndImplementsIAndI2WithMethodFromBAndIAndTypesStatic" + ], + members: validStaticMembersOfBaseClassB, + }, + // instance members of B without protectedMethod, I and I2 + { marker: "extendsBAndImplementsIAndI2WithMethodFromB",members: [validInstanceMembersOfBaseClassB[1], ...membersOfIAndI2] }, //TODO:NEATER + // instance members of B, members of T without methodOfInterface and I2 + { marker: "extendsBAndImplementsIAndI2WithMethodFromI", members: [...validInstanceMembersOfBaseClassB, ...membersOfI2] }, + // instance members of B without protectedMethod, members of T without methodOfInterface and I2 + { marker: "extendsBAndImplementsIAndI2WithMethodFromBAndI", members: [validInstanceMembersOfBaseClassB[1], ...membersOfI2] }, + // members of B and members of I3 that are not same as name of method in B + { marker: "extendsBAndImplementsI3WithSameNameMembers", members: [...validInstanceMembersOfBaseClassB, membersOfI3[1]] }, //TODO:NEATER + // members of B (without getValue since its implemented) and members of I3 that are not same as name of method in B + { marker: "extendsBAndImplementsI3WithSameNameMembersAndHasImplementedTheMember", members: [validInstanceMembersOfBaseClassB[0], membersOfI3[1]] }, //TODO:NEATER + // members of B0 and members of I4 + { + marker: [ + "extendsB0ThatExtendsAndImplementsI4WithStaticMethod", + "extendsB0ThatExtendsAndImplementsI4WithStaticMethodAndImplementedAnotherMethod", + "extendsB0ThatExtendsAndImplementsI4WithStaticMethodAndImplementedThatMethodAsStatic", + ], + members: [...validInstanceMembersOfBaseClassB0_2, ...membersOfI4], + }, + // members of B0 and members of I4 that are not staticMethod + { + marker: [ + "extendsB0ThatExtendsAndImplementsI4WithStaticMethodAndImplementedThatMethod", + "extendsB0ThatExtendsAndImplementsI4WithStaticMethodAndImplementedThatMethodAsBoth", + ], + members: [...validInstanceMembersOfBaseClassB0_2, membersOfI4[1]], //TODO:NEATER + }, + // static members of B0 + { + marker: [ + "extendsB0ThatExtendsAndImplementsI4WithStaticMethodWritingStatic", + "extendsB0ThatExtendsAndImplementsI4WithStaticMethodAndImplementedAnotherMethodWritingStatic", + "extendsB0ThatExtendsAndImplementsI4WithStaticMethodAndImplementedThatMethodWritingStatic", + ], + members: validStaticMembersOfBaseClassB0, + }, + // static members of B0 without staticMethod + { + marker: [ + "extendsB0ThatExtendsAndImplementsI4WithStaticMethodAndImplementedThatMethodAsStaticWritingStatic", + "extendsB0ThatExtendsAndImplementsI4WithStaticMethodAndImplementedThatMethodAsBothWritingStatic", + ], + members: [validStaticMembersOfBaseClassB0[1]] // TODO:NEATER + }, + // members of I7 extends I + { + marker: [ + "implementsI7whichExtendsI", + "implementsI7whichExtendsIAndAlsoImplementsI", + ], + members: membersOfI7, + }, + { + marker: "implementsIAndAlsoImplementsI7whichExtendsI", + members: membersOfI7_2, + }, + // members of I5 extends B0 + { + marker: "implementsI5ThatExtendsB0", + members: [...membersOfJustI5, protectedPropertiesOfBaseClassB0[0], publicPropertiesOfBaseClassB0[0], protectedPropertiesOfBaseClassB0[1], publicPropertiesOfBaseClassB0[1]], //TODO:NEATER + }, + // members of I6 extends B0 + { + marker: "implementsI6ThatExtendsB0AndHasStaticMethodOfB0", + //TODO:NEATER + members:[ + membersOfI6[3], + membersOfI6[2], + protectedPropertiesOfBaseClassB0[0], + membersOfI6[0], + protectedPropertiesOfBaseClassB0[1], + membersOfI6[1], + ], + }, + // members of B0 and I5 that extends B0 + { + marker: "extendsB0AndImplementsI5ThatExtendsB0", + members: [ + protectedPropertiesOfBaseClassB0[0], + membersOfI5[0], + protectedPropertiesOfBaseClassB0[1], + membersOfI5[1], + membersOfI5[2], + ], + }, + // members of B0 and I6 that extends B0 + { + marker: "extendsB0AndImplementsI6ThatExtendsB0AndHasStaticMethodOfB0", + members: [ + protectedPropertiesOfBaseClassB0[0], + membersOfI6[0], + protectedPropertiesOfBaseClassB0[1], + membersOfI6[1], + membersOfI6[3], + membersOfI6[2], + ], + }, + // nothing on static side as these do not extend any other class + { + marker: [ + "implementsI5ThatExtendsB0TypesStatic", + "implementsI6ThatExtendsB0AndHasStaticMethodOfB0TypesStatic", + ], + members: [], + }, + { + marker: [ + "extendsB0AndImplementsI5ThatExtendsB0TypesStatic", + "extendsB0AndImplementsI6ThatExtendsB0AndHasStaticMethodOfB0TypesStatic", + ], + // statics of base B but nothing from instance side + members: validStaticMembersOfBaseClassB0, + }, +]; -// statics of base B but nothing from instance side -verifyClassElementLocations({ - validMembers: validStaticMembersOfBaseClassB0, - invalidMembers: membersOfI5.concat(membersOfI6, invalidMembersOfB0AtStaticSide) -}, [ - "extendsB0AndImplementsI5ThatExtendsB0TypesStatic", - "extendsB0AndImplementsI6ThatExtendsB0AndHasStaticMethodOfB0TypesStatic" - ]); \ No newline at end of file +verify.completions(...tests.map(({ marker, members }): FourSlashInterface.CompletionsOptions => ({ + marker, + exact: [...members.map(m => ({ ...m, kind: "method" })), ...completion.classElementKeywords], + isNewIdentifierLocation: true, +}))); diff --git a/tests/cases/fourslash/completionEntryForClassMembers3.ts b/tests/cases/fourslash/completionEntryForClassMembers3.ts index a27c5959e6de1..ff33116b064da 100644 --- a/tests/cases/fourslash/completionEntryForClassMembers3.ts +++ b/tests/cases/fourslash/completionEntryForClassMembers3.ts @@ -15,11 +15,15 @@ //// zap() { } //// b/*3*/: any; ////} -const allowedKeywordCount = verify.allowedClassElementKeywords.length; + function verifyHasBar() { - verify.completionListContains("bar", "(method) IFoo.bar(): void", /*documentation*/ undefined, "method"); - verify.completionListContainsClassElementKeywords(); - verify.completionListCount(allowedKeywordCount + 1); + verify.completions({ + exact: [ + { name: "bar", text: "(method) IFoo.bar(): void", kind: "method" }, + ...completion.classElementKeywords, + ], + isNewIdentifierLocation: true, + }); } goTo.marker("1"); diff --git a/tests/cases/fourslash/completionEntryForConst.ts b/tests/cases/fourslash/completionEntryForConst.ts index 933212d4ef7d6..c89dd82124580 100644 --- a/tests/cases/fourslash/completionEntryForConst.ts +++ b/tests/cases/fourslash/completionEntryForConst.ts @@ -3,5 +3,4 @@ ////const c = "s"; /////**/ -goTo.marker(); -verify.completionListContains("c", "const c: \"s\"", /*documentation*/ undefined, "const"); \ No newline at end of file +verify.completions({ marker: "", includes: { name: "c", text: 'const c: "s"', kind: "const" } }); diff --git a/tests/cases/fourslash/completionEntryForDeferredMappedTypeMembers.ts b/tests/cases/fourslash/completionEntryForDeferredMappedTypeMembers.ts index 785ac32ee39ac..e1ec3b0102eb0 100644 --- a/tests/cases/fourslash/completionEntryForDeferredMappedTypeMembers.ts +++ b/tests/cases/fourslash/completionEntryForDeferredMappedTypeMembers.ts @@ -9,9 +9,4 @@ //// out.a./*2*/a //// out.a.a./*3*/a -goTo.marker('1'); -verify.completionListCount(1); -goTo.marker('2'); -verify.completionListCount(1); -goTo.marker('3'); -verify.completionListCount(1); +verify.completions({ marker: test.markers(), exact: "a" }); diff --git a/tests/cases/fourslash/completionEntryForImportName.ts b/tests/cases/fourslash/completionEntryForImportName.ts index 5773eb5376e59..2567d7f3e117c 100644 --- a/tests/cases/fourslash/completionEntryForImportName.ts +++ b/tests/cases/fourslash/completionEntryForImportName.ts @@ -2,10 +2,9 @@ ////import /*1*/ /*2*/ -goTo.marker('1'); -verify.completionListIsEmpty(); +verify.completions({ marker: "1", exact: undefined }); edit.insert('q'); -verify.completionListIsEmpty(); +verify.completions({ exact: undefined }); verifyIncompleteImportName(); goTo.marker('2'); @@ -18,7 +17,6 @@ edit.insert("a."); verifyIncompleteImportName(); function verifyIncompleteImportName() { - goTo.marker('1'); - verify.completionListIsEmpty(); + verify.completions({ marker: "1", exact: undefined }); verify.quickInfoIs("import q"); } \ No newline at end of file diff --git a/tests/cases/fourslash/completionEntryForPropertyFromUnionOfModuleType.ts b/tests/cases/fourslash/completionEntryForPropertyFromUnionOfModuleType.ts index a9205b97f1f77..70a0c863f879a 100644 --- a/tests/cases/fourslash/completionEntryForPropertyFromUnionOfModuleType.ts +++ b/tests/cases/fourslash/completionEntryForPropertyFromUnionOfModuleType.ts @@ -11,5 +11,4 @@ ////var q: typeof E | typeof F; ////var j = q./*1*/ -goTo.marker('1'); -verify.completionListContains('n', "(property) n: number"); \ No newline at end of file +verify.completions({ marker: "1", exact: [{ name: "n", text: "(property) n: number" }] }); diff --git a/tests/cases/fourslash/completionEntryForShorthandPropertyAssignment.ts b/tests/cases/fourslash/completionEntryForShorthandPropertyAssignment.ts index dae5762d92cf3..51779afa36deb 100644 --- a/tests/cases/fourslash/completionEntryForShorthandPropertyAssignment.ts +++ b/tests/cases/fourslash/completionEntryForShorthandPropertyAssignment.ts @@ -2,5 +2,4 @@ //// var person: {name:string; id:number} = {n/**/ -goTo.marker(); -verify.completionListContains("name", /*text*/ undefined, /*documentation*/ undefined, "property"); \ No newline at end of file +verify.completions({ marker: "", includes: { name: "name", kind: "property" } }); diff --git a/tests/cases/fourslash/completionEntryForUnionMethod.ts b/tests/cases/fourslash/completionEntryForUnionMethod.ts index f8fd9ad9dc92b..71b7702511078 100644 --- a/tests/cases/fourslash/completionEntryForUnionMethod.ts +++ b/tests/cases/fourslash/completionEntryForUnionMethod.ts @@ -3,9 +3,19 @@ ////var y: Array|Array; ////y.map/**/( -goTo.marker(); -verify.quickInfoIs( - "(property) map: ((callbackfn: (value: string, index: number, array: string[]) => U, thisArg?: any) => U[]) | ((callbackfn: (value: number, index: number, array: number[]) => U, thisArg?: any) => U[])", - "Calls a defined callback function on each element of an array, and returns an array that contains the results."); +const text = "(property) map: ((callbackfn: (value: string, index: number, array: string[]) => U, thisArg?: any) => U[]) | ((callbackfn: (value: number, index: number, array: number[]) => U, thisArg?: any) => U[])"; +const documentation = "Calls a defined callback function on each element of an array, and returns an array that contains the results."; -verify.completionListContains('map', "(property) map: ((callbackfn: (value: string, index: number, array: string[]) => U, thisArg?: any) => U[]) | ((callbackfn: (value: number, index: number, array: number[]) => U, thisArg?: any) => U[])"); \ No newline at end of file +verify.quickInfoAt("", text, documentation); +verify.completions({ + marker: "", + includes: { + name: "map", + text, + documentation, + tags: [ + { name: "param", text: "callbackfn A function that accepts up to three arguments. The map method calls the callbackfn function one time for each element in the array." }, + { name: "param", text: "thisArg An object to which the this keyword can refer in the callbackfn function. If thisArg is omitted, undefined is used as the this value." } + ], + }, +}); diff --git a/tests/cases/fourslash/completionEntryForUnionProperty.ts b/tests/cases/fourslash/completionEntryForUnionProperty.ts index 0ffc184693cdf..ea5e34d95dd4c 100644 --- a/tests/cases/fourslash/completionEntryForUnionProperty.ts +++ b/tests/cases/fourslash/completionEntryForUnionProperty.ts @@ -14,7 +14,10 @@ //// ////x./**/ -goTo.marker(); -verify.completionListContains("commonProperty", "(property) commonProperty: string | number"); -verify.completionListContains("commonFunction", "(method) commonFunction(): number"); -verify.completionListCount(2); \ No newline at end of file +verify.completions({ + marker: "", + exact: [ + { name: "commonProperty", text: "(property) commonProperty: string | number" }, + { name: "commonFunction", text: "(method) commonFunction(): number" }, + ], +}); diff --git a/tests/cases/fourslash/completionEntryForUnionProperty2.ts b/tests/cases/fourslash/completionEntryForUnionProperty2.ts index 604052ff1b584..c254213e47328 100644 --- a/tests/cases/fourslash/completionEntryForUnionProperty2.ts +++ b/tests/cases/fourslash/completionEntryForUnionProperty2.ts @@ -14,7 +14,10 @@ //// ////x.commonProperty./**/ -goTo.marker(); -verify.completionListContains("toString", "(method) toString(): string"); -verify.completionListContains("valueOf", "(method) valueOf(): string | number"); -verify.completionListCount(2); \ No newline at end of file +verify.completions({ + marker: "", + exact: [ + { name: "toString", text: "(method) toString(): string", documentation: "Returns a string representation of a string.", }, + { name: "valueOf", text: "(method) valueOf(): string | number", documentation: "Returns the primitive value of the specified object." }, + ], +}); diff --git a/tests/cases/fourslash/completionEntryOnNarrowedType.ts b/tests/cases/fourslash/completionEntryOnNarrowedType.ts index f81572ccebf4a..aa8f7a64e7f83 100644 --- a/tests/cases/fourslash/completionEntryOnNarrowedType.ts +++ b/tests/cases/fourslash/completionEntryOnNarrowedType.ts @@ -10,11 +10,8 @@ //// } ////} -goTo.marker('1'); -verify.completionListContains("strOrNum", "(parameter) strOrNum: string | number"); - -goTo.marker('2'); -verify.completionListContains("strOrNum", "(parameter) strOrNum: number"); - -goTo.marker('3'); -verify.completionListContains("strOrNum", "(parameter) strOrNum: string"); \ No newline at end of file +verify.completions( + { marker: "1", includes: { name: "strOrNum", text: "(parameter) strOrNum: string | number" } }, + { marker: "2", includes: { name: "strOrNum", text: "(parameter) strOrNum: number" } }, + { marker: "3", includes: { name: "strOrNum", text: "(parameter) strOrNum: string" } }, +); diff --git a/tests/cases/fourslash/completionForQuotedPropertyInPropertyAssignment1.ts b/tests/cases/fourslash/completionForQuotedPropertyInPropertyAssignment1.ts index 1b1cbe9a4dfcc..a913a4d5e6585 100644 --- a/tests/cases/fourslash/completionForQuotedPropertyInPropertyAssignment1.ts +++ b/tests/cases/fourslash/completionForQuotedPropertyInPropertyAssignment1.ts @@ -3,8 +3,6 @@ //// export interface Configfiles { //// jspm: string; //// 'jspm:browser': string; -//// 'jspm:dev': string; -//// 'jspm:node': string; //// } //// let files: Configfiles; @@ -13,5 +11,7 @@ //// '/*1*/': '' //// } -verify.completionsAt("0", ["jspm", '"jspm:browser"', '"jspm:dev"', '"jspm:node"']); -verify.completionsAt("1", ["jspm", "jspm:browser", "jspm:dev", "jspm:node"]); +verify.completions( + { marker: "0", exact: ["jspm", '"jspm:browser"'] }, + { marker: "1", exact: ["jspm", "jspm:browser"] }, +); diff --git a/tests/cases/fourslash/completionForQuotedPropertyInPropertyAssignment2.ts b/tests/cases/fourslash/completionForQuotedPropertyInPropertyAssignment2.ts index 669e58bdac16d..1f779908ca1ea 100644 --- a/tests/cases/fourslash/completionForQuotedPropertyInPropertyAssignment2.ts +++ b/tests/cases/fourslash/completionForQuotedPropertyInPropertyAssignment2.ts @@ -7,8 +7,6 @@ //// export interface ConfigFiles { //// jspm: string; //// 'jspm:browser': string; -//// 'jspm:dev': string; -//// 'jspm:node': string; //// } //// let config: Config; @@ -19,5 +17,7 @@ //// } //// } -verify.completionsAt("0", ["jspm", '"jspm:browser"', '"jspm:dev"', '"jspm:node"']); -verify.completionsAt("1", ["jspm", "jspm:browser", "jspm:dev", "jspm:node"]); +verify.completions( + { marker: "0", exact: ["jspm", '"jspm:browser"'] }, + { marker: "1", exact: ["jspm", "jspm:browser"] }, +); diff --git a/tests/cases/fourslash/completionForQuotedPropertyInPropertyAssignment3.ts b/tests/cases/fourslash/completionForQuotedPropertyInPropertyAssignment3.ts index 7878750c6faeb..fe8818e7831ca 100644 --- a/tests/cases/fourslash/completionForQuotedPropertyInPropertyAssignment3.ts +++ b/tests/cases/fourslash/completionForQuotedPropertyInPropertyAssignment3.ts @@ -15,5 +15,7 @@ //// '/*1*/': "" //// } -verify.completionsAt("0", ["jspm", '"jspm:browser"']); -verify.completionsAt("1", ["jspm", "jspm:browser"]); +verify.completions( + { marker: "0", exact: ["jspm", '"jspm:browser"'] }, + { marker: "1", exact: ["jspm", "jspm:browser"] }, +); diff --git a/tests/cases/fourslash/completionForQuotedPropertyInPropertyAssignment4.ts b/tests/cases/fourslash/completionForQuotedPropertyInPropertyAssignment4.ts index 703e6738098ee..ff654b57f16e2 100644 --- a/tests/cases/fourslash/completionForQuotedPropertyInPropertyAssignment4.ts +++ b/tests/cases/fourslash/completionForQuotedPropertyInPropertyAssignment4.ts @@ -3,8 +3,6 @@ //// export interface ConfigFiles { //// jspm: string; //// 'jspm:browser': string; -//// 'jspm:dev': string; -//// 'jspm:node': string; //// } //// function foo(c: ConfigFiles) {} @@ -13,12 +11,8 @@ //// "/*1*/": "", //// }) -goTo.marker('0'); -verify.completionListContains("jspm"); -//verify.completionListAllowsNewIdentifier(); -//verify.completionListCount(1); -/*goTo.marker('1'); -verify.completionListContains("jspm:dev"); -verify.completionListAllowsNewIdentifier(); -verify.completionListCount(4);*/ +verify.completions( + { marker: "0", exact: ["jspm", '"jspm:browser"'] }, + { marker: "1", exact: ["jspm", "jspm:browser"] }, +); diff --git a/tests/cases/fourslash/completionForStringLiteral.ts b/tests/cases/fourslash/completionForStringLiteral.ts index 7a14f6b65194e..66fd26f26dd13 100644 --- a/tests/cases/fourslash/completionForStringLiteral.ts +++ b/tests/cases/fourslash/completionForStringLiteral.ts @@ -6,10 +6,4 @@ ////function f(a: Options) { }; ////f("/*2*/ -goTo.marker('1'); -verify.completionListContains("Option 1"); -verify.completionListCount(3); - -goTo.marker('2'); -verify.completionListContains("Option 2"); -verify.completionListCount(3); +verify.completions({ marker: ["1", "2"], exact: ["Option 1", "Option 2", "Option 3"] }); diff --git a/tests/cases/fourslash/completionForStringLiteral10.ts b/tests/cases/fourslash/completionForStringLiteral10.ts index 76a98eb732f8e..0da078af6d8da 100644 --- a/tests/cases/fourslash/completionForStringLiteral10.ts +++ b/tests/cases/fourslash/completionForStringLiteral10.ts @@ -4,9 +4,4 @@ ////let a: As; ////if ('/**/' != a -goTo.marker(); -verify.completionListContains("arf"); -verify.completionListContains("abacus"); -verify.completionListContains("abaddon"); -verify.completionListCount(3); - +verify.completions({ marker: "", exact: ["arf", "abacus", "abaddon"] }); diff --git a/tests/cases/fourslash/completionForStringLiteral11.ts b/tests/cases/fourslash/completionForStringLiteral11.ts index f6acac28a65ac..c0edc8e2a6122 100644 --- a/tests/cases/fourslash/completionForStringLiteral11.ts +++ b/tests/cases/fourslash/completionForStringLiteral11.ts @@ -6,9 +6,4 @@ //// case '/**/ ////} -goTo.marker(); -verify.completionListContains("arf"); -verify.completionListContains("abacus"); -verify.completionListContains("abaddon"); -verify.completionListCount(3); - +verify.completions({ marker: "", exact: ["arf", "abacus", "abaddon" ] }); diff --git a/tests/cases/fourslash/completionForStringLiteral12.ts b/tests/cases/fourslash/completionForStringLiteral12.ts index 22bb2f00a43ba..a8ccfb0840233 100644 --- a/tests/cases/fourslash/completionForStringLiteral12.ts +++ b/tests/cases/fourslash/completionForStringLiteral12.ts @@ -5,6 +5,4 @@ ////function foo(x: string) {} ////foo("/**/") -goTo.marker(); -verify.completionListContains("bla"); -verify.completionListCount(1); +verify.completions({ marker: "", exact: "bla" }); diff --git a/tests/cases/fourslash/completionForStringLiteral13.ts b/tests/cases/fourslash/completionForStringLiteral13.ts index 391a1ed508313..5e3c7a56a2e26 100644 --- a/tests/cases/fourslash/completionForStringLiteral13.ts +++ b/tests/cases/fourslash/completionForStringLiteral13.ts @@ -10,5 +10,4 @@ ////var Promise: PromiseConstructor; ////Promise["/*1*/"]; -goTo.marker('1'); -verify.not.completionListContains("__@species"); +verify.completions({ marker: "1", exact: [] }); diff --git a/tests/cases/fourslash/completionForStringLiteral2.ts b/tests/cases/fourslash/completionForStringLiteral2.ts index 2bc783f7e538e..d6b71594d8855 100644 --- a/tests/cases/fourslash/completionForStringLiteral2.ts +++ b/tests/cases/fourslash/completionForStringLiteral2.ts @@ -11,5 +11,7 @@ ////o["/*2*/ ; ////p["/*3*/"]; -verify.completionsAt(["1", "2"], ["foo", "bar", "some other name"]); -verify.completionsAt("3", ["a"], { isNewIdentifierLocation: true }); +verify.completions( + { marker: ["1", "2"], exact: ["foo", "bar", "some other name"] }, + { marker: "3", exact: "a", isNewIdentifierLocation: true }, +); diff --git a/tests/cases/fourslash/completionForStringLiteral3.ts b/tests/cases/fourslash/completionForStringLiteral3.ts index 4e0a2133a0a43..9ebcec525938d 100644 --- a/tests/cases/fourslash/completionForStringLiteral3.ts +++ b/tests/cases/fourslash/completionForStringLiteral3.ts @@ -9,4 +9,4 @@ //// ////f("/*2*/ -verify.completionsAt(["1", "2"], ["A", "B", "C"], { isNewIdentifierLocation: true }); +verify.completions({ marker: ["1", "2"], exact: ["A", "B", "C"], isNewIdentifierLocation: true }); diff --git a/tests/cases/fourslash/completionForStringLiteral4.ts b/tests/cases/fourslash/completionForStringLiteral4.ts index 5629926bd187e..d05e353fd234e 100644 --- a/tests/cases/fourslash/completionForStringLiteral4.ts +++ b/tests/cases/fourslash/completionForStringLiteral4.ts @@ -17,7 +17,4 @@ goTo.marker('1'); verify.quickInfoExists(); verify.quickInfoIs('function f(p1: "literal", p2: "literal", p3: "other1" | "other2", p4: number | "literal", p5: true | 12): string', 'I am documentation'); -goTo.marker('2'); -verify.completionListContains("other1"); -verify.completionListContains("other2"); -verify.completionListCount(2); +verify.completions({ marker: "2", exact: ["other1", "other2"] }); diff --git a/tests/cases/fourslash/completionForStringLiteral5.ts b/tests/cases/fourslash/completionForStringLiteral5.ts index a850ee3aafc22..3592d37434137 100644 --- a/tests/cases/fourslash/completionForStringLiteral5.ts +++ b/tests/cases/fourslash/completionForStringLiteral5.ts @@ -8,8 +8,4 @@ ////function f(a: K) { }; ////f("/*1*/ -goTo.marker('1'); -verify.completionListContains("foo"); -verify.completionListContains("bar"); -verify.completionListCount(2); - +verify.completions({ marker: "1", exact: ["foo", "bar"] }); diff --git a/tests/cases/fourslash/completionForStringLiteral6.ts b/tests/cases/fourslash/completionForStringLiteral6.ts index ac4a378abfb91..df08f56aa9afc 100644 --- a/tests/cases/fourslash/completionForStringLiteral6.ts +++ b/tests/cases/fourslash/completionForStringLiteral6.ts @@ -6,7 +6,4 @@ ////function bar(f: Foo) { }; ////bar({x: "/**/"}); -goTo.marker(); -verify.completionListContains("abc"); -verify.completionListContains("def"); -verify.completionListCount(2); +verify.completions({ marker: "", exact: ["abc", "def"] }); diff --git a/tests/cases/fourslash/completionForStringLiteral7.ts b/tests/cases/fourslash/completionForStringLiteral7.ts index 23a12f9ea4b19..13cf2814c860a 100644 --- a/tests/cases/fourslash/completionForStringLiteral7.ts +++ b/tests/cases/fourslash/completionForStringLiteral7.ts @@ -5,5 +5,7 @@ ////function f(x: T, ...args: U[]) { }; ////f("/*1*/", "/*2*/", "/*3*/"); -verify.completionsAt("1", ["foo", "bar"]); -verify.completionsAt(["2", "3"], ["oof", "rab"]); +verify.completions( + { marker: "1", exact: ["foo", "bar"] }, + { marker: ["2", "3"], exact: ["oof", "rab"] }, +); diff --git a/tests/cases/fourslash/completionForStringLiteral8.ts b/tests/cases/fourslash/completionForStringLiteral8.ts index 727bdf6e6a444..bec0ab05b12db 100644 --- a/tests/cases/fourslash/completionForStringLiteral8.ts +++ b/tests/cases/fourslash/completionForStringLiteral8.ts @@ -4,9 +4,4 @@ ////let a: As; ////if (a === '/**/ -goTo.marker(); -verify.completionListContains("arf"); -verify.completionListContains("abacus"); -verify.completionListContains("abaddon"); -verify.completionListCount(3); - +verify.completions({ marker: "", exact: ["arf", "abacus", "abaddon"] }); diff --git a/tests/cases/fourslash/completionForStringLiteralExport.ts b/tests/cases/fourslash/completionForStringLiteralExport.ts index f20ae1b39f1e2..43275689b0a4c 100644 --- a/tests/cases/fourslash/completionForStringLiteralExport.ts +++ b/tests/cases/fourslash/completionForStringLiteralExport.ts @@ -21,7 +21,9 @@ // @Filename: my_typings/some-module/index.d.ts //// export var x = 9; -verify.completionsAt(["0", "4"], ["someFile1", "my_typings", "sub"], { isNewIdentifierLocation: true }); -verify.completionsAt("1", ["someFile2"], { isNewIdentifierLocation: true }); -verify.completionsAt("2", [{ name: "some-module", replacementSpan: test.ranges()[0] }], { isNewIdentifierLocation: true }); -verify.completionsAt("3", ["fourslash"], { isNewIdentifierLocation: true }); +verify.completions( + { marker: ["0", "4"], exact: ["someFile1", "my_typings", "sub"], isNewIdentifierLocation: true }, + { marker: "1", exact: "someFile2", isNewIdentifierLocation: true }, + { marker: "2", exact: { name: "some-module", replacementSpan: test.ranges()[0] }, isNewIdentifierLocation: true }, + { marker: "3", exact: "fourslash", isNewIdentifierLocation: true }, +); diff --git a/tests/cases/fourslash/completionForStringLiteralFromSignature.ts b/tests/cases/fourslash/completionForStringLiteralFromSignature.ts index ec7d046ef9b81..b9e96c7603b21 100644 --- a/tests/cases/fourslash/completionForStringLiteralFromSignature.ts +++ b/tests/cases/fourslash/completionForStringLiteralFromSignature.ts @@ -4,4 +4,4 @@ ////declare function f(a: string): void; ////f("/**/"); -verify.completionsAt("", ["x"], { isNewIdentifierLocation: true }); +verify.completions({ marker: "", exact: "x", isNewIdentifierLocation: true }); diff --git a/tests/cases/fourslash/completionForStringLiteralFromSignature2.ts b/tests/cases/fourslash/completionForStringLiteralFromSignature2.ts index 176efac4e5545..f070d7e238902 100644 --- a/tests/cases/fourslash/completionForStringLiteralFromSignature2.ts +++ b/tests/cases/fourslash/completionForStringLiteralFromSignature2.ts @@ -4,4 +4,4 @@ ////declare function f(a: string, b: number): void; ////f("/**/", 0); -verify.completionsAt("", [], { isNewIdentifierLocation: true }); +verify.completions({ marker: "", exact: [], isNewIdentifierLocation: true }); diff --git a/tests/cases/fourslash/completionForStringLiteralImport1.ts b/tests/cases/fourslash/completionForStringLiteralImport1.ts index 0c279d7504caf..7705d802ecc00 100644 --- a/tests/cases/fourslash/completionForStringLiteralImport1.ts +++ b/tests/cases/fourslash/completionForStringLiteralImport1.ts @@ -20,7 +20,9 @@ // @Filename: my_typings/some-module/index.d.ts //// export var x = 9; -verify.completionsAt("0", ["someFile1", "my_typings", "sub"], { isNewIdentifierLocation: true }); -verify.completionsAt("1", ["someFile2"], { isNewIdentifierLocation: true }); -verify.completionsAt("2", [{ name: "some-module", replacementSpan: test.ranges()[0] }], { isNewIdentifierLocation: true }); -verify.completionsAt("3", ["fourslash"], { isNewIdentifierLocation: true }); +verify.completions( + { marker: "0", exact: ["someFile1", "my_typings", "sub"], isNewIdentifierLocation: true }, + { marker: "1", exact: "someFile2", isNewIdentifierLocation: true }, + { marker: "2", exact: { name: "some-module", replacementSpan: test.ranges()[0] }, isNewIdentifierLocation: true }, + { marker: "3", exact: "fourslash", isNewIdentifierLocation: true }, +); diff --git a/tests/cases/fourslash/completionForStringLiteralImport2.ts b/tests/cases/fourslash/completionForStringLiteralImport2.ts index 885686f499904..727fd52a2184d 100644 --- a/tests/cases/fourslash/completionForStringLiteralImport2.ts +++ b/tests/cases/fourslash/completionForStringLiteralImport2.ts @@ -20,7 +20,9 @@ // @Filename: my_typings/some-module/index.d.ts //// export var x = 9; -verify.completionsAt("0", ["someFile.ts", "my_typings", "sub"], { isNewIdentifierLocation: true }); -verify.completionsAt("1", ["some-module"], { isNewIdentifierLocation: true }); -verify.completionsAt("2", ["someOtherFile.ts"], { isNewIdentifierLocation: true }); -verify.completionsAt("3", ["some-module"], { isNewIdentifierLocation: true }); +verify.completions( + { marker: "0", exact: ["someFile.ts", "my_typings", "sub"], isNewIdentifierLocation: true }, + { marker: "1", exact: "some-module", isNewIdentifierLocation: true }, + { marker: "2", exact: "someOtherFile.ts", isNewIdentifierLocation: true }, + { marker: "3", exact: "some-module", isNewIdentifierLocation: true }, +); diff --git a/tests/cases/fourslash/completionForStringLiteralInIndexedAccess01.ts b/tests/cases/fourslash/completionForStringLiteralInIndexedAccess01.ts index 0a86f5396c41e..14f11ba227ecd 100644 --- a/tests/cases/fourslash/completionForStringLiteralInIndexedAccess01.ts +++ b/tests/cases/fourslash/completionForStringLiteralInIndexedAccess01.ts @@ -7,7 +7,4 @@ //// ////let x: Foo["/*1*/"] -goTo.marker("1"); -verify.completionListContains("foo"); -verify.completionListContains("bar"); -verify.completionListCount(2); +verify.completions({ marker: "1", exact: ["foo", "bar"] }); diff --git a/tests/cases/fourslash/completionForStringLiteralNonrelativeImport1.ts b/tests/cases/fourslash/completionForStringLiteralNonrelativeImport1.ts index ad45719caeaa8..6737384aff0c4 100644 --- a/tests/cases/fourslash/completionForStringLiteralNonrelativeImport1.ts +++ b/tests/cases/fourslash/completionForStringLiteralNonrelativeImport1.ts @@ -42,7 +42,9 @@ //// /*unlisted-module*/ ["import_as", "import_equals", "require"].forEach((kind, i) => { - verify.completionsAt(`${kind}0`, ["fake-module", "fake-module-dev"], { isNewIdentifierLocation: true }); - verify.completionsAt(`${kind}1`, ["dts", "index", "ts", "tsx"], { isNewIdentifierLocation: true }); - verify.completionsAt(`${kind}2`, ["fake-module", "fake-module-dev"].map(name => ({ name, replacementSpan: test.ranges()[i] })), { isNewIdentifierLocation: true }); + verify.completions( + { marker: `${kind}0`, exact: ["fake-module", "fake-module-dev"], isNewIdentifierLocation: true }, + { marker: `${kind}1`, exact: ["dts", "index", "ts", "tsx"], isNewIdentifierLocation: true }, + { marker: `${kind}2`, exact: ["fake-module", "fake-module-dev"].map(name => ({ name, replacementSpan: test.ranges()[i] })), isNewIdentifierLocation: true }, + ); }); diff --git a/tests/cases/fourslash/completionForStringLiteralNonrelativeImport10.ts b/tests/cases/fourslash/completionForStringLiteralNonrelativeImport10.ts index d85d207dc0449..5e568e2507e4b 100644 --- a/tests/cases/fourslash/completionForStringLiteralNonrelativeImport10.ts +++ b/tests/cases/fourslash/completionForStringLiteralNonrelativeImport10.ts @@ -24,4 +24,4 @@ // @Filename: dir1/dir2/dir3/node_modules/fake-module3/ts.ts //// -verify.completions({ marker: test.markerNames(), exact: [], isNewIdentifierLocation: true }); +verify.completions({ marker: test.markers(), exact: [], isNewIdentifierLocation: true }); diff --git a/tests/cases/fourslash/completionForStringLiteralNonrelativeImport12.ts b/tests/cases/fourslash/completionForStringLiteralNonrelativeImport12.ts index 4d7ffccf8b8c7..8a3970fb96eed 100644 --- a/tests/cases/fourslash/completionForStringLiteralNonrelativeImport12.ts +++ b/tests/cases/fourslash/completionForStringLiteralNonrelativeImport12.ts @@ -16,7 +16,7 @@ //// } verify.completions({ - marker: test.markerNames(), + marker: test.markers(), exact: ["module", "dev-module", "peer-module", "optional-module"], isNewIdentifierLocation: true, }); diff --git a/tests/cases/fourslash/completionForStringLiteralNonrelativeImport2.ts b/tests/cases/fourslash/completionForStringLiteralNonrelativeImport2.ts index a8fe2b5679d54..5a0dd9784768c 100644 --- a/tests/cases/fourslash/completionForStringLiteralNonrelativeImport2.ts +++ b/tests/cases/fourslash/completionForStringLiteralNonrelativeImport2.ts @@ -27,4 +27,4 @@ // @Filename: ambient.ts //// declare module "fake-module/other" -verify.completionsAt(["import_as0", "import_equals0", "require0"], ["other", "repeated"], { isNewIdentifierLocation: true }) +verify.completions({ marker: ["import_as0", "import_equals0", "require0"], exact: ["other", "repeated"], isNewIdentifierLocation: true }); diff --git a/tests/cases/fourslash/completionForStringLiteralNonrelativeImport3.ts b/tests/cases/fourslash/completionForStringLiteralNonrelativeImport3.ts index 450b7fb006222..a2fbca92b1762 100644 --- a/tests/cases/fourslash/completionForStringLiteralNonrelativeImport3.ts +++ b/tests/cases/fourslash/completionForStringLiteralNonrelativeImport3.ts @@ -27,4 +27,8 @@ // @Filename: node_modules/fake-module/repeated.jsx //// /*repeatedjsx*/ -verify.completionsAt(["import_as0", "import_equals0", "require0"], ["dts", "js", "jsx", "repeated", "ts", "tsx"], { isNewIdentifierLocation: true }); +verify.completions({ + marker: ["import_as0", "import_equals0", "require0"], + exact: ["dts", "js", "jsx", "repeated", "ts", "tsx"], + isNewIdentifierLocation: true, +}); diff --git a/tests/cases/fourslash/completionForStringLiteralNonrelativeImport4.ts b/tests/cases/fourslash/completionForStringLiteralNonrelativeImport4.ts index e35ffa1992496..7c8692e4e7e2e 100644 --- a/tests/cases/fourslash/completionForStringLiteralNonrelativeImport4.ts +++ b/tests/cases/fourslash/completionForStringLiteralNonrelativeImport4.ts @@ -23,7 +23,7 @@ //// verify.completions({ - marker: test.markerNames(), + marker: test.markers(), exact: ["fake-module3", "fake-module2", "fake-module"], isNewIdentifierLocation: true, }); diff --git a/tests/cases/fourslash/completionForStringLiteralNonrelativeImport7.ts b/tests/cases/fourslash/completionForStringLiteralNonrelativeImport7.ts index f12c87c5fc3b5..fa144081001d1 100644 --- a/tests/cases/fourslash/completionForStringLiteralNonrelativeImport7.ts +++ b/tests/cases/fourslash/completionForStringLiteralNonrelativeImport7.ts @@ -18,7 +18,7 @@ //// verify.completions({ - marker: test.markerNames(), + marker: test.markers(), exact: ["module", "module-from-node"], isNewIdentifierLocation: true, }); diff --git a/tests/cases/fourslash/completionForStringLiteralNonrelativeImport8.ts b/tests/cases/fourslash/completionForStringLiteralNonrelativeImport8.ts index 58b3f6695a607..20bb304d125b4 100644 --- a/tests/cases/fourslash/completionForStringLiteralNonrelativeImport8.ts +++ b/tests/cases/fourslash/completionForStringLiteralNonrelativeImport8.ts @@ -41,7 +41,7 @@ //// export var z = 5; verify.completions({ - marker: test.markerNames(), + marker: test.markers(), exact: ["2test", "prefix", "prefix-only", "0test", "1test"], isNewIdentifierLocation: true, }); diff --git a/tests/cases/fourslash/completionForStringLiteralNonrelativeImport9.ts b/tests/cases/fourslash/completionForStringLiteralNonrelativeImport9.ts index 3a5f28b0f0cc2..cdb08070db7c7 100644 --- a/tests/cases/fourslash/completionForStringLiteralNonrelativeImport9.ts +++ b/tests/cases/fourslash/completionForStringLiteralNonrelativeImport9.ts @@ -25,4 +25,4 @@ // @Filename: some/other/path.ts //// export var y = 10; -verify.completions({ marker: test.markerNames(), exact: ["module1", "module2"], isNewIdentifierLocation: true }); +verify.completions({ marker: test.markers(), exact: ["module1", "module2"], isNewIdentifierLocation: true }); diff --git a/tests/cases/fourslash/completionForStringLiteralNonrelativeImportTypings1.ts b/tests/cases/fourslash/completionForStringLiteralNonrelativeImportTypings1.ts index 687103629e2dd..7329c5828b0c7 100644 --- a/tests/cases/fourslash/completionForStringLiteralNonrelativeImportTypings1.ts +++ b/tests/cases/fourslash/completionForStringLiteralNonrelativeImportTypings1.ts @@ -23,13 +23,4 @@ // @Filename: my_other_typings/module-z/index.d.ts //// export var z = 9; - -const kinds = ["types_ref", "import_as", "import_equals", "require"]; - -for (const kind of kinds) { - goTo.marker(kind + "0"); - verify.completionListContains("module-x"); - verify.completionListContains("module-y"); - verify.completionListContains("module-z"); - verify.not.completionListItemsCountIsGreaterThan(3); -} +verify.completions({ marker: test.markers(), exact: ["module-x", "module-y", "module-z"], isNewIdentifierLocation: true }) diff --git a/tests/cases/fourslash/completionForStringLiteralNonrelativeImportTypings2.ts b/tests/cases/fourslash/completionForStringLiteralNonrelativeImportTypings2.ts index 12a4fcf243fdb..cea75b50c456a 100644 --- a/tests/cases/fourslash/completionForStringLiteralNonrelativeImportTypings2.ts +++ b/tests/cases/fourslash/completionForStringLiteralNonrelativeImportTypings2.ts @@ -21,12 +21,4 @@ // @Filename: my_other_typings/module-z/index.d.ts //// export var z = 9; - -const kinds = ["types_ref", "import_as", "import_equals", "require"]; - -for (const kind of kinds) { - goTo.marker(kind + "0"); - verify.completionListContains("module-x"); - verify.completionListContains("module-z"); - verify.not.completionListItemsCountIsGreaterThan(2); -} +verify.completions({ marker: test.markers(), exact: ["module-x", "module-z"], isNewIdentifierLocation: true }); diff --git a/tests/cases/fourslash/completionForStringLiteralNonrelativeImportTypings3.ts b/tests/cases/fourslash/completionForStringLiteralNonrelativeImportTypings3.ts index 5f56de7798437..1e998c6e96677 100644 --- a/tests/cases/fourslash/completionForStringLiteralNonrelativeImportTypings3.ts +++ b/tests/cases/fourslash/completionForStringLiteralNonrelativeImportTypings3.ts @@ -18,4 +18,8 @@ // @Filename: package.json //// { "dependencies": { "@types/module-y": "latest" } } -verify.completionsAt(["types_ref0", "import_as0", "import_equals0", "require0"], ["module-x", "module-y"], { isNewIdentifierLocation: true }); +verify.completions({ + marker: ["types_ref0", "import_as0", "import_equals0", "require0"], + exact: ["module-x", "module-y"], + isNewIdentifierLocation: true, +}); diff --git a/tests/cases/fourslash/completionForStringLiteralRelativeImport4.ts b/tests/cases/fourslash/completionForStringLiteralRelativeImport4.ts index 1cfacb08838f2..cacb3c1917453 100644 --- a/tests/cases/fourslash/completionForStringLiteralRelativeImport4.ts +++ b/tests/cases/fourslash/completionForStringLiteralRelativeImport4.ts @@ -38,7 +38,7 @@ //// verify.completions({ - marker: test.markerNames(), + marker: test.markers(), exact: ["module1", "module2", "more", "module0"], isNewIdentifierLocation: true, }); diff --git a/tests/cases/fourslash/completionForStringLiteralRelativeImportAllowJSFalse.ts b/tests/cases/fourslash/completionForStringLiteralRelativeImportAllowJSFalse.ts index f343ce8699b38..e5260281f064c 100644 --- a/tests/cases/fourslash/completionForStringLiteralRelativeImportAllowJSFalse.ts +++ b/tests/cases/fourslash/completionForStringLiteralRelativeImportAllowJSFalse.ts @@ -22,51 +22,32 @@ // @Filename: f1.ts -//// /*f1*/ +//// // @Filename: f2.js -//// /*f2*/ +//// // @Filename: f3.d.ts -//// /*f3*/ +//// // @Filename: f4.tsx -//// /f4*/ +//// // @Filename: f5.js -//// /*f5*/ +//// // @Filename: f6.jsx -//// /*f6*/ +//// // @Filename: f7.ts -//// /*f7*/ +//// // @Filename: d1/f8.ts -//// /*d1f1*/ +//// // @Filename: d1/f9.ts -//// /*d1f9*/ +//// // @Filename: d2/f10.ts -//// /*d2f1*/ +//// // @Filename: d2/f11.ts -//// /*d2f11*/ +//// const kinds = ["import_as", "import_equals", "require"]; - -for (const kind of kinds) { - goTo.marker(kind + "0"); - verify.completionListIsEmpty(); - - goTo.marker(kind + "1"); - verify.completionListContains("f1"); - verify.completionListContains("f3"); - verify.completionListContains("f4"); - verify.completionListContains("f7"); - verify.completionListContains("d1"); - verify.completionListContains("d2"); - verify.not.completionListItemsCountIsGreaterThan(6); - - goTo.marker(kind + "2"); - verify.completionListContains("f8"); - verify.completionListContains("f9"); - verify.not.completionListItemsCountIsGreaterThan(2); - - goTo.marker(kind + "3"); - verify.completionListContains("f10"); - verify.completionListContains("f11"); - verify.completionListContains("d3"); - verify.not.completionListItemsCountIsGreaterThan(3); -} \ No newline at end of file +verify.completions( + { marker: kinds.map(k => k + "0"), exact: [], isNewIdentifierLocation: true }, + { marker: kinds.map(k => k + "1"), exact: ["f1", "f3", "f4", "f7", "d1", "d2"], isNewIdentifierLocation: true }, + { marker: kinds.map(k => k + "2"), exact: ["f8", "f9"], isNewIdentifierLocation: true }, + { marker: kinds.map(k => k + "3"), exact: ["f10", "f11", "d3"], isNewIdentifierLocation: true }, +); diff --git a/tests/cases/fourslash/completionForStringLiteralRelativeImportAllowJSTrue.ts b/tests/cases/fourslash/completionForStringLiteralRelativeImportAllowJSTrue.ts index 6eab9aaeca243..b9fe6bebdf70c 100644 --- a/tests/cases/fourslash/completionForStringLiteralRelativeImportAllowJSTrue.ts +++ b/tests/cases/fourslash/completionForStringLiteralRelativeImportAllowJSTrue.ts @@ -15,34 +15,24 @@ //// var foo6 = require("./f/*require1*/ // @Filename: f1.ts -//// /f1*/ +//// // @Filename: f2.js -//// /*f2*/ +//// // @Filename: f3.d.ts -//// /*f3*/ +//// // @Filename: f4.tsx -//// /*f4*/ +//// // @Filename: f5.js -//// /*f5*/ +//// // @Filename: f6.jsx -//// /*f6*/ +//// // @Filename: g1.ts -//// /*g1*/ +//// // @Filename: g2.js -//// /*g2*/ -const kinds = ["import_as", "import_equals", "require"]; +//// -for (const kind of kinds) { - for(let i = 0; i < 2; ++i) { - goTo.marker(kind + i); - verify.completionListContains("f1"); - verify.completionListContains("f2"); - verify.completionListContains("f3"); - verify.completionListContains("f4"); - verify.completionListContains("f5"); - verify.completionListContains("f6"); - verify.completionListContains("g1"); - verify.completionListContains("g2"); - verify.not.completionListItemsCountIsGreaterThan(8); - } -} \ No newline at end of file +verify.completions({ + marker: test.markers(), + exact: ["f1", "f2", "f3", "f4", "f5", "f6", "g1", "g2"], + isNewIdentifierLocation: true, +}); diff --git a/tests/cases/fourslash/completionForStringLiteralWithDynamicImport.ts b/tests/cases/fourslash/completionForStringLiteralWithDynamicImport.ts index 4815e52edf516..8571f483eebdb 100644 --- a/tests/cases/fourslash/completionForStringLiteralWithDynamicImport.ts +++ b/tests/cases/fourslash/completionForStringLiteralWithDynamicImport.ts @@ -20,7 +20,9 @@ // @Filename: my_typings/some-module/index.d.ts //// export var x = 9; -verify.completionsAt("0", ["someFile1", "my_typings", "sub"], { isNewIdentifierLocation: true }); -verify.completionsAt("1", ["someFile2"], { isNewIdentifierLocation: true }); -verify.completionsAt("2", [{ name: "some-module", replacementSpan: test.ranges()[0] }], { isNewIdentifierLocation: true }); -verify.completionsAt("3", ["fourslash"], { isNewIdentifierLocation: true }); +verify.completions( + { marker: "0", exact: ["someFile1", "my_typings", "sub"], isNewIdentifierLocation: true }, + { marker: "1", exact: "someFile2", isNewIdentifierLocation: true }, + { marker: "2", exact: { name: "some-module", replacementSpan: test.ranges()[0] }, isNewIdentifierLocation: true }, + { marker: "3", exact: "fourslash", isNewIdentifierLocation: true }, +); diff --git a/tests/cases/fourslash/completionForStringLiteral_details.ts b/tests/cases/fourslash/completionForStringLiteral_details.ts index 547c1fc5f81d1..f7ef83f6f3966 100644 --- a/tests/cases/fourslash/completionForStringLiteral_details.ts +++ b/tests/cases/fourslash/completionForStringLiteral_details.ts @@ -17,12 +17,14 @@ ////declare const o: I; ////o["/*prop*/"]; -goTo.marker("path"); -verify.completionListContains("other", "other", "", "script"); - -goTo.marker("type"); -verify.completionListContains("a", "a", "", "string"); - -goTo.marker("prop"); -verify.completionListContains("x", "(property) I.x: number", "Prop doc", "property"); -verify.completionListContains("m", "(method) I.m(): void", "Method doc", "method"); +verify.completions( + { marker: "path", includes: { name: "other", text: "other", kind: "script" }, isNewIdentifierLocation: true }, + { marker: "type", exact: { name: "a", text: "a", kind: "string" } }, + { + marker: "prop", + exact: [ + { name: "x", text: "(property) I.x: number", documentation: "Prop doc", kind: "property" }, + { name: "m", text: "(method) I.m(): void", documentation: "Method doc", kind: "method" }, + ], + }, +); diff --git a/tests/cases/fourslash/completionImportMeta.ts b/tests/cases/fourslash/completionImportMeta.ts index cac84c2c82f78..45b6f889a1133 100644 --- a/tests/cases/fourslash/completionImportMeta.ts +++ b/tests/cases/fourslash/completionImportMeta.ts @@ -2,5 +2,4 @@ ////import./**/ -goTo.marker(""); -verify.completionListContains("meta"); \ No newline at end of file +verify.completions({ marker: "", exact: "meta" }); diff --git a/tests/cases/fourslash/completionInAugmentedClassModule.ts b/tests/cases/fourslash/completionInAugmentedClassModule.ts index 18ea0dbbcb6cd..2ea90b2e0f20b 100644 --- a/tests/cases/fourslash/completionInAugmentedClassModule.ts +++ b/tests/cases/fourslash/completionInAugmentedClassModule.ts @@ -4,5 +4,4 @@ ////module m3f { export interface I { foo(): void } } ////var x: m3f./**/ -goTo.marker(); -verify.not.completionListContains("foo"); \ No newline at end of file +verify.completions({ marker: "", exact: "I" }); diff --git a/tests/cases/fourslash/completionInFunctionLikeBody.ts b/tests/cases/fourslash/completionInFunctionLikeBody.ts index 76e1249e760e0..95407b8f01894 100644 --- a/tests/cases/fourslash/completionInFunctionLikeBody.ts +++ b/tests/cases/fourslash/completionInFunctionLikeBody.ts @@ -12,35 +12,12 @@ //// } //// /*4*/ //// } - - -goTo.marker("1"); -verify.completionListContains("async", "async", /*documentation*/ undefined, "keyword"); -verify.not.completionListContains("public", "public", /*documentation*/ undefined, "keyword"); -verify.not.completionListContains("private", "private", /*documentation*/ undefined, "keyword"); -verify.not.completionListContains("protected", "protected", /*documentation*/ undefined, "keyword"); -verify.not.completionListContains("constructor", "constructor", /*documentation*/ undefined, "keyword"); -verify.not.completionListContains("readonly", "readonly", /*documentation*/ undefined, "keyword"); -verify.not.completionListContains("static", "static", /*documentation*/ undefined, "keyword"); -verify.not.completionListContains("abstract", "abstract", /*documentation*/ undefined, "keyword"); -verify.not.completionListContains("get", "get", /*documentation*/ undefined, "keyword"); -verify.not.completionListContains("set", "set", /*documentation*/ undefined, "keyword"); - -goTo.marker("2"); -verify.completionListContains("async", "async", /*documentation*/ undefined, "keyword"); -verify.not.completionListContains("public", "public", /*documentation*/ undefined, "keyword"); -verify.not.completionListContains("private", "private", /*documentation*/ undefined, "keyword"); -verify.not.completionListContains("protected", "protected", /*documentation*/ undefined, "keyword"); -verify.not.completionListContains("constructor", "constructor", /*documentation*/ undefined, "keyword"); -verify.not.completionListContains("readonly", "readonly", /*documentation*/ undefined, "keyword"); -verify.not.completionListContains("static", "static", /*documentation*/ undefined, "keyword"); -verify.not.completionListContains("abstract", "abstract", /*documentation*/ undefined, "keyword"); -verify.not.completionListContains("get", "get", /*documentation*/ undefined, "keyword"); -verify.not.completionListContains("set", "set", /*documentation*/ undefined, "keyword"); - -goTo.marker("3"); -verify.completionListContainsClassElementKeywords(); - -goTo.marker("4"); -verify.completionListContainsClassElementKeywords(); +verify.completions( + { + marker: ["1", "2"], + includes: "async", + excludes: ["public", "private", "protected", "constructor", "readonly", "static", "abstract", "get", "set"], + }, + { marker: ["3", "4"], exact: completion.classElementKeywords, isNewIdentifierLocation: true }, +); diff --git a/tests/cases/fourslash/completionInIncompleteCallExpression.ts b/tests/cases/fourslash/completionInIncompleteCallExpression.ts index eda8cf14378e0..eb24d0abce699 100644 --- a/tests/cases/fourslash/completionInIncompleteCallExpression.ts +++ b/tests/cases/fourslash/completionInIncompleteCallExpression.ts @@ -3,7 +3,5 @@ ////var array = [1, 2, 4] ////function a4(x, y, z) { } ////a4(.../**/ - -goTo.marker(); -verify.not.completionListIsEmpty(); \ No newline at end of file +verify.completions({ marker: "", exact: completion.globalsPlus(["a4", "array"]) }); diff --git a/tests/cases/fourslash/completionInJSDocFunctionNew.ts b/tests/cases/fourslash/completionInJSDocFunctionNew.ts index 2d2b47bad3f93..8cf8502aa201b 100644 --- a/tests/cases/fourslash/completionInJSDocFunctionNew.ts +++ b/tests/cases/fourslash/completionInJSDocFunctionNew.ts @@ -5,5 +5,4 @@ /////** @type {function (new: string, string): string} */ ////var f = function () { return new/**/; } -goTo.marker(); -verify.completionListContains('new'); +verify.completions({ marker: "", includes: "new" }); diff --git a/tests/cases/fourslash/completionInJSDocFunctionThis.ts b/tests/cases/fourslash/completionInJSDocFunctionThis.ts index 2eedbc8e06286..4f732fdcec1fd 100644 --- a/tests/cases/fourslash/completionInJSDocFunctionThis.ts +++ b/tests/cases/fourslash/completionInJSDocFunctionThis.ts @@ -4,5 +4,4 @@ /////** @type {function (this: string, string): string} */ ////var f = function (s) { return this/**/; } -goTo.marker(); -verify.completionListContains('this') +verify.completions({ marker: "", includes: "this" }); diff --git a/tests/cases/fourslash/completionInJsDoc.ts b/tests/cases/fourslash/completionInJsDoc.ts index 1a9170ca9500d..ef438b8f4be75 100644 --- a/tests/cases/fourslash/completionInJsDoc.ts +++ b/tests/cases/fourslash/completionInJsDoc.ts @@ -54,56 +54,10 @@ //// //// /** @param /*16*/ */ -goTo.marker('1'); -verify.completionListContains("constructor"); -verify.completionListContains("param"); -verify.completionListContains("type"); -verify.completionListContains("method"); -verify.completionListContains("template"); - -goTo.marker('2'); -verify.completionListContains("constructor"); -verify.completionListContains("param"); -verify.completionListContains("type"); - -goTo.marker('3'); -verify.completionListIsEmpty(); - -goTo.marker('4'); -verify.completionListContains('number'); - -goTo.marker('5'); -verify.completionListContains('number'); - -goTo.marker('6'); -verify.completionListIsEmpty(); - -goTo.marker('7'); -verify.completionListIsEmpty(); - -goTo.marker('8'); -verify.completionListContains('number'); - -goTo.marker('9'); -verify.completionListContains("@argument"); - -goTo.marker('10'); -verify.completionListContains("@returns"); - -goTo.marker('11'); -verify.completionListContains("@argument"); - -goTo.marker('12'); -verify.completionListContains("@constructor"); - -goTo.marker('13'); -verify.completionListContains("@param"); - -goTo.marker('14'); -verify.completionListIsEmpty(); - -goTo.marker('15'); -verify.completionListIsEmpty(); - -goTo.marker('16'); -verify.completionListIsEmpty(); \ No newline at end of file +verify.completions( + { marker: ["1", "2"], includes: ["constructor", "param", "type", "method", "template"] }, + { marker: ["3", "15", "16"], exact: [] }, + { marker: ["4", "5", "8"], includes: "number" }, + { marker: ["6", "7", "14"], exact: undefined }, + { marker: ["9", "10", "11", "12", "13"], includes: ["@argument", "@returns"] }, +); diff --git a/tests/cases/fourslash/completionInJsDocQualifiedNames.ts b/tests/cases/fourslash/completionInJsDocQualifiedNames.ts index 0de3ad0d21c11..f5ce027f131a7 100644 --- a/tests/cases/fourslash/completionInJsDocQualifiedNames.ts +++ b/tests/cases/fourslash/completionInJsDocQualifiedNames.ts @@ -11,5 +11,4 @@ /////** @type {Foo./**/} */ ////const x = 0; -goTo.marker(); -verify.completionListContains("T", "type T = number", "tee", "type"); +verify.completions({ marker: "", includes: { name: "T", text: "type T = number", documentation: "tee", kind: "type" } }); diff --git a/tests/cases/fourslash/completionInNamedImportLocation.ts b/tests/cases/fourslash/completionInNamedImportLocation.ts index 596de652cc308..85db087f11be4 100644 --- a/tests/cases/fourslash/completionInNamedImportLocation.ts +++ b/tests/cases/fourslash/completionInNamedImportLocation.ts @@ -12,12 +12,7 @@ ////import { x, /*2*/ } from "./file"; goTo.file("a.ts"); -goTo.marker('1'); -verify.completionListContains("x", "var x: number"); -verify.completionListContains("y", "var y: number"); -verify.not.completionListContains("C"); - -goTo.marker('2'); -verify.not.completionListContains("x", "var x: number"); -verify.completionListContains("y", "var y: number"); -verify.not.completionListContains("C"); \ No newline at end of file +verify.completions( + { marker: "1", exact: [{ name: "x", text: "var x: number" }, { name: "y", text: "var y: number" }] }, + { marker: "2", exact: [{ name: "y", text: "var y: number" }] }, +); diff --git a/tests/cases/fourslash/completionInTypeOf1.ts b/tests/cases/fourslash/completionInTypeOf1.ts index 87d267cee2f24..87d7e99e13585 100644 --- a/tests/cases/fourslash/completionInTypeOf1.ts +++ b/tests/cases/fourslash/completionInTypeOf1.ts @@ -5,8 +5,5 @@ ////} ////var x: typeof m1c./*1*/; -goTo.marker('1'); - // No completion because m1c is not an instantiated module. -verify.not.completionListContains('I'); -verify.not.completionListContains('foo'); \ No newline at end of file +verify.completions({ marker: "1", exact: undefined }); diff --git a/tests/cases/fourslash/completionInTypeOf2.ts b/tests/cases/fourslash/completionInTypeOf2.ts index e242c9db0db25..a76b2e853d1f1 100644 --- a/tests/cases/fourslash/completionInTypeOf2.ts +++ b/tests/cases/fourslash/completionInTypeOf2.ts @@ -5,6 +5,4 @@ ////} ////var x: typeof m1c./*1*/; -goTo.marker('1'); -verify.completionListContains('C'); -verify.not.completionListContains('foo'); +verify.completions({ marker: "1", exact: "C" }); diff --git a/tests/cases/fourslash/completionInfoWithExplicitTypeArguments.ts b/tests/cases/fourslash/completionInfoWithExplicitTypeArguments.ts index 6951614298e46..3fc5052fcff86 100644 --- a/tests/cases/fourslash/completionInfoWithExplicitTypeArguments.ts +++ b/tests/cases/fourslash/completionInfoWithExplicitTypeArguments.ts @@ -11,12 +11,4 @@ ////declare function g(x: keyof T, y: number): void; ////g("/*g*/"); -goTo.marker("f"); -verify.completionListCount(2); -verify.completionListContains("x"); -verify.completionListContains("y"); - -goTo.marker("g"); -verify.completionListContains("x"); -verify.completionListContains("y"); -verify.completionListCount(2); +verify.completions({ marker: test.markers(), exact: ["x", "y"] }); diff --git a/tests/cases/fourslash/completionInsideFunctionContainsArguments.ts b/tests/cases/fourslash/completionInsideFunctionContainsArguments.ts index 903253b1a095a..0b0a6c0d52f3c 100644 --- a/tests/cases/fourslash/completionInsideFunctionContainsArguments.ts +++ b/tests/cases/fourslash/completionInsideFunctionContainsArguments.ts @@ -10,13 +10,7 @@ ////} ////let g = () => /*5*/ -goTo.marker('1'); -verify.completionListContains("arguments"); -goTo.marker('2'); -verify.not.completionListContains("arguments"); -goTo.marker('3'); -verify.completionListContains("arguments"); -goTo.marker('4'); -verify.completionListContains("arguments"); -goTo.marker('5'); -verify.not.completionListContains("arguments"); \ No newline at end of file +verify.completions( + { marker: ["1", "3", "4"], includes: "arguments" }, + { marker: ["2", "5"], excludes: "arguments" }, +); diff --git a/tests/cases/fourslash/completionListAfterAnyType.ts b/tests/cases/fourslash/completionListAfterAnyType.ts index f7222675a0f9e..6eebc090e8326 100644 --- a/tests/cases/fourslash/completionListAfterAnyType.ts +++ b/tests/cases/fourslash/completionListAfterAnyType.ts @@ -3,11 +3,9 @@ //// declare class myString { //// charAt(pos: number): string; //// } -//// +//// //// function bar(a: myString) { //// var x: any = a./**/ //// } -goTo.marker(); -verify.completionListContains("charAt"); -verify.completionListCount(1); +verify.completions({ marker: "", exact: "charAt" }); diff --git a/tests/cases/fourslash/completionListAfterClassExtends.ts b/tests/cases/fourslash/completionListAfterClassExtends.ts index 15a3e261768c9..a9892c3eae6f0 100644 --- a/tests/cases/fourslash/completionListAfterClassExtends.ts +++ b/tests/cases/fourslash/completionListAfterClassExtends.ts @@ -10,7 +10,4 @@ ////function Blah(x: Bar.Bleah) { ////} -goTo.marker(); -verify.completionListContains("Bar"); -verify.completionListContains("Bleah"); -verify.completionListContains("Foo"); \ No newline at end of file +verify.completions({ marker: "", includes: ["Bar", "Bleah", "Foo"] }); diff --git a/tests/cases/fourslash/completionListAfterFunction.ts b/tests/cases/fourslash/completionListAfterFunction.ts index 140c5e2e363bb..1898534c9c0ab 100644 --- a/tests/cases/fourslash/completionListAfterFunction.ts +++ b/tests/cases/fourslash/completionListAfterFunction.ts @@ -12,14 +12,9 @@ ////// inside the function ////function f4(d: number) { /*4*/} -goTo.marker("1"); -verify.not.completionListContains("a"); - -goTo.marker("2"); -verify.completionListContains("b"); - -goTo.marker("3"); -verify.not.completionListContains("c"); - -goTo.marker("4"); -verify.completionListContains("d"); +verify.completions( + { marker: "1", excludes: "a" }, + { marker: "2", includes: "b" }, + { marker: "3", excludes: "c" }, + { marker: "4", includes: "d" }, +); diff --git a/tests/cases/fourslash/completionListAfterFunction2.ts b/tests/cases/fourslash/completionListAfterFunction2.ts index 0dfbd4fb461a6..7abd3dc4dabda 100644 --- a/tests/cases/fourslash/completionListAfterFunction2.ts +++ b/tests/cases/fourslash/completionListAfterFunction2.ts @@ -5,10 +5,9 @@ //// ////declare var f1: (b: number, b2: /*2*/) => void; -goTo.marker("1"); -verify.not.completionListContains("a"); - -goTo.marker("2"); -verify.not.completionListContains("b"); +verify.completions( + { marker: "1", excludes: "a" }, + { marker: "2", excludes: "b" }, +); edit.insert("typeof "); -verify.completionListContains("b"); +verify.completions({ includes: "b" }); diff --git a/tests/cases/fourslash/completionListAfterFunction3.ts b/tests/cases/fourslash/completionListAfterFunction3.ts index 575351ea64823..4bc7ae08a89ad 100644 --- a/tests/cases/fourslash/completionListAfterFunction3.ts +++ b/tests/cases/fourslash/completionListAfterFunction3.ts @@ -5,8 +5,7 @@ //// ////var x2 = (b: number) => {/*2*/ }; -goTo.marker("1"); -verify.not.completionListContains("a"); - -goTo.marker("2"); -verify.completionListContains("b"); +verify.completions( + { marker: "1", excludes: "a" }, + { marker: "2", includes: "b" }, +); diff --git a/tests/cases/fourslash/completionListAfterInvalidCharacter.ts b/tests/cases/fourslash/completionListAfterInvalidCharacter.ts index ece28e5e3a0c9..b3f2237561307 100644 --- a/tests/cases/fourslash/completionListAfterInvalidCharacter.ts +++ b/tests/cases/fourslash/completionListAfterInvalidCharacter.ts @@ -4,8 +4,7 @@ ////module testModule { //// export var foo = 1; ////} -////@ +////@ ////testModule./**/ -goTo.marker(); -verify.completionListContains("foo"); +verify.completions({ marker: "", exact: "foo" }); diff --git a/tests/cases/fourslash/completionListAfterNumericLiteral.ts b/tests/cases/fourslash/completionListAfterNumericLiteral.ts index 549c048a63565..4ef879cc48501 100644 --- a/tests/cases/fourslash/completionListAfterNumericLiteral.ts +++ b/tests/cases/fourslash/completionListAfterNumericLiteral.ts @@ -1,43 +1,30 @@ /// // @Filename: f1.ts -////0./*dotOnNumberExrpressions1*/ +////0./*dotOnNumberExpressions1*/ // @Filename: f2.ts -////0.0./*dotOnNumberExrpressions2*/ +////0.0./*dotOnNumberExpressions2*/ // @Filename: f3.ts -////0.0.0./*dotOnNumberExrpressions3*/ +////0.0.0./*dotOnNumberExpressions3*/ // @Filename: f4.ts -////0./** comment *//*dotOnNumberExrpressions4*/ +////0./** comment *//*dotOnNumberExpressions4*/ // @Filename: f5.ts -////(0)./*validDotOnNumberExrpressions1*/ +////(0)./*validDotOnNumberExpressions1*/ // @Filename: f6.ts -////(0.)./*validDotOnNumberExrpressions2*/ +////(0.)./*validDotOnNumberExpressions2*/ // @Filename: f7.ts -////(0.0)./*validDotOnNumberExrpressions3*/ - -goTo.marker("dotOnNumberExrpressions1"); -verify.completionListIsEmpty(); - -goTo.marker("dotOnNumberExrpressions2"); -verify.completionListContains("toExponential"); - -goTo.marker("dotOnNumberExrpressions3"); -verify.completionListContains("toExponential"); - -goTo.marker("dotOnNumberExrpressions4"); -verify.completionListIsEmpty(); - -goTo.marker("validDotOnNumberExrpressions1"); -verify.completionListContains("toExponential"); - -goTo.marker("validDotOnNumberExrpressions2"); -verify.completionListContains("toExponential"); - -goTo.marker("validDotOnNumberExrpressions3"); -verify.completionListContains("toExponential"); +////(0.0)./*validDotOnNumberExpressions3*/ + +verify.completions( + { marker: ["dotOnNumberExpressions1", "dotOnNumberExpressions4"], exact: undefined }, + { + marker: ["dotOnNumberExpressions2", "dotOnNumberExpressions3", "validDotOnNumberExpressions1", "validDotOnNumberExpressions2", "validDotOnNumberExpressions3"], + includes: "toExponential" + }, +); diff --git a/tests/cases/fourslash/completionListAfterNumericLiteral1.ts b/tests/cases/fourslash/completionListAfterNumericLiteral1.ts index cf8b5d41e9820..1541989c9c867 100644 --- a/tests/cases/fourslash/completionListAfterNumericLiteral1.ts +++ b/tests/cases/fourslash/completionListAfterNumericLiteral1.ts @@ -2,5 +2,4 @@ ////5../**/ -goTo.marker(); -verify.completionListContains("toFixed"); \ No newline at end of file +verify.completions({ marker: "", exact: ["toString", "toFixed", "toExponential", "toPrecision", "valueOf", "toLocaleString"] }); diff --git a/tests/cases/fourslash/completionListAfterObjectLiteral1.ts b/tests/cases/fourslash/completionListAfterObjectLiteral1.ts index 7296ce057b45a..1b6d280793321 100644 --- a/tests/cases/fourslash/completionListAfterObjectLiteral1.ts +++ b/tests/cases/fourslash/completionListAfterObjectLiteral1.ts @@ -2,6 +2,4 @@ ////var v = { x: 4, y: 3 }./**/ -goTo.marker(); -verify.not.completionListContains('a'); -verify.completionListContains('x'); \ No newline at end of file +verify.completions({ marker: "", exact: ["x", "y"] }); diff --git a/tests/cases/fourslash/completionListAfterPropertyName.ts b/tests/cases/fourslash/completionListAfterPropertyName.ts index c83b16c97417e..652526f3af73b 100644 --- a/tests/cases/fourslash/completionListAfterPropertyName.ts +++ b/tests/cases/fourslash/completionListAfterPropertyName.ts @@ -70,19 +70,29 @@ //// constructor(public a, /*afterConstructorParameterComma*/ ////} -for (const marker of ["afterPropertyName", - "inMethodParameter", "atMethodParameter", "afterMethodParameter", - "afterMethodParameterBeforeComma", "afterMethodParameterComma", - "afterConstructorParameter", "afterConstructorParameterBeforeComma"]) { - - goTo.marker(marker); - verify.completionListIsEmpty(); -} - -for (const marker of ["inConstructorParameter", "inConstructorParameterAfterModifier", - "atConstructorParameter", "atConstructorParameterModifier", "atConstructorParameterAfterModifier", - "afterConstructorParameterComma"]) { - goTo.marker(marker); - verify.completionListContainsConstructorParameterKeywords(); - verify.completionListCount(verify.allowedConstructorParameterKeywords.length); -} \ No newline at end of file +verify.completions( + { + marker:[ + "afterPropertyName", + "inMethodParameter", + "atMethodParameter", + "afterMethodParameter", + "afterMethodParameterBeforeComma", + "afterMethodParameterComma", + "afterConstructorParameter", + ], + exact: undefined, + }, + { + marker: [ + "inConstructorParameter", + "inConstructorParameterAfterModifier", + "atConstructorParameter", + "atConstructorParameterModifier", + "atConstructorParameterAfterModifier", + "afterConstructorParameterComma", + ], + exact: completion.constructorParameterKeywords, + isNewIdentifierLocation: true, + }, +); diff --git a/tests/cases/fourslash/completionListAfterRegularExpressionLiteral01.ts b/tests/cases/fourslash/completionListAfterRegularExpressionLiteral01.ts index 759a3f9c2a41e..8572229531a9b 100644 --- a/tests/cases/fourslash/completionListAfterRegularExpressionLiteral01.ts +++ b/tests/cases/fourslash/completionListAfterRegularExpressionLiteral01.ts @@ -3,6 +3,4 @@ ////let v = 100; /////a/./**/ -goTo.marker(); -verify.not.completionListContains('v'); -verify.completionListContains('compile'); \ No newline at end of file +verify.completions({ marker: "", exact: ["exec", "test", "source", "global", "ignoreCase", "multiline", "lastIndex", "compile"] }); diff --git a/tests/cases/fourslash/completionListAfterRegularExpressionLiteral02.ts b/tests/cases/fourslash/completionListAfterRegularExpressionLiteral02.ts index 2719d747d5816..e791f6d386a8c 100644 --- a/tests/cases/fourslash/completionListAfterRegularExpressionLiteral02.ts +++ b/tests/cases/fourslash/completionListAfterRegularExpressionLiteral02.ts @@ -5,6 +5,4 @@ // Should get nothing at the marker since it's // going to be considered part of the regex flags. - -goTo.marker(); -verify.completionListIsEmpty(); \ No newline at end of file +verify.completions({ marker: "", exact: undefined }); diff --git a/tests/cases/fourslash/completionListAfterRegularExpressionLiteral03.ts b/tests/cases/fourslash/completionListAfterRegularExpressionLiteral03.ts index 7c0e4d5144674..2e6c5f7c86f32 100644 --- a/tests/cases/fourslash/completionListAfterRegularExpressionLiteral03.ts +++ b/tests/cases/fourslash/completionListAfterRegularExpressionLiteral03.ts @@ -7,5 +7,4 @@ // Should not be blocked since there is a // newline separating us from the regex flags. -goTo.marker(); -verify.completionListContains("v"); \ No newline at end of file +verify.completions({ marker: "", includes: "v" }); diff --git a/tests/cases/fourslash/completionListAfterRegularExpressionLiteral04.ts b/tests/cases/fourslash/completionListAfterRegularExpressionLiteral04.ts index 06f31b8175b89..877ae3b62aa70 100644 --- a/tests/cases/fourslash/completionListAfterRegularExpressionLiteral04.ts +++ b/tests/cases/fourslash/completionListAfterRegularExpressionLiteral04.ts @@ -6,5 +6,4 @@ // Should not be blocked since there is a // space separating us from the regex flags. -goTo.marker(); -verify.completionListContains("v"); \ No newline at end of file +verify.completions({ marker: "", includes: "v" }); diff --git a/tests/cases/fourslash/completionListAfterRegularExpressionLiteral05.ts b/tests/cases/fourslash/completionListAfterRegularExpressionLiteral05.ts index 7ac0d1cd71c29..4032912481aa0 100644 --- a/tests/cases/fourslash/completionListAfterRegularExpressionLiteral05.ts +++ b/tests/cases/fourslash/completionListAfterRegularExpressionLiteral05.ts @@ -5,6 +5,4 @@ // Should get nothing at the marker since it's // going to be considered part of the regex flags. - -goTo.marker(); -verify.completionListIsEmpty() \ No newline at end of file +verify.completions({ marker: "", exact: undefined }); diff --git a/tests/cases/fourslash/completionListAfterRegularExpressionLiteral1.ts b/tests/cases/fourslash/completionListAfterRegularExpressionLiteral1.ts index 465c676c7140d..22fdf36adbbf8 100644 --- a/tests/cases/fourslash/completionListAfterRegularExpressionLiteral1.ts +++ b/tests/cases/fourslash/completionListAfterRegularExpressionLiteral1.ts @@ -2,6 +2,4 @@ /////a/./**/ -goTo.marker(); -verify.not.completionListContains('alert'); -verify.completionListContains('compile'); \ No newline at end of file +verify.completions({ marker: "", exact: ["exec", "test", "source", "global", "ignoreCase", "multiline", "lastIndex", "compile"] }); diff --git a/tests/cases/fourslash/completionListAfterSlash.ts b/tests/cases/fourslash/completionListAfterSlash.ts index f9a0b69afdfe1..b1ae2330b7bbe 100644 --- a/tests/cases/fourslash/completionListAfterSlash.ts +++ b/tests/cases/fourslash/completionListAfterSlash.ts @@ -3,6 +3,5 @@ ////var a = 0; ////a/./**/ -goTo.marker(); // should not crash -verify.completionListIsEmpty(); +verify.completions({ marker: "", exact: undefined }); diff --git a/tests/cases/fourslash/completionListAfterSpreadOperator01.ts b/tests/cases/fourslash/completionListAfterSpreadOperator01.ts index 48a50124daf3d..903953d509677 100644 --- a/tests/cases/fourslash/completionListAfterSpreadOperator01.ts +++ b/tests/cases/fourslash/completionListAfterSpreadOperator01.ts @@ -3,5 +3,4 @@ ////let v = [1,2,3,4]; ////let x = [.../**/ -goTo.marker(); -verify.completionListContains("v"); \ No newline at end of file +verify.completions({ marker: "", includes: "v" }); diff --git a/tests/cases/fourslash/completionListAfterStringLiteralTypeWithNoSubstitutionTemplateLiteral.ts b/tests/cases/fourslash/completionListAfterStringLiteralTypeWithNoSubstitutionTemplateLiteral.ts index c5deac5123e40..d44b1d04bbeb9 100644 --- a/tests/cases/fourslash/completionListAfterStringLiteralTypeWithNoSubstitutionTemplateLiteral.ts +++ b/tests/cases/fourslash/completionListAfterStringLiteralTypeWithNoSubstitutionTemplateLiteral.ts @@ -3,6 +3,4 @@ ////let count: 'one' | 'two'; ////count = `/**/` -goTo.marker(); -verify.completionListContains('one'); -verify.completionListContains('two'); +verify.completions({ marker: "", exact: ["one", "two"] }); diff --git a/tests/cases/fourslash/completionListAndMemberListOnCommentedDot.ts b/tests/cases/fourslash/completionListAndMemberListOnCommentedDot.ts index b57e7b84b5354..e742c722d3ef6 100644 --- a/tests/cases/fourslash/completionListAndMemberListOnCommentedDot.ts +++ b/tests/cases/fourslash/completionListAndMemberListOnCommentedDot.ts @@ -13,5 +13,4 @@ //////Test for comment //////c./**/ -goTo.marker(); -verify.completionListIsEmpty(); \ No newline at end of file +verify.completions({ marker: "", exact: undefined }); diff --git a/tests/cases/fourslash/completionListAndMemberListOnCommentedLine.ts b/tests/cases/fourslash/completionListAndMemberListOnCommentedLine.ts index 96eac09b6fff1..7d1543d3e65c4 100644 --- a/tests/cases/fourslash/completionListAndMemberListOnCommentedLine.ts +++ b/tests/cases/fourslash/completionListAndMemberListOnCommentedLine.ts @@ -3,5 +3,4 @@ ////// /**/ ////var -goTo.marker(); -verify.completionListIsEmpty(); \ No newline at end of file +verify.completions({ marker: "", exact: undefined }); diff --git a/tests/cases/fourslash/completionListAndMemberListOnCommentedWhiteSpace.ts b/tests/cases/fourslash/completionListAndMemberListOnCommentedWhiteSpace.ts index a40c68e8b1596..715897abd1575 100644 --- a/tests/cases/fourslash/completionListAndMemberListOnCommentedWhiteSpace.ts +++ b/tests/cases/fourslash/completionListAndMemberListOnCommentedWhiteSpace.ts @@ -13,6 +13,4 @@ //////Test for comment //////c. /**/ -goTo.marker(); -verify.completionListIsEmpty(); -verify.completionListIsEmpty(); \ No newline at end of file +verify.completions({ marker: "", exact: undefined }); diff --git a/tests/cases/fourslash/completionListAtBeginningOfFile01.ts b/tests/cases/fourslash/completionListAtBeginningOfFile01.ts index f811fec4c6710..f6e0676d9769f 100644 --- a/tests/cases/fourslash/completionListAtBeginningOfFile01.ts +++ b/tests/cases/fourslash/completionListAtBeginningOfFile01.ts @@ -6,8 +6,4 @@ //// A, B, C ////} -goTo.marker("1"); -verify.completionListContains("x"); -verify.completionListContains("y"); -verify.completionListContains("z"); -verify.completionListContains("E"); \ No newline at end of file +verify.completions({ marker: "1", includes: ["x", "y", "z", "E"] }); diff --git a/tests/cases/fourslash/completionListAtBeginningOfIdentifierInArrowFunction01.ts b/tests/cases/fourslash/completionListAtBeginningOfIdentifierInArrowFunction01.ts index 0562a5a4bd3eb..ebcbfc754f48f 100644 --- a/tests/cases/fourslash/completionListAtBeginningOfIdentifierInArrowFunction01.ts +++ b/tests/cases/fourslash/completionListAtBeginningOfIdentifierInArrowFunction01.ts @@ -2,5 +2,4 @@ ////xyz => /*1*/x -goTo.marker("1"); -verify.completionListContains("xyz"); \ No newline at end of file +verify.completions({ marker: "1", includes: "xyz" }); diff --git a/tests/cases/fourslash/completionListAtDeclarationOfParameterType.ts b/tests/cases/fourslash/completionListAtDeclarationOfParameterType.ts index 94de51cc9a345..708bd9fcd6464 100644 --- a/tests/cases/fourslash/completionListAtDeclarationOfParameterType.ts +++ b/tests/cases/fourslash/completionListAtDeclarationOfParameterType.ts @@ -10,5 +10,4 @@ ////function Blah(x: /**/Bar.Bleah) { ////} -goTo.marker(); -verify.completionListContains("Bar"); \ No newline at end of file +verify.completions({ marker: "", includes: "Bar" }); diff --git a/tests/cases/fourslash/completionListAtEOF.ts b/tests/cases/fourslash/completionListAtEOF.ts index e1b210281cbbd..6871d9061763d 100644 --- a/tests/cases/fourslash/completionListAtEOF.ts +++ b/tests/cases/fourslash/completionListAtEOF.ts @@ -3,10 +3,10 @@ ////var a; goTo.eof(); -verify.completionListContains("a"); +verify.completions({ includes: "a" }); edit.insertLine(""); -verify.completionListContains("a"); +verify.completions({ includes: "a" }); edit.insertLine(""); -verify.completionListContains("a"); +verify.completions({ includes: "a" }); diff --git a/tests/cases/fourslash/completionListAtEOF1.ts b/tests/cases/fourslash/completionListAtEOF1.ts index 3a7cfe953162a..693ad936eb2c5 100644 --- a/tests/cases/fourslash/completionListAtEOF1.ts +++ b/tests/cases/fourslash/completionListAtEOF1.ts @@ -3,4 +3,4 @@ //// if(0 === ''. goTo.eof(); -verify.completionListContains("charAt"); +verify.completions({ includes: "charAt" }); diff --git a/tests/cases/fourslash/completionListAtEOF2.ts b/tests/cases/fourslash/completionListAtEOF2.ts index 8ba6a9d8e650b..01f05b3b61f5a 100644 --- a/tests/cases/fourslash/completionListAtEOF2.ts +++ b/tests/cases/fourslash/completionListAtEOF2.ts @@ -8,4 +8,4 @@ ////var p = x/*1*/ -goTo.marker("1"); -verify.completionListContains("xyz"); \ No newline at end of file +verify.completions({ marker: "1", includes: "xyz" }); diff --git a/tests/cases/fourslash/completionListAtEndOfWordInArrowFunction02.ts b/tests/cases/fourslash/completionListAtEndOfWordInArrowFunction02.ts index 32a11f9b15148..73cd0c29be97f 100644 --- a/tests/cases/fourslash/completionListAtEndOfWordInArrowFunction02.ts +++ b/tests/cases/fourslash/completionListAtEndOfWordInArrowFunction02.ts @@ -2,9 +2,8 @@ ////(d, defaultIsAnInvalidParameterName) => d/*1*/ -goTo.marker("1"); -verify.completionListContains("d"); -verify.completionListContains("defaultIsAnInvalidParameterName"); - -// This should probably stop working in the future. -verify.completionListContains("default", "default", /*documentation*/ undefined, "keyword"); \ No newline at end of file +verify.completions({ + marker: "1", + // TODO: should not include 'default' keyword at an expression location + includes: ["d", "defaultIsAnInvalidParameterName", "default"] +}); diff --git a/tests/cases/fourslash/completionListAtEndOfWordInArrowFunction03.ts b/tests/cases/fourslash/completionListAtEndOfWordInArrowFunction03.ts index 15acdc2045686..0487107d3afee 100644 --- a/tests/cases/fourslash/completionListAtEndOfWordInArrowFunction03.ts +++ b/tests/cases/fourslash/completionListAtEndOfWordInArrowFunction03.ts @@ -2,8 +2,11 @@ ////(d, defaultIsAnInvalidParameterName) => default/*1*/ -goTo.marker("1"); -verify.completionListContains("defaultIsAnInvalidParameterName"); - -// This should probably stop working in the future. -verify.completionListContains("default", "default", /*documentation*/ undefined, "keyword"); \ No newline at end of file +verify.completions({ + marker: "1", + includes: [ + "defaultIsAnInvalidParameterName", + // This should probably stop working in the future. + { name: "default", text: "default", kind: "keyword" }, + ], +}); diff --git a/tests/cases/fourslash/completionListAtIdentifierDefinitionLocations_Generics.ts b/tests/cases/fourslash/completionListAtIdentifierDefinitionLocations_Generics.ts index 784fc8c499c52..fce92a33fc849 100644 --- a/tests/cases/fourslash/completionListAtIdentifierDefinitionLocations_Generics.ts +++ b/tests/cases/fourslash/completionListAtIdentifierDefinitionLocations_Generics.ts @@ -11,4 +11,4 @@ ////function A verify.completionListIsEmpty()); +verify.completions({ marker: test.markers(), exact: undefined }); diff --git a/tests/cases/fourslash/completionListAtIdentifierDefinitionLocations_catch.ts b/tests/cases/fourslash/completionListAtIdentifierDefinitionLocations_catch.ts index bfbfa1bb16093..4a7b35f840c2d 100644 --- a/tests/cases/fourslash/completionListAtIdentifierDefinitionLocations_catch.ts +++ b/tests/cases/fourslash/completionListAtIdentifierDefinitionLocations_catch.ts @@ -6,4 +6,4 @@ //// try {} catch(a/*catchVariable2*/ -goTo.eachMarker(() => verify.completionListIsEmpty()); +verify.completions({ marker: test.markers(), exact: undefined }); diff --git a/tests/cases/fourslash/completionListAtIdentifierDefinitionLocations_classes.ts b/tests/cases/fourslash/completionListAtIdentifierDefinitionLocations_classes.ts index 5d96c56571951..189c475aa2048 100644 --- a/tests/cases/fourslash/completionListAtIdentifierDefinitionLocations_classes.ts +++ b/tests/cases/fourslash/completionListAtIdentifierDefinitionLocations_classes.ts @@ -6,4 +6,4 @@ ////class a/*className2*/ -goTo.eachMarker(() => verify.completionListIsEmpty()); +verify.completions({ marker: test.markers(), exact: undefined }); diff --git a/tests/cases/fourslash/completionListAtIdentifierDefinitionLocations_destructuring.ts b/tests/cases/fourslash/completionListAtIdentifierDefinitionLocations_destructuring.ts index d2ecdf2942613..27c7f9a4dae21 100644 --- a/tests/cases/fourslash/completionListAtIdentifierDefinitionLocations_destructuring.ts +++ b/tests/cases/fourslash/completionListAtIdentifierDefinitionLocations_destructuring.ts @@ -16,4 +16,4 @@ //// function func2({ a, b/*parameter2*/ -goTo.eachMarker(() => verify.completionListIsEmpty()); +verify.completions({ marker: test.markers(), exact: undefined }); diff --git a/tests/cases/fourslash/completionListAtIdentifierDefinitionLocations_enumMembers.ts b/tests/cases/fourslash/completionListAtIdentifierDefinitionLocations_enumMembers.ts index f08181083018c..fc4b9b4441723 100644 --- a/tests/cases/fourslash/completionListAtIdentifierDefinitionLocations_enumMembers.ts +++ b/tests/cases/fourslash/completionListAtIdentifierDefinitionLocations_enumMembers.ts @@ -4,4 +4,4 @@ ////enum a { /*enumValueName1*/ -goTo.eachMarker(() => verify.completionListIsEmpty()); +verify.completions({ marker: test.markers(), exact: undefined }); diff --git a/tests/cases/fourslash/completionListAtIdentifierDefinitionLocations_enumMembers2.ts b/tests/cases/fourslash/completionListAtIdentifierDefinitionLocations_enumMembers2.ts index 11aa276bb5aa9..56ba378043e74 100644 --- a/tests/cases/fourslash/completionListAtIdentifierDefinitionLocations_enumMembers2.ts +++ b/tests/cases/fourslash/completionListAtIdentifierDefinitionLocations_enumMembers2.ts @@ -3,4 +3,4 @@ ////var aa = 1; ////enum a { foo, /*enumValueName3*/ -goTo.eachMarker(() => verify.completionListIsEmpty()); +verify.completions({ marker: test.markers(), exact: undefined }); diff --git a/tests/cases/fourslash/completionListAtIdentifierDefinitionLocations_enums.ts b/tests/cases/fourslash/completionListAtIdentifierDefinitionLocations_enums.ts index c740218e27ea5..e17e37a6a7eda 100644 --- a/tests/cases/fourslash/completionListAtIdentifierDefinitionLocations_enums.ts +++ b/tests/cases/fourslash/completionListAtIdentifierDefinitionLocations_enums.ts @@ -8,4 +8,4 @@ ////var x = 0; enum /*enumName4*/ -goTo.eachMarker(() => verify.completionListIsEmpty()); +verify.completions({ marker: test.markers(), exact: undefined }); diff --git a/tests/cases/fourslash/completionListAtIdentifierDefinitionLocations_functions.ts b/tests/cases/fourslash/completionListAtIdentifierDefinitionLocations_functions.ts index 2f55f9527bcd6..14e5b6a55de89 100644 --- a/tests/cases/fourslash/completionListAtIdentifierDefinitionLocations_functions.ts +++ b/tests/cases/fourslash/completionListAtIdentifierDefinitionLocations_functions.ts @@ -6,4 +6,4 @@ ////function a/*functionName2*/ -goTo.eachMarker(() => verify.completionListIsEmpty()); +verify.completions({ marker: test.markers(), exact: undefined }); diff --git a/tests/cases/fourslash/completionListAtIdentifierDefinitionLocations_interfaces.ts b/tests/cases/fourslash/completionListAtIdentifierDefinitionLocations_interfaces.ts index d4be268eb7de4..bff0e4dd0881f 100644 --- a/tests/cases/fourslash/completionListAtIdentifierDefinitionLocations_interfaces.ts +++ b/tests/cases/fourslash/completionListAtIdentifierDefinitionLocations_interfaces.ts @@ -6,4 +6,4 @@ ////interface a/*interfaceName2*/ -goTo.eachMarker(() => verify.completionListIsEmpty()); +verify.completions({ marker: test.markers(), exact: undefined }); diff --git a/tests/cases/fourslash/completionListAtIdentifierDefinitionLocations_parameters.ts b/tests/cases/fourslash/completionListAtIdentifierDefinitionLocations_parameters.ts index c59b08dd70ae0..d69645a55c96e 100644 --- a/tests/cases/fourslash/completionListAtIdentifierDefinitionLocations_parameters.ts +++ b/tests/cases/fourslash/completionListAtIdentifierDefinitionLocations_parameters.ts @@ -10,30 +10,31 @@ ////function testFunction(a, b/*parameterName4*/ -////class bar5{ constructor(public /*constructorParamter1*/ - -////class bar6{ constructor(public a/*constructorParamter2*/ - -////class bar7{ constructor(protected a/*constructorParamter3*/ - -////class bar8{ constructor(private a/*constructorParamter4*/ - -////class bar9{ constructor(.../*constructorParamter5*/ - -////class bar10{ constructor(...a/*constructorParamter6*/ - -for (let i = 1; i <= 4; i++) { - goTo.marker("parameterName" + i.toString()); - verify.completionListIsEmpty(); -} - -for (let i = 1; i <= 4; i++) { - goTo.marker("constructorParamter" + i.toString()); - verify.completionListContainsConstructorParameterKeywords(); - verify.completionListCount(verify.allowedConstructorParameterKeywords.length); -} - -for (let i = 5; i <= 6; i++) { - goTo.marker("constructorParamter" + i.toString()); - verify.completionListIsEmpty(); -} +////class bar5{ constructor(public /*constructorParameter1*/ + +////class bar6{ constructor(public a/*constructorParameter2*/ + +////class bar7{ constructor(protected a/*constructorParameter3*/ + +////class bar8{ constructor(private a/*constructorParameter4*/ + +////class bar9{ constructor(.../*constructorParameter5*/ + +////class bar10{ constructor(...a/*constructorParameter6*/ + +verify.completions( + { + marker: [1,2,3,4].map(i => `parameterName${i}`), + exact: undefined, + }, + { + marker: [1,2,3,4].map(i => `constructorParameter${i}`), + exact: completion.constructorParameterKeywords, + isNewIdentifierLocation: true, + }, + { + marker: [5, 6].map(i => `constructorParameter${i}`), + exact: undefined, + isNewIdentifierLocation: true, + }, +); diff --git a/tests/cases/fourslash/completionListAtIdentifierDefinitionLocations_properties.ts b/tests/cases/fourslash/completionListAtIdentifierDefinitionLocations_properties.ts index 3ba0df0c31dae..dd57b22a9d60e 100644 --- a/tests/cases/fourslash/completionListAtIdentifierDefinitionLocations_properties.ts +++ b/tests/cases/fourslash/completionListAtIdentifierDefinitionLocations_properties.ts @@ -30,7 +30,4 @@ //// private a/*property7*/ ////} -goTo.eachMarker(() => { - verify.not.completionListIsEmpty(); - verify.completionListAllowsNewIdentifier(); -}); \ No newline at end of file +verify.completions({ marker: test.markers(), exact: completion.classElementKeywords, isNewIdentifierLocation: true }); diff --git a/tests/cases/fourslash/completionListAtIdentifierDefinitionLocations_varDeclarations.ts b/tests/cases/fourslash/completionListAtIdentifierDefinitionLocations_varDeclarations.ts index 9a2c9ba664a2e..fb49509b24848 100644 --- a/tests/cases/fourslash/completionListAtIdentifierDefinitionLocations_varDeclarations.ts +++ b/tests/cases/fourslash/completionListAtIdentifierDefinitionLocations_varDeclarations.ts @@ -11,4 +11,4 @@ ////var a2, a/*varName4*/ -goTo.eachMarker(() => verify.completionListIsEmpty()); +verify.completions({ marker: test.markers(), exact: undefined }); diff --git a/tests/cases/fourslash/completionListAtInvalidLocations.ts b/tests/cases/fourslash/completionListAtInvalidLocations.ts index 171f63825f226..0185807a7e9bb 100644 --- a/tests/cases/fourslash/completionListAtInvalidLocations.ts +++ b/tests/cases/fourslash/completionListAtInvalidLocations.ts @@ -21,4 +21,7 @@ //// foo; //// var v10 = /reg/*inRegExp1*/ex/; -goTo.eachMarker(() => verify.completionListIsEmpty()); +verify.completions( + { marker: ["openString1", "openString2", "openString3"], exact: [] }, + { marker: ["inComment1", "inComment2", "inComment3", "inComment4", "inTypeAlias", "inComment5", "inRegExp1"], exact: undefined }, +); diff --git a/tests/cases/fourslash/completionListAtNodeBoundry.ts b/tests/cases/fourslash/completionListAtNodeBoundary.ts similarity index 85% rename from tests/cases/fourslash/completionListAtNodeBoundry.ts rename to tests/cases/fourslash/completionListAtNodeBoundary.ts index 40c151e0ef4dc..5d321399c93a3 100644 --- a/tests/cases/fourslash/completionListAtNodeBoundry.ts +++ b/tests/cases/fourslash/completionListAtNodeBoundary.ts @@ -17,6 +17,4 @@ ////var a: string[]; ////var e = a.map(x => x./**/); - -goTo.marker(); -verify.completionListContains("charAt"); +verify.completions({ marker: "", includes: "charAt" }); diff --git a/tests/cases/fourslash/completionListBeforeKeyword.ts b/tests/cases/fourslash/completionListBeforeKeyword.ts index 01efe29764aa6..d52a311759b06 100644 --- a/tests/cases/fourslash/completionListBeforeKeyword.ts +++ b/tests/cases/fourslash/completionListBeforeKeyword.ts @@ -16,11 +16,4 @@ //// export class Test3 {} ////} - -goTo.marker("TypeReference"); -verify.completionListContains("C1"); -verify.completionListContains("C2"); - -goTo.marker("ValueReference"); -verify.completionListContains("C1"); -verify.completionListContains("C2"); \ No newline at end of file +verify.completions({ marker: test.markers(), exact: ["C1", "C2"] }); diff --git a/tests/cases/fourslash/completionListBeforeNewScope01.ts b/tests/cases/fourslash/completionListBeforeNewScope01.ts index 79159744b8103..4da7b6d9a4148 100644 --- a/tests/cases/fourslash/completionListBeforeNewScope01.ts +++ b/tests/cases/fourslash/completionListBeforeNewScope01.ts @@ -6,6 +6,4 @@ //// let party = Math.random() < 0.99; ////} -goTo.marker("1"); -verify.not.completionListContains("param"); -verify.not.completionListContains("party"); \ No newline at end of file +verify.completions({ marker: "1", excludes: ["param", "party"] }); diff --git a/tests/cases/fourslash/completionListBeforeNewScope02.ts b/tests/cases/fourslash/completionListBeforeNewScope02.ts index 9fb1182b56e0a..4eccb6a10a97c 100644 --- a/tests/cases/fourslash/completionListBeforeNewScope02.ts +++ b/tests/cases/fourslash/completionListBeforeNewScope02.ts @@ -6,5 +6,4 @@ //// let aaaaaa = 10; ////} -goTo.marker("1"); -verify.not.completionListContains("aaaaa"); \ No newline at end of file +verify.completions({ marker: "1", excludes: "aaaaaa" }); diff --git a/tests/cases/fourslash/completionListBuilderLocations_Modules.ts b/tests/cases/fourslash/completionListBuilderLocations_Modules.ts index 0552e540a7e8c..a98d65e255d06 100644 --- a/tests/cases/fourslash/completionListBuilderLocations_Modules.ts +++ b/tests/cases/fourslash/completionListBuilderLocations_Modules.ts @@ -5,8 +5,7 @@ ////module A./*moduleName2*/ -goTo.marker("moduleName1"); -verify.not.completionListIsEmpty(); - -goTo.marker("moduleName2"); -verify.completionListIsEmpty(); +verify.completions( + { marker: "moduleName1", exact: completion.globals, isNewIdentifierLocation: true }, + { marker: "moduleName2", exact: undefined }, +); diff --git a/tests/cases/fourslash/completionListBuilderLocations_VariableDeclarations.ts b/tests/cases/fourslash/completionListBuilderLocations_VariableDeclarations.ts index 2562b84099507..af119f40be57f 100644 --- a/tests/cases/fourslash/completionListBuilderLocations_VariableDeclarations.ts +++ b/tests/cases/fourslash/completionListBuilderLocations_VariableDeclarations.ts @@ -11,7 +11,7 @@ //// var y : any = "", x = (a/*var5*/ ////class C{} -////var y = new C( +////var y = new C(/*var6*/ //// class C{} //// var y = new C(0, /*var7*/ @@ -26,4 +26,8 @@ ////var y = 10; y=/*var12*/ -goTo.eachMarker(() => verify.completionListAllowsNewIdentifier()); +verify.completions({ + marker: test.markers(), + exact: completion.globalsPlus(["x", "y", "C"]), + isNewIdentifierLocation: true +}); diff --git a/tests/cases/fourslash/completionListBuilderLocations_parameters.ts b/tests/cases/fourslash/completionListBuilderLocations_parameters.ts index 607ca0d9819aa..09d8d8956e9d1 100644 --- a/tests/cases/fourslash/completionListBuilderLocations_parameters.ts +++ b/tests/cases/fourslash/completionListBuilderLocations_parameters.ts @@ -2,19 +2,20 @@ ////var aa = 1; -////class bar1{ constructor(/*constructorParamter1*/ +////class bar1{ constructor(/*1*/ -////class bar2{ constructor(a/*constructorParamter2*/ +////class bar2{ constructor(a/*2*/ -////class bar3{ constructor(a, /*constructorParamter3*/ +////class bar3{ constructor(a, /*3*/ -////class bar4{ constructor(a, b/*constructorParamter4*/ +////class bar4{ constructor(a, b/*4*/ -////class bar6{ constructor(public a, /*constructorParamter5*/ +////class bar6{ constructor(public a, /*5*/ -////class bar7{ constructor(private a, /*constructorParamter6*/ +////class bar7{ constructor(private a, /*6*/ -goTo.eachMarker(() => { - verify.not.completionListIsEmpty(); - verify.completionListAllowsNewIdentifier(); -}); \ No newline at end of file +verify.completions({ + marker: test.markers(), + exact: completion.constructorParameterKeywords, + isNewIdentifierLocation: true +}); diff --git a/tests/cases/fourslash/completionListBuilderLocations_properties.ts b/tests/cases/fourslash/completionListBuilderLocations_properties.ts index 2cdc3b7e7baa7..d0ba2198c8aa6 100644 --- a/tests/cases/fourslash/completionListBuilderLocations_properties.ts +++ b/tests/cases/fourslash/completionListBuilderLocations_properties.ts @@ -10,4 +10,4 @@ //// public static a/*property2*/ ////} -goTo.eachMarker(() => verify.completionListContainsClassElementKeywords()); +verify.completions({ marker: test.markers(), exact: completion.classElementKeywords, isNewIdentifierLocation: true }); diff --git a/tests/cases/fourslash/completionListCladule.ts b/tests/cases/fourslash/completionListCladule.ts index 6d9e9145b66bc..1040446f4d0a4 100644 --- a/tests/cases/fourslash/completionListCladule.ts +++ b/tests/cases/fourslash/completionListCladule.ts @@ -14,15 +14,12 @@ goTo.marker("c1"); edit.insert("."); -verify.completionListContains("x"); -verify.completionListContains("prototype"); -verify.completionListContains("staticMethod"); +verify.completions({ includes: ["x", "prototype", "staticMethod"] }); goTo.marker("c2"); edit.insert("."); -verify.completionListIsEmpty(); +verify.completions({ exact: undefined }); goTo.marker("c3"); edit.insert("."); -verify.completionListContains("doStuff"); -verify.completionListCount(1); +verify.completions({ exact: "doStuff" }); diff --git a/tests/cases/fourslash/completionListClassMembers.ts b/tests/cases/fourslash/completionListClassMembers.ts index 2bf65cc7c0c37..6a51ce7e71db6 100644 --- a/tests/cases/fourslash/completionListClassMembers.ts +++ b/tests/cases/fourslash/completionListClassMembers.ts @@ -23,48 +23,21 @@ ////var c = new Class(); ////c./*instanceMembersOutsideClassScope*/privateProperty; - -goTo.marker("staticsInsideClassScope"); -verify.completionListContains("privateStaticProperty"); -verify.completionListContains("privateStaticMethod"); -verify.completionListContains("publicStaticProperty"); -verify.completionListContains("publicStaticMethod"); -// No instance properties -verify.not.completionListContains("privateProperty"); -verify.not.completionListContains("privateInstanceMethod"); -// constructors should have a 'prototype' member -verify.completionListContains("prototype"); - -goTo.marker("instanceMembersInsideClassScope"); -verify.completionListContains("privateProperty"); -verify.completionListContains("privateInstanceMethod"); -verify.completionListContains("publicProperty"); -verify.completionListContains("publicInstanceMethod"); -// No statics -verify.not.completionListContains("privateStaticProperty"); -verify.not.completionListContains("privateStaticMethod"); - - -goTo.marker("staticsOutsideClassScope"); -// No privates -verify.not.completionListContains("privateStaticProperty"); -verify.not.completionListContains("privateStaticMethod"); -// Only publics -verify.completionListContains("publicStaticProperty"); -verify.completionListContains("publicStaticMethod"); -// No instance properties -verify.not.completionListContains("publicProperty"); -verify.not.completionListContains("publicInstanceMethod"); -// constructors should have a 'prototype' member -verify.completionListContains("prototype"); - -goTo.marker("instanceMembersOutsideClassScope"); -// No privates -verify.not.completionListContains("privateProperty"); -verify.not.completionListContains("privateInstanceMethod"); -// Only publics -verify.completionListContains("publicProperty"); -verify.completionListContains("publicInstanceMethod"); -// No statics -verify.not.completionListContains("publicStaticProperty"); -verify.not.completionListContains("publicStaticMethod"); \ No newline at end of file +verify.completions( + { + marker: "staticsInsideClassScope", + exact: ["prototype", "privateStaticProperty", "publicStaticProperty", "privateStaticMethod", "publicStaticMethod", ...completion.functionMembers], + }, + { + marker: "instanceMembersInsideClassScope", + exact: ["privateInstanceMethod", "publicInstanceMethod", "privateProperty", "publicProperty"], + }, + { + marker: "staticsOutsideClassScope", + exact: ["prototype", "publicStaticProperty", "publicStaticMethod", ...completion.functionMembers], + }, + { + marker: "instanceMembersOutsideClassScope", + exact: ["publicInstanceMethod", "publicProperty"], + }, +); diff --git a/tests/cases/fourslash/completionListClassMembersWithSuperClassFromUnknownNamespace.ts b/tests/cases/fourslash/completionListClassMembersWithSuperClassFromUnknownNamespace.ts index 8e6aab7394bf8..3776ea2c58435 100644 --- a/tests/cases/fourslash/completionListClassMembersWithSuperClassFromUnknownNamespace.ts +++ b/tests/cases/fourslash/completionListClassMembersWithSuperClassFromUnknownNamespace.ts @@ -4,6 +4,4 @@ //// /**/ ////} -goTo.marker(""); -verify.completionListContainsClassElementKeywords(); -verify.completionListCount(verify.allowedClassElementKeywords.length); \ No newline at end of file +verify.completions({ marker: "", includes: completion.classElementKeywords, isNewIdentifierLocation: true }); diff --git a/tests/cases/fourslash/completionListEnumMembers.ts b/tests/cases/fourslash/completionListEnumMembers.ts index 134fdd304f109..42029ae3216c1 100644 --- a/tests/cases/fourslash/completionListEnumMembers.ts +++ b/tests/cases/fourslash/completionListEnumMembers.ts @@ -9,16 +9,7 @@ ////var t :Foo./*typeReference*/ba; ////Foo.bar./*enumValueReference*/; -goTo.marker('valueReference'); -verify.completionListContains("bar"); -verify.completionListContains("baz"); -verify.completionListCount(2); - - -goTo.marker('typeReference'); -verify.completionListCount(2); - -goTo.marker('enumValueReference'); -verify.completionListContains("toString"); -verify.completionListContains("toFixed"); -verify.completionListCount(6); +verify.completions( + { marker: ["valueReference", "typeReference"], exact: ["bar", "baz"] }, + { marker: "enumValueReference", exact: ["toString", "toFixed", "toExponential", "toPrecision", "valueOf", "toLocaleString"] }, +); diff --git a/tests/cases/fourslash/completionListEnumValues.ts b/tests/cases/fourslash/completionListEnumValues.ts index 0b0bf0f96768b..b684bdad49af7 100644 --- a/tests/cases/fourslash/completionListEnumValues.ts +++ b/tests/cases/fourslash/completionListEnumValues.ts @@ -13,20 +13,9 @@ ////function foo(): Colors { return null; } ////foo()./*callOfEnumReturnType*/ -goTo.marker("enumVariable"); -// Should only have the enum's own members, and nothing else -verify.completionListContains("Red"); -verify.completionListContains("Green"); -verify.completionListCount(2); - - -goTo.marker("variableOfEnumType"); -// Should have number members, and not enum members -verify.completionListContains("toString"); -verify.not.completionListContains("Red"); - - -goTo.marker("callOfEnumReturnType"); -// Should have number members, and not enum members -verify.completionListContains("toString"); -verify.not.completionListContains("Red"); +verify.completions( + // Should only have the enum's own members, and nothing else + { marker: "enumVariable", exact: ["Red", "Green"] }, + // Should have number members, and not enum members + { marker: ["variableOfEnumType", "callOfEnumReturnType"], exact: ["toString", "toFixed", "toExponential", "toPrecision", "valueOf", "toLocaleString"] }, +); diff --git a/tests/cases/fourslash/completionListErrorRecovery.ts b/tests/cases/fourslash/completionListErrorRecovery.ts index d5917d43aeb58..69eb8004f47f3 100644 --- a/tests/cases/fourslash/completionListErrorRecovery.ts +++ b/tests/cases/fourslash/completionListErrorRecovery.ts @@ -5,6 +5,5 @@ ////Foo./**/; /////*1*/var bar; -goTo.marker(); -verify.completionListContains("fun"); -verify.not.errorExistsAfterMarker("1"); \ No newline at end of file +verify.completions({ marker: "", includes: "fun" }); +verify.not.errorExistsAfterMarker("1"); diff --git a/tests/cases/fourslash/completionListForDerivedType1.ts b/tests/cases/fourslash/completionListForDerivedType1.ts index 0d771441dae61..ef9b28503d109 100644 --- a/tests/cases/fourslash/completionListForDerivedType1.ts +++ b/tests/cases/fourslash/completionListForDerivedType1.ts @@ -8,14 +8,13 @@ ////} ////var f: IFoo; ////var f2: IFoo2; -////f./*1*/ // completion here shows bar with return type is any +////f./*1*/; // completion here shows bar with return type is any ////f2./*2*/ // here bar has return type any, but bar2 is Foo2 -goTo.marker('1'); -verify.completionListContains('bar', '(method) IFoo.bar(): IFoo'); -verify.not.completionListContains('bar2'); -edit.insert('bar();'); // just to make the file valid before checking next completion location - -goTo.marker('2'); -verify.completionListContains('bar', '(method) IFoo.bar(): IFoo'); -verify.completionListContains('bar2', '(method) IFoo2.bar2(): IFoo2'); \ No newline at end of file +verify.completions( + { marker: "1", exact: [{ name: "bar", text: "(method) IFoo.bar(): IFoo" }] }, + { + marker: "2", + exact: [{ name: "bar2", text: "(method) IFoo2.bar2(): IFoo2" }, { name: "bar", text: "(method) IFoo.bar(): IFoo" }] + }, +); diff --git a/tests/cases/fourslash/completionListForExportEquals.ts b/tests/cases/fourslash/completionListForExportEquals.ts index 28b20177c572a..54161ea840c1a 100644 --- a/tests/cases/fourslash/completionListForExportEquals.ts +++ b/tests/cases/fourslash/completionListForExportEquals.ts @@ -13,4 +13,4 @@ // @Filename: /a.ts ////import { /**/ } from "foo"; -verify.completionsAt("", ["Static", "foo"]); +verify.completions({ marker: "", exact: ["Static", "foo"] }); diff --git a/tests/cases/fourslash/completionListForExportEquals2.ts b/tests/cases/fourslash/completionListForExportEquals2.ts index a7b0772d55e8a..cf890b47ab1f8 100644 --- a/tests/cases/fourslash/completionListForExportEquals2.ts +++ b/tests/cases/fourslash/completionListForExportEquals2.ts @@ -11,4 +11,4 @@ // @Filename: /a.ts ////import { /**/ } from "foo"; -verify.completionsAt("", ["Static"]); +verify.completions({ marker: "", exact: "Static" }); diff --git a/tests/cases/fourslash/completionListForGenericInstance1.ts b/tests/cases/fourslash/completionListForGenericInstance1.ts index 5f323c1269172..718b90ca65c22 100644 --- a/tests/cases/fourslash/completionListForGenericInstance1.ts +++ b/tests/cases/fourslash/completionListForGenericInstance1.ts @@ -6,5 +6,4 @@ ////var i: Iterator; ////i/**/ -goTo.marker(); -verify.completionListContains('i', 'var i: Iterator'); +verify.completions({ marker: "", includes: { name: "i", text: "var i: Iterator" } }); diff --git a/tests/cases/fourslash/completionListForNonExportedMemberInAmbientModuleWithExportAssignment1.ts b/tests/cases/fourslash/completionListForNonExportedMemberInAmbientModuleWithExportAssignment1.ts index 6bc2eaf886aa2..3887d991e4b83 100644 --- a/tests/cases/fourslash/completionListForNonExportedMemberInAmbientModuleWithExportAssignment1.ts +++ b/tests/cases/fourslash/completionListForNonExportedMemberInAmbientModuleWithExportAssignment1.ts @@ -9,5 +9,4 @@ //// import test = require("completionListForNonExportedMemberInAmbientModuleWithExportAssignment1_file0"); //// test./**/ -goTo.marker(); -verify.not.completionListContains("x"); \ No newline at end of file +verify.completions({ marker: "", exact: undefined }); diff --git a/tests/cases/fourslash/completionListForObjectSpread.ts b/tests/cases/fourslash/completionListForObjectSpread.ts index 1fc9a7795e686..703a2e521534f 100644 --- a/tests/cases/fourslash/completionListForObjectSpread.ts +++ b/tests/cases/fourslash/completionListForObjectSpread.ts @@ -18,18 +18,16 @@ //// { a: 7, ...undefined } ////spreadNull./*3*/a; ////spreadUndefined./*4*/a; -goTo.marker('1'); -verify.completionListContains('a', '(property) a: number'); -verify.completionListContains('b', '(property) b: string'); -verify.completionListCount(2); -goTo.marker('2'); -verify.completionListContains('a', '(property) a: number'); -verify.completionListContains('b', '(property) b: boolean'); -verify.completionListContains('c', '(property) c: number'); -verify.completionListCount(3); -goTo.marker('3'); -verify.completionListContains('a', '(property) a: number'); -verify.completionListCount(1); -goTo.marker('4'); -verify.completionListContains('a', '(property) a: number'); -verify.completionListCount(1); + +const a: FourSlashInterface.ExpectedCompletionEntry = { name: "a", text: "(property) a: number" }; +verify.completions( + { + marker: "1", + exact: [a, { name: "b", text: "(property) b: string" }], + }, + { + marker: "2", + exact: [a, { name: "b", text: "(property) b: boolean" }, { name: "c", text: "(property) c: number" }], + }, + { marker: ["3", "4"], exact: a }, +); diff --git a/tests/cases/fourslash/completionListForRest.ts b/tests/cases/fourslash/completionListForRest.ts index 8ea1b7a2a9d06..af2d3b5f3cf74 100644 --- a/tests/cases/fourslash/completionListForRest.ts +++ b/tests/cases/fourslash/completionListForRest.ts @@ -7,7 +7,8 @@ ////let t: Gen; ////var { x, ...rest } = t; ////rest./*1*/x; -goTo.marker('1'); -verify.completionListContains('parent', '(property) Gen.parent: Gen'); -verify.completionListContains('millenial', '(property) Gen.millenial: string'); -verify.completionListCount(2); + +verify.completions({ + marker: "1", + exact: [{ name: "parent", text: "(property) Gen.parent: Gen" }, { name: "millenial", text: "(property) Gen.millenial: string" }], +}); diff --git a/tests/cases/fourslash/completionListForShorthandPropertyAssignment.ts b/tests/cases/fourslash/completionListForShorthandPropertyAssignment.ts index 2b10757bbef40..7b364b69ec985 100644 --- a/tests/cases/fourslash/completionListForShorthandPropertyAssignment.ts +++ b/tests/cases/fourslash/completionListForShorthandPropertyAssignment.ts @@ -2,6 +2,4 @@ //// var person: {name:string; id: number} = { n/**/ -goTo.marker(); -verify.completionListContains('name'); -verify.completionListContains('id'); \ No newline at end of file +verify.completions({ marker: "", exact: ["name", "id"] }); diff --git a/tests/cases/fourslash/completionListForShorthandPropertyAssignment2.ts b/tests/cases/fourslash/completionListForShorthandPropertyAssignment2.ts index 2b10757bbef40..7b364b69ec985 100644 --- a/tests/cases/fourslash/completionListForShorthandPropertyAssignment2.ts +++ b/tests/cases/fourslash/completionListForShorthandPropertyAssignment2.ts @@ -2,6 +2,4 @@ //// var person: {name:string; id: number} = { n/**/ -goTo.marker(); -verify.completionListContains('name'); -verify.completionListContains('id'); \ No newline at end of file +verify.completions({ marker: "", exact: ["name", "id"] }); diff --git a/tests/cases/fourslash/completionListForTransitivelyExportedMembers01.ts b/tests/cases/fourslash/completionListForTransitivelyExportedMembers01.ts index c9fe659cd91a1..90f5cceac34ac 100644 --- a/tests/cases/fourslash/completionListForTransitivelyExportedMembers01.ts +++ b/tests/cases/fourslash/completionListForTransitivelyExportedMembers01.ts @@ -31,9 +31,4 @@ ////import * as c from "./C"; ////var x = c./**/ -goTo.marker(); -verify.completionListContains("C1"); -verify.completionListContains("Inner"); -verify.completionListContains("bVar"); -verify.completionListContains("cVar"); -verify.not.completionListContains("__export"); \ No newline at end of file +verify.completions({ marker: "", exact: ["cVar", "C1", "Inner", "bVar"] }); diff --git a/tests/cases/fourslash/completionListForTransitivelyExportedMembers02.ts b/tests/cases/fourslash/completionListForTransitivelyExportedMembers02.ts index 6f2e2f490b112..e2335c4b36f78 100644 --- a/tests/cases/fourslash/completionListForTransitivelyExportedMembers02.ts +++ b/tests/cases/fourslash/completionListForTransitivelyExportedMembers02.ts @@ -32,8 +32,4 @@ ////import * as c from "./C"; ////var x = c.Inner./**/ -goTo.marker(); -verify.completionListContains("varVar"); -verify.completionListContains("letVar"); -verify.completionListContains("constVar"); -verify.not.completionListContains("__export"); \ No newline at end of file +verify.completions({ marker: "", exact: ["varVar", "letVar", "constVar"] }); diff --git a/tests/cases/fourslash/completionListForTransitivelyExportedMembers03.ts b/tests/cases/fourslash/completionListForTransitivelyExportedMembers03.ts index ae92a706e50ba..4a878081d2e1d 100644 --- a/tests/cases/fourslash/completionListForTransitivelyExportedMembers03.ts +++ b/tests/cases/fourslash/completionListForTransitivelyExportedMembers03.ts @@ -32,9 +32,4 @@ ////import * as c from "./C"; ////var x: c./**/ -goTo.marker(); -verify.completionListContains("I1"); -verify.completionListContains("I2"); -verify.completionListContains("I1_OR_I2"); -verify.completionListContains("C1"); -verify.not.completionListContains("__export"); \ No newline at end of file +verify.completions({ marker: "", includes: ["I1", "I2", "I1_OR_I2", "C1"] }); diff --git a/tests/cases/fourslash/completionListForTransitivelyExportedMembers04.ts b/tests/cases/fourslash/completionListForTransitivelyExportedMembers04.ts index 44f2bf224ad87..f6052fe030cba 100644 --- a/tests/cases/fourslash/completionListForTransitivelyExportedMembers04.ts +++ b/tests/cases/fourslash/completionListForTransitivelyExportedMembers04.ts @@ -32,6 +32,4 @@ ////import * as c from "C"; ////var x: c.Inner./**/ -goTo.marker(); -verify.completionListContains("I3"); -verify.not.completionListContains("__export"); \ No newline at end of file +verify.completions({ marker: "", exact: "I3" }); diff --git a/tests/cases/fourslash/completionListForUnicodeEscapeName.ts b/tests/cases/fourslash/completionListForUnicodeEscapeName.ts index 9ada3e3596173..7c18e6c82a08c 100644 --- a/tests/cases/fourslash/completionListForUnicodeEscapeName.ts +++ b/tests/cases/fourslash/completionListForUnicodeEscapeName.ts @@ -1,26 +1,12 @@ /// ////function \u0042 () { /*0*/ } -////export default function \u0043 () { /*1*/ } +////export default function \u0043 () {} ////class \u0041 { /*2*/ } /////*3*/ -goTo.marker("0"); -verify.completionListContains("B"); -verify.completionListContains("\u0042"); - -goTo.marker("2"); -verify.not.completionListContains("C"); -verify.not.completionListContains("\u0043"); - -goTo.marker("2"); -verify.not.completionListContains("A"); -verify.not.completionListContains("\u0041"); - -goTo.marker("3"); -verify.completionListContains("B"); -verify.completionListContains("\u0042"); -verify.completionListContains("A"); -verify.completionListContains("\u0041"); -verify.completionListContains("C"); -verify.completionListContains("\u0043"); +verify.completions( + { marker: "0", includes: ["B", "\u0042"] }, + { marker: "2", excludes: ["C", "\u0043", "A", "\u0041"], isNewIdentifierLocation: true }, + { marker: "3", includes: ["B", "\u0042", "A", "\u0041", "C", "\u0043"] }, +); diff --git a/tests/cases/fourslash/completionListFunctionExpression.ts b/tests/cases/fourslash/completionListFunctionExpression.ts index b861ff2e023b0..4b7f75dc6e0f3 100644 --- a/tests/cases/fourslash/completionListFunctionExpression.ts +++ b/tests/cases/fourslash/completionListFunctionExpression.ts @@ -15,7 +15,7 @@ goTo.marker("local"); edit.insertLine(""); -verify.completionListContains("xmlEvent"); - -goTo.marker("this"); -verify.completionListIsEmpty(); \ No newline at end of file +verify.completions( + { includes: "xmlEvent" }, + { marker: "this", exact: undefined }, +); diff --git a/tests/cases/fourslash/completionListFunctionMembers.ts b/tests/cases/fourslash/completionListFunctionMembers.ts index 1a10fea1d8d05..f53b66b1c0310 100644 --- a/tests/cases/fourslash/completionListFunctionMembers.ts +++ b/tests/cases/fourslash/completionListFunctionMembers.ts @@ -7,5 +7,4 @@ //// ////fnc1./**/ -goTo.marker(); -verify.completionListContains('arguments', '(property) Function.arguments: any'); \ No newline at end of file +verify.completions({ marker: "", exact: completion.functionMembersWithPrototype }); diff --git a/tests/cases/fourslash/completionListGenericConstraints.ts b/tests/cases/fourslash/completionListGenericConstraints.ts index 10058ccbafa38..cb0965e6288a3 100644 --- a/tests/cases/fourslash/completionListGenericConstraints.ts +++ b/tests/cases/fourslash/completionListGenericConstraints.ts @@ -32,7 +32,7 @@ //// ////class CallableWrapper { //// public call(value: T) { -//// value./*callableMembers*/ +//// value./*callableMembers*/ //// } ////} ////// Only public members of a constraint should be shown @@ -47,31 +47,13 @@ //// ////class BaseWrapper { //// public test(value: T) { -//// value./*publicOnlyMemebers*/ +//// value./*publicOnlyMembers*/ //// } ////} -goTo.marker("objectMembers"); -verify.completionListContains("hasOwnProperty"); -verify.completionListContains("isPrototypeOf"); -verify.completionListContains("toString"); - -goTo.marker("interfaceMembers"); -verify.completionListContains("bar11"); -verify.completionListContains("bar12"); -verify.completionListContains("bar21"); -verify.completionListContains("bar22"); - -goTo.marker("callableMembers"); -verify.completionListContains("name"); -verify.completionListContains("apply"); -verify.completionListContains("call"); -verify.completionListContains("bind"); - -goTo.marker("publicOnlyMemebers"); -verify.completionListContains("publicProperty"); -verify.completionListContains("publicMethod"); -verify.not.completionListContains("privateProperty"); -verify.not.completionListContains("privateMethod"); -verify.not.completionListContains("publicStaticMethod"); -verify.not.completionListContains("privateStaticMethod"); \ No newline at end of file +verify.completions( + { marker: "objectMembers", exact: ["constructor", "toString", "toLocaleString", "valueOf", "hasOwnProperty", "isPrototypeOf", "propertyIsEnumerable"] }, + { marker: "interfaceMembers", exact: ["bar21", "bar22", "bar11", "bar12"] }, + { marker: "callableMembers", exact: ["name", ...completion.functionMembersWithPrototype] }, + { marker: "publicOnlyMembers", exact: ["publicProperty", "publicMethod"] }, +); diff --git a/tests/cases/fourslash/completionListImplementingInterfaceFunctions.ts b/tests/cases/fourslash/completionListImplementingInterfaceFunctions.ts index 42be3a51618b3..179fc02aa5991 100644 --- a/tests/cases/fourslash/completionListImplementingInterfaceFunctions.ts +++ b/tests/cases/fourslash/completionListImplementingInterfaceFunctions.ts @@ -15,7 +15,4 @@ //// /*1*/ ////} -goTo.marker("0"); -verify.not.completionListContains("a"); -goTo.marker("1"); -verify.not.completionListContains("a"); +verify.completions({ marker: ["0", "1"], exact: "b" }); diff --git a/tests/cases/fourslash/completionListInArrowFunctionInUnclosedCallSite01.ts b/tests/cases/fourslash/completionListInArrowFunctionInUnclosedCallSite01.ts index 633dc00a94146..0dde6f859900a 100644 --- a/tests/cases/fourslash/completionListInArrowFunctionInUnclosedCallSite01.ts +++ b/tests/cases/fourslash/completionListInArrowFunctionInUnclosedCallSite01.ts @@ -4,8 +4,8 @@ ////function getAllFiles(rootFileNames: string[]) { //// var processedFiles = rootFileNames.map(fileName => foo(/*1*/ -goTo.marker("1"); -verify.completionListContains("fileName"); -verify.completionListContains("rootFileNames"); -verify.completionListContains("getAllFiles"); -verify.completionListContains("foo"); \ No newline at end of file +verify.completions({ + marker: "1", + includes: ["fileName", "rootFileNames", "getAllFiles", "foo"], + isNewIdentifierLocation: true, +}); diff --git a/tests/cases/fourslash/completionListInClassExpressionWithTypeParameter.ts b/tests/cases/fourslash/completionListInClassExpressionWithTypeParameter.ts index 47f030bf90706..7a4a42f90db5b 100644 --- a/tests/cases/fourslash/completionListInClassExpressionWithTypeParameter.ts +++ b/tests/cases/fourslash/completionListInClassExpressionWithTypeParameter.ts @@ -8,10 +8,7 @@ //// prop: Ty/*1*/ //// } -goTo.marker("0"); -verify.not.completionListContains("TypeParam", "(type parameter) TypeParam in myClass", /*documentation*/ undefined, "type parameter"); -goTo.marker("0Type"); -verify.completionListContains("TypeParam", "(type parameter) TypeParam in myClass", /*documentation*/ undefined, "type parameter"); - -goTo.marker("1"); -verify.completionListContains("TypeParam", "(type parameter) TypeParam in myClass", /*documentation*/ undefined, "type parameter"); \ No newline at end of file +verify.completions( + { marker: "0", excludes: "TypeParam" }, + { marker: ["0Type", "1"], includes: { name: "TypeParam", text: "(type parameter) TypeParam in myClass", kind: "type parameter" } }, +); diff --git a/tests/cases/fourslash/completionListInClosedFunction01.ts b/tests/cases/fourslash/completionListInClosedFunction01.ts index 608d0c761cfe9..af1175e46955c 100644 --- a/tests/cases/fourslash/completionListInClosedFunction01.ts +++ b/tests/cases/fourslash/completionListInClosedFunction01.ts @@ -4,9 +4,4 @@ //// /*1*/ ////} -goTo.marker("1"); - -verify.completionListContains("foo"); -verify.completionListContains("x"); -verify.completionListContains("y"); -verify.completionListContains("z"); \ No newline at end of file +verify.completions({ marker: "1", includes: ["x", "y", "z"] }); diff --git a/tests/cases/fourslash/completionListInClosedFunction02.ts b/tests/cases/fourslash/completionListInClosedFunction02.ts index 89428df12f819..bfda6646fd736 100644 --- a/tests/cases/fourslash/completionListInClosedFunction02.ts +++ b/tests/cases/fourslash/completionListInClosedFunction02.ts @@ -5,14 +5,8 @@ //// } ////} -goTo.marker("1"); - -verify.completionListContains("foo"); -verify.completionListContains("x"); -verify.completionListContains("y"); -verify.completionListContains("z"); - -verify.completionListContains("bar"); -verify.completionListContains("a"); -verify.completionListContains("b"); -verify.completionListContains("c"); // questionable \ No newline at end of file +verify.completions({ + marker: "1", + // Note: `c: typeof c` would be a compile error + includes: ["foo", "x", "y", "z", "bar", "a", "b", "c"], +}); diff --git a/tests/cases/fourslash/completionListInClosedFunction03.ts b/tests/cases/fourslash/completionListInClosedFunction03.ts index ce43ec33b0dd4..3ee7cd43d2496 100644 --- a/tests/cases/fourslash/completionListInClosedFunction03.ts +++ b/tests/cases/fourslash/completionListInClosedFunction03.ts @@ -2,18 +2,12 @@ ////function foo(x: string, y: number, z: boolean) { //// function bar(a: number, b: string, c: typeof x = /*1*/) { -//// +//// //// } ////} -goTo.marker("1"); - -verify.completionListContains("foo"); -verify.completionListContains("x"); -verify.completionListContains("y"); -verify.completionListContains("z"); - -verify.completionListContains("bar"); -verify.completionListContains("a"); -verify.completionListContains("b"); -verify.completionListContains("c"); // questionable \ No newline at end of file +verify.completions({ + marker: "1", + // Note: `c = c` would be a compile error + includes: ["foo", "x", "y", "z", "bar", "a", "b", "c"], +}); diff --git a/tests/cases/fourslash/completionListInClosedFunction04.ts b/tests/cases/fourslash/completionListInClosedFunction04.ts index 47ae9da2c9efb..225cbbb1a2062 100644 --- a/tests/cases/fourslash/completionListInClosedFunction04.ts +++ b/tests/cases/fourslash/completionListInClosedFunction04.ts @@ -2,18 +2,12 @@ ////function foo(x: string, y: number, z: boolean) { //// function bar(a: number, b: string = /*1*/, c: typeof x = "hello") { -//// +//// //// } ////} -goTo.marker("1"); - -verify.completionListContains("foo"); -verify.completionListContains("x"); -verify.completionListContains("y"); -verify.completionListContains("z"); - -verify.completionListContains("bar"); -verify.completionListContains("a"); -verify.completionListContains("b"); -verify.completionListContains("c"); // definitely questionable \ No newline at end of file +verify.completions({ + marker: "1", + // Note: `b = b` or `b = c` would be a compile error + includes: ["foo", "x", "y", "z", "bar", "a", "b", "c"], +}); diff --git a/tests/cases/fourslash/completionListInClosedFunction05.ts b/tests/cases/fourslash/completionListInClosedFunction05.ts index 3252904ee19f2..11c1600934983 100644 --- a/tests/cases/fourslash/completionListInClosedFunction05.ts +++ b/tests/cases/fourslash/completionListInClosedFunction05.ts @@ -6,16 +6,9 @@ //// } ////} -goTo.marker("1"); - -verify.completionListContains("foo"); -verify.completionListContains("x"); -verify.completionListContains("y"); -verify.completionListContains("z"); - -verify.completionListContains("bar"); -verify.completionListContains("a"); -verify.completionListContains("b"); -verify.completionListContains("c"); - -verify.completionListContains("v"); // questionable \ No newline at end of file +verify.completions({ + marker: "1", + // Note: `v = v` would be a compile error + includes: ["foo", "x", "y", "z", "bar", "a", "b", "c", "v"], + isNewIdentifierLocation: true, +}); diff --git a/tests/cases/fourslash/completionListInClosedFunction06.ts b/tests/cases/fourslash/completionListInClosedFunction06.ts index 76c58f87174e4..f9c9cc4c8df47 100644 --- a/tests/cases/fourslash/completionListInClosedFunction06.ts +++ b/tests/cases/fourslash/completionListInClosedFunction06.ts @@ -9,6 +9,4 @@ //// } ////} -goTo.marker("1"); - -verify.completionListContains("MyType"); \ No newline at end of file +verify.completions({ marker: "1", includes: "MyType", excludes: "x" }); diff --git a/tests/cases/fourslash/completionListInClosedFunction07.ts b/tests/cases/fourslash/completionListInClosedFunction07.ts index 8c0b5e68872d1..0c911c8b61ed4 100644 --- a/tests/cases/fourslash/completionListInClosedFunction07.ts +++ b/tests/cases/fourslash/completionListInClosedFunction07.ts @@ -9,17 +9,8 @@ //// } ////} -goTo.marker("1"); - -verify.completionListContains("foo"); -verify.completionListContains("x"); -verify.completionListContains("y"); -verify.completionListContains("z"); - -verify.completionListContains("bar"); -verify.completionListContains("a"); -verify.completionListContains("b"); -verify.completionListContains("c"); - -verify.completionListContains("v"); -verify.completionListContains("p"); \ No newline at end of file +verify.completions({ + marker: "1", + includes: ["foo", "x", "y", "z", "bar", "a", "b", "c", "v", "p"], + excludes: "MyType", +}); diff --git a/tests/cases/fourslash/completionListInClosedObjectTypeLiteralInSignature01.ts b/tests/cases/fourslash/completionListInClosedObjectTypeLiteralInSignature01.ts index 856d94492e664..1c75426785181 100644 --- a/tests/cases/fourslash/completionListInClosedObjectTypeLiteralInSignature01.ts +++ b/tests/cases/fourslash/completionListInClosedObjectTypeLiteralInSignature01.ts @@ -7,12 +7,8 @@ //// ////declare function foo(obj: I): { str: T/*1*/ } -goTo.marker("1"); - -verify.completionListContains("I"); -verify.completionListContains("TString"); -verify.completionListContains("TNumber"); - -// Ideally the following shouldn't show up since they're not types. -verify.not.completionListContains("foo"); -verify.not.completionListContains("obj"); \ No newline at end of file +verify.completions({ + marker: "1", + includes: ["I", "TString", "TNumber"], + excludes: ["foo", "obj"], // not types +}); diff --git a/tests/cases/fourslash/completionListInClosedObjectTypeLiteralInSignature02.ts b/tests/cases/fourslash/completionListInClosedObjectTypeLiteralInSignature02.ts index 0472a9c04fa8c..5b0af2dd4914f 100644 --- a/tests/cases/fourslash/completionListInClosedObjectTypeLiteralInSignature02.ts +++ b/tests/cases/fourslash/completionListInClosedObjectTypeLiteralInSignature02.ts @@ -7,12 +7,4 @@ //// ////declare function foo(obj: I): { str: TStr/*1*/ } -goTo.marker("1"); - -verify.completionListContains("I"); -verify.completionListContains("TString"); -verify.completionListContains("TNumber"); // REVIEW: Is this intended behavior? - -// Ideally the following shouldn't show up since they're not types. -verify.not.completionListContains("foo"); -verify.not.completionListContains("obj"); \ No newline at end of file +verify.completions({ marker: "1", includes: ["I", "TString", "TNumber"], excludes: ["foo", "obj"] }); diff --git a/tests/cases/fourslash/completionListInClosedObjectTypeLiteralInSignature03.ts b/tests/cases/fourslash/completionListInClosedObjectTypeLiteralInSignature03.ts index 1dc34dcffd454..eb49f7e23400b 100644 --- a/tests/cases/fourslash/completionListInClosedObjectTypeLiteralInSignature03.ts +++ b/tests/cases/fourslash/completionListInClosedObjectTypeLiteralInSignature03.ts @@ -7,12 +7,8 @@ //// ////declare function foo(obj: I): { str: TString/*1*/ } -goTo.marker("1"); - -verify.completionListContains("I"); -verify.completionListContains("TString"); -verify.completionListContains("TNumber"); // REVIEW: Is this intended behavior? - -// Ideally the following shouldn't show up since they're not types. -verify.not.completionListContains("foo"); -verify.not.completionListContains("obj"); \ No newline at end of file +verify.completions({ + marker: "1", + includes: ["I", "TString", "TNumber"], + excludes: ["foo", "obj"], // not types +}); diff --git a/tests/cases/fourslash/completionListInClosedObjectTypeLiteralInSignature04.ts b/tests/cases/fourslash/completionListInClosedObjectTypeLiteralInSignature04.ts index 8674124f05f5c..2f07107e0578b 100644 --- a/tests/cases/fourslash/completionListInClosedObjectTypeLiteralInSignature04.ts +++ b/tests/cases/fourslash/completionListInClosedObjectTypeLiteralInSignature04.ts @@ -7,4 +7,4 @@ //// ////declare function foo(obj: I): { /*1*/ } -verify.completionsAt("1", ["readonly"], { isNewIdentifierLocation: true }); +verify.completions({ marker: "1", exact: "readonly", isNewIdentifierLocation: true }); diff --git a/tests/cases/fourslash/completionListInComments.ts b/tests/cases/fourslash/completionListInComments.ts index dadb1ba46f45a..fd9c5bcb02cf1 100644 --- a/tests/cases/fourslash/completionListInComments.ts +++ b/tests/cases/fourslash/completionListInComments.ts @@ -3,6 +3,5 @@ ////var foo = ''; ////( // f/**/ -goTo.marker(); // Completion list should not be available within comments -verify.completionListIsEmpty(); +verify.completions({ marker: "", exact: undefined }); diff --git a/tests/cases/fourslash/completionListInComments2.ts b/tests/cases/fourslash/completionListInComments2.ts index d9855306fcf33..8eb1272ba64f9 100644 --- a/tests/cases/fourslash/completionListInComments2.ts +++ b/tests/cases/fourslash/completionListInComments2.ts @@ -2,6 +2,5 @@ //// // */{| "name" : "1" |} -goTo.marker("1"); // Completion list should not be available within comments -verify.completionListIsEmpty(); +verify.completions({ marker: "1", exact: undefined }); diff --git a/tests/cases/fourslash/completionListInComments3.ts b/tests/cases/fourslash/completionListInComments3.ts index 2f20a969ba174..a874ab8e953e1 100644 --- a/tests/cases/fourslash/completionListInComments3.ts +++ b/tests/cases/fourslash/completionListInComments3.ts @@ -12,20 +12,7 @@ /////* {| "name": "6" |} -goTo.marker("1"); -verify.completionListIsEmpty(); - -goTo.marker("2"); -verify.completionListIsEmpty(); - -goTo.marker("3"); -verify.completionListIsEmpty(); - -goTo.marker("4"); -verify.not.completionListIsEmpty(); - -goTo.marker("5"); -verify.not.completionListIsEmpty(); - -goTo.marker("6"); -verify.completionListIsEmpty(); +verify.completions( + { marker: ["1", "2", "3", "6"], exact: undefined }, + { marker: ["4", "5"], exact: completion.globals }, +); diff --git a/tests/cases/fourslash/completionListInContextuallyTypedArgument.ts b/tests/cases/fourslash/completionListInContextuallyTypedArgument.ts index 69a35bed0e373..7a1d1f936c026 100644 --- a/tests/cases/fourslash/completionListInContextuallyTypedArgument.ts +++ b/tests/cases/fourslash/completionListInContextuallyTypedArgument.ts @@ -17,11 +17,4 @@ //// e./*2*/ ////} ); - -goTo.marker("1"); -verify.completionListContains('x1'); -verify.completionListContains('y1'); - -goTo.marker("2"); -verify.completionListContains('x1'); -verify.completionListContains('y1'); \ No newline at end of file +verify.completions({ marker: ["1", "2"], exact: ["x1", "y1"] }); diff --git a/tests/cases/fourslash/completionListInEmptyFile.ts b/tests/cases/fourslash/completionListInEmptyFile.ts index fc17606135890..99f895eb20c1c 100644 --- a/tests/cases/fourslash/completionListInEmptyFile.ts +++ b/tests/cases/fourslash/completionListInEmptyFile.ts @@ -3,5 +3,4 @@ ////var a = 0; /////**/ -goTo.marker(); -verify.completionListContains("a"); +verify.completions({ marker: "", includes: "a" }); diff --git a/tests/cases/fourslash/completionListInExportClause01.ts b/tests/cases/fourslash/completionListInExportClause01.ts index 741a1ac333c81..d11d395b5b0a5 100644 --- a/tests/cases/fourslash/completionListInExportClause01.ts +++ b/tests/cases/fourslash/completionListInExportClause01.ts @@ -12,29 +12,10 @@ ////export {bar as /*5*/, /*6*/ from "./m1" ////export {foo, bar, baz as b,/*7*/} from "./m1" -function verifyCompletionAtMarker(marker: string, showBuilder: boolean, ...completions: string[]) { - goTo.marker(marker); - if (completions.length) { - for (let completion of completions) { - verify.completionListContains(completion); - } - } - else { - verify.completionListIsEmpty(); - } - - if (showBuilder) { - verify.completionListAllowsNewIdentifier(); - } - else { - verify.not.completionListAllowsNewIdentifier(); - } -} - -verifyCompletionAtMarker("1", /*showBuilder*/ false, "foo", "bar", "baz"); -verifyCompletionAtMarker("2", /*showBuilder*/ false, "foo", "bar", "baz"); -verifyCompletionAtMarker("3", /*showBuilder*/ false, "foo", "bar", "baz"); -verifyCompletionAtMarker("4", /*showBuilder*/ false, "bar", "baz"); -verifyCompletionAtMarker("5", /*showBuilder*/ true); -verifyCompletionAtMarker("6", /*showBuilder*/ false, "foo", "baz"); -verifyCompletionAtMarker("7", /*showBuilder*/ false); \ No newline at end of file +verify.completions( + { marker: ["1", "2", "3"], exact: ["bar", "baz", "foo"] }, + { marker: "4", exact: ["bar", "baz"] }, + { marker: "5", exact: undefined, isNewIdentifierLocation: true }, + { marker: "6", exact: ["baz", "foo"] }, + { marker: "7", exact: undefined }, +); diff --git a/tests/cases/fourslash/completionListInExportClause02.ts b/tests/cases/fourslash/completionListInExportClause02.ts index 4b40976f52137..7ded96ef0aeca 100644 --- a/tests/cases/fourslash/completionListInExportClause02.ts +++ b/tests/cases/fourslash/completionListInExportClause02.ts @@ -8,7 +8,4 @@ //// export { /**/ } from "M1" ////} -goTo.marker(); -verify.completionListContains("V"); -verify.not.completionListContains("W"); -verify.not.completionListAllowsNewIdentifier(); \ No newline at end of file +verify.completions({ marker: "", exact: "V" }); diff --git a/tests/cases/fourslash/completionListInExportClause03.ts b/tests/cases/fourslash/completionListInExportClause03.ts index 426c85d02ea7a..f731833ac02f2 100644 --- a/tests/cases/fourslash/completionListInExportClause03.ts +++ b/tests/cases/fourslash/completionListInExportClause03.ts @@ -10,7 +10,4 @@ ////} // Ensure we don't filter out the current item. -goTo.marker(); -verify.completionListContains("abc"); -verify.completionListContains("def"); -verify.not.completionListAllowsNewIdentifier(); \ No newline at end of file +verify.completions({ marker: "", exact: ["abc", "def"] }); diff --git a/tests/cases/fourslash/completionListInExtendsClause.ts b/tests/cases/fourslash/completionListInExtendsClause.ts index 79451e4fd57eb..f5b1ce4384ef5 100644 --- a/tests/cases/fourslash/completionListInExtendsClause.ts +++ b/tests/cases/fourslash/completionListInExtendsClause.ts @@ -17,14 +17,8 @@ ////interface test3 extends IFoo./*3*/ {} ////interface test4 implements Foo./*4*/ {} -goTo.marker("1"); -verify.not.completionListIsEmpty(); -goTo.marker("2"); -verify.completionListIsEmpty(); - -goTo.marker("3"); -verify.completionListIsEmpty(); - -goTo.marker("4"); -verify.completionListIsEmpty(); \ No newline at end of file +verify.completions( + { marker: "1", exact: ["prototype", "staticMethod", ...completion.functionMembers] }, + { marker: ["2", "3", "4"], exact: undefined }, +); diff --git a/tests/cases/fourslash/completionListInExtendsClauseAtEOF.ts b/tests/cases/fourslash/completionListInExtendsClauseAtEOF.ts index 7a065fd364d00..3c59425e17f57 100644 --- a/tests/cases/fourslash/completionListInExtendsClauseAtEOF.ts +++ b/tests/cases/fourslash/completionListInExtendsClauseAtEOF.ts @@ -5,6 +5,4 @@ ////} ////class Bar extends mod./**/ -goTo.marker(); -verify.completionListContains("Foo"); -verify.completionListCount(1); \ No newline at end of file +verify.completions({ marker: "", includes: "Foo" }); diff --git a/tests/cases/fourslash/completionListInFatArrow.ts b/tests/cases/fourslash/completionListInFatArrow.ts index 140fa17667580..8aac72fec39a4 100644 --- a/tests/cases/fourslash/completionListInFatArrow.ts +++ b/tests/cases/fourslash/completionListInFatArrow.ts @@ -8,4 +8,4 @@ goTo.marker(); edit.insert('it'); -verify.completionListContains('items'); \ No newline at end of file +verify.completions({ includes: "items" }); diff --git a/tests/cases/fourslash/completionListInFunctionDeclaration.ts b/tests/cases/fourslash/completionListInFunctionDeclaration.ts index 87107da897c0a..3ba4b7d47755c 100644 --- a/tests/cases/fourslash/completionListInFunctionDeclaration.ts +++ b/tests/cases/fourslash/completionListInFunctionDeclaration.ts @@ -3,15 +3,14 @@ ////var a = 0; ////function foo(/**/ -goTo.marker(); -verify.completionListIsEmpty(); +verify.completions({ marker: "", exact: undefined }); edit.insert("a"); // foo(a| -verify.completionListIsEmpty(); +verify.completions({ exact: undefined }); edit.insert(" , "); // foo(a ,| -verify.completionListIsEmpty(); +verify.completions({ exact: undefined }); edit.insert("b"); // foo(a ,b| -verify.completionListIsEmpty(); +verify.completions({ exact: undefined }); edit.insert(":"); // foo(a ,b:| <- type ref -verify.not.completionListIsEmpty(); +verify.completions({ exact: completion.globalTypes }); edit.insert("number, "); // foo(a ,b:number,| -verify.completionListIsEmpty(); \ No newline at end of file +verify.completions({ exact: undefined }); diff --git a/tests/cases/fourslash/completionListInFunctionExpression.ts b/tests/cases/fourslash/completionListInFunctionExpression.ts index bba9eb09c3a49..60e96745754f4 100644 --- a/tests/cases/fourslash/completionListInFunctionExpression.ts +++ b/tests/cases/fourslash/completionListInFunctionExpression.ts @@ -6,19 +6,18 @@ //// foo./*memberCompletion*/toString; ////}/*editDeclaration*/ -goTo.marker("requestCompletion"); -verify.completionListContains("foo"); +function check() { + verify.completions( + { marker: "requestCompletion", includes: "foo" }, + { marker: "memberCompletion", includes: "toExponential" }, + ); +} -goTo.marker("memberCompletion"); -verify.completionListContains("toExponential"); +check(); // Now change the decl by adding a semicolon goTo.marker("editDeclaration"); edit.insert(";"); // foo should still be there -goTo.marker("requestCompletion"); -verify.completionListContains("foo"); - -goTo.marker("memberCompletion"); -verify.completionListContains("toExponential"); +check(); diff --git a/tests/cases/fourslash/completionListInImportClause01.ts b/tests/cases/fourslash/completionListInImportClause01.ts index fb2beadc566ac..026d436063340 100644 --- a/tests/cases/fourslash/completionListInImportClause01.ts +++ b/tests/cases/fourslash/completionListInImportClause01.ts @@ -13,29 +13,10 @@ ////import {bar as /*5*/, /*6*/ from "m1" ////import {foo, bar, baz as b,/*7*/} from "m1" -function verifyCompletionAtMarker(marker: string, showBuilder: boolean, ...completions: string[]) { - goTo.marker(marker); - if (completions.length) { - for (let completion of completions) { - verify.completionListContains(completion); - } - } - else { - verify.completionListIsEmpty(); - } - - if (showBuilder) { - verify.completionListAllowsNewIdentifier(); - } - else { - verify.not.completionListAllowsNewIdentifier(); - } -} - -verifyCompletionAtMarker("1", /*showBuilder*/ false, "foo", "bar", "baz"); -verifyCompletionAtMarker("2", /*showBuilder*/ false, "foo", "bar", "baz"); -verifyCompletionAtMarker("3", /*showBuilder*/ false, "foo", "bar", "baz"); -verifyCompletionAtMarker("4", /*showBuilder*/ false, "bar", "baz"); -verifyCompletionAtMarker("5", /*showBuilder*/ true); -verifyCompletionAtMarker("6", /*showBuilder*/ false, "foo", "baz"); -verifyCompletionAtMarker("7", /*showBuilder*/ false); \ No newline at end of file +verify.completions( + { marker: ["1", "2", "3"], exact: ["bar", "baz", "foo"] }, + { marker: "4", exact: ["bar", "baz"] }, + { marker: "5", exact: undefined, isNewIdentifierLocation: true }, + { marker: "6", exact: ["baz", "foo"] }, + { marker: "7", exact: undefined }, +); diff --git a/tests/cases/fourslash/completionListInImportClause02.ts b/tests/cases/fourslash/completionListInImportClause02.ts index 9cf216f4578c9..0bc840eed54cc 100644 --- a/tests/cases/fourslash/completionListInImportClause02.ts +++ b/tests/cases/fourslash/completionListInImportClause02.ts @@ -8,6 +8,4 @@ //// import { /**/ } from "M1" ////} -goTo.marker(); -verify.completionListContains("V"); -verify.not.completionListAllowsNewIdentifier(); +verify.completions({ marker: "", exact: "V" }); diff --git a/tests/cases/fourslash/completionListInImportClause03.ts b/tests/cases/fourslash/completionListInImportClause03.ts index 7461c83022b7f..db1d7f84a53e9 100644 --- a/tests/cases/fourslash/completionListInImportClause03.ts +++ b/tests/cases/fourslash/completionListInImportClause03.ts @@ -10,7 +10,4 @@ ////} // Ensure we don't filter out the current item. -goTo.marker(); -verify.completionListContains("abc"); -verify.completionListContains("def"); -verify.not.completionListAllowsNewIdentifier(); \ No newline at end of file +verify.completions({ marker: "", exact: ["abc", "def"] }); diff --git a/tests/cases/fourslash/completionListInImportClause04.ts b/tests/cases/fourslash/completionListInImportClause04.ts index 60ec5790120e3..321a38d85460a 100644 --- a/tests/cases/fourslash/completionListInImportClause04.ts +++ b/tests/cases/fourslash/completionListInImportClause04.ts @@ -11,7 +11,7 @@ // @Filename: app.ts ////import {/*1*/} from './foo'; -verify.completionsAt("1", ["prototype", "prop1", "prop2"]); +verify.completions({ marker: "1", exact: ["prototype", "prop1", "prop2"] }); verify.noErrors(); goTo.marker('2'); verify.noErrors(); diff --git a/tests/cases/fourslash/completionListInImportClause05.ts b/tests/cases/fourslash/completionListInImportClause05.ts index 00b7273776947..115e53fd5c032 100644 --- a/tests/cases/fourslash/completionListInImportClause05.ts +++ b/tests/cases/fourslash/completionListInImportClause05.ts @@ -12,4 +12,4 @@ // NOTE: The node_modules folder is in "/", rather than ".", because it requires // less scaffolding to mock. In particular, "/" is where we look for type roots. -verify.completionsAt("1", ["@e/f", "@a/b", "@c/d"], { isNewIdentifierLocation: true }); +verify.completions({ marker: "1", exact: ["@e/f", "@a/b", "@c/d"], isNewIdentifierLocation: true }); diff --git a/tests/cases/fourslash/completionListInImportClause06.ts b/tests/cases/fourslash/completionListInImportClause06.ts index 3dfcea3cdbfdf..e16039f633b66 100644 --- a/tests/cases/fourslash/completionListInImportClause06.ts +++ b/tests/cases/fourslash/completionListInImportClause06.ts @@ -12,4 +12,4 @@ ////export declare let x: number; // Confirm that entries are de-dup'd. -verify.completionsAt("1", ["@a/b"], { isNewIdentifierLocation: true }); +verify.completions({ marker: "1", exact: "@a/b", isNewIdentifierLocation: true }); diff --git a/tests/cases/fourslash/completionListInIndexSignature01.ts b/tests/cases/fourslash/completionListInIndexSignature01.ts index aaf97fee1a561..01032017b7171 100644 --- a/tests/cases/fourslash/completionListInIndexSignature01.ts +++ b/tests/cases/fourslash/completionListInIndexSignature01.ts @@ -14,4 +14,9 @@ //// [x/*5*/yz: number]: boolean; //// [/*6*/ -goTo.eachMarker(() => verify.completionListAllowsNewIdentifier()); +const exact = completion.globalsPlus(["C"]); +verify.completions( + { marker: ["1", "2", "3", "6"], exact, isNewIdentifierLocation: true }, + { marker: "4", exact: ["str", ...exact], isNewIdentifierLocation: true }, + { marker: "5", exact: ["xyz", ...exact], isNewIdentifierLocation: true }, +); diff --git a/tests/cases/fourslash/completionListInIndexSignature02.ts b/tests/cases/fourslash/completionListInIndexSignature02.ts index ce1f8b38e2454..c7b725d4f7c0e 100644 --- a/tests/cases/fourslash/completionListInIndexSignature02.ts +++ b/tests/cases/fourslash/completionListInIndexSignature02.ts @@ -13,4 +13,8 @@ ////type T = { //// [xyz: /*5*/ -goTo.eachMarker(() => verify.not.completionListAllowsNewIdentifier()); +const exact = completion.globalTypesPlus(["I", "C"]); +verify.completions( + { marker: ["1", "2"], exact: ["T", ...exact] }, + { marker: ["3", "4", "5"], exact: completion.globalTypesPlus(["I", "C", "T"]) }, +); diff --git a/tests/cases/fourslash/completionListInMiddleOfIdentifierInArrowFunction01.ts b/tests/cases/fourslash/completionListInMiddleOfIdentifierInArrowFunction01.ts index c48e36c91c83c..1d06df28a0bd9 100644 --- a/tests/cases/fourslash/completionListInMiddleOfIdentifierInArrowFunction01.ts +++ b/tests/cases/fourslash/completionListInMiddleOfIdentifierInArrowFunction01.ts @@ -2,5 +2,4 @@ ////xyz => x/*1*/y -goTo.marker("1"); -verify.completionListContains("xyz"); \ No newline at end of file +verify.completions({ marker: "1", includes: "xyz" }); diff --git a/tests/cases/fourslash/completionListInNamedClassExpression.ts b/tests/cases/fourslash/completionListInNamedClassExpression.ts index 8ca6806ce7f87..466342ab630e0 100644 --- a/tests/cases/fourslash/completionListInNamedClassExpression.ts +++ b/tests/cases/fourslash/completionListInNamedClassExpression.ts @@ -7,8 +7,11 @@ //// /*1*/ //// } -goTo.marker("0"); -verify.completionListContains("myClass", "(local class) myClass", /*documentation*/ undefined, "local class"); - -goTo.marker("1"); -verify.not.completionListContains("myClass", "(local class) myClass", /*documentation*/ undefined, "local class"); \ No newline at end of file +verify.completions( + { marker: "0", includes: { name: "myClass", text: "(local class) myClass", kind: "local class" } }, + { + marker: "1", + exact: ["private", "protected", "public", "static", "abstract", "async", "constructor", "get", "readonly", "set"], + isNewIdentifierLocation: true, + }, +); diff --git a/tests/cases/fourslash/completionListInNamedClassExpressionWithShadowing.ts b/tests/cases/fourslash/completionListInNamedClassExpressionWithShadowing.ts index fd347d5803791..ac6d9f1d17d8e 100644 --- a/tests/cases/fourslash/completionListInNamedClassExpressionWithShadowing.ts +++ b/tests/cases/fourslash/completionListInNamedClassExpressionWithShadowing.ts @@ -15,26 +15,9 @@ //// /*5*/ //// } -goTo.marker("0"); -verify.not.completionListContains("myClass", "class myClass", /*documentation*/ undefined, "class"); -verify.not.completionListContains("myClass", "(local class) myClass", /*documentation*/ undefined, "local class"); - -goTo.marker("1"); -verify.completionListContains("myClass", "class myClass", /*documentation*/ undefined, "class"); -verify.not.completionListContains("myClass", "(local class) myClass", /*documentation*/ undefined, "local class"); - -goTo.marker("2"); -verify.completionListContains("myClass", "(local class) myClass", /*documentation*/ undefined, "local class"); -verify.not.completionListContains("myClass", "class myClass", /*documentation*/ undefined, "class"); - -goTo.marker("3"); -verify.not.completionListContains("myClass", "(local class) myClass", /*documentation*/ undefined, "local class"); -verify.not.completionListContains("myClass", "class myClass", /*documentation*/ undefined, "class"); - -goTo.marker("4"); -verify.completionListContains("myClass", "class myClass", /*documentation*/ undefined, "class"); -verify.not.completionListContains("myClass", "(local class) myClass", /*documentation*/ undefined, "local class"); - -goTo.marker("5"); -verify.not.completionListContains("myClass", "class myClass", /*documentation*/ undefined, "class"); -verify.not.completionListContains("myClass", "(local class) myClass", /*documentation*/ undefined, "local class"); +verify.completions( + { marker: "0", excludes: "myClass", isNewIdentifierLocation: true }, + { marker: ["1", "4"], includes: { name: "myClass", text: "class myClass", kind: "class" } }, + { marker: "2", includes: { name: "myClass", text: "(local class) myClass", kind: "local class" } }, + { marker: ["3", "5"], excludes: "myClass", isNewIdentifierLocation: true }, +); diff --git a/tests/cases/fourslash/completionListInNamedFunctionExpression.ts b/tests/cases/fourslash/completionListInNamedFunctionExpression.ts index d136ea45e9eb0..47973ddf8d221 100644 --- a/tests/cases/fourslash/completionListInNamedFunctionExpression.ts +++ b/tests/cases/fourslash/completionListInNamedFunctionExpression.ts @@ -14,14 +14,7 @@ /////*globalScope*/ ////fo/*referenceInGlobalScope*/o; -goTo.marker("globalScope"); -verify.completionListContains("foo"); - -goTo.marker("insideFunctionDeclaration"); -verify.completionListContains("foo"); - -goTo.marker("insideFunctionExpression"); -verify.completionListContains("foo"); +verify.completions({ marker: ["globalScope", "insideFunctionDeclaration", "insideFunctionExpression"], includes: "foo" }); verify.quickInfos({ referenceInsideFunctionExpression: "(local function) foo(): number", diff --git a/tests/cases/fourslash/completionListInNamedFunctionExpression1.ts b/tests/cases/fourslash/completionListInNamedFunctionExpression1.ts index bb64e04b93b09..b8162894c0b82 100644 --- a/tests/cases/fourslash/completionListInNamedFunctionExpression1.ts +++ b/tests/cases/fourslash/completionListInNamedFunctionExpression1.ts @@ -4,5 +4,4 @@ //// /*1*/ //// } -goTo.marker("1"); -verify.completionListContains("foo", "(local function) foo(): void", /*documentation*/ undefined, "local function"); \ No newline at end of file +verify.completions({ marker: "1", includes: { name: "foo", text: "(local function) foo(): void", kind: "local function" } }); diff --git a/tests/cases/fourslash/completionListInNamedFunctionExpressionWithShadowing.ts b/tests/cases/fourslash/completionListInNamedFunctionExpressionWithShadowing.ts index 14965253e8439..d73c8ed372061 100644 --- a/tests/cases/fourslash/completionListInNamedFunctionExpressionWithShadowing.ts +++ b/tests/cases/fourslash/completionListInNamedFunctionExpressionWithShadowing.ts @@ -9,14 +9,7 @@ //// /*2*/ //// } -goTo.marker("0"); -verify.completionListContains("foo", "function foo(): void", /*documentation*/ undefined, "function"); -verify.not.completionListContains("foo", "(local function) foo(): void", /*documentation*/ undefined, "local function");; - -goTo.marker("1"); -verify.completionListContains("foo", "(local function) foo(): void", /*documentation*/ undefined, "local function"); -verify.not.completionListContains("foo", "function foo(): void", /*documentation*/ undefined, "function");; - -goTo.marker("2"); -verify.completionListContains("foo", "function foo(): void", /*documentation*/ undefined, "function") -verify.not.completionListContains("foo", "(local function) foo(): void", /*documentation*/ undefined, "local function");; \ No newline at end of file +verify.completions( + { marker: ["0", "2"], includes: { name: "foo", text: "function foo(): void", kind: "function" } }, + { marker: "1", includes: { name: "foo", text: "(local function) foo(): void", kind: "local function" } }, +); diff --git a/tests/cases/fourslash/completionListInNamespaceImportName01.ts b/tests/cases/fourslash/completionListInNamespaceImportName01.ts index ac1c0e13e0739..10b502f8966eb 100644 --- a/tests/cases/fourslash/completionListInNamespaceImportName01.ts +++ b/tests/cases/fourslash/completionListInNamespaceImportName01.ts @@ -6,6 +6,4 @@ // @Filename: m2.ts ////import * as /**/ from "m1" -goTo.marker(); -verify.completionListIsEmpty(); -verify.completionListAllowsNewIdentifier(); \ No newline at end of file +verify.completions({ marker: "", exact: undefined, isNewIdentifierLocation: true }); diff --git a/tests/cases/fourslash/completionListInObjectBindingPattern01.ts b/tests/cases/fourslash/completionListInObjectBindingPattern01.ts index 99188457e6fd7..dc4adaa8d989c 100644 --- a/tests/cases/fourslash/completionListInObjectBindingPattern01.ts +++ b/tests/cases/fourslash/completionListInObjectBindingPattern01.ts @@ -8,7 +8,4 @@ ////var foo: I; ////var { /**/ } = foo; -goTo.marker(); -verify.completionListContains("property1"); -verify.completionListContains("property2"); -verify.not.completionListAllowsNewIdentifier(); \ No newline at end of file +verify.completions({ marker: "", exact: ["property1", "property2"] }); diff --git a/tests/cases/fourslash/completionListInObjectBindingPattern02.ts b/tests/cases/fourslash/completionListInObjectBindingPattern02.ts index 0cd86c8d1a655..33881d6978b9a 100644 --- a/tests/cases/fourslash/completionListInObjectBindingPattern02.ts +++ b/tests/cases/fourslash/completionListInObjectBindingPattern02.ts @@ -8,7 +8,4 @@ ////var foo: I; ////var { property1, /**/ } = foo; -goTo.marker(); -verify.completionListContains("property2"); -verify.not.completionListContains("property1"); -verify.not.completionListAllowsNewIdentifier(); \ No newline at end of file +verify.completions({ marker: "", exact: "property2" }); diff --git a/tests/cases/fourslash/completionListInObjectBindingPattern03.ts b/tests/cases/fourslash/completionListInObjectBindingPattern03.ts index 72da68168bde9..895f03a186df1 100644 --- a/tests/cases/fourslash/completionListInObjectBindingPattern03.ts +++ b/tests/cases/fourslash/completionListInObjectBindingPattern03.ts @@ -8,6 +8,4 @@ ////var foo: I; ////var { property1: /**/ } = foo; -goTo.marker(); -verify.completionListAllowsNewIdentifier(); -verify.completionListIsEmpty(); \ No newline at end of file +verify.completions({ marker: "", exact: undefined, isNewIdentifierLocation: true }); diff --git a/tests/cases/fourslash/completionListInObjectBindingPattern04.ts b/tests/cases/fourslash/completionListInObjectBindingPattern04.ts index e6057ec0fae54..2e093274f9b05 100644 --- a/tests/cases/fourslash/completionListInObjectBindingPattern04.ts +++ b/tests/cases/fourslash/completionListInObjectBindingPattern04.ts @@ -8,7 +8,4 @@ ////var foo: I; ////var { prope/**/ } = foo; -goTo.marker(); -verify.completionListContains("property1"); -verify.completionListContains("property2"); -verify.not.completionListAllowsNewIdentifier(); \ No newline at end of file +verify.completions({ marker: "", exact: ["property1", "property2"] }); diff --git a/tests/cases/fourslash/completionListInObjectBindingPattern05.ts b/tests/cases/fourslash/completionListInObjectBindingPattern05.ts index d0876ed6a349e..e3a75457db885 100644 --- a/tests/cases/fourslash/completionListInObjectBindingPattern05.ts +++ b/tests/cases/fourslash/completionListInObjectBindingPattern05.ts @@ -8,6 +8,4 @@ ////var foo: I; ////var { property1/**/ } = foo; -goTo.marker(); -verify.completionListContains("property1"); -verify.not.completionListAllowsNewIdentifier(); \ No newline at end of file +verify.completions({ marker: "", exact: ["property1", "property2"] }); diff --git a/tests/cases/fourslash/completionListInObjectBindingPattern06.ts b/tests/cases/fourslash/completionListInObjectBindingPattern06.ts index 8060c2bde78a2..d79659c5f6d11 100644 --- a/tests/cases/fourslash/completionListInObjectBindingPattern06.ts +++ b/tests/cases/fourslash/completionListInObjectBindingPattern06.ts @@ -8,5 +8,4 @@ ////var foo: I; ////var { property1, property2, /**/ } = foo; -goTo.marker(); -verify.completionListIsEmpty(); \ No newline at end of file +verify.completions({ marker: "", exact: undefined }); diff --git a/tests/cases/fourslash/completionListInObjectBindingPattern07.ts b/tests/cases/fourslash/completionListInObjectBindingPattern07.ts index 4db3fc383d4c4..6eff9015cbb9d 100644 --- a/tests/cases/fourslash/completionListInObjectBindingPattern07.ts +++ b/tests/cases/fourslash/completionListInObjectBindingPattern07.ts @@ -12,8 +12,4 @@ ////var foo: J; ////var { property1: { /**/ } } = foo; -goTo.marker(); -verify.completionListContains("propertyOfI_1"); -verify.completionListContains("propertyOfI_2"); -verify.not.completionListContains("property2"); -verify.not.completionListAllowsNewIdentifier(); \ No newline at end of file +verify.completions({ marker: "", exact: ["propertyOfI_1", "propertyOfI_2"] }); diff --git a/tests/cases/fourslash/completionListInObjectBindingPattern08.ts b/tests/cases/fourslash/completionListInObjectBindingPattern08.ts index b062ca702a27e..5d74383e187cc 100644 --- a/tests/cases/fourslash/completionListInObjectBindingPattern08.ts +++ b/tests/cases/fourslash/completionListInObjectBindingPattern08.ts @@ -12,8 +12,4 @@ ////var foo: J; ////var { property1: { propertyOfI_1, /**/ } } = foo; -goTo.marker(); -verify.completionListContains("propertyOfI_2"); -verify.not.completionListContains("propertyOfI_1"); -verify.not.completionListContains("property2"); -verify.not.completionListAllowsNewIdentifier(); \ No newline at end of file +verify.completions({ marker: "", exact: "propertyOfI_2" }); diff --git a/tests/cases/fourslash/completionListInObjectBindingPattern09.ts b/tests/cases/fourslash/completionListInObjectBindingPattern09.ts index 61b31385b35ca..812f8946f1eab 100644 --- a/tests/cases/fourslash/completionListInObjectBindingPattern09.ts +++ b/tests/cases/fourslash/completionListInObjectBindingPattern09.ts @@ -12,9 +12,4 @@ ////var foo: J; ////var { property1: { propertyOfI_1, }, /**/ } = foo; -goTo.marker(); -verify.completionListContains("property2"); -verify.not.completionListContains("property1"); -verify.not.completionListContains("propertyOfI_2"); -verify.not.completionListContains("propertyOfI_1"); -verify.not.completionListAllowsNewIdentifier(); \ No newline at end of file +verify.completions({ marker: "", exact: ["property2"] }); diff --git a/tests/cases/fourslash/completionListInObjectBindingPattern10.ts b/tests/cases/fourslash/completionListInObjectBindingPattern10.ts index 836e12fd8a33b..79776b13d3aea 100644 --- a/tests/cases/fourslash/completionListInObjectBindingPattern10.ts +++ b/tests/cases/fourslash/completionListInObjectBindingPattern10.ts @@ -12,14 +12,7 @@ ////var foo: J[]; ////var [{ property1: { propertyOfI_1, }, /*1*/ }, { /*2*/ }] = foo; -goTo.marker("1"); -verify.completionListContains("property2"); -verify.not.completionListContains("property1"); -verify.not.completionListContains("propertyOfI_2"); -verify.not.completionListContains("propertyOfI_1"); -verify.not.completionListAllowsNewIdentifier(); - -goTo.marker("2"); -verify.completionListContains("property1"); -verify.completionListContains("property2"); -verify.not.completionListAllowsNewIdentifier(); \ No newline at end of file +verify.completions( + { marker: "1", exact: "property2" }, + { marker: "2", exact: ["property1", "property2"] }, +); diff --git a/tests/cases/fourslash/completionListInObjectBindingPattern11.ts b/tests/cases/fourslash/completionListInObjectBindingPattern11.ts index 57a32578026ce..ea1479f72b08c 100644 --- a/tests/cases/fourslash/completionListInObjectBindingPattern11.ts +++ b/tests/cases/fourslash/completionListInObjectBindingPattern11.ts @@ -7,8 +7,4 @@ //// ////var { property1: prop1, /**/ }: I; -goTo.marker(""); -verify.completionListContains("property2"); -verify.not.completionListContains("property1"); -verify.not.completionListContains("prop1"); -verify.not.completionListAllowsNewIdentifier(); \ No newline at end of file +verify.completions({ marker: "", exact: "property2" }); diff --git a/tests/cases/fourslash/completionListInObjectBindingPattern12.ts b/tests/cases/fourslash/completionListInObjectBindingPattern12.ts index 59af2da38d22f..8941dda7f6512 100644 --- a/tests/cases/fourslash/completionListInObjectBindingPattern12.ts +++ b/tests/cases/fourslash/completionListInObjectBindingPattern12.ts @@ -8,7 +8,4 @@ ////function f({ property1, /**/ }: I): void { ////} -goTo.marker(""); -verify.completionListContains("property2"); -verify.not.completionListContains("property1"); -verify.not.completionListAllowsNewIdentifier(); \ No newline at end of file +verify.completions({ marker: "", includes: "property2", excludes: "property1" }); diff --git a/tests/cases/fourslash/completionListInObjectBindingPattern13.ts b/tests/cases/fourslash/completionListInObjectBindingPattern13.ts index 8081d2ee23baf..d1223a731bf7b 100644 --- a/tests/cases/fourslash/completionListInObjectBindingPattern13.ts +++ b/tests/cases/fourslash/completionListInObjectBindingPattern13.ts @@ -13,8 +13,4 @@ //// ////let { /**/ }: I | J = { x: 10 }; -goTo.marker(); -verify.completionListContains("x"); -verify.completionListContains("y"); -verify.not.completionListContains("z"); -verify.not.completionListAllowsNewIdentifier(); \ No newline at end of file +verify.completions({ marker: "", exact: ["x", "y"] }); diff --git a/tests/cases/fourslash/completionListInObjectBindingPattern14.ts b/tests/cases/fourslash/completionListInObjectBindingPattern14.ts index 425813a5543e3..4f1015d52371d 100644 --- a/tests/cases/fourslash/completionListInObjectBindingPattern14.ts +++ b/tests/cases/fourslash/completionListInObjectBindingPattern14.ts @@ -5,5 +5,4 @@ //// protected bc; ////} -goTo.marker(); -verify.completionListIsEmpty(); +verify.completions({ marker: "", exact: undefined }); diff --git a/tests/cases/fourslash/completionListInObjectLiteral.ts b/tests/cases/fourslash/completionListInObjectLiteral.ts index 4d0aca29f8d7c..b7125f27e1fde 100644 --- a/tests/cases/fourslash/completionListInObjectLiteral.ts +++ b/tests/cases/fourslash/completionListInObjectLiteral.ts @@ -11,6 +11,4 @@ ////var t: thing; ////t.pos = { x: 4, y: 3 + t./**/ }; -goTo.marker(); -verify.not.completionListContains('x'); -verify.completionListContains('name'); \ No newline at end of file +verify.completions({ marker: "", exact: ["name", "pos"] }); diff --git a/tests/cases/fourslash/completionListInObjectLiteral2.ts b/tests/cases/fourslash/completionListInObjectLiteral2.ts index dad1d3bc249b3..34925d616a622 100644 --- a/tests/cases/fourslash/completionListInObjectLiteral2.ts +++ b/tests/cases/fourslash/completionListInObjectLiteral2.ts @@ -12,7 +12,7 @@ ////class Foo { //// public telemetryService: TelemetryService; // If telemetry service is of type 'any' (i.e. uncomment below line), the drop-down list works -//// public telemetryService2; +//// public telemetryService2; //// private test() { //// var onComplete = (searchResult: SearchResult) => { //// var hasResults = !searchResult.isEmpty(); // Drop-down list on searchResult fine here @@ -23,12 +23,4 @@ //// } ////} -goTo.marker('1'); -verify.completionListContains('count'); -verify.completionListContains('isEmpty'); -verify.completionListContains('fileCount'); - -goTo.marker('2'); -verify.completionListContains('count'); -verify.completionListContains('isEmpty'); -verify.completionListContains('fileCount'); +verify.completions({ marker: test.markers(), exact: ["count", "isEmpty", "fileCount"] }); diff --git a/tests/cases/fourslash/completionListInObjectLiteral3.ts b/tests/cases/fourslash/completionListInObjectLiteral3.ts index f69a3c0e01fc7..7fa7de331be59 100644 --- a/tests/cases/fourslash/completionListInObjectLiteral3.ts +++ b/tests/cases/fourslash/completionListInObjectLiteral3.ts @@ -8,8 +8,4 @@ //// /**/ ////} -goTo.marker() -verify.completionListContains('name'); -verify.completionListContains('children'); -verify.not.completionListContains('any'); -verify.not.completionListContains('number'); +verify.completions({ marker: "", exact: ["name", "children"] }); diff --git a/tests/cases/fourslash/completionListInObjectLiteral4.ts b/tests/cases/fourslash/completionListInObjectLiteral4.ts index 3094b4db6ad4f..57b13385049b8 100644 --- a/tests/cases/fourslash/completionListInObjectLiteral4.ts +++ b/tests/cases/fourslash/completionListInObjectLiteral4.ts @@ -20,7 +20,4 @@ ////funcE({ /*E*/ }); ////funcF({ /*F*/ }); -goTo.eachMarker(() => { - verify.completionListContains("hello"); - verify.completionListContains("world"); -}); +verify.completions({ marker: test.markers(), exact: ["hello", "world"] }); diff --git a/tests/cases/fourslash/completionListInObjectLiteralPropertyAssignment.ts b/tests/cases/fourslash/completionListInObjectLiteralPropertyAssignment.ts index 14ccd985577ee..eaa062426775e 100644 --- a/tests/cases/fourslash/completionListInObjectLiteralPropertyAssignment.ts +++ b/tests/cases/fourslash/completionListInObjectLiteralPropertyAssignment.ts @@ -9,7 +9,4 @@ //// metadata: "/*1*/ ////} -goTo.marker('1'); - -verify.not.completionListContains("metadata"); -verify.not.completionListContains("wat"); \ No newline at end of file +verify.completions({ marker: "1", exact: [] }); diff --git a/tests/cases/fourslash/completionListInObjectLiteralThatIsParameterOfFunctionCall.ts b/tests/cases/fourslash/completionListInObjectLiteralThatIsParameterOfFunctionCall.ts index 94a1ba5c70711..c72ac67194b47 100644 --- a/tests/cases/fourslash/completionListInObjectLiteralThatIsParameterOfFunctionCall.ts +++ b/tests/cases/fourslash/completionListInObjectLiteralThatIsParameterOfFunctionCall.ts @@ -5,7 +5,4 @@ ////f({ //// /**/ -goTo.marker() -verify.completionListContains('xa'); -verify.completionListContains('xb'); -verify.completionListCount(2); \ No newline at end of file +verify.completions({ marker: "", exact: ["xa", "xb"] }); diff --git a/tests/cases/fourslash/completionListInScope.ts b/tests/cases/fourslash/completionListInScope.ts index 70f82b80f5f35..00317438e91fb 100644 --- a/tests/cases/fourslash/completionListInScope.ts +++ b/tests/cases/fourslash/completionListInScope.ts @@ -2,7 +2,7 @@ ////module TestModule { //// var localVariable = ""; -//// export var exportedVaribale = 0; +//// export var exportedVariable = 0; //// //// function localFunction() { } //// export function exportedFunction() { } @@ -27,7 +27,7 @@ ////// Add some new items to the module ////module TestModule { //// var localVariable2 = ""; -//// export var exportedVaribale2 = 0; +//// export var exportedVariable2 = 0; //// //// function localFunction2() { } //// export function exportedFunction2() { } @@ -59,46 +59,53 @@ //// } ////} - -goTo.marker("valueReference"); -verify.completionListContains("localVariable"); -verify.completionListContains("exportedVaribale"); - -verify.completionListContains("localFunction"); -verify.completionListContains("exportedFunction"); - -verify.completionListContains("localClass"); -verify.completionListContains("exportedClass"); - -verify.completionListContains("localModule"); -verify.completionListContains("exportedModule"); - -verify.completionListContains("exportedVaribale2"); -verify.completionListContains("exportedFunction2"); -verify.completionListContains("exportedClass2"); -verify.completionListContains("exportedModule2"); - -goTo.marker("typeReference"); -verify.completionListContains("localInterface"); -verify.completionListContains("exportedInterface"); - -verify.completionListContains("localClass"); -verify.completionListContains("exportedClass"); - -verify.not.completionListContains("localModule"); -verify.not.completionListContains("exportedModule"); - -verify.completionListContains("exportedClass2"); -verify.not.completionListContains("exportedModule2"); - -goTo.marker("insideMethod"); -verify.not.completionListContains("property"); -verify.not.completionListContains("testMethod"); -verify.not.completionListContains("staticMethod"); - -verify.completionListContains("globalVar"); -verify.completionListContains("globalFunction"); - -verify.completionListContains("param"); -verify.completionListContains("localVar"); -verify.completionListContains("localFunction"); +verify.completions( + { + marker: "valueReference", + includes: [ + "localVariable", + "exportedVariable", + "localFunction", + "exportedFunction", + "localClass", + "exportedClass", + "localModule", + "exportedModule", + "exportedVariable2", + "exportedFunction2", + "exportedClass2", + "exportedModule2", + ], + isNewIdentifierLocation: true, // TODO: Should not be a new identifier location + }, + { + marker: "typeReference", + includes: [ + "localInterface", + "exportedInterface", + "localClass", + "exportedClass", + "exportedClass2", + ], + excludes: [ + "localModule", + "exportedModule", + "exportedModule2", + ], + }, + { + marker: "insideMethod", + includes: [ + "globalVar", + "globalFunction", + "param", + "localVar", + "localFunction", + ], + excludes: [ + "property", + "testMethod", + "staticMethod", + ], + }, +); diff --git a/tests/cases/fourslash/completionListInScope_doesNotIncludeAugmentations.ts b/tests/cases/fourslash/completionListInScope_doesNotIncludeAugmentations.ts index de70890c4c6d5..2432573314a6e 100644 --- a/tests/cases/fourslash/completionListInScope_doesNotIncludeAugmentations.ts +++ b/tests/cases/fourslash/completionListInScope_doesNotIncludeAugmentations.ts @@ -9,5 +9,4 @@ //// /////**/ -goTo.marker(); -verify.not.completionListContains("a"); +verify.completions({ marker: "", excludes: "a" }); diff --git a/tests/cases/fourslash/completionListInStringLiterals1.ts b/tests/cases/fourslash/completionListInStringLiterals1.ts index aabcc82eba581..2f6d59bf2d0c0 100644 --- a/tests/cases/fourslash/completionListInStringLiterals1.ts +++ b/tests/cases/fourslash/completionListInStringLiterals1.ts @@ -3,4 +3,4 @@ ////"/*1*/ /*2*/\/*3*/ //// /*4*/ \\/*5*/ -goTo.eachMarker(() => verify.completionListIsEmpty()); +verify.completions({ marker: test.markers(), exact: [] }); diff --git a/tests/cases/fourslash/completionListInStringLiterals2.ts b/tests/cases/fourslash/completionListInStringLiterals2.ts index 4ffd5eb8a9b6d..c4e680c638709 100644 --- a/tests/cases/fourslash/completionListInStringLiterals2.ts +++ b/tests/cases/fourslash/completionListInStringLiterals2.ts @@ -4,4 +4,4 @@ //// /*4*/ \\\/*5*/ //// /*6*/ -goTo.eachMarker(() => verify.completionListIsEmpty()); +verify.completions({ marker: test.markers(), exact: [] }); diff --git a/tests/cases/fourslash/completionListInTemplateLiteralParts1.ts b/tests/cases/fourslash/completionListInTemplateLiteralParts1.ts index 9de7b6a6a5b58..509b08c80c274 100644 --- a/tests/cases/fourslash/completionListInTemplateLiteralParts1.ts +++ b/tests/cases/fourslash/completionListInTemplateLiteralParts1.ts @@ -4,4 +4,7 @@ //// /////*6*/`asdasd${/*7*/ 2 + 1.1 /*8*/} 12312 { -goTo.eachMarker(() => verify.completionListItemsCountIsGreaterThan(0)); +verify.completions( + { marker: ["1", "7"], exact: completion.globals, isNewIdentifierLocation: true }, + { marker: ["2", "3", "4", "5", "6", "8"], exact: completion.globals }, +); diff --git a/tests/cases/fourslash/completionListInTemplateLiteralPartsNegatives1.ts b/tests/cases/fourslash/completionListInTemplateLiteralPartsNegatives1.ts index 30af0678e7d80..1c482cdc67d7e 100644 --- a/tests/cases/fourslash/completionListInTemplateLiteralPartsNegatives1.ts +++ b/tests/cases/fourslash/completionListInTemplateLiteralPartsNegatives1.ts @@ -4,4 +4,4 @@ //// ////`asdasd$/*7*/{ 2 + 1.1 }/*8*/ 12312 /*9*/{/*10*/ -goTo.eachMarker(() => verify.completionListIsEmpty()); +verify.completions({ marker: test.markers(), exact: undefined }); diff --git a/tests/cases/fourslash/completionListInTypeParameterOfClassExpression1.ts b/tests/cases/fourslash/completionListInTypeParameterOfClassExpression1.ts index f8afcdc418c3f..290aa3a7ef63d 100644 --- a/tests/cases/fourslash/completionListInTypeParameterOfClassExpression1.ts +++ b/tests/cases/fourslash/completionListInTypeParameterOfClassExpression1.ts @@ -2,17 +2,9 @@ ////var C0 = class D {} -////var C3 = class D{} -////var C5 = class D{} +////var C2 = class D{} +////var C4 = class D{} -goTo.marker("0"); -verify.completionListIsEmpty(); -goTo.marker("1"); -verify.completionListIsEmpty(); -goTo.marker("2"); -verify.completionListIsEmpty(); -goTo.marker("3"); -verify.completionListIsEmpty(); -goTo.marker("4"); -verify.not.completionListIsEmpty(); \ No newline at end of file +verify.completions({ marker: ["0", "1", "2", "3"], exact: undefined }); +verify.completions({ marker: "4", exact: ["D", ...completion.globalsPlus(["C0", "C1", "C2", "C3", "C4"])] }); diff --git a/tests/cases/fourslash/completionListInTypeParameterOfTypeAlias1.ts b/tests/cases/fourslash/completionListInTypeParameterOfTypeAlias1.ts index 57931c7b6d1de..b3ca601b6dbd5 100644 --- a/tests/cases/fourslash/completionListInTypeParameterOfTypeAlias1.ts +++ b/tests/cases/fourslash/completionListInTypeParameterOfTypeAlias1.ts @@ -5,13 +5,8 @@ ////type List4 = /*2*/T[]; ////type List3 = /*3*/; -goTo.marker("0"); -verify.completionListIsEmpty(); -goTo.marker("1"); -verify.completionListIsEmpty(); -goTo.marker("2"); -verify.completionListContains("T"); -goTo.marker("3"); -verify.not.completionListIsEmpty(); -verify.not.completionListContains("T"); -verify.completionListContains("T1"); \ No newline at end of file +verify.completions( + { marker: ["0", "1"], exact: undefined }, + { marker: "2", includes: "T" }, + { marker: "3", includes: "T1", excludes: "T" }, +); diff --git a/tests/cases/fourslash/completionListInTypeParameterOfTypeAlias2.ts b/tests/cases/fourslash/completionListInTypeParameterOfTypeAlias2.ts index 44f7342029e55..f4e184a8c0a67 100644 --- a/tests/cases/fourslash/completionListInTypeParameterOfTypeAlias2.ts +++ b/tests/cases/fourslash/completionListInTypeParameterOfTypeAlias2.ts @@ -5,15 +5,8 @@ ////type Map1 = /*2*/[]; ////type Map1 = = new a,/*1*/ -goTo.marker("1"); -verify.not.completionListContains("a"); -verify.not.completionListContains("b"); \ No newline at end of file +verify.completions({ marker: "1", excludes: ["a", "b"], isNewIdentifierLocation: true }); diff --git a/tests/cases/fourslash/completionListInUnclosedCommaExpression02.ts b/tests/cases/fourslash/completionListInUnclosedCommaExpression02.ts index e0ea3abbd3815..44f579c653b3f 100644 --- a/tests/cases/fourslash/completionListInUnclosedCommaExpression02.ts +++ b/tests/cases/fourslash/completionListInUnclosedCommaExpression02.ts @@ -3,6 +3,4 @@ ////// should NOT see a and b ////foo((a, b) => (a,/*1*/ -goTo.marker("1"); -verify.completionListContains("a"); -verify.completionListContains("b"); \ No newline at end of file +verify.completions({ marker: "1", includes: ["a", "b"], isNewIdentifierLocation: true }); diff --git a/tests/cases/fourslash/completionListInUnclosedDeleteExpression01.ts b/tests/cases/fourslash/completionListInUnclosedDeleteExpression01.ts index fdb67dfc3354a..28a850737ed8c 100644 --- a/tests/cases/fourslash/completionListInUnclosedDeleteExpression01.ts +++ b/tests/cases/fourslash/completionListInUnclosedDeleteExpression01.ts @@ -3,5 +3,4 @@ ////var x; ////var y = delete /*1*/ -goTo.marker("1"); -verify.completionListContains("x"); \ No newline at end of file +verify.completions({marker: "1", includes: "x" }); diff --git a/tests/cases/fourslash/completionListInUnclosedDeleteExpression02.ts b/tests/cases/fourslash/completionListInUnclosedDeleteExpression02.ts index 3573c345285bd..d0145bb8977d5 100644 --- a/tests/cases/fourslash/completionListInUnclosedDeleteExpression02.ts +++ b/tests/cases/fourslash/completionListInUnclosedDeleteExpression02.ts @@ -3,6 +3,4 @@ ////var x; ////var y = (p) => delete /*1*/ -goTo.marker("1"); -verify.completionListContains("x"); -verify.completionListContains("p"); \ No newline at end of file +verify.completions({ marker: "1", includes: ["x", "p"] }); diff --git a/tests/cases/fourslash/completionListInUnclosedElementAccessExpression01.ts b/tests/cases/fourslash/completionListInUnclosedElementAccessExpression01.ts index 59c4922671eaf..2c11029b9aa45 100644 --- a/tests/cases/fourslash/completionListInUnclosedElementAccessExpression01.ts +++ b/tests/cases/fourslash/completionListInUnclosedElementAccessExpression01.ts @@ -3,5 +3,4 @@ ////var x; ////var y = x[/*1*/ -goTo.marker("1"); -verify.completionListContains("x"); \ No newline at end of file +verify.completions({ marker: "1", includes: "x" }); diff --git a/tests/cases/fourslash/completionListInUnclosedElementAccessExpression02.ts b/tests/cases/fourslash/completionListInUnclosedElementAccessExpression02.ts index 1d6403cfa10af..b9f7d411ac6d6 100644 --- a/tests/cases/fourslash/completionListInUnclosedElementAccessExpression02.ts +++ b/tests/cases/fourslash/completionListInUnclosedElementAccessExpression02.ts @@ -3,6 +3,4 @@ ////var x; ////var y = (p) => x[/*1*/ -goTo.marker("1"); -verify.completionListContains("p"); -verify.completionListContains("x"); \ No newline at end of file +verify.completions({ marker: "1", includes: ["p", "x"] }); diff --git a/tests/cases/fourslash/completionListInUnclosedForLoop01.ts b/tests/cases/fourslash/completionListInUnclosedForLoop01.ts index 35e5efdd304d8..83cb4bb5c58ac 100644 --- a/tests/cases/fourslash/completionListInUnclosedForLoop01.ts +++ b/tests/cases/fourslash/completionListInUnclosedForLoop01.ts @@ -2,5 +2,4 @@ ////for (let i = 0; /*1*/ -goTo.marker("1"); -verify.completionListContains("i"); \ No newline at end of file +verify.completions({ marker: "1", includes: "i" }); diff --git a/tests/cases/fourslash/completionListInUnclosedForLoop02.ts b/tests/cases/fourslash/completionListInUnclosedForLoop02.ts index e79f428b2b066..c749ad57dbcb2 100644 --- a/tests/cases/fourslash/completionListInUnclosedForLoop02.ts +++ b/tests/cases/fourslash/completionListInUnclosedForLoop02.ts @@ -2,5 +2,4 @@ ////for (let i = 0; i < 10; i++) /*1*/ -goTo.marker("1"); -verify.completionListContains("i"); \ No newline at end of file +verify.completions({ marker: "1", includes: "i" }); diff --git a/tests/cases/fourslash/completionListInUnclosedIndexSignature01.ts b/tests/cases/fourslash/completionListInUnclosedIndexSignature01.ts index 0667742d4cb9e..07afc0d7c384a 100644 --- a/tests/cases/fourslash/completionListInUnclosedIndexSignature01.ts +++ b/tests/cases/fourslash/completionListInUnclosedIndexSignature01.ts @@ -5,6 +5,4 @@ //// [foo: string]: typeof /*1*/ ////} -goTo.marker("1"); -verify.completionListContains("foo"); -verify.completionListContains("C"); \ No newline at end of file +verify.completions({ marker: "1", includes: ["foo", "C"] }); diff --git a/tests/cases/fourslash/completionListInUnclosedIndexSignature02.ts b/tests/cases/fourslash/completionListInUnclosedIndexSignature02.ts index 54612d3efcf25..57b3268aeccc6 100644 --- a/tests/cases/fourslash/completionListInUnclosedIndexSignature02.ts +++ b/tests/cases/fourslash/completionListInUnclosedIndexSignature02.ts @@ -5,9 +5,6 @@ //// [foo: /*1*/ ////} -goTo.marker("1"); -verify.completionListContains("C"); -verify.not.completionListContains("foo"); // ideally this shouldn't show up for a type +verify.completions({ marker: "1", includes: "C", excludes: "foo" }); edit.insert("typeof "); -verify.completionListContains("C"); -verify.completionListContains("foo"); \ No newline at end of file +verify.completions({ includes: ["C", "foo"] }); diff --git a/tests/cases/fourslash/completionListInUnclosedIndexSignature03.ts b/tests/cases/fourslash/completionListInUnclosedIndexSignature03.ts index bb4ef808bff78..f21b987e396cc 100644 --- a/tests/cases/fourslash/completionListInUnclosedIndexSignature03.ts +++ b/tests/cases/fourslash/completionListInUnclosedIndexSignature03.ts @@ -5,6 +5,4 @@ //// [foo: string]: { x: typeof /*1*/ ////} -goTo.marker("1"); -verify.completionListContains("foo"); -verify.completionListContains("C"); \ No newline at end of file +verify.completions({ marker: "1", includes: ["foo", "C"] }); diff --git a/tests/cases/fourslash/completionListInUnclosedObjectTypeLiteralInSignature01.ts b/tests/cases/fourslash/completionListInUnclosedObjectTypeLiteralInSignature01.ts index ed4468b896a82..3d2710e74e056 100644 --- a/tests/cases/fourslash/completionListInUnclosedObjectTypeLiteralInSignature01.ts +++ b/tests/cases/fourslash/completionListInUnclosedObjectTypeLiteralInSignature01.ts @@ -7,12 +7,8 @@ //// ////declare function foo(obj: I): { str: T/*1*/ -goTo.marker("1"); - -verify.completionListContains("I"); -verify.completionListContains("TString"); -verify.completionListContains("TNumber"); - -// Ideally the following shouldn't show up since they're not types. -verify.not.completionListContains("foo"); -verify.not.completionListContains("obj"); +verify.completions({ + marker: "1", + includes: ["I", "TString", "TNumber"], + excludes: ["foo", "obj"], // not types +}); diff --git a/tests/cases/fourslash/completionListInUnclosedObjectTypeLiteralInSignature03.ts b/tests/cases/fourslash/completionListInUnclosedObjectTypeLiteralInSignature03.ts index 61fa09120070c..da975ba18f6b0 100644 --- a/tests/cases/fourslash/completionListInUnclosedObjectTypeLiteralInSignature03.ts +++ b/tests/cases/fourslash/completionListInUnclosedObjectTypeLiteralInSignature03.ts @@ -7,12 +7,8 @@ //// ////declare function foo(obj: I): { str: TString/*1*/ -goTo.marker("1"); - -verify.completionListContains("I"); -verify.completionListContains("TString"); -verify.completionListContains("TNumber"); // REVIEW: Is this intended behavior? - -// Ideally the following shouldn't show up since they're not types. -verify.not.completionListContains("foo"); -verify.not.completionListContains("obj"); +verify.completions({ + marker: "1", + includes: ["I", "TString", "TNumber"], + excludes: ["foo", "obj"], // not types +}); diff --git a/tests/cases/fourslash/completionListInUnclosedObjectTypeLiteralInSignature04.ts b/tests/cases/fourslash/completionListInUnclosedObjectTypeLiteralInSignature04.ts index 5a9731ca0e3b2..587db09d2676f 100644 --- a/tests/cases/fourslash/completionListInUnclosedObjectTypeLiteralInSignature04.ts +++ b/tests/cases/fourslash/completionListInUnclosedObjectTypeLiteralInSignature04.ts @@ -7,4 +7,4 @@ //// ////declare function foo(obj: I): { /*1*/ -verify.completionsAt("1", ["readonly"], { isNewIdentifierLocation: true }); +verify.completions({ marker: "1", exact: "readonly", isNewIdentifierLocation: true }); diff --git a/tests/cases/fourslash/completionListInUnclosedSpreadExpression01.ts b/tests/cases/fourslash/completionListInUnclosedSpreadExpression01.ts index b9cc01f0a66cb..a2ad320d48340 100644 --- a/tests/cases/fourslash/completionListInUnclosedSpreadExpression01.ts +++ b/tests/cases/fourslash/completionListInUnclosedSpreadExpression01.ts @@ -3,5 +3,4 @@ ////var x; ////var y = [1,2,.../*1*/ -goTo.marker("1"); -verify.completionListContains("x"); \ No newline at end of file +verify.completions({ marker: "1", includes: "x" }); diff --git a/tests/cases/fourslash/completionListInUnclosedSpreadExpression02.ts b/tests/cases/fourslash/completionListInUnclosedSpreadExpression02.ts index 40d90370232e8..94d2d67b3803f 100644 --- a/tests/cases/fourslash/completionListInUnclosedSpreadExpression02.ts +++ b/tests/cases/fourslash/completionListInUnclosedSpreadExpression02.ts @@ -3,6 +3,4 @@ ////var x; ////var y = (p) => [1,2,.../*1*/ -goTo.marker("1"); -verify.completionListContains("p"); -verify.completionListContains("x"); \ No newline at end of file +verify.completions({ marker: "1", includes: ["p", "x"] }); diff --git a/tests/cases/fourslash/completionListInUnclosedTaggedTemplate01.ts b/tests/cases/fourslash/completionListInUnclosedTaggedTemplate01.ts index 20e2a5d0663ed..6b0c3fd7eb158 100644 --- a/tests/cases/fourslash/completionListInUnclosedTaggedTemplate01.ts +++ b/tests/cases/fourslash/completionListInUnclosedTaggedTemplate01.ts @@ -3,6 +3,4 @@ ////var x; ////var y = (p) => x `abc ${ /*1*/ -goTo.marker("1"); -verify.completionListContains("p"); -verify.completionListContains("x"); \ No newline at end of file +verify.completions({ marker: "1", includes: ["p", "x"], isNewIdentifierLocation: true }); diff --git a/tests/cases/fourslash/completionListInUnclosedTaggedTemplate02.ts b/tests/cases/fourslash/completionListInUnclosedTaggedTemplate02.ts index d4bbd5992c63b..dc5f17cbebef8 100644 --- a/tests/cases/fourslash/completionListInUnclosedTaggedTemplate02.ts +++ b/tests/cases/fourslash/completionListInUnclosedTaggedTemplate02.ts @@ -3,6 +3,4 @@ ////var x; ////var y = (p) => x `abc ${ 123 } ${ /*1*/ -goTo.marker("1"); -verify.completionListContains("p"); -verify.completionListContains("x"); \ No newline at end of file +verify.completions({ marker: "1", includes: ["p", "x"], isNewIdentifierLocation: true }); diff --git a/tests/cases/fourslash/completionListInUnclosedTemplate01.ts b/tests/cases/fourslash/completionListInUnclosedTemplate01.ts index c7b8f62817044..6f9f99b2106e3 100644 --- a/tests/cases/fourslash/completionListInUnclosedTemplate01.ts +++ b/tests/cases/fourslash/completionListInUnclosedTemplate01.ts @@ -3,6 +3,4 @@ ////var x; ////var y = (p) => `abc ${ /*1*/ -goTo.marker("1"); -verify.completionListContains("p"); -verify.completionListContains("x"); \ No newline at end of file +verify.completions({ marker: "1", includes: ["p", "x"], isNewIdentifierLocation: true }); diff --git a/tests/cases/fourslash/completionListInUnclosedTemplate02.ts b/tests/cases/fourslash/completionListInUnclosedTemplate02.ts index 5fd5c94ee3eb2..6e53aff9b8072 100644 --- a/tests/cases/fourslash/completionListInUnclosedTemplate02.ts +++ b/tests/cases/fourslash/completionListInUnclosedTemplate02.ts @@ -3,6 +3,4 @@ ////var x; ////var y = (p) => `abc ${ 123 } ${ /*1*/ -goTo.marker("1"); -verify.completionListContains("p"); -verify.completionListContains("x"); \ No newline at end of file +verify.completions({ marker: "1", includes: ["p", "x"], isNewIdentifierLocation: true }); diff --git a/tests/cases/fourslash/completionListInUnclosedTypeArguments.ts b/tests/cases/fourslash/completionListInUnclosedTypeArguments.ts index 43458be9ff43e..31397518ed833 100644 --- a/tests/cases/fourslash/completionListInUnclosedTypeArguments.ts +++ b/tests/cases/fourslash/completionListInUnclosedTypeArguments.ts @@ -11,32 +11,26 @@ ////f(); //// ////f2 -////f2 -////f2(); +////f2 +////f2 +////f2(); //// -////f2/*4x*/T/*5x*/y/*6x*/ ////f2<() =>/*1y*/T/*2y*/y/*3y*/, () =>/*4y*/T/*5y*/y/*6y*/ ////f2/*1z*/T/*2z*/y/*3z*/ - -goTo.eachMarker((marker) => { - const markerName = test.markerName(marker); - if (markerName.endsWith("TypeOnly")) { - verify.not.completionListContains("x"); - } - else { - verify.completionListContains("x"); - } - - if (markerName.endsWith("ValueOnly")) { - verify.not.completionListContains("Type"); - } - else { - verify.completionListContains("Type"); - } -}); \ No newline at end of file +goTo.eachMarker(marker => { + const markerName = test.markerName(marker) || ""; + const typeOnly = markerName.endsWith("TypeOnly") || marker.data && marker.data.typeOnly; + const valueOnly = markerName.endsWith("ValueOnly"); + verify.completions({ + marker, + includes: typeOnly ? "Type" : valueOnly ? "x" : ["Type", "x"], + excludes: typeOnly ? "x" : valueOnly ? "Type" : [], + isNewIdentifierLocation: marker.data && marker.data.newId || false, + }); +}); diff --git a/tests/cases/fourslash/completionListInUnclosedTypeOfExpression01.ts b/tests/cases/fourslash/completionListInUnclosedTypeOfExpression01.ts index 3da8b4fd6169f..079173b02e6f8 100644 --- a/tests/cases/fourslash/completionListInUnclosedTypeOfExpression01.ts +++ b/tests/cases/fourslash/completionListInUnclosedTypeOfExpression01.ts @@ -3,5 +3,4 @@ ////var x; ////var y = typeof /*1*/ -goTo.marker("1"); -verify.completionListContains("x"); \ No newline at end of file +verify.completions({ marker: "1", includes: "x" }); diff --git a/tests/cases/fourslash/completionListInUnclosedTypeOfExpression02.ts b/tests/cases/fourslash/completionListInUnclosedTypeOfExpression02.ts index b1d347211ac69..7f3e9b17ddbcc 100644 --- a/tests/cases/fourslash/completionListInUnclosedTypeOfExpression02.ts +++ b/tests/cases/fourslash/completionListInUnclosedTypeOfExpression02.ts @@ -3,6 +3,4 @@ ////var x; ////var y = (p) => typeof /*1*/ -goTo.marker("1"); -verify.completionListContains("x"); -verify.completionListContains("p"); \ No newline at end of file +verify.completions({ marker: "1", includes: ["x", "p"] }); diff --git a/tests/cases/fourslash/completionListInUnclosedVoidExpression01.ts b/tests/cases/fourslash/completionListInUnclosedVoidExpression01.ts index d1cfecbffec3b..a51b9b5f9f3b6 100644 --- a/tests/cases/fourslash/completionListInUnclosedVoidExpression01.ts +++ b/tests/cases/fourslash/completionListInUnclosedVoidExpression01.ts @@ -3,6 +3,4 @@ ////var x; ////var y = (p) => void /*1*/ -goTo.marker("1"); -verify.completionListContains("p"); -verify.completionListContains("x"); \ No newline at end of file +verify.completions({ marker: "1", includes: ["p", "x"] }); diff --git a/tests/cases/fourslash/completionListInUnclosedYieldExpression01.ts b/tests/cases/fourslash/completionListInUnclosedYieldExpression01.ts index 658b0de7dc812..89b50e7bff5e1 100644 --- a/tests/cases/fourslash/completionListInUnclosedYieldExpression01.ts +++ b/tests/cases/fourslash/completionListInUnclosedYieldExpression01.ts @@ -3,8 +3,5 @@ ////var x; ////var y = function* gen(p) { yield /*1*/ -goTo.marker("1"); // These tentatively don't work. -verify.not.completionListContains("p"); -verify.not.completionListContains("gen"); -verify.not.completionListContains("x"); \ No newline at end of file +verify.completions({ marker: "1", exact: undefined }); diff --git a/tests/cases/fourslash/completionListInsideTargetTypedFunction.ts b/tests/cases/fourslash/completionListInsideTargetTypedFunction.ts index 68d7f3081f7bc..2ab796f7d8206 100644 --- a/tests/cases/fourslash/completionListInsideTargetTypedFunction.ts +++ b/tests/cases/fourslash/completionListInsideTargetTypedFunction.ts @@ -5,5 +5,4 @@ //// var foo: iFace = function (elem) { /**/ } ////} -goTo.marker(); -verify.completionListContains("elem", "(parameter) elem: string"); \ No newline at end of file +verify.completions({ marker: "", includes: { name: "elem", text: "(parameter) elem: string" } }); diff --git a/tests/cases/fourslash/completionListInstanceProtectedMembers.ts b/tests/cases/fourslash/completionListInstanceProtectedMembers.ts index 87207db733a2a..7e39a21bf5a2f 100644 --- a/tests/cases/fourslash/completionListInstanceProtectedMembers.ts +++ b/tests/cases/fourslash/completionListInstanceProtectedMembers.ts @@ -29,35 +29,14 @@ //// protected protectedOverriddenProperty; ////} - -// Same class, everything is visible -goTo.marker("1"); -verify.completionListContains('privateMethod'); -verify.completionListContains('privateProperty'); -verify.completionListContains('protectedMethod'); -verify.completionListContains('protectedProperty'); -verify.completionListContains('publicMethod'); -verify.completionListContains('publicProperty'); -verify.completionListContains('protectedOverriddenMethod'); -verify.completionListContains('protectedOverriddenProperty'); - -goTo.marker("2"); -verify.completionListContains('privateMethod'); -verify.completionListContains('privateProperty'); -verify.completionListContains('protectedMethod'); -verify.completionListContains('protectedProperty'); -verify.completionListContains('publicMethod'); -verify.completionListContains('publicProperty'); -verify.completionListContains('protectedOverriddenMethod'); -verify.completionListContains('protectedOverriddenProperty'); - -// Can not access protected properties overridden in subclass -goTo.marker("3"); -verify.completionListContains('privateMethod'); -verify.completionListContains('privateProperty'); -verify.completionListContains('protectedMethod'); -verify.completionListContains('protectedProperty'); -verify.completionListContains('publicMethod'); -verify.completionListContains('publicProperty'); -verify.not.completionListContains('protectedOverriddenMethod'); -verify.not.completionListContains('protectedOverriddenProperty'); +verify.completions( + { + marker: ["1", "2"], + exact: ["privateMethod", "privateProperty", "protectedMethod", "protectedProperty", "publicMethod", "publicProperty", "protectedOverriddenMethod", "protectedOverriddenProperty", "test"], + }, + { + marker: "3", + // Can not access protected properties overridden in subclass + exact: ["privateMethod", "privateProperty", "protectedMethod", "protectedProperty", "publicMethod", "publicProperty", "test"], + }, +); diff --git a/tests/cases/fourslash/completionListInstanceProtectedMembers2.ts b/tests/cases/fourslash/completionListInstanceProtectedMembers2.ts index 0733cb4d7da48..ebbfb95cb3595 100644 --- a/tests/cases/fourslash/completionListInstanceProtectedMembers2.ts +++ b/tests/cases/fourslash/completionListInstanceProtectedMembers2.ts @@ -30,47 +30,29 @@ //// } ////} - -// Same class, everything is visible -goTo.marker("1"); -verify.not.completionListContains('privateMethod'); -verify.not.completionListContains('privateProperty'); -verify.completionListContains('protectedMethod'); -verify.completionListContains('protectedProperty'); -verify.completionListContains('publicMethod'); -verify.completionListContains('publicProperty'); -verify.completionListContains('protectedOverriddenMethod'); -verify.completionListContains('protectedOverriddenProperty'); - -// Can not access properties on super -goTo.marker("2"); -verify.not.completionListContains('privateMethod'); -verify.not.completionListContains('privateProperty'); -verify.completionListContains('protectedMethod'); -verify.not.completionListContains('protectedProperty'); -verify.completionListContains('publicMethod'); -verify.not.completionListContains('publicProperty'); -verify.completionListContains('protectedOverriddenMethod'); -verify.not.completionListContains('protectedOverriddenProperty'); - -// Can not access protected properties through base class -goTo.marker("3"); -verify.not.completionListContains('privateMethod'); -verify.not.completionListContains('privateProperty'); -verify.not.completionListContains('protectedMethod'); -verify.not.completionListContains('protectedProperty'); -verify.completionListContains('publicMethod'); -verify.completionListContains('publicProperty'); -verify.not.completionListContains('protectedOverriddenMethod'); -verify.not.completionListContains('protectedOverriddenProperty'); - -// Same class, everything is visible -goTo.marker("4"); -verify.not.completionListContains('privateMethod'); -verify.not.completionListContains('privateProperty'); -verify.completionListContains('protectedMethod'); -verify.completionListContains('protectedProperty'); -verify.completionListContains('publicMethod'); -verify.completionListContains('publicProperty'); -verify.completionListContains('protectedOverriddenMethod'); -verify.completionListContains('protectedOverriddenProperty'); +verify.completions( + { + // Same class, everything is visible + marker: "1", + includes: ["protectedMethod", "protectedProperty", "publicMethod", "publicProperty", "protectedOverriddenMethod", "protectedOverriddenProperty"], + excludes: ["privateMethod", "privateProperty"], + }, + { + // Can not access properties on super + marker: "2", + includes: ["protectedMethod", "publicMethod", "protectedOverriddenMethod"], + excludes: ["privateMethod", "privateProperty", "protectedProperty", "publicProperty", "protectedOverriddenProperty"], + }, + { + // Can not access protected properties through base class + marker: "3", + includes: ["publicMethod", "publicProperty"], + excludes: ["privateMethod", "privateProperty", "protectedMethod", "protectedProperty", "protectedOverriddenMethod", "protectedOverriddenProperty"], + }, + { + // Same class, everything is visible + marker: "4", + includes: ["protectedMethod", "protectedProperty", "publicMethod", "publicProperty", "protectedOverriddenMethod", "protectedOverriddenProperty"], + excludes: ["privateMethod", "privateProperty"], + }, +); diff --git a/tests/cases/fourslash/completionListInstanceProtectedMembers3.ts b/tests/cases/fourslash/completionListInstanceProtectedMembers3.ts index 5454fa10ef03f..6f87abf10f02e 100644 --- a/tests/cases/fourslash/completionListInstanceProtectedMembers3.ts +++ b/tests/cases/fourslash/completionListInstanceProtectedMembers3.ts @@ -25,22 +25,4 @@ //// c./*2*/; // Only public properties are visible outside the class -goTo.marker("1"); -verify.not.completionListContains('privateMethod'); -verify.not.completionListContains('privateProperty'); -verify.not.completionListContains('protectedMethod'); -verify.not.completionListContains('protectedProperty'); -verify.completionListContains('publicMethod'); -verify.completionListContains('publicProperty'); -verify.not.completionListContains('protectedOverriddenMethod'); -verify.not.completionListContains('protectedOverriddenProperty'); - -goTo.marker("2"); -verify.not.completionListContains('privateMethod'); -verify.not.completionListContains('privateProperty'); -verify.not.completionListContains('protectedMethod'); -verify.not.completionListContains('protectedProperty'); -verify.completionListContains('publicMethod'); -verify.completionListContains('publicProperty'); -verify.not.completionListContains('protectedOverriddenMethod'); -verify.not.completionListContains('protectedOverriddenProperty'); +verify.completions({ marker: ["1", "2"], exact: ["publicMethod", "publicProperty"] }); diff --git a/tests/cases/fourslash/completionListInstanceProtectedMembers4.ts b/tests/cases/fourslash/completionListInstanceProtectedMembers4.ts index b4f282d19fef0..1ab01c0bff6d1 100644 --- a/tests/cases/fourslash/completionListInstanceProtectedMembers4.ts +++ b/tests/cases/fourslash/completionListInstanceProtectedMembers4.ts @@ -22,13 +22,4 @@ //// var c: C1; //// c./*1*/ - -goTo.marker("1"); -verify.not.completionListContains('privateMethod'); -verify.not.completionListContains('privateProperty'); -verify.not.completionListContains('protectedMethod'); -verify.not.completionListContains('protectedProperty'); -verify.completionListContains('publicMethod'); -verify.completionListContains('publicProperty'); -verify.completionListContains('protectedOverriddenMethod'); -verify.completionListContains('protectedOverriddenProperty'); +verify.completions({ marker: "1", exact: ["protectedOverriddenMethod", "protectedOverriddenProperty", "publicMethod", "publicProperty"] }); diff --git a/tests/cases/fourslash/completionListInvalidMemberNames.ts b/tests/cases/fourslash/completionListInvalidMemberNames.ts index 3dc54274e838e..2f124758d69bf 100644 --- a/tests/cases/fourslash/completionListInvalidMemberNames.ts +++ b/tests/cases/fourslash/completionListInvalidMemberNames.ts @@ -14,18 +14,21 @@ ////x[|./*a*/|]; ////x["/*b*/"]; -verify.completionsAt("b", ["foo ", "bar", "break", "any", "#", "$", "b", "1b"]); - const replacementSpan = test.ranges()[0]; -verify.completionsAt("a", [ - { name: "foo ", insertText: '["foo "]', replacementSpan }, - "bar", - "break", - "any", - { name: "#", insertText: '["#"]', replacementSpan }, - "$", - "b", - { name: "1b", insertText: '["1b"]', replacementSpan }, -], { - includeInsertTextCompletions: true, -}); +verify.completions( + { marker: "b", exact: ["foo ", "bar", "break", "any", "#", "$", "b", "1b"] }, + { + marker: "a", + exact: [ + { name: "foo ", insertText: '["foo "]', replacementSpan }, + "bar", + "break", + "any", + { name: "#", insertText: '["#"]', replacementSpan }, + "$", + "b", + { name: "1b", insertText: '["1b"]', replacementSpan }, + ], + preferences: { includeInsertTextCompletions: true }, + }, +); diff --git a/tests/cases/fourslash/completionListInvalidMemberNames2.ts b/tests/cases/fourslash/completionListInvalidMemberNames2.ts index 153ed3bdb5e32..b7f18b7f71b05 100644 --- a/tests/cases/fourslash/completionListInvalidMemberNames2.ts +++ b/tests/cases/fourslash/completionListInvalidMemberNames2.ts @@ -15,5 +15,4 @@ ////var _ : SomeInterface; ////_./**/ -goTo.marker(); -verify.not.completionListContains("[Symbol.hasInstance]"); +verify.completions({ marker: "", exact: completion.functionMembersWithPrototype }); diff --git a/tests/cases/fourslash/completionListInvalidMemberNames_escapeQuote.ts b/tests/cases/fourslash/completionListInvalidMemberNames_escapeQuote.ts index e61c9bc874a02..4ec5a611e4333 100644 --- a/tests/cases/fourslash/completionListInvalidMemberNames_escapeQuote.ts +++ b/tests/cases/fourslash/completionListInvalidMemberNames_escapeQuote.ts @@ -4,9 +4,17 @@ ////x[|./**/|]; const replacementSpan = test.ranges()[0]; -verify.completionsAt("", [{ name: `"'`, insertText: `["\\"'"]`, replacementSpan }], { includeInsertTextCompletions: true }); +verify.completions({ + marker: "", + exact: { name: `"'`, insertText: `["\\"'"]`, replacementSpan }, + preferences: { includeInsertTextCompletions: true }, +}); -verify.completionsAt("", [{ name: `"'`, insertText: `['"\\'']`, replacementSpan }], { - includeInsertTextCompletions: true, - quotePreference: "single", +verify.completions({ + marker: "", + exact: { name: `"'`, insertText: `['"\\'']`, replacementSpan }, + preferences: { + includeInsertTextCompletions: true, + quotePreference: "single", + }, }); diff --git a/tests/cases/fourslash/completionListInvalidMemberNames_startWithSpace.ts b/tests/cases/fourslash/completionListInvalidMemberNames_startWithSpace.ts index f86c8a5a8132b..be1310d967183 100644 --- a/tests/cases/fourslash/completionListInvalidMemberNames_startWithSpace.ts +++ b/tests/cases/fourslash/completionListInvalidMemberNames_startWithSpace.ts @@ -5,4 +5,8 @@ const replacementSpan = test.ranges()[0]; // No completion for " foo" because it starts with a space. See https://github.com/Microsoft/TypeScript/pull/20547 -verify.completionsAt("", [{ name: "foo ", insertText: '["foo "]', replacementSpan }], { includeInsertTextCompletions: true }); +verify.completions({ + marker: "", + exact: [{ name: "foo ", insertText: '["foo "]', replacementSpan }], + preferences: { includeInsertTextCompletions: true }, +}); diff --git a/tests/cases/fourslash/completionListInvalidMemberNames_withExistingIdentifier.ts b/tests/cases/fourslash/completionListInvalidMemberNames_withExistingIdentifier.ts index 3c06692293ebc..3e75bd26be0ba 100644 --- a/tests/cases/fourslash/completionListInvalidMemberNames_withExistingIdentifier.ts +++ b/tests/cases/fourslash/completionListInvalidMemberNames_withExistingIdentifier.ts @@ -6,5 +6,15 @@ ////unrelatedIdentifier; const [r0, r1] = test.ranges(); -verify.completionsAt("0", [{ name: "foo ", insertText: '["foo "]', replacementSpan: r0 }], { includeInsertTextCompletions: true }); -verify.completionsAt("1", [{ name: "foo ", insertText: '["foo "]', replacementSpan: r1 }], { includeInsertTextCompletions: true }); +verify.completions( + { + marker: "0", + exact: [{ name: "foo ", insertText: '["foo "]', replacementSpan: r0 }], + preferences: { includeInsertTextCompletions: true }, + }, + { + marker: "1", + exact: [{ name: "foo ", insertText: '["foo "]', replacementSpan: r1 }], + preferences: { includeInsertTextCompletions: true }, + }, +); diff --git a/tests/cases/fourslash/completionListIsGlobalCompletion.ts b/tests/cases/fourslash/completionListIsGlobalCompletion.ts index 121ab940d6549..f8ee943053781 100644 --- a/tests/cases/fourslash/completionListIsGlobalCompletion.ts +++ b/tests/cases/fourslash/completionListIsGlobalCompletion.ts @@ -34,41 +34,19 @@ ////const z =
; // no globals in jsx attribute with syntax error ////const x = `/*14*/ ${/*15*/}`; // globals only in template expression ////var user = ; // globals only in JSX expression (but not in JSX expression strings) -goTo.marker("1"); -verify.completionListIsGlobal(false); -goTo.marker("2"); -verify.completionListIsGlobal(false); -goTo.marker("3"); -verify.completionListIsGlobal(false); -goTo.marker("4"); -verify.completionListIsGlobal(false); -goTo.marker("5"); -verify.completionListIsGlobal(true); -goTo.marker("6"); -verify.completionListIsGlobal(false); -goTo.marker("7"); -verify.completionListIsGlobal(true); -goTo.marker("8"); -verify.completionListIsGlobal(false); -goTo.marker("9"); -verify.completionListIsGlobal(false); -goTo.marker("10"); -verify.completionListIsGlobal(false); -goTo.marker("11"); -verify.completionListIsGlobal(true); -goTo.marker("12"); -verify.completionListIsGlobal(false); -goTo.marker("13"); -verify.completionListIsGlobal(false); -goTo.marker("14"); -verify.completionListIsGlobal(false); -goTo.marker("15"); -verify.completionListIsGlobal(true); -goTo.marker("16"); -verify.completionListIsGlobal(false); -goTo.marker("17"); -verify.completionListIsGlobal(false); -goTo.marker("18"); -verify.completionListIsGlobal(true); -goTo.marker("19"); -verify.completionListIsGlobal(false); \ No newline at end of file + +const x = ["test", "A", "B", "C", "y", "z", "x", "user"]; +const globals: ReadonlyArray = [...x, ...completion.globals] +verify.completions( + { marker: ["1", "3", "6", "8", "12", "14"], exact: undefined, isGlobalCompletion: false }, + { marker: "2", exact: ["a.ts", "file.ts"], isGlobalCompletion: false, isNewIdentifierLocation: true }, + { marker: ["4", "19"], exact: [], isGlobalCompletion: false }, + { marker: ["5", "11", "18"], exact: globals, isGlobalCompletion: true }, + { marker: "7", exact: completion.globalsInsideFunction(x), isGlobalCompletion: true }, + { marker: "9", exact: ["x", "y"], isGlobalCompletion: false }, + { marker: "10", exact: completion.classElementKeywords, isGlobalCompletion: false, isNewIdentifierLocation: true }, + { marker: "13", exact: globals, isGlobalCompletion: false }, + { marker: "15", exact: globals, isGlobalCompletion: true, isNewIdentifierLocation: true }, + { marker: "16", exact: [...x, ...completion.globalsVars, "undefined"], isGlobalCompletion: false }, + { marker: "17", exact: completion.globalKeywordsPlusUndefined, isGlobalCompletion: false }, +); diff --git a/tests/cases/fourslash/completionListKeywords.ts b/tests/cases/fourslash/completionListKeywords.ts index 8b9a8cc222cb0..660099d3188a0 100644 --- a/tests/cases/fourslash/completionListKeywords.ts +++ b/tests/cases/fourslash/completionListKeywords.ts @@ -1,42 +1,7 @@ /// -//// +// @noLib: true -verify.completions({ - includes: [ - "break", - "case", - "catch", - "class", - "continue", - "debugger", - "declare", - "default", - "delete", - "do", - "else", - "enum", - "export", - "extends", - "false", - "finally", - "for", - "function", - "if", - "instanceof", - "interface", - "module", - "new", - "return", - "super", - "switch", - "this", - "throw", - "true", - "try", - "typeof", - "var", - "while", - "with", - ], -}); +/////**/ + +verify.completions({ marker: "", exact: ["undefined", ...completion.statementKeywordsWithTypes] }); diff --git a/tests/cases/fourslash/completionListModuleMembers.ts b/tests/cases/fourslash/completionListModuleMembers.ts index 48278652fb5c3..9881fb3b7f7df 100644 --- a/tests/cases/fourslash/completionListModuleMembers.ts +++ b/tests/cases/fourslash/completionListModuleMembers.ts @@ -21,40 +21,13 @@ //// ////interface TestInterface implements Module./*TypeReferenceInImplementsList*/ { } -function getVerify(isTypeLocation: boolean) { - return { - verifyValue: isTypeLocation ? verify.not : verify, - verifyType: isTypeLocation ? verify : verify.not, - verifyValueOrType: verify, - verifyNotValueOrType: verify.not, - }; -} - -function verifyModuleMembers(marker: string, isTypeLocation: boolean) { - goTo.marker(marker); - - const { verifyValue, verifyType, verifyValueOrType, verifyNotValueOrType } = getVerify(isTypeLocation); - - verifyValue.completionListContains("exportedVariable"); - verifyValue.completionListContains("exportedFunction"); - verifyValue.completionListContains("exportedModule"); - - verifyValueOrType.completionListContains("exportedClass"); - - // Include type declarations - verifyType.completionListContains("exportedInterface"); - - // No inner declarations - verifyNotValueOrType.completionListContains("innerVariable"); - verifyNotValueOrType.completionListContains("innerFunction"); - verifyNotValueOrType.completionListContains("innerClass"); - verifyNotValueOrType.completionListContains("innerModule"); - verifyNotValueOrType.completionListContains("innerInterface"); - - verifyNotValueOrType.completionListContains("exportedInnerModuleVariable"); -} - -verifyModuleMembers("ValueReference", /*isTypeLocation*/ false); -verifyModuleMembers("TypeReference", /*isTypeLocation*/ true); -verifyModuleMembers("TypeReferenceInExtendsList", /*isTypeLocation*/ false); -verifyModuleMembers("TypeReferenceInImplementsList", /*isTypeLocation*/ true); +verify.completions( + { + marker: ["ValueReference", "TypeReferenceInExtendsList"], + exact: ["exportedFunction", "exportedVariable", "exportedClass", "exportedModule"], + }, + { + marker: ["TypeReference", "TypeReferenceInImplementsList"], + exact: ["exportedClass", "exportedInterface"], + }, +); diff --git a/tests/cases/fourslash/completionListNewIdentifierBindingElement.ts b/tests/cases/fourslash/completionListNewIdentifierBindingElement.ts index 753d6c7d4d2dc..3513e33484f67 100644 --- a/tests/cases/fourslash/completionListNewIdentifierBindingElement.ts +++ b/tests/cases/fourslash/completionListNewIdentifierBindingElement.ts @@ -2,5 +2,4 @@ ////var { x:html/*1*/ -goTo.marker("1"); -verify.completionListIsEmpty(); \ No newline at end of file +verify.completions({ marker: "1", exact: undefined }); diff --git a/tests/cases/fourslash/completionListNewIdentifierFunctionDeclaration.ts b/tests/cases/fourslash/completionListNewIdentifierFunctionDeclaration.ts index 1f8b24d1cf19d..f6303f8441dda 100644 --- a/tests/cases/fourslash/completionListNewIdentifierFunctionDeclaration.ts +++ b/tests/cases/fourslash/completionListNewIdentifierFunctionDeclaration.ts @@ -1,8 +1,11 @@ /// +// @noLib: true + ////function F(pref: (a/*1*/ -goTo.eachMarker(() => { - verify.not.completionListIsEmpty(); - verify.completionListAllowsNewIdentifier(); +verify.completions({ + marker: "1", + exact: completion.typeKeywords, + isNewIdentifierLocation: true, }); diff --git a/tests/cases/fourslash/completionListNewIdentifierVariableDeclaration.ts b/tests/cases/fourslash/completionListNewIdentifierVariableDeclaration.ts index cdebbaa1334ac..c9900cf86ac46 100644 --- a/tests/cases/fourslash/completionListNewIdentifierVariableDeclaration.ts +++ b/tests/cases/fourslash/completionListNewIdentifierVariableDeclaration.ts @@ -2,6 +2,5 @@ ////var y : (s:string, list/*2*/ -goTo.marker("2"); -verify.completionListIsEmpty(); // Parameter name -verify.completionListAllowsNewIdentifier(); \ No newline at end of file +// Parameter name +verify.completions({ marker: "2", exact: undefined, isNewIdentifierLocation: true }); diff --git a/tests/cases/fourslash/completionListObjectMembers.ts b/tests/cases/fourslash/completionListObjectMembers.ts index ae773c1c3b45f..ebf50ae18db59 100644 --- a/tests/cases/fourslash/completionListObjectMembers.ts +++ b/tests/cases/fourslash/completionListObjectMembers.ts @@ -9,6 +9,7 @@ //// }; ////object./**/ -goTo.marker(); -verify.completionListContains("bar", '(property) bar: any'); -verify.completionListContains("foo", '(method) foo(bar: any): any'); +verify.completions({ + marker: "", + includes: [{ name: "bar", text: "(property) bar: any" }, { name: "foo", text: "(method) foo(bar: any): any" }], +}); diff --git a/tests/cases/fourslash/completionListOfGenericSymbol.ts b/tests/cases/fourslash/completionListOfGenericSymbol.ts new file mode 100644 index 0000000000000..804b2c1d297ad --- /dev/null +++ b/tests/cases/fourslash/completionListOfGenericSymbol.ts @@ -0,0 +1,24 @@ +/// + +// Ensure kind is set correctly on completions of a generic symbol + +////var a = [1,2,3]; +////a./**/ + +verify.completions({ + marker: "", + includes: [ + { + name: "length", + text: "(property) Array.length: number", + documentation: "Gets or sets the length of the array. This is a number one higher than the highest element defined in an array.", + kind: "property", + }, + { + name: "toString", + text: "(method) Array.toString(): string", + documentation: "Returns a string representation of an array.", + kind: "method", + }, + ], +}); diff --git a/tests/cases/fourslash/completionListOfGnericSymbol.ts b/tests/cases/fourslash/completionListOfGnericSymbol.ts deleted file mode 100644 index 9251892db2389..0000000000000 --- a/tests/cases/fourslash/completionListOfGnericSymbol.ts +++ /dev/null @@ -1,11 +0,0 @@ -/// - -// Ensure kind is set correctelly on completions of a generic symbol - -////var a = [1,2,3]; -////a./**/ - -goTo.marker(); -verify.completionListContains('length', "(property) Array.length: number", /*docComments*/ undefined, /*kind*/ "property"); -verify.completionListContains('toString', "(method) Array.toString(): string", /*docComments*/ undefined, /*kind*/ "method"); - diff --git a/tests/cases/fourslash/completionListOfSplitInterface.ts b/tests/cases/fourslash/completionListOfSplitInterface.ts index 9bc635d8f8b87..df84dc96d1bc4 100644 --- a/tests/cases/fourslash/completionListOfSplitInterface.ts +++ b/tests/cases/fourslash/completionListOfSplitInterface.ts @@ -32,19 +32,7 @@ ////var ci1: I1; ////ci1./*2*/b; -goTo.marker('1'); -verify.completionListCount(6); -verify.completionListContains("a"); -verify.completionListContains("b"); -verify.completionListContains("c"); -verify.completionListContains("i1"); -verify.completionListContains("i2"); -verify.completionListContains("i3"); - -goTo.marker('2'); -verify.completionListCount(5); -verify.completionListContains("a"); -verify.completionListContains("b"); -verify.completionListContains("b1"); -verify.completionListContains("i11"); -verify.completionListContains("i12"); +verify.completions( + { marker: "1", exact: ["i1", "i2", "i3", "a", "b", "c"] }, + { marker: "2", exact: ["i11", "i12", "a", "b", "b1"] }, +); diff --git a/tests/cases/fourslash/completionListOfUnion.ts b/tests/cases/fourslash/completionListOfUnion.ts index c323c83d0543d..740113099f79d 100644 --- a/tests/cases/fourslash/completionListOfUnion.ts +++ b/tests/cases/fourslash/completionListOfUnion.ts @@ -9,12 +9,14 @@ ////function f(...args: Array) {} ////f({ /*f*/ }); -goTo.marker("x"); -verify.completionListCount(3); -verify.completionListContains("a", "(property) a: string | number"); -verify.completionListContains("b", "(property) b: number | boolean"); -verify.completionListContains("c", "(property) c: string"); - -goTo.marker("f"); -verify.completionListContains("a", "(property) I.a: number"); -// Also contains array members +verify.completions( + { + marker: "x", + exact: [ + { name: "a", text: "(property) a: string | number" }, + { name: "b", text: "(property) b: number | boolean" }, + { name: "c", text: "(property) c: string"} , + ], + }, + { marker: "f", includes: [{ name: "a", text: "(property) I.a: number" }] }, // Also contains array members +); diff --git a/tests/cases/fourslash/completionListOnAliasedModule.ts b/tests/cases/fourslash/completionListOnAliasedModule.ts index 7b533408bbde5..753a52f0de44a 100644 --- a/tests/cases/fourslash/completionListOnAliasedModule.ts +++ b/tests/cases/fourslash/completionListOnAliasedModule.ts @@ -9,6 +9,4 @@ ////import p = M.N; ////p./**/ -goTo.marker(); -verify.completionListContains('foo'); -verify.not.completionListContains('bar'); \ No newline at end of file +verify.completions({ marker: "", exact: "foo" }); diff --git a/tests/cases/fourslash/completionListOnAliases.ts b/tests/cases/fourslash/completionListOnAliases.ts index 0c5b7adcd50c3..7e2b7a07f72a5 100644 --- a/tests/cases/fourslash/completionListOnAliases.ts +++ b/tests/cases/fourslash/completionListOnAliases.ts @@ -8,8 +8,7 @@ //// x./*2*/ ////} -goTo.marker("1"); -verify.completionListContains("x", "(alias) namespace x\nimport x = M", undefined); - -goTo.marker("2"); -verify.completionListContains("value"); +verify.completions( + { marker: "1", includes: [{ name: "x", text: "(alias) namespace x\nimport x = M" }] }, + { marker: "2", exact: "value" }, +); diff --git a/tests/cases/fourslash/completionListOnAliases2.ts b/tests/cases/fourslash/completionListOnAliases2.ts index 5933fbe89d463..ffa1c212a8d71 100644 --- a/tests/cases/fourslash/completionListOnAliases2.ts +++ b/tests/cases/fourslash/completionListOnAliases2.ts @@ -34,56 +34,18 @@ ////a./*7*/; ////var tmp2: a./*7Type*/; -function getVerify(isTypeLocation?: boolean) { - return { - verifyValue: isTypeLocation ? verify.not : verify, - verifyType: isTypeLocation ? verify : verify.not, - verifyValueOrType: verify - }; -} - -function verifyModuleM(marker: string) { - verifyModuleMWorker(marker, /*isTypeLocation*/ false); - verifyModuleMWorker(`${marker}Type`, /*isTypeLocation*/ true); -} - -function verifyModuleMWorker(marker: string, isTypeLocation: boolean): void { - goTo.marker(marker); - - const { verifyValue, verifyType, verifyValueOrType } = getVerify(isTypeLocation); - verifyType.completionListContains("I"); - verifyValueOrType.completionListContains("C"); - verifyValueOrType.completionListContains("E"); - verifyValue.completionListContains("N"); - verifyValue.completionListContains("V"); - verifyValue.completionListContains("F"); - verifyValueOrType.completionListContains("A"); -} - -// Module m -goTo.marker("1"); -verify.completionListContains("A"); -verifyModuleM("1"); - -// Class C -goTo.marker("2"); -verify.completionListContains("property"); - -// Enum E -goTo.marker("3"); -verify.completionListContains("value"); - -// Module N -goTo.marker("4"); -verify.completionListContains("v"); - -// var V -goTo.marker("5"); -verify.completionListContains("toFixed"); - -// function F -goTo.marker("6"); -verify.completionListContains("call"); - -// alias a -verifyModuleM("7"); \ No newline at end of file +verify.completions( + // Module m / alias a + { marker: ["1", "7"], exact: ["F", "C", "E", "N", "V", "A"] }, + { marker: ["1Type", "7Type"], exact: ["I", "C", "E", "A"] }, + // Class C + { marker: "2", exact: ["prototype", "property", ...completion.functionMembers] }, + // Enum E + { marker: "3", exact: "value" }, + // Module N + { marker: "4", exact: "v" }, + // var V + { marker: "5", includes: "toFixed" }, + // function F + { marker: "6", includes: "call" }, +); diff --git a/tests/cases/fourslash/completionListOnAliases3.ts b/tests/cases/fourslash/completionListOnAliases3.ts index 3eab00e2ed960..b3884a400a2f4 100644 --- a/tests/cases/fourslash/completionListOnAliases3.ts +++ b/tests/cases/fourslash/completionListOnAliases3.ts @@ -5,9 +5,7 @@ ////} ////declare module 'thing' { //// import x = require('foobar'); -//// var m: x./*1*/; +//// var m: x./*1*/; ////} -// Q does not show up in member list of x -goTo.marker("1"); -verify.completionListContains("Q"); +verify.completions({ marker: "1", exact: "Q" }); diff --git a/tests/cases/fourslash/completionListOnFunctionCallWithOptionalArgument.ts b/tests/cases/fourslash/completionListOnFunctionCallWithOptionalArgument.ts index cec7bf87aece3..aee8633d743eb 100644 --- a/tests/cases/fourslash/completionListOnFunctionCallWithOptionalArgument.ts +++ b/tests/cases/fourslash/completionListOnFunctionCallWithOptionalArgument.ts @@ -3,5 +3,4 @@ //// declare function Foo(arg1?: Function): { q: number }; //// Foo(function () { } )./**/; -goTo.marker(); -verify.completionListContains('q'); +verify.completions({ marker: "", exact: "q" }); diff --git a/tests/cases/fourslash/completionListOnMethodParameterName.ts b/tests/cases/fourslash/completionListOnMethodParameterName.ts index e02167850af0d..4de92beea966f 100644 --- a/tests/cases/fourslash/completionListOnMethodParameterName.ts +++ b/tests/cases/fourslash/completionListOnMethodParameterName.ts @@ -5,6 +5,5 @@ //// } ////} -goTo.marker(); // Completion list shouldn't be present in argument name position -verify.completionListIsEmpty(); +verify.completions({ marker: "", exact: undefined }); diff --git a/tests/cases/fourslash/completionListOnParam.ts b/tests/cases/fourslash/completionListOnParam.ts index ad2bbcde1b894..7f2da15814f6b 100644 --- a/tests/cases/fourslash/completionListOnParam.ts +++ b/tests/cases/fourslash/completionListOnParam.ts @@ -8,5 +8,4 @@ //// public Foo(x: Bar./**/Blah, y: Bar.Blah) { } ////} -goTo.marker(); -verify.completionListContains('Blah'); \ No newline at end of file +verify.completions({ marker: "", exact: "Blah" }); diff --git a/tests/cases/fourslash/completionListOnParamInClass.ts b/tests/cases/fourslash/completionListOnParamInClass.ts index 44c1c22d5c852..4f0e8efeaceb7 100644 --- a/tests/cases/fourslash/completionListOnParamInClass.ts +++ b/tests/cases/fourslash/completionListOnParamInClass.ts @@ -4,6 +4,4 @@ //// static getEncoding(buffer: buffer/**/Pointer ////} -goTo.marker(); -verify.not.completionListContains('parseInt'); -verify.completionListContains('encoder'); +verify.completions({ marker: "", includes: "encoder", excludes: "parseInt" }); diff --git a/tests/cases/fourslash/completionListOnParamOfGenericType1.ts b/tests/cases/fourslash/completionListOnParamOfGenericType1.ts index c55b48bf7e922..79fc9ee49ea9d 100644 --- a/tests/cases/fourslash/completionListOnParamOfGenericType1.ts +++ b/tests/cases/fourslash/completionListOnParamOfGenericType1.ts @@ -8,15 +8,9 @@ //// } ////} -goTo.marker('1'); -verify.completionListContains('next'); -verify.completionListContains('prev'); -verify.completionListContains('pushEntry'); +const exact = ["next", "prev", "pushEntry"]; +verify.completions({ marker: "1", exact }); edit.insert('next.'); -verify.completionListContains('next'); -verify.completionListContains('prev'); -verify.completionListContains('pushEntry'); +verify.completions({ exact }); edit.insert('prev.'); -verify.completionListContains('next'); -verify.completionListContains('prev'); -verify.completionListContains('pushEntry'); +verify.completions({ exact }); diff --git a/tests/cases/fourslash/completionListOnPrivateVariableInModule.ts b/tests/cases/fourslash/completionListOnPrivateVariableInModule.ts index b22113b856f13..849765e212dd7 100644 --- a/tests/cases/fourslash/completionListOnPrivateVariableInModule.ts +++ b/tests/cases/fourslash/completionListOnPrivateVariableInModule.ts @@ -2,5 +2,4 @@ //// module Foo { var testing = ""; test/**/ } -goTo.marker(); -verify.completionListContains('testing', 'var testing: string'); +verify.completions({ marker: "", includes: { name: "testing", text: "var testing: string" } }); diff --git a/tests/cases/fourslash/completionListOnSuper.ts b/tests/cases/fourslash/completionListOnSuper.ts index 2b3c0ef75fabd..842c7d7db161c 100644 --- a/tests/cases/fourslash/completionListOnSuper.ts +++ b/tests/cases/fourslash/completionListOnSuper.ts @@ -16,7 +16,4 @@ //// } ////} -goTo.marker(); -verify.completionListContains('foo'); -verify.completionListContains('bar'); -verify.completionListCount(2); +verify.completions({ marker: "", exact: ["foo", "bar"] }); diff --git a/tests/cases/fourslash/completionListOnVarBetweenModules.ts b/tests/cases/fourslash/completionListOnVarBetweenModules.ts index b0205e3428ce9..72bd4c74125d3 100644 --- a/tests/cases/fourslash/completionListOnVarBetweenModules.ts +++ b/tests/cases/fourslash/completionListOnVarBetweenModules.ts @@ -12,6 +12,4 @@ //// } ////} -goTo.marker(); -verify.completionListContains("C1"); -verify.completionListContains("C2"); +verify.completions({ marker: "", exact: ["C1", "C2"] }); diff --git a/tests/cases/fourslash/completionListOutsideOfClosedArrowFunction01.ts b/tests/cases/fourslash/completionListOutsideOfClosedArrowFunction01.ts index d775371796fdc..1dc4927bdfba4 100644 --- a/tests/cases/fourslash/completionListOutsideOfClosedArrowFunction01.ts +++ b/tests/cases/fourslash/completionListOutsideOfClosedArrowFunction01.ts @@ -3,6 +3,4 @@ ////// no a or b /////*1*/(a, b) => { } -goTo.marker("1"); -verify.not.completionListContains("a"); -verify.not.completionListContains("b"); \ No newline at end of file +verify.completions({ marker: "1", excludes: ["a", "b"] }); diff --git a/tests/cases/fourslash/completionListOutsideOfClosedArrowFunction02.ts b/tests/cases/fourslash/completionListOutsideOfClosedArrowFunction02.ts index d9195ce5b9758..badd1bc8d18c9 100644 --- a/tests/cases/fourslash/completionListOutsideOfClosedArrowFunction02.ts +++ b/tests/cases/fourslash/completionListOutsideOfClosedArrowFunction02.ts @@ -3,6 +3,4 @@ ////// no a or b ////(a, b) => { }/*1*/ -goTo.marker("1"); -verify.not.completionListContains("a"); -verify.not.completionListContains("b"); \ No newline at end of file +verify.completions({ marker: "1", excludes: ["a", "b"] }); diff --git a/tests/cases/fourslash/completionListOutsideOfClosedFunctionDeclaration01.ts b/tests/cases/fourslash/completionListOutsideOfClosedFunctionDeclaration01.ts index 8b6077e0f8b5a..e45b58aa49912 100644 --- a/tests/cases/fourslash/completionListOutsideOfClosedFunctionDeclaration01.ts +++ b/tests/cases/fourslash/completionListOutsideOfClosedFunctionDeclaration01.ts @@ -3,6 +3,4 @@ ////// no a or b /////*1*/function f (a, b) {} -goTo.marker("1"); -verify.not.completionListContains("a"); -verify.not.completionListContains("b"); \ No newline at end of file +verify.completions({ marker: "1", excludes: ["a", "b"] }); diff --git a/tests/cases/fourslash/completionListOutsideOfForLoop01.ts b/tests/cases/fourslash/completionListOutsideOfForLoop01.ts index 473a39a453d00..bf01ab447a0f6 100644 --- a/tests/cases/fourslash/completionListOutsideOfForLoop01.ts +++ b/tests/cases/fourslash/completionListOutsideOfForLoop01.ts @@ -2,5 +2,4 @@ ////for (let i = 0; i < 10; i++) i;/*1*/ -goTo.marker("1"); -verify.not.completionListContains("i"); \ No newline at end of file +verify.completions({ marker: "1", excludes: "i" }); diff --git a/tests/cases/fourslash/completionListOutsideOfForLoop02.ts b/tests/cases/fourslash/completionListOutsideOfForLoop02.ts index b1186ac7cce7f..d4f11a6b97373 100644 --- a/tests/cases/fourslash/completionListOutsideOfForLoop02.ts +++ b/tests/cases/fourslash/completionListOutsideOfForLoop02.ts @@ -2,5 +2,4 @@ ////for (let i = 0; i < 10; i++);/*1*/ -goTo.marker("1"); -verify.not.completionListContains("i"); \ No newline at end of file +verify.completions({ marker: "1", excludes: "i" }); diff --git a/tests/cases/fourslash/completionListPrivateMembers.ts b/tests/cases/fourslash/completionListPrivateMembers.ts index e5e494d521d69..7ad87f4bccdc5 100644 --- a/tests/cases/fourslash/completionListPrivateMembers.ts +++ b/tests/cases/fourslash/completionListPrivateMembers.ts @@ -11,7 +11,4 @@ //// } ////} - -goTo.marker(); -verify.completionListContains("y"); -verify.not.completionListContains("x"); +verify.completions({ marker: "", exact: ["y", "foo"] }); diff --git a/tests/cases/fourslash/completionListPrivateMembers2.ts b/tests/cases/fourslash/completionListPrivateMembers2.ts index 1a04df1d82341..b766823e0b9c4 100644 --- a/tests/cases/fourslash/completionListPrivateMembers2.ts +++ b/tests/cases/fourslash/completionListPrivateMembers2.ts @@ -8,10 +8,7 @@ ////var f:Foo; ////f./*2*/ -goTo.marker("1"); -verify.completionListContains("y"); -verify.completionListContains("x"); - -goTo.marker("2"); -verify.not.completionListContains("x"); -verify.not.completionListContains("y"); \ No newline at end of file +verify.completions( + { marker: "1", exact: ["y", "x", "method"] }, + { marker: "2", exact: "method" }, +); diff --git a/tests/cases/fourslash/completionListPrivateMembers3.ts b/tests/cases/fourslash/completionListPrivateMembers3.ts index 999ab8fa5e630..d333b677ea21c 100644 --- a/tests/cases/fourslash/completionListPrivateMembers3.ts +++ b/tests/cases/fourslash/completionListPrivateMembers3.ts @@ -18,14 +18,4 @@ //// } ////} -goTo.marker("1"); -verify.completionListContains("p"); -verify.completionListCount(1); - -goTo.marker("2"); -verify.completionListContains("p"); -verify.completionListCount(1); - -goTo.marker("2"); -verify.completionListContains("p"); -verify.completionListCount(1); +verify.completions({ marker: ["1", "2", "3"], exact: "p" }); diff --git a/tests/cases/fourslash/completionListStaticProtectedMembers2.ts b/tests/cases/fourslash/completionListStaticProtectedMembers2.ts index c6c64c5c6ebe8..aff0c075faa58 100644 --- a/tests/cases/fourslash/completionListStaticProtectedMembers2.ts +++ b/tests/cases/fourslash/completionListStaticProtectedMembers2.ts @@ -26,45 +26,46 @@ //// } ////} - -// Same class, everything is visible -goTo.marker("1"); -verify.not.completionListContains('privateMethod'); -verify.not.completionListContains('privateProperty'); -verify.completionListContains('protectedMethod'); -verify.completionListContains('protectedProperty'); -verify.completionListContains('publicMethod'); -verify.completionListContains('publicProperty'); -verify.completionListContains('protectedOverriddenMethod'); -verify.completionListContains('protectedOverriddenProperty'); - -goTo.marker("2"); -verify.not.completionListContains('privateMethod'); -verify.not.completionListContains('privateProperty'); -verify.completionListContains('protectedMethod'); -verify.completionListContains('protectedProperty'); -verify.completionListContains('publicMethod'); -verify.completionListContains('publicProperty'); -verify.completionListContains('protectedOverriddenMethod'); -verify.completionListContains('protectedOverriddenProperty'); - -goTo.marker("3"); -verify.not.completionListContains('privateMethod'); -verify.not.completionListContains('privateProperty'); -verify.completionListContains('protectedMethod'); -verify.completionListContains('protectedProperty'); -verify.completionListContains('publicMethod'); -verify.completionListContains('publicProperty'); -verify.completionListContains('protectedOverriddenMethod'); -verify.completionListContains('protectedOverriddenProperty'); - -// only public and protected methods of the base class are accessible through super -goTo.marker("4"); -verify.not.completionListContains('privateMethod'); -verify.not.completionListContains('privateProperty'); -verify.completionListContains('protectedMethod'); -verify.not.completionListContains('protectedProperty'); -verify.completionListContains('publicMethod'); -verify.not.completionListContains('publicProperty'); -verify.completionListContains('protectedOverriddenMethod'); -verify.not.completionListContains('protectedOverriddenProperty'); \ No newline at end of file +verify.completions( + { + // Same class, everything is visible + marker: ["1"], + exact: [ + "prototype", + "protectedMethod", + "protectedProperty", + "publicMethod", + "publicProperty", + "protectedOverriddenMethod", + "protectedOverriddenProperty", + ...completion.functionMembers, + ], + }, + { + marker: ["2", "3"], + exact: [ + "prototype", + "protectedOverriddenMethod", + "protectedOverriddenProperty", + "test", + "protectedMethod", + "protectedProperty", + "publicMethod", + "publicProperty", + ...completion.functionMembers, + ], + }, + { + // only public and protected methods of the base class are accessible through super + marker: "4", + exact: [ + "protectedMethod", + "publicMethod", + "protectedOverriddenMethod", + "apply", + "call", + "bind", + "toString", + ], + }, +); diff --git a/tests/cases/fourslash/completionListStaticProtectedMembers3.ts b/tests/cases/fourslash/completionListStaticProtectedMembers3.ts index 0cb916c181f18..57cf38dcb4f0a 100644 --- a/tests/cases/fourslash/completionListStaticProtectedMembers3.ts +++ b/tests/cases/fourslash/completionListStaticProtectedMembers3.ts @@ -22,24 +22,8 @@ ////Base./*1*/; ////C3./*2*/; - // Only public properties are visible outside the class -goTo.marker("1"); -verify.not.completionListContains('privateMethod'); -verify.not.completionListContains('privateProperty'); -verify.not.completionListContains('protectedMethod'); -verify.not.completionListContains('protectedProperty'); -verify.completionListContains('publicMethod'); -verify.completionListContains('publicProperty'); -verify.not.completionListContains('protectedOverriddenMethod'); -verify.not.completionListContains('protectedOverriddenProperty'); - -goTo.marker("2"); -verify.not.completionListContains('privateMethod'); -verify.not.completionListContains('privateProperty'); -verify.not.completionListContains('protectedMethod'); -verify.not.completionListContains('protectedProperty'); -verify.completionListContains('publicMethod'); -verify.completionListContains('publicProperty'); -verify.not.completionListContains('protectedOverriddenMethod'); -verify.not.completionListContains('protectedOverriddenProperty'); \ No newline at end of file +verify.completions({ + marker: ["1", "2"], + exact: ["prototype", "publicMethod", "publicProperty", ...completion.functionMembers], +}); diff --git a/tests/cases/fourslash/completionListStaticProtectedMembers4.ts b/tests/cases/fourslash/completionListStaticProtectedMembers4.ts index 14c460d6873c3..a34a3cda3ac2d 100644 --- a/tests/cases/fourslash/completionListStaticProtectedMembers4.ts +++ b/tests/cases/fourslash/completionListStaticProtectedMembers4.ts @@ -26,24 +26,29 @@ ////} //// Derived./*2*/ -// Sub class, everything but private is visible -goTo.marker("1"); -verify.not.completionListContains('privateMethod'); -verify.not.completionListContains('privateProperty'); -verify.completionListContains('protectedMethod'); -verify.completionListContains('protectedProperty'); -verify.completionListContains('publicMethod'); -verify.completionListContains('publicProperty'); -verify.completionListContains('protectedOverriddenMethod'); -verify.completionListContains('protectedOverriddenProperty'); +const publicCompletions: ReadonlyArray = ["publicMethod", "publicProperty", ...completion.functionMembers]; -// Can see protected methods elevated to public -goTo.marker("2"); -verify.not.completionListContains('privateMethod'); -verify.not.completionListContains('privateProperty'); -verify.not.completionListContains('protectedMethod'); -verify.not.completionListContains('protectedProperty'); -verify.completionListContains('publicMethod'); -verify.completionListContains('publicProperty'); -verify.completionListContains('protectedOverriddenMethod'); -verify.completionListContains('protectedOverriddenProperty'); +verify.completions( + { + // Sub class, everything but private is visible + marker: "1", + exact: [ + "prototype", + "protectedOverriddenMethod", + "protectedOverriddenProperty", + "protectedMethod", + "protectedProperty", + ...publicCompletions + ], + }, + { + // Can see protected methods elevated to public + marker: "2", + exact: [ + "prototype", + "protectedOverriddenMethod", + "protectedOverriddenProperty", + ...publicCompletions, + ], + }, +); diff --git a/tests/cases/fourslash/completionListWithLabel.ts b/tests/cases/fourslash/completionListWithLabel.ts index 1efc0ebb5fa37..dcf5cc1f776b8 100644 --- a/tests/cases/fourslash/completionListWithLabel.ts +++ b/tests/cases/fourslash/completionListWithLabel.ts @@ -13,32 +13,8 @@ //// break; /*8*/ ////} -goTo.marker("1"); -verify.completionListContains("label"); - -goTo.marker("2"); -verify.completionListContains("label"); -verify.not.completionListContains("testlabel"); - -goTo.marker("3"); -verify.completionListContains("label"); -verify.completionListContains("testlabel"); - -goTo.marker("4"); -verify.completionListContains("label"); -verify.completionListContains("testlabel"); - -goTo.marker("5"); -verify.completionListContains("testlabel"); -verify.completionListContains("label"); - -goTo.marker("6"); -verify.completionListContains("testlabel"); -verify.completionListContains("label"); - -goTo.marker("7"); -verify.completionListContains("label"); -verify.not.completionListContains("testlabel"); - -goTo.marker("8"); -verify.not.completionListContains("label"); +verify.completions( + { marker: ["1", "2", "7"], exact: "label" }, + { marker: ["3", "4", "5", "6"], exact: ["testlabel", "label"] }, + { marker: "8", excludes: ["label"] }, +); diff --git a/tests/cases/fourslash/completionListWithMeanings.ts b/tests/cases/fourslash/completionListWithMeanings.ts index 61dc95adca8b1..8c3498ebda5a7 100644 --- a/tests/cases/fourslash/completionListWithMeanings.ts +++ b/tests/cases/fourslash/completionListWithMeanings.ts @@ -1,5 +1,7 @@ /// +// @noLib: true + ////namespace m { export interface point2 { } } ////namespace m2 { export var zz = 10; } ////namespace m3 { export var zz2 = 10; export interface point3 { } } @@ -13,58 +15,29 @@ ////var kk: m3.point3/*membertypeExpr*/ = m3.zz2/*membervalueExpr*/; ////var zz = { x: 4, y: 3 }; -const markers = test.markerNames(); - -function getVerifyBasedOnMarker(marker: string, meaning: string) { - return marker.indexOf(meaning) === 0 ? verify : verify.not; -} - -function verifyCompletions(verify: FourSlashInterface.verifyNegatable, completions: CompletionInfo[]) { - for (const info of completions) { - verify.completionListContains(info[0], info[1]); - } -} - -type CompletionInfo = [string, string]; -function verifyCompletionsExistForMeaning(marker: string, meaning: string, completions: CompletionInfo[]) { - verifyCompletions(getVerifyBasedOnMarker(marker, meaning), completions); -} - -function verifyCompletionsDoNotExistForMeaning(marker: string, meaning: string, completions: CompletionInfo[]) { - verifyCompletions(getVerifyBasedOnMarker(marker, meaning) === verify.not ? verify : verify.not, completions); -} - -const values: CompletionInfo[] = [ - ["xx", "var xx: number"], - ["tt", "var tt: number"], - ["yy", "var yy: point"], - ["zz", "var zz: point"], - ["m2", "namespace m2"], // With no type side, allowed only in value +const values: ReadonlyArray = [ + { name: "m2", text: "namespace m2" }, // With no type side, allowed only in value + { name: "m3", text: "namespace m3" }, + { name: "xx", text: "var xx: number" }, + { name: "tt", text: "var tt: number" }, + { name: "yy", text: "var yy: point" }, + { name: "kk", text: "var kk: m3.point3" }, + { name: "zz", text: "var zz: point" }, + "undefined", + ...completion.statementKeywordsWithTypes, ]; -const types: CompletionInfo[] = [ - ["point", "interface point"], - ["m", "namespace m"], // Uninstantiated namespace only allowed at type locations -]; - -const namespaces: CompletionInfo[] = [ - ["m3", "namespace m3"], // Has both type and values, allowed in all locations -]; - -const membervalues: CompletionInfo[] = [ - ["zz2", "var m3.zz2: number"], -]; - - -const membertypes: CompletionInfo[] = [ - ["point3", "interface m3.point3"], +const types: ReadonlyArray = [ + { name: "m", text: "namespace m" }, + { name: "m3", text: "namespace m3" }, + { name: "point", text: "interface point" }, + ...completion.typeKeywords, ]; -for (const marker of markers) { - goTo.marker(marker); - verifyCompletionsExistForMeaning(marker, "value", values); - verifyCompletionsExistForMeaning(marker, "type", types); - verifyCompletionsExistForMeaning(marker, "membervalue", membervalues); - verifyCompletionsExistForMeaning(marker, "membertype", membertypes); - verifyCompletionsDoNotExistForMeaning(marker, "member", namespaces); -} \ No newline at end of file +verify.completions( + { marker: "valueExpr", exact: values, isNewIdentifierLocation: true }, + { marker: "typeExpr", exact: types, }, + { marker: "valueExprInObjectLiteral", exact: values }, + { marker: "membertypeExpr", exact: [{ name: "point3", text: "interface m3.point3" }] }, + { marker: "membervalueExpr", exact: [{ name: "zz2", text: "var m3.zz2: number" }] }, +); diff --git a/tests/cases/fourslash/completionListWithModulesFromModule.ts b/tests/cases/fourslash/completionListWithModulesFromModule.ts index 462faa5ebf510..d08e26a8d504e 100644 --- a/tests/cases/fourslash/completionListWithModulesFromModule.ts +++ b/tests/cases/fourslash/completionListWithModulesFromModule.ts @@ -1,5 +1,7 @@ /// +// @noLib: true + ////namespace mod1 { //// var mod1var = 1; //// function mod1fn() { @@ -248,118 +250,55 @@ //// ////var shwvar = 1; -function sharedNegativeVerify() -{ - verify.not.completionListContains('sfvar'); - verify.not.completionListContains('sffn'); - verify.not.completionListContains('scvar'); - verify.not.completionListContains('scfn'); - verify.not.completionListContains('scpfn'); - verify.not.completionListContains('scpvar'); - verify.not.completionListContains('scsvar'); - verify.not.completionListContains('scsfn'); - verify.not.completionListContains('sivar'); - verify.not.completionListContains('sifn'); - verify.not.completionListContains('mod1exvar'); - verify.not.completionListContains('mod2eexvar'); -} - -function goToMarkAndVerifyShadow() -{ - sharedNegativeVerify(); - verify.not.completionListContains('mod2var'); - verify.not.completionListContains('mod2fn'); - verify.not.completionListContains('mod2cls'); - verify.not.completionListContains('mod2int'); - verify.not.completionListContains('mod2mod'); - verify.not.completionListContains('mod2evar'); - verify.not.completionListContains('mod2efn'); - verify.not.completionListContains('mod2ecls'); - verify.not.completionListContains('mod2eint'); - verify.not.completionListContains('mod2emod'); -} - -function getVerify(isTypeLocation?: boolean) { - return { - verifyValue: isTypeLocation ? verify.not : verify, - verifyType: isTypeLocation ? verify : verify.not, - verifyValueOrType: verify - }; -} - -function typeLocationVerify(valueMarker: string, verify: (typeMarker: string) => void) { - verify(valueMarker + "Type"); - return valueMarker; -} -// from a shadow namespace with no export -verifyShadowNamespaceWithNoExport(); -function verifyShadowNamespaceWithNoExport(marker?: string) { - const { verifyValue, verifyType, verifyValueOrType } = getVerify(!!marker); - if (!marker) { - marker = typeLocationVerify('shadowNamespaceWithNoExport', verifyShadowNamespaceWithNoExport); - } - goTo.marker(marker); - - verifyValue.completionListContains('shwvar', 'var shwvar: string'); - verifyValue.completionListContains('shwfn', 'function shwfn(shadow: any): void'); - verifyValueOrType.completionListContains('shwcls', 'class shwcls'); - verifyType.completionListContains('shwint', 'interface shwint'); +const commonValues: ReadonlyArray = + [1, 2, 3, 4, 5].map(n => ({ name: `mod${n}`, text: `namespace mod${n}` })); +const commonTypes: ReadonlyArray = + [1, 2, 4].map(n => ({ name: `mod${n}`, text: `namespace mod${n}` })); - goToMarkAndVerifyShadow(); -} - -// from a shadow namespace with export -verifyShadowNamespaceWithNoExport(); -function verifyShadowNamespaceWithExport(marker?: string) { - const { verifyValue, verifyType, verifyValueOrType } = getVerify(!!marker); - if (!marker) { - marker = typeLocationVerify('shadowNamespaceWithExport', verifyShadowNamespaceWithExport); - } - goTo.marker(marker); - verifyValue.completionListContains('shwvar', 'var mod4.shwvar: string'); - verifyValue.completionListContains('shwfn', 'function mod4.shwfn(shadow: any): void'); - verifyValueOrType.completionListContains('shwcls', 'class mod4.shwcls'); - verifyType.completionListContains('shwint', 'interface mod4.shwint'); - goToMarkAndVerifyShadow(); -} - -// from a namespace with import -verifyShadowNamespaceWithNoExport(); -function verifyNamespaceWithImport(marker?: string) { - const { verifyValue, verifyType, verifyValueOrType } = getVerify(!!marker); - if (!marker) { - marker = typeLocationVerify('namespaceWithImport', verifyNamespaceWithImport); +verify.completions( + { + marker: ["shadowNamespaceWithNoExport", "shadowNamespaceWithExport"], + exact: [ + { name: "shwfn", text: "function shwfn(shadow: any): void" }, + { name: "shwvar", text: "var shwvar: string" }, + { name: "shwcls", text: "class shwcls" }, + "tmp", + ...commonValues, + "undefined", + ...completion.statementKeywordsWithTypes, + ], + }, { + marker: ["shadowNamespaceWithNoExportType", "shadowNamespaceWithExportType"], + exact: [ + { name: "shwcls", text: "class shwcls" }, + { name: "shwint", text: "interface shwint" }, + ...commonTypes, + ...completion.typeKeywords, + ] + }, + { + marker: "namespaceWithImport", + exact: [ + "Mod1", + "iMod1", + "tmp", + { name: "shwfn", text: "function shwfn(): void" }, + ...commonValues, + { name: "shwcls", text: "class shwcls" }, + { name: "shwvar", text: "var shwvar: number" }, + "undefined", + ...completion.statementKeywordsWithTypes, + ], + }, + { + marker: "namespaceWithImportType", + exact: [ + "Mod1", + "iMod1", + ...commonTypes, + { name: "shwcls", text: "class shwcls" }, + { name: "shwint", text: "interface shwint" }, + ...completion.typeKeywords, + ], } - goTo.marker(marker); - - verifyValue.completionListContains('mod1', 'namespace mod1'); - verifyValue.completionListContains('mod2', 'namespace mod2'); - verifyValue.completionListContains('mod3', 'namespace mod3'); - verifyValue.completionListContains('shwvar', 'var shwvar: number'); - verifyValue.completionListContains('shwfn', 'function shwfn(): void'); - verifyValueOrType.completionListContains('shwcls', 'class shwcls'); - verifyType.completionListContains('shwint', 'interface shwint'); - - sharedNegativeVerify(); - - verify.not.completionListContains('mod1var'); - verify.not.completionListContains('mod1fn'); - verify.not.completionListContains('mod1cls'); - verify.not.completionListContains('mod1int'); - verify.not.completionListContains('mod1mod'); - verify.not.completionListContains('mod1evar'); - verify.not.completionListContains('mod1efn'); - verify.not.completionListContains('mod1ecls'); - verify.not.completionListContains('mod1eint'); - verify.not.completionListContains('mod1emod'); - verify.not.completionListContains('mX'); - verify.not.completionListContains('mFunc'); - verify.not.completionListContains('mClass'); - verify.not.completionListContains('mInt'); - verify.not.completionListContains('mMod'); - verify.not.completionListContains('meX'); - verify.not.completionListContains('meFunc'); - verify.not.completionListContains('meClass'); - verify.not.completionListContains('meInt'); - verify.not.completionListContains('meMod'); -} \ No newline at end of file +); diff --git a/tests/cases/fourslash/completionListWithModulesInsideModuleScope.ts b/tests/cases/fourslash/completionListWithModulesInsideModuleScope.ts index 682ef9b453e52..d1bc6233f72e6 100644 --- a/tests/cases/fourslash/completionListWithModulesInsideModuleScope.ts +++ b/tests/cases/fourslash/completionListWithModulesInsideModuleScope.ts @@ -1,5 +1,7 @@ /// +// @noLib: true + ////namespace mod1 { //// var mod1var = 1; //// function mod1fn() { @@ -229,146 +231,177 @@ //// ////var shwvar = 1; -interface GotoMarkVerifyOptions { - isClassScope?: boolean; - isTypeLocation?: boolean; - insideMod1?: boolean; -} - -function getVerify(isTypeLocation: boolean) { - return { - verifyValue: isTypeLocation ? verify.not : verify, - verifyType: isTypeLocation ? verify : verify.not, - verifyValueOrType: verify, - verifyNotValueOrType: verify.not, - }; +interface VerifyGeneralOptions { + readonly isClassScope?: boolean; + readonly isTypeLocation?: boolean; + readonly insideMod1?: boolean; + readonly isNewIdentifierLocation?: boolean; + readonly moreIncludes?: ReadonlyArray; + readonly moreExcludes?: ReadonlyArray; } -function goToMarkAndGeneralVerify(marker: string, { isClassScope, isTypeLocation, insideMod1 }: GotoMarkVerifyOptions = {}) { - goTo.marker(marker); - +function verifyGeneral(marker: string, { isClassScope, isTypeLocation, insideMod1, isNewIdentifierLocation, moreIncludes, moreExcludes }: VerifyGeneralOptions = {}) { const mod1Dot = insideMod1 ? "" : "mod1."; - const verifyValueInModule = isClassScope || isTypeLocation ? verify.not : verify; - const verifyValueOrTypeInModule = isClassScope ? verify.not : verify; - const verifyTypeInModule = isTypeLocation ? verify : verify.not; - verifyValueInModule.completionListContains('mod1var', 'var mod1var: number'); - verifyValueInModule.completionListContains('mod1fn', 'function mod1fn(): void'); - verifyValueInModule.completionListContains('mod1evar', `var ${mod1Dot}mod1evar: number`); - verifyValueInModule.completionListContains('mod1efn', `function ${mod1Dot}mod1efn(): void`); - verifyValueInModule.completionListContains('mod1eexvar', `var mod1.mod1eexvar: number`); - verifyValueInModule.completionListContains('mod3', 'namespace mod3'); - verifyValueInModule.completionListContains('shwvar', 'var shwvar: number'); - verifyValueInModule.completionListContains('shwfn', 'function shwfn(): void'); - - verifyTypeInModule.completionListContains('mod1int', 'interface mod1int'); - verifyTypeInModule.completionListContains('mod1eint', `interface ${mod1Dot}mod1eint`); - verifyTypeInModule.completionListContains('shwint', 'interface shwint'); - verifyValueOrTypeInModule.completionListContains('mod1cls', 'class mod1cls'); - verifyValueOrTypeInModule.completionListContains('mod1mod', 'namespace mod1mod'); - verifyValueOrTypeInModule.completionListContains('mod1ecls', `class ${mod1Dot}mod1ecls`); - verifyValueOrTypeInModule.completionListContains('mod1emod', `namespace ${mod1Dot}mod1emod`); - verifyValueOrTypeInModule.completionListContains('mod2', 'namespace mod2'); - verifyValueOrTypeInModule.completionListContains('shwcls', 'class shwcls'); - - verify.not.completionListContains('mod2var'); - verify.not.completionListContains('mod2fn'); - verify.not.completionListContains('mod2cls'); - verify.not.completionListContains('mod2int'); - verify.not.completionListContains('mod2mod'); - verify.not.completionListContains('mod2evar'); - verify.not.completionListContains('mod2efn'); - verify.not.completionListContains('mod2ecls'); - verify.not.completionListContains('mod2eint'); - verify.not.completionListContains('mod2emod'); - verify.not.completionListContains('sfvar'); - verify.not.completionListContains('sffn'); - verify.not.completionListContains('scvar'); - verify.not.completionListContains('scfn'); - verify.not.completionListContains('scpfn'); - verify.not.completionListContains('scpvar'); - verify.not.completionListContains('scsvar'); - verify.not.completionListContains('scsfn'); - verify.not.completionListContains('sivar'); - verify.not.completionListContains('sifn'); - verify.not.completionListContains('mod1exvar'); - verify.not.completionListContains('mod2eexvar'); + const valueInModule: ReadonlyArray = [ + { name: "mod1var", text: "var mod1var: number" }, + { name: "mod1fn", text: "function mod1fn(): void" }, + { name: "mod1evar", text: `var ${mod1Dot}mod1evar: number` }, + { name: "mod1efn", text: `function ${mod1Dot}mod1efn(): void` }, + { name: "mod1eexvar", text: `var mod1.mod1eexvar: number` }, + { name: "mod3", text: "namespace mod3" }, + { name: "shwvar", text: "var shwvar: number" }, + { name: "shwfn", text: "function shwfn(): void" }, + ]; + const typeInModule: ReadonlyArray = [ + { name: "mod1int", text: "interface mod1int" }, + { name: "mod1eint", text: `interface ${mod1Dot}mod1eint` }, + { name: "shwint", text: "interface shwint" }, + ]; + const valueOrTypeInModule: ReadonlyArray = [ + { name: "mod1cls", text: "class mod1cls" }, + { name: "mod1mod", text: "namespace mod1mod" }, + { name: "mod1ecls", text: `class ${mod1Dot}mod1ecls` }, + { name: "mod1emod", text: `namespace ${mod1Dot}mod1emod` }, + { name: "mod2", text: "namespace mod2" }, + { name: "shwcls", text: "class shwcls" }, + ]; + + verify.completions({ + marker, + includes: [ + ...(isClassScope || isTypeLocation ? [] : valueInModule), + ...(isClassScope ? [] : valueOrTypeInModule), + ...(isTypeLocation ? typeInModule : []), + ...(moreIncludes || []), + ], + excludes: [ + "mod2var", + "mod2fn", + "mod2cls", + "mod2int", + "mod2mod", + "mod2evar", + "mod2efn", + "mod2ecls", + "mod2eint", + "mod2emod", + "sfvar", + "sffn", + "scvar", + "scfn", + "scpfn", + "scpvar", + "scsvar", + "scsfn", + "sivar", + "sifn", + "mod1exvar", + "mod2eexvar", + ...(moreExcludes || []), + ], + isNewIdentifierLocation, + }); } // from mod1 -goToMarkAndGeneralVerify('mod1', { insideMod1: true }); +verifyGeneral('mod1', { insideMod1: true }); // from mod1 in type position -goToMarkAndGeneralVerify('mod1Type', { isTypeLocation: true, insideMod1: true }); +verifyGeneral('mod1Type', { isTypeLocation: true, insideMod1: true }); // from function in mod1 -goToMarkAndGeneralVerify('function', { insideMod1: true }); -verify.completionListContains('bar', '(local var) bar: number'); -verify.completionListContains('foob', '(local function) foob(): void'); +verifyGeneral('function', { + insideMod1: true, + moreIncludes: [ + { name: "bar", text: "(local var) bar: number" }, + { name: "foob", text: "(local function) foob(): void" }, + ], +}); // from class in mod1 -goToMarkAndGeneralVerify('class', { isClassScope: true }); -//verify.not.completionListContains('ceFunc'); -//verify.not.completionListContains('ceVar'); +verifyGeneral('class', { + isClassScope: true, + isNewIdentifierLocation: true, + moreExcludes: ["ceFunc", "ceVar"], +}); // from interface in mod1 -verify.completionsAt("interface", ["readonly"], { isNewIdentifierLocation: true }); +verify.completions({ + marker: "interface", + exact: "readonly", + isNewIdentifierLocation: true, +}); // from namespace in mod1 verifyNamespaceInMod1('namespace'); verifyNamespaceInMod1('namespaceType', /*isTypeLocation*/ true); function verifyNamespaceInMod1(marker: string, isTypeLocation?: boolean) { - goToMarkAndGeneralVerify(marker, { isTypeLocation, insideMod1: true }); - - const { verifyValue, verifyType, verifyValueOrType, verifyNotValueOrType } = getVerify(isTypeLocation); - - verifyValue.completionListContains('m1X', 'var m1X: number'); - verifyValue.completionListContains('m1Func', 'function m1Func(): void'); - verifyValue.completionListContains('m1eX', 'var m1eX: number'); - verifyValue.completionListContains('m1eFunc', 'function m1eFunc(): void'); - - verifyType.completionListContains('m1Int', 'interface m1Int'); - verifyType.completionListContains('m1eInt', 'interface m1eInt'); - - verifyValueOrType.completionListContains('m1Class', 'class m1Class'); - verifyValueOrType.completionListContains('m1eClass', 'class m1eClass'); - - verifyNotValueOrType.completionListContains('m1Mod', 'namespace m1Mod'); - verifyNotValueOrType.completionListContains('m1eMod', 'namespace m1eMod'); + verifyGeneral(marker, { isTypeLocation, insideMod1: true }); + + const values: ReadonlyArray = [ + { name: "m1X", text: "var m1X: number" }, + { name: "m1Func", text: "function m1Func(): void" }, + { name: "m1eX", text: "var m1eX: number" }, + { name: "m1eFunc", text: "function m1eFunc(): void" }, + ]; + const types: ReadonlyArray = [ + { name: "m1Int", text: "interface m1Int" }, + { name: "m1eInt", text: "interface m1eInt" }, + ]; + verify.completions({ + includes: [ + ...(isTypeLocation ? types : values), + { name: "m1Class", text: "class m1Class" }, + { name: "m1eClass", text: "class m1eClass" }, + ], + excludes: ["m1Mod", "m1eMod"], + }); } // from exported function in mod1 -goToMarkAndGeneralVerify('exportedFunction', { insideMod1: true }); -verify.completionListContains('bar', '(local var) bar: number'); -verify.completionListContains('foob', '(local function) foob(): void'); +verifyGeneral('exportedFunction', { + insideMod1: true, + moreIncludes: [ + { name: "bar", text: "(local var) bar: number" }, + { name: "foob", text: "(local function) foob(): void" }, + ], +}); // from exported class in mod1 -goToMarkAndGeneralVerify('exportedClass', { isClassScope: true }); -verify.not.completionListContains('ceFunc'); -verify.not.completionListContains('ceVar'); +verifyGeneral('exportedClass', { + isClassScope: true, + isNewIdentifierLocation: true, + moreExcludes: ["ceFunc", "ceVar"], +}); // from exported interface in mod1 -verify.completionsAt("exportedInterface", ["readonly"], { isNewIdentifierLocation: true }); +verify.completions({ marker: "exportedInterface", exact: ["readonly"], isNewIdentifierLocation: true }); // from exported namespace in mod1 verifyExportedNamespace('exportedNamespace'); verifyExportedNamespace('exportedNamespaceType', /*isTypeLocation*/ true); function verifyExportedNamespace(marker: string, isTypeLocation?: boolean) { - goToMarkAndGeneralVerify(marker, { isTypeLocation, insideMod1: true }); - const { verifyValue, verifyType, verifyValueOrType, verifyNotValueOrType } = getVerify(isTypeLocation); - verifyValue.completionListContains('mX', 'var mX: number'); - verifyValue.completionListContains('mFunc', 'function mFunc(): void'); - verifyValue.completionListContains('meX', 'var meX: number'); - verifyValue.completionListContains('meFunc', 'function meFunc(): void'); - - verifyType.completionListContains('mInt', 'interface mInt'); - verifyType.completionListContains('meInt', 'interface meInt'); - - verifyValueOrType.completionListContains('mClass', 'class mClass'); - verifyValueOrType.completionListContains('meClass', 'class meClass'); - - verifyNotValueOrType.completionListContains('mMod', 'namespace mMod'); - verifyNotValueOrType.completionListContains('meMod', 'namespace meMod'); + const values: ReadonlyArray = [ + { name: "mX", text: "var mX: number" }, + { name: "mFunc", text: "function mFunc(): void" }, + { name: "meX", text: "var meX: number" }, + { name: "meFunc", text: "function meFunc(): void" }, + ]; + const types: ReadonlyArray = [ + { name: "mInt", text: "interface mInt" }, + { name: "meInt", text: "interface meInt" }, + ]; + verifyGeneral(marker, { + isTypeLocation, + insideMod1: true, + moreIncludes: [ + ...(isTypeLocation ? types : values), + { name: "mClass", text: "class mClass" }, + { name: "meClass", text: "class meClass" }, + ], + moreExcludes: ["mMod", "meMod"], + }); } // from extended namespace @@ -376,44 +409,50 @@ verifyExtendedNamespace('extendedNamespace'); verifyExtendedNamespace('extendedNamespaceType', /*isTypeLocation*/ true); function verifyExtendedNamespace(marker: string, isTypeLocation?: boolean) { - goTo.marker(marker); - const { verifyValue, verifyType, verifyValueOrType, verifyNotValueOrType } = getVerify(isTypeLocation); - - verifyValue.completionListContains('mod1evar', 'var mod1.mod1evar: number'); - verifyValue.completionListContains('mod1efn', 'function mod1.mod1efn(): void'); - verifyValue.completionListContains('mod1eexvar', 'var mod1eexvar: number'); - verifyValue.completionListContains('mod3', 'namespace mod3'); - verifyValue.completionListContains('shwvar', 'var shwvar: number'); - verifyValue.completionListContains('shwfn', 'function shwfn(): void'); - - verifyType.completionListContains('mod1eint', 'interface mod1.mod1eint'); - verifyType.completionListContains('shwint', 'interface shwint'); - - verifyValueOrType.completionListContains('mod1ecls', 'class mod1.mod1ecls'); - verifyValueOrType.completionListContains('mod1emod', 'namespace mod1.mod1emod'); - verifyValueOrType.completionListContains('mod2', 'namespace mod2'); - verifyValueOrType.completionListContains('shwcls', 'class shwcls'); - - - verify.not.completionListContains('mod2var'); - verify.not.completionListContains('mod2fn'); - verify.not.completionListContains('mod2cls'); - verify.not.completionListContains('mod2int'); - verify.not.completionListContains('mod2mod'); - verify.not.completionListContains('mod2evar'); - verify.not.completionListContains('mod2efn'); - verify.not.completionListContains('mod2ecls'); - verify.not.completionListContains('mod2eint'); - verify.not.completionListContains('mod2emod'); - verify.not.completionListContains('sfvar'); - verify.not.completionListContains('sffn'); - verify.not.completionListContains('scvar'); - verify.not.completionListContains('scfn'); - verify.not.completionListContains('scpfn'); - verify.not.completionListContains('scpvar'); - verify.not.completionListContains('scsvar'); - verify.not.completionListContains('scsfn'); - verify.not.completionListContains('sivar'); - verify.not.completionListContains('sifn'); - verify.not.completionListContains('mod2eexvar'); + const values: ReadonlyArray = [ + { name: "mod1evar", text: "var mod1.mod1evar: number" }, + { name: "mod1efn", text: "function mod1.mod1efn(): void" }, + { name: "mod1eexvar", text: "var mod1eexvar: number" }, + { name: "mod3", text: "namespace mod3" }, + { name: "shwvar", text: "var shwvar: number" }, + { name: "shwfn", text: "function shwfn(): void" }, + ]; + const types: ReadonlyArray = [ + { name: "mod1eint", text: "interface mod1.mod1eint" }, + { name: "shwint", text: "interface shwint" }, + ]; + + verify.completions({ + marker, + includes: [ + ...(isTypeLocation ? types : values), + { name: "mod1ecls", text: "class mod1.mod1ecls" }, + { name: "mod1emod", text: "namespace mod1.mod1emod" }, + { name: "mod2", text: "namespace mod2" }, + { name: "shwcls", text: "class shwcls" }, + ], + excludes: [ + "mod2var", + "mod2fn", + "mod2cls", + "mod2int", + "mod2mod", + "mod2evar", + "mod2efn", + "mod2ecls", + "mod2eint", + "mod2emod", + "sfvar", + "sffn", + "scvar", + "scfn", + "scpfn", + "scpvar", + "scsvar", + "scsfn", + "sivar", + "sifn", + "mod2eexvar", + ], + }); } diff --git a/tests/cases/fourslash/completionListWithModulesOutsideModuleScope.ts b/tests/cases/fourslash/completionListWithModulesOutsideModuleScope.ts index c72159b002799..8b9a13fc5b29e 100644 --- a/tests/cases/fourslash/completionListWithModulesOutsideModuleScope.ts +++ b/tests/cases/fourslash/completionListWithModulesOutsideModuleScope.ts @@ -219,73 +219,44 @@ ////var shwvar = 1; /////*global*/ -function verifyNotContainFunctionMembers() -{ - verify.not.completionListContains('sfvar'); - verify.not.completionListContains('sffn'); -} - -function verifyNotContainClassMembers() -{ - verify.not.completionListContains('scvar'); - verify.not.completionListContains('scfn'); - verify.not.completionListContains('scpfn'); - verify.not.completionListContains('scpvar'); - verify.not.completionListContains('scsvar'); - verify.not.completionListContains('scsfn'); -} - -function verifyNotContainInterfaceMembers() -{ - verify.not.completionListContains('sivar'); - verify.not.completionListContains('sifn'); -} - -function goToMarkAndGeneralVerify(marker: string) -{ - goTo.marker(marker); - - verify.not.completionListContains('mod1var'); - verify.not.completionListContains('mod1fn'); - verify.not.completionListContains('mod1cls'); - verify.not.completionListContains('mod1int'); - verify.not.completionListContains('mod1mod'); - verify.not.completionListContains('mod1evar'); - verify.not.completionListContains('mod1efn'); - verify.not.completionListContains('mod1ecls'); - verify.not.completionListContains('mod1eint'); - verify.not.completionListContains('mod1emod'); - verify.not.completionListContains('mod1eexvar'); -} - -// from global scope -goToMarkAndGeneralVerify('global'); -verify.completionListContains('mod1', 'namespace mod1'); -verify.completionListContains('mod2', 'namespace mod2'); -verify.completionListContains('mod3', 'namespace mod3'); -verify.completionListContains('shwvar', 'var shwvar: number'); -verify.completionListContains('shwfn', 'function shwfn(): void'); -verify.completionListContains('shwcls', 'class shwcls'); -verify.not.completionListContains('shwint', 'interface shwint'); - -verifyNotContainFunctionMembers(); -verifyNotContainClassMembers(); -verifyNotContainInterfaceMembers(); - -// from function scope -goToMarkAndGeneralVerify('function'); -verify.completionListContains('sfvar', '(local var) sfvar: number'); -verify.completionListContains('sffn', '(local function) sffn(): void'); - -verifyNotContainClassMembers(); -verifyNotContainInterfaceMembers(); - -// from class scope -goToMarkAndGeneralVerify('class'); -verifyNotContainFunctionMembers(); -verifyNotContainInterfaceMembers(); - -// from interface scope -goToMarkAndGeneralVerify('interface'); -verifyNotContainClassMembers(); -verifyNotContainFunctionMembers(); \ No newline at end of file +const commonExcludes: ReadonlyArray = [ + "mod1var", "mod1fn", "mod1cls", "mod1int", "mod1mod", "mod1evar", "mod1efn", "mod1ecls", "mod1eint", "mod1emod", "mod1eexvar", + "scvar", "scfn", "scpfn", "scpvar", "scsvar", "scsfn", + "sivar", "sifn", +]; +verify.completions( + // from global scope + { + marker: "global", + includes: [ + { name: "mod1", text: "namespace mod1" }, + { name: "mod2", text: "namespace mod2" }, + { name: "mod3", text: "namespace mod3" }, + { name: "shwvar", text: "var shwvar: number" }, + { name: "shwfn", text: "function shwfn(): void" }, + { name: "shwcls", text: "class shwcls" }, + ], + excludes: [...commonExcludes, "shwint", "sfvar", "sffn"], + }, + // from function scope + { + marker: "function", + includes: [ + { name: "sfvar", text: "(local var) sfvar: number" }, + { name: "sffn", text: "(local function) sffn(): void" }, + ], + excludes: commonExcludes, + }, + // from class scope + { + marker: "class", + exact: completion.classElementKeywords, + isNewIdentifierLocation: true, + }, + // from interface scope + { + marker: "interface", + exact: ["readonly"], + isNewIdentifierLocation: true, + } +); diff --git a/tests/cases/fourslash/completionListWithModulesOutsideModuleScope2.ts b/tests/cases/fourslash/completionListWithModulesOutsideModuleScope2.ts index c8aa1933defa5..7d015de28b30d 100644 --- a/tests/cases/fourslash/completionListWithModulesOutsideModuleScope2.ts +++ b/tests/cases/fourslash/completionListWithModulesOutsideModuleScope2.ts @@ -1,4 +1,4 @@ -/// +/// ////module mod1 { //// var mod1var = 1; @@ -231,76 +231,50 @@ //// x: /*objectLiteral*/ ////} -goTo.marker('extendedClass'); - -verify.not.completionListContains('mod1'); -verify.not.completionListContains('mod2'); -verify.not.completionListContains('mod3'); -verify.not.completionListContains('shwvar', 'var shwvar: number'); -verify.not.completionListContains('shwfn', 'function shwfn(): void'); -verify.not.completionListContains('shwcls', 'class shwcls'); -verify.not.completionListContains('shwint', 'interface shwint'); - -verify.not.completionListContains('mod2var'); -verify.not.completionListContains('mod2fn'); -verify.not.completionListContains('mod2cls'); -verify.not.completionListContains('mod2int'); -verify.not.completionListContains('mod2mod'); -verify.not.completionListContains('mod2evar'); -verify.not.completionListContains('mod2efn'); -verify.not.completionListContains('mod2ecls'); -verify.not.completionListContains('mod2eint'); -verify.not.completionListContains('mod2emod'); -verify.not.completionListContains('sfvar'); -verify.not.completionListContains('sffn'); -verify.not.completionListContains('scvar'); -verify.not.completionListContains('scfn'); -verify.completionListContains('scpfn'); -verify.completionListContains('scpvar'); -verify.not.completionListContains('scsvar'); -verify.not.completionListContains('scsfn'); -verify.not.completionListContains('sivar'); -verify.not.completionListContains('sifn'); -verify.not.completionListContains('mod1exvar'); -verify.not.completionListContains('mod2eexvar'); - -function goToMarkerAndVerify(marker: string) -{ - goTo.marker(marker); - - verify.completionListContains('mod1'); - verify.completionListContains('mod2'); - verify.completionListContains('mod3'); - verify.completionListContains('shwvar', 'var shwvar: number'); - verify.completionListContains('shwfn', 'function shwfn(): void'); - verify.completionListContains('shwcls', 'class shwcls'); - verify.not.completionListContains('shwint', 'interface shwint'); - - verify.not.completionListContains('mod2var'); - verify.not.completionListContains('mod2fn'); - verify.not.completionListContains('mod2cls'); - verify.not.completionListContains('mod2int'); - verify.not.completionListContains('mod2mod'); - verify.not.completionListContains('mod2evar'); - verify.not.completionListContains('mod2efn'); - verify.not.completionListContains('mod2ecls'); - verify.not.completionListContains('mod2eint'); - verify.not.completionListContains('mod2emod'); - verify.not.completionListContains('sfvar'); - verify.not.completionListContains('sffn'); - verify.not.completionListContains('scvar'); - verify.not.completionListContains('scfn'); - verify.not.completionListContains('scpfn'); - verify.not.completionListContains('scpvar'); - verify.not.completionListContains('scsvar'); - verify.not.completionListContains('scsfn'); - verify.not.completionListContains('sivar'); - verify.not.completionListContains('sifn'); - verify.not.completionListContains('mod1exvar'); - verify.not.completionListContains('mod2eexvar'); -} - -goToMarkerAndVerify('objectLiteral'); - -goTo.marker('localVar'); -verify.completionListContains('shwvar', '(local var) shwvar: string'); \ No newline at end of file +verify.completions( + { + marker: "extendedClass", + exact: ["scpfn", "scpvar", ...completion.classElementKeywords], + isNewIdentifierLocation: true, + }, + { + marker: "objectLiteral", + includes: [ + "mod1", + "mod2", + "mod3", + { name: "shwvar", text: "var shwvar: number" }, + { name: "shwfn", text: "function shwfn(): void" }, + { name: "shwcls", text: "class shwcls" }, + ], + excludes: [ + "shwint", + "mod2var", + "mod2fn", + "mod2cls", + "mod2int", + "mod2mod", + "mod2evar", + "mod2efn", + "mod2ecls", + "mod2eint", + "mod2emod", + "sfvar", + "sffn", + "scvar", + "scfn", + "scpfn", + "scpvar", + "scsvar", + "scsfn", + "sivar", + "sifn", + "mod1exvar", + "mod2eexvar", + ] + }, + { + marker: "localVar", + includes: { name: "shwvar", text: "(local var) shwvar: string" }, + }, +); diff --git a/tests/cases/fourslash/completionListWithUnresolvedModule.ts b/tests/cases/fourslash/completionListWithUnresolvedModule.ts index 0950636efee67..73c6c52a93795 100644 --- a/tests/cases/fourslash/completionListWithUnresolvedModule.ts +++ b/tests/cases/fourslash/completionListWithUnresolvedModule.ts @@ -5,6 +5,4 @@ //// var n: num/**/ ////} -goTo.marker(); - -verify.completionListContains('number'); +verify.completions({ marker: "", includes: "number" }); diff --git a/tests/cases/fourslash/completionList_getExportsOfModule.ts b/tests/cases/fourslash/completionList_getExportsOfModule.ts index 160ac17d843b8..55e4b8d49f556 100644 --- a/tests/cases/fourslash/completionList_getExportsOfModule.ts +++ b/tests/cases/fourslash/completionList_getExportsOfModule.ts @@ -11,6 +11,5 @@ //// ////let y: /**/ -goTo.marker(); // This is just a dummy test to cause `getCompletionsAtPosition` to be called. -verify.not.completionListContains("x"); +verify.completions({ marker: "", excludes: "x" }); diff --git a/tests/cases/fourslash/completionOfInterfaceAndVar.ts b/tests/cases/fourslash/completionOfInterfaceAndVar.ts index be1a1546d0b80..748078f2b4e97 100644 --- a/tests/cases/fourslash/completionOfInterfaceAndVar.ts +++ b/tests/cases/fourslash/completionOfInterfaceAndVar.ts @@ -1,17 +1,23 @@ /// -////interface AnalyserNode { -////} -////declare var AnalyserNode: { -//// prototype: AnalyserNode; -//// new(): AnalyserNode; +////interface AnalyserNode { +////} +////declare var AnalyserNode: { +//// prototype: AnalyserNode; +//// new(): AnalyserNode; ////}; /////**/ -goTo.marker(); -verify.completionListContains("AnalyserNode", /*text*/ undefined, /*documentation*/ undefined, "var"); -verify.completionEntryDetailIs("AnalyserNode", `interface AnalyserNode +verify.completions({ + marker: "", + includes: { + name: "AnalyserNode", + text: +`interface AnalyserNode var AnalyserNode: { new (): AnalyserNode; prototype: AnalyserNode; -}`, /*documentation*/ undefined, "var") \ No newline at end of file +}`, + kind: "var", + }, +}); diff --git a/tests/cases/fourslash/completionWithConditionalOperatorMissingColon.ts b/tests/cases/fourslash/completionWithConditionalOperatorMissingColon.ts index 9ec879d502236..95efcebbbf8c0 100644 --- a/tests/cases/fourslash/completionWithConditionalOperatorMissingColon.ts +++ b/tests/cases/fourslash/completionWithConditionalOperatorMissingColon.ts @@ -1,6 +1,5 @@ -/// -////1 ? fun/*1*/ -////function func () {} - -goTo.marker("1"); -verify.completionListContains("func"); +/// +////1 ? fun/*1*/ +////function func () {} + +verify.completions({ marker: "1", includes: "func" }); diff --git a/tests/cases/fourslash/completionWithDotFollowedByNamespaceKeyword.ts b/tests/cases/fourslash/completionWithDotFollowedByNamespaceKeyword.ts index 1526224eb20be..5f8ce63251fd2 100644 --- a/tests/cases/fourslash/completionWithDotFollowedByNamespaceKeyword.ts +++ b/tests/cases/fourslash/completionWithDotFollowedByNamespaceKeyword.ts @@ -8,5 +8,4 @@ //// export function baz() { } ////} -goTo.marker(); -verify.completionListContains("baz", "function B.baz(): void"); \ No newline at end of file +verify.completions({ marker: "", exact: { name: "baz", text: "function B.baz(): void" } }); diff --git a/tests/cases/fourslash/completionWithNamespaceInsideFunction.ts b/tests/cases/fourslash/completionWithNamespaceInsideFunction.ts index f9259dd2eed2f..9892af996b9cd 100644 --- a/tests/cases/fourslash/completionWithNamespaceInsideFunction.ts +++ b/tests/cases/fourslash/completionWithNamespaceInsideFunction.ts @@ -21,26 +21,27 @@ ////} /////*33*/ -goTo.marker('1'); -verify.completionListContains("f", "function f(): void"); -verify.not.completionListContains("n", "namespace n"); -verify.not.completionListContains("I", "interface I"); - -goTo.marker('2'); -verify.completionListContains("f", "function f(): void"); -verify.not.completionListContains("n", "namespace n"); - -goTo.marker('3'); -verify.completionListContains("f", "function f(): void"); - -goTo.marker('11'); -verify.completionListContains("f2", "function f2(): void"); -verify.completionListContains("n2", "namespace n2"); -verify.completionListContains("I2", "class I2"); - -goTo.marker('22'); -verify.completionListContains("f2", "function f2(): void"); -verify.completionListContains("n2", "namespace n2"); - -goTo.marker('33'); -verify.completionListContains("f2", "function f2(): void"); \ No newline at end of file +verify.completions( + { marker: ["1", "2", "3"], includes: { name: "f", text: "function f(): void" }, excludes: ["n", "I"] }, + { + marker: "11", + includes: [ + { name: "f2", text: "function f2(): void" }, + { name: "n2", text: "namespace n2" }, + { name: "I2", text: "class I2" }, + ], + }, + { + marker: "22", + includes: [ + { name: "f2", text: "function f2(): void" }, + { name: "n2", text: "namespace n2" }, + ], + excludes: "I2", + }, + { + marker: "33", + includes: { name: "f2", text: "function f2(): void" }, + excludes: ["n2", "I2"], + }, +); diff --git a/tests/cases/fourslash/completionsDefaultExport.ts b/tests/cases/fourslash/completionsDefaultExport.ts index 82bcefac40303..fff397862305d 100644 --- a/tests/cases/fourslash/completionsDefaultExport.ts +++ b/tests/cases/fourslash/completionsDefaultExport.ts @@ -7,5 +7,4 @@ ////import * as a from "./a"; ////a./**/; -goTo.marker(); -verify.completionListContains("default", "function f(): void"); +verify.completions({ marker: "", exact: { name: "default", text: "function f(): void" } }); diff --git a/tests/cases/fourslash/completionsDestructuring.ts b/tests/cases/fourslash/completionsDestructuring.ts index d2e9f38871e65..63cca7c41018e 100644 --- a/tests/cases/fourslash/completionsDestructuring.ts +++ b/tests/cases/fourslash/completionsDestructuring.ts @@ -5,8 +5,4 @@ ////const { /*b*/ } = points[0]; ////for (const { /*c*/ } of points) {} -goTo.eachMarker(() => { - verify.completionListContains("x"); - verify.completionListContains("y"); - verify.completionListCount(2); -}); +verify.completions({ marker: test.markers(), exact: ["x", "y"] }); diff --git a/tests/cases/fourslash/completionsForRecursiveGenericTypesMember.ts b/tests/cases/fourslash/completionsForRecursiveGenericTypesMember.ts index 993b9eb73ac96..afede5d353429 100644 --- a/tests/cases/fourslash/completionsForRecursiveGenericTypesMember.ts +++ b/tests/cases/fourslash/completionsForRecursiveGenericTypesMember.ts @@ -1,7 +1,7 @@ /// //// export class TestBase> -//// { +//// { //// public publicMethod(p: any): void {} //// private privateMethod(p: any): void {} //// protected protectedMethod(p: any): void {} @@ -11,8 +11,4 @@ //// } //// } -goTo.marker(); - -verify.completionListContains('publicMethod'); -verify.completionListContains('privateMethod'); -verify.completionListContains('protectedMethod'); +verify.completions({ marker: "", exact: ["publicMethod", "privateMethod", "protectedMethod", "test"] }); diff --git a/tests/cases/fourslash/completionsImportBaseUrl.ts b/tests/cases/fourslash/completionsImportBaseUrl.ts index 372dd86d4e969..413c798421551 100644 --- a/tests/cases/fourslash/completionsImportBaseUrl.ts +++ b/tests/cases/fourslash/completionsImportBaseUrl.ts @@ -15,8 +15,15 @@ ////fo/**/ // Test that it prefers a relative import (see sourceDisplay). -goTo.marker(""); -verify.completionListContains({ name: "foo", source: "/src/a" }, "const foo: 0", "", "const", undefined, /*hasAction*/ true, { - includeCompletionsForModuleExports: true, - sourceDisplay: "./a", +verify.completions({ + marker: "", + includes: { + name: "foo", + source: "/src/a", + sourceDisplay: "./a", + text: "const foo: 0", + kind: "const", + hasAction: true, + }, + preferences: { includeCompletionsForModuleExports: true }, }); diff --git a/tests/cases/fourslash/completionsImport_default_addToNamedImports.ts b/tests/cases/fourslash/completionsImport_default_addToNamedImports.ts index 5f9c677b61f7f..35c06d5a55019 100644 --- a/tests/cases/fourslash/completionsImport_default_addToNamedImports.ts +++ b/tests/cases/fourslash/completionsImport_default_addToNamedImports.ts @@ -8,10 +8,17 @@ ////import { x } from "./a"; ////f/**/; -goTo.marker(""); -verify.completionListContains({ name: "foo", source: "/a" }, "function foo(): void", "", "function", /*spanIndex*/ undefined, /*hasAction*/ true, { - includeExternalModuleExports: true, - sourceDisplay: "./a", +verify.completions({ + marker: "", + includes: { + name: "foo", + source: "/a", + sourceDisplay: "./a", + text: "function foo(): void", + kind: "function", + hasAction: true, + }, + preferences: { includeCompletionsForModuleExports: true }, }); verify.applyCodeActionFromCompletion("", { diff --git a/tests/cases/fourslash/completionsImport_default_addToNamespaceImport.ts b/tests/cases/fourslash/completionsImport_default_addToNamespaceImport.ts index 2b9543f0cb608..0a52a7103ee73 100644 --- a/tests/cases/fourslash/completionsImport_default_addToNamespaceImport.ts +++ b/tests/cases/fourslash/completionsImport_default_addToNamespaceImport.ts @@ -7,12 +7,11 @@ ////import * as a from "./a"; ////f/**/; -goTo.marker(""); -verify.completionListContains({ name: "foo", source: "/a" }, "function foo(): void", "", "function", /*spanIndex*/ undefined, /*hasAction*/ true, { - includeCompletionsForModuleExports: true, - sourceDisplay: "./a", +verify.completions({ + marker: "", + includes: { name: "foo", source: "/a", sourceDisplay: "./a", text: "function foo(): void", kind: "function", hasAction: true }, + preferences: { includeCompletionsForModuleExports: true }, }); - verify.applyCodeActionFromCompletion("", { name: "foo", source: "/a", diff --git a/tests/cases/fourslash/completionsImport_default_alreadyExistedWithRename.ts b/tests/cases/fourslash/completionsImport_default_alreadyExistedWithRename.ts index db9b23b082b88..d3027bb18cfb5 100644 --- a/tests/cases/fourslash/completionsImport_default_alreadyExistedWithRename.ts +++ b/tests/cases/fourslash/completionsImport_default_alreadyExistedWithRename.ts @@ -7,12 +7,11 @@ ////import f_o_o from "./a"; ////f/**/; -goTo.marker(""); -verify.completionListContains({ name: "foo", source: "/a" }, "function foo(): void", "", "function", /*spanIndex*/ undefined, /*hasAction*/ true, { - includeExternalModuleExports: true, - sourceDisplay: "./a", +verify.completions({ + marker: "", + includes: { name: "foo", source: "/a", sourceDisplay: "./a", text: "function foo(): void", kind: "function", hasAction: true }, + preferences: { includeCompletionsForModuleExports: true }, }); - verify.applyCodeActionFromCompletion("", { name: "foo", source: "/a", diff --git a/tests/cases/fourslash/completionsImport_default_anonymous.ts b/tests/cases/fourslash/completionsImport_default_anonymous.ts index 82e5f07b064dd..46b333beb292b 100644 --- a/tests/cases/fourslash/completionsImport_default_anonymous.ts +++ b/tests/cases/fourslash/completionsImport_default_anonymous.ts @@ -2,6 +2,7 @@ // Use `/src` to test that directory names are not included in conversion from module path to identifier. // @module: esnext +// @noLib: true // @Filename: /src/foo-bar.ts ////export default 0; @@ -13,8 +14,15 @@ goTo.marker("0"); const preferences: FourSlashInterface.UserPreferences = { includeCompletionsForModuleExports: true }; verify.completions( - { marker: "0", excludes: { name: "default", source: "/src/foo-bar" }, preferences }, - { marker: "1", includes: { name: "fooBar", source: "/src/foo-bar", sourceDisplay: "./foo-bar", text: "(property) default: 0", kind: "property", hasAction: true }, preferences } + { + marker: "0", + exact: ["undefined", ...completion.statementKeywordsWithTypes], + }, + { + marker: "1", + includes: { name: "fooBar", source: "/src/foo-bar", sourceDisplay: "./foo-bar", text: "(property) default: 0", kind: "property", hasAction: true }, + preferences, + }, ); verify.applyCodeActionFromCompletion("1", { name: "fooBar", diff --git a/tests/cases/fourslash/completionsImport_default_didNotExistBefore.ts b/tests/cases/fourslash/completionsImport_default_didNotExistBefore.ts index bb77874068c5a..69138fa9815c0 100644 --- a/tests/cases/fourslash/completionsImport_default_didNotExistBefore.ts +++ b/tests/cases/fourslash/completionsImport_default_didNotExistBefore.ts @@ -8,12 +8,11 @@ // @Filename: /b.ts ////f/**/; -goTo.marker(""); -verify.completionListContains({ name: "foo", source: "/a" }, "function foo(): void", "", "function", /*spanIndex*/ undefined, /*hasAction*/ true, { - includeExternalModuleExports: true, - sourceDisplay: "./a", +verify.completions({ + marker: "", + includes: { name: "foo", source: "/a", sourceDisplay: "./a", text: "function foo(): void", kind: "function", hasAction: true }, + preferences: { includeCompletionsForModuleExports: true }, }); - verify.applyCodeActionFromCompletion("", { name: "foo", source: "/a", diff --git a/tests/cases/fourslash/completionsImport_default_exportDefaultIdentifier.ts b/tests/cases/fourslash/completionsImport_default_exportDefaultIdentifier.ts index 3f0cb27e00a65..766f50fb9e951 100644 --- a/tests/cases/fourslash/completionsImport_default_exportDefaultIdentifier.ts +++ b/tests/cases/fourslash/completionsImport_default_exportDefaultIdentifier.ts @@ -12,11 +12,11 @@ ////f/**/; goTo.marker(""); -verify.completionListContains({ name: "foo", source: "/a" }, "(alias) const foo: 0\nexport default foo", "", "alias", /*spanIndex*/ undefined, /*hasAction*/ true, { - includeCompletionsForModuleExports: true, - sourceDisplay: "./a", +verify.completions({ + marker: "", + includes: { name: "foo", source: "/a", sourceDisplay: "./a", text: "(alias) const foo: 0\nexport default foo", kind: "alias", hasAction: true }, + preferences: { includeCompletionsForModuleExports: true }, }); - verify.applyCodeActionFromCompletion("", { name: "foo", source: "/a", diff --git a/tests/cases/fourslash/completionsImport_default_fromMergedDeclarations.ts b/tests/cases/fourslash/completionsImport_default_fromMergedDeclarations.ts index 6f6c01cf4d116..c4cfcb98531c8 100644 --- a/tests/cases/fourslash/completionsImport_default_fromMergedDeclarations.ts +++ b/tests/cases/fourslash/completionsImport_default_fromMergedDeclarations.ts @@ -15,12 +15,11 @@ // @Filename: /c.ts /////**/ -goTo.marker(""); -verify.completionListContains({ name: "M", source: "m" }, "class M", "", "class", /*spanIndex*/ undefined, /*hasAction*/ true, { - includeCompletionsForModuleExports: true, - sourceDisplay: "m", +verify.completions({ + marker: "", + includes: { name: "M", source: "m", sourceDisplay: "m", text: "class M", kind: "class", hasAction: true }, + preferences: { includeCompletionsForModuleExports: true }, }); - verify.applyCodeActionFromCompletion("", { name: "M", source: "m", diff --git a/tests/cases/fourslash/completionsImport_multipleWithSameName.ts b/tests/cases/fourslash/completionsImport_multipleWithSameName.ts index e6f2565d5c197..7df6fbfd8744d 100644 --- a/tests/cases/fourslash/completionsImport_multipleWithSameName.ts +++ b/tests/cases/fourslash/completionsImport_multipleWithSameName.ts @@ -1,6 +1,7 @@ /// // @module: esnext +// @noLib: true // @Filename: /global.d.ts // A local variable would prevent import completions (see `completionsImport_shadowedByLocal.ts`), but a global doesn't. @@ -16,11 +17,17 @@ ////fo/**/ goTo.marker(""); -const options = { includeExternalModuleExports: true, sourceDisplay: undefined }; -verify.completionListContains("foo", "var foo: number", "", "var", undefined, undefined, options); -verify.completionListContains({ name: "foo", source: "/a" }, "const foo: 0", "", "const", /*spanIndex*/ undefined, /*hasAction*/ true, { ...options, sourceDisplay: "./a" }); -verify.completionListContains({ name: "foo", source: "/b" }, "const foo: 1", "", "const", /*spanIndex*/ undefined, /*hasAction*/ true, { ...options, sourceDisplay: "./b" }); - +verify.completions({ + marker: "", + exact: [ + { name: "foo", text: "var foo: number", kind: "var" }, + "undefined", + { name: "foo", source: "/a", sourceDisplay: "./a", text: "const foo: 0", kind: "const", hasAction: true }, + { name: "foo", source: "/b", sourceDisplay: "./b", text: "const foo: 1", kind: "const", hasAction: true }, + ...completion.statementKeywordsWithTypes, + ], + preferences: { includeCompletionsForModuleExports: true }, +}); verify.applyCodeActionFromCompletion("", { name: "foo", source: "/b", diff --git a/tests/cases/fourslash/completionsImport_named_addToNamedImports.ts b/tests/cases/fourslash/completionsImport_named_addToNamedImports.ts index fa1be5ca7d2a5..3442d90e05b6d 100644 --- a/tests/cases/fourslash/completionsImport_named_addToNamedImports.ts +++ b/tests/cases/fourslash/completionsImport_named_addToNamedImports.ts @@ -8,12 +8,11 @@ ////import { x } from "./a"; ////f/**/; -goTo.marker(""); -verify.completionListContains({ name: "foo", source: "/a" }, "function foo(): void", "", "function", /*spanIndex*/ undefined, /*hasAction*/ true, { - includeExternalModuleExports: true, - sourceDisplay: "./a", +verify.completions({ + marker: "", + includes: { name: "foo", source: "/a", sourceDisplay: "./a", text: "function foo(): void", kind: "function", hasAction: true }, + preferences: { includeCompletionsForModuleExports: true }, }); - verify.applyCodeActionFromCompletion("", { name: "foo", source: "/a", diff --git a/tests/cases/fourslash/completionsImport_named_didNotExistBefore.ts b/tests/cases/fourslash/completionsImport_named_didNotExistBefore.ts index 94ed1b8a0fa25..321f27ce7606b 100644 --- a/tests/cases/fourslash/completionsImport_named_didNotExistBefore.ts +++ b/tests/cases/fourslash/completionsImport_named_didNotExistBefore.ts @@ -1,5 +1,6 @@ /// +// @noLib: true // @Filename: /a.ts ////export function Test1() {} @@ -11,11 +12,12 @@ verify.completions({ marker: "", - includes: [ - { name: "Test1", source: "/a", sourceDisplay: "./a", text: "function Test1(): void", kind: "function", hasAction: true }, + exact: [ { name: "Test2", text: "(alias) function Test2(): void\nimport Test2", kind: "alias" }, + "undefined", + { name: "Test1", source: "/a", sourceDisplay: "./a", text: "function Test1(): void", kind: "function", hasAction: true }, + ...completion.statementKeywordsWithTypes, ], - excludes: [{ name: "Test2", source: "/a" }], preferences: { includeCompletionsForModuleExports: true }, }); diff --git a/tests/cases/fourslash/completionsImport_named_exportEqualsNamespace.ts b/tests/cases/fourslash/completionsImport_named_exportEqualsNamespace.ts index b9b9b2b3ced0c..c6c9bc45b2c5b 100644 --- a/tests/cases/fourslash/completionsImport_named_exportEqualsNamespace.ts +++ b/tests/cases/fourslash/completionsImport_named_exportEqualsNamespace.ts @@ -11,12 +11,11 @@ // @Filename: /b.ts ////f/**/; -goTo.marker(""); -verify.completionListContains({ name: "foo", source: "/a" }, "const N.foo: 0", "", "const", /*spanIndex*/ undefined, /*hasAction*/ true, { - includeExternalModuleExports: true, - sourceDisplay: "./a", +verify.completions({ + marker: "", + includes: { name: "foo", source: "/a", sourceDisplay: "./a", text: "const N.foo: 0", kind: "const", hasAction: true }, + preferences: { includeCompletionsForModuleExports: true }, }); - verify.applyCodeActionFromCompletion("", { name: "foo", source: "/a", diff --git a/tests/cases/fourslash/completionsImport_named_exportEqualsNamespace_merged.ts b/tests/cases/fourslash/completionsImport_named_exportEqualsNamespace_merged.ts index ba9f5675a1d7e..f68c03f560215 100644 --- a/tests/cases/fourslash/completionsImport_named_exportEqualsNamespace_merged.ts +++ b/tests/cases/fourslash/completionsImport_named_exportEqualsNamespace_merged.ts @@ -16,8 +16,8 @@ // @Filename: /a.ts ////fo/**/ -goTo.marker(""); -verify.completionListContains({ name: "foo", source: "n" }, "const N.foo: number", "", "const", undefined, /*hasAction*/ true, { - includeExternalModuleExports: true, - sourceDisplay: "n", +verify.completions({ + marker: "", + includes: { name: "foo", source: "n", sourceDisplay: "n", text: "const N.foo: number", kind: "const", hasAction: true }, + preferences: { includeCompletionsForModuleExports: true }, }); diff --git a/tests/cases/fourslash/completionsImport_named_namespaceImportExists.ts b/tests/cases/fourslash/completionsImport_named_namespaceImportExists.ts index fddd8ae12caf2..4416b3703c9ee 100644 --- a/tests/cases/fourslash/completionsImport_named_namespaceImportExists.ts +++ b/tests/cases/fourslash/completionsImport_named_namespaceImportExists.ts @@ -7,12 +7,11 @@ ////import * as a from "./a"; ////f/**/; -goTo.marker(""); -verify.completionListContains({ name: "foo", source: "/a" }, "function foo(): void", "", "function", /*spanIndex*/ undefined, /*hasAction*/ true, { - includeExternalModuleExports: true, - sourceDisplay: "./a", +verify.completions({ + marker: "", + includes: { name: "foo", source: "/a", sourceDisplay: "./a", text: "function foo(): void", kind: "function", hasAction: true }, + preferences: { includeCompletionsForModuleExports: true }, }); - verify.applyCodeActionFromCompletion("", { name: "foo", source: "/a", diff --git a/tests/cases/fourslash/completionsImport_notFromIndex.ts b/tests/cases/fourslash/completionsImport_notFromIndex.ts index c42c768d23d5e..4ab8eaf10125d 100644 --- a/tests/cases/fourslash/completionsImport_notFromIndex.ts +++ b/tests/cases/fourslash/completionsImport_notFromIndex.ts @@ -16,8 +16,11 @@ ////x/*2*/ for (const [marker, sourceDisplay] of [["0", "./src"], ["1", "./a"], ["2", "../a"]]) { - goTo.marker(marker); - verify.completionListContains({ name: "x", source: "/src/a" }, "const x: 0", "", "const", /*spanIndex*/ undefined, /*hasAction*/ true, { includeCompletionsForModuleExports: true, sourceDisplay }); + verify.completions({ + marker, + includes: { name: "x", source: "/src/a", sourceDisplay, text: "const x: 0", kind: "const", hasAction: true }, + preferences: { includeCompletionsForModuleExports: true }, + }); verify.applyCodeActionFromCompletion(marker, { name: "x", source: "/src/a", diff --git a/tests/cases/fourslash/completionsImport_ofAlias.ts b/tests/cases/fourslash/completionsImport_ofAlias.ts index 708a5b99d3a53..cb6af7910ba53 100644 --- a/tests/cases/fourslash/completionsImport_ofAlias.ts +++ b/tests/cases/fourslash/completionsImport_ofAlias.ts @@ -21,8 +21,11 @@ verify.completions({ marker: "", - includes: { name: "foo", source: "/a", sourceDisplay: "./a", text: "(alias) const foo: 0\nexport foo", kind: "alias", hasAction: true }, - excludes: [{ name: "foo", source: "/a_reexport" }, { name: "foo", source: "/a_reexport_2" }], + includes: [ + "undefined", + { name: "foo", source: "/a", sourceDisplay: "./a", text: "(alias) const foo: 0\nexport foo", kind: "alias", hasAction: true }, + ...completion.statementKeywordsWithTypes, + ], preferences: { includeCompletionsForModuleExports: true }, }); diff --git a/tests/cases/fourslash/completionsImport_ofAlias_preferShortPath.ts b/tests/cases/fourslash/completionsImport_ofAlias_preferShortPath.ts index 78ac08a1c124d..81d195d0175fd 100644 --- a/tests/cases/fourslash/completionsImport_ofAlias_preferShortPath.ts +++ b/tests/cases/fourslash/completionsImport_ofAlias_preferShortPath.ts @@ -5,6 +5,7 @@ // @moduleResolution: node // @module: commonJs +// @noLib: true // @Filename: /foo/index.ts ////export { foo } from "./lib/foo"; @@ -17,8 +18,11 @@ verify.completions({ marker: "", - includes: { name: "foo", source: "/foo/lib/foo", sourceDisplay: "./foo", text: "const foo: 0", kind: "const", hasAction: true }, - excludes: { name: "foo", source: "/foo/index" }, + exact: [ + "undefined", + { name: "foo", source: "/foo/lib/foo", sourceDisplay: "./foo", text: "const foo: 0", kind: "const", hasAction: true }, + ...completion.statementKeywordsWithTypes, + ], preferences: { includeCompletionsForModuleExports: true }, }); verify.applyCodeActionFromCompletion("", { diff --git a/tests/cases/fourslash/completionsImport_previousTokenIsSemicolon.ts b/tests/cases/fourslash/completionsImport_previousTokenIsSemicolon.ts index 06fb93283eed7..36649451530e8 100644 --- a/tests/cases/fourslash/completionsImport_previousTokenIsSemicolon.ts +++ b/tests/cases/fourslash/completionsImport_previousTokenIsSemicolon.ts @@ -7,8 +7,8 @@ ////import * as a from 'a'; /////**/ -goTo.marker(""); -verify.completionListContains({ name: "foo", source: "/a" }, "function foo(): void", "", "function", /*spanIndex*/ undefined, /*hasAction*/ true, { - includeExternalModuleExports: true, - sourceDisplay: "./a", +verify.completions({ + marker: "", + includes: { name: "foo", source: "/a", sourceDisplay: "./a", text: "function foo(): void", kind: "function", hasAction: true }, + preferences: { includeCompletionsForModuleExports: true }, }); diff --git a/tests/cases/fourslash/completionsImport_reExportDefault.ts b/tests/cases/fourslash/completionsImport_reExportDefault.ts index b5c93e9dc0a55..ae8af9c1d3581 100644 --- a/tests/cases/fourslash/completionsImport_reExportDefault.ts +++ b/tests/cases/fourslash/completionsImport_reExportDefault.ts @@ -12,10 +12,16 @@ // @Filename: /use.ts ////fo/**/ -goTo.marker(""); -verify.completionListContains({ name: "foo", source: "/a/b/impl" }, "function foo(): void", "", "function", /*spanIndex*/ undefined, /*hasAction*/ true, { - includeExternalModuleExports: true, - sourceDisplay: "./a", +verify.completions({ + marker: "", + exact: [ + ...completion.globalsVars, + "undefined", + { name: "foo", source: "/a/b/impl", sourceDisplay: "./a", text: "function foo(): void", kind: "function", hasAction: true }, + { name: "foo", source: "/a/index", sourceDisplay: "./a", text: "(alias) function foo(): void\nexport foo", kind: "alias", hasAction: true }, + ...completion.globalKeywords, + ], + preferences: { includeCompletionsForModuleExports: true }, }); verify.applyCodeActionFromCompletion("", { name: "foo", diff --git a/tests/cases/fourslash/completionsImport_reExport_wrongName.ts b/tests/cases/fourslash/completionsImport_reExport_wrongName.ts index 912f133e72ab6..31de7ef7d8de0 100644 --- a/tests/cases/fourslash/completionsImport_reExport_wrongName.ts +++ b/tests/cases/fourslash/completionsImport_reExport_wrongName.ts @@ -20,7 +20,6 @@ verify.completions({ ], preferences: { includeCompletionsForModuleExports: true }, }); - verify.applyCodeActionFromCompletion("", { name: "x", source: "/a", diff --git a/tests/cases/fourslash/completionsImport_require.ts b/tests/cases/fourslash/completionsImport_require.ts index c90eb6246e762..6002366ce02ba 100644 --- a/tests/cases/fourslash/completionsImport_require.ts +++ b/tests/cases/fourslash/completionsImport_require.ts @@ -9,12 +9,11 @@ ////import * as s from "something"; ////fo/*b*/ -goTo.marker("b"); -verify.completionListContains({ name: "foo", source: "/a" }, "const foo: 0", "", "const", /*spanIndex*/ undefined, /*hasAction*/ true, { - includeCompletionsForModuleExports: true, - sourceDisplay: "./a", +verify.completions({ + marker: "b", + includes: { name: "foo", source: "/a", sourceDisplay: "./a", text: "const foo: 0", kind: "const", hasAction: true }, + preferences: { includeCompletionsForModuleExports: true }, }); - verify.applyCodeActionFromCompletion("b", { name: "foo", source: "/a", diff --git a/tests/cases/fourslash/completionsImport_shadowedByLocal.ts b/tests/cases/fourslash/completionsImport_shadowedByLocal.ts index 7ad88ff4d2fee..afe88fa6da893 100644 --- a/tests/cases/fourslash/completionsImport_shadowedByLocal.ts +++ b/tests/cases/fourslash/completionsImport_shadowedByLocal.ts @@ -1,5 +1,7 @@ /// +// @noLib: true + // @Filename: /a.ts ////export const foo = 0; @@ -9,7 +11,6 @@ verify.completions({ marker: "", - includes: "foo", - excludes: { name: "foo", source: "/a" }, + exact: [{ name: "foo", text: "const foo: 1" }, "undefined", ...completion.statementKeywordsWithTypes], preferences: { includeCompletionsForModuleExports: true }, -}) +}); diff --git a/tests/cases/fourslash/completionsInJsxTag.ts b/tests/cases/fourslash/completionsInJsxTag.ts index 223c3875cbd43..e2921aecd154d 100644 --- a/tests/cases/fourslash/completionsInJsxTag.ts +++ b/tests/cases/fourslash/completionsInJsxTag.ts @@ -19,9 +19,4 @@ //// } ////} -goTo.marker("1"); -verify.completionListCount(1); -verify.completionListContains("foo", "(JSX attribute) foo: string", "Doc", "JSX attribute"); -goTo.marker("2"); -verify.completionListCount(1); -verify.completionListContains("foo", "(JSX attribute) foo: string", "Doc", "JSX attribute"); +verify.completions({ marker: ["1", "2"], exact: { name: "foo", text: "(JSX attribute) foo: string", documentation: "Doc", kind: "JSX attribute" } }); diff --git a/tests/cases/fourslash/completionsInterfaceElement.ts b/tests/cases/fourslash/completionsInterfaceElement.ts index cbf15581dc0a2..65b1627c8f31a 100644 --- a/tests/cases/fourslash/completionsInterfaceElement.ts +++ b/tests/cases/fourslash/completionsInterfaceElement.ts @@ -13,6 +13,4 @@ ////interface EndOfFile { f; /*e*/ -for (const marker of test.markerNames()) { - verify.completionsAt(marker, ["readonly"], { isNewIdentifierLocation: true }); -} +verify.completions({ marker: test.markers(), exact: "readonly", isNewIdentifierLocation: true }); diff --git a/tests/cases/fourslash/completionsJsPropertyAssignment.ts b/tests/cases/fourslash/completionsJsPropertyAssignment.ts index c7e8a9ad268b1..77fade15b7664 100644 --- a/tests/cases/fourslash/completionsJsPropertyAssignment.ts +++ b/tests/cases/fourslash/completionsJsPropertyAssignment.ts @@ -7,4 +7,4 @@ ////const x = { p: "x" }; ////x.p = "/**/"; -verify.completionsAt("", ["x", "y"]); +verify.completions({ marker: "", exact: ["x", "y"] }); diff --git a/tests/cases/fourslash/completionsJsdocTag.ts b/tests/cases/fourslash/completionsJsdocTag.ts index 0a8088ebfaabc..71a7a97bc6e61 100644 --- a/tests/cases/fourslash/completionsJsdocTag.ts +++ b/tests/cases/fourslash/completionsJsdocTag.ts @@ -5,5 +5,4 @@ //// * /**/ //// */ -goTo.marker(); -verify.completionListContains("@property", "@property", "", "keyword"); +verify.completions({ marker: "", includes: { name: "@property", text: "@property", kind: "keyword" } }); diff --git a/tests/cases/fourslash/completionsJsdocTypeTagCast.ts b/tests/cases/fourslash/completionsJsdocTypeTagCast.ts index 822069feb534f..5eff16bb27834 100644 --- a/tests/cases/fourslash/completionsJsdocTypeTagCast.ts +++ b/tests/cases/fourslash/completionsJsdocTypeTagCast.ts @@ -4,4 +4,4 @@ // @Filename: /a.js ////const x = /** @type {{ s: string }} */ ({ /**/ }); -verify.completionsAt("", ["s", "x"]); +verify.completions({ marker: "", exact: ["s", "x"] }); diff --git a/tests/cases/fourslash/completionsJsxAttributeInitializer.ts b/tests/cases/fourslash/completionsJsxAttributeInitializer.ts index f473d0be422b7..44d79b059a6d1 100644 --- a/tests/cases/fourslash/completionsJsxAttributeInitializer.ts +++ b/tests/cases/fourslash/completionsJsxAttributeInitializer.ts @@ -5,19 +5,14 @@ ////
; ////} -goTo.marker(); - -verify.completionListContains("x", "(parameter) x: number", "", "parameter", undefined, undefined, { - includeInsertTextCompletions: true, - insertText: "{x}", -}); - -verify.completionListContains("p", "(JSX attribute) p: number", "", "JSX attribute", undefined, undefined, { - includeInsertTextCompletions: true, - insertText: "{this.p}", -}); - -verify.completionListContains("a b", '(JSX attribute) "a b": number', "", "JSX attribute", undefined, undefined, { - includeInsertTextCompletions: true, - insertText: '{this["a b"]}', +verify.completions({ + marker: "", + includes: [ + { name: "x", text: "(parameter) x: number", kind: "parameter", insertText: "{x}" }, + { name: "p", text: "(JSX attribute) p: number", kind: "JSX attribute", insertText: "{this.p}" }, + { name: "a b", text: '(JSX attribute) "a b": number', kind: "JSX attribute", insertText: '{this["a b"]}' }, + ], + preferences: { + includeInsertTextCompletions: true, + }, }); diff --git a/tests/cases/fourslash/completionsJsxAttributeInitializer2.ts b/tests/cases/fourslash/completionsJsxAttributeInitializer2.ts index 581d0ad2b5359..e9d740b2b42a2 100644 --- a/tests/cases/fourslash/completionsJsxAttributeInitializer2.ts +++ b/tests/cases/fourslash/completionsJsxAttributeInitializer2.ts @@ -12,12 +12,11 @@ ////
////
-const [replacementSpan] = test.ranges(); -goTo.marker("0"); -verify.completionListContains("foo", "const foo: 0", undefined, "const", undefined, undefined, { - includeInsertTextCompletions: true, - insertText: "{foo}", - replacementSpan, -}); - -verify.completionsAt(["1", "2"], ["b"]); +verify.completions( + { + marker: "0", + includes: { name: "foo", text: "const foo: 0", kind: "const", insertText: "{foo}", replacementSpan: test.ranges()[0] }, + preferences: { includeInsertTextCompletions: true }, + }, + { marker: ["1", "2"], exact: "b" }, +); diff --git a/tests/cases/fourslash/completionsKeyof.ts b/tests/cases/fourslash/completionsKeyof.ts index e3beae556c556..3f743ed604da0 100644 --- a/tests/cases/fourslash/completionsKeyof.ts +++ b/tests/cases/fourslash/completionsKeyof.ts @@ -7,11 +7,7 @@ ////function g(key: T) {} ////g("/*g*/"); -goTo.marker("f"); -verify.completionListCount(1); -verify.completionListContains("a"); - -goTo.marker("g"); -verify.completionListCount(2); -verify.completionListContains("a"); -verify.completionListContains("b"); +verify.completions( + { marker: "f", exact: "a" }, + { marker: "g", exact: ["a", "b"] }, +); diff --git a/tests/cases/fourslash/completionsKeywordsExtends.ts b/tests/cases/fourslash/completionsKeywordsExtends.ts index 50c9b741cdacd..bd88311b46cc5 100644 --- a/tests/cases/fourslash/completionsKeywordsExtends.ts +++ b/tests/cases/fourslash/completionsKeywordsExtends.ts @@ -5,11 +5,7 @@ // Tests that `isCompletionListBlocker` is true *at* the class name, but false *after* it. -goTo.marker("a"); -verify.completionListIsEmpty(); - -goTo.marker("b"); -verify.completionListContains("extends"); - -goTo.marker("c"); -verify.completionListContains("extends"); +verify.completions( + { marker: "a", exact: undefined }, + { marker: ["b", "c"], includes: "extends" }, +); diff --git a/tests/cases/fourslash/completionsMethodWithThisParameter.ts b/tests/cases/fourslash/completionsMethodWithThisParameter.ts index eb7c00421ddfe..d746f3626dc08 100644 --- a/tests/cases/fourslash/completionsMethodWithThisParameter.ts +++ b/tests/cases/fourslash/completionsMethodWithThisParameter.ts @@ -14,5 +14,7 @@ ////s./*s*/; ////n./*n*/; -verify.completionsAt("s", ["value", "ms", "mo", "mt", "mp", "mps"]); -verify.completionsAt("n", ["value", "mo", "mt", "mp"]); +verify.completions( + { marker: "s", exact: ["value", "ms", "mo", "mt", "mp", "mps"] }, + { marker: "n", exact: ["value", "mo", "mt", "mp"] }, +); diff --git a/tests/cases/fourslash/completionsNamespaceMergedWithClass.ts b/tests/cases/fourslash/completionsNamespaceMergedWithClass.ts index 414a233bdb154..109b6f72b1b38 100644 --- a/tests/cases/fourslash/completionsNamespaceMergedWithClass.ts +++ b/tests/cases/fourslash/completionsNamespaceMergedWithClass.ts @@ -12,10 +12,7 @@ ////let x: D./*type*/; ////D./*value*/ -goTo.marker("type"); -verify.completionListContains("T"); -verify.not.completionListContains("m"); - -goTo.marker("value"); -verify.not.completionListContains("T"); -verify.completionListContains("m"); +verify.completions( + { marker: "type", exact: "T" }, + { marker: "value", exact: ["prototype", "m", ...completion.functionMembers] }, +); diff --git a/tests/cases/fourslash/completionsNamespaceMergedWithObject.ts b/tests/cases/fourslash/completionsNamespaceMergedWithObject.ts index cd799981ee768..f93792641df2e 100644 --- a/tests/cases/fourslash/completionsNamespaceMergedWithObject.ts +++ b/tests/cases/fourslash/completionsNamespaceMergedWithObject.ts @@ -7,10 +7,7 @@ ////let x: N./*type*/; ////N./*value*/; -goTo.marker("type"); -verify.completionListContains("T"); -verify.not.completionListContains("m"); - -goTo.marker("value"); -verify.not.completionListContains("T"); -verify.completionListContains("m"); +verify.completions( + { marker: "type", exact: "T" }, + { marker: "value", exact: "m" }, +); diff --git a/tests/cases/fourslash/completionsNewTarget.ts b/tests/cases/fourslash/completionsNewTarget.ts index 3f8a4d689cce3..5c25ecbc73929 100644 --- a/tests/cases/fourslash/completionsNewTarget.ts +++ b/tests/cases/fourslash/completionsNewTarget.ts @@ -6,5 +6,4 @@ //// } ////} -goTo.marker(""); -verify.completionListContains("target"); \ No newline at end of file +verify.completions({ marker: "", exact: "target" }); diff --git a/tests/cases/fourslash/completionsOptionalKindModifier.ts b/tests/cases/fourslash/completionsOptionalKindModifier.ts index 39ace2342d3d0..1592fb5d10bde 100644 --- a/tests/cases/fourslash/completionsOptionalKindModifier.ts +++ b/tests/cases/fourslash/completionsOptionalKindModifier.ts @@ -5,6 +5,10 @@ ////x./*a*/; ////} -goTo.marker("a"); -verify.completionListContains("a", /* text */ undefined, /* documentation */ undefined, { kindModifiers: "optional" }); -verify.completionListContains("method", /* text */ undefined, /* documentation */ undefined, { kindModifiers: "optional" }); +verify.completions({ + marker: "a", + exact: [ + { name: "a", kindModifiers: "optional" }, + { name: "method", kindModifiers: "optional" }, + ], +}); diff --git a/tests/cases/fourslash/completionsOptionalMethod.ts b/tests/cases/fourslash/completionsOptionalMethod.ts index 72399f177f28f..4c70e31606299 100644 --- a/tests/cases/fourslash/completionsOptionalMethod.ts +++ b/tests/cases/fourslash/completionsOptionalMethod.ts @@ -5,4 +5,4 @@ ////declare const x: { m?(): void }; ////x./**/ -verify.completionsAt("", ["m"]); +verify.completions({ marker: "", exact: "m" }); diff --git a/tests/cases/fourslash/completionsPathsJsonModule.ts b/tests/cases/fourslash/completionsPathsJsonModule.ts index 6d1a621d69a65..fb3370c69c930 100644 --- a/tests/cases/fourslash/completionsPathsJsonModule.ts +++ b/tests/cases/fourslash/completionsPathsJsonModule.ts @@ -9,4 +9,4 @@ // @Filename: /project/index.ts ////import { } from "/**/"; -verify.completionsAt("", ["test.json"], { isNewIdentifierLocation: true }); \ No newline at end of file +verify.completions({ marker: "", exact: "test.json", isNewIdentifierLocation: true }); diff --git a/tests/cases/fourslash/completionsPathsJsonModuleWithAmd.ts b/tests/cases/fourslash/completionsPathsJsonModuleWithAmd.ts index 8a2388655af74..27676d1fdc963 100644 --- a/tests/cases/fourslash/completionsPathsJsonModuleWithAmd.ts +++ b/tests/cases/fourslash/completionsPathsJsonModuleWithAmd.ts @@ -9,4 +9,4 @@ // @Filename: /project/index.ts ////import { } from ".//**/"; -verify.completionsAt("", [], { isNewIdentifierLocation: true }); \ No newline at end of file +verify.completions({ marker: "", exact: [], isNewIdentifierLocation: true }); \ No newline at end of file diff --git a/tests/cases/fourslash/completionsPathsJsonModuleWithoutResolveJsonModule.ts b/tests/cases/fourslash/completionsPathsJsonModuleWithoutResolveJsonModule.ts index 432fc6e858b6a..95a4468324700 100644 --- a/tests/cases/fourslash/completionsPathsJsonModuleWithoutResolveJsonModule.ts +++ b/tests/cases/fourslash/completionsPathsJsonModuleWithoutResolveJsonModule.ts @@ -8,4 +8,4 @@ // @Filename: /project/index.ts ////import { } from ".//**/"; -verify.completionsAt("", [], { isNewIdentifierLocation: true }); +verify.completions({ marker: "", exact: [], isNewIdentifierLocation: true }); diff --git a/tests/cases/fourslash/completionsPathsRelativeJsonModule.ts b/tests/cases/fourslash/completionsPathsRelativeJsonModule.ts index 93a6ac6e4e239..a0c9f92e545cb 100644 --- a/tests/cases/fourslash/completionsPathsRelativeJsonModule.ts +++ b/tests/cases/fourslash/completionsPathsRelativeJsonModule.ts @@ -9,4 +9,4 @@ // @Filename: /project/index.ts ////import { } from ".//**/"; -verify.completionsAt("", ["test.json"], { isNewIdentifierLocation: true }); \ No newline at end of file +verify.completions({ marker: "", exact: "test.json", isNewIdentifierLocation: true }); diff --git a/tests/cases/fourslash/completionsPaths_pathMapping.ts b/tests/cases/fourslash/completionsPaths_pathMapping.ts index c6c879dc97e6c..9bff5424e5d7a 100644 --- a/tests/cases/fourslash/completionsPaths_pathMapping.ts +++ b/tests/cases/fourslash/completionsPaths_pathMapping.ts @@ -21,5 +21,7 @@ ////} const [r0, r1] = test.ranges(); -verify.completionsAt("0", ["a", "b", "dir"], { isNewIdentifierLocation: true }); -verify.completionsAt("1", ["x"], { isNewIdentifierLocation: true }); +verify.completions( + { marker: "0", exact: ["a", "b", "dir"], isNewIdentifierLocation: true }, + { marker: "1", exact: "x", isNewIdentifierLocation: true }, +); diff --git a/tests/cases/fourslash/completionsPaths_pathMapping_parentDirectory.ts b/tests/cases/fourslash/completionsPaths_pathMapping_parentDirectory.ts index 71d0705231820..f870af306567c 100644 --- a/tests/cases/fourslash/completionsPaths_pathMapping_parentDirectory.ts +++ b/tests/cases/fourslash/completionsPaths_pathMapping_parentDirectory.ts @@ -16,4 +16,4 @@ //// } ////} -verify.completionsAt("", ["x"], { isNewIdentifierLocation: true }); +verify.completions({ marker: "", exact: ["x"], isNewIdentifierLocation: true }); diff --git a/tests/cases/fourslash/completionsPaths_pathMapping_relativePath.ts b/tests/cases/fourslash/completionsPaths_pathMapping_relativePath.ts index a9af29cd6e731..a86e5bcb0d329 100644 --- a/tests/cases/fourslash/completionsPaths_pathMapping_relativePath.ts +++ b/tests/cases/fourslash/completionsPaths_pathMapping_relativePath.ts @@ -19,4 +19,4 @@ //// } ////} -verify.completionsAt("", ["a", "b"], { isNewIdentifierLocation: true }); +verify.completions({ marker: "", exact: ["a", "b"], isNewIdentifierLocation: true }); diff --git a/tests/cases/fourslash/completionsPaths_pathMapping_topLevel.ts b/tests/cases/fourslash/completionsPaths_pathMapping_topLevel.ts index 449ff3f65bde7..9b9c67abbfc08 100644 --- a/tests/cases/fourslash/completionsPaths_pathMapping_topLevel.ts +++ b/tests/cases/fourslash/completionsPaths_pathMapping_topLevel.ts @@ -13,4 +13,4 @@ //// } ////} -verify.completionsAt("", ["src", "foo/"], { isNewIdentifierLocation: true }); +verify.completions({ marker: "", exact: ["src", "foo/"], isNewIdentifierLocation: true }); diff --git a/tests/cases/fourslash/completionsRecommended_contextualTypes.ts b/tests/cases/fourslash/completionsRecommended_contextualTypes.ts index fb88434f98a5f..8d35ba131468c 100644 --- a/tests/cases/fourslash/completionsRecommended_contextualTypes.ts +++ b/tests/cases/fourslash/completionsRecommended_contextualTypes.ts @@ -20,16 +20,24 @@ recommended("arg0"); recommended("arg1", { enumName: "F" }); -recommended("prop"); +recommended("prop", { isNewIdentifierLocation: false }); recommended("tag"); -recommended("jsx"); -recommended("jsx2", { insertText: "{E}" }); +recommended("jsx", { isNewIdentifierLocation: false }); +recommended("jsx2", { isNewIdentifierLocation: false, insertText: "{E}" }); -function recommended(markerName: string, { insertText, enumName = "E" }: { insertText?: string, enumName?: string } = {}) { - goTo.marker(markerName); - verify.completionListContains(enumName, `enum ${enumName}`, "", "enum", undefined, undefined , { - isRecommended: true, - includeInsertTextCompletions: true, - insertText, +function recommended(marker: string, { insertText, isNewIdentifierLocation = true, enumName = "E" }: { insertText?: string, isNewIdentifierLocation?: boolean, enumName?: string } = {}) { + verify.completions({ + marker, + includes: { + name: enumName, + text: `enum ${enumName}`, + kind: "enum", + isRecommended: true, + insertText, + }, + isNewIdentifierLocation, + preferences: { + includeInsertTextCompletions: true, + }, }); } diff --git a/tests/cases/fourslash/completionsRecommended_equals.ts b/tests/cases/fourslash/completionsRecommended_equals.ts index 37e4c9313597d..356a9410ba28e 100644 --- a/tests/cases/fourslash/completionsRecommended_equals.ts +++ b/tests/cases/fourslash/completionsRecommended_equals.ts @@ -5,6 +5,7 @@ ////e === /*a*/; ////e === E/*b*/ -goTo.eachMarker(["a", "b"], () => { - verify.completionListContains("Enu", "enum Enu", "", "enum", undefined, undefined, { isRecommended: true }); +verify.completions({ + marker: ["a", "b"], + includes: { name: "Enu", text: "enum Enu", kind: "enum", isRecommended: true }, }); diff --git a/tests/cases/fourslash/completionsRecommended_import.ts b/tests/cases/fourslash/completionsRecommended_import.ts index 158221f03a8c8..4f58827f74260 100644 --- a/tests/cases/fourslash/completionsRecommended_import.ts +++ b/tests/cases/fourslash/completionsRecommended_import.ts @@ -18,21 +18,27 @@ ////alpha.f(new al/*c0*/); ////alpha.f(new /*c1*/); -goTo.eachMarker(["b0", "b1"], (_, idx) => { - verify.completionListContains( - { name: "Cls", source: "/a" }, - idx === 0 ? "constructor Cls(): Cls" : "class Cls", - "", - "class", - undefined, - /*hasAction*/ true, { - includeExternalModuleExports: true, - isRecommended: true, - sourceDisplay: "./a", - }); +const preferences: FourSlashInterface.UserPreferences = { includeCompletionsForModuleExports: true }; +const classEntry = (isConstructor: boolean): FourSlashInterface.ExpectedCompletionEntry => ({ + name: "Cls", + source: "/a", + sourceDisplay: "./a", + kind: "class", + text: isConstructor ? "constructor Cls(): Cls" : "class Cls", + hasAction: true, + isRecommended: true, }); - -goTo.eachMarker(["c0", "c1"], (_, idx) => { - verify.completionListContains("alpha", "import alpha", "", "alias", undefined, undefined, { isRecommended: true }) -}); - +verify.completions( + { marker: "b0", includes: classEntry(true), preferences }, + { marker: "b1", includes: classEntry(false), preferences }, + { + marker: ["c0", "c1"], + includes: { + name: "alpha", + text: "import alpha", + kind: "alias", + isRecommended: true, + }, + preferences, + }, +); diff --git a/tests/cases/fourslash/completionsRecommended_local.ts b/tests/cases/fourslash/completionsRecommended_local.ts index ca098bae44270..76690b7dbbdba 100644 --- a/tests/cases/fourslash/completionsRecommended_local.ts +++ b/tests/cases/fourslash/completionsRecommended_local.ts @@ -15,23 +15,28 @@ ////enu = E/*let0*/; ////enu = E/*let1*/; -goTo.eachMarker(["e0", "e1", "let0", "let1"], () => { - verify.completionListContains("Enu", "enum Enu", "", "enum", undefined, undefined, { isRecommended: true }); +const cls = (ctr: boolean): FourSlashInterface.ExpectedCompletionEntry => ({ + name: "Cls", + text: ctr ? "constructor Cls(): Cls" : "class Cls", + kind: "class", + isRecommended: true, }); -goTo.eachMarker(["c0", "c1"], (_, idx) => { - verify.completionListContains( - "Cls", - idx === 0 ? "constructor Cls(): Cls" : "class Cls", - "", - "class", - undefined, - undefined, { - isRecommended: true, - }); +// Not recommended, because it's an abstract class +const abs = (ctr: boolean): FourSlashInterface.ExpectedCompletionEntry => ({ + name: "Abs", + text: ctr ? "constructor Abs(): Abs" : "class Abs", + kind: "class", }); -goTo.eachMarker(["a0", "a1"], (_, idx) => { - // Not recommended, because it's an abstract class - verify.completionListContains("Abs", idx == 0 ? "constructor Abs(): Abs" : "class Abs", "", "class"); -}); +verify.completions( + { + marker: ["e0", "e1", "let0", "let1"], + includes: { name: "Enu", text: "enum Enu", kind: "enum", isRecommended: true }, + isNewIdentifierLocation: true, + }, + { marker: "c0", includes: cls(true) }, + { marker: "c1", includes: cls(false) }, + { marker: "a0", includes: abs(true) }, + { marker: "a1", includes: abs(false) }, +); diff --git a/tests/cases/fourslash/completionsRecommended_namespace.ts b/tests/cases/fourslash/completionsRecommended_namespace.ts index d3fe9c2a54b2e..9cf98f43b59b6 100644 --- a/tests/cases/fourslash/completionsRecommended_namespace.ts +++ b/tests/cases/fourslash/completionsRecommended_namespace.ts @@ -22,18 +22,12 @@ ////alpha.f(new a/*c0*/); ////alpha.f(new /*c1*/); -goTo.eachMarker(["a0", "a1"], () => { - verify.completionListContains("Name", "namespace Name", "", "module", undefined, undefined, { isRecommended: true }); -}); - -goTo.eachMarker(["b0", "b1"], () => { - verify.completionListContains({ name: "Name", source: "/a" }, "namespace Name", "", "module", undefined, /*hasAction*/ true, { - includeExternalModuleExports: true, - isRecommended: true, - sourceDisplay: "./a", - }); -}); - -goTo.eachMarker(["c0", "c1"], () => { - verify.completionListContains("alpha", "import alpha", "", "alias", undefined, undefined, { isRecommended: true }); -}); +verify.completions( + { marker: ["a0", "a1"], includes: { name: "Name", text: "namespace Name", kind: "module", isRecommended: true } }, + { + marker: ["b0", "b1"], + includes: { name: "Name", source: "/a", sourceDisplay: "./a", text: "namespace Name", kind: "module", hasAction: true, isRecommended: true, }, + preferences: { includeCompletionsForModuleExports: true }, + }, + { marker: ["c0", "c1"], includes: { name: "alpha", text: "import alpha", kind: "alias", isRecommended: true } }, +); diff --git a/tests/cases/fourslash/completionsRecommended_nonAccessibleSymbol.ts b/tests/cases/fourslash/completionsRecommended_nonAccessibleSymbol.ts index 0f27e824d2bd6..13afccb6c0925 100644 --- a/tests/cases/fourslash/completionsRecommended_nonAccessibleSymbol.ts +++ b/tests/cases/fourslash/completionsRecommended_nonAccessibleSymbol.ts @@ -6,5 +6,4 @@ ////} ////f()(new /**/); -goTo.marker(""); -verify.not.completionListContains("C"); // Not accessible +verify.completions({ marker: "", excludes: "C" }); diff --git a/tests/cases/fourslash/completionsRecommended_switch.ts b/tests/cases/fourslash/completionsRecommended_switch.ts index a8941ac53eae5..d5773c092c202 100644 --- a/tests/cases/fourslash/completionsRecommended_switch.ts +++ b/tests/cases/fourslash/completionsRecommended_switch.ts @@ -7,6 +7,7 @@ //// case /*1*/: ////} -goTo.eachMarker((_, idx) => { - verify.completionListContains("Enu", "enum Enu", "", "enum", undefined, undefined, { isRecommended: true }); +verify.completions({ + marker: test.markers(), + includes: { name: "Enu", text: "enum Enu", kind: "enum", isRecommended: true }, }); diff --git a/tests/cases/fourslash/completionsStringLiteral_fromTypeConstraint.ts b/tests/cases/fourslash/completionsStringLiteral_fromTypeConstraint.ts index cb3f1a31fe2fd..e29b2b7268f37 100644 --- a/tests/cases/fourslash/completionsStringLiteral_fromTypeConstraint.ts +++ b/tests/cases/fourslash/completionsStringLiteral_fromTypeConstraint.ts @@ -3,4 +3,4 @@ ////interface Foo { foo: string; bar: string; } ////type T = Pick; -verify.completionsAt("", ["foo", "bar"]); +verify.completions({ marker: "", exact: ["foo", "bar"] }); diff --git a/tests/cases/fourslash/completionsSymbolMembers.ts b/tests/cases/fourslash/completionsSymbolMembers.ts index 269443e23dd84..39b8c5c499ac9 100644 --- a/tests/cases/fourslash/completionsSymbolMembers.ts +++ b/tests/cases/fourslash/completionsSymbolMembers.ts @@ -11,5 +11,15 @@ ////declare const j: J; ////j[|./*j*/|]; -verify.completionsAt("i", [{ name: "s", insertText: "[s]", replacementSpan: test.ranges()[0] }], { includeInsertTextCompletions: true }); -verify.completionsAt("j", [{ name: "N", insertText: "[N]", replacementSpan: test.ranges()[1] }], { includeInsertTextCompletions: true }) +verify.completions( + { + marker: "i", + exact: { name: "s", insertText: "[s]", replacementSpan: test.ranges()[0] }, + preferences: { includeInsertTextCompletions: true }, + }, + { + marker: "j", + exact: { name: "N", insertText: "[N]", replacementSpan: test.ranges()[1] }, + preferences: { includeInsertTextCompletions: true }, + } +); diff --git a/tests/cases/fourslash/completionsUnion.ts b/tests/cases/fourslash/completionsUnion.ts index d9d1d3c792f18..6bc6bd1a86031 100644 --- a/tests/cases/fourslash/completionsUnion.ts +++ b/tests/cases/fourslash/completionsUnion.ts @@ -7,4 +7,4 @@ // We specifically filter out any array-like types. // Private members will be excluded by `createUnionOrIntersectionProperty`. -verify.completionsAt("", ["x"]); +verify.completions({ marker: "", exact: "x" }); diff --git a/tests/cases/fourslash/constEnumQuickInfoAndCompletionList.ts b/tests/cases/fourslash/constEnumQuickInfoAndCompletionList.ts index 8d312aa37ab62..03dd93ce38db5 100644 --- a/tests/cases/fourslash/constEnumQuickInfoAndCompletionList.ts +++ b/tests/cases/fourslash/constEnumQuickInfoAndCompletionList.ts @@ -7,8 +7,6 @@ ////} /////*2*/e.a; -verify.quickInfoAt("1", "const enum e"); - -goTo.marker('2'); -verify.completionListContains("e", "const enum e"); -verify.quickInfoIs("const enum e"); \ No newline at end of file +const text = "const enum e"; +verify.completions({ marker: "2", includes: { name: "e", text } }); +verify.quickInfos({ 1: text, 2: text }); diff --git a/tests/cases/fourslash/constQuickInfoAndCompletionList.ts b/tests/cases/fourslash/constQuickInfoAndCompletionList.ts index 80b7ac5950737..290552d40bff3 100644 --- a/tests/cases/fourslash/constQuickInfoAndCompletionList.ts +++ b/tests/cases/fourslash/constQuickInfoAndCompletionList.ts @@ -9,27 +9,22 @@ //// var z = /*6*/a; //// /*7*/ ////} -verify.quickInfoAt("1", "const a: 10"); -goTo.marker('2'); -verify.completionListContains("a", "const a: 10"); -verify.quickInfoIs("const a: 10"); +const a = "const a: 10"; +const b = "const b: 20"; +const completeA: FourSlashInterface.ExpectedCompletionEntry = { name: "a", text: a }; +const completeB: FourSlashInterface.ExpectedCompletionEntry = { name: "b", text: b }; +verify.completions( + { marker: "2", includes: completeA, excludes: "b", isNewIdentifierLocation: true }, + { marker: "3", includes: completeA, excludes: "b" }, + { marker: ["5", "6"], includes: [completeA, completeB], isNewIdentifierLocation: true }, + { marker: "7", includes: [completeA, completeB] }, +); -goTo.marker('3'); -verify.completionListContains("a", "const a: 10"); - -verify.quickInfoAt("4", "const b: 20"); - -goTo.marker('5'); -verify.completionListContains("a", "const a: 10"); -verify.completionListContains("b", "const b: 20"); -verify.quickInfoIs("const b: 20"); - -goTo.marker('6'); -verify.completionListContains("a", "const a: 10"); -verify.completionListContains("b", "const b: 20"); -verify.quickInfoIs("const a: 10"); - -goTo.marker('7'); -verify.completionListContains("a", "const a: 10"); -verify.completionListContains("b", "const b: 20"); +verify.quickInfos({ + 1: a, + 2: a, + 4: b, + 5: b, + 6: a, +}); diff --git a/tests/cases/fourslash/doubleUnderscoreCompletions.ts b/tests/cases/fourslash/doubleUnderscoreCompletions.ts index df36a9adc4802..007842edc1bc0 100644 --- a/tests/cases/fourslash/doubleUnderscoreCompletions.ts +++ b/tests/cases/fourslash/doubleUnderscoreCompletions.ts @@ -8,5 +8,11 @@ //// var instance = new MyObject(); //// instance./*1*/ -goTo.marker("1"); -verify.completionListContains("__property", "(property) MyObject.__property: number"); +verify.completions({ + marker: "1", + exact: [ + { name: "__property", text: "(property) MyObject.__property: number" }, + "MyObject", + "instance", + ], +}); diff --git a/tests/cases/fourslash/exportDefaultClass.ts b/tests/cases/fourslash/exportDefaultClass.ts index 04ab351ab3609..da22984757a88 100644 --- a/tests/cases/fourslash/exportDefaultClass.ts +++ b/tests/cases/fourslash/exportDefaultClass.ts @@ -5,8 +5,4 @@ ////} //// /*2*/ -goTo.marker('1'); -verify.completionListContains("C", "class C", /*documentation*/ undefined, "class"); - -goTo.marker('2'); -verify.completionListContains("C", "class C", /*documentation*/ undefined, "class"); \ No newline at end of file +verify.completions({ marker: test.markers(), includes: { name: "C", text: "class C", kind: "class" } }); diff --git a/tests/cases/fourslash/exportDefaultFunction.ts b/tests/cases/fourslash/exportDefaultFunction.ts index 42ddced6994c0..3b7882e025de8 100644 --- a/tests/cases/fourslash/exportDefaultFunction.ts +++ b/tests/cases/fourslash/exportDefaultFunction.ts @@ -5,8 +5,7 @@ ////} //// /*2*/ -goTo.marker('1'); -verify.completionListContains("func", "function func(): void", /*documentation*/ undefined, "function"); - -goTo.marker('2'); -verify.completionListContains("func", "function func(): void", /*documentation*/ undefined, "function"); +verify.completions({ + marker: test.markers(), + includes: { name: "func", text: "function func(): void", kind: "function" }, +}); diff --git a/tests/cases/fourslash/exportEqualCallableInterface.ts b/tests/cases/fourslash/exportEqualCallableInterface.ts index 795df0c8695f8..2b65ca69c6fc7 100644 --- a/tests/cases/fourslash/exportEqualCallableInterface.ts +++ b/tests/cases/fourslash/exportEqualCallableInterface.ts @@ -13,7 +13,7 @@ ////var t2: test; ////t2./**/ -goTo.marker(); -verify.completionListContains('apply'); -verify.completionListContains('arguments'); -verify.completionListContains('foo'); +verify.completions({ + marker: "", + exact: ["foo", ...completion.functionMembersWithPrototype], +}); diff --git a/tests/cases/fourslash/exportEqualTypes.ts b/tests/cases/fourslash/exportEqualTypes.ts index cb1e2ec90a12e..6cb7eb9f9ae05 100644 --- a/tests/cases/fourslash/exportEqualTypes.ts +++ b/tests/cases/fourslash/exportEqualTypes.ts @@ -19,6 +19,5 @@ verify.quickInfos({ 2: "var r1: Date", 3: "var r2: string" }); -goTo.marker('4'); -verify.completionListContains('foo'); +verify.completions({ marker: "4", exact: ["foo", ...completion.functionMembersWithPrototype] }); verify.noErrors(); diff --git a/tests/cases/fourslash/extendArrayInterface.ts b/tests/cases/fourslash/extendArrayInterface.ts index d2322b37df05f..09add80a685de 100644 --- a/tests/cases/fourslash/extendArrayInterface.ts +++ b/tests/cases/fourslash/extendArrayInterface.ts @@ -7,8 +7,7 @@ //// -goTo.marker("1"); -verify.completionListContains("concat"); +verify.completions({ marker: "1", includes: "concat" }); // foo doesn't exist, so both references should be in error verify.errorExistsBetweenMarkers("2", "3"); diff --git a/tests/cases/fourslash/externalModuleIntellisense.ts b/tests/cases/fourslash/externalModuleIntellisense.ts index 8577e0686bf01..5083833803792 100644 --- a/tests/cases/fourslash/externalModuleIntellisense.ts +++ b/tests/cases/fourslash/externalModuleIntellisense.ts @@ -21,6 +21,4 @@ goTo.marker('1'); verify.numberOfErrorsInCurrentFile(0); goTo.eof(); edit.insert("x."); -verify.completionListContains('enable'); -verify.completionListContains('post'); -verify.completionListCount(2); +verify.completions({ exact: ["enable", "post"] }); diff --git a/tests/cases/fourslash/externalModuleRefernceResolutionOrderInImportDeclaration.ts b/tests/cases/fourslash/externalModuleRefernceResolutionOrderInImportDeclaration.ts index a1d503a657ad7..79b1ce4f2e612 100644 --- a/tests/cases/fourslash/externalModuleRefernceResolutionOrderInImportDeclaration.ts +++ b/tests/cases/fourslash/externalModuleRefernceResolutionOrderInImportDeclaration.ts @@ -16,5 +16,4 @@ goTo.marker('1'); edit.insert("file1."); -verify.completionListContains("bar"); -verify.not.completionListContains("foo"); \ No newline at end of file +verify.completions({ includes: "bar", excludes: "foo" }); diff --git a/tests/cases/fourslash/externalModuleWithExportAssignment.ts b/tests/cases/fourslash/externalModuleWithExportAssignment.ts index 02f53b661d595..7131042427b08 100644 --- a/tests/cases/fourslash/externalModuleWithExportAssignment.ts +++ b/tests/cases/fourslash/externalModuleWithExportAssignment.ts @@ -48,10 +48,14 @@ verify.quickInfoAt("2", [ goTo.marker('3'); verify.quickInfoIs("(property) test1: a1.connectModule\n(res: any, req: any, next: any) => void", undefined); -verify.completionListContains("test1", "(property) test1: a1.connectModule\n(res: any, req: any, next: any) => void", undefined); -verify.completionListContains("test2", "(method) test2(): a1.connectModule", undefined); -verify.not.completionListContains("connectModule"); -verify.not.completionListContains("connectExport"); +verify.completions({ + marker: ["3", "9"], + exact: [ + { name: "test1", text: "(property) test1: a1.connectModule\n(res: any, req: any, next: any) => void" }, + { name: "test2", text: "(method) test2(): a1.connectModule" }, + ...completion.functionMembersWithPrototype, + ], +}); verify.signatureHelp( { marker: "4", text: "test1(res: any, req: any, next: any): void" }, @@ -66,10 +70,6 @@ verify.quickInfoAt("8", "var r2: a1.connectExport", undefined); goTo.marker('9'); verify.quickInfoIs("(property) test1: a1.connectModule\n(res: any, req: any, next: any) => void", undefined); -verify.completionListContains("test1", "(property) test1: a1.connectModule\n(res: any, req: any, next: any) => void", undefined); -verify.completionListContains("test2", "(method) test2(): a1.connectModule", undefined); -verify.not.completionListContains("connectModule"); -verify.not.completionListContains("connectExport"); verify.signatureHelp( { marker: "10", text: "test1(res: any, req: any, next: any): void" }, @@ -82,9 +82,10 @@ verify.signatureHelp({ marker: "13", text: "a1(): a1.connectExport" }); verify.quickInfoAt("14", "var r4: a1.connectExport", undefined); -goTo.marker('15'); -verify.not.completionListContains("test1", "(property) test1: a1.connectModule", undefined); -verify.not.completionListContains("test2", "(method) test2(): a1.connectModule", undefined); -verify.completionListContains("connectModule", "interface a1.connectModule", undefined); -verify.completionListContains("connectExport", "interface a1.connectExport", undefined); - +verify.completions({ + marker: "15", + exact: [ + { name: "connectModule", text: "interface a1.connectModule" }, + { name: "connectExport", text: "interface a1.connectExport" }, + ], +}); diff --git a/tests/cases/fourslash/forwardReference.ts b/tests/cases/fourslash/forwardReference.ts index 355eda9113c08..ad300bc673421 100644 --- a/tests/cases/fourslash/forwardReference.ts +++ b/tests/cases/fourslash/forwardReference.ts @@ -8,5 +8,4 @@ //// public n: number; ////} -goTo.marker(); -verify.completionListContains('n'); +verify.completions({ marker: "", exact: "n" }); diff --git a/tests/cases/fourslash/fourslash.ts b/tests/cases/fourslash/fourslash.ts index 57b5af7e1b617..dd6d5fce27393 100644 --- a/tests/cases/fourslash/fourslash.ts +++ b/tests/cases/fourslash/fourslash.ts @@ -146,27 +146,6 @@ declare namespace FourSlashInterface { allowedClassElementKeywords: string[]; allowedConstructorParameterKeywords: string[]; constructor(negative?: boolean); - completionListCount(expectedCount: number): void; - completionListContains( - entryId: string | { name: string, source?: string }, - text?: string, - documentation?: string, - kind?: string | { kind?: string, kindModifiers?: string }, - spanIndex?: number, - hasAction?: boolean, - options?: UserPreferences & { - triggerCharacter?: string, - sourceDisplay?: string, - isRecommended?: true, - insertText?: string, - replacementSpan?: Range, - }, - ): void; - completionListItemsCountIsGreaterThan(count: number): void; - completionListIsEmpty(): void; - completionListContainsClassElementKeywords(): void; - completionListContainsConstructorParameterKeywords(): void; - completionListAllowsNewIdentifier(): void; errorExistsBetweenMarkers(startMarker: string, endMarker: string): void; errorExistsAfterMarker(markerName?: string): void; errorExistsBeforeMarker(markerName?: string): void; @@ -201,16 +180,7 @@ declare namespace FourSlashInterface { class verify extends verifyNegatable { assertHasRanges(ranges: Range[]): void; caretAtMarker(markerName?: string): void; - completions(...options: { - readonly marker?: ArrayOrSingle, - readonly isNewIdentifierLocation?: boolean; - readonly exact?: ArrayOrSingle; - readonly includes?: ArrayOrSingle; - readonly excludes?: ArrayOrSingle; - readonly preferences?: UserPreferences; - readonly triggerCharacter?: string; - }[]): void; - completionsAt(markerName: ArrayOrSingle, completions: ReadonlyArray, options?: CompletionsAtOptions): void; + completions(...options: CompletionsOptions[]): void; applyCodeActionFromCompletion(markerName: string, options: { name: string, source?: string, @@ -299,7 +269,6 @@ declare namespace FourSlashInterface { rangesAreDocumentHighlights(ranges?: Range[], options?: VerifyDocumentHighlightsOptions): void; rangesWithSameTextAreDocumentHighlights(): void; documentHighlightsOf(startRange: Range, ranges: Range[], options?: VerifyDocumentHighlightsOptions): void; - completionEntryDetailIs(entryName: string, text: string, documentation?: string, kind?: string, tags?: JSDocTagInfo[]): void; /** * This method *requires* a contiguous, complete, and ordered stream of classifications for a file. */ @@ -536,25 +505,33 @@ declare namespace FourSlashInterface { readonly importModuleSpecifierPreference?: "relative" | "non-relative"; readonly importModuleSpecifierEnding?: "minimal" | "index" | "js"; } - interface CompletionsAtOptions extends UserPreferences { - triggerCharacter?: string; - isNewIdentifierLocation?: boolean; - } - type ExpectedCompletionEntry = string | { - readonly name: string, - readonly source?: string, - readonly insertText?: string, - readonly replacementSpan?: Range, - readonly hasAction?: boolean, - readonly isRecommended?: boolean, - readonly kind?: string, + interface CompletionsOptions { + readonly marker?: ArrayOrSingle, + readonly isNewIdentifierLocation?: boolean; + readonly isGlobalCompletion?: boolean; + readonly exact?: ArrayOrSingle; + readonly includes?: ArrayOrSingle; + readonly excludes?: ArrayOrSingle; + readonly preferences?: UserPreferences; + readonly triggerCharacter?: string; + } + type ExpectedCompletionEntry = string | ExpectedCompletionEntryObject; + interface ExpectedCompletionEntryObject { + readonly name: string; + readonly source?: string; + readonly insertText?: string; + readonly replacementSpan?: Range; + readonly hasAction?: boolean; + readonly isRecommended?: boolean; + readonly kind?: string; + readonly kindModifiers?: string; // details - readonly text?: string, - readonly documentation?: string, + readonly text?: string; + readonly documentation?: string; readonly tags?: ReadonlyArray; - readonly sourceDisplay?: string, - }; + readonly sourceDisplay?: string; + } interface VerifySignatureHelpOptions { marker?: ArrayOrSingle; @@ -666,3 +643,24 @@ declare var debug: FourSlashInterface.debug; declare var format: FourSlashInterface.format; declare var cancellation: FourSlashInterface.cancellation; declare var classification: typeof FourSlashInterface.classification; +declare namespace completion { + export const globals: ReadonlyArray; + export const globalKeywords: ReadonlyArray; + export const insideMethodKeywords: ReadonlyArray; + export const globalKeywordsPlusUndefined: ReadonlyArray; + export const globalsVars: ReadonlyArray; + export function globalsInsideFunction(plus: ReadonlyArray): ReadonlyArray; + export function globalsPlus(plus: ReadonlyArray): ReadonlyArray; + export const keywordsWithUndefined: ReadonlyArray; + export const keywords: ReadonlyArray; + export const typeKeywords: ReadonlyArray; + export const globalTypes: ReadonlyArray; + export function globalTypesPlus(plus: ReadonlyArray): ReadonlyArray; + export const classElementKeywords: ReadonlyArray; + export const constructorParameterKeywords: ReadonlyArray; + export const functionMembers: ReadonlyArray; + export const stringMembers: ReadonlyArray; + export const functionMembersWithPrototype: ReadonlyArray; + export const statementKeywordsWithTypes: ReadonlyArray; + export const statementKeywords: ReadonlyArray; +} diff --git a/tests/cases/fourslash/functionProperty.ts b/tests/cases/fourslash/functionProperty.ts index 9ba3bce35435b..07d617b8acc39 100644 --- a/tests/cases/fourslash/functionProperty.ts +++ b/tests/cases/fourslash/functionProperty.ts @@ -23,17 +23,15 @@ verify.signatureHelp({ marker: ["signatureA", "signatureB", "signatureC"], text: "x(a: number): void" }); -goTo.marker('completionA'); -verify.completionListContains("x", "(method) x(a: number): void"); - -goTo.marker('completionB'); -verify.completionListContains("x", "(property) x: (a: number) => void"); - -goTo.marker('completionC'); -verify.completionListContains("x", "(property) x: (a: number) => void"); +const method = "(method) x(a: number): void"; +const property = "(property) x: (a: number) => void"; +verify.completions( + { marker: "completionA", exact: { name: "x", text: method } }, + { marker: ["completionB", "completionC"], exact: { name: "x", text: property } }, +); verify.quickInfos({ - quickInfoA: "(method) x(a: number): void", - quickInfoB: "(property) x: (a: number) => void", - quickInfoC: "(property) x: (a: number) => void" + quickInfoA: method, + quickInfoB: property, + quickInfoC: property, }); diff --git a/tests/cases/fourslash/functionTypes.ts b/tests/cases/fourslash/functionTypes.ts index 5ef931a602d7e..205861e43b55c 100644 --- a/tests/cases/fourslash/functionTypes.ts +++ b/tests/cases/fourslash/functionTypes.ts @@ -21,10 +21,7 @@ ////l./*7*/prototype = Object.prototype; verify.noErrors(); -verify.completionsAt('1', ["apply", "call", "bind", "toString", "prototype", "length", "arguments", "caller" ]); -verify.completionsAt('2', ["apply", "call", "bind", "toString", "prototype", "length", "arguments", "caller" ]); -verify.completionsAt('3', ["apply", "call", "bind", "toString", "prototype", "length", "arguments", "caller" ]); -verify.completionsAt('4', ["apply", "call", "bind", "toString", "prototype", "length", "arguments", "caller" ]); -verify.completionsAt('5', ["apply", "call", "bind", "toString", "prototype", "length", "arguments", "caller" ]); -verify.completionsAt('6', ["apply", "call", "bind", "toString", "prototype", "length", "arguments", "caller" ]); -verify.completionsAt('7', ["prototype", "apply", "call", "bind", "toString", "length", "arguments", "caller" ]); +verify.completions( + { marker: ["1", "2", "3", "4", "5", "6"], exact: completion.functionMembersWithPrototype }, + { marker: "7", exact: ["prototype", ...completion.functionMembers] }, +); diff --git a/tests/cases/fourslash/genericCloduleCompletionList.ts b/tests/cases/fourslash/genericCloduleCompletionList.ts index 3ca9546eece07..6b184e5079c3f 100644 --- a/tests/cases/fourslash/genericCloduleCompletionList.ts +++ b/tests/cases/fourslash/genericCloduleCompletionList.ts @@ -6,6 +6,4 @@ ////var d: D; ////d./**/ -goTo.marker(); -verify.completionListContains('x'); -verify.not.completionListContains('f'); +verify.completions({ marker: "", exact: "x" }); diff --git a/tests/cases/fourslash/genericTypeAliasIntersectionCompletions.ts b/tests/cases/fourslash/genericTypeAliasIntersectionCompletions.ts index 0b2646291dadc..b16e0eba5bba1 100644 --- a/tests/cases/fourslash/genericTypeAliasIntersectionCompletions.ts +++ b/tests/cases/fourslash/genericTypeAliasIntersectionCompletions.ts @@ -28,6 +28,4 @@ //// var obj = new (merge(LeftSideNode, RightSideNode))(); //// obj./**/ -goTo.marker(); -verify.completionListContains("left"); -verify.completionListContains("right"); +verify.completions({ marker: "", exact: ["right", "left", "value", "constructor"] }); diff --git a/tests/cases/fourslash/genericTypeWithMultipleBases1.ts b/tests/cases/fourslash/genericTypeWithMultipleBases1.ts index 867cea490effe..32263a73fa43c 100644 --- a/tests/cases/fourslash/genericTypeWithMultipleBases1.ts +++ b/tests/cases/fourslash/genericTypeWithMultipleBases1.ts @@ -12,7 +12,11 @@ ////var x: iScope; ////x./**/ -goTo.marker(); -verify.completionListContains('watch', '(property) iBaseScope.watch: () => void'); -verify.completionListContains('moveUp', '(property) iMover.moveUp: () => void'); -verify.completionListContains('family', '(property) iScope.family: number'); \ No newline at end of file +verify.completions({ + marker: "", + exact: [ + { name: "family", text: "(property) iScope.family: number" }, + { name: "watch", text: "(property) iBaseScope.watch: () => void" }, + { name: "moveUp", text: "(property) iMover.moveUp: () => void" }, + ], +}); diff --git a/tests/cases/fourslash/genericTypeWithMultipleBases1MultiFile.ts b/tests/cases/fourslash/genericTypeWithMultipleBases1MultiFile.ts index 6c15a5a5c0120..e089824f53cad 100644 --- a/tests/cases/fourslash/genericTypeWithMultipleBases1MultiFile.ts +++ b/tests/cases/fourslash/genericTypeWithMultipleBases1MultiFile.ts @@ -17,7 +17,11 @@ // @Filename: genericTypeWithMultipleBases_4.ts ////x./**/ -goTo.marker(); -verify.completionListContains('watch', '(property) iBaseScope.watch: () => void'); -verify.completionListContains('moveUp', '(property) iMover.moveUp: () => void'); -verify.completionListContains('family', '(property) iScope.family: number'); +verify.completions({ + marker: "", + includes: [ + { name: "watch", text: "(property) iBaseScope.watch: () => void" }, + { name: "moveUp", text: "(property) iMover.moveUp: () => void" }, + { name: "family", text: "(property) iScope.family: number" }, + ], +}); diff --git a/tests/cases/fourslash/getCompletionEntryDetails.ts b/tests/cases/fourslash/getCompletionEntryDetails.ts index 1ed680b667800..436c0d195bcf6 100644 --- a/tests/cases/fourslash/getCompletionEntryDetails.ts +++ b/tests/cases/fourslash/getCompletionEntryDetails.ts @@ -7,24 +7,23 @@ ////var bbb: string; /////*1*/ +const check = () => verify.completions({ + includes: [ + { name: "aaa", text: "var aaa: number" }, + { name: "bbb", text: "var bbb: string" }, + { name: "ccc", text: "var ccc: number" }, + { name: "ddd", text: "var ddd: string" }, + ], +}); + goTo.marker("1"); -verify.completionListContains("aaa"); -verify.completionListContains("bbb"); -verify.completionListContains("ccc"); -verify.completionListContains("ddd"); // Checking for completion details before edit should work -verify.completionEntryDetailIs("aaa", "var aaa: number"); -verify.completionEntryDetailIs("ccc", "var ccc: number"); +check(); // Make an edit edit.insert("a"); edit.backspace(); // Checking for completion details after edit should work too -verify.completionEntryDetailIs("bbb", "var bbb: string"); -verify.completionEntryDetailIs("ddd", "var ddd: string"); - -// Checking for completion details again before edit should work -verify.completionEntryDetailIs("aaa", "var aaa: number"); -verify.completionEntryDetailIs("ccc", "var ccc: number"); +check(); diff --git a/tests/cases/fourslash/getCompletionEntryDetails2.ts b/tests/cases/fourslash/getCompletionEntryDetails2.ts index 3e7e77b588c8d..ecb5e43918a2d 100644 --- a/tests/cases/fourslash/getCompletionEntryDetails2.ts +++ b/tests/cases/fourslash/getCompletionEntryDetails2.ts @@ -7,12 +7,16 @@ ////} ////Foo./**/ -goTo.marker(""); -verify.completionListContains("x"); +const exact: ReadonlyArray = [ + "prototype", + { name: "x", text: "var Foo.x: number" }, + ...completion.functionMembers, +]; +verify.completions({ marker: "", exact }); // Make an edit edit.insert("a"); edit.backspace(); // Checking for completion details after edit should work too -verify.completionEntryDetailIs("x", "var Foo.x: number"); +verify.completions({ exact }); diff --git a/tests/cases/fourslash/getJavaScriptCompletions1.ts b/tests/cases/fourslash/getJavaScriptCompletions1.ts index 6d8f36aac1b51..fd677b12354c7 100644 --- a/tests/cases/fourslash/getJavaScriptCompletions1.ts +++ b/tests/cases/fourslash/getJavaScriptCompletions1.ts @@ -6,5 +6,4 @@ ////var v; ////v./**/ -goTo.marker(); -verify.completionListContains("toExponential", /*displayText:*/ undefined, /*documentation*/ undefined, "method"); +verify.completions({ marker: "", includes: { name: "toExponential", kind: "method" } }); diff --git a/tests/cases/fourslash/getJavaScriptCompletions10.ts b/tests/cases/fourslash/getJavaScriptCompletions10.ts index 5fbd91e89881a..0eaccdb26b9e6 100644 --- a/tests/cases/fourslash/getJavaScriptCompletions10.ts +++ b/tests/cases/fourslash/getJavaScriptCompletions10.ts @@ -7,5 +7,4 @@ //// */ ////function f() { this./**/ } -goTo.marker(); -verify.completionListContains("toExponential", /*displayText:*/ undefined, /*documentation*/ undefined, "method"); \ No newline at end of file +verify.completions({ marker: "", includes: { name: "toExponential", kind: "method" } }); diff --git a/tests/cases/fourslash/getJavaScriptCompletions11.ts b/tests/cases/fourslash/getJavaScriptCompletions11.ts index f12f53fa960fe..9b15b09a2775e 100644 --- a/tests/cases/fourslash/getJavaScriptCompletions11.ts +++ b/tests/cases/fourslash/getJavaScriptCompletions11.ts @@ -6,6 +6,10 @@ ////var v; ////v./**/ -goTo.marker(); -verify.completionListContains("toExponential", /*displayText:*/ undefined, /*documentation*/ undefined, "method"); -verify.completionListContains("charCodeAt", /*displayText:*/ undefined, /*documentation*/ undefined, "method"); \ No newline at end of file +verify.completions({ + marker: "", + includes: [ + { name: "toExponential", kind: "method" }, + { name: "charCodeAt", kind: "method" }, + ], +}); diff --git a/tests/cases/fourslash/getJavaScriptCompletions14.ts b/tests/cases/fourslash/getJavaScriptCompletions14.ts index 52a23065a5e2e..d89d77ba0d4da 100644 --- a/tests/cases/fourslash/getJavaScriptCompletions14.ts +++ b/tests/cases/fourslash/getJavaScriptCompletions14.ts @@ -9,5 +9,4 @@ ////var x = 1; ////x./*1*/ -goTo.marker("1"); -verify.completionListContains("toExponential", /*displayText:*/ undefined, /*documentation*/ undefined, "method"); +verify.completions({ marker: "1", includes: { name: "toExponential", kind: "method" } }); diff --git a/tests/cases/fourslash/getJavaScriptCompletions15.ts b/tests/cases/fourslash/getJavaScriptCompletions15.ts index 2903cb6fa7ccb..e46b0780d429e 100644 --- a/tests/cases/fourslash/getJavaScriptCompletions15.ts +++ b/tests/cases/fourslash/getJavaScriptCompletions15.ts @@ -19,11 +19,9 @@ //// v.x./*3*/; //// v.x.V./*4*/; -goTo.marker("1"); -verify.completionListContains("toExponential"); -goTo.marker("2"); -verify.completionListContains("toLowerCase"); -goTo.marker("3"); -verify.completionListContains("V"); -goTo.marker("4"); -verify.completionListContains("toLowerCase"); +verify.completions( + { marker: "1", includes: "toExponential" }, + { marker: "2", includes: "toLowerCase" }, + { marker: "3", exact: ["V", "ref1", "ref2", "require", "v", "x"] }, + { marker: "4", includes: "toLowerCase" }, +); diff --git a/tests/cases/fourslash/getJavaScriptCompletions16.ts b/tests/cases/fourslash/getJavaScriptCompletions16.ts index 86adead3e1a0c..8f698004eb400 100644 --- a/tests/cases/fourslash/getJavaScriptCompletions16.ts +++ b/tests/cases/fourslash/getJavaScriptCompletions16.ts @@ -24,7 +24,7 @@ goTo.marker('body'); edit.insert('.'); -verify.completionListContains('toFixed', undefined, undefined, 'method'); +verify.completions({ includes: { name: "toFixed", kind: "method" } }); edit.backspace(); verify.signatureHelp({ @@ -35,4 +35,4 @@ verify.signatureHelp({ goTo.marker('method'); edit.insert('.'); -verify.completionListContains('toFixed', undefined, undefined, 'method'); +verify.completions({ includes: { name: "toFixed", kind: "method" } }); diff --git a/tests/cases/fourslash/getJavaScriptCompletions18.ts b/tests/cases/fourslash/getJavaScriptCompletions18.ts index a30d4943f4f08..bad58889efb8d 100644 --- a/tests/cases/fourslash/getJavaScriptCompletions18.ts +++ b/tests/cases/fourslash/getJavaScriptCompletions18.ts @@ -13,9 +13,8 @@ goTo.marker('a'); edit.insert('.'); -verify.completionListContains('toFixed', undefined, undefined, 'method'); - +verify.completions({ includes: { name: "toFixed", kind: "method" } }); goTo.marker('b'); edit.insert('.'); -verify.completionListContains('substr', undefined, undefined, 'method'); +verify.completions({ includes: { name: "substr", kind: "method" } }); diff --git a/tests/cases/fourslash/getJavaScriptCompletions19.ts b/tests/cases/fourslash/getJavaScriptCompletions19.ts index 5a361930e86b2..0c90a32a32288 100644 --- a/tests/cases/fourslash/getJavaScriptCompletions19.ts +++ b/tests/cases/fourslash/getJavaScriptCompletions19.ts @@ -18,8 +18,8 @@ goTo.marker('str'); edit.insert('.'); -verify.completionListContains('substr', undefined, undefined, 'method'); +verify.completions({ includes: { name: "substr", kind: "method" } }); goTo.marker('num'); edit.insert('.'); -verify.completionListContains('toFixed', undefined, undefined, 'method'); +verify.completions({ includes: { name: "toFixed", kind: "method" } }); diff --git a/tests/cases/fourslash/getJavaScriptCompletions2.ts b/tests/cases/fourslash/getJavaScriptCompletions2.ts index b5aab81b434e2..4425e4a76e844 100644 --- a/tests/cases/fourslash/getJavaScriptCompletions2.ts +++ b/tests/cases/fourslash/getJavaScriptCompletions2.ts @@ -6,5 +6,4 @@ ////var v; ////v./**/ -goTo.marker(); -verify.completionListContains("valueOf", /*displayText:*/ undefined, /*documentation*/ undefined, "method"); +verify.completions({ marker: "", includes: { name: "valueOf", kind: "method" } }); diff --git a/tests/cases/fourslash/getJavaScriptCompletions20.ts b/tests/cases/fourslash/getJavaScriptCompletions20.ts index ec2bcef161b09..cbe74a4b392d5 100644 --- a/tests/cases/fourslash/getJavaScriptCompletions20.ts +++ b/tests/cases/fourslash/getJavaScriptCompletions20.ts @@ -12,10 +12,12 @@ //// this.name = name; //// this.age = age; //// } -//// -//// +//// +//// //// Person.getName = 10; //// Person.getNa/**/ = 10; -goTo.marker(); -verify.completionListContains('getName'); +verify.completions({ + marker: "", + exact: ["getName", "getNa", ...completion.functionMembersWithPrototype, "Person", "name", "age"], +}); diff --git a/tests/cases/fourslash/getJavaScriptCompletions3.ts b/tests/cases/fourslash/getJavaScriptCompletions3.ts index 13a6f1673e6b3..da2a05c0cfb40 100644 --- a/tests/cases/fourslash/getJavaScriptCompletions3.ts +++ b/tests/cases/fourslash/getJavaScriptCompletions3.ts @@ -6,5 +6,4 @@ ////var v; ////v./**/ -goTo.marker(); -verify.completionListContains("concat", /*displayText:*/ undefined, /*documentation*/ undefined, "method"); \ No newline at end of file +verify.completions({ marker: "", includes: { name: "concat", kind: "method" } }); \ No newline at end of file diff --git a/tests/cases/fourslash/getJavaScriptCompletions4.ts b/tests/cases/fourslash/getJavaScriptCompletions4.ts index 3719b8e1258cb..841c60d91b4a3 100644 --- a/tests/cases/fourslash/getJavaScriptCompletions4.ts +++ b/tests/cases/fourslash/getJavaScriptCompletions4.ts @@ -6,5 +6,4 @@ ////function foo(a,b) { } ////foo(1,2)./**/ -goTo.marker(); -verify.completionListContains("toExponential", /*displayText:*/ undefined, /*documentation*/ undefined, "method"); \ No newline at end of file +verify.completions({ marker: "", includes: { name: "toExponential", kind: "method" } }); diff --git a/tests/cases/fourslash/getJavaScriptCompletions5.ts b/tests/cases/fourslash/getJavaScriptCompletions5.ts index 348feef94c329..85808d466264b 100644 --- a/tests/cases/fourslash/getJavaScriptCompletions5.ts +++ b/tests/cases/fourslash/getJavaScriptCompletions5.ts @@ -7,9 +7,7 @@ //// * @param {T} a //// * @return {T} */ //// function foo(a) { } -//// let x = /*1*/foo; +//// let x = foo; //// foo(1)./**/ -goTo.marker('1'); -goTo.marker(); -verify.completionListContains("toExponential", /*displayText:*/ undefined, /*documentation*/ undefined, "method"); +verify.completions({ marker: "", includes: { name: "toExponential", kind: "method" } }); diff --git a/tests/cases/fourslash/getJavaScriptCompletions8.ts b/tests/cases/fourslash/getJavaScriptCompletions8.ts index 418aae676bee5..6ac9387b10c52 100644 --- a/tests/cases/fourslash/getJavaScriptCompletions8.ts +++ b/tests/cases/fourslash/getJavaScriptCompletions8.ts @@ -8,5 +8,4 @@ ////var v; ////v()./**/ -goTo.marker(); -verify.completionListContains("toExponential", /*displayText:*/ undefined, /*documentation*/ undefined, "method"); \ No newline at end of file +verify.completions({ marker: "", includes: { name: "toExponential", kind: "method" } }); diff --git a/tests/cases/fourslash/getJavaScriptCompletions9.ts b/tests/cases/fourslash/getJavaScriptCompletions9.ts index 1619a2ca9fc49..de9a9c068dbb1 100644 --- a/tests/cases/fourslash/getJavaScriptCompletions9.ts +++ b/tests/cases/fourslash/getJavaScriptCompletions9.ts @@ -8,5 +8,4 @@ ////var v; ////new v()./**/ -goTo.marker(); -verify.completionListContains("toExponential", /*displayText:*/ undefined, /*documentation*/ undefined, "method"); \ No newline at end of file +verify.completions({ marker: "", includes: { name: "toExponential", kind: "method" } }); diff --git a/tests/cases/fourslash/getJavaScriptGlobalCompletions1.ts b/tests/cases/fourslash/getJavaScriptGlobalCompletions1.ts index 240df24bf5233..478d472217e12 100644 --- a/tests/cases/fourslash/getJavaScriptGlobalCompletions1.ts +++ b/tests/cases/fourslash/getJavaScriptGlobalCompletions1.ts @@ -9,7 +9,7 @@ //// } //// return 5; //// } -//// +//// //// hello/**/ -verify.completionListContains('helloWorld'); +verify.completions({ includes: "helloWorld" }); diff --git a/tests/cases/fourslash/getJavaScriptQuickInfo8.ts b/tests/cases/fourslash/getJavaScriptQuickInfo8.ts index 958dec3765d1d..9b0478698962f 100644 --- a/tests/cases/fourslash/getJavaScriptQuickInfo8.ts +++ b/tests/cases/fourslash/getJavaScriptQuickInfo8.ts @@ -21,9 +21,9 @@ goTo.marker('1'); edit.insert('.'); -verify.completionListContains('toFixed', undefined, undefined, 'method'); +verify.completions({ includes: { name: "toFixed", kind: "method" } }); edit.backspace(); goTo.marker('2'); edit.insert('.'); -verify.completionListContains('substr', undefined, undefined, 'method'); +verify.completions({ includes: { name: "substr", kind: "method" } }); diff --git a/tests/cases/fourslash/globalCompletionListInsideObjectLiterals.ts b/tests/cases/fourslash/globalCompletionListInsideObjectLiterals.ts index 33f8534344e84..e41ec0a99f44d 100644 --- a/tests/cases/fourslash/globalCompletionListInsideObjectLiterals.ts +++ b/tests/cases/fourslash/globalCompletionListInsideObjectLiterals.ts @@ -23,27 +23,12 @@ //// }; ////} -function VerifyGlobalCompletionList() { - verify.completionListItemsCountIsGreaterThan(10); -} - -// Completion on '{' location. -goTo.marker("1"); -VerifyGlobalCompletionList(); - -// Literal member completion after member name with empty member expression and missing colon. -goTo.marker("2"); -VerifyGlobalCompletionList(); - -goTo.marker("3"); -VerifyGlobalCompletionList(); - -goTo.marker("4"); -verify.completionListIsEmpty(); - -// Literal member completion after member name with empty member expression. -goTo.marker("5"); -VerifyGlobalCompletionList(); - -goTo.marker("6"); -VerifyGlobalCompletionList(); \ No newline at end of file +// 1: Completion on '{' location. +// 2: Literal member completion after member name with empty member expression and missing colon. +// 5, 6: Literal member completion after member name with empty member expression. +const exact = ["p1", "p2", "p3", "p4", ...completion.globalsPlus(["ObjectLiterals"])]; +verify.completions( + { marker: ["1"], exact, isNewIdentifierLocation: true }, + { marker: ["2", "3", "5", "6"], exact }, + { marker: "4", exact: undefined }, +); diff --git a/tests/cases/fourslash/identifierErrorRecovery.ts b/tests/cases/fourslash/identifierErrorRecovery.ts index cb266584b0462..91210b9e08942 100644 --- a/tests/cases/fourslash/identifierErrorRecovery.ts +++ b/tests/cases/fourslash/identifierErrorRecovery.ts @@ -10,5 +10,4 @@ verify.errorExistsBetweenMarkers("1", "2"); verify.errorExistsBetweenMarkers("3", "4"); verify.numberOfErrorsInCurrentFile(3); goTo.eof(); -verify.completionListContains("foo"); -verify.completionListContains("bar"); +verify.completions({ includes: ["foo", "bar"] }); diff --git a/tests/cases/fourslash/importJsNodeModule1.ts b/tests/cases/fourslash/importJsNodeModule1.ts index 2c4b6352cb02f..e5177d19a88f8 100644 --- a/tests/cases/fourslash/importJsNodeModule1.ts +++ b/tests/cases/fourslash/importJsNodeModule1.ts @@ -11,8 +11,6 @@ goTo.file('consumer.js'); goTo.marker(); edit.insert('.'); -verify.completionListContains("n", /*displayText:*/ undefined, /*documentation*/ undefined, "property"); -verify.completionListContains("s", /*displayText:*/ undefined, /*documentation*/ undefined, "property"); -verify.completionListContains("b", /*displayText:*/ undefined, /*documentation*/ undefined, "property"); +verify.completions({ includes: ["n", "s", "b"].map(name => ({ name, kind: "property" })) }); edit.insert('n.'); -verify.completionListContains("toFixed", /*displayText:*/ undefined, /*documentation*/ undefined, "method"); +verify.completions({ includes: { name: "toFixed", kind: "method" } }); diff --git a/tests/cases/fourslash/importJsNodeModule2.ts b/tests/cases/fourslash/importJsNodeModule2.ts index c8b7c479ddf8c..34ed62814addf 100644 --- a/tests/cases/fourslash/importJsNodeModule2.ts +++ b/tests/cases/fourslash/importJsNodeModule2.ts @@ -16,8 +16,11 @@ goTo.file('consumer.js'); goTo.marker(); edit.insert('.'); -verify.completionListContains("n", /*displayText:*/ undefined, /*documentation*/ undefined, "property"); -verify.completionListContains("s", /*displayText:*/ undefined, /*documentation*/ undefined, "property"); -verify.completionListContains("b", /*displayText:*/ undefined, /*documentation*/ undefined, "property"); +verify.completions({ + exact: [ + ...["n", "s", "b"].map(name => ({ name, kind: "property" })), + ...["x", "require"].map(name => ({ name, kind: "warning" })), + ], +}); edit.insert('n.'); -verify.completionListContains("toFixed", /*displayText:*/ undefined, /*documentation*/ undefined, "method"); +verify.completions({ includes: { name: "toFixed", kind: "method" } }); diff --git a/tests/cases/fourslash/importJsNodeModule3.ts b/tests/cases/fourslash/importJsNodeModule3.ts index 46ff4d009bebf..761a2ef3e452d 100644 --- a/tests/cases/fourslash/importJsNodeModule3.ts +++ b/tests/cases/fourslash/importJsNodeModule3.ts @@ -24,15 +24,13 @@ goTo.file('consumer.js'); goTo.marker(); edit.insert('.'); -verify.completionListContains("n", /*displayText:*/ undefined, /*documentation*/ undefined, "property"); -verify.completionListContains("s", /*displayText:*/ undefined, /*documentation*/ undefined, "property"); -verify.completionListContains("b", /*displayText:*/ undefined, /*documentation*/ undefined, "property"); +verify.completions({ includes: ["n", "s", "b"].map(name => ({ name, kind: "property" })) });; edit.insert('n.'); -verify.completionListContains("toFixed", /*displayText:*/ undefined, /*documentation*/ undefined, "method"); +verify.completions({ includes: { name: "toFixed", kind: "method" } }); edit.backspace(4); edit.insert('y.'); -verify.completionListContains("toUpperCase", /*displayText:*/ undefined, /*documentation*/ undefined, "method"); +verify.completions({ includes: { name: "toUpperCase", kind: "method" } }); edit.backspace(2); edit.insert('z('); verify.signatureHelp({ diff --git a/tests/cases/fourslash/importJsNodeModule4.ts b/tests/cases/fourslash/importJsNodeModule4.ts index 917bea35842d6..08e9b9369852d 100644 --- a/tests/cases/fourslash/importJsNodeModule4.ts +++ b/tests/cases/fourslash/importJsNodeModule4.ts @@ -12,8 +12,6 @@ goTo.file('consumer.js'); goTo.marker(); edit.insert('.'); -verify.completionListContains("n", /*displayText:*/ undefined, /*documentation*/ undefined, "property"); -verify.completionListContains("s", /*displayText:*/ undefined, /*documentation*/ undefined, "property"); -verify.completionListContains("b", /*displayText:*/ undefined, /*documentation*/ undefined, "property"); +verify.completions({ includes: ["n", "s", "b"].map(name => ({ name, kind: "property" })) });; edit.insert('n.'); -verify.completionListContains("toFixed", /*displayText:*/ undefined, /*documentation*/ undefined, "method"); +verify.completions({ includes: { name: "toFixed", kind: "method" } }); diff --git a/tests/cases/fourslash/importTypeMemberCompletions.ts b/tests/cases/fourslash/importTypeMemberCompletions.ts index b2bbc0e81b189..d91f2d271c298 100644 --- a/tests/cases/fourslash/importTypeMemberCompletions.ts +++ b/tests/cases/fourslash/importTypeMemberCompletions.ts @@ -40,12 +40,14 @@ // @Filename: /usage9.ts ////type H = typeof import("./equals")./*9*/ -verify.completionsAt("1", ["Foo"]); -verify.completionsAt("2", ["Bar"]); -verify.completionsAt("3", ["Baz", "a"]); -verify.completionsAt("4", ["Foo"]); -verify.completionsAt("5", ["Bar"]); -verify.completionsAt("6", ["Baz", "Bat"]); -verify.completionsAt("7", ["a"]); -verify.completionsAt("8", ["Bat"]); -verify.completionsAt("9", ["prototype", "bar"]); +verify.completions( + { marker: "1", exact: "Foo" }, + { marker: "2", exact: "Bar" }, + { marker: "3", exact: ["Baz", "a"] }, + { marker: "4", exact: "Foo" }, + { marker: "5", exact: "Bar" }, + { marker: "6", exact: ["Baz", "Bat"] }, + { marker: "7", exact: "a" }, + { marker: "8", exact: "Bat" }, + { marker: "9", exact: ["prototype", "bar"] }, +); diff --git a/tests/cases/fourslash/indirectClassInstantiation.ts b/tests/cases/fourslash/indirectClassInstantiation.ts index 819db3373082f..198515dd806d7 100644 --- a/tests/cases/fourslash/indirectClassInstantiation.ts +++ b/tests/cases/fourslash/indirectClassInstantiation.ts @@ -14,7 +14,7 @@ //// inst2.blah/*b*/; goTo.marker('a'); -verify.completionListContains('property'); +verify.completions({ exact: ["property", "TestObj", "constructor", "instance", "class2", "prototype", "blah", "inst2"] }); edit.backspace(); goTo.marker('b'); diff --git a/tests/cases/fourslash/javaScriptClass4.ts b/tests/cases/fourslash/javaScriptClass4.ts index 1148d5f320eb2..eae26f500cd1b 100644 --- a/tests/cases/fourslash/javaScriptClass4.ts +++ b/tests/cases/fourslash/javaScriptClass4.ts @@ -18,5 +18,4 @@ goTo.marker(); edit.insert('.baz.'); -verify.completionListContains("substr", /*displayText*/ undefined, /*documentation*/ undefined, "method"); - +verify.completions({ includes: { name: "substr", kind: "method" } }); diff --git a/tests/cases/fourslash/javaScriptModules13.ts b/tests/cases/fourslash/javaScriptModules13.ts index 5e3eead3b6cf6..3f462f343eecb 100644 --- a/tests/cases/fourslash/javaScriptModules13.ts +++ b/tests/cases/fourslash/javaScriptModules13.ts @@ -19,10 +19,9 @@ goTo.file('consumer.js'); goTo.marker(); -verify.completionListContains('y'); -verify.not.completionListContains('invisible'); +verify.completions({ marker: "", includes: "y", excludes: "invisible" }); edit.insert('x.'); -verify.completionListContains('a', undefined, undefined, 'property'); +verify.completions({ includes: { name: "a", kind: "property" } }); edit.insert('a.'); -verify.completionListContains('toFixed', undefined, undefined, 'method'); +verify.completions({ includes: { name: "toFixed", kind: "method" } }); diff --git a/tests/cases/fourslash/javaScriptModules14.ts b/tests/cases/fourslash/javaScriptModules14.ts index 9039292d511cb..1b564c096367c 100644 --- a/tests/cases/fourslash/javaScriptModules14.ts +++ b/tests/cases/fourslash/javaScriptModules14.ts @@ -21,8 +21,4 @@ //// var x = require('myMod'); //// /**/; -goTo.file('consumer.js'); -goTo.marker(); - -verify.completionListContains('y'); -verify.not.completionListContains('invisible'); +verify.completions({ marker: "", includes: "y", excludes: "invisible" }); diff --git a/tests/cases/fourslash/javaScriptModules15.ts b/tests/cases/fourslash/javaScriptModules15.ts index 0636f0360af0f..7a000c53a2c24 100644 --- a/tests/cases/fourslash/javaScriptModules15.ts +++ b/tests/cases/fourslash/javaScriptModules15.ts @@ -20,8 +20,6 @@ goTo.file('consumer.js'); goTo.marker(); edit.insert('.'); -verify.completionListContains("n", /*displayText:*/ undefined, /*documentation*/ undefined, "property"); -verify.completionListContains("s", /*displayText:*/ undefined, /*documentation*/ undefined, "property"); -verify.completionListContains("b", /*displayText:*/ undefined, /*documentation*/ undefined, "property"); +verify.completions({ includes: ["s", "b", "n"].map(name => ({ name, kind: "property" })) }); edit.insert('n.'); -verify.completionListContains("toFixed", /*displayText:*/ undefined, /*documentation*/ undefined, "method"); +verify.completions({ includes: { name: "toFixed", kind: "method" } }); diff --git a/tests/cases/fourslash/javaScriptModules16.ts b/tests/cases/fourslash/javaScriptModules16.ts index 09a777f7d2ccb..715e5d84da450 100644 --- a/tests/cases/fourslash/javaScriptModules16.ts +++ b/tests/cases/fourslash/javaScriptModules16.ts @@ -15,8 +15,11 @@ goTo.file('consumer.js'); goTo.marker(); edit.insert('.'); -verify.completionListContains("n", /*displayText:*/ undefined, /*documentation*/ undefined, "property"); -verify.completionListContains("s", /*displayText:*/ undefined, /*documentation*/ undefined, "property"); -verify.completionListContains("b", /*displayText:*/ undefined, /*documentation*/ undefined, "property"); +verify.completions({ + exact: [ + ...["n", "s", "b"].map(name => ({ name, kind: "property" })), + ...["x", "require"].map(name => ({ name, kind: "warning" })), + ], +}); edit.insert('n.'); -verify.completionListContains("toFixed", /*displayText:*/ undefined, /*documentation*/ undefined, "method"); +verify.completions({ includes: { name: "toFixed", kind: "method" } }); diff --git a/tests/cases/fourslash/javaScriptModules17.ts b/tests/cases/fourslash/javaScriptModules17.ts index 83ae882f32360..02cddc4006f8c 100644 --- a/tests/cases/fourslash/javaScriptModules17.ts +++ b/tests/cases/fourslash/javaScriptModules17.ts @@ -11,8 +11,6 @@ goTo.file('consumer.js'); goTo.marker(); edit.insert('.'); -verify.completionListContains("n", /*displayText:*/ undefined, /*documentation*/ undefined, "property"); -verify.completionListContains("s", /*displayText:*/ undefined, /*documentation*/ undefined, "property"); -verify.completionListContains("b", /*displayText:*/ undefined, /*documentation*/ undefined, "property"); +verify.completions({ includes: ["n", "s", "b"].map(name => ({ name, kind: "property" })) }); edit.insert('n.'); -verify.completionListContains("toFixed", /*displayText:*/ undefined, /*documentation*/ undefined, "method"); +verify.completions({ includes: { name: "toFixed", kind: "method" } }); diff --git a/tests/cases/fourslash/javaScriptModules18.ts b/tests/cases/fourslash/javaScriptModules18.ts index 77a751f2a9bb4..fa7e348912942 100644 --- a/tests/cases/fourslash/javaScriptModules18.ts +++ b/tests/cases/fourslash/javaScriptModules18.ts @@ -9,6 +9,4 @@ // @Filename: other.js //// /**/; -goTo.file('other.js'); - -verify.not.completionListContains('x'); +verify.completions({ marker: "", excludes: "x" }); diff --git a/tests/cases/fourslash/javaScriptModules19.ts b/tests/cases/fourslash/javaScriptModules19.ts index 56ee5a2a2e581..37304c4593a18 100644 --- a/tests/cases/fourslash/javaScriptModules19.ts +++ b/tests/cases/fourslash/javaScriptModules19.ts @@ -17,10 +17,9 @@ goTo.file('consumer.js'); goTo.marker(); -verify.completionListContains('y'); -verify.not.completionListContains('invisible'); +verify.completions({ marker: "", includes: "y", excludes: "invisible" }); edit.insert('x.'); -verify.completionListContains('a', undefined, undefined, 'property'); +verify.completions({ includes: { name: "a", kind: "property" } }); edit.insert('a.'); -verify.completionListContains('toFixed', undefined, undefined, 'method'); +verify.completions({ includes: { name: "toFixed", kind: "method" } }); diff --git a/tests/cases/fourslash/javaScriptModulesWithBackticks.ts b/tests/cases/fourslash/javaScriptModulesWithBackticks.ts index b2ce64d36479e..aef3a0a7e845f 100644 --- a/tests/cases/fourslash/javaScriptModulesWithBackticks.ts +++ b/tests/cases/fourslash/javaScriptModulesWithBackticks.ts @@ -8,5 +8,4 @@ //// var a = require(`./a`); //// a./**/; -goTo.marker(); -verify.completionListContains("x"); +verify.completions({ marker: "", includes: "x" }); diff --git a/tests/cases/fourslash/javaScriptPrototype1.ts b/tests/cases/fourslash/javaScriptPrototype1.ts index 7eae28f9e983c..e586b124e44f9 100644 --- a/tests/cases/fourslash/javaScriptPrototype1.ts +++ b/tests/cases/fourslash/javaScriptPrototype1.ts @@ -8,7 +8,7 @@ //// } //// myCtor.prototype.foo = function() { return 32 }; //// myCtor.prototype.bar = function() { return '' }; -//// +//// //// var m = new myCtor(10); //// m/*1*/ //// var a = m.foo; @@ -22,25 +22,22 @@ // Members of the class instance goTo.marker('1'); edit.insert('.'); -verify.completionListContains('foo', undefined, undefined, 'method'); -verify.completionListContains('bar', undefined, undefined, 'method'); +verify.completions({ includes: ["foo", "bar"].map(name => ({ name, kind: "method" })) }); edit.backspace(); // Members of a class method (1) goTo.marker('2'); edit.insert('.'); -verify.completionListContains('length', undefined, undefined, 'property'); +verify.completions({ includes: { name: "length", kind: "property" } }); edit.backspace(); // Members of the invocation of a class method (1) goTo.marker('3'); edit.insert('.'); -verify.completionListContains('toFixed', undefined, undefined, 'method'); -verify.not.completionListContains('substr', undefined, undefined, 'method'); +verify.completions({ includes: "toFixed", excludes: "substr" }); edit.backspace(); // Members of the invocation of a class method (2) goTo.marker('4'); edit.insert('.'); -verify.completionListContains('substr', undefined, undefined, 'method'); -verify.not.completionListContains('toFixed', undefined, undefined, 'method'); +verify.completions({ includes: "substr", excludes: "toFixed" }); diff --git a/tests/cases/fourslash/javaScriptPrototype3.ts b/tests/cases/fourslash/javaScriptPrototype3.ts index 4a92f4226b99c..627f5c399778d 100644 --- a/tests/cases/fourslash/javaScriptPrototype3.ts +++ b/tests/cases/fourslash/javaScriptPrototype3.ts @@ -2,19 +2,26 @@ // Inside an inferred method body, the type of 'this' is the class type +// @noLib: true // @allowNonTsExtensions: true // @Filename: myMod.js //// function myCtor(x) { //// this.qua = 10; //// } -//// myCtor.prototype.foo = function() { return this/**/; }; +//// myCtor.prototype.foo = function() { return this./**/; }; //// myCtor.prototype.bar = function() { return '' }; -//// +//// goTo.marker(); edit.insert('.'); // Check members of the function -verify.completionListContains('foo', undefined, undefined, 'method'); -verify.completionListContains('bar', undefined, undefined, 'method'); -verify.completionListContains('qua', undefined, undefined, 'property'); +verify.completions({ + marker: "", + exact: [ + { name: "qua", kind: "property" }, + { name: "foo", kind: "method" }, + { name: "bar", kind: "method" }, + ...["myCtor", "x", "prototype"].map(name => ({ name, kind: "warning" })), + ], +}); diff --git a/tests/cases/fourslash/javaScriptPrototype4.ts b/tests/cases/fourslash/javaScriptPrototype4.ts index 81cb5fe378424..98deee4f22ac1 100644 --- a/tests/cases/fourslash/javaScriptPrototype4.ts +++ b/tests/cases/fourslash/javaScriptPrototype4.ts @@ -9,13 +9,11 @@ //// } //// myCtor.prototype.foo = function() { return 32 }; //// myCtor.prototype.bar = function() { return '' }; -//// +//// //// myCtor/*1*/ goTo.marker('1'); edit.insert('.'); // Check members of the function -verify.completionListContains('foo', undefined, undefined, 'warning'); -verify.completionListContains('bar', undefined, undefined, 'warning'); -verify.completionListContains('qua', undefined, undefined, 'warning'); +verify.completions({ includes: ["foo", "bar", "qua"].map(name => ({ name, kind: "warning" })) }); diff --git a/tests/cases/fourslash/javaScriptPrototype5.ts b/tests/cases/fourslash/javaScriptPrototype5.ts index a0125e4751213..2473f658f5a0a 100644 --- a/tests/cases/fourslash/javaScriptPrototype5.ts +++ b/tests/cases/fourslash/javaScriptPrototype5.ts @@ -15,5 +15,4 @@ goTo.marker(); edit.insert('.'); // Check members of the function -verify.completionListContains('foo', undefined, undefined, 'property'); -verify.completionListContains('bar', undefined, undefined, 'property'); +verify.completions({ includes: ["foo", "bar"].map(name => ({ name, kind: "property" })) }); diff --git a/tests/cases/fourslash/javascriptModules20.ts b/tests/cases/fourslash/javascriptModules20.ts index 7ef5c73e1c326..8b8f0095959cd 100644 --- a/tests/cases/fourslash/javascriptModules20.ts +++ b/tests/cases/fourslash/javascriptModules20.ts @@ -9,5 +9,4 @@ //// import * as mod from "./mod" //// mod./**/ -goTo.marker(); -verify.completionListContains('a'); +verify.completions({ marker: "", exact: [{ name: "a", kind: "property" }, { name: "mod", kind: "warning" }] }); diff --git a/tests/cases/fourslash/javascriptModules21.ts b/tests/cases/fourslash/javascriptModules21.ts index 3a04651592444..5a8dd6b872b1e 100644 --- a/tests/cases/fourslash/javascriptModules21.ts +++ b/tests/cases/fourslash/javascriptModules21.ts @@ -10,5 +10,4 @@ //// import mod from "./mod" //// mod./**/ -goTo.marker(); -verify.completionListContains('a'); +verify.completions({ marker: "", exact: [{ name: "a", kind: "property" }, { name: "mod", kind: "warning" }] }); diff --git a/tests/cases/fourslash/javascriptModules22.ts b/tests/cases/fourslash/javascriptModules22.ts index caa8c6798b19d..ccc6d741c90d1 100644 --- a/tests/cases/fourslash/javascriptModules22.ts +++ b/tests/cases/fourslash/javascriptModules22.ts @@ -19,14 +19,13 @@ //// import def, {sausages} from "./mod2" //// a./**/ -goTo.marker(); -verify.completionListContains('toString'); +verify.completions({ marker: "", includes: "toString" }); edit.backspace(2); edit.insert("def."); -verify.completionListContains("name"); +verify.completions({ includes: "name" }); edit.insert("name;\nsausages."); -verify.completionListContains("eggs"); +verify.completions({ includes: "eggs" }); edit.insert("eggs;"); verify.noErrors(); diff --git a/tests/cases/fourslash/javascriptModules23.ts b/tests/cases/fourslash/javascriptModules23.ts index eafbea87baa91..303a73444fb2c 100644 --- a/tests/cases/fourslash/javascriptModules23.ts +++ b/tests/cases/fourslash/javascriptModules23.ts @@ -8,5 +8,4 @@ //// import {a} from "./mod" //// a./**/ -goTo.marker(); -verify.completionListContains('toString'); +verify.completions({ marker: "", includes: "toString" }); diff --git a/tests/cases/fourslash/javascriptModules25.ts b/tests/cases/fourslash/javascriptModules25.ts index aceada8af212f..ec4b41c27f497 100644 --- a/tests/cases/fourslash/javascriptModules25.ts +++ b/tests/cases/fourslash/javascriptModules25.ts @@ -9,5 +9,4 @@ //// import * as mod from "./mod" //// mod./**/ -goTo.marker(); -verify.completionListContains('a'); +verify.completions({ marker: "", includes: "a" }); diff --git a/tests/cases/fourslash/jsDocFunctionSignatures3.ts b/tests/cases/fourslash/jsDocFunctionSignatures3.ts index 87efaec330861..c519a1dcc72c4 100644 --- a/tests/cases/fourslash/jsDocFunctionSignatures3.ts +++ b/tests/cases/fourslash/jsDocFunctionSignatures3.ts @@ -18,15 +18,15 @@ //// otherMethod(p1) { //// p1/*2*/ //// } -//// +//// //// }; goTo.marker('1'); edit.insert('.'); -verify.completionListContains('substr', undefined, undefined, 'method'); +verify.completions({ includes: { name: "substr", kind: "method" } }); edit.backspace(); goTo.marker('2'); edit.insert('.'); -verify.completionListContains('toFixed', undefined, undefined, 'method'); +verify.completions({ includes: { name: "toFixed", kind: "method" } }); edit.backspace(); diff --git a/tests/cases/fourslash/jsDocGenerics1.ts b/tests/cases/fourslash/jsDocGenerics1.ts index e5570937ba4c2..70e13851cf788 100644 --- a/tests/cases/fourslash/jsDocGenerics1.ts +++ b/tests/cases/fourslash/jsDocGenerics1.ts @@ -23,12 +23,4 @@ //// var x; //// x[0].a./*3*/ - -goTo.marker('1'); -verify.completionListContains("toFixed", /*displayText:*/ undefined, /*documentation*/ undefined, "method"); - -goTo.marker('2'); -verify.completionListContains("toFixed", /*displayText:*/ undefined, /*documentation*/ undefined, "method"); - -goTo.marker('3'); -verify.completionListContains("toFixed", /*displayText:*/ undefined, /*documentation*/ undefined, "method"); +verify.completions({ marker: test.markers(), includes: { name: "toFixed", kind: "method" } }); diff --git a/tests/cases/fourslash/jsDocTags.ts b/tests/cases/fourslash/jsDocTags.ts index 7cb5ae7198eb7..ddd1c54725060 100644 --- a/tests/cases/fourslash/jsDocTags.ts +++ b/tests/cases/fourslash/jsDocTags.ts @@ -76,10 +76,13 @@ verify.signatureHelp( { marker: "13", tags: [{ name: "returns", text: "a value" }] }, ); -goTo.marker('14'); -verify.completionEntryDetailIs( - "newMethod", - "(method) Foo.newMethod(): void", - "method documentation", - "method", - [{name: "mytag", text: "a JSDoc tag"}]); +verify.completions({ + marker: "14", + includes: { + name: "newMethod", + text: "(method) Foo.newMethod(): void", + documentation: "method documentation", + kind: "method", + tags: [{ name: "mytag", text: "a JSDoc tag" }], + }, +}); diff --git a/tests/cases/fourslash/jsFileJsdocTypedefTagTypeExpressionCompletion.ts b/tests/cases/fourslash/jsFileJsdocTypedefTagTypeExpressionCompletion.ts index d6c3ca4f91468..d3c4aafc938ef 100644 --- a/tests/cases/fourslash/jsFileJsdocTypedefTagTypeExpressionCompletion.ts +++ b/tests/cases/fourslash/jsFileJsdocTypedefTagTypeExpressionCompletion.ts @@ -11,60 +11,54 @@ //// */ //// var x; //// /** @type {/*5*/T./*2TypeMember*/O.Q.NumberLike} */ -//// var x1; +//// var x1; //// /** @type {/*6*/T./*3TypeMember*/People} */ //// var x1; //// /*globalValue*/ -interface VerifyCompletionsInJsDoc { - verifyType(symbol: string, kind: string): void; - verifyValue(symbol: string, kind: string): void; - verifyTypeMember(symbol: string, kind: string): void; -} - -function verifyCompletionsInJsDocType(marker: string, { verifyType, verifyValue, verifyTypeMember }: VerifyCompletionsInJsDoc) { - goTo.marker(marker); - - verifyType("T", "module"); - - // TODO: May be filter keywords based on context - //verifyType("string", "keyword"); - //verifyType("number", "keyword"); - - verifyValue("x", "var"); - verifyValue("x1", "var"); - - verifyTypeMember("NumberLike", "type"); - verifyTypeMember("People", "type"); - verifyTypeMember("O", "module"); +const types: ReadonlyArray = [ + { name: "T", kind: "module" }, +]; +const values: ReadonlyArray = [ + { name: "x", kind: "var" }, + { name: "x1", kind: "var" }, +]; +const typeMembers: ReadonlyArray = [ + { name: "NumberLike", kind: "type" }, + { name: "People", kind: "type" }, + { name: "O", kind: "module" }, +]; +function warnings(entries: ReadonlyArray): ReadonlyArray { + return entries.map(e => ({ ...e, kind: "warning" })); } -function verifySymbolPresentWithKind(symbol: string, kind: string) { - return verify.completionListContains(symbol, /*text*/ undefined, /*documentation*/ undefined, kind); -} - -function verifySymbolPresentWithWarning(symbol: string) { - return verifySymbolPresentWithKind(symbol, "warning"); -} - -for (let i = 1; i <= 6; i++) { - verifyCompletionsInJsDocType(i.toString(), { - verifyType: verifySymbolPresentWithKind, - verifyValue: verifySymbolPresentWithWarning, - verifyTypeMember: verifySymbolPresentWithWarning, - }); -} -verifyCompletionsInJsDocType("globalValue", { - verifyType: verifySymbolPresentWithWarning, - verifyValue: verifySymbolPresentWithKind, - verifyTypeMember: verifySymbolPresentWithWarning, -}); -for (let i = 1; i <= 3; i++) { - verifyCompletionsInJsDocType(i.toString() + "TypeMember", { - verifyType: verifySymbolPresentWithWarning, - verifyValue: verifySymbolPresentWithWarning, - verifyTypeMember: verifySymbolPresentWithKind, - }); -} -goTo.marker("propertyName"); -verify.completionListIsEmpty(); +verify.completions( + { + marker: ["1", "2", "3", "4", "5", "6"], + includes: [ + ...types, + ...warnings(values), + ...warnings(typeMembers), + ], + }, + { + marker: "globalValue", + includes: [ + ...values, + ...warnings(types), + ...warnings(typeMembers), + ], + }, + { + marker: [1, 2, 3].map(i => `${i}TypeMember`), + includes: [ + ...typeMembers, + ...warnings(types), + ...warnings(values), + ], + }, + { + marker: "propertyName", + exact: undefined, + }, +); diff --git a/tests/cases/fourslash/jsFileJsdocTypedefTagTypeExpressionCompletion2.ts b/tests/cases/fourslash/jsFileJsdocTypedefTagTypeExpressionCompletion2.ts index 038c5db55283b..9cb94689b7671 100644 --- a/tests/cases/fourslash/jsFileJsdocTypedefTagTypeExpressionCompletion2.ts +++ b/tests/cases/fourslash/jsFileJsdocTypedefTagTypeExpressionCompletion2.ts @@ -10,7 +10,7 @@ //// /** //// * @param {string} foo A value. //// * @returns {number} Another value -//// * @mytag +//// * @mytag //// */ //// method4(foo) { return 3; } //// } @@ -21,45 +21,21 @@ /////*globalValue*/ ////x./*valueMember*/ -interface VerifyCompletionsInJsDoc { - verifyValueOrType(symbol: string, kind: string): void; - verifyValue(symbol: string, kind: string): void; - verifyValueMember(symbol: string, kind: string): void; +function getCompletions(nonWarnings: ReadonlyArray): ReadonlyArray { + const withKinds: ReadonlyArray = [ + { name: "Foo", kind: "class" }, + { name: "x", kind: "var" }, + { name: "property1", kind: "property" }, + { name: "method3", kind: "method" }, + { name: "method4", kind: "method" }, + { name: "foo", kind: "warning" }, + ]; + for (const name of nonWarnings) ts.Debug.assert(withKinds.some(entry => entry.name === name)); + return withKinds.map(entry => nonWarnings.includes(entry.name) ? entry : ({ name: entry.name, kind: "warning" })); } -function verifyCompletionsInJsDocType(marker: string, { verifyValueOrType, verifyValue, verifyValueMember }: VerifyCompletionsInJsDoc) { - goTo.marker(marker); - - verifyValueOrType("Foo", "class"); - - verifyValue("x", "var"); - - verifyValueMember("property1", "property"); - verifyValueMember("method3", "method"); - verifyValueMember("method4", "method"); - verifyValueMember("foo", "warning"); -} - -function verifySymbolPresentWithKind(symbol: string, kind: string) { - return verify.completionListContains(symbol, /*text*/ undefined, /*documentation*/ undefined, kind); -} - -function verifySymbolPresentWithWarning(symbol: string) { - return verifySymbolPresentWithKind(symbol, "warning"); -} - -verifyCompletionsInJsDocType("type", { - verifyValueOrType: verifySymbolPresentWithKind, - verifyValue: verifySymbolPresentWithWarning, - verifyValueMember: verifySymbolPresentWithWarning, -}); -verifyCompletionsInJsDocType("globalValue", { - verifyValueOrType: verifySymbolPresentWithKind, - verifyValue: verifySymbolPresentWithKind, - verifyValueMember: verifySymbolPresentWithWarning, -}); -verifyCompletionsInJsDocType("valueMember", { - verifyValueOrType: verifySymbolPresentWithWarning, - verifyValue: verifySymbolPresentWithWarning, - verifyValueMember: verifySymbolPresentWithKind, -}); +verify.completions( + { marker: "type", includes: getCompletions(["Foo"]) }, + { marker: "globalValue", includes: getCompletions(["Foo", "x"]) }, + { marker: "valueMember", includes: getCompletions(["property1", "method3", "method4", "foo"]) }, +); diff --git a/tests/cases/fourslash/jsFileJsdocTypedefTagTypeExpressionCompletion3.ts b/tests/cases/fourslash/jsFileJsdocTypedefTagTypeExpressionCompletion3.ts index 66c3856d0b745..0c9391918087a 100644 --- a/tests/cases/fourslash/jsFileJsdocTypedefTagTypeExpressionCompletion3.ts +++ b/tests/cases/fourslash/jsFileJsdocTypedefTagTypeExpressionCompletion3.ts @@ -13,7 +13,7 @@ //// /** //// * @param {string} foo A value. //// * @returns {number} Another value -//// * @mytag +//// * @mytag //// */ //// method4(foo) { return 3; } //// } @@ -30,98 +30,63 @@ ////x1./*valueMemberOfFooInstance*/; ////Foo./*valueMemberOfFoo*/; -function verifySymbolPresentWithKind(symbol: string, kind: string) { - return verify.completionListContains(symbol, /*text*/ undefined, /*documentation*/ undefined, kind); -} +const warnings = (names: ReadonlyArray): ReadonlyArray => + names.map(name => ({ name, kind: "warning" })); -function verifySymbolPresentWithWarning(symbol: string) { - return verifySymbolPresentWithKind(symbol, "warning"); -} - -for (const marker of ["type1", "type2"]) { - goTo.marker(marker); - verifySymbolPresentWithKind("Foo", "class"); - - verifySymbolPresentWithWarning("Namespace"); - verifySymbolPresentWithWarning("SomeType"); - - verifySymbolPresentWithWarning("x"); - verifySymbolPresentWithWarning("x1"); - verifySymbolPresentWithWarning("method1"); - verifySymbolPresentWithWarning("property1"); - verifySymbolPresentWithWarning("method3"); - verifySymbolPresentWithWarning("method4"); - verifySymbolPresentWithWarning("foo"); -} - -goTo.marker("typeFooMember"); -verifySymbolPresentWithWarning("Foo"); -verifySymbolPresentWithKind("Namespace", "module"); -verifySymbolPresentWithWarning("SomeType"); -verifySymbolPresentWithWarning("x"); -verifySymbolPresentWithWarning("x1"); -verifySymbolPresentWithWarning("method1"); -verifySymbolPresentWithWarning("property1"); -verifySymbolPresentWithWarning("method3"); -verifySymbolPresentWithWarning("method4"); -verifySymbolPresentWithWarning("foo"); - -goTo.marker("NamespaceMember"); -verifySymbolPresentWithWarning("Foo"); -verifySymbolPresentWithWarning("Namespace"); -verifySymbolPresentWithKind("SomeType", "type"); -verifySymbolPresentWithWarning("x"); -verifySymbolPresentWithWarning("x1"); -verifySymbolPresentWithWarning("method1"); -verifySymbolPresentWithWarning("property1"); -verifySymbolPresentWithWarning("method3"); -verifySymbolPresentWithWarning("method4"); -verifySymbolPresentWithWarning("foo"); - -goTo.marker("globalValue"); -verifySymbolPresentWithKind("Foo", "class"); -verifySymbolPresentWithWarning("Namespace"); -verifySymbolPresentWithWarning("SomeType"); -verifySymbolPresentWithKind("x", "var"); -verifySymbolPresentWithKind("x1", "var"); -verifySymbolPresentWithWarning("method1"); -verifySymbolPresentWithWarning("property1"); -verifySymbolPresentWithWarning("method3"); -verifySymbolPresentWithWarning("method4"); -verifySymbolPresentWithWarning("foo"); - -goTo.marker("valueMemberOfSomeType"); -verifySymbolPresentWithWarning("Foo"); -verifySymbolPresentWithWarning("Namespace"); -verifySymbolPresentWithWarning("SomeType"); -verifySymbolPresentWithWarning("x"); -verifySymbolPresentWithWarning("x1"); -verifySymbolPresentWithWarning("method1"); -verifySymbolPresentWithWarning("property1"); -verifySymbolPresentWithWarning("method3"); -verifySymbolPresentWithWarning("method4"); -verifySymbolPresentWithWarning("foo"); - -goTo.marker("valueMemberOfFooInstance"); -verifySymbolPresentWithWarning("Foo"); -verifySymbolPresentWithWarning("Namespace"); -verifySymbolPresentWithWarning("SomeType"); -verifySymbolPresentWithWarning("x"); -verifySymbolPresentWithWarning("x1"); -verifySymbolPresentWithWarning("method1"); -verifySymbolPresentWithKind("property1", "property"); -verifySymbolPresentWithKind("method3", "method"); -verifySymbolPresentWithKind("method4", "method"); -verifySymbolPresentWithKind("foo", "warning"); - -goTo.marker("valueMemberOfFoo"); -verifySymbolPresentWithWarning("Foo"); -verifySymbolPresentWithWarning("Namespace"); -verifySymbolPresentWithWarning("SomeType"); -verifySymbolPresentWithWarning("x"); -verifySymbolPresentWithWarning("x1"); -verifySymbolPresentWithKind("method1", "method"); -verifySymbolPresentWithWarning("property1"); -verifySymbolPresentWithWarning("method3"); -verifySymbolPresentWithWarning("method4"); -verifySymbolPresentWithWarning("foo"); \ No newline at end of file +verify.completions( + { + marker: ["type1", "type2"], + includes: [ + { name: "Foo", kind: "class" }, + ...warnings(["Namespace", "SomeType", "x", "x1", "method1", "property1", "method3", "method4", "foo"]), + ], + }, + { + marker: "typeFooMember", + exact: [ + { name: "Namespace", kind: "module" }, + ...warnings(["Foo", "value", "property1", "method1", "method3", "method4", "foo", "age", "SomeType", "x", "x1"]), + ], + }, + { + marker: "NamespaceMember", + exact: [ + { name: "SomeType", kind: "type" }, + ...warnings(["Foo", "value", "property1", "method1", "method3", "method4", "foo", "age", "Namespace", "x", "x1"]), + ], + }, + { + marker: "globalValue", + includes: [ + { name: "Foo", kind: "class" }, + { name: "x", kind: "var" }, + { name: "x1", kind: "var" }, + ...warnings(["Namespace", "SomeType", "method1", "property1", "method3", "method4", "foo"]), + ], + }, + { + marker: "valueMemberOfSomeType", + exact: [ + { name: "age", kind: "property" }, + ...warnings(["Foo", "value", "property1", "method1", "method3", "method4", "foo", "Namespace", "SomeType", "x", "x1"]), + ], + }, + { + marker: "valueMemberOfFooInstance", + exact: [ + { name: "property1", kind: "property" }, + { name: "method3", kind: "method" }, + { name: "method4", kind: "method" }, + ...warnings(["Foo", "value", "method1", "foo", "age", "Namespace", "SomeType", "x", "x1"]), + ], + }, + { + marker: "valueMemberOfFoo", + exact: [ + { name: "prototype", kind: "property" }, + { name: "method1", kind: "method" }, + ...completion.functionMembers, + ...warnings(["Foo", "value", "property1", "method3", "method4", "foo", "age", "Namespace", "SomeType", "x", "x1"]), + ], + }, +); diff --git a/tests/cases/fourslash/jsdocNullableUnion.ts b/tests/cases/fourslash/jsdocNullableUnion.ts index 50b929b19120b..f8c4e13a8ce0e 100644 --- a/tests/cases/fourslash/jsdocNullableUnion.ts +++ b/tests/cases/fourslash/jsdocNullableUnion.ts @@ -1,23 +1,21 @@ /// // @allowNonTsExtensions: true +// @checkJs: true // @Filename: Foo.js -//// +/////** //// * @param {never | {x: string}} p1 //// * @param {undefined | {y: number}} p2 //// * @param {null | {z: boolean}} p3 //// * @returns {void} nothing //// */ ////function f(p1, p2, p3) { -//// p1./*1*/ -//// p2./*2*/ -//// p3./*3*/ +//// p1./*1*/; +//// p2./*2*/; +//// p3./*3*/; ////} -goTo.marker('1'); -verify.completionListContains("x"); - -goTo.marker('2'); -verify.completionListContains("y"); - -goTo.marker('3'); -verify.completionListContains("z"); +verify.completions( + { marker: "1", exact: "x" }, + { marker: "2", exact: "y" }, + { marker: "3", exact: "z" }, +); diff --git a/tests/cases/fourslash/jsdocParameterNameCompletion.ts b/tests/cases/fourslash/jsdocParameterNameCompletion.ts index b379cb771356e..05aa388009b47 100644 --- a/tests/cases/fourslash/jsdocParameterNameCompletion.ts +++ b/tests/cases/fourslash/jsdocParameterNameCompletion.ts @@ -22,8 +22,8 @@ //// */ ////function i(foo, bar) {} -verify.completionsAt("0", ["foo", "bar"]); -verify.completionsAt("1", ["bar"]); -verify.completionsAt("2", ["canary", "canoodle"]); -verify.completionsAt("3", ["foo", "bar"]); -verify.completionsAt("4", ["foo", "bar"]); +verify.completions( + { marker: ["0", "3", "4"], exact: ["foo", "bar"] }, + { marker: "1", exact: "bar" }, + { marker: "2", exact: ["canary", "canoodle"] }, +); diff --git a/tests/cases/fourslash/jsdocTypedefTagTypeExpressionCompletion.ts b/tests/cases/fourslash/jsdocTypedefTagTypeExpressionCompletion.ts index b7a2b7d899397..21cea81e57b2d 100644 --- a/tests/cases/fourslash/jsdocTypedefTagTypeExpressionCompletion.ts +++ b/tests/cases/fourslash/jsdocTypedefTagTypeExpressionCompletion.ts @@ -30,111 +30,53 @@ //// */ ////var y; -function verifySymbolPresentWithKind(symbol: string, kind: string) { - return verify.completionListContains(symbol, /*text*/ undefined, /*documentation*/ undefined, kind); -} - -function verifySymbolNotPresent(symbol: string) { - return verify.not.completionListContains(symbol); -} - -goTo.marker("type1"); -verifySymbolPresentWithKind("Foo", "class"); -verifySymbolPresentWithKind("I", "interface"); -verifySymbolNotPresent("Namespace"); -verifySymbolNotPresent("SomeType"); -verifySymbolNotPresent("x"); -verifySymbolNotPresent("x1"); -verifySymbolNotPresent("y"); -verifySymbolNotPresent("method1"); -verifySymbolNotPresent("property1"); -verifySymbolNotPresent("method3"); -verifySymbolNotPresent("method4"); -verifySymbolNotPresent("foo"); - -goTo.marker("typeFooMember"); -verifySymbolNotPresent("Foo"); -verifySymbolNotPresent("I"); -verifySymbolPresentWithKind("Namespace", "module"); -verifySymbolNotPresent("SomeType"); -verifySymbolNotPresent("x"); -verifySymbolNotPresent("x1"); -verifySymbolNotPresent("y"); -verifySymbolNotPresent("method1"); -verifySymbolNotPresent("property1"); -verifySymbolNotPresent("method3"); -verifySymbolNotPresent("method4"); -verifySymbolNotPresent("foo"); - -goTo.marker("NamespaceMember"); -verifySymbolNotPresent("Foo"); -verifySymbolNotPresent("I"); -verifySymbolNotPresent("Namespace"); -verifySymbolPresentWithKind("SomeType", "interface"); -verifySymbolNotPresent("x"); -verifySymbolNotPresent("x1"); -verifySymbolNotPresent("y"); -verifySymbolNotPresent("method1"); -verifySymbolNotPresent("property1"); -verifySymbolNotPresent("method3"); -verifySymbolNotPresent("method4"); -verifySymbolNotPresent("foo"); - -goTo.marker("globalValue"); -verifySymbolPresentWithKind("Foo", "class"); -verifySymbolNotPresent("I"); -verifySymbolNotPresent("Namespace"); -verifySymbolNotPresent("SomeType"); -verifySymbolPresentWithKind("x", "var"); -verifySymbolPresentWithKind("x1", "var"); -verifySymbolPresentWithKind("y", "var"); -verifySymbolNotPresent("method1"); -verifySymbolNotPresent("property1"); -verifySymbolNotPresent("method3"); -verifySymbolNotPresent("method4"); -verifySymbolNotPresent("foo"); - -goTo.marker("valueMemberOfSomeType"); -verifySymbolNotPresent("Foo"); -verifySymbolNotPresent("I"); -verifySymbolNotPresent("Namespace"); -verifySymbolNotPresent("SomeType"); -verifySymbolNotPresent("x"); -verifySymbolNotPresent("x1"); -verifySymbolNotPresent("y"); -verifySymbolNotPresent("method1"); -verifySymbolNotPresent("property1"); -verifySymbolNotPresent("method3"); -verifySymbolNotPresent("method4"); -verifySymbolNotPresent("foo"); - -goTo.marker("valueMemberOfFooInstance"); -verifySymbolNotPresent("Foo"); -verifySymbolNotPresent("I"); -verifySymbolNotPresent("Namespace"); -verifySymbolNotPresent("SomeType"); -verifySymbolNotPresent("x"); -verifySymbolNotPresent("x1"); -verifySymbolNotPresent("y"); -verifySymbolNotPresent("method1"); -verifySymbolPresentWithKind("property1", "property"); -verifySymbolPresentWithKind("method3", "method"); -verifySymbolPresentWithKind("method4", "method"); -verifySymbolNotPresent("foo"); - -goTo.marker("valueMemberOfFoo"); -verifySymbolNotPresent("Foo"); -verifySymbolNotPresent("I"); -verifySymbolNotPresent("Namespace"); -verifySymbolNotPresent("SomeType"); -verifySymbolNotPresent("x"); -verifySymbolNotPresent("x1"); -verifySymbolNotPresent("y"); -verifySymbolPresentWithKind("method1", "method"); -verifySymbolNotPresent("property1"); -verifySymbolNotPresent("method3"); -verifySymbolNotPresent("method4"); -verifySymbolNotPresent("foo"); - -goTo.marker("propertyName"); -verify.completionListIsEmpty(); \ No newline at end of file +verify.completions( + { + marker: "type1", + includes: [ + { name: "Foo", kind: "class" }, + { name: "I", kind: "interface" }, + ], + excludes: ["Namespace", "SomeType", "x", "x1", "y", "method1", "property1", "method3", "method4", "foo"], + }, + { + marker: "typeFooMember", + exact: { name: "Namespace", kind: "module" }, + }, + { + marker: "NamespaceMember", + exact: { name: "SomeType", kind: "interface" }, + }, + { + marker: "globalValue", + includes: [ + { name: "Foo", kind: "class" }, + { name: "x", kind: "var" }, + { name: "x1", kind: "var" }, + { name: "y", kind: "var" }, + ], + excludes: ["I", "Namespace", "SomeType", "method1", "property1", "method3", "method4", "foo"], + }, + // This is TypeScript code, so the @type tag doesn't change the type of `x`. + { marker: "valueMemberOfSomeType", exact: undefined }, + { + marker: "valueMemberOfFooInstance", + exact: [ + { name: "property1", kind: "property" }, + { name: "method3", kind: "method" }, + { name: "method4", kind: "method" }, + ], + }, + { + marker: "valueMemberOfFoo", + exact: [ + "prototype", + { name: "method1", kind: "method" }, + ...completion.functionMembers, + ], + }, + { + marker: "propertyName", + exact: undefined, + }, +); diff --git a/tests/cases/fourslash/lambdaThisMembers.ts b/tests/cases/fourslash/lambdaThisMembers.ts index 1a5aa112a6cce..d0936b624033a 100644 --- a/tests/cases/fourslash/lambdaThisMembers.ts +++ b/tests/cases/fourslash/lambdaThisMembers.ts @@ -9,8 +9,4 @@ //// } //// } -goTo.marker(); -verify.completionListContains("a"); -verify.completionListContains("b"); -verify.completionListCount(2); - +verify.completions({ marker: "", exact: ["a", "b"] }); diff --git a/tests/cases/fourslash/letQuickInfoAndCompletionList.ts b/tests/cases/fourslash/letQuickInfoAndCompletionList.ts index 5f9764b935771..66a5d95439aef 100644 --- a/tests/cases/fourslash/letQuickInfoAndCompletionList.ts +++ b/tests/cases/fourslash/letQuickInfoAndCompletionList.ts @@ -7,20 +7,21 @@ //// /*4*/b = /*5*/a; ////} -verify.quickInfoAt("1", "let a: number"); +const a = "let a: number"; +const b = "let b: number"; +const completionA: FourSlashInterface.ExpectedCompletionEntry = { name: "a", text: a }; +const completionB: FourSlashInterface.ExpectedCompletionEntry = { name: "b", text: b }; -goTo.marker('2'); -verify.completionListContains("a", "let a: number"); -verify.quickInfoIs("let a: number"); +verify.completions( + { marker: "2", includes: completionA }, + { marker: "4", includes: [completionA, completionB] }, + { marker: "5", includes: [completionA, completionB], isNewIdentifierLocation: true }, +); -verify.quickInfoAt("3", "let b: number"); - -goTo.marker('4'); -verify.completionListContains("a", "let a: number"); -verify.completionListContains("b", "let b: number"); -verify.quickInfoIs("let b: number"); - -goTo.marker('5'); -verify.completionListContains("a", "let a: number"); -verify.completionListContains("b", "let b: number"); -verify.quickInfoIs("let a: number"); +verify.quickInfos({ + 1: a, + 2: a, + 3: b, + 4: b, + 5: a, +}); diff --git a/tests/cases/fourslash/memberCompletionFromFunctionCall.ts b/tests/cases/fourslash/memberCompletionFromFunctionCall.ts index 9bd59e1dc9f9f..d55d0d99034f7 100644 --- a/tests/cases/fourslash/memberCompletionFromFunctionCall.ts +++ b/tests/cases/fourslash/memberCompletionFromFunctionCall.ts @@ -8,5 +8,4 @@ goTo.marker(); edit.insert("."); -verify.not.completionListIsEmpty(); -verify.completionListContains("text"); \ No newline at end of file +verify.completions({ exact: "text" }); diff --git a/tests/cases/fourslash/memberCompletionInForEach1.ts b/tests/cases/fourslash/memberCompletionInForEach1.ts index b90da43c11915..f26a5e409ba82 100644 --- a/tests/cases/fourslash/memberCompletionInForEach1.ts +++ b/tests/cases/fourslash/memberCompletionInForEach1.ts @@ -6,11 +6,9 @@ goTo.marker('1'); edit.insert('.'); -verify.completionListContains('trim'); -verify.completionListCount(21); +verify.completions({ exact: completion.stringMembers }); edit.insert('});'); // need the following lines to not have parse errors in order for completion list to appear goTo.marker('2'); edit.insert('.'); -verify.completionListContains('trim'); -verify.completionListCount(21); +verify.completions({ exact: completion.stringMembers }); diff --git a/tests/cases/fourslash/memberCompletionOnRightSideOfImport.ts b/tests/cases/fourslash/memberCompletionOnRightSideOfImport.ts index 223995ebb0c22..98546eee3d36c 100644 --- a/tests/cases/fourslash/memberCompletionOnRightSideOfImport.ts +++ b/tests/cases/fourslash/memberCompletionOnRightSideOfImport.ts @@ -2,5 +2,4 @@ ////import x = M./**/ -goTo.marker(""); -verify.completionListIsEmpty(); \ No newline at end of file +verify.completions({ marker: "", exact: undefined }); diff --git a/tests/cases/fourslash/memberCompletionOnTypeParameters2.ts b/tests/cases/fourslash/memberCompletionOnTypeParameters2.ts index f77a8b0c61236..84fa058086c08 100644 --- a/tests/cases/fourslash/memberCompletionOnTypeParameters2.ts +++ b/tests/cases/fourslash/memberCompletionOnTypeParameters2.ts @@ -15,7 +15,4 @@ //// y = this.x./**/ // completion list here ////} - -goTo.marker(); -verify.completionListContains("foo"); -verify.completionListCount(1); +verify.completions({ marker: "", exact: "foo" }); diff --git a/tests/cases/fourslash/memberListAfterDoubleDot.ts b/tests/cases/fourslash/memberListAfterDoubleDot.ts index 489e7c3b10513..1da99ddaa0748 100644 --- a/tests/cases/fourslash/memberListAfterDoubleDot.ts +++ b/tests/cases/fourslash/memberListAfterDoubleDot.ts @@ -2,5 +2,4 @@ ////../**/ -goTo.marker(); -verify.completionListIsEmpty(); \ No newline at end of file +verify.completions({ marker: "", exact: undefined }); diff --git a/tests/cases/fourslash/memberListAfterSingleDot.ts b/tests/cases/fourslash/memberListAfterSingleDot.ts index ba0cdb1a1eba8..1b4957ecfbb0e 100644 --- a/tests/cases/fourslash/memberListAfterSingleDot.ts +++ b/tests/cases/fourslash/memberListAfterSingleDot.ts @@ -2,5 +2,4 @@ ////./**/ -goTo.marker(); -verify.completionListIsEmpty(); \ No newline at end of file +verify.completions({ marker: "", exact: undefined }); diff --git a/tests/cases/fourslash/memberListErrorRecovery.ts b/tests/cases/fourslash/memberListErrorRecovery.ts index ee1fdf9193cc7..a7414b4769ecc 100644 --- a/tests/cases/fourslash/memberListErrorRecovery.ts +++ b/tests/cases/fourslash/memberListErrorRecovery.ts @@ -5,6 +5,4 @@ ////Foo./**/; /////*1*/var bar; -goTo.marker(); -verify.completionListContains("fun"); -verify.not.errorExistsAfterMarker("1"); \ No newline at end of file +verify.completions({ marker: "", includes: "fun" }); diff --git a/tests/cases/fourslash/memberListInFunctionCall.ts b/tests/cases/fourslash/memberListInFunctionCall.ts index 82e05bc4a008c..67ff7ad0f8fe9 100644 --- a/tests/cases/fourslash/memberListInFunctionCall.ts +++ b/tests/cases/fourslash/memberListInFunctionCall.ts @@ -10,6 +10,5 @@ goTo.marker(); edit.insert('.'); - -verify.completionListContains('charAt'); +verify.completions({ includes: "charAt" }); diff --git a/tests/cases/fourslash/memberListInReopenedEnum.ts b/tests/cases/fourslash/memberListInReopenedEnum.ts index a03ee39041cd1..70dae89b7820d 100644 --- a/tests/cases/fourslash/memberListInReopenedEnum.ts +++ b/tests/cases/fourslash/memberListInReopenedEnum.ts @@ -10,9 +10,12 @@ //// var x = E./*1*/ ////} - -goTo.marker('1'); -verify.completionListContains('A', '(enum member) E.A = 0'); -verify.completionListContains('B', '(enum member) E.B = 1'); -verify.completionListContains('C', '(enum member) E.C = 0'); -verify.completionListContains('D', '(enum member) E.D = 1'); \ No newline at end of file +verify.completions({ + marker: "1", + exact: [ + { name: "A", text: "(enum member) E.A = 0" }, + { name: "B", text: "(enum member) E.B = 1" }, + { name: "C", text: "(enum member) E.C = 0" }, + { name: "D", text: "(enum member) E.D = 1" }, + ], +}); diff --git a/tests/cases/fourslash/memberListInWithBlock.ts b/tests/cases/fourslash/memberListInWithBlock.ts index 5253e924ff397..889c2cdcab532 100644 --- a/tests/cases/fourslash/memberListInWithBlock.ts +++ b/tests/cases/fourslash/memberListInWithBlock.ts @@ -11,14 +11,8 @@ //// } ////} -goTo.marker('1'); -verify.completionListIsEmpty(); - -goTo.marker('2'); -// Only keywords should show in completion, no members or types -verify.not.completionListContains("foo"); -verify.not.completionListContains("f"); -verify.not.completionListContains("c"); -verify.not.completionListContains("d"); -verify.not.completionListContains("x"); -verify.not.completionListContains("Object"); +verify.completions( + { marker: "1", exact: undefined }, + // Only keywords should show in completion, no members or types + { marker: "2", excludes: ["foo", "f", "c", "d", "x", "Object"] }, +); diff --git a/tests/cases/fourslash/memberListInWithBlock2.ts b/tests/cases/fourslash/memberListInWithBlock2.ts index 534cd12a41671..07dfd49855e11 100644 --- a/tests/cases/fourslash/memberListInWithBlock2.ts +++ b/tests/cases/fourslash/memberListInWithBlock2.ts @@ -5,8 +5,7 @@ ////} //// ////with (x) { -//// var y: IFoo = { /*1*/ }; +//// var y: IFoo = { /*1*/ }; ////} -goTo.marker('1'); -verify.completionListIsEmpty(); \ No newline at end of file +verify.completions({ marker: "1", exact: undefined }); diff --git a/tests/cases/fourslash/memberListInWithBlock3.ts b/tests/cases/fourslash/memberListInWithBlock3.ts index b30ceed989740..5495b8f4c0d51 100644 --- a/tests/cases/fourslash/memberListInWithBlock3.ts +++ b/tests/cases/fourslash/memberListInWithBlock3.ts @@ -3,5 +3,4 @@ ////var x = { a: 0 }; ////with(x./*1*/ -goTo.marker('1'); -verify.completionListContains("a"); +verify.completions({ marker: "1", exact: "a" }); diff --git a/tests/cases/fourslash/memberListOfClass.ts b/tests/cases/fourslash/memberListOfClass.ts index 3355109e4a74a..fcc01c604caef 100644 --- a/tests/cases/fourslash/memberListOfClass.ts +++ b/tests/cases/fourslash/memberListOfClass.ts @@ -9,7 +9,10 @@ ////var f = new C1(); ////f./**/ -goTo.marker(); -verify.completionListCount(2); -verify.completionListContains('pubMeth', '(method) C1.pubMeth(): void'); -verify.completionListContains('pubProp', '(property) C1.pubProp: number'); \ No newline at end of file +verify.completions({ + marker: "", + exact: [ + { name: "pubMeth", text: "(method) C1.pubMeth(): void" }, + { name: "pubProp", text: "(property) C1.pubProp: number" }, + ], +}); diff --git a/tests/cases/fourslash/memberListOfEnumFromExternalModule.ts b/tests/cases/fourslash/memberListOfEnumFromExternalModule.ts index 5caaf5d9c23f1..e114d3a214378 100644 --- a/tests/cases/fourslash/memberListOfEnumFromExternalModule.ts +++ b/tests/cases/fourslash/memberListOfEnumFromExternalModule.ts @@ -8,6 +8,4 @@ ////import t = require('./memberListOfEnumFromExternalModule_file0'); ////var topic = t.Topic./*1*/ -goTo.file("memberListOfEnumFromExternalModule_file1.ts"); -goTo.marker('1'); -verify.completionListContains("One"); \ No newline at end of file +verify.completions({ marker: "1", exact: ["One", "Two"] }); diff --git a/tests/cases/fourslash/memberListOfEnumInModule.ts b/tests/cases/fourslash/memberListOfEnumInModule.ts index 0a3887e3304ef..6f4fe6ef239f6 100644 --- a/tests/cases/fourslash/memberListOfEnumInModule.ts +++ b/tests/cases/fourslash/memberListOfEnumInModule.ts @@ -8,6 +8,4 @@ //// var f: Foo = Foo./**/; ////} -goTo.marker(); -verify.completionListContains("bar"); -verify.completionListContains("baz"); \ No newline at end of file +verify.completions({ marker: "", exact: ["bar", "baz"] }); diff --git a/tests/cases/fourslash/memberListOfExportedClass.ts b/tests/cases/fourslash/memberListOfExportedClass.ts index 3c9fe36358b43..a84c22e85aa39 100644 --- a/tests/cases/fourslash/memberListOfExportedClass.ts +++ b/tests/cases/fourslash/memberListOfExportedClass.ts @@ -10,6 +10,4 @@ //// ////c./**/ // test on c. -goTo.marker(); -verify.completionListCount(1); -verify.completionListContains('pub', '(property) M.C.pub: number'); \ No newline at end of file +verify.completions({ marker: "", exact: { name: "pub", text: "(property) M.C.pub: number" } }); diff --git a/tests/cases/fourslash/memberListOfModule.ts b/tests/cases/fourslash/memberListOfModule.ts index 0e095c94cbd95..3dac514dda5fb 100644 --- a/tests/cases/fourslash/memberListOfModule.ts +++ b/tests/cases/fourslash/memberListOfModule.ts @@ -13,7 +13,4 @@ //// ////var x: Foo./**/ -goTo.marker(); -verify.completionListCount(1); -verify.completionListContains('Bar'); -verify.not.completionListContains('Blah'); \ No newline at end of file +verify.completions({ marker: "", exact: "Bar" }); diff --git a/tests/cases/fourslash/memberListOfModuleAfterInvalidCharater.ts b/tests/cases/fourslash/memberListOfModuleAfterInvalidCharater.ts index 76ffa87dd4f83..98e39c8a14160 100644 --- a/tests/cases/fourslash/memberListOfModuleAfterInvalidCharater.ts +++ b/tests/cases/fourslash/memberListOfModuleAfterInvalidCharater.ts @@ -6,5 +6,4 @@ ////@ ////testModule./**/ -goTo.marker(); -verify.completionListContains('foo', 'var testModule.foo: number'); +verify.completions({ marker: "", exact: { name: "foo", text: "var testModule.foo: number" } }); diff --git a/tests/cases/fourslash/memberListOfModuleBeforeKeyword.ts b/tests/cases/fourslash/memberListOfModuleBeforeKeyword.ts index 0ea07e87a0a78..1f7e2ab5e24b6 100644 --- a/tests/cases/fourslash/memberListOfModuleBeforeKeyword.ts +++ b/tests/cases/fourslash/memberListOfModuleBeforeKeyword.ts @@ -9,16 +9,12 @@ //// export class Test3 {} ////} //// -////TypeModule1./*dotedExpression*/ +////TypeModule1./*dottedExpression*/ ////module TypeModule3 { //// export class Test3 {} ////} // Verify the memberlist of module when the following line has a keyword -goTo.marker('namedType'); -verify.completionListContains('C1'); -verify.completionListContains('C2'); - -goTo.marker('dotedExpression'); -verify.completionListContains('C1'); -verify.completionListContains('C2'); \ No newline at end of file +verify.completions( + { marker: test.markers(), exact: ["C1", "C2"] }, +); diff --git a/tests/cases/fourslash/memberListOfModuleInAnotherModule.ts b/tests/cases/fourslash/memberListOfModuleInAnotherModule.ts index d8b90a3c21942..0fd2d19631509 100644 --- a/tests/cases/fourslash/memberListOfModuleInAnotherModule.ts +++ b/tests/cases/fourslash/memberListOfModuleInAnotherModule.ts @@ -20,18 +20,14 @@ //// iMod1./*3*/iMex = 1; ////} -goTo.marker('1'); -verify.completionListContains('meX', 'var mod1.meX: number'); -verify.completionListContains('meFunc', 'function mod1.meFunc(): void'); -verify.completionListContains('meClass', 'class mod1.meClass'); -verify.completionListContains('meMod', 'namespace mod1.meMod'); -verify.completionListContains('meInt', 'interface mod1.meInt'); - -goTo.marker('2'); -verify.completionListContains('meX', 'var mod1.meX: number'); -verify.completionListContains('meFunc', 'function mod1.meFunc(): void'); -verify.completionListContains('meClass', 'class mod1.meClass'); -verify.completionListContains('meMod', 'namespace mod1.meMod'); - -goTo.marker('3'); -verify.completionListContains('iMex', 'var mod1.meMod.iMex: number'); +const values: ReadonlyArray = [ + { name: "meFunc", text: "function mod1.meFunc(): void" }, + { name: "meX", text: "var mod1.meX: number" }, + { name: "meClass", text: "class mod1.meClass" }, + { name: "meMod", text: "namespace mod1.meMod" }, +]; +verify.completions( + { marker: "1", exact: [...values, { name: "meInt", text: "interface mod1.meInt" }] }, + { marker: "2", exact: values }, + { marker: "3", exact: { name: "iMex", text: "var mod1.meMod.iMex: number" } }, +); diff --git a/tests/cases/fourslash/memberListOfVarInArrowExpression.ts b/tests/cases/fourslash/memberListOfVarInArrowExpression.ts index b1a91ae3cb217..f146a86332de7 100644 --- a/tests/cases/fourslash/memberListOfVarInArrowExpression.ts +++ b/tests/cases/fourslash/memberListOfVarInArrowExpression.ts @@ -13,6 +13,5 @@ ////}); ////function each(items: T[], handler: (item: T) => void) { } -goTo.marker('1'); -verify.quickInfoIs("(property) a1: string"); -verify.completionListContains("a1", "(property) a1: string"); \ No newline at end of file +verify.quickInfoAt("1", "(property) a1: string"); +verify.completions({ marker: "1", exact: { name: "a1", text: "(property) a1: string" } }); diff --git a/tests/cases/fourslash/memberListOnConstructorType.ts b/tests/cases/fourslash/memberListOnConstructorType.ts index 3d5596f2e58dc..336814aca4187 100644 --- a/tests/cases/fourslash/memberListOnConstructorType.ts +++ b/tests/cases/fourslash/memberListOnConstructorType.ts @@ -3,6 +3,4 @@ ////var f: new () => void; ////f./*1*/ -goTo.marker('1'); -verify.completionListContains('apply'); -verify.completionListContains('arguments'); \ No newline at end of file +verify.completions({ marker: "1", exact: completion.functionMembersWithPrototype }); diff --git a/tests/cases/fourslash/memberListOnContextualThis.ts b/tests/cases/fourslash/memberListOnContextualThis.ts index e17600cad988b..d35f49e2c68ab 100644 --- a/tests/cases/fourslash/memberListOnContextualThis.ts +++ b/tests/cases/fourslash/memberListOnContextualThis.ts @@ -5,8 +5,5 @@ ////declare function ctx(callback: (this: A) => string): string; ////ctx(function () { return th/*1*/is./*2*/a }); -goTo.marker('1'); -verify.quickInfoIs("this: A"); -goTo.marker('2'); -verify.completionListContains('a', '(property) A.a: string'); - +verify.quickInfoAt("1", "this: A"); +verify.completions({ marker: "2", exact: { name: "a", text: "(property) A.a: string" } }); diff --git a/tests/cases/fourslash/memberListOnExplicitThis.ts b/tests/cases/fourslash/memberListOnExplicitThis.ts index 425eb17f8ba66..b437e3c70a6bf 100644 --- a/tests/cases/fourslash/memberListOnExplicitThis.ts +++ b/tests/cases/fourslash/memberListOnExplicitThis.ts @@ -12,18 +12,19 @@ ////function f(this: void) {this./*3*/} ////function g(this: Restricted) {this./*4*/} -goTo.marker('1'); -verify.completionListContains('f', '(method) C1.f(this: this): void'); -verify.completionListContains('g', '(method) C1.g(this: Restricted): void'); -verify.completionListContains('n', '(property) C1.n: number'); -verify.completionListContains('m', '(property) C1.m: number'); - -goTo.marker('2'); -verify.completionListContains('n', '(property) Restricted.n: number'); - -goTo.marker('3'); -verify.completionListIsEmpty(); - -goTo.marker('4'); -verify.completionListContains('n', '(property) Restricted.n: number'); - +verify.completions( + { + marker: "1", + exact: [ + { name: "n", text: "(property) C1.n: number" }, + { name: "m", text: "(property) C1.m: number" }, + { name: "f", text: "(method) C1.f(this: this): void" }, + { name: "g", text: "(method) C1.g(this: Restricted): void" }, + ], + }, + { + marker: ["2", "4"], + exact: { name: "n", text: "(property) Restricted.n: number" }, + }, + { marker: "3", exact: undefined }, +); diff --git a/tests/cases/fourslash/memberListOnFunctionParameter.ts b/tests/cases/fourslash/memberListOnFunctionParameter.ts index 52daacb357370..8679f1be59128 100644 --- a/tests/cases/fourslash/memberListOnFunctionParameter.ts +++ b/tests/cases/fourslash/memberListOnFunctionParameter.ts @@ -5,9 +5,8 @@ //// x.forEach(function (y) { y./**/} ); ////} -goTo.marker(); -verify.completionListContains("charAt"); -verify.completionListContains("charCodeAt"); -verify.completionListContains("length"); -verify.completionListContains("concat"); -verify.not.completionListContains("toFixed"); \ No newline at end of file +verify.completions({ + marker: "", + includes: "charAt", + excludes: "toFixed", +}); diff --git a/tests/cases/fourslash/memberListOnThisInClassWithPrivates.ts b/tests/cases/fourslash/memberListOnThisInClassWithPrivates.ts index c44835f68826e..edc7432ab0773 100644 --- a/tests/cases/fourslash/memberListOnThisInClassWithPrivates.ts +++ b/tests/cases/fourslash/memberListOnThisInClassWithPrivates.ts @@ -7,7 +7,12 @@ //// private privProp = 0; ////} -goTo.marker(); -verify.completionListContains('privMeth', '(method) C1.privMeth(): void'); -verify.completionListContains('pubMeth', '(method) C1.pubMeth(): void'); -verify.completionListContains('pubProp', '(property) C1.pubProp: number'); \ No newline at end of file +verify.completions({ + marker: "", + exact: [ + { name: "pubMeth", text: "(method) C1.pubMeth(): void" }, + { name: "privMeth", text: "(method) C1.privMeth(): void" }, + { name: "pubProp", text: "(property) C1.pubProp: number" }, + { name: "privProp", text: "(property) C1.privProp: number" }, + ], +}) diff --git a/tests/cases/fourslash/memberlistOnDDot.ts b/tests/cases/fourslash/memberlistOnDDot.ts index 11efdd5d523c2..c9d80fd827fee 100644 --- a/tests/cases/fourslash/memberlistOnDDot.ts +++ b/tests/cases/fourslash/memberlistOnDDot.ts @@ -6,4 +6,4 @@ goTo.marker(); edit.insert('.'); edit.insert('.'); -//verify.not.completionListContains('charAt'); \ No newline at end of file +verify.completions({ exact: undefined }); diff --git a/tests/cases/fourslash/mergedDeclarations1.ts b/tests/cases/fourslash/mergedDeclarations1.ts index 3c99b89e0e723..b0b8806e95684 100644 --- a/tests/cases/fourslash/mergedDeclarations1.ts +++ b/tests/cases/fourslash/mergedDeclarations1.ts @@ -17,11 +17,7 @@ ////var p2 = point./*2*/origin; ////var b = point./*3*/equals(p1, p2); -goTo.marker('1'); -verify.completionListContains('point'); - -goTo.marker('2'); -verify.completionListContains('origin'); - -goTo.marker('3'); -verify.completionListContains('equals'); \ No newline at end of file +verify.completions( + { marker: "1", includes: "point", isNewIdentifierLocation: true }, + { marker: ["2", "3"], exact: ["equals", "origin", ...completion.functionMembersWithPrototype] }, +); diff --git a/tests/cases/fourslash/mergedDeclarations2.ts b/tests/cases/fourslash/mergedDeclarations2.ts index 426a27d7b767b..d02e557ba6bc4 100644 --- a/tests/cases/fourslash/mergedDeclarations2.ts +++ b/tests/cases/fourslash/mergedDeclarations2.ts @@ -13,8 +13,7 @@ ////var p2 = point./*1*/origin; ////var b = point./*2*/equals(p1, p2); -goTo.marker('1'); -verify.completionListContains('origin'); - -goTo.marker('2'); -verify.completionListContains('equals'); \ No newline at end of file +verify.completions( + { marker: "1", includes: "origin" }, + { marker: "2", includes: "equals" }, +); diff --git a/tests/cases/fourslash/mergedDeclarationsWithExportAssignment1.ts b/tests/cases/fourslash/mergedDeclarationsWithExportAssignment1.ts index f6a159f7eee6e..5854f830d82f9 100644 --- a/tests/cases/fourslash/mergedDeclarationsWithExportAssignment1.ts +++ b/tests/cases/fourslash/mergedDeclarationsWithExportAssignment1.ts @@ -15,19 +15,17 @@ ////var /*3*/z = new /*2*/Foo(); ////var /*5*/r2 = Foo./*4*/x; -verify.quickInfoAt("1", [ - "(alias) class Foo", - "(alias) namespace Foo", - "import Foo = require('./mergedDeclarationsWithExportAssignment1_file0')" -].join("\n")); - -goTo.marker('2'); -verify.completionListContains('Foo'); - -verify.quickInfoAt("3", "var z: Foo"); - -goTo.marker('4'); -verify.completionListContains('x'); - -verify.quickInfoAt("5", "var r2: number"); - +verify.quickInfos({ + 1: [ + "(alias) class Foo", + "(alias) namespace Foo", + "import Foo = require('./mergedDeclarationsWithExportAssignment1_file0')" + ].join("\n"), + 3: "var z: Foo", + 5: "var r2: number", +}); + +verify.completions( + { marker: "2", includes: "Foo" }, + { marker: "4", includes: "x" }, +); diff --git a/tests/cases/fourslash/moduleMembersOfGenericType.ts b/tests/cases/fourslash/moduleMembersOfGenericType.ts index 1c5a3acff2c60..f3af3e2080fd6 100644 --- a/tests/cases/fourslash/moduleMembersOfGenericType.ts +++ b/tests/cases/fourslash/moduleMembersOfGenericType.ts @@ -5,5 +5,4 @@ ////} ////var r = M./**/; -goTo.marker(); -verify.completionListContains('x', 'var M.x: (x: T) => T'); +verify.completions({ marker: "", exact: { name: "x", text: "var M.x: (x: T) => T" } }); diff --git a/tests/cases/fourslash/multiModuleClodule1.ts b/tests/cases/fourslash/multiModuleClodule1.ts index 5aeb2e709f502..fa52150896f97 100644 --- a/tests/cases/fourslash/multiModuleClodule1.ts +++ b/tests/cases/fourslash/multiModuleClodule1.ts @@ -17,26 +17,11 @@ ////} //// ////var c = new C/*1*/(C./*2*/x); -////c/*3*/.foo = C./*4*/foo; +////c./*3*/foo = C./*4*/foo; -goTo.marker('1'); -verify.completionListContains('C'); - -goTo.marker('2'); -verify.completionListContains('x'); -verify.completionListContains('foo'); - -verify.completionListContains('boo'); -verify.not.completionListContains('bar'); - -goTo.marker('3'); -// editor is doing the right thing, fourslash is not -//verify.completionListContains('foo'); -//verify.completionListContains('bar'); - -goTo.marker('4'); -verify.completionListContains('x'); -verify.completionListContains('foo'); -verify.completionListContains('boo'); - -verify.noErrors(); \ No newline at end of file +verify.completions( + { marker: "1", includes: "C" }, + { marker: ["2", "4"], exact: ["prototype", "boo", "x", "foo", ...completion.functionMembers] }, + { marker: "3", exact: ["foo", "bar"] }, +); +verify.noErrors(); diff --git a/tests/cases/fourslash/multiModuleFundule1.ts b/tests/cases/fourslash/multiModuleFundule1.ts index 71fd64771d6a9..6cc23caf81f1a 100644 --- a/tests/cases/fourslash/multiModuleFundule1.ts +++ b/tests/cases/fourslash/multiModuleFundule1.ts @@ -13,21 +13,17 @@ ////var /*4*/r2 = new C(/*3*/ // using void returning function as constructor ////var r3 = C./*5*/ -goTo.marker('1'); -verify.completionListContains('C'); +verify.completions({ marker: "1", includes: "C", isNewIdentifierLocation: true }); edit.insert('C.x);'); verify.quickInfoAt("2", "var r: void"); -goTo.marker('3'); -verify.completionListContains('C'); +verify.completions({ marker: "3", includes: "C", isNewIdentifierLocation: true }); edit.insert('C.x);'); verify.quickInfoAt("4", "var r2: any"); -goTo.marker('5'); -verify.completionListContains('x'); -verify.completionListContains('foo'); +verify.completions({ marker: "5", includes: ["x", "foo"] }); edit.insert('x;'); verify.noErrors(); \ No newline at end of file diff --git a/tests/cases/fourslash/noCompletionListOnCommentsInsideObjectLiterals.ts b/tests/cases/fourslash/noCompletionListOnCommentsInsideObjectLiterals.ts index 38f9133149eaf..9247b2593a5f8 100644 --- a/tests/cases/fourslash/noCompletionListOnCommentsInsideObjectLiterals.ts +++ b/tests/cases/fourslash/noCompletionListOnCommentsInsideObjectLiterals.ts @@ -11,8 +11,4 @@ //// }; ////} -goTo.marker("1"); -verify.completionListIsEmpty(); - -goTo.marker("2"); -verify.completionListIsEmpty(); \ No newline at end of file +verify.completions({ marker: test.markers(), exact: undefined }); diff --git a/tests/cases/fourslash/noImportCompletionsInOtherJavaScriptFile.ts b/tests/cases/fourslash/noImportCompletionsInOtherJavaScriptFile.ts index 3493c4c2cff1a..681ea8f04d735 100644 --- a/tests/cases/fourslash/noImportCompletionsInOtherJavaScriptFile.ts +++ b/tests/cases/fourslash/noImportCompletionsInOtherJavaScriptFile.ts @@ -9,23 +9,21 @@ // @Filename: /a.js //// export const x = 0; //// export class C {} -//// +//// // @Filename: /b.js //// /**/ -goTo.file("/b.js"); -goTo.marker(); -verify.not.completionListContains("fail", undefined, undefined, undefined, undefined, undefined, { includeCompletionsForModuleExports: true }); +verify.completions({ marker: "", excludes: "fail", preferences: { includeCompletionsForModuleExports: true } }); edit.insert("export const k = 10;\r\nf"); -verify.completionListContains( - { name: "fail", source: "/node_modules/foo/index" }, - "const fail: number", - "", - "const", - undefined, - true, - { - includeCompletionsForModuleExports: true, - sourceDisplay: "./node_modules/foo/index" - }); +verify.completions({ + includes: { + name: "fail", + source: "/node_modules/foo/index", + sourceDisplay: "./node_modules/foo/index", + text: "const fail: number", + kind: "const", + hasAction: true, + }, + preferences: { includeCompletionsForModuleExports: true }, +}); diff --git a/tests/cases/fourslash/nonExistingImport.ts b/tests/cases/fourslash/nonExistingImport.ts index 899d4422aade2..a06a58a14e098 100644 --- a/tests/cases/fourslash/nonExistingImport.ts +++ b/tests/cases/fourslash/nonExistingImport.ts @@ -5,5 +5,4 @@ //// var n: num/*1*/ ////} -goTo.marker('1'); -verify.not.completionListIsEmpty(); \ No newline at end of file +verify.completions({ marker: "1", exact: completion.globalTypes }); diff --git a/tests/cases/fourslash/objectLiteralBindingInParameter.ts b/tests/cases/fourslash/objectLiteralBindingInParameter.ts index b1cbd21d92919..b35890a0d3b58 100644 --- a/tests/cases/fourslash/objectLiteralBindingInParameter.ts +++ b/tests/cases/fourslash/objectLiteralBindingInParameter.ts @@ -18,18 +18,4 @@ //// } ////}; -goTo.marker("1"); -verify.completionListContains("x1"); -verify.completionListContains("x2"); - -goTo.marker("2"); -verify.completionListContains("x1"); -verify.completionListContains("x2"); - -goTo.marker("3"); -verify.completionListContains("x1"); -verify.completionListContains("x2"); - -goTo.marker("4"); -verify.completionListContains("x1"); -verify.completionListContains("x2"); \ No newline at end of file +verify.completions({ marker: test.markers(), exact: ["x1", "x2"] }); diff --git a/tests/cases/fourslash/paramHelpOnCommaInString.ts b/tests/cases/fourslash/paramHelpOnCommaInString.ts index 258dbfa48e307..56d7cdabfac76 100644 --- a/tests/cases/fourslash/paramHelpOnCommaInString.ts +++ b/tests/cases/fourslash/paramHelpOnCommaInString.ts @@ -5,4 +5,4 @@ ////blah('hola/*1*/,/*2*/') // making sure the comma in a string literal doesn't trigger param help on the second function param -verify.signatureHelp({ marker: test.markerNames(), parameterName: "foo" }); +verify.signatureHelp({ marker: test.markers(), parameterName: "foo" }); diff --git a/tests/cases/fourslash/parameterInfoOnParameterType.ts b/tests/cases/fourslash/parameterInfoOnParameterType.ts index 117f07021db8a..dc12353f50289 100644 --- a/tests/cases/fourslash/parameterInfoOnParameterType.ts +++ b/tests/cases/fourslash/parameterInfoOnParameterType.ts @@ -5,4 +5,4 @@ ////foo("test"/*1*/); ////foo(b/*2*/); -verify.signatureHelp({ marker: test.markerNames(), parameterName: "a" }); +verify.signatureHelp({ marker: test.markers(), parameterName: "a" }); diff --git a/tests/cases/fourslash/proto.ts b/tests/cases/fourslash/proto.ts index 8dc82c53cd1d0..acf7f15b1b50f 100644 --- a/tests/cases/fourslash/proto.ts +++ b/tests/cases/fourslash/proto.ts @@ -12,8 +12,7 @@ verify.quickInfos({ 2: "var __proto__: M.__proto__" }); -goTo.marker('3'); -verify.completionListContains("__proto__", "var __proto__: M.__proto__", ""); +verify.completions({ marker: "3", includes: { name: "__proto__", text: "var __proto__: M.__proto__" } }); edit.insert("__proto__"); verify.goToDefinitionIs("2"); diff --git a/tests/cases/fourslash/protoPropertyInObjectLiteral.ts b/tests/cases/fourslash/protoPropertyInObjectLiteral.ts index 74e422fcec7e5..0f450f9c94fea 100644 --- a/tests/cases/fourslash/protoPropertyInObjectLiteral.ts +++ b/tests/cases/fourslash/protoPropertyInObjectLiteral.ts @@ -9,14 +9,12 @@ ////o1./*1*/ ////o2./*2*/ -goTo.marker('1'); -verify.completionListContains("__proto__", '(property) "__proto__": number'); +verify.completions({ marker: "1", exact: { name: "__proto__", text: '(property) "__proto__": number' } }); edit.insert("__proto__ = 10;"); verify.quickInfoAt("1", '(property) "__proto__": number'); -goTo.marker('2'); -verify.completionListContains("__proto__", '(property) __proto__: number'); +verify.completions({ marker: "2", exact: { name: "__proto__", text: "(property) __proto__: number" } }); edit.insert("__proto__ = 10;"); verify.quickInfoAt("2", "(property) __proto__: number"); diff --git a/tests/cases/fourslash/protoVarInContextualObjectLiteral.ts b/tests/cases/fourslash/protoVarInContextualObjectLiteral.ts index cf76ba7c3cd8b..68a155674358b 100644 --- a/tests/cases/fourslash/protoVarInContextualObjectLiteral.ts +++ b/tests/cases/fourslash/protoVarInContextualObjectLiteral.ts @@ -39,56 +39,35 @@ //// /*6*/ //// }; -goTo.marker('1'); -verify.completionListContains("__proto__", '(property) __proto__: number'); -verify.completionListContains("p", '(property) p: number'); +const tripleProto: FourSlashInterface.ExpectedCompletionEntry = { name: "___proto__", text: "(property) ___proto__: string" }; +const proto: FourSlashInterface.ExpectedCompletionEntry = { name: "__proto__", text: "(property) __proto__: number" }; +const protoQuoted: FourSlashInterface.ExpectedCompletionEntry = { name: "__proto__", text: '(property) "__proto__": number' }; +const p: FourSlashInterface.ExpectedCompletionEntry = { name: "p", text: "(property) p: number" }; + +verify.completions({ marker: "1", exact: [proto, p] }); edit.insert('__proto__: 10,'); -verify.not.completionListContains("__proto__", '(property) __proto__: number'); -verify.completionListContains("p", '(property) p: number'); +verify.completions({ exact: p }); -goTo.marker('2'); -verify.completionListContains("__proto__", '(property) __proto__: number'); -verify.completionListContains("p", '(property) p: number'); +verify.completions({ marker: "2", exact: [proto, p] }); edit.insert('"__proto__": 10,'); -verify.not.completionListContains("__proto__", '(property) __proto__: number'); -verify.completionListContains("p", '(property) p: number'); +verify.completions({ exact: p }); -goTo.marker('3'); -verify.completionListContains("__proto__", '(property) "__proto__": number'); -verify.completionListContains("p", '(property) p: number'); +verify.completions({ marker: "3", exact: [protoQuoted, p] }) edit.insert('__proto__: 10,'); -verify.not.completionListContains("__proto__", '(property) "__proto__": number'); -verify.completionListContains("p", '(property) p: number'); +verify.completions({ exact: p }); -goTo.marker('4'); -verify.completionListContains("__proto__", '(property) "__proto__": number'); -verify.completionListContains("p", '(property) p: number'); +verify.completions({ marker: "4", exact: [protoQuoted, p] }); edit.insert('"__proto__": 10,'); -verify.not.completionListContains("__proto__", '(property) "__proto__": number'); -verify.completionListContains("p", '(property) p: number'); +verify.completions({ exact: p }); -goTo.marker('5'); -verify.completionListContains("___proto__", '(property) ___proto__: string'); -verify.completionListContains("__proto__", '(property) __proto__: number'); -verify.completionListContains("p", '(property) p: number'); +verify.completions({ marker: "5", exact: [proto, tripleProto, p] }); edit.insert('__proto__: 10,'); -verify.not.completionListContains("__proto__", '(property) __proto__: number'); -verify.completionListContains("___proto__", '(property) ___proto__: string'); -verify.completionListContains("p", '(property) p: number'); +verify.completions({ exact: [tripleProto, p] }); edit.insert('"___proto__": "10",'); -verify.not.completionListContains("__proto__", '(property) __proto__: number'); -verify.not.completionListContains("___proto__", '(property) ___proto__: string'); -verify.completionListContains("p", '(property) p: number'); +verify.completions({ exact: p }); -goTo.marker('6'); -verify.completionListContains("___proto__", '(property) ___proto__: string'); -verify.completionListContains("__proto__", '(property) __proto__: number'); -verify.completionListContains("p", '(property) p: number'); +verify.completions({ marker: "6", exact: [proto, tripleProto, p] }); edit.insert('___proto__: "10",'); -verify.completionListContains("__proto__", '(property) __proto__: number'); -verify.not.completionListContains("___proto__", '(property) ___proto__: string'); -verify.completionListContains("p", '(property) p: number'); +verify.completions({ exact: [proto, p] }); edit.insert('"__proto__": 10,'); -verify.not.completionListContains("__proto__", '(property) __proto__: number'); -verify.not.completionListContains("___proto__", '(property) ___proto__: string'); -verify.completionListContains("p", '(property) p: number'); \ No newline at end of file +verify.completions({ exact: p }); diff --git a/tests/cases/fourslash/protoVarVisibleWithOuterScopeUnderscoreProto.ts b/tests/cases/fourslash/protoVarVisibleWithOuterScopeUnderscoreProto.ts index c0c7eb9f3ce21..b24cbfb7ae81d 100644 --- a/tests/cases/fourslash/protoVarVisibleWithOuterScopeUnderscoreProto.ts +++ b/tests/cases/fourslash/protoVarVisibleWithOuterScopeUnderscoreProto.ts @@ -7,6 +7,10 @@ //// /**/ ////} -goTo.marker(''); -verify.completionListContains("__proto__", '(local var) __proto__: string'); -verify.completionListContains("___proto__", 'var ___proto__: number'); +verify.completions({ + marker: "", + includes: [ + { name: "__proto__", text: "(local var) __proto__: string" }, + { name: "___proto__", text: "var ___proto__: number" }, + ], +}); diff --git a/tests/cases/fourslash/prototypeProperty.ts b/tests/cases/fourslash/prototypeProperty.ts index cae07d04a3ed6..ada6d7244690c 100644 --- a/tests/cases/fourslash/prototypeProperty.ts +++ b/tests/cases/fourslash/prototypeProperty.ts @@ -6,5 +6,4 @@ verify.quickInfoAt("1", "(property) A.prototype: A"); -goTo.marker('2'); -verify.completionListContains('prototype', '(property) A.prototype: A'); +verify.completions({ marker: "2", includes: [{ name: "prototype", text: "(property) A.prototype: A" }] }); diff --git a/tests/cases/fourslash/qualifiedName_import-declaration-with-variable-entity-names.ts b/tests/cases/fourslash/qualifiedName_import-declaration-with-variable-entity-names.ts index ea660aa89ecc3..9cdedf6d46e2c 100644 --- a/tests/cases/fourslash/qualifiedName_import-declaration-with-variable-entity-names.ts +++ b/tests/cases/fourslash/qualifiedName_import-declaration-with-variable-entity-names.ts @@ -11,7 +11,7 @@ ////var x = Alpha.[|{| "name" : "mem" |}x|] goTo.marker('import'); -verify.completionListContains('x', 'var Alpha.x: number'); +verify.completions({ includes: { name: "x", text: "var Alpha.x: number" } }); var def: FourSlashInterface.Range = test.ranges().filter(range => range.marker.data.name === "def")[0]; var imp: FourSlashInterface.Range = test.ranges().filter(range => range.marker.data.name === "import")[0]; diff --git a/tests/cases/fourslash/quickInfoOnNarrowedType.ts b/tests/cases/fourslash/quickInfoOnNarrowedType.ts index 2c8f4c8e216b7..da9a7ba0c7ac1 100644 --- a/tests/cases/fourslash/quickInfoOnNarrowedType.ts +++ b/tests/cases/fourslash/quickInfoOnNarrowedType.ts @@ -4,7 +4,7 @@ ////function foo(strOrNum: string | number) { //// if (typeof /*1*/strOrNum === "number") { -//// return /*2*/strOrNum; +//// return /*2*/strOrNum; //// } //// else { //// return /*3*/strOrNum.length; @@ -18,26 +18,19 @@ //// /*6*/s; ////} -goTo.marker('1'); -verify.quickInfoIs('(parameter) strOrNum: string | number'); -verify.completionListContains("strOrNum", "(parameter) strOrNum: string | number"); - -goTo.marker('2'); -verify.quickInfoIs('(parameter) strOrNum: number'); -verify.completionListContains("strOrNum", "(parameter) strOrNum: number"); - -goTo.marker('3'); -verify.quickInfoIs('(parameter) strOrNum: string'); -verify.completionListContains("strOrNum", "(parameter) strOrNum: string"); - -goTo.marker('4'); -verify.quickInfoIs('let s: string | undefined'); -verify.completionListContains("s", "let s: string | undefined"); - -goTo.marker('5'); -verify.quickInfoIs('let s: string | undefined'); -verify.completionListContains("s", "let s: string | undefined"); - -goTo.marker('6'); -verify.quickInfoIs('let s: string'); -verify.completionListContains("s", "let s: string"); +verify.quickInfos({ + 1: "(parameter) strOrNum: string | number", + 2: "(parameter) strOrNum: number", + 3: "(parameter) strOrNum: string", + 4: "let s: string | undefined", + 5: "let s: string | undefined", + 6: "let s: string", +}); + +verify.completions( + { marker: "1", includes: { name: "strOrNum", text: "(parameter) strOrNum: string | number" } }, + { marker: "2", includes: { name: "strOrNum", text: "(parameter) strOrNum: number" } }, + { marker: "3", includes: { name: "strOrNum", text: "(parameter) strOrNum: string" } }, + { marker: ["4", "5"], includes: { name: "s", text: "let s: string | undefined" } }, + { marker: "6", includes: { name: "s", text: "let s: string" } }, +); diff --git a/tests/cases/fourslash/quickInfoOnNarrowedTypeInModule.ts b/tests/cases/fourslash/quickInfoOnNarrowedTypeInModule.ts index 54a80194f3748..f995cd25cc486 100644 --- a/tests/cases/fourslash/quickInfoOnNarrowedTypeInModule.ts +++ b/tests/cases/fourslash/quickInfoOnNarrowedTypeInModule.ts @@ -26,50 +26,26 @@ //// strOrNum = m./*9*/exportedStrOrNum; ////} -goTo.marker('1'); -verify.quickInfoIs('var nonExportedStrOrNum: string | number'); -verify.completionListContains("nonExportedStrOrNum", "var nonExportedStrOrNum: string | number"); - -goTo.marker('2'); -verify.quickInfoIs('var nonExportedStrOrNum: number'); -verify.completionListContains("nonExportedStrOrNum", "var nonExportedStrOrNum: number"); - -goTo.marker('3'); -verify.quickInfoIs('var nonExportedStrOrNum: string'); -verify.completionListContains("nonExportedStrOrNum", "var nonExportedStrOrNum: string"); - -goTo.marker('4'); -verify.quickInfoIs('var m.exportedStrOrNum: string | number'); -verify.completionListContains("exportedStrOrNum", "var exportedStrOrNum: string | number"); - -goTo.marker('5'); -verify.quickInfoIs('var m.exportedStrOrNum: number'); -verify.completionListContains("exportedStrOrNum", "var exportedStrOrNum: number"); - -goTo.marker('6'); -verify.quickInfoIs('var m.exportedStrOrNum: string'); -verify.completionListContains("exportedStrOrNum", "var exportedStrOrNum: string"); - -goTo.marker('7'); -verify.quickInfoIs('var m.exportedStrOrNum: string | number'); -verify.completionListContains("exportedStrOrNum", "var m.exportedStrOrNum: string | number"); - -goTo.marker('8'); -verify.quickInfoIs('var m.exportedStrOrNum: number'); -verify.completionListContains("exportedStrOrNum", "var m.exportedStrOrNum: number"); - -goTo.marker('9'); -verify.quickInfoIs('var m.exportedStrOrNum: string'); -verify.completionListContains("exportedStrOrNum", "var m.exportedStrOrNum: string"); - -goTo.marker('7'); -verify.quickInfoIs('var m.exportedStrOrNum: string | number'); -verify.completionListContains("exportedStrOrNum", "var m.exportedStrOrNum: string | number"); - -goTo.marker('8'); -verify.quickInfoIs('var m.exportedStrOrNum: number'); -verify.completionListContains("exportedStrOrNum", "var m.exportedStrOrNum: number"); - -goTo.marker('9'); -verify.quickInfoIs('var m.exportedStrOrNum: string'); -verify.completionListContains("exportedStrOrNum", "var m.exportedStrOrNum: string"); \ No newline at end of file +verify.quickInfos({ + 1: "var nonExportedStrOrNum: string | number", + 2: "var nonExportedStrOrNum: number", + 3: "var nonExportedStrOrNum: string", + 4: "var m.exportedStrOrNum: string | number", + 5: "var m.exportedStrOrNum: number", + 6: "var m.exportedStrOrNum: string", + 7: "var m.exportedStrOrNum: string | number", + 8: "var m.exportedStrOrNum: number", + 9: "var m.exportedStrOrNum: string", +}); + +verify.completions( + { marker: "1", includes: { name: "nonExportedStrOrNum", text: "var nonExportedStrOrNum: string | number" } }, + { marker: "2", includes: { name: "nonExportedStrOrNum", text: "var nonExportedStrOrNum: number" }, isNewIdentifierLocation: true }, + { marker: "3", includes: { name: "nonExportedStrOrNum", text: "var nonExportedStrOrNum: string" }, isNewIdentifierLocation: true }, + { marker: "4", includes: { name: "exportedStrOrNum", text: "var exportedStrOrNum: string | number" } }, + { marker: "5", includes: { name: "exportedStrOrNum", text: "var exportedStrOrNum: number" }, isNewIdentifierLocation: true }, + { marker: "6", includes: { name: "exportedStrOrNum", text: "var exportedStrOrNum: string" }, isNewIdentifierLocation: true }, + { marker: "7", includes: { name: "exportedStrOrNum", text: "var m.exportedStrOrNum: string | number" } }, + { marker: "8", includes: { name: "exportedStrOrNum", text: "var m.exportedStrOrNum: number" } }, + { marker: "9", includes: { name: "exportedStrOrNum", text: "var m.exportedStrOrNum: string" } }, +); diff --git a/tests/cases/fourslash/quickInfoOnObjectLiteralWithAccessors.ts b/tests/cases/fourslash/quickInfoOnObjectLiteralWithAccessors.ts index e11af2beda407..1d7130948c117 100644 --- a/tests/cases/fourslash/quickInfoOnObjectLiteralWithAccessors.ts +++ b/tests/cases/fourslash/quickInfoOnObjectLiteralWithAccessors.ts @@ -1,6 +1,6 @@ /// -////function /*1*/makePoint(x: number) { +////function /*1*/makePoint(x: number) { //// return { //// b: 10, //// get x() { return x; }, @@ -13,12 +13,15 @@ verify.quickInfos({ 1: "function makePoint(x: number): {\n b: number;\n x: number;\n}", - 2: "var x: number" + 2: "var x: number", + 3: "(property) x: number", + 4: "var point: {\n b: number;\n x: number;\n}", }); -goTo.marker('3'); -verify.completionListContains("x", "(property) x: number", undefined); -verify.completionListContains("b", "(property) b: number", undefined); -verify.quickInfoIs("(property) x: number"); - -verify.quickInfoAt("4", "var point: {\n b: number;\n x: number;\n}"); +verify.completions({ + marker: "3", + exact: [ + { name: "b", text: "(property) b: number" }, + { name: "x", text: "(property) x: number" }, + ], +}); diff --git a/tests/cases/fourslash/quickInfoOnObjectLiteralWithOnlyGetter.ts b/tests/cases/fourslash/quickInfoOnObjectLiteralWithOnlyGetter.ts index f592b255ac05e..2c7a07dd8448f 100644 --- a/tests/cases/fourslash/quickInfoOnObjectLiteralWithOnlyGetter.ts +++ b/tests/cases/fourslash/quickInfoOnObjectLiteralWithOnlyGetter.ts @@ -1,6 +1,6 @@ /// -////function /*1*/makePoint(x: number) { +////function /*1*/makePoint(x: number) { //// return { //// get x() { return x; }, //// }; @@ -10,10 +10,8 @@ verify.quickInfos({ 1: "function makePoint(x: number): {\n readonly x: number;\n}", - 2: "var x: number" + 2: "var x: number", + 4: "var point: {\n readonly x: number;\n}", }); -goTo.marker('3'); -verify.completionListContains("x", "(property) x: number", undefined); - -verify.quickInfoAt("4", "var point: {\n readonly x: number;\n}"); +verify.completions({ marker: "3", exact: { name: "x", text: "(property) x: number" } }); diff --git a/tests/cases/fourslash/quickInfoOnObjectLiteralWithOnlySetter.ts b/tests/cases/fourslash/quickInfoOnObjectLiteralWithOnlySetter.ts index d66626cc99de7..d9639821792ae 100644 --- a/tests/cases/fourslash/quickInfoOnObjectLiteralWithOnlySetter.ts +++ b/tests/cases/fourslash/quickInfoOnObjectLiteralWithOnlySetter.ts @@ -1,6 +1,6 @@ /// -////function /*1*/makePoint(x: number) { +////function /*1*/makePoint(x: number) { //// return { //// b: 10, //// set x(a: number) { this.b = a; } @@ -9,11 +9,16 @@ ////var /*3*/point = makePoint(2); ////point./*2*/x = 30; -verify.quickInfoAt("1", "function makePoint(x: number): {\n b: number;\n x: number;\n}"); +verify.completions({ + marker: "2", + exact: [ + { name: "b", text: "(property) b: number" }, + { name: "x", text: "(property) x: number" }, + ], +}); -goTo.marker('2'); -verify.completionListContains("x", "(property) x: number", undefined); -verify.completionListContains("b", "(property) b: number", undefined); -verify.quickInfoIs("(property) x: number"); - -verify.quickInfoAt("3", "var point: {\n b: number;\n x: number;\n}"); +verify.quickInfos({ + 1: "function makePoint(x: number): {\n b: number;\n x: number;\n}", + 2: "(property) x: number", + 3: "var point: {\n b: number;\n x: number;\n}", +}); diff --git a/tests/cases/fourslash/salsaMethodsOnAssignedFunctionExpressions.ts b/tests/cases/fourslash/salsaMethodsOnAssignedFunctionExpressions.ts index 368064ea7f64c..2b433fd13c980 100644 --- a/tests/cases/fourslash/salsaMethodsOnAssignedFunctionExpressions.ts +++ b/tests/cases/fourslash/salsaMethodsOnAssignedFunctionExpressions.ts @@ -13,5 +13,12 @@ ////x/*1*/./*2*/m(); verify.quickInfoAt("1", "var x: C"); -goTo.marker('2'); -verify.completionListContains('m', '(property) C.m: (a: string) => void', 'The prototype method.'); +verify.completions({ + marker: "2", + includes: { + name: "m", + text: "(property) C.m: (a: string) => void", + documentation: "The prototype method.", + tags: [{ name: "param", text: "a Parameter definition." }], + }, +}); diff --git a/tests/cases/fourslash/selfReferencedExternalModule.ts b/tests/cases/fourslash/selfReferencedExternalModule.ts index 3c96c3207847b..142d45e5a0896 100644 --- a/tests/cases/fourslash/selfReferencedExternalModule.ts +++ b/tests/cases/fourslash/selfReferencedExternalModule.ts @@ -4,6 +4,10 @@ ////export var I = 1; ////A./**/I -goTo.marker(); -verify.completionListContains("A", "import A = require('./app')"); -verify.completionListContains("I", "var I: number"); +verify.completions({ + marker: "", + exact: [ + { name: "A", text: "import A = require('./app')" }, + { name: "I", text: "var I: number" }, + ], +}); diff --git a/tests/cases/fourslash/server/completionEntryDetailAcrossFiles01.ts b/tests/cases/fourslash/server/completionEntryDetailAcrossFiles01.ts index 243975fde2d45..005f42f82bceb 100644 --- a/tests/cases/fourslash/server/completionEntryDetailAcrossFiles01.ts +++ b/tests/cases/fourslash/server/completionEntryDetailAcrossFiles01.ts @@ -14,7 +14,8 @@ //// import a = require("./a"); //// a.fo/*2*/ -goTo.marker('1'); -verify.completionEntryDetailIs("foo", "var foo: (p1: string) => void", "Modify the parameter"); -goTo.marker('2'); -verify.completionEntryDetailIs("foo", "(property) a.foo: (p1: string) => void", "Modify the parameter"); +const entry = (text: string): FourSlashInterface.ExpectedCompletionEntry => ({ name: "foo", text, documentation: "Modify the parameter", tags: [{ name: "param", text: "p1" }] }); +verify.completions( + { marker: "1", includes: entry("var foo: (p1: string) => void") }, + { marker: "2", exact: entry("(property) a.foo: (p1: string) => void") }, +); diff --git a/tests/cases/fourslash/server/completions01.ts b/tests/cases/fourslash/server/completions01.ts index 38fdbab4eda9f..21fb7145ebbad 100644 --- a/tests/cases/fourslash/server/completions01.ts +++ b/tests/cases/fourslash/server/completions01.ts @@ -6,11 +6,9 @@ goTo.marker('1'); edit.insert('.'); -verify.completionListContains('trim'); -verify.completionListCount(21); +verify.completions({ includes: "trim" }); edit.insert('});'); // need the following lines to not have parse errors in order for completion list to appear goTo.marker('2'); edit.insert('.'); -verify.completionListContains('trim'); -verify.completionListCount(21); +verify.completions({ includes: "trim" }); diff --git a/tests/cases/fourslash/server/completions02.ts b/tests/cases/fourslash/server/completions02.ts index b6c39a5c7234f..1a493af524ba8 100644 --- a/tests/cases/fourslash/server/completions02.ts +++ b/tests/cases/fourslash/server/completions02.ts @@ -7,12 +7,14 @@ ////} ////Foo./**/ -goTo.marker(""); -verify.completionListContains("x"); +const entryName = (e: FourSlashInterface.ExpectedCompletionEntry) => typeof e === "string" ? e : e.name; +const sortedFunctionMembers = completion.functionMembersWithPrototype.slice().sort((a, b) => entryName(a).localeCompare(entryName(b))); +const exact: ReadonlyArray = [...sortedFunctionMembers, { name: "x", text: "var Foo.x: number" }]; +verify.completions({ marker: "", exact }); // Make an edit edit.insert("a"); edit.backspace(); // Checking for completion details after edit should work too -verify.completionEntryDetailIs("x", "var Foo.x: number"); +verify.completions({ exact }); diff --git a/tests/cases/fourslash/server/completions03.ts b/tests/cases/fourslash/server/completions03.ts index ef5f165195126..ad8aeff2b77ae 100644 --- a/tests/cases/fourslash/server/completions03.ts +++ b/tests/cases/fourslash/server/completions03.ts @@ -14,7 +14,4 @@ //// /**/ //// } -goTo.marker(""); -verify.completionListContains("three"); -verify.not.completionListContains("one"); -verify.not.completionListContains("two"); +verify.completions({ marker: "", exact: "three" }); diff --git a/tests/cases/fourslash/server/jsdocParamTagSpecialKeywords.ts b/tests/cases/fourslash/server/jsdocParamTagSpecialKeywords.ts index be7ca5f0dffe0..2d7606ccbebc0 100644 --- a/tests/cases/fourslash/server/jsdocParamTagSpecialKeywords.ts +++ b/tests/cases/fourslash/server/jsdocParamTagSpecialKeywords.ts @@ -9,6 +9,4 @@ //// type./**/ //// } - -goTo.marker(); -verify.completionListContains("charAt"); \ No newline at end of file +verify.completions({ marker: "", includes: "charAt" }); diff --git a/tests/cases/fourslash/server/jsdocTypedefTag.ts b/tests/cases/fourslash/server/jsdocTypedefTag.ts index 1ab7060456123..ed27e6e29ef49 100644 --- a/tests/cases/fourslash/server/jsdocTypedefTag.ts +++ b/tests/cases/fourslash/server/jsdocTypedefTag.ts @@ -51,41 +51,24 @@ //// d.dogName./*dogName*/; //// d.dogAge./*dogAge*/; -goTo.marker('numberLike'); -verify.completionListContains('charAt'); -verify.completionListContains('toExponential'); +verify.completions( + { marker: "numberLike", includes: ["charAt", "toExponential"] }, -goTo.marker('person'); -verify.completionListContains('personName'); -verify.completionListContains('personAge'); -goTo.marker('personName'); -verify.completionListContains('charAt'); -goTo.marker('personAge'); -verify.completionListContains('toExponential'); + { marker: "person", includes: ["personName", "personAge"] }, + { marker: "personName", includes: "charAt" }, + { marker: "personAge", includes: "toExponential" }, -goTo.marker('animal'); -verify.completionListContains('animalName'); -verify.completionListContains('animalAge'); -goTo.marker('animalName'); -verify.completionListContains('charAt'); -goTo.marker('animalAge'); -verify.completionListContains('toExponential'); + { marker: "animal", includes: ["animalName", "animalAge"] }, + { marker: "animalName", includes: "charAt" }, + { marker: "animalAge", includes: "toExponential" }, -goTo.marker('dog'); -verify.completionListContains('dogName'); -verify.completionListContains('dogAge'); -goTo.marker('dogName'); -verify.completionListContains('charAt'); -goTo.marker('dogAge'); -verify.completionListContains('toExponential'); + { marker: "dog", includes: ["dogName", "dogAge"] }, + { marker: "dogName", includes: "charAt" }, + { marker: "dogAge", includes: "toExponential" }, -goTo.marker('cat'); -verify.completionListContains('catName'); -verify.completionListContains('catAge'); -goTo.marker('catName'); -verify.completionListContains('charAt'); -goTo.marker('catAge'); -verify.completionListContains('toExponential'); + { marker: "cat", includes: ["catName", "catAge"] }, + { marker: "catName", includes: "charAt" }, + { marker: "catAge", includes: "toExponential" }, +); -goTo.marker("AnimalType"); -verify.quickInfoIs("type Animal = {\n animalName: string;\n animalAge: number;\n}", "- think Giraffes"); +verify.quickInfoAt("AnimalType", "type Animal = {\n animalName: string;\n animalAge: number;\n}", "- think Giraffes"); diff --git a/tests/cases/fourslash/server/jsdocTypedefTag1.ts b/tests/cases/fourslash/server/jsdocTypedefTag1.ts index 273dc1002af9d..4c7bde499eb60 100644 --- a/tests/cases/fourslash/server/jsdocTypedefTag1.ts +++ b/tests/cases/fourslash/server/jsdocTypedefTag1.ts @@ -9,12 +9,11 @@ //// */ //// function foo() { } -//// /** +//// /** //// * @param {MyType} my //// */ //// function a(my) { //// my.yes./*1*/ //// } -goTo.marker('1'); -verify.completionListContains('charAt'); \ No newline at end of file +verify.completions({ marker: "1", includes: "charAt" }); diff --git a/tests/cases/fourslash/server/jsdocTypedefTag2.ts b/tests/cases/fourslash/server/jsdocTypedefTag2.ts index 602109352103e..601db94513045 100644 --- a/tests/cases/fourslash/server/jsdocTypedefTag2.ts +++ b/tests/cases/fourslash/server/jsdocTypedefTag2.ts @@ -9,22 +9,21 @@ //// */ //// function foo() {} -//// /** +//// /** //// * @param {A.B.MyType} my2 //// */ //// function a(my2) { //// my2.yes./*1*/ //// } -//// /** +//// /** //// * @param {MyType} my2 //// */ //// function b(my2) { //// my2.yes./*2*/ //// } - -goTo.marker('1'); -verify.completionListContains('charAt'); -goTo.marker('2'); -verify.not.completionListContains('charAt'); \ No newline at end of file +verify.completions( + { marker: "1", includes: "charAt" }, + { marker: "2", excludes: "charAt" }, +); diff --git a/tests/cases/fourslash/server/jsdocTypedefTagNamespace.ts b/tests/cases/fourslash/server/jsdocTypedefTagNamespace.ts index 29330a73d3c53..0d04b58606fe6 100644 --- a/tests/cases/fourslash/server/jsdocTypedefTagNamespace.ts +++ b/tests/cases/fourslash/server/jsdocTypedefTagNamespace.ts @@ -15,13 +15,7 @@ //// /** @type {T.People} */ //// var x1; x1./*3*/; -goTo.marker("1"); -verify.completionListContains('charAt'); -verify.completionListContains('toExponential'); - -goTo.marker("2"); -verify.completionListContains('age'); - -goTo.marker("3"); -verify.completionListContains('charAt'); -verify.completionListContains('toExponential'); \ No newline at end of file +verify.completions( + { marker: ["1", "3"], includes: ["charAt", "toExponential"] }, + { marker: "2", includes: "age" }, +); diff --git a/tests/cases/fourslash/server/openFile.ts b/tests/cases/fourslash/server/openFile.ts index 320e52c9f5e1a..e30bccc488a19 100644 --- a/tests/cases/fourslash/server/openFile.ts +++ b/tests/cases/fourslash/server/openFile.ts @@ -13,4 +13,4 @@ var overridingContent = "var t = 10; t."; goTo.file("test.ts", overridingContent); goTo.file("test1.ts"); goTo.eof(); -verify.completionListContains("toExponential"); +verify.completions({ includes: "toExponential" }); diff --git a/tests/cases/fourslash/server/openFileWithSyntaxKind.ts b/tests/cases/fourslash/server/openFileWithSyntaxKind.ts index dcb1e54999ebd..16e05cf408092 100644 --- a/tests/cases/fourslash/server/openFileWithSyntaxKind.ts +++ b/tests/cases/fourslash/server/openFileWithSyntaxKind.ts @@ -16,4 +16,4 @@ goTo.file("test.ts", /*content*/ undefined, "JS"); goTo.eof(); -verify.completionListContains("toExponential"); +verify.completions({ includes: "toExponential" }); diff --git a/tests/cases/fourslash/server/typeReferenceOnServer.ts b/tests/cases/fourslash/server/typeReferenceOnServer.ts index 574ea6f60c46e..5a3273da7d7d7 100644 --- a/tests/cases/fourslash/server/typeReferenceOnServer.ts +++ b/tests/cases/fourslash/server/typeReferenceOnServer.ts @@ -4,6 +4,5 @@ ////var x: number; ////x./*1*/ -goTo.marker("1"); -verify.not.completionListIsEmpty(); +verify.completions({ marker: "1", includes: "toFixed" }); diff --git a/tests/cases/fourslash/shims-pp/getCompletionsAtPosition.ts b/tests/cases/fourslash/shims-pp/getCompletionsAtPosition.ts index f81572ccebf4a..527c0d0b6cab9 100644 --- a/tests/cases/fourslash/shims-pp/getCompletionsAtPosition.ts +++ b/tests/cases/fourslash/shims-pp/getCompletionsAtPosition.ts @@ -1,4 +1,4 @@ -/// +/// ////function foo(strOrNum: string | number) { //// /*1*/ @@ -10,11 +10,8 @@ //// } ////} -goTo.marker('1'); -verify.completionListContains("strOrNum", "(parameter) strOrNum: string | number"); - -goTo.marker('2'); -verify.completionListContains("strOrNum", "(parameter) strOrNum: number"); - -goTo.marker('3'); -verify.completionListContains("strOrNum", "(parameter) strOrNum: string"); \ No newline at end of file +verify.completions( + { marker: "1", includes: { name: "strOrNum", text: "(parameter) strOrNum: string | number" } }, + { marker: "2", includes: { name: "strOrNum", text: "(parameter) strOrNum: number" } }, + { marker: "3", includes: { name: "strOrNum", text: "(parameter) strOrNum: string" } }, +); diff --git a/tests/cases/fourslash/shims/getCompletionsAtPosition.ts b/tests/cases/fourslash/shims/getCompletionsAtPosition.ts index f81572ccebf4a..aa8f7a64e7f83 100644 --- a/tests/cases/fourslash/shims/getCompletionsAtPosition.ts +++ b/tests/cases/fourslash/shims/getCompletionsAtPosition.ts @@ -10,11 +10,8 @@ //// } ////} -goTo.marker('1'); -verify.completionListContains("strOrNum", "(parameter) strOrNum: string | number"); - -goTo.marker('2'); -verify.completionListContains("strOrNum", "(parameter) strOrNum: number"); - -goTo.marker('3'); -verify.completionListContains("strOrNum", "(parameter) strOrNum: string"); \ No newline at end of file +verify.completions( + { marker: "1", includes: { name: "strOrNum", text: "(parameter) strOrNum: string | number" } }, + { marker: "2", includes: { name: "strOrNum", text: "(parameter) strOrNum: number" } }, + { marker: "3", includes: { name: "strOrNum", text: "(parameter) strOrNum: string" } }, +); diff --git a/tests/cases/fourslash/signatureHelpTaggedTemplates1.ts b/tests/cases/fourslash/signatureHelpTaggedTemplates1.ts index 3824d238af3ec..334ce17779c8d 100644 --- a/tests/cases/fourslash/signatureHelpTaggedTemplates1.ts +++ b/tests/cases/fourslash/signatureHelpTaggedTemplates1.ts @@ -6,7 +6,7 @@ //// f `/*1*/ qwe/*2*/rty /*3*/$/*4*/{ 123 }/*5*/ as/*6*/df /*7*/$/*8*/{ 41234 }/*9*/ zxc/*10*/vb /*11*/$/*12*/{ g ` ` }/*13*/ /*14*/ /*15*/` verify.signatureHelp({ - marker: test.markerNames(), + marker: test.markers(), text: "f(templateStrings: any, x: any, y: any, z: any): number", argumentCount: 4, parameterCount: 4, diff --git a/tests/cases/fourslash/signatureHelpTaggedTemplates2.ts b/tests/cases/fourslash/signatureHelpTaggedTemplates2.ts index dc8fafdf7b433..b2c88fcd3151b 100644 --- a/tests/cases/fourslash/signatureHelpTaggedTemplates2.ts +++ b/tests/cases/fourslash/signatureHelpTaggedTemplates2.ts @@ -6,7 +6,7 @@ //// f `/*1*/ qwe/*2*/rty /*3*/$/*4*/{ 123 }/*5*/ as/*6*/df /*7*/$/*8*/{ 41234 }/*9*/ zxc/*10*/vb /*11*/$/*12*/{ g ` ` }/*13*/ /*14*/ /*15*/ verify.signatureHelp({ - marker: test.markerNames(), + marker: test.markers(), text: "f(templateStrings: any, x: any, y: any, z: any): number", argumentCount: 4, parameterCount: 4, diff --git a/tests/cases/fourslash/signatureHelpTaggedTemplates3.ts b/tests/cases/fourslash/signatureHelpTaggedTemplates3.ts index 8ec7d55e0c8de..1022f7df13fa3 100644 --- a/tests/cases/fourslash/signatureHelpTaggedTemplates3.ts +++ b/tests/cases/fourslash/signatureHelpTaggedTemplates3.ts @@ -6,7 +6,7 @@ //// f ` qwerty ${/*1*/ /*2*/123/*3*/ /*4*/} asdf ${ 41234 } zxcvb ${ g ` ` } ` verify.signatureHelp({ - marker: test.markerNames(), + marker: test.markers(), text: "f(templateStrings: any, x: any, y: any, z: any): number", argumentCount: 4, parameterCount: 4, diff --git a/tests/cases/fourslash/signatureHelpTaggedTemplates4.ts b/tests/cases/fourslash/signatureHelpTaggedTemplates4.ts index 526aea3595742..a0e6208c90baa 100644 --- a/tests/cases/fourslash/signatureHelpTaggedTemplates4.ts +++ b/tests/cases/fourslash/signatureHelpTaggedTemplates4.ts @@ -6,7 +6,7 @@ //// f ` qwerty ${ 123 } asdf ${/*1*/ /*2*/ /*3*/41/*4*/234/*5*/ /*6*/} zxcvb ${ g ` ` } ` verify.signatureHelp({ - marker: test.markerNames(), + marker: test.markers(), text: "f(templateStrings: any, x: any, y: any, z: any): number", argumentCount: 4, parameterCount: 4, diff --git a/tests/cases/fourslash/signatureHelpTaggedTemplates5.ts b/tests/cases/fourslash/signatureHelpTaggedTemplates5.ts index 4b29879047faa..25b83ece4bea8 100644 --- a/tests/cases/fourslash/signatureHelpTaggedTemplates5.ts +++ b/tests/cases/fourslash/signatureHelpTaggedTemplates5.ts @@ -6,7 +6,7 @@ //// f ` qwerty ${ 123 } asdf ${ 41234 } zxcvb ${/*1*/ /*2*/g/*3*/ /*4*/` `/*5*/ /*6*/} ` verify.signatureHelp({ - marker: test.markerNames(), + marker: test.markers(), text: "f(templateStrings: any, x: any, y: any, z: any): number", argumentCount: 4, parameterCount: 4, diff --git a/tests/cases/fourslash/signatureHelpTaggedTemplates6.ts b/tests/cases/fourslash/signatureHelpTaggedTemplates6.ts index a0455fe01166c..70d49704aef1c 100644 --- a/tests/cases/fourslash/signatureHelpTaggedTemplates6.ts +++ b/tests/cases/fourslash/signatureHelpTaggedTemplates6.ts @@ -6,7 +6,7 @@ //// f ` qwerty ${ 123 } asdf ${ 41234 } zxcvb ${ g `/*1*/ /*2*/ /*3*/` } ` verify.signatureHelp({ - marker: test.markerNames(), + marker: test.markers(), text: "g(templateStrings: any, x: any, y: any, z: any): string", argumentCount: 1, parameterCount: 4, diff --git a/tests/cases/fourslash/signatureHelpTaggedTemplates7.ts b/tests/cases/fourslash/signatureHelpTaggedTemplates7.ts index bd5456ccdd068..1c20a904b4e48 100644 --- a/tests/cases/fourslash/signatureHelpTaggedTemplates7.ts +++ b/tests/cases/fourslash/signatureHelpTaggedTemplates7.ts @@ -6,7 +6,7 @@ //// f `/*1*/ /*2*/ verify.signatureHelp({ - marker: test.markerNames(), + marker: test.markers(), text: "f(templateStrings: any, x: any, y: any, z: any): number", argumentCount: 1, parameterCount: 4, diff --git a/tests/cases/fourslash/signatureHelpTaggedTemplatesIncomplete1.ts b/tests/cases/fourslash/signatureHelpTaggedTemplatesIncomplete1.ts index 7c50431f62fa8..93888461b3a02 100644 --- a/tests/cases/fourslash/signatureHelpTaggedTemplatesIncomplete1.ts +++ b/tests/cases/fourslash/signatureHelpTaggedTemplatesIncomplete1.ts @@ -6,7 +6,7 @@ //// f `/*1*/ /*2*/${ verify.signatureHelp({ - marker: test.markerNames(), + marker: test.markers(), text: "f(templateStrings: any, x: any, y: any, z: any): number", argumentCount: 2, parameterCount: 4, diff --git a/tests/cases/fourslash/signatureHelpTaggedTemplatesIncomplete2.ts b/tests/cases/fourslash/signatureHelpTaggedTemplatesIncomplete2.ts index c8ed457422e24..f693b991ce5ae 100644 --- a/tests/cases/fourslash/signatureHelpTaggedTemplatesIncomplete2.ts +++ b/tests/cases/fourslash/signatureHelpTaggedTemplatesIncomplete2.ts @@ -6,7 +6,7 @@ //// f ` ${/*1*/ /*2*/ verify.signatureHelp({ - marker: test.markerNames(), + marker: test.markers(), text: "f(templateStrings: any, x: any, y: any, z: any): number", argumentCount: 2, parameterCount: 4, diff --git a/tests/cases/fourslash/signatureHelpTaggedTemplatesIncomplete3.ts b/tests/cases/fourslash/signatureHelpTaggedTemplatesIncomplete3.ts index 375a3d919ecb2..7dd7c9331fb3b 100644 --- a/tests/cases/fourslash/signatureHelpTaggedTemplatesIncomplete3.ts +++ b/tests/cases/fourslash/signatureHelpTaggedTemplatesIncomplete3.ts @@ -6,7 +6,7 @@ //// f ` ${ }/*1*/ /*2*/ verify.signatureHelp({ - marker: test.markerNames(), + marker: test.markers(), text: "f(templateStrings: any, x: any, y: any, z: any): number", argumentCount: 2, parameterCount: 4, diff --git a/tests/cases/fourslash/signatureHelpTaggedTemplatesIncomplete4.ts b/tests/cases/fourslash/signatureHelpTaggedTemplatesIncomplete4.ts index 275dd2b536029..4641f73b69d4c 100644 --- a/tests/cases/fourslash/signatureHelpTaggedTemplatesIncomplete4.ts +++ b/tests/cases/fourslash/signatureHelpTaggedTemplatesIncomplete4.ts @@ -6,7 +6,7 @@ //// f ` ${ } ${/*1*/ /*2*/ verify.signatureHelp({ - marker: test.markerNames(), + marker: test.markers(), text: "f(templateStrings: any, x: any, y: any, z: any): number", argumentCount: 3, parameterCount: 4, diff --git a/tests/cases/fourslash/signatureHelpTaggedTemplatesIncomplete5.ts b/tests/cases/fourslash/signatureHelpTaggedTemplatesIncomplete5.ts index fa02e910637cc..3d82c58cbd59e 100644 --- a/tests/cases/fourslash/signatureHelpTaggedTemplatesIncomplete5.ts +++ b/tests/cases/fourslash/signatureHelpTaggedTemplatesIncomplete5.ts @@ -6,7 +6,7 @@ //// f ` ${ } ${ }/*1*/ /*2*/ verify.signatureHelp({ - marker: test.markerNames(), + marker: test.markers(), text: "f(templateStrings: any, x: any, y: any, z: any): number", argumentCount: 3, parameterCount: 4, diff --git a/tests/cases/fourslash/signatureHelpTaggedTemplatesIncomplete6.ts b/tests/cases/fourslash/signatureHelpTaggedTemplatesIncomplete6.ts index c283d2e005383..0b602f34661fc 100644 --- a/tests/cases/fourslash/signatureHelpTaggedTemplatesIncomplete6.ts +++ b/tests/cases/fourslash/signatureHelpTaggedTemplatesIncomplete6.ts @@ -6,7 +6,7 @@ //// f ` ${ 123 } ${/*1*/ } ` verify.signatureHelp({ - marker: test.markerNames(), + marker: test.markers(), text: "f(templateStrings: any, x: any, y: any, z: any): number", argumentCount: 3, parameterCount: 4, diff --git a/tests/cases/fourslash/signatureHelpTaggedTemplatesIncomplete7.ts b/tests/cases/fourslash/signatureHelpTaggedTemplatesIncomplete7.ts index b375bcc30d2e4..89bee03054f2d 100644 --- a/tests/cases/fourslash/signatureHelpTaggedTemplatesIncomplete7.ts +++ b/tests/cases/fourslash/signatureHelpTaggedTemplatesIncomplete7.ts @@ -9,7 +9,7 @@ //// /*8*/ verify.signatureHelp({ - marker: test.markerNames(), + marker: test.markers(), text: "f(templateStrings: any, x: any, y: any, z: any): number", argumentCount: 3, parameterCount: 4, diff --git a/tests/cases/fourslash/signatureHelpTaggedTemplatesIncomplete8.ts b/tests/cases/fourslash/signatureHelpTaggedTemplatesIncomplete8.ts index 1224f317f014d..184a6ad5dd089 100644 --- a/tests/cases/fourslash/signatureHelpTaggedTemplatesIncomplete8.ts +++ b/tests/cases/fourslash/signatureHelpTaggedTemplatesIncomplete8.ts @@ -6,7 +6,7 @@ //// f `/*1*/\/*2*/`/*3*/ /*4*/ verify.signatureHelp({ - marker: test.markerNames(), + marker: test.markers(), text: "f(templateStrings: any, x: any, y: any, z: any): number", argumentCount: 1, parameterCount: 4, diff --git a/tests/cases/fourslash/signatureHelpTaggedTemplatesIncomplete9.ts b/tests/cases/fourslash/signatureHelpTaggedTemplatesIncomplete9.ts index 5635cf2a41867..07b86e067eb31 100644 --- a/tests/cases/fourslash/signatureHelpTaggedTemplatesIncomplete9.ts +++ b/tests/cases/fourslash/signatureHelpTaggedTemplatesIncomplete9.ts @@ -6,7 +6,7 @@ //// f `/*1*/ \\\/*2*/`/*3*/ /*4*/ verify.signatureHelp({ - marker: test.markerNames(), + marker: test.markers(), text: "f(templateStrings: any, x: any, y: any, z: any): number", argumentCount: 1, parameterCount: 4, diff --git a/tests/cases/fourslash/signatureHelpTaggedTemplatesNested1.ts b/tests/cases/fourslash/signatureHelpTaggedTemplatesNested1.ts index e8c39a633a0d1..38b0f0e3b9347 100644 --- a/tests/cases/fourslash/signatureHelpTaggedTemplatesNested1.ts +++ b/tests/cases/fourslash/signatureHelpTaggedTemplatesNested1.ts @@ -6,7 +6,7 @@ //// f `a ${ g `/*1*/alpha/*2*/ ${/*3*/ 12/*4*/3 /*5*/} beta /*6*/${ /*7*/456 /*8*/} gamma/*9*/` } b ${ g `/*10*/txt/*11*/` } c ${ g `/*12*/aleph /*13*/$/*14*/{ 12/*15*/3 } beit/*16*/` } d`; verify.signatureHelp({ - marker: test.markerNames(), + marker: test.markers(), text: "g(templateStrings: any, x: any, y: any, z: any): string", parameterCount: 4, }); diff --git a/tests/cases/fourslash/signatureHelpTaggedTemplatesNested2.ts b/tests/cases/fourslash/signatureHelpTaggedTemplatesNested2.ts index 32a64402ee36a..bf99fd8e7dfce 100644 --- a/tests/cases/fourslash/signatureHelpTaggedTemplatesNested2.ts +++ b/tests/cases/fourslash/signatureHelpTaggedTemplatesNested2.ts @@ -6,7 +6,7 @@ //// f `/*1*/a $/*2*/{ /*3*/g /*4*/`alpha ${ 123 } beta ${ 456 } gamma`/*5*/ }/*6*/ b $/*7*/{ /*8*/g /*9*/`txt`/*10*/ } /*11*/c ${ /*12*/g /*13*/`aleph ${ 123 } beit`/*14*/ } d/*15*/`; verify.signatureHelp({ - marker: test.markerNames(), + marker: test.markers(), text: "f(templateStrings: any, x: any, y: any, z: any): number", parameterCount: 4, }); diff --git a/tests/cases/fourslash/signatureHelpTaggedTemplatesWithOverloadedTags1.ts b/tests/cases/fourslash/signatureHelpTaggedTemplatesWithOverloadedTags1.ts index 7d119a4d3e8e3..ca38f83a778e7 100644 --- a/tests/cases/fourslash/signatureHelpTaggedTemplatesWithOverloadedTags1.ts +++ b/tests/cases/fourslash/signatureHelpTaggedTemplatesWithOverloadedTags1.ts @@ -8,7 +8,7 @@ //// f `/*1*/ /*2*/$/*3*/{ verify.signatureHelp({ - marker: test.markerNames(), + marker: test.markers(), overloadsCount: 3, text: "f(templateStrings: string[], p1_o1: string): number", argumentCount: 2, diff --git a/tests/cases/fourslash/signatureHelpTaggedTemplatesWithOverloadedTags2.ts b/tests/cases/fourslash/signatureHelpTaggedTemplatesWithOverloadedTags2.ts index 9bd062cf62f3f..268a811dd2f16 100644 --- a/tests/cases/fourslash/signatureHelpTaggedTemplatesWithOverloadedTags2.ts +++ b/tests/cases/fourslash/signatureHelpTaggedTemplatesWithOverloadedTags2.ts @@ -8,7 +8,7 @@ //// f `${/*1*/ /*2*/ /*3*/ verify.signatureHelp({ - marker: test.markerNames(), + marker: test.markers(), overloadsCount: 3, text: "f(templateStrings: string[], p1_o1: string): number", argumentCount: 2, diff --git a/tests/cases/fourslash/signatureHelpTaggedTemplatesWithOverloadedTags3.ts b/tests/cases/fourslash/signatureHelpTaggedTemplatesWithOverloadedTags3.ts index 3a76cbc1adad5..98936bfcc562d 100644 --- a/tests/cases/fourslash/signatureHelpTaggedTemplatesWithOverloadedTags3.ts +++ b/tests/cases/fourslash/signatureHelpTaggedTemplatesWithOverloadedTags3.ts @@ -8,7 +8,7 @@ //// f `${/*1*/ "s/*2*/tring" /*3*/ } ${ verify.signatureHelp({ - marker: test.markerNames(), + marker: test.markers(), overloadsCount: 3, text: "f(templateStrings: TemplateStringsArray, p1_o3: string, p2_o3: boolean, p3_o3: number): boolean", argumentCount: 3, diff --git a/tests/cases/fourslash/signatureHelpTaggedTemplatesWithOverloadedTags4.ts b/tests/cases/fourslash/signatureHelpTaggedTemplatesWithOverloadedTags4.ts index fbf66ddd58e9b..3294dc1da50eb 100644 --- a/tests/cases/fourslash/signatureHelpTaggedTemplatesWithOverloadedTags4.ts +++ b/tests/cases/fourslash/signatureHelpTaggedTemplatesWithOverloadedTags4.ts @@ -8,7 +8,7 @@ //// f `${/*1*/ 123.456/*2*/ /*3*/ } ${ verify.signatureHelp({ - marker: test.markerNames(), + marker: test.markers(), overloadsCount: 3, text: "f(templateStrings: string[], p1_o2: number, p2_o2: number, p3_o2: number): string", parameterCount: 4, diff --git a/tests/cases/fourslash/signatureHelpTaggedTemplatesWithOverloadedTags5.ts b/tests/cases/fourslash/signatureHelpTaggedTemplatesWithOverloadedTags5.ts index dc4dc4db7ae3e..7dc7be257cc5b 100644 --- a/tests/cases/fourslash/signatureHelpTaggedTemplatesWithOverloadedTags5.ts +++ b/tests/cases/fourslash/signatureHelpTaggedTemplatesWithOverloadedTags5.ts @@ -8,7 +8,7 @@ //// f `${ } ${/*1*/ /*2*/ /*3*/ verify.signatureHelp({ - marker: test.markerNames(), + marker: test.markers(), overloadsCount: 3, text: "f(templateStrings: string[], p1_o2: number, p2_o2: number, p3_o2: number): string", argumentCount: 3, diff --git a/tests/cases/fourslash/signatureHelpTaggedTemplatesWithOverloadedTags6.ts b/tests/cases/fourslash/signatureHelpTaggedTemplatesWithOverloadedTags6.ts index e012ec63665ad..2b2c9c5f22142 100644 --- a/tests/cases/fourslash/signatureHelpTaggedTemplatesWithOverloadedTags6.ts +++ b/tests/cases/fourslash/signatureHelpTaggedTemplatesWithOverloadedTags6.ts @@ -8,7 +8,7 @@ //// f `${ } ${/*1*/ /*2*/ /*3*/} verify.signatureHelp({ - marker: test.markerNames(), + marker: test.markers(), overloadsCount: 3, text: "f(templateStrings: string[], p1_o2: number, p2_o2: number, p3_o2: number): string", argumentCount: 3, diff --git a/tests/cases/fourslash/signatureHelpTaggedTemplatesWithOverloadedTags7.ts b/tests/cases/fourslash/signatureHelpTaggedTemplatesWithOverloadedTags7.ts index f61b0921ebf69..8e77f60b5c018 100644 --- a/tests/cases/fourslash/signatureHelpTaggedTemplatesWithOverloadedTags7.ts +++ b/tests/cases/fourslash/signatureHelpTaggedTemplatesWithOverloadedTags7.ts @@ -8,7 +8,7 @@ //// f `${ } ${/*1*/ fa/*2*/lse /*3*/} verify.signatureHelp({ - marker: test.markerNames(), + marker: test.markers(), overloadsCount: 3, text: "f(templateStrings: TemplateStringsArray, p1_o3: string, p2_o3: boolean, p3_o3: number): boolean", argumentCount: 3, diff --git a/tests/cases/fourslash/signatureHelpTaggedTemplatesWithOverloadedTags8.ts b/tests/cases/fourslash/signatureHelpTaggedTemplatesWithOverloadedTags8.ts index 58ad3426f786d..258067573de97 100644 --- a/tests/cases/fourslash/signatureHelpTaggedTemplatesWithOverloadedTags8.ts +++ b/tests/cases/fourslash/signatureHelpTaggedTemplatesWithOverloadedTags8.ts @@ -8,7 +8,7 @@ //// f `${ undefined } ${ undefined } ${/*1*/ 10/*2*/./*3*/01 /*4*/} ` verify.signatureHelp({ - marker: test.markerNames(), + marker: test.markers(), overloadsCount: 3, text: "f(templateStrings: string[], p1_o2: number, p2_o2: number, p3_o2: number): string", argumentCount: 4, diff --git a/tests/cases/fourslash/signatureHelpTaggedTemplatesWithOverloadedTags9.ts b/tests/cases/fourslash/signatureHelpTaggedTemplatesWithOverloadedTags9.ts index daf0a55965e38..7fbaf5ecb5215 100644 --- a/tests/cases/fourslash/signatureHelpTaggedTemplatesWithOverloadedTags9.ts +++ b/tests/cases/fourslash/signatureHelpTaggedTemplatesWithOverloadedTags9.ts @@ -8,7 +8,7 @@ //// f `${/*1*/ /*2*/ /*3*/} ${ verify.signatureHelp({ - marker: test.markerNames(), + marker: test.markers(), overloadsCount: 3, text: "f(templateStrings: string[], p1_o2: number, p2_o2: number, p3_o2: number): string", argumentCount: 3, diff --git a/tests/cases/fourslash/stringLiteralCompletionsForStringEnumContextualType.ts b/tests/cases/fourslash/stringLiteralCompletionsForStringEnumContextualType.ts index 664bfbac36995..4c5228c101757 100644 --- a/tests/cases/fourslash/stringLiteralCompletionsForStringEnumContextualType.ts +++ b/tests/cases/fourslash/stringLiteralCompletionsForStringEnumContextualType.ts @@ -5,5 +5,4 @@ ////} ////const e: E = "/**/"; -goTo.marker(""); -verify.completionListIsEmpty(); +verify.completions({ marker: "", exact: [] }); diff --git a/tests/cases/fourslash/thisPredicateFunctionCompletions01.ts b/tests/cases/fourslash/thisPredicateFunctionCompletions01.ts index 8c9abb8541846..de869dcd8d589 100644 --- a/tests/cases/fourslash/thisPredicateFunctionCompletions01.ts +++ b/tests/cases/fourslash/thisPredicateFunctionCompletions01.ts @@ -40,13 +40,11 @@ //// obj./*5*/; //// } -goTo.marker("1"); -verify.completionListContains("content"); -goTo.marker("2"); -verify.completionListContains("host"); -goTo.marker("3"); -verify.completionListContains("children"); -goTo.marker("4"); -verify.completionListContains("host"); -goTo.marker("5"); -verify.completionListContains("host"); \ No newline at end of file +const common: ReadonlyArray = ["isFile", "isDirectory", "isNetworked", "path"]; +verify.completions( + { marker: "1", exact: ["content", ...common] }, + { marker: "2", exact: ["host", "content", ...common] }, + { marker: "3", exact: ["children", ...common] }, + { marker: "4", exact: ["host", "children", ...common] }, + { marker: "5", exact: ["host", ...common] }, +); diff --git a/tests/cases/fourslash/thisPredicateFunctionCompletions02.ts b/tests/cases/fourslash/thisPredicateFunctionCompletions02.ts index e2e311ea649ce..d83c43e2cf9ab 100644 --- a/tests/cases/fourslash/thisPredicateFunctionCompletions02.ts +++ b/tests/cases/fourslash/thisPredicateFunctionCompletions02.ts @@ -31,13 +31,8 @@ //// } //// } -goTo.marker("1"); -verify.completionListContains("extraContents"); -goTo.marker("2"); -verify.completionListContains("broken"); -goTo.marker("3"); -verify.completionListContains("extraContents"); -goTo.marker("4"); -verify.completionListContains("spoiled"); -goTo.marker("5"); -verify.completionListContains("extraContents"); \ No newline at end of file +verify.completions( + { marker: ["1", "3", "5"], exact: ["contents", "isSundries", "isSupplies", "isPackedTight", "extraContents"] }, + { marker: "2", exact: "broken" }, + { marker: "4", exact: "spoiled" }, +); diff --git a/tests/cases/fourslash/thisPredicateFunctionCompletions03.ts b/tests/cases/fourslash/thisPredicateFunctionCompletions03.ts index 4985a1ca5613f..8c395bdb8012b 100644 --- a/tests/cases/fourslash/thisPredicateFunctionCompletions03.ts +++ b/tests/cases/fourslash/thisPredicateFunctionCompletions03.ts @@ -44,13 +44,7 @@ //// } //// let checked/*14*/LeaderStatus = isLeader/*15*/Guard(a); - -goTo.marker("2"); -verify.completionListContains("lead"); -goTo.marker("4"); -verify.completionListContains("follow"); - -goTo.marker("6"); -verify.completionListContains("lead"); -goTo.marker("8"); -verify.completionListContains("follow"); +verify.completions( + { marker: ["2", "6"], exact: ["lead", "isLeader", "isFollower"] }, + { marker: ["4", "8"], exact: ["follow", "isLeader", "isFollower"] }, +); diff --git a/tests/cases/fourslash/tripleSlashRefPathCompletionAbsolutePaths.ts b/tests/cases/fourslash/tripleSlashRefPathCompletionAbsolutePaths.ts index 99fffd7a7d65a..3bf1ce1312541 100644 --- a/tests/cases/fourslash/tripleSlashRefPathCompletionAbsolutePaths.ts +++ b/tests/cases/fourslash/tripleSlashRefPathCompletionAbsolutePaths.ts @@ -26,18 +26,7 @@ // @Filename: e2.js //// /*e2*/ -goTo.marker("0"); -verify.completionListContains("fourslash"); -verify.not.completionListItemsCountIsGreaterThan(1); - -goTo.marker("1"); -verify.completionListContains("fourslash"); -verify.not.completionListItemsCountIsGreaterThan(1); - -goTo.marker("2"); -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 +verify.completions( + { marker: ["0", "1"], exact: "fourslash", isNewIdentifierLocation: true }, + { marker: "2", exact: ["e1.ts", "f1.ts", "f2.tsx", "folder", "tests"], isNewIdentifierLocation: true }, +); diff --git a/tests/cases/fourslash/tripleSlashRefPathCompletionBackandForwardSlash.ts b/tests/cases/fourslash/tripleSlashRefPathCompletionBackandForwardSlash.ts index e25521ed81216..81b19359f262f 100644 --- a/tests/cases/fourslash/tripleSlashRefPathCompletionBackandForwardSlash.ts +++ b/tests/cases/fourslash/tripleSlashRefPathCompletionBackandForwardSlash.ts @@ -54,10 +54,19 @@ testBlock(12, 'h.ts', "d3"); testBlock(16, 'h.ts', "d3"); testBlock(20, 'h.ts', "d3"); testBlock(24, 'h.ts', "d3"); -verify.completionsAt("28", ["g.ts", "d2"], { isNewIdentifierLocation: true }); +verify.completions({ marker: "28", exact: ["g.ts", "d2"], isNewIdentifierLocation: true }); function testBlock(offset: number, fileName: string, dir: string) { const names = [fileName, dir]; - verify.completionsAt([offset, offset + 1, offset + 2].map(String), names, { isNewIdentifierLocation: true }); - verify.completionsAt(String(offset + 3), names.map(name => ({ name, replacementSpan: test.ranges()[offset / 4] })), { isNewIdentifierLocation: true }); + verify.completions( + { + marker: [offset, offset + 1, offset + 2].map(String), + exact: names, + isNewIdentifierLocation: true, + }, + { + marker: String(offset + 3), + exact: names.map(name => ({ name, replacementSpan: test.ranges()[offset / 4] })), + isNewIdentifierLocation: true, + }); } diff --git a/tests/cases/fourslash/tripleSlashRefPathCompletionContext.ts b/tests/cases/fourslash/tripleSlashRefPathCompletionContext.ts index ccab45a2b2174..2204afc61fc7f 100644 --- a/tests/cases/fourslash/tripleSlashRefPathCompletionContext.ts +++ b/tests/cases/fourslash/tripleSlashRefPathCompletionContext.ts @@ -9,13 +9,7 @@ //// /// /*7*/ -for(let m = 0; m < 8; ++m) { - goTo.marker("" + m); - verify.not.completionListItemsCountIsGreaterThan(0); -} - -for(let m of ["8", "9"]) { - goTo.marker(m); - verify.completionListContains("f.ts"); - verify.not.completionListItemsCountIsGreaterThan(1); -} \ No newline at end of file +verify.completions( + { marker: ["0", "1", "2", "3", "4", "5", "6", "7"], exact: undefined, isNewIdentifierLocation: true }, + { marker: ["8", "9"], exact: "f.ts", isNewIdentifierLocation: true }, +); diff --git a/tests/cases/fourslash/tripleSlashRefPathCompletionExtensionsAllowJSFalse.ts b/tests/cases/fourslash/tripleSlashRefPathCompletionExtensionsAllowJSFalse.ts index 95a4cd01b604e..198a46cdeb930 100644 --- a/tests/cases/fourslash/tripleSlashRefPathCompletionExtensionsAllowJSFalse.ts +++ b/tests/cases/fourslash/tripleSlashRefPathCompletionExtensionsAllowJSFalse.ts @@ -8,24 +8,22 @@ //// /// ({ name, replacementSpan: test.ranges()[idx] })), { isNewIdentifierLocation: true }); -} +const ranges = test.ranges(); +verify.completions( + { + marker: ["0", "1", "2", "3", "7"], + exact: names, + isNewIdentifierLocation: true, + }, + ...markersWithReplacementSpan.map((marker, i): FourSlashInterface.CompletionsOptions => ({ + marker: String(marker), + exact: names.map(name => ({ name, replacementSpan: ranges[i] })), + isNewIdentifierLocation: true, + })), +); diff --git a/tests/cases/fourslash/tripleSlashRefPathCompletionRelativePaths.ts b/tests/cases/fourslash/tripleSlashRefPathCompletionRelativePaths.ts index a67310d0349b5..2922453c89d89 100644 --- a/tests/cases/fourslash/tripleSlashRefPathCompletionRelativePaths.ts +++ b/tests/cases/fourslash/tripleSlashRefPathCompletionRelativePaths.ts @@ -32,15 +32,17 @@ //// /// ({ name, replacementSpan: test.ranges()[0] })), { isNewIdentifierLocation: true }); -verify.completionsAt("3", ["h.ts", "d3"].map(name => ({ name, replacementSpan: test.ranges()[1] })), { isNewIdentifierLocation: true }); - -// parent dir completions -verify.completionsAt(["5", "6"], ["g.ts", "d2"], { isNewIdentifierLocation: true }); -verify.completionsAt("7", ["f.ts", "d1"], { isNewIdentifierLocation: true }); - -// child dir completions -verify.completionsAt(["8", "9"], ["i.ts", "d4"], { isNewIdentifierLocation: true }); -verify.completionsAt(["10", "11"], ["j.ts"], { isNewIdentifierLocation: true }); +verify.completions( + // working dir completions + { marker: ["0", "1", "4"], exact: ["h.ts", "d3"], isNewIdentifierLocation: true }, + { marker: "2", exact: ["h.ts", "d3"].map(name => ({ name, replacementSpan: test.ranges()[0] })), isNewIdentifierLocation: true }, + { marker: "3", exact: ["h.ts", "d3"].map(name => ({ name, replacementSpan: test.ranges()[1] })), isNewIdentifierLocation: true }, + + // parent dir completions + { marker: ["5", "6"], exact: ["g.ts", "d2"], isNewIdentifierLocation: true }, + { marker: "7", exact: ["f.ts", "d1"], isNewIdentifierLocation: true }, + + // child dir completions + { marker: ["8", "9"], exact: ["i.ts", "d4"], isNewIdentifierLocation: true }, + { marker: ["10", "11"], exact: "j.ts", isNewIdentifierLocation: true }, +); diff --git a/tests/cases/fourslash/tripleSlashRefPathCompletionRootdirs.ts b/tests/cases/fourslash/tripleSlashRefPathCompletionRootdirs.ts index 2eb58646675fc..9e82be11f216c 100644 --- a/tests/cases/fourslash/tripleSlashRefPathCompletionRootdirs.ts +++ b/tests/cases/fourslash/tripleSlashRefPathCompletionRootdirs.ts @@ -35,9 +35,4 @@ // @Filename: e2.js //// /*e2*/ - -goTo.marker("0"); - -verify.completionListContains("module0.ts"); - -verify.not.completionListItemsCountIsGreaterThan(1); \ No newline at end of file +verify.completions({ marker: "0", exact: "module0.ts", isNewIdentifierLocation: true }); diff --git a/tests/cases/fourslash/tsxCompletion1.ts b/tests/cases/fourslash/tsxCompletion1.ts index f638b0b6e4fa8..12d62333d8401 100644 --- a/tests/cases/fourslash/tsxCompletion1.ts +++ b/tests/cases/fourslash/tsxCompletion1.ts @@ -9,6 +9,4 @@ //// } //// var x =
; -goTo.marker(); -verify.completionListContains('ONE'); -verify.completionListContains('TWO'); +verify.completions({ marker: "", exact: ["ONE", "TWO"] }); diff --git a/tests/cases/fourslash/tsxCompletion11.ts b/tests/cases/fourslash/tsxCompletion11.ts index 5d9c869a9b6d5..a98b6132850d1 100644 --- a/tests/cases/fourslash/tsxCompletion11.ts +++ b/tests/cases/fourslash/tsxCompletion11.ts @@ -10,5 +10,4 @@ //// import {Thing} from './exporter'; //// var x1 =
; //// let opt4 = ; -goTo.marker("1"); -verify.completionListContains('propx'); -verify.completionListContains('propString'); -verify.completionListContains('optional'); - -goTo.marker("2"); -verify.completionListContains('propx'); -verify.completionListContains('propString'); - -goTo.marker("3"); -verify.completionListContains("propString") -verify.completionListContains("optional") -verify.not.completionListContains("propx") - -goTo.marker("4"); -verify.completionListContains("propString"); -verify.not.completionListContains("propx"); -verify.not.completionListContains("optional"); - -goTo.marker("5"); -verify.completionListContains('propx'); -verify.completionListContains('propString'); -verify.completionListContains('optional'); \ No newline at end of file +verify.completions( + { marker: ["1", "2", "5"], exact: ["propx", "propString", "optional"] }, + { marker: "3", exact: ["propString", "optional"] }, + { marker: "4", exact: "propString" }, +); diff --git a/tests/cases/fourslash/tsxCompletion13.ts b/tests/cases/fourslash/tsxCompletion13.ts index 9a79de927d2bb..b1ac2c7af7a2a 100644 --- a/tests/cases/fourslash/tsxCompletion13.ts +++ b/tests/cases/fourslash/tsxCompletion13.ts @@ -30,33 +30,8 @@ //// let opt = ; //// let opt = ; -goTo.marker("1"); -verify.completionListContains('children'); -verify.completionListContains('className'); -verify.completionListContains('onClick'); -verify.completionListContains('goTo'); - -goTo.marker("2"); -verify.completionListContains('className'); -verify.completionListContains('onClick'); -verify.completionListContains('goTo'); - -goTo.marker("3"); -verify.completionListContains('children'); -verify.completionListContains('className'); -verify.not.completionListContains('goTo'); - -goTo.marker("4"); -verify.completionListContains('children'); -verify.completionListContains('className'); - -goTo.marker("5"); -verify.completionListContains('children'); -verify.completionListContains('className'); -verify.not.completionListContains('onClick'); - -goTo.marker("6"); -verify.completionListContains('children'); -verify.completionListContains('className'); -verify.completionListContains('onClick'); -verify.completionListContains('goTo'); \ No newline at end of file +verify.completions( + { marker: ["1", "6"], exact: ["onClick", "children", "className", "goTo"] }, + { marker: "2", exact: ["onClick", "className", "goTo"] }, + { marker: ["3", "4", "5"], exact: ["children", "className"] }, +); diff --git a/tests/cases/fourslash/tsxCompletion2.ts b/tests/cases/fourslash/tsxCompletion2.ts index d33f910687719..157f8858d35d2 100644 --- a/tests/cases/fourslash/tsxCompletion2.ts +++ b/tests/cases/fourslash/tsxCompletion2.ts @@ -10,6 +10,4 @@ //// class MyComp { props: { ONE: string; TWO: number } } //// var x = ; -goTo.marker(); -verify.completionListContains('ONE'); -verify.completionListContains('TWO'); +verify.completions({ marker: "", exact: ["ONE", "TWO"] }); diff --git a/tests/cases/fourslash/tsxCompletion3.ts b/tests/cases/fourslash/tsxCompletion3.ts index 5ee712f7e967a..08e8be38657d6 100644 --- a/tests/cases/fourslash/tsxCompletion3.ts +++ b/tests/cases/fourslash/tsxCompletion3.ts @@ -9,6 +9,4 @@ //// } ////
; -goTo.marker(); -verify.completionListContains('two'); -verify.not.completionListContains('one'); +verify.completions({ marker: "", exact: "two" }); diff --git a/tests/cases/fourslash/tsxCompletion4.ts b/tests/cases/fourslash/tsxCompletion4.ts index 6a66c4a898ff6..536476d4053ae 100644 --- a/tests/cases/fourslash/tsxCompletion4.ts +++ b/tests/cases/fourslash/tsxCompletion4.ts @@ -10,5 +10,4 @@ //// let bag = { x: 100, y: 200 }; ////
; -goTo.marker(); -verify.completionListContains("ONE"); -verify.completionListContains("TWO"); -verify.not.completionListAllowsNewIdentifier(); \ No newline at end of file +verify.completions({ marker: "", exact: ["ONE", "TWO"] }); diff --git a/tests/cases/fourslash/tsxCompletion6.ts b/tests/cases/fourslash/tsxCompletion6.ts index 5bb01717be792..bdc7823ec925f 100644 --- a/tests/cases/fourslash/tsxCompletion6.ts +++ b/tests/cases/fourslash/tsxCompletion6.ts @@ -9,7 +9,4 @@ //// } //// var x =
; -goTo.marker(); - -verify.completionListContains("TWO"); -verify.not.completionListAllowsNewIdentifier(); +verify.completions({ marker: "", exact: "TWO" }); diff --git a/tests/cases/fourslash/tsxCompletion7.ts b/tests/cases/fourslash/tsxCompletion7.ts index ca489b8e0c422..87638f38e3805 100644 --- a/tests/cases/fourslash/tsxCompletion7.ts +++ b/tests/cases/fourslash/tsxCompletion7.ts @@ -10,8 +10,4 @@ //// let y = { ONE: '' }; //// var x =
; -goTo.marker(); - -verify.completionListContains("ONE"); -verify.completionListContains("TWO"); -verify.not.completionListAllowsNewIdentifier(); +verify.completions({ marker: "", exact: ["ONE", "TWO"] }); diff --git a/tests/cases/fourslash/tsxCompletion9.ts b/tests/cases/fourslash/tsxCompletion9.ts index 12542cc6b5bd2..21d2c43f67658 100644 --- a/tests/cases/fourslash/tsxCompletion9.ts +++ b/tests/cases/fourslash/tsxCompletion9.ts @@ -13,12 +13,9 @@ //// var x4 =
/*10*/
; ////
//// /*end*/ -//// +//// for (var i = 1; i <= 10; i++) { - goTo.marker(i + ''); - verify.completionListIsEmpty(); + verify.completions({ marker: String(i), exact: undefined }); } - -goTo.marker('end'); -verify.not.completionListIsEmpty(); +verify.completions({ marker: "end", includes: "null" }); diff --git a/tests/cases/fourslash/tsxCompletionInFunctionExpressionOfChildrenCallback.ts b/tests/cases/fourslash/tsxCompletionInFunctionExpressionOfChildrenCallback.ts index 911fa41470dc8..b23b7f23c6979 100644 --- a/tests/cases/fourslash/tsxCompletionInFunctionExpressionOfChildrenCallback.ts +++ b/tests/cases/fourslash/tsxCompletionInFunctionExpressionOfChildrenCallback.ts @@ -20,11 +20,10 @@ //// return ( //// //// { user => ( -////

{ user./**/ }

+////

{ user./**/ }

//// )} ////
//// ); //// } -goTo.marker(); -verify.completionListIsEmpty(); \ No newline at end of file +verify.completions({ marker: "", exact: undefined }); diff --git a/tests/cases/fourslash/tsxCompletionInFunctionExpressionOfChildrenCallback1.ts b/tests/cases/fourslash/tsxCompletionInFunctionExpressionOfChildrenCallback1.ts index d849948775e62..6c805e897d0bc 100644 --- a/tests/cases/fourslash/tsxCompletionInFunctionExpressionOfChildrenCallback1.ts +++ b/tests/cases/fourslash/tsxCompletionInFunctionExpressionOfChildrenCallback1.ts @@ -21,11 +21,10 @@ //// return ( //// //// { user => ( -////

{ user./**/ }

+////

{ user./**/ }

//// )} ////
//// ); //// } -goTo.marker(); -verify.completionListContains('Name'); \ No newline at end of file +verify.completions({ marker: "", exact: "Name" }); diff --git a/tests/cases/fourslash/tsxCompletionNonTagLessThan.ts b/tests/cases/fourslash/tsxCompletionNonTagLessThan.ts index 8fb1501eb50d8..b2b6a046e6b01 100644 --- a/tests/cases/fourslash/tsxCompletionNonTagLessThan.ts +++ b/tests/cases/fourslash/tsxCompletionNonTagLessThan.ts @@ -5,12 +5,7 @@ ////[].map -goTo.marker(); -verify.completionListIsEmpty(); \ No newline at end of file +verify.completions({ marker: "", exact: undefined }); diff --git a/tests/cases/fourslash/typeArgCompletion.ts b/tests/cases/fourslash/typeArgCompletion.ts index 19fe006f26afb..a32bab43e931c 100644 --- a/tests/cases/fourslash/typeArgCompletion.ts +++ b/tests/cases/fourslash/typeArgCompletion.ts @@ -8,5 +8,4 @@ ////} ////var x1: I1; -goTo.marker(); -verify.completionListContains("Derived"); +verify.completions({ marker: "", includes: "Derived" }); diff --git a/tests/cases/fourslash/unclosedCommentsInConstructor.ts b/tests/cases/fourslash/unclosedCommentsInConstructor.ts index a81bfb1fbf2aa..ebc532ae44b41 100644 --- a/tests/cases/fourslash/unclosedCommentsInConstructor.ts +++ b/tests/cases/fourslash/unclosedCommentsInConstructor.ts @@ -1,8 +1,7 @@ /// ////class Foo { -//// constructor(/*/**/) { } +//// constructor(/* /**/) { } ////} -goTo.marker(); -// verify.completionListIsEmpty(); // TODO: difference between LS and FourSlash \ No newline at end of file +verify.completions({ marker: "", exact: undefined, isNewIdentifierLocation: true }); diff --git a/tests/cases/fourslash/unclosedStringLiteralErrorRecovery.ts b/tests/cases/fourslash/unclosedStringLiteralErrorRecovery.ts index 88c13954ec07e..5c51d897f4a65 100644 --- a/tests/cases/fourslash/unclosedStringLiteralErrorRecovery.ts +++ b/tests/cases/fourslash/unclosedStringLiteralErrorRecovery.ts @@ -6,6 +6,5 @@ ////var f = new foo(); ////f./**/ -goTo.marker(); // Error recovery for unclosed string literals -verify.completionListContains('x'); +verify.completions({ marker: "", exact: "x" }); diff --git a/tests/cases/fourslash/underscoreTypings01.ts b/tests/cases/fourslash/underscoreTypings01.ts index e75f3ad61cedd..b2c96552dcf31 100644 --- a/tests/cases/fourslash/underscoreTypings01.ts +++ b/tests/cases/fourslash/underscoreTypings01.ts @@ -47,6 +47,4 @@ verify.quickInfos({ 12: "(parameter) x: any" }); -goTo.marker('13'); -verify.completionListContains('length'); -verify.not.completionListContains('toFixed'); \ No newline at end of file +verify.completions({ marker: "13", includes: "length", excludes: "toFixed" });