Skip to content

Commit

Permalink
feat: add + prefix to kind specifiers in declaration ids
Browse files Browse the repository at this point in the history
  • Loading branch information
velut committed Mar 29, 2024
1 parent 174c639 commit dde5abf
Show file tree
Hide file tree
Showing 63 changed files with 2,491 additions and 2,491 deletions.
6 changes: 3 additions & 3 deletions src/extract-class.ts
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ export const extractClass = async (
exportName: string,
declaration: ClassDeclaration,
): Promise<ExtractedClass> => {
const classId = id(containerName, "class", exportName);
const classId = id(containerName, "+class", exportName);
return {
kind: "class",
id: classId,
Expand Down Expand Up @@ -162,7 +162,7 @@ const extractClassProperties = async (
const name = declaration.getName();
properties.push({
kind: "class-property" as const,
id: id(classId, "property", name),
id: id(classId, "+property", name),
name,
docs: docs(declaration),
file: sourceFilePath(declaration),
Expand Down Expand Up @@ -213,7 +213,7 @@ const extractClassMethods = async (
seenMethods.add(name);
methods.push({
kind: "class-method" as const,
id: id(classId, "method", name),
id: id(classId, "+method", name),
name,
docs: docs(declaration),
file: sourceFilePath(declaration),
Expand Down
4 changes: 2 additions & 2 deletions src/extract-declarations.ts
Original file line number Diff line number Diff line change
Expand Up @@ -182,7 +182,7 @@ const extractDeclaration = async ({
}
seenNamespaces.add(exportName);
const innerDeclarations = await extractDeclarations({
containerName: id(containerName, "namespace", exportName),
containerName: id(containerName, "+namespace", exportName),
container: declaration,
maxDepth: maxDepth - 1,
});
Expand All @@ -193,7 +193,7 @@ const extractDeclaration = async ({
// `import * as ns from module; export { ns };` or
// `export * as ns from module`.
const innerDeclarations = await extractDeclarations({
containerName: id(containerName, "namespace", exportName),
containerName: id(containerName, "+namespace", exportName),
container: declaration,
maxDepth: maxDepth - 1,
});
Expand Down
4 changes: 2 additions & 2 deletions src/extract-enum.ts
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ export const extractEnum = async (
exportName: string,
declaration: EnumDeclaration,
): Promise<ExtractedEnum> => {
const enumId = id(containerName, "enum", exportName);
const enumId = id(containerName, "+enum", exportName);
return {
kind: "enum",
id: enumId,
Expand Down Expand Up @@ -62,7 +62,7 @@ const extractEnumMembers = async (
const name = declaration.getName();
members.push({
kind: "enum-member" as const,
id: id(enumId, "member", name),
id: id(enumId, "+member", name),
name,
docs: docs(declaration),
file: sourceFilePath(declaration),
Expand Down
2 changes: 1 addition & 1 deletion src/extract-expression.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ export const extractExpression = async (
declaration: Expression,
): Promise<ExtractedVariable> => ({
kind: "variable",
id: id(containerName, "variable", exportName),
id: id(containerName, "+variable", exportName),
name: exportName,
docs: docs(declaration),
file: sourceFilePath(declaration),
Expand Down
2 changes: 1 addition & 1 deletion src/extract-file-module.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ export const extractFileModule = async (
declarations: ExtractedDeclaration[],
): Promise<ExtractedNamespace> => ({
kind: "namespace",
id: id(containerName, "namespace", exportName),
id: id(containerName, "+namespace", exportName),
name: exportName,
docs: fileModuleDocs(declaration),
file: sourceFilePath(declaration),
Expand Down
2 changes: 1 addition & 1 deletion src/extract-function-expression.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ export const extractFunctionExpression = async (
declaration: VariableDeclaration,
): Promise<ExtractedFunction> => ({
kind: "function",
id: id(containerName, "function", exportName),
id: id(containerName, "+function", exportName),
name: exportName,
docs: docs(declaration),
file: sourceFilePath(declaration),
Expand Down
2 changes: 1 addition & 1 deletion src/extract-function.ts
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ export const extractFunction = async (
declaration: FunctionDeclaration | ArrowFunction,
): Promise<ExtractedFunction> => ({
kind: "function",
id: id(containerName, "function", exportName),
id: id(containerName, "+function", exportName),
name: exportName,
docs: docs(declaration),
file: sourceFilePath(declaration),
Expand Down
10 changes: 5 additions & 5 deletions src/extract-interface.ts
Original file line number Diff line number Diff line change
Expand Up @@ -109,7 +109,7 @@ export const extractInterface = async (
exportName: string,
declaration: InterfaceDeclaration,
): Promise<ExtractedInterface> => {
const interfaceId = id(containerName, "interface", exportName);
const interfaceId = id(containerName, "+interface", exportName);
return {
kind: "interface",
id: interfaceId,
Expand Down Expand Up @@ -145,7 +145,7 @@ const extractInterfaceProperties = async (
const name = declaration.getName();
properties.push({
kind: "interface-property" as const,
id: id(interfaceId, "property", name),
id: id(interfaceId, "+property", name),
name,
docs: docs(declaration),
file: sourceFilePath(declaration),
Expand Down Expand Up @@ -179,7 +179,7 @@ const extractInterfaceMethods = async (
seenMethods.add(name);
methods.push({
kind: "interface-method" as const,
id: id(interfaceId, "method", name),
id: id(interfaceId, "+method", name),
name,
docs: docs(declaration),
file: sourceFilePath(declaration),
Expand Down Expand Up @@ -297,7 +297,7 @@ const extractInterfaceGetAccessors = async (
const name = declaration.getName();
getAccessors.push({
kind: "interface-get-accessor" as const,
id: id(interfaceId, "get-accessor", name),
id: id(interfaceId, "+get-accessor", name),
name,
docs: docs(declaration),
file: sourceFilePath(declaration),
Expand Down Expand Up @@ -327,7 +327,7 @@ const extractInterfaceSetAccessors = async (
const name = declaration.getName();
setAccessors.push({
kind: "interface-set-accessor" as const,
id: id(interfaceId, "set-accessor", name),
id: id(interfaceId, "+set-accessor", name),
name,
docs: docs(declaration),
file: sourceFilePath(declaration),
Expand Down
2 changes: 1 addition & 1 deletion src/extract-namespace.ts
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ export const extractNamespace = async (
declarations: ExtractedDeclaration[],
): Promise<ExtractedNamespace> => ({
kind: "namespace",
id: id(containerName, "namespace", exportName),
id: id(containerName, "+namespace", exportName),
name: exportName,
docs: docs(declaration),
file: sourceFilePath(declaration),
Expand Down
2 changes: 1 addition & 1 deletion src/extract-type-alias.ts
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ export const extractTypeAlias = async (
declaration: TypeAliasDeclaration,
): Promise<ExtractedTypeAlias> => ({
kind: "type",
id: id(containerName, "type", exportName),
id: id(containerName, "+type", exportName),
name: exportName,
docs: docs(declaration),
file: sourceFilePath(declaration),
Expand Down
2 changes: 1 addition & 1 deletion src/extract-variable-assignment-expression.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ export const extractVariableAssignmentExpression = async (
.getDeclarations()[0] as VariableDeclaration;
return {
kind: "variable",
id: id(containerName, "variable", exportName),
id: id(containerName, "+variable", exportName),
name: exportName,
docs: docs(variableDeclaration),
file: sourceFilePath(variableDeclaration),
Expand Down
2 changes: 1 addition & 1 deletion src/extract-variable.ts
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ export const extractVariable = async (
declaration: VariableDeclaration,
): Promise<ExtractedVariable> => ({
kind: "variable",
id: id(containerName, "variable", exportName),
id: id(containerName, "+variable", exportName),
name: exportName,
docs: docs(declaration),
file: sourceFilePath(declaration),
Expand Down
12 changes: 6 additions & 6 deletions test/declarations/__snapshots__/ambient-modules.test.ts.snap
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ exports[`ambient modules 1`] = `
"/** Variable var1 */",
],
"file": "/index.d.ts",
"id": "namespace."bar".variable.var1",
"id": "+namespace."bar".+variable.var1",
"kind": "variable",
"line": 7,
"name": "var1",
Expand All @@ -20,7 +20,7 @@ exports[`ambient modules 1`] = `
"/** Variable var2 */",
],
"file": "/index.d.ts",
"id": "namespace."bar".variable.var2",
"id": "+namespace."bar".+variable.var2",
"kind": "variable",
"line": 10,
"name": "var2",
Expand All @@ -31,7 +31,7 @@ exports[`ambient modules 1`] = `
"/** Module 'bar' */",
],
"file": "/index.d.ts",
"id": "namespace."bar"",
"id": "+namespace."bar"",
"kind": "namespace",
"line": 5,
"name": ""bar"",
Expand All @@ -42,7 +42,7 @@ exports[`ambient modules 1`] = `
{
"docs": [],
"file": "/index.d.ts",
"id": "namespace."foo bar".function.default",
"id": "+namespace."foo bar".+function.default",
"kind": "function",
"line": 15,
"name": "default",
Expand All @@ -53,7 +53,7 @@ exports[`ambient modules 1`] = `
"/** Module 'foo bar' */",
],
"file": "/index.d.ts",
"id": "namespace."foo bar"",
"id": "+namespace."foo bar"",
"kind": "namespace",
"line": 14,
"name": ""foo bar"",
Expand All @@ -65,7 +65,7 @@ exports[`ambient modules 1`] = `
"/** Module 'foo' */",
],
"file": "/index.d.ts",
"id": "namespace."foo"",
"id": "+namespace."foo"",
"kind": "namespace",
"line": 2,
"name": ""foo"",
Expand Down
14 changes: 7 additions & 7 deletions test/declarations/__snapshots__/ambient-namespaces.test.ts.snap
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ exports[`ambient namespaces 1`] = `
"/** Global function foobar */",
],
"file": "/index.d.ts",
"id": "function.foobar",
"id": "+function.foobar",
"kind": "function",
"line": 20,
"name": "foobar",
Expand All @@ -23,7 +23,7 @@ exports[`ambient namespaces 1`] = `
],
"file": "/index.d.ts",
"getAccessors": [],
"id": "namespace.Foo.interface.Bar",
"id": "+namespace.Foo.+interface.Bar",
"indexSignatures": [],
"kind": "interface",
"line": 4,
Expand All @@ -35,7 +35,7 @@ exports[`ambient namespaces 1`] = `
"/** Property qux */",
],
"file": "/index.d.ts",
"id": "namespace.Foo.interface.Bar.property.qux",
"id": "+namespace.Foo.+interface.Bar.+property.qux",
"kind": "interface-property",
"line": 6,
"name": "qux",
Expand All @@ -50,7 +50,7 @@ exports[`ambient namespaces 1`] = `
"/** Variable baz */",
],
"file": "/index.d.ts",
"id": "namespace.Foo.variable.baz",
"id": "+namespace.Foo.+variable.baz",
"kind": "variable",
"line": 10,
"name": "baz",
Expand All @@ -61,7 +61,7 @@ exports[`ambient namespaces 1`] = `
"/** Ambient namespace Foo */",
],
"file": "/index.d.ts",
"id": "namespace.Foo",
"id": "+namespace.Foo",
"kind": "namespace",
"line": 2,
"name": "Foo",
Expand All @@ -72,7 +72,7 @@ exports[`ambient namespaces 1`] = `
"/** Global read-only variable bar */",
],
"file": "/index.d.ts",
"id": "variable.bar",
"id": "+variable.bar",
"kind": "variable",
"line": 17,
"name": "bar",
Expand All @@ -83,7 +83,7 @@ exports[`ambient namespaces 1`] = `
"/** Global variable foo */",
],
"file": "/index.d.ts",
"id": "variable.foo",
"id": "+variable.foo",
"kind": "variable",
"line": 14,
"name": "foo",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ exports[`class with ambient constructor 1`] = `
{
"docs": [],
"file": "/index.d.ts",
"id": "class.Class1.constructor",
"id": "+class.Class1.constructor",
"kind": "class-constructor",
"line": 2,
"name": "constructor",
Expand All @@ -16,7 +16,7 @@ exports[`class with ambient constructor 1`] = `
],
"docs": [],
"file": "/index.d.ts",
"id": "class.Class1",
"id": "+class.Class1",
"kind": "class",
"line": 1,
"methods": [],
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ exports[`class with overloaded methods 1`] = `
"constructors": [],
"docs": [],
"file": "/index.d.ts",
"id": "class.Class1",
"id": "+class.Class1",
"kind": "class",
"line": 1,
"methods": [
Expand All @@ -16,7 +16,7 @@ exports[`class with overloaded methods 1`] = `
"/** (B) foo */",
],
"file": "/index.d.ts",
"id": "class.Class1.method.foo",
"id": "+class.Class1.+method.foo",
"kind": "class-method",
"line": 3,
"name": "foo",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ exports[`export all as namespace 1`] = `
"/** Variable foo1 */",
],
"file": "/foo.d.ts",
"id": "namespace.foo.variable.foo1",
"id": "+namespace.foo.+variable.foo1",
"kind": "variable",
"line": 6,
"name": "foo1",
Expand All @@ -22,7 +22,7 @@ exports[`export all as namespace 1`] = `
*/",
],
"file": "/foo.d.ts",
"id": "namespace.foo",
"id": "+namespace.foo",
"kind": "namespace",
"line": 6,
"name": "foo",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ exports[`export as namespace 1`] = `
"/** func1 */",
],
"file": "/index.d.ts",
"id": "function.func1",
"id": "+function.func1",
"kind": "function",
"line": 2,
"name": "func1",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ exports[`export default arrow function 1`] = `
"/** func1 */",
],
"file": "/index.ts",
"id": "function.default",
"id": "+function.default",
"kind": "function",
"line": 2,
"name": "default",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ exports[`export default class 1`] = `
"/** Class1 */",
],
"file": "/index.ts",
"id": "class.default",
"id": "+class.default",
"kind": "class",
"line": 2,
"methods": [],
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ exports[`export default const 1`] = `
"/** var1 */",
],
"file": "/index.ts",
"id": "variable.default",
"id": "+variable.default",
"kind": "variable",
"line": 2,
"name": "default",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ exports[`export default expression 1`] = `
"/** expr1 */",
],
"file": "/index.ts",
"id": "variable.default",
"id": "+variable.default",
"kind": "variable",
"line": 2,
"name": "default",
Expand Down
Loading

0 comments on commit dde5abf

Please sign in to comment.