Skip to content
Merged
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
24 changes: 24 additions & 0 deletions snapshots/input/syntax/src/ClassWithPrivate.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
export class ClassWithPrivate {
#privateField
#privateFieldWithInitializer = 42

#privateMethod() {
this.#privateField = 'private field'
return this.#privateField
}

static #privateStaticField
static #privateStaticFieldWithInitializer = 42

static #privateStaticMethod() {}
public publicMethod(): any[] {
return [
this.#privateField,
this.#privateFieldWithInitializer,
this.#privateMethod(),
ClassWithPrivate.#privateStaticMethod(),
ClassWithPrivate.#privateStaticField,
ClassWithPrivate.#privateStaticFieldWithInitializer,
]
}
}
2 changes: 1 addition & 1 deletion snapshots/input/syntax/tsconfig.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"compilerOptions": {
"outDir": "dist",
"target": "ES5"
"target": "ES2015"
}
}
54 changes: 54 additions & 0 deletions snapshots/output/syntax/src/ClassWithPrivate.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@
export class ClassWithPrivate {
// definition syntax 1.0.0 src/`ClassWithPrivate.ts`/
//documentation ```ts\nmodule "ClassWithPrivate.ts"\n```
// ^^^^^^^^^^^^^^^^ definition syntax 1.0.0 src/`ClassWithPrivate.ts`/ClassWithPrivate#
// documentation ```ts\nclass ClassWithPrivate\n```
#privateField
// ^^^^^^^^^^^^^ definition syntax 1.0.0 src/`ClassWithPrivate.ts`/ClassWithPrivate#`#privateField`.
// documentation ```ts\n(property) #privateField: any\n```
#privateFieldWithInitializer = 42
// ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ definition syntax 1.0.0 src/`ClassWithPrivate.ts`/ClassWithPrivate#`#privateFieldWithInitializer`.
// documentation ```ts\n(property) #privateFieldWithInitializer: number\n```

#privateMethod() {
// ^^^^^^^^^^^^^^ definition syntax 1.0.0 src/`ClassWithPrivate.ts`/ClassWithPrivate#`#privateMethod`().
// documentation ```ts\n(method) #privateMethod(): any\n```
this.#privateField = 'private field'
// ^^^^^^^^^^^^^ reference syntax 1.0.0 src/`ClassWithPrivate.ts`/ClassWithPrivate#`#privateField`.
return this.#privateField
// ^^^^^^^^^^^^^ reference syntax 1.0.0 src/`ClassWithPrivate.ts`/ClassWithPrivate#`#privateField`.
}

static #privateStaticField
// ^^^^^^^^^^^^^^^^^^^ definition syntax 1.0.0 src/`ClassWithPrivate.ts`/ClassWithPrivate#`#privateStaticField`.
// documentation ```ts\n(property) #privateStaticField: any\n```
static #privateStaticFieldWithInitializer = 42
// ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ definition syntax 1.0.0 src/`ClassWithPrivate.ts`/ClassWithPrivate#`#privateStaticFieldWithInitializer`.
// documentation ```ts\n(property) #privateStaticFieldWithInitializer: number\n```

static #privateStaticMethod() {}
// ^^^^^^^^^^^^^^^^^^^^ definition syntax 1.0.0 src/`ClassWithPrivate.ts`/ClassWithPrivate#`#privateStaticMethod`().
// documentation ```ts\n(method) #privateStaticMethod(): void\n```
public publicMethod(): any[] {
// ^^^^^^^^^^^^ definition syntax 1.0.0 src/`ClassWithPrivate.ts`/ClassWithPrivate#publicMethod().
// documentation ```ts\n(method) publicMethod(): any[]\n```
return [
this.#privateField,
// ^^^^^^^^^^^^^ reference syntax 1.0.0 src/`ClassWithPrivate.ts`/ClassWithPrivate#`#privateField`.
this.#privateFieldWithInitializer,
// ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ reference syntax 1.0.0 src/`ClassWithPrivate.ts`/ClassWithPrivate#`#privateFieldWithInitializer`.
this.#privateMethod(),
// ^^^^^^^^^^^^^^ reference syntax 1.0.0 src/`ClassWithPrivate.ts`/ClassWithPrivate#`#privateMethod`().
ClassWithPrivate.#privateStaticMethod(),
// ^^^^^^^^^^^^^^^^ reference syntax 1.0.0 src/`ClassWithPrivate.ts`/ClassWithPrivate#
// ^^^^^^^^^^^^^^^^^^^^ reference syntax 1.0.0 src/`ClassWithPrivate.ts`/ClassWithPrivate#`#privateStaticMethod`().
ClassWithPrivate.#privateStaticField,
// ^^^^^^^^^^^^^^^^ reference syntax 1.0.0 src/`ClassWithPrivate.ts`/ClassWithPrivate#
// ^^^^^^^^^^^^^^^^^^^ reference syntax 1.0.0 src/`ClassWithPrivate.ts`/ClassWithPrivate#`#privateStaticField`.
ClassWithPrivate.#privateStaticFieldWithInitializer,
// ^^^^^^^^^^^^^^^^ reference syntax 1.0.0 src/`ClassWithPrivate.ts`/ClassWithPrivate#
// ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ reference syntax 1.0.0 src/`ClassWithPrivate.ts`/ClassWithPrivate#`#privateStaticFieldWithInitializer`.
]
}
}

8 changes: 6 additions & 2 deletions src/FileIndexer.ts
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ export class FileIndexer {
}
public index(): void {
// Uncomment below if you want to skip certain files for local development.
// if (!this.sourceFile.fileName.includes('conflicting-const')) {
// if (!this.sourceFile.fileName.includes('ClassWithPrivate')) {
// return
// }
this.emitSourceFileOccurrence()
Expand Down Expand Up @@ -66,7 +66,11 @@ export class FileIndexer {
)
}
private visit(node: ts.Node): void {
if (ts.isIdentifier(node) || ts.isStringLiteralLike(node)) {
if (
ts.isIdentifier(node) ||
ts.isPrivateIdentifier(node) ||
ts.isStringLiteralLike(node)
) {
const sym = this.getTSSymbolAtLocation(node)
if (sym) {
this.visitSymbolOccurrence(node, sym)
Expand Down