| 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 243 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 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) { | 261 cls.fields.forEach((field) { |
| 262 if (field.isStatic && field.isConst) { | 262 if (field.isStatic && field.isConst) { |
| 263 namespace[field.name] = | 263 namespace[field.name] = |
| 264 new _Meaning(unitNum, ReferenceKind.constField, 0, 0); | 264 new _Meaning(unitNum, ReferenceKind.propertyAccessor, 0, 0); |
| 265 } | 265 } |
| 266 }); | 266 }); |
| 267 cls.executables.forEach((executable) { | 267 cls.executables.forEach((executable) { |
| 268 ReferenceKind kind = null; | 268 ReferenceKind kind = null; |
| 269 if (executable.kind == UnlinkedExecutableKind.constructor && | 269 if (executable.kind == UnlinkedExecutableKind.constructor && |
| 270 executable.isConst) { | 270 executable.isConst) { |
| 271 kind = ReferenceKind.constructor; | 271 kind = ReferenceKind.constructor; |
| 272 } else if (executable.kind == | 272 } else if (executable.kind == |
| 273 UnlinkedExecutableKind.functionOrMethod && | 273 UnlinkedExecutableKind.functionOrMethod && |
| 274 executable.isStatic) { | 274 executable.isStatic) { |
| 275 kind = ReferenceKind.staticMethod; | 275 kind = ReferenceKind.method; |
| 276 } | 276 } |
| 277 if (kind != null) { | 277 if (kind != null) { |
| 278 namespace[executable.name] = new _Meaning( | 278 namespace[executable.name] = new _Meaning( |
| 279 unitNum, kind, 0, executable.typeParameters.length); | 279 unitNum, kind, 0, executable.typeParameters.length); |
| 280 } | 280 } |
| 281 }); | 281 }); |
| 282 return new _ClassMeaning( | 282 return new _ClassMeaning( |
| 283 unitNum, 0, cls.typeParameters.length, namespace); | 283 unitNum, 0, cls.typeParameters.length, namespace); |
| 284 }); | 284 }); |
| 285 } | 285 } |
| (...skipping 124 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 410 namespace = privateNamespace; | 410 namespace = privateNamespace; |
| 411 } else { | 411 } else { |
| 412 // Prefix references must always point backward. | 412 // Prefix references must always point backward. |
| 413 assert(reference.prefixReference < i); | 413 assert(reference.prefixReference < i); |
| 414 namespace = prefixNamespaces[reference.prefixReference]; | 414 namespace = prefixNamespaces[reference.prefixReference]; |
| 415 // If in `a.length` the `a` prefix is a top-level variable or a field, | 415 // If in `a.length` the `a` prefix is a top-level variable or a field, |
| 416 // then it must be the `String.length` property reference. | 416 // then it must be the `String.length` property reference. |
| 417 if (namespace == null && reference.name == 'length') { | 417 if (namespace == null && reference.name == 'length') { |
| 418 ReferenceKind prefixKind = references[reference.prefixReference].kind; | 418 ReferenceKind prefixKind = references[reference.prefixReference].kind; |
| 419 if (prefixKind == ReferenceKind.topLevelPropertyAccessor || | 419 if (prefixKind == ReferenceKind.topLevelPropertyAccessor || |
| 420 prefixKind == ReferenceKind.constField) { | 420 prefixKind == ReferenceKind.propertyAccessor) { |
| 421 references | 421 references |
| 422 .add(new LinkedReferenceBuilder(kind: ReferenceKind.length)); | 422 .add(new LinkedReferenceBuilder(kind: ReferenceKind.length)); |
| 423 continue; | 423 continue; |
| 424 } | 424 } |
| 425 } | 425 } |
| 426 // Prefix references must always point to proper prefixes. | 426 // Prefix references must always point to proper prefixes. |
| 427 assert(namespace != null); | 427 assert(namespace != null); |
| 428 } | 428 } |
| 429 _Meaning meaning = namespace[reference.name]; | 429 _Meaning meaning = namespace[reference.name]; |
| 430 if (meaning != null) { | 430 if (meaning != null) { |
| (...skipping 68 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 499 * [sourceUri] is also relative. | 499 * [sourceUri] is also relative. |
| 500 */ | 500 */ |
| 501 String resolveUri(String sourceUri, String relativeUri) { | 501 String resolveUri(String sourceUri, String relativeUri) { |
| 502 if (sourceUri == null) { | 502 if (sourceUri == null) { |
| 503 return relativeUri; | 503 return relativeUri; |
| 504 } else { | 504 } else { |
| 505 return Uri.parse(sourceUri).resolve(relativeUri).toString(); | 505 return Uri.parse(sourceUri).resolve(relativeUri).toString(); |
| 506 } | 506 } |
| 507 } | 507 } |
| 508 } | 508 } |
| OLD | NEW |