| OLD | NEW |
| 1 // Copyright (c) 2016, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2016, 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 import 'package:analyzer/src/summary/format.dart'; | 5 import 'package:analyzer/src/summary/format.dart'; |
| 6 import 'package:analyzer/src/summary/name_filter.dart'; | 6 import 'package:analyzer/src/summary/name_filter.dart'; |
| 7 | 7 |
| 8 /** | 8 /** |
| 9 * Create a [LinkedLibraryBuilder] corresponding to the given | 9 * Create a [LinkedLibraryBuilder] corresponding to the given |
| 10 * [definingUnit], which should be the defining compilation unit for a library. | 10 * [definingUnit], which should be the defining compilation unit for a library. |
| (...skipping 240 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 251 | 251 |
| 252 /** | 252 /** |
| 253 * Extract all the names defined in [unit] (which is the [unitNum]th unit in | 253 * Extract all the names defined in [unit] (which is the [unitNum]th unit in |
| 254 * the library being prelinked) and store them in [privateNamespace]. | 254 * the library being prelinked) and store them in [privateNamespace]. |
| 255 * Excludes names introduced by `import` statements. | 255 * Excludes names introduced by `import` statements. |
| 256 */ | 256 */ |
| 257 void extractPrivateNames(UnlinkedUnit unit, int unitNum) { | 257 void extractPrivateNames(UnlinkedUnit unit, int unitNum) { |
| 258 for (UnlinkedClass cls in unit.classes) { | 258 for (UnlinkedClass cls in unit.classes) { |
| 259 privateNamespace.putIfAbsent(cls.name, () { | 259 privateNamespace.putIfAbsent(cls.name, () { |
| 260 Map<String, _Meaning> namespace = <String, _Meaning>{}; | 260 Map<String, _Meaning> namespace = <String, _Meaning>{}; |
| 261 cls.fields.forEach((field) { |
| 262 if (field.isStatic && field.isConst) { |
| 263 namespace[field.name] = |
| 264 new _Meaning(unitNum, ReferenceKind.constField, 0, 0); |
| 265 } |
| 266 }); |
| 261 cls.executables.forEach((executable) { | 267 cls.executables.forEach((executable) { |
| 262 namespace[executable.name] = new _Meaning( | 268 ReferenceKind kind = null; |
| 263 unitNum, | 269 if (executable.kind == UnlinkedExecutableKind.constructor && |
| 264 executable.kind == UnlinkedExecutableKind.constructor | 270 executable.isConst) { |
| 265 ? ReferenceKind.constructor | 271 kind = ReferenceKind.constructor; |
| 266 : ReferenceKind.staticMethod, | 272 } else if (executable.kind == |
| 267 0, | 273 UnlinkedExecutableKind.functionOrMethod && |
| 268 executable.typeParameters.length); | 274 executable.isStatic) { |
| 275 kind = ReferenceKind.staticMethod; |
| 276 } |
| 277 if (kind != null) { |
| 278 namespace[executable.name] = new _Meaning( |
| 279 unitNum, kind, 0, executable.typeParameters.length); |
| 280 } |
| 269 }); | 281 }); |
| 270 return new _ClassMeaning( | 282 return new _ClassMeaning( |
| 271 unitNum, 0, cls.typeParameters.length, namespace); | 283 unitNum, 0, cls.typeParameters.length, namespace); |
| 272 }); | 284 }); |
| 273 } | 285 } |
| 274 for (UnlinkedEnum enm in unit.enums) { | 286 for (UnlinkedEnum enm in unit.enums) { |
| 275 privateNamespace.putIfAbsent(enm.name, | 287 privateNamespace.putIfAbsent(enm.name, |
| 276 () => new _Meaning(unitNum, ReferenceKind.classOrEnum, 0, 0)); | 288 () => new _Meaning(unitNum, ReferenceKind.classOrEnum, 0, 0)); |
| 277 } | 289 } |
| 278 for (UnlinkedExecutable executable in unit.executables) { | 290 for (UnlinkedExecutable executable in unit.executables) { |
| (...skipping 197 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 476 * [sourceUri] is also relative. | 488 * [sourceUri] is also relative. |
| 477 */ | 489 */ |
| 478 String resolveUri(String sourceUri, String relativeUri) { | 490 String resolveUri(String sourceUri, String relativeUri) { |
| 479 if (sourceUri == null) { | 491 if (sourceUri == null) { |
| 480 return relativeUri; | 492 return relativeUri; |
| 481 } else { | 493 } else { |
| 482 return Uri.parse(sourceUri).resolve(relativeUri).toString(); | 494 return Uri.parse(sourceUri).resolve(relativeUri).toString(); |
| 483 } | 495 } |
| 484 } | 496 } |
| 485 } | 497 } |
| OLD | NEW |