Skip to content

🤖 User test baselines have changed for feature/36048 #2

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
35 changes: 24 additions & 11 deletions src/services/completions.ts
Original file line number Diff line number Diff line change
Expand Up @@ -272,7 +272,7 @@ namespace ts.Completions {
}

for (const literal of literals) {
entries.push(createCompletionEntryForLiteral(literal));
entries.push(createCompletionEntryForLiteral(literal, preferences));
}

return { isGlobalCompletion: isInSnippetScope, isMemberCompletion: isMemberCompletionKind(completionKind), isNewIdentifierLocation, entries };
Expand Down Expand Up @@ -317,10 +317,13 @@ namespace ts.Completions {
});
}

const completionNameForLiteral = (literal: string | number | PseudoBigInt) =>
typeof literal === "object" ? pseudoBigIntToString(literal) + "n" : JSON.stringify(literal);
function createCompletionEntryForLiteral(literal: string | number | PseudoBigInt): CompletionEntry {
return { name: completionNameForLiteral(literal), kind: ScriptElementKind.string, kindModifiers: ScriptElementKindModifier.none, sortText: SortText.LocationPriority };
function completionNameForLiteral(literal: string | number | PseudoBigInt, preferences: UserPreferences): string {
return typeof literal === "object" ? pseudoBigIntToString(literal) + "n" :
isString(literal) ? quote(literal, preferences) : JSON.stringify(literal);
}

function createCompletionEntryForLiteral(literal: string | number | PseudoBigInt, preferences: UserPreferences): CompletionEntry {
return { name: completionNameForLiteral(literal, preferences), kind: ScriptElementKind.string, kindModifiers: ScriptElementKindModifier.none, sortText: SortText.LocationPriority };
}

function createCompletionEntry(
Expand All @@ -344,13 +347,13 @@ namespace ts.Completions {
const useBraces = origin && originIsSymbolMember(origin) || needsConvertPropertyAccess;
if (origin && originIsThisType(origin)) {
insertText = needsConvertPropertyAccess
? `this${insertQuestionDot ? "?." : ""}[${quote(name, preferences)}]`
? `this${insertQuestionDot ? "?." : ""}[${quotePropertyName(name, preferences)}]`
: `this${insertQuestionDot ? "?." : "."}${name}`;
}
// We should only have needsConvertPropertyAccess if there's a property access to convert. But see #21790.
// Somehow there was a global with a non-identifier name. Hopefully someone will complain about getting a "foo bar" global completion and provide a repro.
else if ((useBraces || insertQuestionDot) && propertyAccessToConvert) {
insertText = useBraces ? needsConvertPropertyAccess ? `[${quote(name, preferences)}]` : `[${name}]` : name;
insertText = useBraces ? needsConvertPropertyAccess ? `[${quotePropertyName(name, preferences)}]` : `[${name}]` : name;
if (insertQuestionDot || propertyAccessToConvert.questionDotToken) {
insertText = `?.${insertText}`;
}
Expand Down Expand Up @@ -410,6 +413,14 @@ namespace ts.Completions {
};
}

function quotePropertyName(name: string, preferences: UserPreferences): string {
if (/^\d+$/.test(name)) {
return name;
}

return quote(name, preferences);
}

function isRecommendedCompletionMatch(localSymbol: Symbol, recommendedCompletion: Symbol | undefined, checker: TypeChecker): boolean {
return localSymbol === recommendedCompletion ||
!!(localSymbol.flags & SymbolFlags.ExportValue) && checker.getExportSymbolOfSymbol(localSymbol) === recommendedCompletion;
Expand Down Expand Up @@ -531,6 +542,7 @@ namespace ts.Completions {
position: number,
entryId: CompletionEntryIdentifier,
host: LanguageServiceHost,
preferences: UserPreferences,
): SymbolCompletion | { type: "request", request: Request } | { type: "literal", literal: string | number | PseudoBigInt } | { type: "none" } {
const compilerOptions = program.getCompilerOptions();
const completionData = getCompletionData(program, log, sourceFile, isUncheckedFile(sourceFile, compilerOptions), position, { includeCompletionsForModuleExports: true, includeCompletionsWithInsertText: true }, entryId, host);
Expand All @@ -543,7 +555,7 @@ namespace ts.Completions {

const { symbols, literals, location, completionKind, symbolToOriginInfoMap, previousToken, isJsxInitializer, isTypeOnlyLocation } = completionData;

const literal = find(literals, l => completionNameForLiteral(l) === entryId.name);
const literal = find(literals, l => completionNameForLiteral(l, preferences) === entryId.name);
if (literal !== undefined) return { type: "literal", literal };

// Find the symbol with the matching entry name.
Expand Down Expand Up @@ -585,7 +597,7 @@ namespace ts.Completions {
}

// Compute all the completion symbols again.
const symbolCompletion = getSymbolCompletionFromEntryId(program, log, sourceFile, position, entryId, host);
const symbolCompletion = getSymbolCompletionFromEntryId(program, log, sourceFile, position, entryId, host, preferences);
switch (symbolCompletion.type) {
case "request": {
const { request } = symbolCompletion;
Expand All @@ -607,7 +619,7 @@ namespace ts.Completions {
}
case "literal": {
const { literal } = symbolCompletion;
return createSimpleDetails(completionNameForLiteral(literal), ScriptElementKind.string, typeof literal === "string" ? SymbolDisplayPartKind.stringLiteral : SymbolDisplayPartKind.numericLiteral);
return createSimpleDetails(completionNameForLiteral(literal, preferences), ScriptElementKind.string, typeof literal === "string" ? SymbolDisplayPartKind.stringLiteral : SymbolDisplayPartKind.numericLiteral);
}
case "none":
// Didn't find a symbol with this name. See if we can find a keyword instead.
Expand Down Expand Up @@ -677,8 +689,9 @@ namespace ts.Completions {
position: number,
entryId: CompletionEntryIdentifier,
host: LanguageServiceHost,
preferences: UserPreferences,
): Symbol | undefined {
const completion = getSymbolCompletionFromEntryId(program, log, sourceFile, position, entryId, host);
const completion = getSymbolCompletionFromEntryId(program, log, sourceFile, position, entryId, host, preferences);
return completion.type === "symbol" ? completion.symbol : undefined;
}

Expand Down
4 changes: 2 additions & 2 deletions src/services/services.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1490,9 +1490,9 @@ namespace ts {
);
}

function getCompletionEntrySymbol(fileName: string, position: number, name: string, source?: string): Symbol | undefined {
function getCompletionEntrySymbol(fileName: string, position: number, name: string, source?: string, preferences: UserPreferences = emptyOptions): Symbol | undefined {
synchronizeHostData();
return Completions.getCompletionEntrySymbol(program, log, getValidSourceFile(fileName), position, { name, source }, host);
return Completions.getCompletionEntrySymbol(program, log, getValidSourceFile(fileName), position, { name, source }, host, preferences);
}

function getQuickInfoAtPosition(fileName: string, position: number): QuickInfo | undefined {
Expand Down
3 changes: 0 additions & 3 deletions src/services/utilities.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2343,9 +2343,6 @@ namespace ts {
}

export function quote(text: string, preferences: UserPreferences): string {
if (/^\d+$/.test(text)) {
return text;
}
// Editors can pass in undefined or empty string - we want to infer the preference in those cases.
const quotePreference = preferences.quotePreference || "auto";
const quoted = JSON.stringify(text);
Expand Down
25 changes: 16 additions & 9 deletions tests/baselines/reference/docker/azure-sdk.log
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ Exit Code: 1
Standard output:

Rush Multi-Project Build Tool 5.X.X - https://rushjs.io
Node.js version is 12.16.0 (LTS)
Node.js version is 12.16.1 (LTS)
Starting "rush rebuild"
Executing a maximum of ?simultaneous processes...
XX of XX: [@azure/abort-controller] completed successfully in ? seconds
Expand Down Expand Up @@ -41,7 +41,6 @@ npm ERR! Failed at the @azure/keyvault-certificates@X.X.X extract-api script.
npm ERR! This is probably not a problem with npm. There is likely additional logging output above.
npm ERR! A complete log of this run can be found in:
npm ERR! /root/.npm/_logs/XXXX-XX-XXXXXXXXX-debug.log
Warning: You have changed the public API signature for this project. Updating review/service-bus.api.md
npm ERR! code ELIFECYCLE
npm ERR! errno 2
npm ERR! @azure/storage-file-datalake@X.X.X-preview.9 build:es6: `tsc -p tsconfig.json && npm run build:types`
Expand Down Expand Up @@ -75,7 +74,7 @@ SUCCESS (17)
@azure/template (? seconds)
testhub (? seconds)
================================
SUCCESS WITH WARNINGS (7)
SUCCESS WITH WARNINGS (6)
================================
@azure/event-hubs (? seconds)
Warning: You have changed the public API signature for this project. Updating review/event-hubs.api.md
Expand All @@ -93,14 +92,12 @@ os-name (imported by dist-esm/utils/user-agent.js)
Use output.globals to specify browser global variable names corresponding to external modules
os-name (guessing 'osName')
created dist/index.js in ?s
@azure/service-bus (? seconds)
Warning: You have changed the public API signature for this project. Updating review/service-bus.api.md
@azure/storage-file-share (? seconds)
Warning: You have changed the public API signature for this project. Updating review/storage-file-share.api.md
@azure/storage-queue (? seconds)
Warning: You have changed the public API signature for this project. Updating review/storage-queue.api.md
================================
FAILURE (4)
FAILURE (5)
================================
@azure/app-configuration ( ? seconds)
>>> @azure/app-configuration
Expand All @@ -123,7 +120,7 @@ test/testHelpers.ts(92,31): error TS2322: Type 'PagedAsyncIterableIterator<Confi
Types of property 'next' are incompatible.
Type '() => Promise<{ done?: boolean | undefined; value: ConfigurationSetting; }>' is not assignable to type '(value?: any) => Promise<IteratorResult<ConfigurationSetting>>'.
Type 'Promise<{ done?: boolean | undefined; value: ConfigurationSetting; }>' is not assignable to type 'Promise<IteratorResult<ConfigurationSetting>>'.
@azure/eventhubs-checkpointstore-blob ( ? seconds)
@azure/eventhubs-checkpointstore-blob (? seconds)
>>> @azure/eventhubs-checkpointstore-blob
tsc -p . && rollup -c 2>&1 && npm run extract-api
src/blobCheckpointStore.ts(50,32): error TS2322: Type 'PagedAsyncIterableIterator<BlobItem, ContainerListBlobFlatSegmentResponse, PageSettings>' is not assignable to type 'AsyncIterable<BlobItem>'.
Expand All @@ -137,7 +134,7 @@ src/blobCheckpointStore.ts(50,32): error TS2322: Type 'PagedAsyncIterableIterato
Types of property 'done' are incompatible.
Type 'boolean | undefined' is not assignable to type 'boolean'.
Type 'undefined' is not assignable to type 'boolean'.
@azure/keyvault-certificates ( ? seconds)
@azure/keyvault-certificates (? seconds)
npm ERR! code ELIFECYCLE
npm ERR! errno 2
npm ERR! @azure/keyvault-certificates@X.X.X extract-api: `tsc -p . && api-extractor run --local`
Expand All @@ -147,6 +144,15 @@ npm ERR! Failed at the @azure/keyvault-certificates@X.X.X extract-api script.
npm ERR! This is probably not a problem with npm. There is likely additional logging output above.
npm ERR! A complete log of this run can be found in:
npm ERR! /root/.npm/_logs/XXXX-XX-XXXXXXXXX-debug.log
@azure/service-bus (? seconds)
>>> @azure/service-bus
tsc -p . && rollup -c 2>&1 && npm run extract-api
src/serviceBusClient.ts(90,34): error TS1109: Expression expected.
src/serviceBusClient.ts(90,52): error TS1109: Expression expected.
src/serviceBusClient.ts(90,62): error TS1005: ':' expected.
src/serviceBusClient.ts(92,52): error TS1109: Expression expected.
src/serviceBusClient.ts(92,70): error TS1109: Expression expected.
src/serviceBusClient.ts(92,98): error TS1005: ':' expected.
@azure/storage-file-datalake (? seconds)
npm ERR! code ELIFECYCLE
npm ERR! errno 2
Expand All @@ -171,11 +177,12 @@ XX of XX: [@azure/app-configuration] failed!
XX of XX: [@azure/cosmos] completed with warnings in ? seconds
XX of XX: [@azure/eventhubs-checkpointstore-blob] failed!
XX of XX: [@azure/keyvault-certificates] failed!
XX of XX: [@azure/service-bus] completed with warnings in ? seconds
XX of XX: [@azure/service-bus] failed!
XX of XX: [@azure/storage-file-datalake] failed!
XX of XX: [@azure/storage-file-share] completed with warnings in ? seconds
XX of XX: [@azure/storage-queue] completed with warnings in ? seconds
[@azure/app-configuration] Returned error code: 2
[@azure/eventhubs-checkpointstore-blob] Returned error code: 2
[@azure/keyvault-certificates] Returned error code: 2
[@azure/service-bus] Returned error code: 2
[@azure/storage-file-datalake] Returned error code: 2
Loading