Skip to content

Commit ad54eef

Browse files
formatting
1 parent 17b7321 commit ad54eef

File tree

3 files changed

+12
-14
lines changed

3 files changed

+12
-14
lines changed

src/harness/fourslashImpl.ts

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -858,11 +858,13 @@ export class TestState {
858858
}
859859

860860
// Check if the inferred definition points to the expected marker location
861-
if (inferredDef.fileName !== expectedMarker.fileName ||
862-
inferredDef.textSpan.start !== expectedMarker.position) {
861+
if (
862+
inferredDef.fileName !== expectedMarker.fileName ||
863+
inferredDef.textSpan.start !== expectedMarker.position
864+
) {
863865
this.raiseError(
864866
`Expected inferredIndex to point to marker "${expectedDefinitionMarkerName}" at ${expectedMarker.fileName}:${expectedMarker.position}, ` +
865-
`but it points to ${inferredDef.fileName}:${inferredDef.textSpan.start}.`
867+
`but it points to ${inferredDef.fileName}:${inferredDef.textSpan.start}.`,
866868
);
867869
}
868870
}

src/server/session.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1639,7 +1639,7 @@ export class Session<TMessage = string> implements EventSender {
16391639
const { file, project } = this.getFileAndProject(args);
16401640
const position = this.getPositionInFile(args, file);
16411641
const scriptInfo = Debug.checkDefined(project.getScriptInfo(file));
1642-
1642+
16431643
const unmappedDefinitionAndBoundSpan = project.getLanguageService().getDefinitionAndBoundSpan(file, position);
16441644

16451645
if (!unmappedDefinitionAndBoundSpan || !unmappedDefinitionAndBoundSpan.definitions) {
@@ -1653,7 +1653,7 @@ export class Session<TMessage = string> implements EventSender {
16531653
const name = unmappedDefinitionAndBoundSpan.definitions[unmappedDefinitionAndBoundSpan.inferredIndex].name;
16541654

16551655
if (!this.recentAttemptedDefinitionInferenceNames.has(name)) {
1656-
this.recentAttemptedDefinitionInferenceNames.add(name)
1656+
this.recentAttemptedDefinitionInferenceNames.add(name);
16571657
this.host.setTimeout(() => this.recentAttemptedDefinitionInferenceNames.delete(name), 5000);
16581658
unmappedDefinitionAndBoundSpan.definitions = [unmappedDefinitionAndBoundSpan.definitions[unmappedDefinitionAndBoundSpan.inferredIndex]];
16591659
}

src/services/goToDefinition.ts

Lines changed: 5 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -514,8 +514,6 @@ function tryGetReturnTypeOfFunction(symbol: Symbol, type: Type, checker: TypeChe
514514
return undefined;
515515
}
516516

517-
518-
519517
/** @internal */
520518
export function getDefinitionAndBoundSpan(program: Program, sourceFile: SourceFile, position: number): DefinitionInfoAndBoundSpan | undefined {
521519
const definitions = getDefinitionAtPosition(program, sourceFile, position);
@@ -541,17 +539,17 @@ export function getDefinitionAndBoundSpan(program: Program, sourceFile: SourceFi
541539
}
542540

543541
function getInferrableDefinitionIndex(definitions: readonly DefinitionInfo[], node: Node, program: Program): number | undefined {
544-
const TYPEY_SET = new Set([SyntaxKind.InterfaceDeclaration, SyntaxKind.TypeAliasDeclaration])
542+
const TYPEY_SET = new Set([SyntaxKind.InterfaceDeclaration, SyntaxKind.TypeAliasDeclaration]);
545543

546544
const mainIsTypey = getUsageNodeKind(node) === SyntaxKind.TypeReference;
547-
const optionNodes = definitions?.map(def => findNodeFromSpan(program.getSourceFile(def.fileName), def.textSpan)!)
548-
const definitionsAreTypey = optionNodes.map((node) => TYPEY_SET.has(node?.parent?.kind ?? undefined))
545+
const optionNodes = definitions?.map(def => findNodeFromSpan(program.getSourceFile(def.fileName), def.textSpan)!);
546+
const definitionsAreTypey = optionNodes.map(node => TYPEY_SET.has(node?.parent?.kind ?? undefined));
549547

550-
return definitionsAreTypey.filter((def) => def === mainIsTypey).length === 1 ? definitionsAreTypey.indexOf(mainIsTypey) : undefined;
548+
return definitionsAreTypey.filter(def => def === mainIsTypey).length === 1 ? definitionsAreTypey.indexOf(mainIsTypey) : undefined;
551549
}
552550

553551
function getUsageNodeKind(node: Node): SyntaxKind {
554-
return node.kind === SyntaxKind.QualifiedName || node.kind === SyntaxKind.Identifier ? getUsageNodeKind(node.parent) : node.kind;
552+
return node.kind === SyntaxKind.QualifiedName || node.kind === SyntaxKind.Identifier ? getUsageNodeKind(node.parent) : node.kind;
555553
}
556554

557555
function findNodeFromSpan(sourceFile: SourceFile | undefined, span: TextSpan): Node | undefined {
@@ -570,8 +568,6 @@ function findNodeFromSpan(sourceFile: SourceFile | undefined, span: TextSpan): N
570568
return sourceFile ? visit(sourceFile) : undefined;
571569
}
572570

573-
574-
575571
// At 'x.foo', see if the type of 'x' has an index signature, and if so find its declarations.
576572
function getDefinitionInfoForIndexSignatures(node: Node, checker: TypeChecker): DefinitionInfo[] | undefined {
577573
return mapDefined(checker.getIndexInfosAtLocation(node), info => info.declaration && createDefinitionFromSignatureDeclaration(checker, info.declaration));

0 commit comments

Comments
 (0)