@zzzen/pyright-internal 1.2.0-dev.20261108 → 1.2.0-dev.20261122
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/analyzer/binder.d.ts +2 -0
- package/dist/analyzer/binder.js +238 -18
- package/dist/analyzer/binder.js.map +1 -1
- package/dist/analyzer/codeFlowEngine.js +28 -3
- package/dist/analyzer/codeFlowEngine.js.map +1 -1
- package/dist/analyzer/constructors.d.ts +1 -1
- package/dist/analyzer/constructors.js +68 -9
- package/dist/analyzer/constructors.js.map +1 -1
- package/dist/analyzer/enums.d.ts +10 -3
- package/dist/analyzer/enums.js +389 -2
- package/dist/analyzer/enums.js.map +1 -1
- package/dist/analyzer/operations.js +81 -4
- package/dist/analyzer/operations.js.map +1 -1
- package/dist/analyzer/parseTreeUtils.js +9 -1
- package/dist/analyzer/parseTreeUtils.js.map +1 -1
- package/dist/analyzer/patternMatching.js +12 -3
- package/dist/analyzer/patternMatching.js.map +1 -1
- package/dist/analyzer/protocols.d.ts +1 -0
- package/dist/analyzer/protocols.js +171 -10
- package/dist/analyzer/protocols.js.map +1 -1
- package/dist/analyzer/scope.d.ts +3 -0
- package/dist/analyzer/scope.js +28 -6
- package/dist/analyzer/scope.js.map +1 -1
- package/dist/analyzer/sentinel.d.ts +4 -2
- package/dist/analyzer/sentinel.js +46 -28
- package/dist/analyzer/sentinel.js.map +1 -1
- package/dist/analyzer/symbol.d.ts +4 -1
- package/dist/analyzer/symbol.js +8 -0
- package/dist/analyzer/symbol.js.map +1 -1
- package/dist/analyzer/tupleComparison.js +69 -85
- package/dist/analyzer/tupleComparison.js.map +1 -1
- package/dist/analyzer/typeEvaluator/collectionInference.d.ts +1 -1
- package/dist/analyzer/typeEvaluator/collectionInference.js +162 -87
- package/dist/analyzer/typeEvaluator/collectionInference.js.map +1 -1
- package/dist/analyzer/typeEvaluator/evaluatorCore.js +6 -0
- package/dist/analyzer/typeEvaluator/evaluatorCore.js.map +1 -1
- package/dist/analyzer/typeEvaluator/expressionEvaluation.d.ts +1 -1
- package/dist/analyzer/typeEvaluator/expressionEvaluation.js +8 -4
- package/dist/analyzer/typeEvaluator/expressionEvaluation.js.map +1 -1
- package/dist/analyzer/typeEvaluator/internals.d.ts +1 -0
- package/dist/analyzer/typeEvaluator/specialFormCreation.js +11 -0
- package/dist/analyzer/typeEvaluator/specialFormCreation.js.map +1 -1
- package/dist/analyzer/typeEvaluator/typeCompatibility.js +14 -1
- package/dist/analyzer/typeEvaluator/typeCompatibility.js.map +1 -1
- package/dist/analyzer/typeEvaluator/typeGuardNarrowing.d.ts +3 -1
- package/dist/analyzer/typeEvaluator/typeGuardNarrowing.js +88 -7
- package/dist/analyzer/typeEvaluator/typeGuardNarrowing.js.map +1 -1
- package/dist/analyzer/typeEvaluator.d.ts +1 -1
- package/dist/analyzer/typeEvaluator.js +241 -22
- package/dist/analyzer/typeEvaluator.js.map +1 -1
- package/dist/analyzer/typeGuards.d.ts +2 -2
- package/dist/analyzer/typeGuards.js +45 -14
- package/dist/analyzer/typeGuards.js.map +1 -1
- package/dist/analyzer/typeUtils.js +23 -20
- package/dist/analyzer/typeUtils.js.map +1 -1
- package/dist/analyzer/typedDicts.js +15 -2
- package/dist/analyzer/typedDicts.js.map +1 -1
- package/dist/analyzer/types.d.ts +16 -2
- package/dist/analyzer/types.js +34 -4
- package/dist/analyzer/types.js.map +1 -1
- package/dist/common/languageInfoUtils.js +1 -1
- package/dist/common/languageInfoUtils.js.map +1 -1
- package/dist/common/processUtils.d.ts +1 -0
- package/dist/common/processUtils.js +38 -0
- package/dist/common/processUtils.js.map +1 -1
- package/dist/common/realFileSystem.d.ts +6 -0
- package/dist/common/realFileSystem.js +83 -1
- package/dist/common/realFileSystem.js.map +1 -1
- package/dist/common/windowsProcessTree.json +20 -2
- package/dist/languageService/documentSymbolCollector.js +1 -1
- package/dist/languageService/documentSymbolCollector.js.map +1 -1
- package/dist/languageService/renameProvider.js +1 -1
- package/dist/languageService/renameProvider.js.map +1 -1
- package/dist/languageService/symbolIndexer.js +1 -1
- package/dist/languageService/symbolIndexer.js.map +1 -1
- package/dist/localization/localize.d.ts +8 -0
- package/dist/localization/localize.js +10 -1
- package/dist/localization/localize.js.map +1 -1
- package/dist/localization/package.nls.cs.json +8 -0
- package/dist/localization/package.nls.de.json +8 -0
- package/dist/localization/package.nls.en-us.json +8 -0
- package/dist/localization/package.nls.es.json +8 -0
- package/dist/localization/package.nls.fr.json +8 -0
- package/dist/localization/package.nls.it.json +8 -0
- package/dist/localization/package.nls.ja.json +8 -0
- package/dist/localization/package.nls.ko.json +8 -0
- package/dist/localization/package.nls.pl.json +8 -0
- package/dist/localization/package.nls.pt-br.json +8 -0
- package/dist/localization/package.nls.qps-ploc.json +8 -0
- package/dist/localization/package.nls.ru.json +8 -0
- package/dist/localization/package.nls.tr.json +8 -0
- package/dist/localization/package.nls.zh-cn.json +8 -0
- package/dist/localization/package.nls.zh-tw.json +8 -0
- package/dist/parser/parseNodes.d.ts +3 -4
- package/dist/parser/parseNodes.js +6 -11
- package/dist/parser/parseNodes.js.map +1 -1
- package/dist/parser/parseTreeTokenReuse.js +3 -0
- package/dist/parser/parseTreeTokenReuse.js.map +1 -1
- package/dist/parser/parser.d.ts +3 -0
- package/dist/parser/parser.js +137 -36
- package/dist/parser/parser.js.map +1 -1
- package/dist/parser/stringTokenUtils.js +11 -13
- package/dist/parser/stringTokenUtils.js.map +1 -1
- package/dist/tests/checker.test.js +19 -2
- package/dist/tests/checker.test.js.map +1 -1
- package/dist/tests/localizer.test.js +23 -0
- package/dist/tests/localizer.test.js.map +1 -1
- package/dist/tests/parser.test.js +357 -1
- package/dist/tests/parser.test.js.map +1 -1
- package/dist/tests/signatureHelp.test.js +22 -0
- package/dist/tests/signatureHelp.test.js.map +1 -1
- package/dist/tests/tokenizer.test.js +32 -0
- package/dist/tests/tokenizer.test.js.map +1 -1
- package/dist/tests/typeEvaluator1.test.js +33 -0
- package/dist/tests/typeEvaluator1.test.js.map +1 -1
- package/dist/tests/typeEvaluator2.test.js +16 -2
- package/dist/tests/typeEvaluator2.test.js.map +1 -1
- package/dist/tests/typeEvaluator3.test.js +36 -0
- package/dist/tests/typeEvaluator3.test.js.map +1 -1
- package/dist/tests/typeEvaluator5.test.js +7 -1
- package/dist/tests/typeEvaluator5.test.js.map +1 -1
- package/dist/tests/typeEvaluator6.test.js +24 -0
- package/dist/tests/typeEvaluator6.test.js.map +1 -1
- package/dist/tests/typeEvaluator7.test.js +244 -17
- package/dist/tests/typeEvaluator7.test.js.map +1 -1
- package/dist/tests/typeEvaluator8.test.js +56 -12
- package/dist/tests/typeEvaluator8.test.js.map +1 -1
- package/dist/tests/typeUtils.test.js +73 -0
- package/dist/tests/typeUtils.test.js.map +1 -1
- package/dist/typeServer/stubGenerator.d.ts +9 -0
- package/dist/typeServer/stubGenerator.js +90 -0
- package/dist/typeServer/stubGenerator.js.map +1 -1
- package/package.json +2 -2
|
@@ -84,6 +84,7 @@ export declare class Binder extends ParseTreeWalker {
|
|
|
84
84
|
visitPatternAs(node: PatternAsNode): boolean;
|
|
85
85
|
visitPatternCapture(node: PatternCaptureNode): boolean;
|
|
86
86
|
visitPatternMappingExpandEntry(node: PatternMappingExpandEntryNode): boolean;
|
|
87
|
+
private _isAwaitAllowed;
|
|
87
88
|
private _isNonEmptyListOrTupleLiteral;
|
|
88
89
|
private _addTypingImportAliasesFromBuiltinsScope;
|
|
89
90
|
private _formatModuleName;
|
|
@@ -96,6 +97,7 @@ export declare class Binder extends ParseTreeWalker {
|
|
|
96
97
|
private _addImplicitFromImport;
|
|
97
98
|
private _createAliasDeclarationForMultipartImportName;
|
|
98
99
|
private _walkStatementsAndReportUnreachable;
|
|
100
|
+
private _bindNamesInUnreachableCode;
|
|
99
101
|
private _createStartFlowNode;
|
|
100
102
|
private _createBranchLabel;
|
|
101
103
|
private _createFlowNarrowForPattern;
|
package/dist/analyzer/binder.js
CHANGED
|
@@ -1368,23 +1368,8 @@ class Binder extends parseTreeWalker_1.ParseTreeWalker {
|
|
|
1368
1368
|
return false;
|
|
1369
1369
|
}
|
|
1370
1370
|
visitAwait(node) {
|
|
1371
|
-
|
|
1372
|
-
|
|
1373
|
-
if (execScopeNode?.nodeType !== 31 /* ParseNodeType.Function */ || !execScopeNode.d.isAsync) {
|
|
1374
|
-
if (this._fileInfo.ipythonMode && execScopeNode?.nodeType === 36 /* ParseNodeType.Module */) {
|
|
1375
|
-
// Top level await is allowed in ipython mode.
|
|
1376
|
-
return true;
|
|
1377
|
-
}
|
|
1378
|
-
const isInGenerator = node.parent?.nodeType === 11 /* ParseNodeType.Comprehension */ &&
|
|
1379
|
-
node.parent?.parent?.nodeType !== 34 /* ParseNodeType.List */ &&
|
|
1380
|
-
node.parent?.parent?.nodeType !== 45 /* ParseNodeType.Set */ &&
|
|
1381
|
-
node.parent?.parent?.nodeType !== 18 /* ParseNodeType.Dictionary */;
|
|
1382
|
-
// Allow if it's within a generator expression. Execution of
|
|
1383
|
-
// generator expressions is deferred and therefore can be
|
|
1384
|
-
// run within the context of an async function later.
|
|
1385
|
-
if (!isInGenerator) {
|
|
1386
|
-
this._addSyntaxError(localize_1.LocMessage.awaitNotInAsync(), node.d.awaitToken);
|
|
1387
|
-
}
|
|
1371
|
+
if (!this._isAwaitAllowed(node)) {
|
|
1372
|
+
this._addSyntaxError(localize_1.LocMessage.awaitNotInAsync(), node.d.awaitToken);
|
|
1388
1373
|
}
|
|
1389
1374
|
return true;
|
|
1390
1375
|
}
|
|
@@ -2028,6 +2013,42 @@ class Binder extends parseTreeWalker_1.ParseTreeWalker {
|
|
|
2028
2013
|
}
|
|
2029
2014
|
return true;
|
|
2030
2015
|
}
|
|
2016
|
+
_isAwaitAllowed(node) {
|
|
2017
|
+
// Preserve the established Binder behavior for type forms; their legality is validated separately.
|
|
2018
|
+
if (ParseTreeUtils.isWithinTypeAnnotation(node, /* requireQuotedAnnotation */ false, this._nodeInfo) ||
|
|
2019
|
+
ParseTreeUtils.isNodeContainedWithinNodeType(node, 75 /* ParseNodeType.TypeParameter */) ||
|
|
2020
|
+
ParseTreeUtils.isNodeContainedWithinNodeType(node, 77 /* ParseNodeType.TypeAlias */)) {
|
|
2021
|
+
const executionScope = ParseTreeUtils.getExecutionScopeNode(node, this._nodeInfo);
|
|
2022
|
+
if ((executionScope.nodeType === 31 /* ParseNodeType.Function */ && executionScope.d.isAsync) ||
|
|
2023
|
+
(executionScope.nodeType === 36 /* ParseNodeType.Module */ && !!this._fileInfo.ipythonMode)) {
|
|
2024
|
+
return true;
|
|
2025
|
+
}
|
|
2026
|
+
const parentNode = node.parent?.nodeType === 56 /* ParseNodeType.Unpack */ ? node.parent.parent : node.parent;
|
|
2027
|
+
return parentNode?.nodeType === 11 /* ParseNodeType.Comprehension */ && parentNode.d.isGenerator;
|
|
2028
|
+
}
|
|
2029
|
+
let scopeNode = ParseTreeUtils.getEvaluationScopeNode(node, this._nodeInfo).node;
|
|
2030
|
+
while (true) {
|
|
2031
|
+
switch (scopeNode.nodeType) {
|
|
2032
|
+
case 31 /* ParseNodeType.Function */:
|
|
2033
|
+
return scopeNode.d.isAsync;
|
|
2034
|
+
case 36 /* ParseNodeType.Module */:
|
|
2035
|
+
return !!this._fileInfo.ipythonMode;
|
|
2036
|
+
case 11 /* ParseNodeType.Comprehension */:
|
|
2037
|
+
if (scopeNode.d.isGenerator) {
|
|
2038
|
+
return true;
|
|
2039
|
+
}
|
|
2040
|
+
break;
|
|
2041
|
+
case 33 /* ParseNodeType.Lambda */:
|
|
2042
|
+
case 10 /* ParseNodeType.Class */:
|
|
2043
|
+
case 76 /* ParseNodeType.TypeParameterList */:
|
|
2044
|
+
return false;
|
|
2045
|
+
}
|
|
2046
|
+
if (!scopeNode.parent) {
|
|
2047
|
+
return false;
|
|
2048
|
+
}
|
|
2049
|
+
scopeNode = ParseTreeUtils.getEvaluationScopeNode(scopeNode.parent, this._nodeInfo).node;
|
|
2050
|
+
}
|
|
2051
|
+
}
|
|
2031
2052
|
// Helper method to determine if an expression is a non-empty list or tuple literal.
|
|
2032
2053
|
// This is a syntactic check, not a semantic one, so it's very fast.
|
|
2033
2054
|
// Guards against starred expressions ([*empty_list]) and comprehensions ([v for v in []]).
|
|
@@ -2368,11 +2389,35 @@ class Binder extends parseTreeWalker_1.ParseTreeWalker {
|
|
|
2368
2389
|
if (!this._moduleSymbolOnly) {
|
|
2369
2390
|
const dummyScopeGenerator = new DummyScopeGenerator(this._currentScope, this._nodeInfo);
|
|
2370
2391
|
dummyScopeGenerator.walk(statement);
|
|
2392
|
+
// Assignments in unreachable code still make names local, matching
|
|
2393
|
+
// CPython. Bind those names without type-checking the dead code.
|
|
2394
|
+
if (this._currentScope.type === 2 /* ScopeType.Function */ || this._currentScope.type === 3 /* ScopeType.Class */) {
|
|
2395
|
+
this._bindNamesInUnreachableCode(statement);
|
|
2396
|
+
}
|
|
2371
2397
|
}
|
|
2372
2398
|
}
|
|
2373
2399
|
}
|
|
2374
2400
|
return false;
|
|
2375
2401
|
}
|
|
2402
|
+
_bindNamesInUnreachableCode(node) {
|
|
2403
|
+
// Directives apply to the entire scope, so process global and
|
|
2404
|
+
// nonlocal declarations before binding any names.
|
|
2405
|
+
new UnreachableDirectiveFinder((globalNode) => this.visitGlobal(globalNode), (nonlocalNode) => {
|
|
2406
|
+
if (this._currentScope.type === 3 /* ScopeType.Class */) {
|
|
2407
|
+
nonlocalNode.d.targets.forEach((name) => this._currentScope.excludeUnreachableSymbol(name.d.value));
|
|
2408
|
+
}
|
|
2409
|
+
else {
|
|
2410
|
+
this.visitNonlocal(nonlocalNode);
|
|
2411
|
+
}
|
|
2412
|
+
}).walk(node);
|
|
2413
|
+
const bindTarget = (target) => {
|
|
2414
|
+
this._bindPossibleTupleNamedTarget(target);
|
|
2415
|
+
};
|
|
2416
|
+
const bindName = (name) => {
|
|
2417
|
+
this._bindNameToScope(this._currentScope, name);
|
|
2418
|
+
};
|
|
2419
|
+
new UnreachableNameBinder(bindTarget, bindName).walk(node);
|
|
2420
|
+
}
|
|
2376
2421
|
_createStartFlowNode() {
|
|
2377
2422
|
const flowNode = {
|
|
2378
2423
|
flags: codeFlowTypes_1.FlowFlags.Start,
|
|
@@ -2830,6 +2875,9 @@ class Binder extends parseTreeWalker_1.ParseTreeWalker {
|
|
|
2830
2875
|
const symbolWithScope = this._currentScope.lookUpSymbolRecursive(node.d.value);
|
|
2831
2876
|
(0, debug_1.assert)(symbolWithScope !== undefined);
|
|
2832
2877
|
targetSymbolId = symbolWithScope.symbol.id;
|
|
2878
|
+
if (unbound && !this._isCodeUnreachable() && symbolWithScope.isBeyondExecutionScope) {
|
|
2879
|
+
symbolWithScope.symbol.setIsUnboundInOtherScope();
|
|
2880
|
+
}
|
|
2833
2881
|
}
|
|
2834
2882
|
const prevFlowNode = this._currentFlowNode;
|
|
2835
2883
|
// Record mutations even when the target cannot be narrowed, so presence
|
|
@@ -2962,6 +3010,9 @@ class Binder extends parseTreeWalker_1.ParseTreeWalker {
|
|
|
2962
3010
|
}
|
|
2963
3011
|
}
|
|
2964
3012
|
else {
|
|
3013
|
+
if (scope.type === 3 /* ScopeType.Class */ && this._isCodeUnreachable()) {
|
|
3014
|
+
return scope.addUnreachableSymbol(name);
|
|
3015
|
+
}
|
|
2965
3016
|
// Don't overwrite an existing symbol.
|
|
2966
3017
|
let symbol = scope.lookUpSymbol(name);
|
|
2967
3018
|
if (!symbol) {
|
|
@@ -2997,7 +3048,9 @@ class Binder extends parseTreeWalker_1.ParseTreeWalker {
|
|
|
2997
3048
|
return undefined;
|
|
2998
3049
|
}
|
|
2999
3050
|
_bindPossibleTupleNamedTarget(target, addedSymbols) {
|
|
3000
|
-
if (this._currentScope.type === 3 /* ScopeType.Class */ &&
|
|
3051
|
+
if (this._currentScope.type === 3 /* ScopeType.Class */ &&
|
|
3052
|
+
!this._isCodeUnreachable() &&
|
|
3053
|
+
!isStaticClassAssignmentTarget(target)) {
|
|
3001
3054
|
this._currentScope.hasPotentiallyDynamicSymbolTable = true;
|
|
3002
3055
|
}
|
|
3003
3056
|
switch (target.nodeType) {
|
|
@@ -3868,6 +3921,173 @@ class ReturnFinder extends parseTreeWalker_1.ParseTreeWalker {
|
|
|
3868
3921
|
}
|
|
3869
3922
|
}
|
|
3870
3923
|
exports.ReturnFinder = ReturnFinder;
|
|
3924
|
+
// Discovers and processes `global` and `nonlocal` directives in unreachable code.
|
|
3925
|
+
// Directives must be evaluated before binding names to ensure that later
|
|
3926
|
+
// assignments do not bind as locals in the current scope. Nested function,
|
|
3927
|
+
// class, and lambda bodies are skipped because their directives belong to
|
|
3928
|
+
// nested scopes.
|
|
3929
|
+
class UnreachableDirectiveFinder extends parseTreeWalker_1.ParseTreeWalker {
|
|
3930
|
+
constructor(_bindGlobal, _bindNonlocal) {
|
|
3931
|
+
super();
|
|
3932
|
+
this._bindGlobal = _bindGlobal;
|
|
3933
|
+
this._bindNonlocal = _bindNonlocal;
|
|
3934
|
+
}
|
|
3935
|
+
visitGlobal(node) {
|
|
3936
|
+
this._bindGlobal(node);
|
|
3937
|
+
return false;
|
|
3938
|
+
}
|
|
3939
|
+
visitNonlocal(node) {
|
|
3940
|
+
this._bindNonlocal(node);
|
|
3941
|
+
return false;
|
|
3942
|
+
}
|
|
3943
|
+
visitFunction(node) {
|
|
3944
|
+
return false;
|
|
3945
|
+
}
|
|
3946
|
+
visitClass(node) {
|
|
3947
|
+
return false;
|
|
3948
|
+
}
|
|
3949
|
+
visitLambda(node) {
|
|
3950
|
+
return false;
|
|
3951
|
+
}
|
|
3952
|
+
}
|
|
3953
|
+
// Binds assignment targets in unreachable code so they still create local
|
|
3954
|
+
// symbols, matching CPython (an assignment after `return` makes the name
|
|
3955
|
+
// local for the entire function).
|
|
3956
|
+
// Header expressions for nested functions, classes, and lambdas (decorators,
|
|
3957
|
+
// parameter defaults/annotations, type parameters, and class bases/arguments)
|
|
3958
|
+
// are evaluated in the enclosing scope, so they are walked to catch assignment
|
|
3959
|
+
// expressions (:=). Nested bodies are skipped because DummyScopeGenerator
|
|
3960
|
+
// already created their scopes and they belong to nested scopes.
|
|
3961
|
+
class UnreachableNameBinder extends parseTreeWalker_1.ParseTreeWalker {
|
|
3962
|
+
constructor(_bindTarget, _bindName) {
|
|
3963
|
+
super();
|
|
3964
|
+
this._bindTarget = _bindTarget;
|
|
3965
|
+
this._bindName = _bindName;
|
|
3966
|
+
}
|
|
3967
|
+
visitAssignment(node) {
|
|
3968
|
+
this._bindTarget(node.d.leftExpr);
|
|
3969
|
+
return true;
|
|
3970
|
+
}
|
|
3971
|
+
visitAugmentedAssignment(node) {
|
|
3972
|
+
this._bindTarget(node.d.leftExpr);
|
|
3973
|
+
return true;
|
|
3974
|
+
}
|
|
3975
|
+
visitTypeAnnotation(node) {
|
|
3976
|
+
this._bindTarget(node.d.valueExpr);
|
|
3977
|
+
return true;
|
|
3978
|
+
}
|
|
3979
|
+
visitAssignmentExpression(node) {
|
|
3980
|
+
this._bindName(node.d.name);
|
|
3981
|
+
return true;
|
|
3982
|
+
}
|
|
3983
|
+
visitFor(node) {
|
|
3984
|
+
this._bindTarget(node.d.targetExpr);
|
|
3985
|
+
return true;
|
|
3986
|
+
}
|
|
3987
|
+
visitWith(node) {
|
|
3988
|
+
node.d.withItems.forEach((item) => {
|
|
3989
|
+
if (item.d.target) {
|
|
3990
|
+
this._bindTarget(item.d.target);
|
|
3991
|
+
}
|
|
3992
|
+
});
|
|
3993
|
+
return true;
|
|
3994
|
+
}
|
|
3995
|
+
visitDel(node) {
|
|
3996
|
+
node.d.targets.forEach((target) => {
|
|
3997
|
+
this._bindTarget(target);
|
|
3998
|
+
});
|
|
3999
|
+
return true;
|
|
4000
|
+
}
|
|
4001
|
+
visitExcept(node) {
|
|
4002
|
+
if (node.d.name) {
|
|
4003
|
+
this._bindName(node.d.name);
|
|
4004
|
+
}
|
|
4005
|
+
return true;
|
|
4006
|
+
}
|
|
4007
|
+
visitImportAs(node) {
|
|
4008
|
+
if (node.d.alias) {
|
|
4009
|
+
this._bindName(node.d.alias);
|
|
4010
|
+
}
|
|
4011
|
+
else if (node.d.module.d.nameParts.length > 0) {
|
|
4012
|
+
this._bindName(node.d.module.d.nameParts[0]);
|
|
4013
|
+
}
|
|
4014
|
+
return false;
|
|
4015
|
+
}
|
|
4016
|
+
visitImportFrom(node) {
|
|
4017
|
+
node.d.imports.forEach((importSymbolNode) => {
|
|
4018
|
+
this._bindName(importSymbolNode.d.alias || importSymbolNode.d.name);
|
|
4019
|
+
});
|
|
4020
|
+
return false;
|
|
4021
|
+
}
|
|
4022
|
+
visitFunction(node) {
|
|
4023
|
+
this._bindName(node.d.name);
|
|
4024
|
+
this.walkMultiple(node.d.decorators);
|
|
4025
|
+
node.d.params.forEach((param) => {
|
|
4026
|
+
if (param.d.defaultValue) {
|
|
4027
|
+
this.walk(param.d.defaultValue);
|
|
4028
|
+
}
|
|
4029
|
+
if (param.d.annotation) {
|
|
4030
|
+
this.walk(param.d.annotation);
|
|
4031
|
+
}
|
|
4032
|
+
if (param.d.annotationComment) {
|
|
4033
|
+
this.walk(param.d.annotationComment);
|
|
4034
|
+
}
|
|
4035
|
+
});
|
|
4036
|
+
if (node.d.typeParams) {
|
|
4037
|
+
this.walk(node.d.typeParams);
|
|
4038
|
+
}
|
|
4039
|
+
if (node.d.returnAnnotation) {
|
|
4040
|
+
this.walk(node.d.returnAnnotation);
|
|
4041
|
+
}
|
|
4042
|
+
if (node.d.funcAnnotationComment) {
|
|
4043
|
+
this.walk(node.d.funcAnnotationComment);
|
|
4044
|
+
}
|
|
4045
|
+
return false;
|
|
4046
|
+
}
|
|
4047
|
+
visitClass(node) {
|
|
4048
|
+
this._bindName(node.d.name);
|
|
4049
|
+
this.walkMultiple(node.d.decorators);
|
|
4050
|
+
if (node.d.typeParams) {
|
|
4051
|
+
this.walk(node.d.typeParams);
|
|
4052
|
+
}
|
|
4053
|
+
this.walkMultiple(node.d.arguments);
|
|
4054
|
+
return false;
|
|
4055
|
+
}
|
|
4056
|
+
visitLambda(node) {
|
|
4057
|
+
node.d.params.forEach((param) => {
|
|
4058
|
+
if (param.d.defaultValue) {
|
|
4059
|
+
this.walk(param.d.defaultValue);
|
|
4060
|
+
}
|
|
4061
|
+
});
|
|
4062
|
+
return false;
|
|
4063
|
+
}
|
|
4064
|
+
visitTypeAlias(node) {
|
|
4065
|
+
this._bindName(node.d.name);
|
|
4066
|
+
if (node.d.typeParams) {
|
|
4067
|
+
this.walk(node.d.typeParams);
|
|
4068
|
+
}
|
|
4069
|
+
this.walk(node.d.expr);
|
|
4070
|
+
return false;
|
|
4071
|
+
}
|
|
4072
|
+
visitPatternAs(node) {
|
|
4073
|
+
if (node.d.target) {
|
|
4074
|
+
this._bindName(node.d.target);
|
|
4075
|
+
}
|
|
4076
|
+
return true;
|
|
4077
|
+
}
|
|
4078
|
+
visitPatternCapture(node) {
|
|
4079
|
+
if (!node.d.isWildcard) {
|
|
4080
|
+
this._bindName(node.d.target);
|
|
4081
|
+
}
|
|
4082
|
+
return false;
|
|
4083
|
+
}
|
|
4084
|
+
visitPatternMappingExpandEntry(node) {
|
|
4085
|
+
if (node.d.target.d.value !== '_') {
|
|
4086
|
+
this._bindName(node.d.target);
|
|
4087
|
+
}
|
|
4088
|
+
return false;
|
|
4089
|
+
}
|
|
4090
|
+
}
|
|
3871
4091
|
// Creates dummy scopes for classes or functions within a parse tree.
|
|
3872
4092
|
// This is needed in cases where the parse tree has been determined
|
|
3873
4093
|
// to be unreachable. There are code paths where the type evaluator
|