mirror of
https://github.com/microsoft/TypeScript.git
synced 2026-03-16 14:40:50 -05:00
Use NodeFlags to detect nodes in ambient contexts instead of climbing ancestors (#17831)
* Use NodeFlags to detect nodes in ambient contexts instead of climbing ancestors * Set context flags on tokens * Remove 'isDeclarationFile' parameter to 'initializeState' and move to 'parseSourceFileWorker' * Changes based on code review * Update API baselines
This commit is contained in:
@@ -31,7 +31,7 @@ namespace ts.BreakpointResolver {
|
||||
}
|
||||
|
||||
// Cannot set breakpoint in ambient declarations
|
||||
if (isInAmbientContext(tokenAtLocation)) {
|
||||
if (tokenAtLocation.flags & NodeFlags.Ambient) {
|
||||
return undefined;
|
||||
}
|
||||
|
||||
|
||||
@@ -335,7 +335,7 @@ namespace ts.refactor.extractSymbol {
|
||||
return [createDiagnosticForNode(nodeToCheck, Messages.StatementOrExpressionExpected)];
|
||||
}
|
||||
|
||||
if (isInAmbientContext(nodeToCheck)) {
|
||||
if (nodeToCheck.flags & NodeFlags.Ambient) {
|
||||
return [createDiagnosticForNode(nodeToCheck, Messages.CannotExtractAmbientBlock)];
|
||||
}
|
||||
|
||||
|
||||
@@ -41,6 +41,7 @@ namespace ts {
|
||||
kind === SyntaxKind.Identifier ? new IdentifierObject(SyntaxKind.Identifier, pos, end) :
|
||||
new TokenObject(kind, pos, end);
|
||||
node.parent = parent;
|
||||
node.flags = parent.flags & NodeFlags.ContextFlags;
|
||||
return node;
|
||||
}
|
||||
|
||||
|
||||
@@ -947,7 +947,7 @@ namespace ts {
|
||||
if (flags & ModifierFlags.Static) result.push(ScriptElementKindModifier.staticModifier);
|
||||
if (flags & ModifierFlags.Abstract) result.push(ScriptElementKindModifier.abstractModifier);
|
||||
if (flags & ModifierFlags.Export) result.push(ScriptElementKindModifier.exportedModifier);
|
||||
if (isInAmbientContext(node)) result.push(ScriptElementKindModifier.ambientModifier);
|
||||
if (node.flags & NodeFlags.Ambient) result.push(ScriptElementKindModifier.ambientModifier);
|
||||
|
||||
return result.length > 0 ? result.join(",") : ScriptElementKindModifier.none;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user