Compare commits
15 commits
main
...
useLessNod
Author | SHA1 | Date | |
---|---|---|---|
b7d31bcd69 | |||
e23710aae5 | |||
d42b2b708d | |||
083db3a677 | |||
cc3836911f | |||
ced38f315e | |||
f9d2db3540 | |||
6a7d2c0a3e | |||
41faf73bfc | |||
5479adffc3 | |||
6f76b625a1 | |||
ca13132e84 | |||
e64dbabab8 | |||
044de3ec63 | |||
e83d14434d |
|
@ -278,20 +278,22 @@ namespace ts {
|
|||
}
|
||||
|
||||
export function getNodeId(node: Node): number {
|
||||
if (!node.id) {
|
||||
node.id = nextNodeId;
|
||||
let id = node.id;
|
||||
if (!id) {
|
||||
node.id = id = nextNodeId;
|
||||
nextNodeId++;
|
||||
}
|
||||
return node.id;
|
||||
return id;
|
||||
}
|
||||
|
||||
export function getSymbolId(symbol: Symbol): SymbolId {
|
||||
if (!symbol.id) {
|
||||
symbol.id = nextSymbolId;
|
||||
let id = symbol.id;
|
||||
if (!id) {
|
||||
symbol.id = id = nextSymbolId;
|
||||
nextSymbolId++;
|
||||
}
|
||||
|
||||
return symbol.id;
|
||||
return id;
|
||||
}
|
||||
|
||||
export function isInstantiatedModule(node: ModuleDeclaration, preserveConstEnums: boolean) {
|
||||
|
@ -3885,10 +3887,9 @@ namespace ts {
|
|||
|
||||
function getAlternativeContainingModules(symbol: Symbol, enclosingDeclaration: Node): Symbol[] {
|
||||
const containingFile = getSourceFileOfNode(enclosingDeclaration);
|
||||
const id = getNodeId(containingFile);
|
||||
const links = getSymbolLinks(symbol);
|
||||
let results: Symbol[] | undefined;
|
||||
if (links.extendedContainersByFile && (results = links.extendedContainersByFile.get(id))) {
|
||||
if (links.extendedContainersByFile && (results = links.extendedContainersByFile.get(containingFile))) {
|
||||
return results;
|
||||
}
|
||||
if (containingFile && containingFile.imports) {
|
||||
|
@ -3902,7 +3903,7 @@ namespace ts {
|
|||
results = append(results, resolvedModule);
|
||||
}
|
||||
if (length(results)) {
|
||||
(links.extendedContainersByFile || (links.extendedContainersByFile = new Map())).set(id, results!);
|
||||
(links.extendedContainersByFile ||= new Map()).set(containingFile, results!);
|
||||
return results!;
|
||||
}
|
||||
}
|
||||
|
@ -33794,7 +33795,7 @@ namespace ts {
|
|||
const type = checkExpression(node);
|
||||
// If control flow analysis was required to determine the type, it is worth caching.
|
||||
if (flowInvocationCount !== startInvocationCount) {
|
||||
const cache = flowTypeCache || (flowTypeCache = []);
|
||||
const cache = (flowTypeCache ||= []);
|
||||
cache[getNodeId(node)] = type;
|
||||
setNodeFlags(node, node.flags | NodeFlags.TypeCached);
|
||||
}
|
||||
|
@ -40316,9 +40317,8 @@ namespace ts {
|
|||
const enclosingFile = getSourceFileOfNode(node);
|
||||
const links = getNodeLinks(enclosingFile);
|
||||
if (!(links.flags & NodeCheckFlags.TypeChecked)) {
|
||||
links.deferredNodes = links.deferredNodes || new Map();
|
||||
const id = getNodeId(node);
|
||||
links.deferredNodes.set(id, node);
|
||||
links.deferredNodes ||= [];
|
||||
links.deferredNodes[getNodeId(node)] = node;
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -4900,7 +4900,7 @@ namespace ts {
|
|||
members?: SymbolTable; // Class, interface or object literal instance members
|
||||
exports?: SymbolTable; // Module exports
|
||||
globalExports?: SymbolTable; // Conditional global UMD exports
|
||||
/* @internal */ id?: SymbolId; // Unique id (used to look up SymbolLinks)
|
||||
/* @internal */ id: SymbolId; // Unique id (used to look up SymbolLinks)
|
||||
/* @internal */ mergeId?: number; // Merge id (used to look up merged symbol)
|
||||
/* @internal */ parent?: Symbol; // Parent symbol
|
||||
/* @internal */ exportSymbol?: Symbol; // Exported symbol associated with this symbol
|
||||
|
@ -4946,7 +4946,7 @@ namespace ts {
|
|||
lateSymbol?: Symbol; // Late-bound symbol for a computed property
|
||||
specifierCache?: ESMap<string, string>; // For symbols corresponding to external modules, a cache of incoming path -> module specifier name mappings
|
||||
extendedContainers?: Symbol[]; // Containers (other than the parent) which this symbol is aliased in
|
||||
extendedContainersByFile?: ESMap<NodeId, Symbol[]>; // Containers (other than the parent) which this symbol is aliased in
|
||||
extendedContainersByFile?: ESMap<Node, Symbol[]>; // Containers (other than the parent) which this symbol is aliased in
|
||||
variances?: VarianceFlags[]; // Alias symbol type argument variance cache
|
||||
deferralConstituents?: Type[]; // Calculated list of constituents for a deferred type
|
||||
deferralParent?: Type; // Source union/intersection of a deferred type
|
||||
|
@ -5106,7 +5106,7 @@ namespace ts {
|
|||
jsxNamespace?: Symbol | false; // Resolved jsx namespace symbol for this node
|
||||
jsxImplicitImportContainer?: Symbol | false; // Resolved module symbol the implicit jsx import of this file should refer to
|
||||
contextFreeType?: Type; // Cached context-free type used by the first pass of inference; used when a function's return is partially contextually sensitive
|
||||
deferredNodes?: ESMap<NodeId, Node>; // Set of nodes whose checking has been deferred
|
||||
deferredNodes?: Node[]; // Sparse array of nodes whose checking has been deferred
|
||||
capturedBlockScopeBindings?: Symbol[]; // Block-scoped bindings captured beneath this part of an IterationStatement
|
||||
outerTypeParameters?: TypeParameter[]; // Outer type parameters of anonymous object type
|
||||
isExhaustive?: boolean; // Is node an exhaustive switch statement
|
||||
|
|
|
@ -5798,7 +5798,7 @@ namespace ts {
|
|||
this.escapedName = name;
|
||||
this.declarations = undefined;
|
||||
this.valueDeclaration = undefined;
|
||||
this.id = undefined;
|
||||
this.id = 0;
|
||||
this.mergeId = undefined;
|
||||
this.parent = undefined;
|
||||
}
|
||||
|
|
|
@ -1597,7 +1597,7 @@ namespace ts.refactor.extractSymbol {
|
|||
const functionErrorsPerScope: Diagnostic[][] = [];
|
||||
const constantErrorsPerScope: Diagnostic[][] = [];
|
||||
const visibleDeclarationsInExtractedRange: NamedDeclaration[] = [];
|
||||
const exposedVariableSymbolSet = new Map<string, true>(); // Key is symbol ID
|
||||
const exposedVariableSymbolSet = new Set<Symbol>(); // Key is symbol ID
|
||||
const exposedVariableDeclarations: VariableDeclaration[] = [];
|
||||
let firstExposedNonVariableDeclaration: NamedDeclaration | undefined;
|
||||
|
||||
|
@ -1903,10 +1903,10 @@ namespace ts.refactor.extractSymbol {
|
|||
const decl = find(visibleDeclarationsInExtractedRange, d => d.symbol === sym);
|
||||
if (decl) {
|
||||
if (isVariableDeclaration(decl)) {
|
||||
const idString = decl.symbol.id!.toString();
|
||||
if (!exposedVariableSymbolSet.has(idString)) {
|
||||
const declSymbol = decl.symbol;
|
||||
if (!exposedVariableSymbolSet.has(declSymbol)) {
|
||||
exposedVariableDeclarations.push(decl);
|
||||
exposedVariableSymbolSet.set(idString, true);
|
||||
exposedVariableSymbolSet.add(declSymbol);
|
||||
}
|
||||
}
|
||||
else {
|
||||
|
|
|
@ -287,6 +287,7 @@ namespace ts {
|
|||
|
||||
class SymbolObject implements Symbol {
|
||||
flags: SymbolFlags;
|
||||
id = 0;
|
||||
escapedName: __String;
|
||||
declarations!: Declaration[];
|
||||
valueDeclaration!: Declaration;
|
||||
|
|
Loading…
Reference in a new issue