Skip to content

Commit 3a30279

Browse files
author
Andy Hanson
committed
Rename includeBracketCompletions to includeInsertTextCompletions
1 parent 84f9203 commit 3a30279

File tree

8 files changed

+23
-23
lines changed

8 files changed

+23
-23
lines changed

src/harness/fourslash.ts

+2-2
Original file line numberDiff line numberDiff line change
@@ -1819,7 +1819,7 @@ Actual: ${stringify(fullActual)}`);
18191819
}
18201820
else if (prevChar === " " && /A-Za-z_/.test(ch)) {
18211821
/* Completions */
1822-
this.languageService.getCompletionsAtPosition(this.activeFile.fileName, offset, { includeExternalModuleExports: false, includeBracketCompletions: false });
1822+
this.languageService.getCompletionsAtPosition(this.activeFile.fileName, offset, { includeExternalModuleExports: false, includeInsertTextCompletions: false });
18231823
}
18241824

18251825
if (i % checkCadence === 0) {
@@ -2394,7 +2394,7 @@ Actual: ${stringify(fullActual)}`);
23942394
public applyCodeActionFromCompletion(markerName: string, options: FourSlashInterface.VerifyCompletionActionOptions) {
23952395
this.goToMarker(markerName);
23962396

2397-
const actualCompletion = this.getCompletionListAtCaret({ includeExternalModuleExports: true, includeBracketCompletions: false }).entries.find(e =>
2397+
const actualCompletion = this.getCompletionListAtCaret({ includeExternalModuleExports: true, includeInsertTextCompletions: false }).entries.find(e =>
23982398
e.name === options.name && e.source === options.source);
23992399

24002400
if (!actualCompletion.hasAction) {

src/harness/unittests/tsserverProjectSystem.ts

+6-6
Original file line numberDiff line numberDiff line change
@@ -1284,13 +1284,13 @@ namespace ts.projectSystem {
12841284
service.checkNumberOfProjects({ externalProjects: 1 });
12851285
checkProjectActualFiles(service.externalProjects[0], [f1.path, f2.path, libFile.path]);
12861286

1287-
const completions1 = service.externalProjects[0].getLanguageService().getCompletionsAtPosition(f1.path, 2, { includeExternalModuleExports: false, includeBracketCompletions: false });
1287+
const completions1 = service.externalProjects[0].getLanguageService().getCompletionsAtPosition(f1.path, 2, { includeExternalModuleExports: false, includeInsertTextCompletions: false });
12881288
// should contain completions for string
12891289
assert.isTrue(completions1.entries.some(e => e.name === "charAt"), "should contain 'charAt'");
12901290
assert.isFalse(completions1.entries.some(e => e.name === "toExponential"), "should not contain 'toExponential'");
12911291

12921292
service.closeClientFile(f2.path);
1293-
const completions2 = service.externalProjects[0].getLanguageService().getCompletionsAtPosition(f1.path, 2, { includeExternalModuleExports: false, includeBracketCompletions: false });
1293+
const completions2 = service.externalProjects[0].getLanguageService().getCompletionsAtPosition(f1.path, 2, { includeExternalModuleExports: false, includeInsertTextCompletions: false });
12941294
// should contain completions for string
12951295
assert.isFalse(completions2.entries.some(e => e.name === "charAt"), "should not contain 'charAt'");
12961296
assert.isTrue(completions2.entries.some(e => e.name === "toExponential"), "should contain 'toExponential'");
@@ -1316,11 +1316,11 @@ namespace ts.projectSystem {
13161316
service.checkNumberOfProjects({ externalProjects: 1 });
13171317
checkProjectActualFiles(service.externalProjects[0], [f1.path, f2.path, libFile.path]);
13181318

1319-
const completions1 = service.externalProjects[0].getLanguageService().getCompletionsAtPosition(f1.path, 0, { includeExternalModuleExports: false, includeBracketCompletions: false });
1319+
const completions1 = service.externalProjects[0].getLanguageService().getCompletionsAtPosition(f1.path, 0, { includeExternalModuleExports: false, includeInsertTextCompletions: false });
13201320
assert.isTrue(completions1.entries.some(e => e.name === "somelongname"), "should contain 'somelongname'");
13211321

13221322
service.closeClientFile(f2.path);
1323-
const completions2 = service.externalProjects[0].getLanguageService().getCompletionsAtPosition(f1.path, 0, { includeExternalModuleExports: false, includeBracketCompletions: false });
1323+
const completions2 = service.externalProjects[0].getLanguageService().getCompletionsAtPosition(f1.path, 0, { includeExternalModuleExports: false, includeInsertTextCompletions: false });
13241324
assert.isFalse(completions2.entries.some(e => e.name === "somelongname"), "should not contain 'somelongname'");
13251325
const sf2 = service.externalProjects[0].getLanguageService().getProgram().getSourceFile(f2.path);
13261326
assert.equal(sf2.text, "");
@@ -1925,7 +1925,7 @@ namespace ts.projectSystem {
19251925

19261926
// Check identifiers defined in HTML content are available in .ts file
19271927
const project = configuredProjectAt(projectService, 0);
1928-
let completions = project.getLanguageService().getCompletionsAtPosition(file1.path, 1, { includeExternalModuleExports: false, includeBracketCompletions: false });
1928+
let completions = project.getLanguageService().getCompletionsAtPosition(file1.path, 1, { includeExternalModuleExports: false, includeInsertTextCompletions: false });
19291929
assert(completions && completions.entries[0].name === "hello", `expected entry hello to be in completion list`);
19301930

19311931
// Close HTML file
@@ -1939,7 +1939,7 @@ namespace ts.projectSystem {
19391939
checkProjectActualFiles(configuredProjectAt(projectService, 0), [file1.path, file2.path, config.path]);
19401940

19411941
// Check identifiers defined in HTML content are not available in .ts file
1942-
completions = project.getLanguageService().getCompletionsAtPosition(file1.path, 5, { includeExternalModuleExports: false, includeBracketCompletions: false });
1942+
completions = project.getLanguageService().getCompletionsAtPosition(file1.path, 5, { includeExternalModuleExports: false, includeInsertTextCompletions: false });
19431943
assert(completions && completions.entries[0].name !== "hello", `unexpected hello entry in completion list`);
19441944
});
19451945

src/server/protocol.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -1697,7 +1697,7 @@ namespace ts.server.protocol {
16971697
* If enabled, the completion list will include completions with invalid identifier names.
16981698
* For those entries, The `insertText` and `replacementSpan` properties will be set to change from `.x` property access to `["x"]`.
16991699
*/
1700-
includeBracketCompletions: boolean;
1700+
includeInsertTextCompletions: boolean;
17011701
}
17021702

17031703
/**

src/services/completions.ts

+9-9
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,7 @@ namespace ts.Completions {
5252

5353
switch (completionData.kind) {
5454
case CompletionDataKind.Data:
55-
return completionInfoFromData(sourceFile, typeChecker, compilerOptions, log, completionData, options.includeBracketCompletions);
55+
return completionInfoFromData(sourceFile, typeChecker, compilerOptions, log, completionData, options.includeInsertTextCompletions);
5656
case CompletionDataKind.JsDocTagName:
5757
// If the current position is a jsDoc tag name, only tag names should be provided for completion
5858
return jsdocCompletionInfo(JsDoc.getJSDocTagNameCompletions());
@@ -70,7 +70,7 @@ namespace ts.Completions {
7070
return { isGlobalCompletion: false, isMemberCompletion: false, isNewIdentifierLocation: false, entries };
7171
}
7272

73-
function completionInfoFromData(sourceFile: SourceFile, typeChecker: TypeChecker, compilerOptions: CompilerOptions, log: Log, completionData: CompletionData, includeBracketCompletions: boolean): CompletionInfo {
73+
function completionInfoFromData(sourceFile: SourceFile, typeChecker: TypeChecker, compilerOptions: CompilerOptions, log: Log, completionData: CompletionData, includeInsertTextCompletions: boolean): CompletionInfo {
7474
const { symbols, completionKind, isNewIdentifierLocation, location, propertyAccessToConvert, keywordFilters, symbolToOriginInfoMap, recommendedCompletion } = completionData;
7575

7676
if (sourceFile.languageVariant === LanguageVariant.JSX && location && location.parent && isJsxClosingElement(location.parent)) {
@@ -91,15 +91,15 @@ namespace ts.Completions {
9191
const entries: CompletionEntry[] = [];
9292

9393
if (isSourceFileJavaScript(sourceFile)) {
94-
const uniqueNames = getCompletionEntriesFromSymbols(symbols, entries, location, sourceFile, typeChecker, compilerOptions.target, log, completionKind, includeBracketCompletions, propertyAccessToConvert, recommendedCompletion, symbolToOriginInfoMap);
94+
const uniqueNames = getCompletionEntriesFromSymbols(symbols, entries, location, sourceFile, typeChecker, compilerOptions.target, log, completionKind, includeInsertTextCompletions, propertyAccessToConvert, recommendedCompletion, symbolToOriginInfoMap);
9595
getJavaScriptCompletionEntries(sourceFile, location.pos, uniqueNames, compilerOptions.target, entries);
9696
}
9797
else {
9898
if ((!symbols || symbols.length === 0) && keywordFilters === KeywordCompletionFilters.None) {
9999
return undefined;
100100
}
101101

102-
getCompletionEntriesFromSymbols(symbols, entries, location, sourceFile, typeChecker, compilerOptions.target, log, completionKind, includeBracketCompletions, propertyAccessToConvert, recommendedCompletion, symbolToOriginInfoMap);
102+
getCompletionEntriesFromSymbols(symbols, entries, location, sourceFile, typeChecker, compilerOptions.target, log, completionKind, includeInsertTextCompletions, propertyAccessToConvert, recommendedCompletion, symbolToOriginInfoMap);
103103
}
104104

105105
// TODO add filter for keyword based on type/value/namespace and also location
@@ -159,15 +159,15 @@ namespace ts.Completions {
159159
origin: SymbolOriginInfo | undefined,
160160
recommendedCompletion: Symbol | undefined,
161161
propertyAccessToConvert: PropertyAccessExpression | undefined,
162-
includeBracketCompletions: boolean,
162+
includeInsertTextCompletions: boolean,
163163
): CompletionEntry | undefined {
164164
const info = getCompletionEntryDisplayNameForSymbol(symbol, target, origin, kind);
165165
if (!info) {
166166
return undefined;
167167
}
168168
const { name, needsConvertPropertyAccess } = info;
169169
Debug.assert(!(needsConvertPropertyAccess && !propertyAccessToConvert));
170-
if (needsConvertPropertyAccess && !includeBracketCompletions) {
170+
if (needsConvertPropertyAccess && !includeInsertTextCompletions) {
171171
return undefined;
172172
}
173173

@@ -218,7 +218,7 @@ namespace ts.Completions {
218218
target: ScriptTarget,
219219
log: Log,
220220
kind: CompletionKind,
221-
includeBracketCompletions?: boolean,
221+
includeInsertTextCompletions?: boolean,
222222
propertyAccessToConvert?: PropertyAccessExpression | undefined,
223223
recommendedCompletion?: Symbol,
224224
symbolToOriginInfoMap?: SymbolOriginInfoMap,
@@ -232,7 +232,7 @@ namespace ts.Completions {
232232
if (symbols) {
233233
for (const symbol of symbols) {
234234
const origin = symbolToOriginInfoMap ? symbolToOriginInfoMap[getSymbolId(symbol)] : undefined;
235-
const entry = createCompletionEntry(symbol, location, sourceFile, typeChecker, target, kind, origin, recommendedCompletion, propertyAccessToConvert, includeBracketCompletions);
235+
const entry = createCompletionEntry(symbol, location, sourceFile, typeChecker, target, kind, origin, recommendedCompletion, propertyAccessToConvert, includeInsertTextCompletions);
236236
if (!entry) {
237237
continue;
238238
}
@@ -464,7 +464,7 @@ namespace ts.Completions {
464464
{ name, source }: CompletionEntryIdentifier,
465465
allSourceFiles: ReadonlyArray<SourceFile>,
466466
): SymbolCompletion | { type: "request", request: Request } | { type: "none" } {
467-
const completionData = getCompletionData(typeChecker, log, sourceFile, position, allSourceFiles, { includeExternalModuleExports: true, includeBracketCompletions: true }, compilerOptions.target);
467+
const completionData = getCompletionData(typeChecker, log, sourceFile, position, allSourceFiles, { includeExternalModuleExports: true, includeInsertTextCompletions: true }, compilerOptions.target);
468468
if (!completionData) {
469469
return { type: "none" };
470470
}

src/services/services.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -1432,7 +1432,7 @@ namespace ts {
14321432
return [...program.getOptionsDiagnostics(cancellationToken), ...program.getGlobalDiagnostics(cancellationToken)];
14331433
}
14341434

1435-
function getCompletionsAtPosition(fileName: string, position: number, options: GetCompletionsAtPositionOptions = { includeExternalModuleExports: false, includeBracketCompletions: false }): CompletionInfo {
1435+
function getCompletionsAtPosition(fileName: string, position: number, options: GetCompletionsAtPositionOptions = { includeExternalModuleExports: false, includeInsertTextCompletions: false }): CompletionInfo {
14361436
synchronizeHostData();
14371437
return Completions.getCompletionsAtPosition(
14381438
host,

src/services/types.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -333,7 +333,7 @@ namespace ts {
333333

334334
export interface GetCompletionsAtPositionOptions {
335335
includeExternalModuleExports: boolean;
336-
includeBracketCompletions: boolean;
336+
includeInsertTextCompletions: boolean;
337337
}
338338

339339
export interface ApplyCodeActionCommandResult {

tests/baselines/reference/api/tsserverlibrary.d.ts

+2-2
Original file line numberDiff line numberDiff line change
@@ -3997,7 +3997,7 @@ declare namespace ts {
39973997
}
39983998
interface GetCompletionsAtPositionOptions {
39993999
includeExternalModuleExports: boolean;
4000-
includeBracketCompletions: boolean;
4000+
includeInsertTextCompletions: boolean;
40014001
}
40024002
interface ApplyCodeActionCommandResult {
40034003
successMessage: string;
@@ -6107,7 +6107,7 @@ declare namespace ts.server.protocol {
61076107
* If enabled, the completion list will include completions with invalid identifier names.
61086108
* For those entries, The `insertText` and `replacementSpan` properties will be set to change from `.x` property access to `["x"]`.
61096109
*/
6110-
includeBracketCompletions: boolean;
6110+
includeInsertTextCompletions: boolean;
61116111
}
61126112
/**
61136113
* Completions request; value of command field is "completions".

tests/baselines/reference/api/typescript.d.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -3997,7 +3997,7 @@ declare namespace ts {
39973997
}
39983998
interface GetCompletionsAtPositionOptions {
39993999
includeExternalModuleExports: boolean;
4000-
includeBracketCompletions: boolean;
4000+
includeInsertTextCompletions: boolean;
40014001
}
40024002
interface ApplyCodeActionCommandResult {
40034003
successMessage: string;

0 commit comments

Comments
 (0)