• Home
  • Raw
  • Download

Lines Matching full:scope

81  * kind of a scope
87 * A map used to track whether identifiers without symbols are in the top-level scope.
102 * type of scope
118 export function isGlobalScope(scope: Scope): boolean {
119 return scope.kind === ScopeKind.GLOBAL;
122 export function isFunctionScope(scope: Scope): boolean {
123 return scope.kind === ScopeKind.FUNCTION;
126 export function isClassScope(scope: Scope): boolean {
127 return scope.kind === ScopeKind.CLASS;
130 export function isInterfaceScope(scope: Scope): boolean {
131 return scope.kind === ScopeKind.INTERFACE;
134 export function isEnumScope(scope: Scope): boolean {
135 return scope.kind === ScopeKind.ENUM;
138 export function isObjectLiteralScope(scope: Scope): boolean {
139 return scope.kind === ScopeKind.OBJECT_LITERAL;
143 * get a new scope.
144 * @param name - name of the scope.
145 * @param node - node of a current scope in ast.
146 * @param type - type of the scope.
147 * @param lexicalScope - indicates if the scope is a lexical scope.
148 * @param upper - parent scope of the current scope.
150 export class Scope { class
151 // scope name
153 // kind of a scope, such as global ,function like, block ..
155 // node of a current scope in ast.
157 // parent scope of current scope
158 parent: Scope | undefined;
159 // sub scopes of current scope
160 children: Scope[];
162 // symbols define in current scope
165 // labels in current scope
176 …structor(name: string, node: Node, type: ScopeKind, lexicalScope: boolean = false, upper?: Scope) {
193 * add a sub scope to current scope
197 addChild(child: Scope): void {
202 * add definition symbol into current scope
214 * add label to current scope
256 scope: Scope; property
259 …export function createLabel(node: LabeledStatement, scope: Scope, parent?: Label | undefined): Lab…
260 let labelName: string = '$' + scope.labels.length + '_' + node.label.text;
267 'scope': scope,
270 scope.labels.push(label);
284 * do scope analysis
292 * get root scope of a file
294 getRootScope(): Scope;
297 * find block Scope of a node
300 getScopeOfNode(node: Node): Scope | undefined;
305 let root: Scope;
306 let current: Scope;
307 let scopes: Scope[] = [];
332 function getRootScope(): Scope {
502 // add symbol of annotationDeclaration into global scope
517 // try to collect symbol for `A` in `import { A as B } from './file'; into current scope`
610 current = new Scope(scopeName, node, ScopeKind.OBJECT_LITERAL, false, current);
674 root = new Scope(scopeName, node, ScopeKind.GLOBAL, true);
679 // locals of a node(scope) is symbol that defines in current scope(node).
688 current = new Scope(scopeName, node, ScopeKind.CATCH, false, current);
719 current = new Scope(scopeName, node, ScopeKind.INTERFACE, true, current);
734 * if it is an anonymous scope, generate the scope name with a number,
735 * which is based on the order of its child scopes in the upper scope
738 current = new Scope(scopeName, node, ScopeKind.MODULE, true, current);
808 current = new Scope(scopeName, node, ScopeKind.FUNCTION, true, current);
835 …The `current` scope is the function's scope, the `current.parent` scope is where the function is d…
836 `foo` has already added in the parent scope, we need to add `bar` here too.
861 current = new Scope(scopeName, node, ScopeKind.SWITCH, false, current);
869 …* ES6+ class like scope, The members of a class aren't not allow to rename in rename identifiers t…
881 current = new Scope(scopeName, node, ScopeKind.CLASS, true, current);
899 current = new Scope(scopeName, node, ScopeKind.FOR, false, current);
909 // skip direct block scope in function scope
915 current = new Scope(scopeName, node, ScopeKind.BLOCK, false, current);
924 current = new Scope(scopeName, node, ScopeKind.INTERFACE, true, current);
944 current = new Scope(scopeName, node, ScopeKind.ENUM, true, current);
1033 …// labels within the same scope are allowed to be duplicated, so label names need to have numberin…
1039 function getScopeOfNode(node: Node): Scope | undefined {
1049 for (const scope of scopes) { constant
1050 if (scope?.defs.has(sym)) {
1051 return scope;
1108 function tryAddExportNamesIntoParentScope(originalSymbol: Symbol, currentScope: Scope): void {
1112 let parentScope: Scope = currentScope.parent;
1119 function tryAddExportNamesIntoCurrentScope(originalSymbol: Symbol, currentScope: Scope): void {
1157 export function getNameWithScopeLoc(scope: Scope, name: string): string {
1158 return scope.loc + '#' + name;