forked from swc-project/swc
-
Notifications
You must be signed in to change notification settings - Fork 0
/
parserRealSource6_es5.2.minified.js
94 lines (94 loc) · 6.61 KB
/
parserRealSource6_es5.2.minified.js
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
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
var TypeScript;
import * as swcHelpers from "@swc/helpers";
!function(TypeScript1) {
var preFindMemberScope = function(ast, parent, walker) {
var memScope = walker.state;
return hasFlag(ast.flags, memScope.matchFlag) && (memScope.pos < 0 || memScope.pos == ast.limChar) && (memScope.ast = ast, null == ast.type && memScope.pos >= 0 && memScope.flow.inScopeTypeCheck(ast, memScope.scope), memScope.type = ast.type, memScope.options.stopWalk()), ast;
}, preFindEnclosingScope = function(ast, parent, walker) {
var context = walker.state, minChar = ast.minChar, limChar = ast.limChar;
if (ast.nodeType == NodeType.Script && context.pos > limChar && (limChar = context.pos), minChar <= context.pos && limChar >= context.pos) {
switch(ast.nodeType){
case NodeType.Script:
var script = ast;
context.scopeGetter = function() {
return null === script.bod ? null : script.bod.enclosingScope;
}, context.scopeStartAST = script;
break;
case NodeType.ClassDeclaration:
context.scopeGetter = function() {
return null === ast.type || null === ast.type.instanceType.containedScope ? null : ast.type.instanceType.containedScope;
}, context.scopeStartAST = ast, context.enclosingClassDecl = ast;
break;
case NodeType.ObjectLit:
var objectLit = ast;
objectLit.targetType && (context.scopeGetter = function() {
return objectLit.targetType.containedScope;
}, context.objectLiteralScopeGetter = function() {
return objectLit.targetType.memberScope;
}, context.enclosingObjectLit = objectLit);
break;
case NodeType.ModuleDeclaration:
context.deepestModuleDecl = ast, context.scopeGetter = function() {
return null === ast.type ? null : ast.type.containedScope;
}, context.scopeStartAST = ast;
break;
case NodeType.InterfaceDeclaration:
context.scopeGetter = function() {
return null === ast.type ? null : ast.type.containedScope;
}, context.scopeStartAST = ast;
break;
case NodeType.FuncDecl:
var funcDecl = ast;
context.skipNextFuncDeclForClass ? context.skipNextFuncDeclForClass = !1 : (context.scopeGetter = function() {
return funcDecl.isConstructor && hasFlag(funcDecl.fncFlags, FncFlags.ClassMethod) && ast.type && ast.type.enclosingType ? ast.type.enclosingType.constructorScope : funcDecl.scopeType ? funcDecl.scopeType.containedScope : funcDecl.type ? funcDecl.type.containedScope : null;
}, context.scopeStartAST = ast);
}
walker.options.goChildren = !0;
} else walker.options.goChildren = !1;
return ast;
}, findEnclosingScopeAt = function(logger, script, text, pos, isMemberCompletion) {
var context = new EnclosingScopeContext(logger, script, text, pos, isMemberCompletion);
return (TypeScript.getAstWalkerFactory().walk(script, preFindEnclosingScope, null, null, context), null === context.scopeStartAST) ? null : context;
}, TypeCollectionContext = function(scopeChain, checker) {
"use strict";
swcHelpers.classCallCheck(this, TypeCollectionContext), this.scopeChain = scopeChain, this.checker = checker, this.script = null;
};
TypeScript1.TypeCollectionContext = TypeCollectionContext;
var MemberScopeContext = function(flow, pos, matchFlag) {
"use strict";
swcHelpers.classCallCheck(this, MemberScopeContext), this.flow = flow, this.pos = pos, this.matchFlag = matchFlag, this.type = null, this.ast = null, this.options = new AstWalkOptions();
};
TypeScript1.MemberScopeContext = MemberScopeContext;
var EnclosingScopeContext = function() {
"use strict";
function EnclosingScopeContext(logger, script, text, pos, isMemberCompletion) {
swcHelpers.classCallCheck(this, EnclosingScopeContext), this.logger = logger, this.script = script, this.text = text, this.pos = pos, this.isMemberCompletion = isMemberCompletion, this.scopeGetter = null, this.objectLiteralScopeGetter = null, this.scopeStartAST = null, this.skipNextFuncDeclForClass = !1, this.deepestModuleDecl = null, this.enclosingClassDecl = null, this.enclosingObjectLit = null, this.publicsOnly = !0, this.useFullAst = !1;
}
var _proto = EnclosingScopeContext.prototype;
return _proto.getScope = function() {
return this.scopeGetter();
}, _proto.getObjectLiteralScope = function() {
return this.objectLiteralScopeGetter();
}, _proto.getScopeAST = function() {
return this.scopeStartAST;
}, _proto.getScopePosition = function() {
return this.scopeStartAST.minChar;
}, _proto.getScriptFragmentStartAST = function() {
return this.scopeStartAST;
}, _proto.getScriptFragmentPosition = function() {
return this.getScriptFragmentStartAST().minChar;
}, _proto.getScriptFragment = function() {
if (null == this.scriptFragment) {
var ast = this.getScriptFragmentStartAST(), minChar = ast.minChar, limChar = this.isMemberCompletion ? this.pos : this.pos + 1;
this.scriptFragment = TypeScript.quickParse(this.logger, ast, this.text, minChar, limChar, null).Script;
}
return this.scriptFragment;
}, EnclosingScopeContext;
}();
TypeScript1.EnclosingScopeContext = EnclosingScopeContext, TypeScript1.preFindMemberScope = preFindMemberScope, TypeScript1.pushTypeCollectionScope = function(container, valueMembers, ambientValueMembers, enclosedTypes, ambientEnclosedTypes, context, thisType, classType, moduleDecl) {
var builder = new SymbolScopeBuilder(valueMembers, ambientValueMembers, enclosedTypes, ambientEnclosedTypes, null, container), chain = new ScopeChain(container, context.scopeChain, builder);
chain.thisType = thisType, chain.classType = classType, chain.moduleDecl = moduleDecl, context.scopeChain = chain;
}, TypeScript1.popTypeCollectionScope = function(context) {
context.scopeChain = context.scopeChain.previous;
}, TypeScript1.preFindEnclosingScope = preFindEnclosingScope, TypeScript1.findEnclosingScopeAt = findEnclosingScopeAt;
}(TypeScript || (TypeScript = {}));