Press n or j to go to the next uncovered block, b, p or k for the previous block.
| 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 | 53x 71x 8x 8x | /**
* Utility functions for building dot-path identifiers for symbols.
* Used by parseWithSymbols and parseCHeader to generate unique symbol IDs.
*/
/**
* Get the parentId for a symbol or scope, given the path of its enclosing scope.
* Returns undefined for top-level symbols.
*
* The one place the symbol model's `""` (no enclosing scope) is translated into
* the `ISymbolInfo` API's `undefined`. The two spellings mean the same thing and
* neither side should learn the other's.
*
* @example
* getParentId("LED") // => "LED"
* getParentId("Teensy4.GPIO7") // => "Teensy4.GPIO7"
* getParentId("") // => undefined (global scope)
*/
function getParentId(scopePath: string): string | undefined {
return scopePath === "" ? undefined : scopePath;
}
/**
* Build a simple dot-path from parent and name.
* Used for C headers where there's no scope chain.
*
* @example
* buildSimpleDotPath("Color", "RED") // => "Color.RED"
* buildSimpleDotPath(undefined, "myFunc") // => "myFunc"
*/
function buildSimpleDotPath(parent: string | undefined, name: string): string {
return parent ? `${parent}.${name}` : name;
}
/**
* #1298 removed `buildScopePath` and `getDotPathId` from this file. Both walked
* a scope's parent chain to rebuild a dotted path -- a third encoder for it,
* beside `ScopeUtils.getTranspiledCName` and the one on `QualifiedCName`, and
* the only one that carried its own ad-hoc cycle guard (`current !== current.parent`).
*
* Neither has anything left to compute. A symbol's dotted path IS
* `cnxScopedName`, computed once at construction; a scope's own path is the same
* field, reachable as `ScopeUtils.pathOf(scope)`.
*/
class SymbolPathUtils {
static readonly getParentId = getParentId;
static readonly buildSimpleDotPath = buildSimpleDotPath;
}
export default SymbolPathUtils;
|