Chromium Code Reviews| 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 services.index; | 5 library services.index; |
| 6 | 6 |
| 7 import 'dart:async'; | 7 import 'dart:async'; |
| 8 | 8 |
| 9 import 'package:analyzer/src/generated/ast.dart'; | 9 import 'package:analyzer/src/generated/ast.dart'; |
| 10 import 'package:analyzer/src/generated/element.dart'; | 10 import 'package:analyzer/src/generated/element.dart'; |
| (...skipping 302 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 313 * Relationship between an element and a location. Relationships are identified | 313 * Relationship between an element and a location. Relationships are identified |
| 314 * by a globally unique identifier. | 314 * by a globally unique identifier. |
| 315 */ | 315 */ |
| 316 class Relationship { | 316 class Relationship { |
| 317 /** | 317 /** |
| 318 * A table mapping relationship identifiers to relationships. | 318 * A table mapping relationship identifiers to relationships. |
| 319 */ | 319 */ |
| 320 static Map<String, Relationship> _RELATIONSHIP_MAP = {}; | 320 static Map<String, Relationship> _RELATIONSHIP_MAP = {}; |
| 321 | 321 |
| 322 /** | 322 /** |
| 323 * The next artificial hash code. | |
| 324 */ | |
| 325 static int _NEXT_HASH_CODE = 0; | |
| 326 | |
| 327 /** | |
| 328 * The artifitial hash code for this object. | |
| 329 */ | |
| 330 final int _hashCode = _NEXT_HASH_CODE++; | |
|
kasperl
2015/02/18 08:04:16
Have you considered masking here? If you start ove
scheglov
2015/02/18 17:20:32
Good question.
See https://codereview.chromium.org
| |
| 331 | |
| 332 /** | |
| 323 * The unique identifier for this relationship. | 333 * The unique identifier for this relationship. |
| 324 */ | 334 */ |
| 325 final String identifier; | 335 final String identifier; |
| 326 | 336 |
| 327 /** | 337 /** |
| 328 * Initialize a newly created relationship with the given unique identifier. | 338 * Initialize a newly created relationship with the given unique identifier. |
| 329 */ | 339 */ |
| 330 Relationship(this.identifier); | 340 Relationship(this.identifier); |
| 331 | 341 |
| 332 @override | 342 @override |
| 343 int get hashCode => _hashCode; | |
| 344 | |
| 345 @override | |
| 333 String toString() => identifier; | 346 String toString() => identifier; |
| 334 | 347 |
| 335 /** | 348 /** |
| 336 * Returns the relationship with the given unique [identifier]. | 349 * Returns the relationship with the given unique [identifier]. |
| 337 */ | 350 */ |
| 338 static Relationship getRelationship(String identifier) { | 351 static Relationship getRelationship(String identifier) { |
| 339 Relationship relationship = _RELATIONSHIP_MAP[identifier]; | 352 Relationship relationship = _RELATIONSHIP_MAP[identifier]; |
| 340 if (relationship == null) { | 353 if (relationship == null) { |
| 341 relationship = new Relationship(identifier); | 354 relationship = new Relationship(identifier); |
| 342 _RELATIONSHIP_MAP[identifier] = relationship; | 355 _RELATIONSHIP_MAP[identifier] = relationship; |
| (...skipping 11 matching lines...) Expand all Loading... | |
| 354 static final UniverseElement INSTANCE = new UniverseElement._(); | 367 static final UniverseElement INSTANCE = new UniverseElement._(); |
| 355 | 368 |
| 356 UniverseElement._() : super("--universe--", -1); | 369 UniverseElement._() : super("--universe--", -1); |
| 357 | 370 |
| 358 @override | 371 @override |
| 359 ElementKind get kind => ElementKind.UNIVERSE; | 372 ElementKind get kind => ElementKind.UNIVERSE; |
| 360 | 373 |
| 361 @override | 374 @override |
| 362 accept(ElementVisitor visitor) => null; | 375 accept(ElementVisitor visitor) => null; |
| 363 } | 376 } |
| OLD | NEW |