OLD | NEW |
1 // Copyright (c) 2014, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2014, the Dart project authors. Please see the AUTHORS file |
2 // for details. All rights reserved. Use of this source code is governed by a | 2 // for details. All rights reserved. Use of this source code is governed by a |
3 // BSD-style license that can be found in the LICENSE file. | 3 // BSD-style license that can be found in the LICENSE file. |
4 | 4 |
5 library trydart.poi.scope_information_visitor; | 5 library trydart.poi.scope_information_visitor; |
6 | 6 |
7 import 'package:compiler/src/elements/modelx.dart' as modelx; | 7 import 'package:compiler/src/elements/modelx.dart' as modelx; |
8 | 8 |
9 import 'package:compiler/src/elements/visitor.dart' show | 9 import 'package:compiler/src/elements/visitor.dart' show |
10 ElementVisitor; | 10 ElementVisitor; |
11 | 11 |
12 import 'package:compiler/src/dart2jslib.dart' show | 12 import 'package:compiler/src/compiler.dart' show |
13 Compiler; | 13 Compiler; |
14 | 14 |
15 import 'package:compiler/src/elements/elements.dart' show | 15 import 'package:compiler/src/elements/elements.dart' show |
16 AbstractFieldElement, | 16 AbstractFieldElement, |
17 ClassElement, | 17 ClassElement, |
18 CompilationUnitElement, | 18 CompilationUnitElement, |
19 Element, | 19 Element, |
20 ElementCategory, | 20 ElementCategory, |
21 FunctionElement, | 21 FunctionElement, |
22 LibraryElement, | 22 LibraryElement, |
(...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
64 buffer.write('\n'); | 64 buffer.write('\n'); |
65 indented; | 65 indented; |
66 serialize(member); | 66 serialize(member); |
67 isFirst = false; | 67 isFirst = false; |
68 } | 68 } |
69 serialize( | 69 serialize( |
70 e, | 70 e, |
71 // TODO(ahe): We omit the import scope if there is no current | 71 // TODO(ahe): We omit the import scope if there is no current |
72 // class. That's wrong. | 72 // class. That's wrong. |
73 omitEnclosing: ignoreImports || currentClass == null, | 73 omitEnclosing: ignoreImports || currentClass == null, |
74 name: e.getLibraryName(), | 74 name: e.libraryName, |
75 serializeEnclosing: () { | 75 serializeEnclosing: () { |
76 // The enclosing scope of a library is a scope which contains all the | 76 // The enclosing scope of a library is a scope which contains all the |
77 // imported names. | 77 // imported names. |
78 isFirst = true; | 78 isFirst = true; |
79 buffer.write('{\n'); | 79 buffer.write('{\n'); |
80 indentationLevel++; | 80 indentationLevel++; |
81 indented.write('"kind": "imports",\n'); | 81 indented.write('"kind": "imports",\n'); |
82 indented.write('"members": ['); | 82 indented.write('"members": ['); |
83 indentationLevel++; | 83 indentationLevel++; |
84 sortElements(importScope(e).importScope.values).forEach(forEach); | 84 sortElements(importScope(e).importScope.values).forEach(forEach); |
(...skipping 25 matching lines...) Expand all Loading... |
110 /// is all the local instance members of the class (the members of the | 110 /// is all the local instance members of the class (the members of the |
111 /// mixin), and the class side is the equivalent for static members and | 111 /// mixin), and the class side is the equivalent for static members and |
112 /// constructors. | 112 /// constructors. |
113 /// The scope chain is ordered so that the "class side" is searched before | 113 /// The scope chain is ordered so that the "class side" is searched before |
114 /// the "instance side". | 114 /// the "instance side". |
115 void serializeClassSide( | 115 void serializeClassSide( |
116 ClassElement e, | 116 ClassElement e, |
117 {bool isStatic: false, | 117 {bool isStatic: false, |
118 bool omitEnclosing: false, | 118 bool omitEnclosing: false, |
119 bool includeSuper: false}) { | 119 bool includeSuper: false}) { |
120 e.ensureResolved(compiler); | 120 e.ensureResolved(compiler.resolution); |
121 bool isFirst = true; | 121 bool isFirst = true; |
122 var serializeEnclosing; | 122 var serializeEnclosing; |
123 String kind; | 123 String kind; |
124 if (isStatic) { | 124 if (isStatic) { |
125 kind = 'class side'; | 125 kind = 'class side'; |
126 serializeEnclosing = () { | 126 serializeEnclosing = () { |
127 serializeClassSide(e, isStatic: false, omitEnclosing: omitEnclosing); | 127 serializeClassSide(e, isStatic: false, omitEnclosing: omitEnclosing); |
128 }; | 128 }; |
129 } else { | 129 } else { |
130 kind = 'instance side'; | 130 kind = 'instance side'; |
(...skipping 162 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
293 } | 293 } |
294 return result; | 294 return result; |
295 } | 295 } |
296 } | 296 } |
297 | 297 |
298 modelx.ScopeX localScope(modelx.LibraryElementX element) => element.localScope; | 298 modelx.ScopeX localScope(modelx.LibraryElementX element) => element.localScope; |
299 | 299 |
300 modelx.ImportScope importScope(modelx.LibraryElementX element) { | 300 modelx.ImportScope importScope(modelx.LibraryElementX element) { |
301 return element.importScope; | 301 return element.importScope; |
302 } | 302 } |
OLD | NEW |