Skip to content

Commit

Permalink
Format code
Browse files Browse the repository at this point in the history
  • Loading branch information
SuperAuguste committed Apr 25, 2023
1 parent c60d510 commit 808dfd5
Show file tree
Hide file tree
Showing 3 changed files with 23 additions and 32 deletions.
10 changes: 2 additions & 8 deletions snapshots/input/syntax/src/constructor.ts
Original file line number Diff line number Diff line change
@@ -1,11 +1,6 @@
// export class Constructor {
// constructor(public readonly property: number) {}
// }

namespace Yay {
export class SuperConstructor {
constructor(public readonly property: number) {
}
constructor(public readonly property: number) {}
}

export namespace Woo {
Expand All @@ -16,8 +11,7 @@ namespace Yay {
}

export class SuperConstructor2 {
constructor(public readonly property: number) {
}
constructor(public readonly property: number) {}
}

export function useConstructor(): Yay.SuperConstructor {
Expand Down
12 changes: 3 additions & 9 deletions snapshots/output/syntax/src/constructor.ts
Original file line number Diff line number Diff line change
@@ -1,21 +1,16 @@
// export class Constructor {
namespace Yay {
// definition syntax 1.0.0 src/`constructor.ts`/
//documentation ```ts\nmodule "constructor.ts"\n```
// constructor(public readonly property: number) {}
// }

namespace Yay {
// ^^^ definition syntax 1.0.0 src/`constructor.ts`/Yay/
// documentation ```ts\nYay: typeof Yay\n```
export class SuperConstructor {
// ^^^^^^^^^^^^^^^^ definition syntax 1.0.0 src/`constructor.ts`/Yay/SuperConstructor#
// documentation ```ts\nclass SuperConstructor\n```
constructor(public readonly property: number) {
constructor(public readonly property: number) {}
// ^^^^^^^^^^^ definition syntax 1.0.0 src/`constructor.ts`/Yay/SuperConstructor#`<constructor>`().
// documentation ```ts\nconstructor(property: number): SuperConstructor\n```
// ^^^^^^^^ definition syntax 1.0.0 src/`constructor.ts`/Yay/SuperConstructor#`<constructor>`().(property)
// documentation ```ts\n(property) property: number\n```
}
}

export namespace Woo {
Expand All @@ -34,12 +29,11 @@
export class SuperConstructor2 {
// ^^^^^^^^^^^^^^^^^ definition syntax 1.0.0 src/`constructor.ts`/SuperConstructor2#
// documentation ```ts\nclass SuperConstructor2\n```
constructor(public readonly property: number) {
constructor(public readonly property: number) {}
// ^^^^^^^^^^^ definition syntax 1.0.0 src/`constructor.ts`/SuperConstructor2#`<constructor>`().
// documentation ```ts\nconstructor(property: number): SuperConstructor2\n```
// ^^^^^^^^ definition syntax 1.0.0 src/`constructor.ts`/SuperConstructor2#`<constructor>`().(property)
// documentation ```ts\n(property) property: number\n```
}
}

export function useConstructor(): Yay.SuperConstructor {
Expand Down
33 changes: 18 additions & 15 deletions src/FileIndexer.ts
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,7 @@ export class FileIndexer {
this.visitSymbolOccurrence(node, sym)
}
}

ts.forEachChild(node, node => this.visit(node))
}

Expand Down Expand Up @@ -117,7 +117,9 @@ export class FileIndexer {
if (isDefinitionNode) {
role |= scip.scip.SymbolRole.Definition
}
const declarations = ts.isConstructorDeclaration(node) ? [node] : isDefinitionNode
const declarations = ts.isConstructorDeclaration(node)
? [node]
: isDefinitionNode
? // Don't emit ambiguous definition at definition-site. You can reproduce
// ambiguous results by triggering "Go to definition" in VS Code on `Conflict`
// in the example below:
Expand All @@ -131,19 +133,15 @@ export class FileIndexer {
let scipSymbol = this.scipSymbol(declaration)

if (
(
(
ts.isIdentifier(node) &&
ts.isNewExpression(node.parent)
) ||
(
ts.isPropertyAccessExpression(node.parent) &&
ts.isNewExpression(node.parent.parent)
)
) &&
((ts.isIdentifier(node) && ts.isNewExpression(node.parent)) ||
(ts.isPropertyAccessExpression(node.parent) &&
ts.isNewExpression(node.parent.parent))) &&
ts.isClassDeclaration(declaration)
) {
scipSymbol = ScipSymbol.global(scipSymbol, methodDescriptor("<constructor>"))
scipSymbol = ScipSymbol.global(
scipSymbol,
methodDescriptor('<constructor>')
)
}

if (scipSymbol.isEmpty()) {
Expand Down Expand Up @@ -491,7 +489,10 @@ export class FileIndexer {
return undefined
}

private asSignatureDeclaration(node: ts.Node, sym: ts.Symbol): ts.SignatureDeclaration | undefined {
private asSignatureDeclaration(
node: ts.Node,
sym: ts.Symbol
): ts.SignatureDeclaration | undefined {
const declaration = sym.declarations?.[0]
if (!declaration) {
return undefined
Expand Down Expand Up @@ -798,5 +799,7 @@ function declarationName(node: ts.Node): ts.Node | undefined {
* ^^^^^^^^^^^^^^^^^^^^^ node.parent
*/
function isDefinition(node: ts.Node): boolean {
return declarationName(node.parent) === node || ts.isConstructorDeclaration(node)
return (
declarationName(node.parent) === node || ts.isConstructorDeclaration(node)
)
}

0 comments on commit 808dfd5

Please sign in to comment.