@@ -174,5 +174,5 @@ import { ParseTree } from "antlr4ts/tree/ParseTree"; | ||
| addNewNamespaceFromPath(parent: ScopedSymbol | undefined, path: string, delimiter?: string): Promise<NamespaceSymbol>; | ||
| getAllSymbols(type?: typeof Symbol, localOnly?: boolean): Promise<Symbol[]>; | ||
| getAllSymbols<T extends Symbol>(t?: new (...args: any[]) => T, localOnly?: boolean): Promise<Symbol[]>; | ||
| symbolWithContext(context: ParseTree): Promise<Symbol | undefined>; | ||
| resolve(name: string, localOnly?: boolean): Promise<Symbol | undefined>; | ||
| } |
@@ -567,3 +567,3 @@ "use strict"; | ||
| } | ||
| getAllSymbols(type, localOnly = false) { | ||
| getAllSymbols(t, localOnly = false) { | ||
| const _super = Object.create(null, { | ||
@@ -573,5 +573,5 @@ getAllSymbols: { get: () => super.getAllSymbols } | ||
| return __awaiter(this, void 0, void 0, function* () { | ||
| const result = yield _super.getAllSymbols.call(this, type !== null && type !== void 0 ? type : Symbol, localOnly); | ||
| const result = yield _super.getAllSymbols.call(this, t !== null && t !== void 0 ? t : Symbol, localOnly); | ||
| if (!localOnly) { | ||
| const dependencyResults = yield Promise.all([...this.dependencies].map((dependency) => (dependency.getAllSymbols(type, localOnly)))); | ||
| const dependencyResults = yield Promise.all([...this.dependencies].map((dependency) => (dependency.getAllSymbols(t, localOnly)))); | ||
| dependencyResults.forEach((value) => { | ||
@@ -578,0 +578,0 @@ result.push(...value); |
@@ -1,1 +0,1 @@ | ||
| {"version":3,"file":"SymbolTable.js","sourceRoot":"","sources":["../../src/SymbolTable.ts"],"names":[],"mappings":";;;;;;;;;;;;AAWA,MAAa,oBAAqB,SAAQ,KAAK;CAAI;AAAnD,oDAAmD;AAEnD,IAAY,gBAMX;AAND,WAAY,gBAAgB;IACxB,8DAAY,CAAA;IACZ,2DAAU,CAAA;IACV,iEAAS,CAAA;IACT,6DAAO,CAAA;IACP,6DAAO,CAAA;AACX,CAAC,EANW,gBAAgB,GAAhB,wBAAgB,KAAhB,wBAAgB,QA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AAY,EAAE;oBACxC,MAAM,GAAG,MAAM,UAAU,CAAC,OAAO,CAAC,IAAI,EAAE,KAAK,CAAC,CAAC;oBAC/C,IAAI,MAAM,EAAE;wBACR,OAAO,MAAM,CAAC;qBACjB;iBACJ;aACJ;YAED,OAAO,MAAM,CAAC;QAClB,CAAC;KAAA;CAEJ;AAjKD,kCAiKC","sourcesContent":["/*\n * This file is released under the MIT license.\n * Copyright (c) 2017, 2020, Mike Lischke\n *\n * See LICENSE file for more info.\n */\n\n/* eslint-disable max-classes-per-file */\n\nimport { ParseTree } from \"antlr4ts/tree/ParseTree\";\n\nexport class DuplicateSymbolError extends Error { }\n\nexport enum MemberVisibility {\n Invalid = -1,\n Public = 0,\n Protected,\n Private,\n Library,\n}\n\nexport enum TypeKind {\n Integer,\n Float,\n String,\n Boolean,\n Date,\n\n Class,\n Array,\n Alias,\n}\n\nexport enum ReferenceKind {\n Irrelevant,\n Pointer, // Default for most languages for dynamically allocated memory (\"Type*\" in C++).\n Reference, // \"Type&\" in C++\n Instance, // \"Type\" as such and default for all value types.\n}\n\n// The root type interface. Used for typed symbols and type aliases.\nexport interface Type {\n name: string;\n\n // The super type of this type or empty if this is a fundamental type.\n // Also used as the target type for type aliases.\n baseTypes: Type[];\n kind: TypeKind;\n reference: ReferenceKind;\n}\n\nexport interface SymbolTableOptions {\n allowDuplicateSymbols?: boolean;\n}\n\n// A single class for all fundamental types. They are distinguished via the kind field.\nexport class FundamentalType implements Type {\n public static readonly integerType = new FundamentalType(\"int\", TypeKind.Integer, ReferenceKind.Instance);\n public static readonly floatType = new FundamentalType(\"float\", TypeKind.Float, ReferenceKind.Instance);\n public static readonly stringType = new FundamentalType(\"string\", TypeKind.String, ReferenceKind.Instance);\n public static readonly boolType = new FundamentalType(\"bool\", TypeKind.Boolean, ReferenceKind.Instance);\n public static readonly dateType = new FundamentalType(\"date\", TypeKind.Date, ReferenceKind.Instance);\n\n public name: string;\n\n private typeKind: TypeKind;\n private referenceKind: ReferenceKind;\n\n public constructor(name: string, typeKind: TypeKind, referenceKind: ReferenceKind) {\n this.name = name;\n this.typeKind = typeKind;\n this.referenceKind = referenceKind;\n }\n\n public get baseTypes(): Type[] {\n return [];\n }\n\n public get kind(): TypeKind {\n return this.typeKind;\n }\n\n public get reference(): ReferenceKind {\n return this.referenceKind;\n }\n\n}\n\n// The root of the symbol table class hierarchy: a symbol can be any manageable entity (like a block), not only\n// things like variables or classes.\n// We are using a class hierarchy here, instead of an enum or similar, to allow for easy extension and certain\n// symbols can so provide additional APIs for simpler access to their sub elements, if needed.\nexport class Symbol {\n public name = \"\"; // The name of the scope or empty if anonymous.\n public context?: ParseTree; // Reference to the parse tree which contains this symbol.\n\n private theParent?: Symbol;\n\n public constructor(name = \"\") {\n this.name = name;\n }\n\n /**\n * The parent is usually a scoped symbol as only those can have children, but we allow\n * any symbol here for special scenarios.\n * This is rather an internal method and should rarely be used by external code.\n *\n * @param parent The new parent to use.\n */\n public setParent(parent: Symbol | undefined): void {\n this.theParent = parent;\n }\n\n public get parent(): Symbol | undefined {\n return this.theParent;\n }\n\n public get firstSibling(): Symbol {\n if (this.theParent instanceof ScopedSymbol) {\n return this.theParent.firstChild!;\n }\n\n return this;\n }\n\n /**\n * @returns the symbol before this symbol in its scope.\n */\n public get previousSibling(): Symbol | undefined {\n if (!(this.theParent instanceof ScopedSymbol)) {\n return this;\n }\n\n return this.theParent.previousSiblingOf(this);\n }\n\n /**\n * @returns the symbol following this symbol in its scope.\n */\n public get nextSibling(): Symbol | undefined {\n if (!(this.theParent instanceof ScopedSymbol)) {\n return this;\n }\n\n return this.theParent.nextSiblingOf(this);\n }\n\n public get lastSibling(): Symbol {\n if (this.theParent instanceof ScopedSymbol) {\n return this.theParent.lastChild!;\n }\n\n return this;\n }\n\n /**\n * @returns the next symbol in definition order, regardless of the scope.\n */\n public get next(): Symbol | undefined {\n if (this.theParent instanceof ScopedSymbol) {\n return this.theParent.nextOf(this);\n }\n\n return undefined;\n }\n\n public removeFromParent(): void {\n if (this.theParent instanceof ScopedSymbol) {\n this.theParent.removeSymbol(this);\n this.theParent = undefined;\n }\n }\n\n /**\n *\n * @param name The name of the symbol to find.\n * @param localOnly If true only child symbols are returned, otherwise also symbols from the parent of this symbol\n * (recursively).\n * @returns the first symbol with a given name, in the order of appearance in this scope\n * or any of the parent scopes (conditionally).\n */\n public async resolve(name: string, localOnly = false): Promise<Symbol | undefined> {\n if (this.theParent instanceof ScopedSymbol) {\n return this.theParent.resolve(name, localOnly);\n }\n\n return Promise.resolve(undefined);\n }\n\n /**\n * @returns the outermost entity (below the symbol table) that holds us.\n */\n public get root(): Symbol | undefined {\n let run = this.theParent;\n while (run) {\n if (!run.theParent || (run.theParent instanceof SymbolTable)) {\n return run;\n }\n run = run.theParent;\n }\n\n return run;\n }\n\n /**\n * @returns the symbol table we belong too or undefined if we are not yet assigned.\n */\n public get symbolTable(): SymbolTable | undefined {\n if (this instanceof SymbolTable) {\n return this;\n }\n\n let run = this.theParent;\n while (run) {\n if (run instanceof SymbolTable) { return run; }\n run = run.theParent;\n }\n\n return undefined;\n }\n\n /**\n * @param t The type of objects to return.\n * @returns the next enclosing parent of the given type.\n */\n public getParentOfType<T extends Symbol>(t: new (...args: any[]) => T): T | undefined {\n let run = this.theParent;\n while (run) {\n if (run instanceof t) { return run; }\n run = run.theParent;\n }\n\n return undefined;\n }\n\n /**\n * @returns the list of symbols from this one up to root.\n */\n public get symbolPath(): Symbol[] {\n const result: Symbol[] = [];\n\n // eslint-disable-next-line @typescript-eslint/no-this-alias\n let run: Symbol = this;\n while (run) {\n result.push(run);\n if (!run.theParent) { break; }\n run = run.theParent;\n }\n\n return result;\n }\n\n /**\n * Creates a qualified identifier from this symbol and its parent.\n * If `full` is true then all parents are traversed in addition to this instance.\n *\n * @param separator The string to be used between the parts.\n * @param full A flag indicating if the full path is to be returned.\n * @param includeAnonymous Use a special string for empty scope names.\n * @returns the constructed qualified identifier.\n */\n public qualifiedName(separator = \".\", full = false, includeAnonymous = false): string {\n if (!includeAnonymous && this.name.length === 0) {\n return \"\";\n }\n\n let result: string = this.name.length === 0 ? \"<anonymous>\" : this.name;\n let run = this.theParent;\n while (run) {\n if (includeAnonymous || run.name.length > 0) {\n result = (run.name.length === 0 ? \"<anonymous>\" : run.name) + separator + result;\n }\n\n if (!full || !run.theParent) {\n break;\n }\n run = run.theParent;\n }\n\n return result;\n }\n\n}\n\n// A symbol with an attached type (variables, fields etc.).\nexport class TypedSymbol extends Symbol {\n public type: Type | undefined;\n\n public constructor(name: string, type?: Type) {\n super(name);\n this.type = type;\n }\n}\n\n// An alias for another type.\nexport class TypeAlias extends Symbol implements Type {\n public get baseTypes(): Type[] { return [this.targetType]; }\n public get kind(): TypeKind { return TypeKind.Alias; }\n public get reference(): ReferenceKind { return ReferenceKind.Irrelevant; }\n\n private targetType: Type;\n\n public constructor(name: string, target: Type) {\n super(name);\n this.targetType = target;\n }\n}\n\n// A symbol with a scope (so it can have child symbols).\nexport class ScopedSymbol extends Symbol {\n\n private _children: Symbol[] = []; // All child symbols in definition order.\n\n public constructor(name = \"\") {\n super(name);\n }\n\n public get children(): Symbol[] {\n // eslint-disable-next-line no-underscore-dangle\n return this._children;\n }\n\n public clear(): void {\n // eslint-disable-next-line no-underscore-dangle\n this._children = [];\n }\n\n /**\n * Adds the given symbol to this scope. If it belongs already to a different scope\n * it is removed from that before adding it here.\n *\n * @param symbol The symbol to add as a child.\n */\n public addSymbol(symbol: Symbol): void {\n symbol.removeFromParent();\n\n // Check for duplicates first.\n const symbolTable = this.symbolTable;\n if (!symbolTable || !symbolTable.options.allowDuplicateSymbols) {\n this.children.forEach((child) => {\n if (child === symbol || (symbol.name.length > 0 && child.name === symbol.name)) {\n let name = symbol.name;\n if (name.length === 0) {\n name = \"<anonymous>\";\n }\n\n throw new DuplicateSymbolError(\"Attempt to add duplicate symbol '\" + name + \"'\");\n }\n });\n }\n\n this.children.push(symbol);\n symbol.setParent(this);\n }\n\n public removeSymbol(symbol: Symbol): void {\n const index = this.children.indexOf(symbol);\n if (index > -1) {\n this.children.splice(index, 1);\n symbol.setParent(undefined);\n }\n }\n\n /**\n * @param t The type of of the objects to return.\n * @returns A promise resolving to all (nested) children of the given type.\n */\n public async getNestedSymbolsOfType<T extends Symbol>(t: new (...args: any[]) => T): Promise<T[]> {\n const result: T[] = [];\n\n const childPromises: Array<Promise<T[]>> = [];\n this.children.forEach((child) => {\n if (child instanceof t) {\n result.push(child);\n }\n\n if (child instanceof ScopedSymbol) {\n childPromises.push(child.getNestedSymbolsOfType(t));\n }\n });\n const childSymbols = await Promise.all(childPromises);\n childSymbols.forEach((entry) => {\n result.push(...entry);\n });\n\n return result;\n }\n\n /**\n * @param name If given only returns symbols with that name.\n * @returns A promise resolving to symbols from this and all nested scopes in the order they were defined.\n */\n public async getAllNestedSymbols(name?: string): Promise<Symbol[]> {\n const result: Symbol[] = [];\n\n const childPromises: Array<Promise<Symbol[]>> = [];\n this.children.forEach((child) => {\n if (!name || child.name === name) {\n result.push(child);\n }\n\n if (child instanceof ScopedSymbol) {\n childPromises.push(child.getAllNestedSymbols(name));\n }\n });\n const childSymbols = await Promise.all(childPromises);\n childSymbols.forEach((entry) => {\n result.push(...entry);\n });\n\n return result;\n }\n\n /**\n * @param t The type of of the objects to return.\n * @returns A promise resolving to direct children of a given type.\n */\n public getSymbolsOfType<T extends Symbol>(t: new (...args: any[]) => T): Promise<T[]> {\n return new Promise((resolve) => {\n const result: T[] = [];\n this.children.forEach((child) => {\n if (child instanceof t) {\n result.push(child);\n }\n });\n\n resolve(result);\n });\n }\n\n /**\n * TODO: add optional position dependency (only symbols defined before a given caret pos are viable).\n *\n * @param t The type of the objects to return.\n * @param localOnly If true only child symbols are returned, otherwise also symbols from the parent of this symbol\n * (recursively).\n * @returns A promise resolving to all symbols of the the given type, accessible from this scope (if localOnly is\n * false), within the owning symbol table.\n */\n public async getAllSymbols<T extends Symbol>(t: new (...args: any[]) => T,\n localOnly = false): Promise<Symbol[]> {\n const result: Symbol[] = [];\n\n // Special handling for namespaces, which act like grouping symbols in this scope,\n // so we show them as available in this scope.\n for (const child of this.children) {\n if (child instanceof t) {\n result.push(child);\n }\n\n if (child instanceof NamespaceSymbol) {\n const childSymbols = await child.getAllSymbols(t, true);\n result.push(...childSymbols);\n }\n }\n\n if (!localOnly) {\n if (this.parent instanceof ScopedSymbol) {\n const childSymbols = await this.getAllSymbols(t, true);\n result.push(...childSymbols);\n }\n }\n\n return result;\n }\n\n /**\n * @param name The name of the symbol to resolve.\n * @param localOnly If true only child symbols are returned, otherwise also symbols from the parent of this symbol\n * (recursively).\n * @returns the first symbol with a given name, in the order of appearance in this scope\n * or any of the parent scopes (conditionally).\n */\n public async resolve(name: string, localOnly = false): Promise<Symbol | undefined> {\n return new Promise((resolve, reject) => {\n for (const child of this.children) {\n if (child.name === name) {\n resolve(child);\n\n return;\n }\n }\n\n // Nothing found locally. Let the parent continue.\n if (!localOnly) {\n if (this.parent instanceof ScopedSymbol) {\n resolve(this.parent.resolve(name, false));\n\n return;\n }\n }\n\n resolve(undefined);\n });\n }\n\n /**\n * @param localOnly If true only child symbols are returned, otherwise also symbols from the parent of this symbol\n * (recursively).\n * @returns all accessible symbols that have a type assigned.\n */\n public getTypedSymbols(localOnly = true): TypedSymbol[] {\n const result: TypedSymbol[] = [];\n\n for (const child of this.children) {\n if (child instanceof TypedSymbol) {\n result.push(child);\n }\n }\n\n if (!localOnly) {\n if (this.parent instanceof ScopedSymbol) {\n const localList = this.parent.getTypedSymbols(true);\n result.push(...localList);\n }\n }\n\n return result;\n }\n\n /**\n * The names of all accessible symbols with a type.\n *\n * @param localOnly If true only child symbols are returned, otherwise also symbols from the parent of this symbol\n * (recursively).\n * @returns A list of names.\n */\n public getTypedSymbolNames(localOnly = true): string[] {\n const result: string[] = [];\n for (const child of this.children) {\n if (child instanceof TypedSymbol) {\n result.push(child.name);\n }\n }\n\n if (!localOnly) {\n if (this.parent instanceof ScopedSymbol) {\n const localList = (this.parent).getTypedSymbolNames(true);\n result.push(...localList);\n }\n }\n\n return result;\n }\n\n /**\n * @returns A promise resolving to all direct child symbols with a scope (e.g. classes in a module).\n */\n public get directScopes(): Promise<ScopedSymbol[]> {\n return this.getSymbolsOfType(ScopedSymbol);\n }\n\n /**\n * @returns the symbol located at the given path through the symbol hierarchy.\n * @param path The path consisting of symbol names separator by `separator`.\n * @param separator The character to separate path segments.\n */\n public symbolFromPath(path: string, separator = \".\"): Symbol | undefined {\n const elements = path.split(separator);\n let index = 0;\n if (elements[0] === this.name || elements[0].length === 0) {\n ++index;\n }\n\n // eslint-disable-next-line @typescript-eslint/no-this-alias\n let result: Symbol = this;\n while (index < elements.length) {\n if (!(result instanceof ScopedSymbol)) {\n return undefined;\n }\n\n // eslint-disable-next-line no-loop-func\n const child = result.children.find((candidate) => candidate.name === elements[index]);\n if (!child) {\n return undefined;\n }\n\n result = child;\n ++index;\n }\n\n return result;\n }\n\n /**\n * @param child The child to search for.\n * @returns the index of the given child symbol in the child list or -1 if it couldn't be found.\n */\n public indexOfChild(child: Symbol): number {\n return this.children.findIndex((value: Symbol, index: number) => value === child);\n }\n\n /**\n * @param child The reference node.\n * @returns the sibling symbol after the given child symbol, if one exists.\n */\n public nextSiblingOf(child: Symbol): Symbol | undefined {\n const index = this.indexOfChild(child);\n if (index === -1 || index >= this.children.length - 1) {\n return;\n }\n\n return this.children[index + 1];\n }\n\n /**\n * @param child The reference node.\n * @returns the sibling symbol before the given child symbol, if one exists.\n */\n public previousSiblingOf(child: Symbol): Symbol | undefined {\n const index = this.indexOfChild(child);\n if (index < 1) {\n return;\n }\n\n return this.children[index - 1];\n }\n\n public get firstChild(): Symbol | undefined {\n if (this.children.length > 0) {\n return this.children[0];\n }\n\n return undefined;\n }\n\n public get lastChild(): Symbol | undefined {\n if (this.children.length > 0) {\n return this.children[this.children.length - 1];\n }\n\n return undefined;\n }\n\n /**\n * @param child The reference node.\n * @returns the next symbol in definition order, regardless of the scope.\n */\n public nextOf(child: Symbol): Symbol | undefined {\n if (!(child.parent instanceof ScopedSymbol)) {\n return;\n }\n\n if (child.parent !== this) {\n return child.parent.nextOf(child);\n }\n\n if (child instanceof ScopedSymbol && child.children.length > 0) {\n return child.children[0];\n }\n\n const sibling = this.nextSiblingOf(child);\n if (sibling) {\n return sibling;\n }\n\n return (this.parent as ScopedSymbol).nextOf(this);\n }\n}\n\nexport class NamespaceSymbol extends ScopedSymbol {\n}\n\nexport class BlockSymbol extends ScopedSymbol {\n}\n\nexport class VariableSymbol extends TypedSymbol {\n\n public value: any;\n\n public constructor(name: string, value: any, type?: Type) {\n super(name, type);\n\n // eslint-disable-next-line @typescript-eslint/no-unsafe-assignment\n this.value = value;\n }\n}\n\nexport class LiteralSymbol extends TypedSymbol {\n public readonly value: any;\n\n public constructor(name: string, value: any, type?: Type) {\n super(name, type);\n\n // eslint-disable-next-line @typescript-eslint/no-unsafe-assignment\n this.value = value;\n }\n}\n\nexport class ParameterSymbol extends VariableSymbol { }\n\n// A standalone function/procedure/rule.\nexport class RoutineSymbol extends ScopedSymbol {\n private returnType?: Type; // Can be null if result is void.\n\n public constructor(name: string, returnType: Type) {\n super(name);\n this.returnType = returnType;\n }\n\n public getVariables(localOnly = true): Promise<VariableSymbol[]> {\n return this.getSymbolsOfType(VariableSymbol);\n }\n\n public getParameters(localOnly = true): Promise<ParameterSymbol[]> {\n return this.getSymbolsOfType(ParameterSymbol);\n }\n}\n\nexport enum MethodFlags {\n None = 0,\n Virtual = 1,\n Const = 2,\n Overwritten = 4,\n SetterOrGetter = 8, // Distinguished by the return type.\n Explicit = 16, // Special flag used e.g. in C++ for explicit c-tors.\n}\n\n// A routine which belongs to a class or other outer container structure.\nexport class MethodSymbol extends RoutineSymbol {\n public methodFlags = MethodFlags.None;\n public visibility = MemberVisibility.Invalid;\n}\n\nexport class FieldSymbol extends VariableSymbol {\n public visibility = MemberVisibility.Invalid;\n\n public setter?: MethodSymbol;\n public getter?: MethodSymbol;\n\n}\n\n// Classes and structs.\nexport class ClassSymbol extends ScopedSymbol implements Type {\n\n public get baseTypes(): Type[] { return this.superClasses; }\n public get kind(): TypeKind { return TypeKind.Class; }\n public get reference(): ReferenceKind { return this.referenceKind; }\n\n public isStruct = false;\n\n /**\n * Usually only one member, unless the language supports multiple inheritance.\n */\n public readonly superClasses: ClassSymbol[] = [];\n\n private referenceKind: ReferenceKind;\n\n public constructor(name: string, referenceKind: ReferenceKind, ...superClass: ClassSymbol[]) {\n super(name);\n this.referenceKind = referenceKind;\n this.superClasses.push(...superClass); // Standard case: a single super class.\n }\n\n /**\n * @param includeInherited Not used.\n * @returns a list of all methods.\n */\n public getMethods(includeInherited = false): Promise<MethodSymbol[]> {\n return this.getSymbolsOfType(MethodSymbol);\n }\n\n /**\n * @param includeInherited Not used.\n * @returns all fields.\n */\n public getFields(includeInherited = false): Promise<FieldSymbol[]> {\n return this.getSymbolsOfType(FieldSymbol);\n }\n\n}\n\nexport class ArrayType extends Symbol implements Type {\n\n public get baseTypes(): Type[] { return []; }\n public get kind(): TypeKind { return TypeKind.Array; }\n public get reference(): ReferenceKind { return this.referenceKind; }\n\n public readonly elementType: Type;\n public readonly size: number; // > 0 if fixed length.\n\n private referenceKind: ReferenceKind;\n\n public constructor(name: string, referenceKind: ReferenceKind, elemType: Type, size = 0) {\n super(name);\n this.referenceKind = referenceKind;\n this.elementType = elemType;\n this.size = size;\n }\n}\n\n// The main class managing all the symbols for a top level entity like a file, library or similar.\nexport class SymbolTable extends ScopedSymbol {\n // Other symbol information available to this instance.\n protected dependencies: Set<SymbolTable> = new Set();\n\n public constructor(name: string, public readonly options: SymbolTableOptions) {\n super(name);\n }\n\n public clear() {\n super.clear();\n this.dependencies.clear();\n }\n\n public addDependencies(...tables: SymbolTable[]) {\n tables.forEach((value, key) => {\n this.dependencies.add(value);\n });\n }\n\n public removeDependency(table: SymbolTable) {\n if (this.dependencies.has(table)) {\n this.dependencies.delete(table);\n }\n }\n\n /**\n * @returns instance information, mostly relevant for unit testing.\n */\n public get info() {\n return {\n dependencyCount: this.dependencies.size,\n symbolCount: this.children.length,\n };\n }\n\n public addNewSymbolOfType<T extends Symbol>(t: new (...args: any[]) => T,\n parent: ScopedSymbol | undefined, ...args: any[]): T {\n\n const result = new t(...args);\n if (!parent || parent === this) {\n this.addSymbol(result);\n } else {\n parent.addSymbol(result);\n }\n\n return result;\n }\n\n /**\n * Adds a new namespace to the symbol table or the given parent. The path parameter specifies a single namespace\n * name or a chain of namespaces (which can be e.g. \"outer.intermittent.inner.final\").\n * If any of the parent namespaces is missing they are created implicitly. The final part must not exist however\n * or you'll get a duplicate symbol error.\n *\n * @param parent The parent to add the namespace to.\n * @param path The namespace path.\n * @param delimiter The delimiter used in the path.\n * @returns The new symbol.\n */\n public async addNewNamespaceFromPath(parent: ScopedSymbol | undefined, path: string,\n delimiter = \".\"): Promise<NamespaceSymbol> {\n const parts = path.split(delimiter);\n let i = 0;\n let currentParent = (parent === undefined) ? this : parent;\n while (i < parts.length - 1) {\n let namespace = await currentParent.resolve(parts[i], true) as NamespaceSymbol;\n if (namespace === undefined) {\n namespace = this.addNewSymbolOfType(NamespaceSymbol, currentParent, parts[i]);\n }\n currentParent = namespace;\n ++i;\n }\n\n return this.addNewSymbolOfType(NamespaceSymbol, currentParent, parts[parts.length - 1]);\n }\n\n public async getAllSymbols(type?: typeof Symbol, localOnly = false): Promise<Symbol[]> {\n const result = await super.getAllSymbols(type ?? Symbol, localOnly);\n\n if (!localOnly) {\n const dependencyResults = await Promise.all([...this.dependencies].map((dependency) => (\n dependency.getAllSymbols(type, localOnly)\n )));\n\n dependencyResults.forEach((value) => {\n result.push(...value);\n });\n }\n\n return result;\n }\n\n /**\n * Looks for a symbol which is connected with a given parse tree context.\n *\n * @param context The context to search for.\n * @returns A promise resolving to the found symbol or undefined.\n */\n public async symbolWithContext(context: ParseTree): Promise<Symbol | undefined> {\n /**\n * Local function to find a symbol recursively.\n *\n * @param symbol The symbol to search through.\n * @returns The symbol with the given context, if found.\n */\n const findRecursive = (symbol: Symbol): Symbol | undefined => {\n if (symbol.context === context) {\n return symbol;\n }\n\n if (symbol instanceof ScopedSymbol) {\n for (const child of symbol.children) {\n const result = findRecursive(child);\n if (result) {\n return result;\n }\n }\n }\n };\n\n\n let symbols = await this.getAllSymbols(Symbol);\n for (const symbol of symbols) {\n const result = findRecursive(symbol);\n if (result) {\n return result;\n }\n }\n\n for (const dependency of this.dependencies) {\n symbols = await dependency.getAllSymbols(Symbol);\n for (const symbol of symbols) {\n const result = findRecursive(symbol);\n if (result) {\n result;\n }\n }\n }\n }\n\n /**\n * Resolves a name to a symbol.\n *\n * @param name The name of the symbol to find.\n * @param localOnly A flag indicating if only this symbol table should be used or also its dependencies.\n * @returns The found symbol or undefined.\n */\n public async resolve(name: string, localOnly = false): Promise<Symbol | undefined> {\n let result = await super.resolve(name, localOnly);\n if (!result && !localOnly) {\n for (const dependency of this.dependencies) {\n result = await dependency.resolve(name, false);\n if (result) {\n return result;\n }\n }\n }\n\n return result;\n }\n\n}\n"]} | ||
| {"version":3,"file":"SymbolTable.js","sourceRoot":"","sources":["../../src/SymbolTable.ts"],"names":[],"mappings":";;;;;;;;;;;;AAWA,MAAa,oBAAqB,SAAQ,KAAK;CAAI;AAAnD,oDAAmD;AAEnD,IAAY,gBAMX;AAND,WAAY,gBAAgB;IACxB,8DAAY,CAAA;IACZ,2DAAU,CAAA;IACV,iEAAS,CAAA;IACT,6DAAO,CAAA;IACP,6DAAO,CAAA;AACX,CAAC,EANW,gBAAgB,GAAhB,wBAAgB,KAAhB,wBAAgB,QAM3B;AAED,IAAY,QAUX;AAVD,WAAY,QAAQ;IAChB,6CAAO,CAAA;IACP,yCAAK,CAAA;IACL,2CAAM,CAAA;IACN,6CAAO,CAAA;IACP,uCAAI,CAAA;IAEJ,yCAAK,CAAA;IACL,yCAAK,CAAA;IACL,yCAAK,CAAA;AACT,CAAC,EAVW,QAAQ,GAAR,gBAAQ,KAAR,gBAAQ,QAUnB;AAED,IAAY,aAKX;AALD,WAAY,aAAa;IACrB,6D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ENSE file for more info.\n */\n\n/* eslint-disable max-classes-per-file */\n\nimport { ParseTree } from \"antlr4ts/tree/ParseTree\";\n\nexport class DuplicateSymbolError extends Error { }\n\nexport enum MemberVisibility {\n Invalid = -1,\n Public = 0,\n Protected,\n Private,\n Library,\n}\n\nexport enum TypeKind {\n Integer,\n Float,\n String,\n Boolean,\n Date,\n\n Class,\n Array,\n Alias,\n}\n\nexport enum ReferenceKind {\n Irrelevant,\n Pointer, // Default for most languages for dynamically allocated memory (\"Type*\" in C++).\n Reference, // \"Type&\" in C++\n Instance, // \"Type\" as such and default for all value types.\n}\n\n// The root type interface. Used for typed symbols and type aliases.\nexport interface Type {\n name: string;\n\n // The super type of this type or empty if this is a fundamental type.\n // Also used as the target type for type aliases.\n baseTypes: Type[];\n kind: TypeKind;\n reference: ReferenceKind;\n}\n\nexport interface SymbolTableOptions {\n allowDuplicateSymbols?: boolean;\n}\n\n// A single class for all fundamental types. They are distinguished via the kind field.\nexport class FundamentalType implements Type {\n public static readonly integerType = new FundamentalType(\"int\", TypeKind.Integer, ReferenceKind.Instance);\n public static readonly floatType = new FundamentalType(\"float\", TypeKind.Float, ReferenceKind.Instance);\n public static readonly stringType = new FundamentalType(\"string\", TypeKind.String, ReferenceKind.Instance);\n public static readonly boolType = new FundamentalType(\"bool\", TypeKind.Boolean, ReferenceKind.Instance);\n public static readonly dateType = new FundamentalType(\"date\", TypeKind.Date, ReferenceKind.Instance);\n\n public name: string;\n\n private typeKind: TypeKind;\n private referenceKind: ReferenceKind;\n\n public constructor(name: string, typeKind: TypeKind, referenceKind: ReferenceKind) {\n this.name = name;\n this.typeKind = typeKind;\n this.referenceKind = referenceKind;\n }\n\n public get baseTypes(): Type[] {\n return [];\n }\n\n public get kind(): TypeKind {\n return this.typeKind;\n }\n\n public get reference(): ReferenceKind {\n return this.referenceKind;\n }\n\n}\n\n// The root of the symbol table class hierarchy: a symbol can be any manageable entity (like a block), not only\n// things like variables or classes.\n// We are using a class hierarchy here, instead of an enum or similar, to allow for easy extension and certain\n// symbols can so provide additional APIs for simpler access to their sub elements, if needed.\nexport class Symbol {\n public name = \"\"; // The name of the scope or empty if anonymous.\n public context?: ParseTree; // Reference to the parse tree which contains this symbol.\n\n private theParent?: Symbol;\n\n public constructor(name = \"\") {\n this.name = name;\n }\n\n /**\n * The parent is usually a scoped symbol as only those can have children, but we allow\n * any symbol here for special scenarios.\n * This is rather an internal method and should rarely be used by external code.\n *\n * @param parent The new parent to use.\n */\n public setParent(parent: Symbol | undefined): void {\n this.theParent = parent;\n }\n\n public get parent(): Symbol | undefined {\n return this.theParent;\n }\n\n public get firstSibling(): Symbol {\n if (this.theParent instanceof ScopedSymbol) {\n return this.theParent.firstChild!;\n }\n\n return this;\n }\n\n /**\n * @returns the symbol before this symbol in its scope.\n */\n public get previousSibling(): Symbol | undefined {\n if (!(this.theParent instanceof ScopedSymbol)) {\n return this;\n }\n\n return this.theParent.previousSiblingOf(this);\n }\n\n /**\n * @returns the symbol following this symbol in its scope.\n */\n public get nextSibling(): Symbol | undefined {\n if (!(this.theParent instanceof ScopedSymbol)) {\n return this;\n }\n\n return this.theParent.nextSiblingOf(this);\n }\n\n public get lastSibling(): Symbol {\n if (this.theParent instanceof ScopedSymbol) {\n return this.theParent.lastChild!;\n }\n\n return this;\n }\n\n /**\n * @returns the next symbol in definition order, regardless of the scope.\n */\n public get next(): Symbol | undefined {\n if (this.theParent instanceof ScopedSymbol) {\n return this.theParent.nextOf(this);\n }\n\n return undefined;\n }\n\n public removeFromParent(): void {\n if (this.theParent instanceof ScopedSymbol) {\n this.theParent.removeSymbol(this);\n this.theParent = undefined;\n }\n }\n\n /**\n *\n * @param name The name of the symbol to find.\n * @param localOnly If true only child symbols are returned, otherwise also symbols from the parent of this symbol\n * (recursively).\n * @returns the first symbol with a given name, in the order of appearance in this scope\n * or any of the parent scopes (conditionally).\n */\n public async resolve(name: string, localOnly = false): Promise<Symbol | undefined> {\n if (this.theParent instanceof ScopedSymbol) {\n return this.theParent.resolve(name, localOnly);\n }\n\n return Promise.resolve(undefined);\n }\n\n /**\n * @returns the outermost entity (below the symbol table) that holds us.\n */\n public get root(): Symbol | undefined {\n let run = this.theParent;\n while (run) {\n if (!run.theParent || (run.theParent instanceof SymbolTable)) {\n return run;\n }\n run = run.theParent;\n }\n\n return run;\n }\n\n /**\n * @returns the symbol table we belong too or undefined if we are not yet assigned.\n */\n public get symbolTable(): SymbolTable | undefined {\n if (this instanceof SymbolTable) {\n return this;\n }\n\n let run = this.theParent;\n while (run) {\n if (run instanceof SymbolTable) { return run; }\n run = run.theParent;\n }\n\n return undefined;\n }\n\n /**\n * @param t The type of objects to return.\n * @returns the next enclosing parent of the given type.\n */\n public getParentOfType<T extends Symbol>(t: new (...args: any[]) => T): T | undefined {\n let run = this.theParent;\n while (run) {\n if (run instanceof t) { return run; }\n run = run.theParent;\n }\n\n return undefined;\n }\n\n /**\n * @returns the list of symbols from this one up to root.\n */\n public get symbolPath(): Symbol[] {\n const result: Symbol[] = [];\n\n // eslint-disable-next-line @typescript-eslint/no-this-alias\n let run: Symbol = this;\n while (run) {\n result.push(run);\n if (!run.theParent) { break; }\n run = run.theParent;\n }\n\n return result;\n }\n\n /**\n * Creates a qualified identifier from this symbol and its parent.\n * If `full` is true then all parents are traversed in addition to this instance.\n *\n * @param separator The string to be used between the parts.\n * @param full A flag indicating if the full path is to be returned.\n * @param includeAnonymous Use a special string for empty scope names.\n * @returns the constructed qualified identifier.\n */\n public qualifiedName(separator = \".\", full = false, includeAnonymous = false): string {\n if (!includeAnonymous && this.name.length === 0) {\n return \"\";\n }\n\n let result: string = this.name.length === 0 ? \"<anonymous>\" : this.name;\n let run = this.theParent;\n while (run) {\n if (includeAnonymous || run.name.length > 0) {\n result = (run.name.length === 0 ? \"<anonymous>\" : run.name) + separator + result;\n }\n\n if (!full || !run.theParent) {\n break;\n }\n run = run.theParent;\n }\n\n return result;\n }\n\n}\n\n// A symbol with an attached type (variables, fields etc.).\nexport class TypedSymbol extends Symbol {\n public type: Type | undefined;\n\n public constructor(name: string, type?: Type) {\n super(name);\n this.type = type;\n }\n}\n\n// An alias for another type.\nexport class TypeAlias extends Symbol implements Type {\n public get baseTypes(): Type[] { return [this.targetType]; }\n public get kind(): TypeKind { return TypeKind.Alias; }\n public get reference(): ReferenceKind { return ReferenceKind.Irrelevant; }\n\n private targetType: Type;\n\n public constructor(name: string, target: Type) {\n super(name);\n this.targetType = target;\n }\n}\n\n// A symbol with a scope (so it can have child symbols).\nexport class ScopedSymbol extends Symbol {\n\n private _children: Symbol[] = []; // All child symbols in definition order.\n\n public constructor(name = \"\") {\n super(name);\n }\n\n public get children(): Symbol[] {\n // eslint-disable-next-line no-underscore-dangle\n return this._children;\n }\n\n public clear(): void {\n // eslint-disable-next-line no-underscore-dangle\n this._children = [];\n }\n\n /**\n * Adds the given symbol to this scope. If it belongs already to a different scope\n * it is removed from that before adding it here.\n *\n * @param symbol The symbol to add as a child.\n */\n public addSymbol(symbol: Symbol): void {\n symbol.removeFromParent();\n\n // Check for duplicates first.\n const symbolTable = this.symbolTable;\n if (!symbolTable || !symbolTable.options.allowDuplicateSymbols) {\n this.children.forEach((child) => {\n if (child === symbol || (symbol.name.length > 0 && child.name === symbol.name)) {\n let name = symbol.name;\n if (name.length === 0) {\n name = \"<anonymous>\";\n }\n\n throw new DuplicateSymbolError(\"Attempt to add duplicate symbol '\" + name + \"'\");\n }\n });\n }\n\n this.children.push(symbol);\n symbol.setParent(this);\n }\n\n public removeSymbol(symbol: Symbol): void {\n const index = this.children.indexOf(symbol);\n if (index > -1) {\n this.children.splice(index, 1);\n symbol.setParent(undefined);\n }\n }\n\n /**\n * @param t The type of of the objects to return.\n * @returns A promise resolving to all (nested) children of the given type.\n */\n public async getNestedSymbolsOfType<T extends Symbol>(t: new (...args: any[]) => T): Promise<T[]> {\n const result: T[] = [];\n\n const childPromises: Array<Promise<T[]>> = [];\n this.children.forEach((child) => {\n if (child instanceof t) {\n result.push(child);\n }\n\n if (child instanceof ScopedSymbol) {\n childPromises.push(child.getNestedSymbolsOfType(t));\n }\n });\n const childSymbols = await Promise.all(childPromises);\n childSymbols.forEach((entry) => {\n result.push(...entry);\n });\n\n return result;\n }\n\n /**\n * @param name If given only returns symbols with that name.\n * @returns A promise resolving to symbols from this and all nested scopes in the order they were defined.\n */\n public async getAllNestedSymbols(name?: string): Promise<Symbol[]> {\n const result: Symbol[] = [];\n\n const childPromises: Array<Promise<Symbol[]>> = [];\n this.children.forEach((child) => {\n if (!name || child.name === name) {\n result.push(child);\n }\n\n if (child instanceof ScopedSymbol) {\n childPromises.push(child.getAllNestedSymbols(name));\n }\n });\n const childSymbols = await Promise.all(childPromises);\n childSymbols.forEach((entry) => {\n result.push(...entry);\n });\n\n return result;\n }\n\n /**\n * @param t The type of of the objects to return.\n * @returns A promise resolving to direct children of a given type.\n */\n public getSymbolsOfType<T extends Symbol>(t: new (...args: any[]) => T): Promise<T[]> {\n return new Promise((resolve) => {\n const result: T[] = [];\n this.children.forEach((child) => {\n if (child instanceof t) {\n result.push(child);\n }\n });\n\n resolve(result);\n });\n }\n\n /**\n * TODO: add optional position dependency (only symbols defined before a given caret pos are viable).\n *\n * @param t The type of the objects to return.\n * @param localOnly If true only child symbols are returned, otherwise also symbols from the parent of this symbol\n * (recursively).\n * @returns A promise resolving to all symbols of the the given type, accessible from this scope (if localOnly is\n * false), within the owning symbol table.\n */\n public async getAllSymbols<T extends Symbol>(t: new (...args: any[]) => T,\n localOnly = false): Promise<Symbol[]> {\n const result: Symbol[] = [];\n\n // Special handling for namespaces, which act like grouping symbols in this scope,\n // so we show them as available in this scope.\n for (const child of this.children) {\n if (child instanceof t) {\n result.push(child);\n }\n\n if (child instanceof NamespaceSymbol) {\n const childSymbols = await child.getAllSymbols(t, true);\n result.push(...childSymbols);\n }\n }\n\n if (!localOnly) {\n if (this.parent instanceof ScopedSymbol) {\n const childSymbols = await this.getAllSymbols(t, true);\n result.push(...childSymbols);\n }\n }\n\n return result;\n }\n\n /**\n * @param name The name of the symbol to resolve.\n * @param localOnly If true only child symbols are returned, otherwise also symbols from the parent of this symbol\n * (recursively).\n * @returns the first symbol with a given name, in the order of appearance in this scope\n * or any of the parent scopes (conditionally).\n */\n public async resolve(name: string, localOnly = false): Promise<Symbol | undefined> {\n return new Promise((resolve, reject) => {\n for (const child of this.children) {\n if (child.name === name) {\n resolve(child);\n\n return;\n }\n }\n\n // Nothing found locally. Let the parent continue.\n if (!localOnly) {\n if (this.parent instanceof ScopedSymbol) {\n resolve(this.parent.resolve(name, false));\n\n return;\n }\n }\n\n resolve(undefined);\n });\n }\n\n /**\n * @param localOnly If true only child symbols are returned, otherwise also symbols from the parent of this symbol\n * (recursively).\n * @returns all accessible symbols that have a type assigned.\n */\n public getTypedSymbols(localOnly = true): TypedSymbol[] {\n const result: TypedSymbol[] = [];\n\n for (const child of this.children) {\n if (child instanceof TypedSymbol) {\n result.push(child);\n }\n }\n\n if (!localOnly) {\n if (this.parent instanceof ScopedSymbol) {\n const localList = this.parent.getTypedSymbols(true);\n result.push(...localList);\n }\n }\n\n return result;\n }\n\n /**\n * The names of all accessible symbols with a type.\n *\n * @param localOnly If true only child symbols are returned, otherwise also symbols from the parent of this symbol\n * (recursively).\n * @returns A list of names.\n */\n public getTypedSymbolNames(localOnly = true): string[] {\n const result: string[] = [];\n for (const child of this.children) {\n if (child instanceof TypedSymbol) {\n result.push(child.name);\n }\n }\n\n if (!localOnly) {\n if (this.parent instanceof ScopedSymbol) {\n const localList = (this.parent).getTypedSymbolNames(true);\n result.push(...localList);\n }\n }\n\n return result;\n }\n\n /**\n * @returns A promise resolving to all direct child symbols with a scope (e.g. classes in a module).\n */\n public get directScopes(): Promise<ScopedSymbol[]> {\n return this.getSymbolsOfType(ScopedSymbol);\n }\n\n /**\n * @returns the symbol located at the given path through the symbol hierarchy.\n * @param path The path consisting of symbol names separator by `separator`.\n * @param separator The character to separate path segments.\n */\n public symbolFromPath(path: string, separator = \".\"): Symbol | undefined {\n const elements = path.split(separator);\n let index = 0;\n if (elements[0] === this.name || elements[0].length === 0) {\n ++index;\n }\n\n // eslint-disable-next-line @typescript-eslint/no-this-alias\n let result: Symbol = this;\n while (index < elements.length) {\n if (!(result instanceof ScopedSymbol)) {\n return undefined;\n }\n\n // eslint-disable-next-line no-loop-func\n const child = result.children.find((candidate) => candidate.name === elements[index]);\n if (!child) {\n return undefined;\n }\n\n result = child;\n ++index;\n }\n\n return result;\n }\n\n /**\n * @param child The child to search for.\n * @returns the index of the given child symbol in the child list or -1 if it couldn't be found.\n */\n public indexOfChild(child: Symbol): number {\n return this.children.findIndex((value: Symbol, index: number) => value === child);\n }\n\n /**\n * @param child The reference node.\n * @returns the sibling symbol after the given child symbol, if one exists.\n */\n public nextSiblingOf(child: Symbol): Symbol | undefined {\n const index = this.indexOfChild(child);\n if (index === -1 || index >= this.children.length - 1) {\n return;\n }\n\n return this.children[index + 1];\n }\n\n /**\n * @param child The reference node.\n * @returns the sibling symbol before the given child symbol, if one exists.\n */\n public previousSiblingOf(child: Symbol): Symbol | undefined {\n const index = this.indexOfChild(child);\n if (index < 1) {\n return;\n }\n\n return this.children[index - 1];\n }\n\n public get firstChild(): Symbol | undefined {\n if (this.children.length > 0) {\n return this.children[0];\n }\n\n return undefined;\n }\n\n public get lastChild(): Symbol | undefined {\n if (this.children.length > 0) {\n return this.children[this.children.length - 1];\n }\n\n return undefined;\n }\n\n /**\n * @param child The reference node.\n * @returns the next symbol in definition order, regardless of the scope.\n */\n public nextOf(child: Symbol): Symbol | undefined {\n if (!(child.parent instanceof ScopedSymbol)) {\n return;\n }\n\n if (child.parent !== this) {\n return child.parent.nextOf(child);\n }\n\n if (child instanceof ScopedSymbol && child.children.length > 0) {\n return child.children[0];\n }\n\n const sibling = this.nextSiblingOf(child);\n if (sibling) {\n return sibling;\n }\n\n return (this.parent as ScopedSymbol).nextOf(this);\n }\n}\n\nexport class NamespaceSymbol extends ScopedSymbol {\n}\n\nexport class BlockSymbol extends ScopedSymbol {\n}\n\nexport class VariableSymbol extends TypedSymbol {\n\n public value: any;\n\n public constructor(name: string, value: any, type?: Type) {\n super(name, type);\n\n // eslint-disable-next-line @typescript-eslint/no-unsafe-assignment\n this.value = value;\n }\n}\n\nexport class LiteralSymbol extends TypedSymbol {\n public readonly value: any;\n\n public constructor(name: string, value: any, type?: Type) {\n super(name, type);\n\n // eslint-disable-next-line @typescript-eslint/no-unsafe-assignment\n this.value = value;\n }\n}\n\nexport class ParameterSymbol extends VariableSymbol { }\n\n// A standalone function/procedure/rule.\nexport class RoutineSymbol extends ScopedSymbol {\n private returnType?: Type; // Can be null if result is void.\n\n public constructor(name: string, returnType: Type) {\n super(name);\n this.returnType = returnType;\n }\n\n public getVariables(localOnly = true): Promise<VariableSymbol[]> {\n return this.getSymbolsOfType(VariableSymbol);\n }\n\n public getParameters(localOnly = true): Promise<ParameterSymbol[]> {\n return this.getSymbolsOfType(ParameterSymbol);\n }\n}\n\nexport enum MethodFlags {\n None = 0,\n Virtual = 1,\n Const = 2,\n Overwritten = 4,\n SetterOrGetter = 8, // Distinguished by the return type.\n Explicit = 16, // Special flag used e.g. in C++ for explicit c-tors.\n}\n\n// A routine which belongs to a class or other outer container structure.\nexport class MethodSymbol extends RoutineSymbol {\n public methodFlags = MethodFlags.None;\n public visibility = MemberVisibility.Invalid;\n}\n\nexport class FieldSymbol extends VariableSymbol {\n public visibility = MemberVisibility.Invalid;\n\n public setter?: MethodSymbol;\n public getter?: MethodSymbol;\n\n}\n\n// Classes and structs.\nexport class ClassSymbol extends ScopedSymbol implements Type {\n\n public get baseTypes(): Type[] { return this.superClasses; }\n public get kind(): TypeKind { return TypeKind.Class; }\n public get reference(): ReferenceKind { return this.referenceKind; }\n\n public isStruct = false;\n\n /**\n * Usually only one member, unless the language supports multiple inheritance.\n */\n public readonly superClasses: ClassSymbol[] = [];\n\n private referenceKind: ReferenceKind;\n\n public constructor(name: string, referenceKind: ReferenceKind, ...superClass: ClassSymbol[]) {\n super(name);\n this.referenceKind = referenceKind;\n this.superClasses.push(...superClass); // Standard case: a single super class.\n }\n\n /**\n * @param includeInherited Not used.\n * @returns a list of all methods.\n */\n public getMethods(includeInherited = false): Promise<MethodSymbol[]> {\n return this.getSymbolsOfType(MethodSymbol);\n }\n\n /**\n * @param includeInherited Not used.\n * @returns all fields.\n */\n public getFields(includeInherited = false): Promise<FieldSymbol[]> {\n return this.getSymbolsOfType(FieldSymbol);\n }\n\n}\n\nexport class ArrayType extends Symbol implements Type {\n\n public get baseTypes(): Type[] { return []; }\n public get kind(): TypeKind { return TypeKind.Array; }\n public get reference(): ReferenceKind { return this.referenceKind; }\n\n public readonly elementType: Type;\n public readonly size: number; // > 0 if fixed length.\n\n private referenceKind: ReferenceKind;\n\n public constructor(name: string, referenceKind: ReferenceKind, elemType: Type, size = 0) {\n super(name);\n this.referenceKind = referenceKind;\n this.elementType = elemType;\n this.size = size;\n }\n}\n\n// The main class managing all the symbols for a top level entity like a file, library or similar.\nexport class SymbolTable extends ScopedSymbol {\n // Other symbol information available to this instance.\n protected dependencies: Set<SymbolTable> = new Set();\n\n public constructor(name: string, public readonly options: SymbolTableOptions) {\n super(name);\n }\n\n public clear() {\n super.clear();\n this.dependencies.clear();\n }\n\n public addDependencies(...tables: SymbolTable[]) {\n tables.forEach((value, key) => {\n this.dependencies.add(value);\n });\n }\n\n public removeDependency(table: SymbolTable) {\n if (this.dependencies.has(table)) {\n this.dependencies.delete(table);\n }\n }\n\n /**\n * @returns instance information, mostly relevant for unit testing.\n */\n public get info() {\n return {\n dependencyCount: this.dependencies.size,\n symbolCount: this.children.length,\n };\n }\n\n public addNewSymbolOfType<T extends Symbol>(t: new (...args: any[]) => T,\n parent: ScopedSymbol | undefined, ...args: any[]): T {\n\n const result = new t(...args);\n if (!parent || parent === this) {\n this.addSymbol(result);\n } else {\n parent.addSymbol(result);\n }\n\n return result;\n }\n\n /**\n * Adds a new namespace to the symbol table or the given parent. The path parameter specifies a single namespace\n * name or a chain of namespaces (which can be e.g. \"outer.intermittent.inner.final\").\n * If any of the parent namespaces is missing they are created implicitly. The final part must not exist however\n * or you'll get a duplicate symbol error.\n *\n * @param parent The parent to add the namespace to.\n * @param path The namespace path.\n * @param delimiter The delimiter used in the path.\n * @returns The new symbol.\n */\n public async addNewNamespaceFromPath(parent: ScopedSymbol | undefined, path: string,\n delimiter = \".\"): Promise<NamespaceSymbol> {\n const parts = path.split(delimiter);\n let i = 0;\n let currentParent = (parent === undefined) ? this : parent;\n while (i < parts.length - 1) {\n let namespace = await currentParent.resolve(parts[i], true) as NamespaceSymbol;\n if (namespace === undefined) {\n namespace = this.addNewSymbolOfType(NamespaceSymbol, currentParent, parts[i]);\n }\n currentParent = namespace;\n ++i;\n }\n\n return this.addNewSymbolOfType(NamespaceSymbol, currentParent, parts[parts.length - 1]);\n }\n\n public async getAllSymbols<T extends Symbol>(t?: new (...args: any[]) => T, localOnly = false): Promise<Symbol[]> {\n const result = await super.getAllSymbols(t ?? Symbol, localOnly);\n\n if (!localOnly) {\n const dependencyResults = await Promise.all([...this.dependencies].map((dependency) => (\n dependency.getAllSymbols(t, localOnly)\n )));\n\n dependencyResults.forEach((value) => {\n result.push(...value);\n });\n }\n\n return result;\n }\n\n /**\n * Looks for a symbol which is connected with a given parse tree context.\n *\n * @param context The context to search for.\n * @returns A promise resolving to the found symbol or undefined.\n */\n public async symbolWithContext(context: ParseTree): Promise<Symbol | undefined> {\n /**\n * Local function to find a symbol recursively.\n *\n * @param symbol The symbol to search through.\n * @returns The symbol with the given context, if found.\n */\n const findRecursive = (symbol: Symbol): Symbol | undefined => {\n if (symbol.context === context) {\n return symbol;\n }\n\n if (symbol instanceof ScopedSymbol) {\n for (const child of symbol.children) {\n const result = findRecursive(child);\n if (result) {\n return result;\n }\n }\n }\n };\n\n\n let symbols = await this.getAllSymbols(Symbol);\n for (const symbol of symbols) {\n const result = findRecursive(symbol);\n if (result) {\n return result;\n }\n }\n\n for (const dependency of this.dependencies) {\n symbols = await dependency.getAllSymbols(Symbol);\n for (const symbol of symbols) {\n const result = findRecursive(symbol);\n if (result) {\n result;\n }\n }\n }\n }\n\n /**\n * Resolves a name to a symbol.\n *\n * @param name The name of the symbol to find.\n * @param localOnly A flag indicating if only this symbol table should be used or also its dependencies.\n * @returns The found symbol or undefined.\n */\n public async resolve(name: string, localOnly = false): Promise<Symbol | undefined> {\n let result = await super.resolve(name, localOnly);\n if (!result && !localOnly) {\n for (const dependency of this.dependencies) {\n result = await dependency.resolve(name, false);\n if (result) {\n return result;\n }\n }\n }\n\n return result;\n }\n\n}\n"]} |
+1
-1
| { | ||
| "name": "antlr4-c3", | ||
| "version": "2.0.0", | ||
| "version": "2.0.1", | ||
| "description": "A code completion core implementation for ANTLR4 based parsers", | ||
@@ -5,0 +5,0 @@ "main": "out/index.js", |
+1
-1
@@ -216,3 +216,3 @@ [](https://nodei.co/npm/antlr4-c3/) | ||
| ### 2.0.0 | ||
| ### 2.0.1 | ||
| - Breaking change: some of the methods in the symbol table implementation, which may require extra work return now promises (symbol collections and resolver methods). This allows also to override them and return asynchronous results which are constructed from external resources (like database symbols). | ||
@@ -219,0 +219,0 @@ |
Uses eval
Supply chain riskPackage uses dynamic code execution (e.g., eval()), which is a dangerous practice. This can prevent the code from running in certain environments and increases the risk that the code may contain exploits or malicious behavior.
Found 1 instance in 1 package
Uses eval
Supply chain riskPackage uses dynamic code execution (e.g., eval()), which is a dangerous practice. This can prevent the code from running in certain environments and increases the risk that the code may contain exploits or malicious behavior.
Found 1 instance in 1 package
210425
0.02%