Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(83)

Side by Side Diff: pkg/analyzer/lib/src/generated/index.dart

Issue 189803004: Translate private Java members to private Dart members. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Tweaks Created 6 years, 9 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « pkg/analyzer/lib/src/generated/html.dart ('k') | pkg/analyzer/lib/src/generated/parser.dart » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 // This code was auto-generated, is not intended to be edited, and is subject to 5 // This code was auto-generated, is not intended to be edited, and is subject to
6 // significant change. Please see the README file for more information. 6 // significant change. Please see the README file for more information.
7 7
8 library engine.index; 8 library engine.index;
9 9
10 import 'dart:collection' show Queue; 10 import 'dart:collection' show Queue;
(...skipping 93 matching lines...) Expand 10 before | Expand all | Expand 10 after
104 static AnalysisContext unwrapContext(AnalysisContext context) { 104 static AnalysisContext unwrapContext(AnalysisContext context) {
105 if (context is InstrumentedAnalysisContextImpl) { 105 if (context is InstrumentedAnalysisContextImpl) {
106 context = (context as InstrumentedAnalysisContextImpl).basis; 106 context = (context as InstrumentedAnalysisContextImpl).basis;
107 } 107 }
108 return context; 108 return context;
109 } 109 }
110 110
111 /** 111 /**
112 * @return the [Source] of the enclosing [LibraryElement], may be `null`. 112 * @return the [Source] of the enclosing [LibraryElement], may be `null`.
113 */ 113 */
114 static Source getLibrarySourceOrNull(Element element) { 114 static Source _getLibrarySourceOrNull(Element element) {
115 LibraryElement library = element.library; 115 LibraryElement library = element.library;
116 if (library == null) { 116 if (library == null) {
117 return null; 117 return null;
118 } 118 }
119 if (library.isAngularHtml) { 119 if (library.isAngularHtml) {
120 return null; 120 return null;
121 } 121 }
122 return library.source; 122 return library.source;
123 } 123 }
124 124
(...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after
164 164
165 int _sourceCount = 0; 165 int _sourceCount = 0;
166 166
167 int _keyCount = 0; 167 int _keyCount = 0;
168 168
169 int _locationCount = 0; 169 int _locationCount = 0;
170 170
171 bool aboutToIndexDart(AnalysisContext context, CompilationUnitElement unitElem ent) { 171 bool aboutToIndexDart(AnalysisContext context, CompilationUnitElement unitElem ent) {
172 context = unwrapContext(context); 172 context = unwrapContext(context);
173 // may be already removed in other thread 173 // may be already removed in other thread
174 if (isRemovedContext(context)) { 174 if (_isRemovedContext(context)) {
175 return false; 175 return false;
176 } 176 }
177 // validate unit 177 // validate unit
178 if (unitElement == null) { 178 if (unitElement == null) {
179 return false; 179 return false;
180 } 180 }
181 LibraryElement libraryElement = unitElement.library; 181 LibraryElement libraryElement = unitElement.library;
182 if (libraryElement == null) { 182 if (libraryElement == null) {
183 return false; 183 return false;
184 } 184 }
(...skipping 15 matching lines...) Expand all
200 Map<Source, Set<Source>> libraryToUnits = _contextToLibraryToUnits[context ]; 200 Map<Source, Set<Source>> libraryToUnits = _contextToLibraryToUnits[context ];
201 if (libraryToUnits == null) { 201 if (libraryToUnits == null) {
202 libraryToUnits = {}; 202 libraryToUnits = {};
203 _contextToLibraryToUnits[context] = libraryToUnits; 203 _contextToLibraryToUnits[context] = libraryToUnits;
204 } 204 }
205 Set<Source> oldParts = libraryToUnits[library]; 205 Set<Source> oldParts = libraryToUnits[library];
206 // check if some parts are not in the library now 206 // check if some parts are not in the library now
207 if (oldParts != null) { 207 if (oldParts != null) {
208 Set<Source> noParts = oldParts.difference(newParts); 208 Set<Source> noParts = oldParts.difference(newParts);
209 for (Source noPart in noParts) { 209 for (Source noPart in noParts) {
210 removeLocations(context, library, noPart); 210 _removeLocations(context, library, noPart);
211 } 211 }
212 } 212 }
213 // remember new parts 213 // remember new parts
214 libraryToUnits[library] = newParts; 214 libraryToUnits[library] = newParts;
215 } 215 }
216 // remember libraries in which unit is used 216 // remember libraries in which unit is used
217 recordUnitInLibrary(context, library, unit); 217 _recordUnitInLibrary(context, library, unit);
218 // remove locations 218 // remove locations
219 removeLocations(context, library, unit); 219 _removeLocations(context, library, unit);
220 // remove keys 220 // remove keys
221 { 221 {
222 Map<MemoryIndexStoreImpl_Source2, Set<MemoryIndexStoreImpl_ElementRelation Key>> sourceToKeys = _contextToSourceToKeys[context]; 222 Map<MemoryIndexStoreImpl_Source2, Set<MemoryIndexStoreImpl_ElementRelation Key>> sourceToKeys = _contextToSourceToKeys[context];
223 if (sourceToKeys != null) { 223 if (sourceToKeys != null) {
224 MemoryIndexStoreImpl_Source2 source2 = new MemoryIndexStoreImpl_Source2( library, unit); 224 MemoryIndexStoreImpl_Source2 source2 = new MemoryIndexStoreImpl_Source2( library, unit);
225 bool hadSource = sourceToKeys.remove(source2) != null; 225 bool hadSource = sourceToKeys.remove(source2) != null;
226 if (hadSource) { 226 if (hadSource) {
227 _sourceCount--; 227 _sourceCount--;
228 } 228 }
229 } 229 }
230 } 230 }
231 // OK, we can index 231 // OK, we can index
232 return true; 232 return true;
233 } 233 }
234 234
235 bool aboutToIndexHtml(AnalysisContext context, HtmlElement htmlElement) { 235 bool aboutToIndexHtml(AnalysisContext context, HtmlElement htmlElement) {
236 context = unwrapContext(context); 236 context = unwrapContext(context);
237 // may be already removed in other thread 237 // may be already removed in other thread
238 if (isRemovedContext(context)) { 238 if (_isRemovedContext(context)) {
239 return false; 239 return false;
240 } 240 }
241 // remove locations 241 // remove locations
242 Source source = htmlElement.source; 242 Source source = htmlElement.source;
243 removeLocations(context, null, source); 243 _removeLocations(context, null, source);
244 // remove keys 244 // remove keys
245 { 245 {
246 Map<MemoryIndexStoreImpl_Source2, Set<MemoryIndexStoreImpl_ElementRelation Key>> sourceToKeys = _contextToSourceToKeys[context]; 246 Map<MemoryIndexStoreImpl_Source2, Set<MemoryIndexStoreImpl_ElementRelation Key>> sourceToKeys = _contextToSourceToKeys[context];
247 if (sourceToKeys != null) { 247 if (sourceToKeys != null) {
248 MemoryIndexStoreImpl_Source2 source2 = new MemoryIndexStoreImpl_Source2( null, source); 248 MemoryIndexStoreImpl_Source2 source2 = new MemoryIndexStoreImpl_Source2( null, source);
249 bool hadSource = sourceToKeys.remove(source2) != null; 249 bool hadSource = sourceToKeys.remove(source2) != null;
250 if (hadSource) { 250 if (hadSource) {
251 _sourceCount--; 251 _sourceCount--;
252 } 252 }
253 } 253 }
254 } 254 }
255 // remember libraries in which unit is used 255 // remember libraries in which unit is used
256 recordUnitInLibrary(context, null, source); 256 _recordUnitInLibrary(context, null, source);
257 // OK, we can index 257 // OK, we can index
258 return true; 258 return true;
259 } 259 }
260 260
261 List<Location> getRelationships(Element element, Relationship relationship) { 261 List<Location> getRelationships(Element element, Relationship relationship) {
262 MemoryIndexStoreImpl_ElementRelationKey key = new MemoryIndexStoreImpl_Eleme ntRelationKey(element, relationship); 262 MemoryIndexStoreImpl_ElementRelationKey key = new MemoryIndexStoreImpl_Eleme ntRelationKey(element, relationship);
263 Set<Location> locations = _keyToLocations[key]; 263 Set<Location> locations = _keyToLocations[key];
264 if (locations != null) { 264 if (locations != null) {
265 return new List.from(locations); 265 return new List.from(locations);
266 } 266 }
(...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after
311 // at the index level we don't care about Member(s) 311 // at the index level we don't care about Member(s)
312 if (element is Member) { 312 if (element is Member) {
313 element = (element as Member).baseElement; 313 element = (element as Member).baseElement;
314 } 314 }
315 // System.out.println(element + " " + relationship + " " + location); 315 // System.out.println(element + " " + relationship + " " + location);
316 // prepare information 316 // prepare information
317 AnalysisContext elementContext = element.context; 317 AnalysisContext elementContext = element.context;
318 AnalysisContext locationContext = location.element.context; 318 AnalysisContext locationContext = location.element.context;
319 Source elementSource = element.source; 319 Source elementSource = element.source;
320 Source locationSource = location.element.source; 320 Source locationSource = location.element.source;
321 Source elementLibrarySource = getLibrarySourceOrNull(element); 321 Source elementLibrarySource = _getLibrarySourceOrNull(element);
322 Source locationLibrarySource = getLibrarySourceOrNull(location.element); 322 Source locationLibrarySource = _getLibrarySourceOrNull(location.element);
323 // sanity check 323 // sanity check
324 if (locationContext == null) { 324 if (locationContext == null) {
325 return; 325 return;
326 } 326 }
327 if (locationSource == null) { 327 if (locationSource == null) {
328 return; 328 return;
329 } 329 }
330 if (elementContext == null && element is! NameElementImpl && element is! Uni verseElementImpl) { 330 if (elementContext == null && element is! NameElementImpl && element is! Uni verseElementImpl) {
331 return; 331 return;
332 } 332 }
333 if (elementSource == null && element is! NameElementImpl && element is! Univ erseElementImpl) { 333 if (elementSource == null && element is! NameElementImpl && element is! Univ erseElementImpl) {
334 return; 334 return;
335 } 335 }
336 // may be already removed in other thread 336 // may be already removed in other thread
337 if (isRemovedContext(elementContext)) { 337 if (_isRemovedContext(elementContext)) {
338 return; 338 return;
339 } 339 }
340 if (isRemovedContext(locationContext)) { 340 if (_isRemovedContext(locationContext)) {
341 return; 341 return;
342 } 342 }
343 // record: key -> location(s) 343 // record: key -> location(s)
344 MemoryIndexStoreImpl_ElementRelationKey key = getCanonicalKey(element, relat ionship); 344 MemoryIndexStoreImpl_ElementRelationKey key = _getCanonicalKey(element, rela tionship);
345 { 345 {
346 Set<Location> locations = _keyToLocations.remove(key); 346 Set<Location> locations = _keyToLocations.remove(key);
347 if (locations == null) { 347 if (locations == null) {
348 locations = createLocationIdentitySet(); 348 locations = _createLocationIdentitySet();
349 } else { 349 } else {
350 _keyCount--; 350 _keyCount--;
351 } 351 }
352 _keyToLocations[key] = locations; 352 _keyToLocations[key] = locations;
353 _keyCount++; 353 _keyCount++;
354 locations.add(location); 354 locations.add(location);
355 _locationCount++; 355 _locationCount++;
356 } 356 }
357 // record: location -> key 357 // record: location -> key
358 location.internalKey = key; 358 location.internalKey = key;
(...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after
390 locations.add(location); 390 locations.add(location);
391 } 391 }
392 } 392 }
393 393
394 void removeContext(AnalysisContext context) { 394 void removeContext(AnalysisContext context) {
395 context = unwrapContext(context); 395 context = unwrapContext(context);
396 if (context == null) { 396 if (context == null) {
397 return; 397 return;
398 } 398 }
399 // mark as removed 399 // mark as removed
400 markRemovedContext(context); 400 _markRemovedContext(context);
401 removeSources(context, null); 401 removeSources(context, null);
402 // remove context 402 // remove context
403 _contextToSourceToKeys.remove(context); 403 _contextToSourceToKeys.remove(context);
404 _contextToSourceToLocations.remove(context); 404 _contextToSourceToLocations.remove(context);
405 _contextToLibraryToUnits.remove(context); 405 _contextToLibraryToUnits.remove(context);
406 _contextToUnitToLibraries.remove(context); 406 _contextToUnitToLibraries.remove(context);
407 } 407 }
408 408
409 void removeSource(AnalysisContext context, Source unit) { 409 void removeSource(AnalysisContext context, Source unit) {
410 context = unwrapContext(context); 410 context = unwrapContext(context);
411 if (context == null) { 411 if (context == null) {
412 return; 412 return;
413 } 413 }
414 // remove locations defined in source 414 // remove locations defined in source
415 Map<Source, Set<Source>> unitToLibraries = _contextToUnitToLibraries[context ]; 415 Map<Source, Set<Source>> unitToLibraries = _contextToUnitToLibraries[context ];
416 if (unitToLibraries != null) { 416 if (unitToLibraries != null) {
417 Set<Source> libraries = unitToLibraries.remove(unit); 417 Set<Source> libraries = unitToLibraries.remove(unit);
418 if (libraries != null) { 418 if (libraries != null) {
419 for (Source library in libraries) { 419 for (Source library in libraries) {
420 MemoryIndexStoreImpl_Source2 source2 = new MemoryIndexStoreImpl_Source 2(library, unit); 420 MemoryIndexStoreImpl_Source2 source2 = new MemoryIndexStoreImpl_Source 2(library, unit);
421 // remove locations defined in source 421 // remove locations defined in source
422 removeLocations(context, library, unit); 422 _removeLocations(context, library, unit);
423 // remove keys for elements defined in source 423 // remove keys for elements defined in source
424 Map<MemoryIndexStoreImpl_Source2, Set<MemoryIndexStoreImpl_ElementRela tionKey>> sourceToKeys = _contextToSourceToKeys[context]; 424 Map<MemoryIndexStoreImpl_Source2, Set<MemoryIndexStoreImpl_ElementRela tionKey>> sourceToKeys = _contextToSourceToKeys[context];
425 if (sourceToKeys != null) { 425 if (sourceToKeys != null) {
426 Set<MemoryIndexStoreImpl_ElementRelationKey> keys = sourceToKeys.rem ove(source2); 426 Set<MemoryIndexStoreImpl_ElementRelationKey> keys = sourceToKeys.rem ove(source2);
427 if (keys != null) { 427 if (keys != null) {
428 for (MemoryIndexStoreImpl_ElementRelationKey key in keys) { 428 for (MemoryIndexStoreImpl_ElementRelationKey key in keys) {
429 _canonicalKeys.remove(key); 429 _canonicalKeys.remove(key);
430 Set<Location> locations = _keyToLocations.remove(key); 430 Set<Location> locations = _keyToLocations.remove(key);
431 if (locations != null) { 431 if (locations != null) {
432 _keyCount--; 432 _keyCount--;
(...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after
466 if (container == null || container.contains(source)) { 466 if (container == null || container.contains(source)) {
467 removeSource(context, source); 467 removeSource(context, source);
468 } 468 }
469 } 469 }
470 } 470 }
471 } 471 }
472 472
473 /** 473 /**
474 * Creates new [Set] that uses object identity instead of equals. 474 * Creates new [Set] that uses object identity instead of equals.
475 */ 475 */
476 Set<Location> createLocationIdentitySet() => new Set<Location>.identity(); 476 Set<Location> _createLocationIdentitySet() => new Set<Location>.identity();
477 477
478 /** 478 /**
479 * @return the canonical [ElementRelationKey] for given [Element] and 479 * @return the canonical [ElementRelationKey] for given [Element] and
480 * [Relationship], i.e. unique instance for this combination. 480 * [Relationship], i.e. unique instance for this combination.
481 */ 481 */
482 MemoryIndexStoreImpl_ElementRelationKey getCanonicalKey(Element element, Relat ionship relationship) { 482 MemoryIndexStoreImpl_ElementRelationKey _getCanonicalKey(Element element, Rela tionship relationship) {
483 MemoryIndexStoreImpl_ElementRelationKey key = new MemoryIndexStoreImpl_Eleme ntRelationKey(element, relationship); 483 MemoryIndexStoreImpl_ElementRelationKey key = new MemoryIndexStoreImpl_Eleme ntRelationKey(element, relationship);
484 MemoryIndexStoreImpl_ElementRelationKey canonicalKey = _canonicalKeys[key]; 484 MemoryIndexStoreImpl_ElementRelationKey canonicalKey = _canonicalKeys[key];
485 if (canonicalKey == null) { 485 if (canonicalKey == null) {
486 canonicalKey = key; 486 canonicalKey = key;
487 _canonicalKeys[key] = canonicalKey; 487 _canonicalKeys[key] = canonicalKey;
488 } 488 }
489 return canonicalKey; 489 return canonicalKey;
490 } 490 }
491 491
492 /** 492 /**
493 * Checks if given [AnalysisContext] is marked as removed. 493 * Checks if given [AnalysisContext] is marked as removed.
494 */ 494 */
495 bool isRemovedContext(AnalysisContext context) => _removedContexts[context] != null; 495 bool _isRemovedContext(AnalysisContext context) => _removedContexts[context] ! = null;
496 496
497 /** 497 /**
498 * Marks given [AnalysisContext] as removed. 498 * Marks given [AnalysisContext] as removed.
499 */ 499 */
500 void markRemovedContext(AnalysisContext context) { 500 void _markRemovedContext(AnalysisContext context) {
501 _removedContexts[context] = true; 501 _removedContexts[context] = true;
502 } 502 }
503 503
504 void recordUnitInLibrary(AnalysisContext context, Source library, Source unit) { 504 void _recordUnitInLibrary(AnalysisContext context, Source library, Source unit ) {
505 Map<Source, Set<Source>> unitToLibraries = _contextToUnitToLibraries[context ]; 505 Map<Source, Set<Source>> unitToLibraries = _contextToUnitToLibraries[context ];
506 if (unitToLibraries == null) { 506 if (unitToLibraries == null) {
507 unitToLibraries = {}; 507 unitToLibraries = {};
508 _contextToUnitToLibraries[context] = unitToLibraries; 508 _contextToUnitToLibraries[context] = unitToLibraries;
509 } 509 }
510 Set<Source> libraries = unitToLibraries[unit]; 510 Set<Source> libraries = unitToLibraries[unit];
511 if (libraries == null) { 511 if (libraries == null) {
512 libraries = new Set(); 512 libraries = new Set();
513 unitToLibraries[unit] = libraries; 513 unitToLibraries[unit] = libraries;
514 } 514 }
515 libraries.add(library); 515 libraries.add(library);
516 } 516 }
517 517
518 /** 518 /**
519 * Removes locations recorded in the given library/unit pair. 519 * Removes locations recorded in the given library/unit pair.
520 */ 520 */
521 void removeLocations(AnalysisContext context, Source library, Source unit) { 521 void _removeLocations(AnalysisContext context, Source library, Source unit) {
522 MemoryIndexStoreImpl_Source2 source2 = new MemoryIndexStoreImpl_Source2(libr ary, unit); 522 MemoryIndexStoreImpl_Source2 source2 = new MemoryIndexStoreImpl_Source2(libr ary, unit);
523 Map<MemoryIndexStoreImpl_Source2, List<Location>> sourceToLocations = _conte xtToSourceToLocations[context]; 523 Map<MemoryIndexStoreImpl_Source2, List<Location>> sourceToLocations = _conte xtToSourceToLocations[context];
524 if (sourceToLocations != null) { 524 if (sourceToLocations != null) {
525 List<Location> sourceLocations = sourceToLocations.remove(source2); 525 List<Location> sourceLocations = sourceToLocations.remove(source2);
526 if (sourceLocations != null) { 526 if (sourceLocations != null) {
527 for (Location location in sourceLocations) { 527 for (Location location in sourceLocations) {
528 MemoryIndexStoreImpl_ElementRelationKey key = location.internalKey as MemoryIndexStoreImpl_ElementRelationKey; 528 MemoryIndexStoreImpl_ElementRelationKey key = location.internalKey as MemoryIndexStoreImpl_ElementRelationKey;
529 Set<Location> relLocations = _keyToLocations[key]; 529 Set<Location> relLocations = _keyToLocations[key];
530 if (relLocations != null) { 530 if (relLocations != null) {
531 relLocations.remove(location); 531 relLocations.remove(location);
(...skipping 137 matching lines...) Expand 10 before | Expand all | Expand 10 after
669 */ 669 */
670 abstract class ExpressionVisitor extends ht.RecursiveXmlVisitor<Object> { 670 abstract class ExpressionVisitor extends ht.RecursiveXmlVisitor<Object> {
671 /** 671 /**
672 * Visits the given [Expression]s embedded into tag or attribute. 672 * Visits the given [Expression]s embedded into tag or attribute.
673 * 673 *
674 * @param expression the [Expression] to visit, not `null` 674 * @param expression the [Expression] to visit, not `null`
675 */ 675 */
676 void visitExpression(Expression expression); 676 void visitExpression(Expression expression);
677 677
678 Object visitXmlAttributeNode(ht.XmlAttributeNode node) { 678 Object visitXmlAttributeNode(ht.XmlAttributeNode node) {
679 visitExpressions(node.expressions); 679 _visitExpressions(node.expressions);
680 return super.visitXmlAttributeNode(node); 680 return super.visitXmlAttributeNode(node);
681 } 681 }
682 682
683 Object visitXmlTagNode(ht.XmlTagNode node) { 683 Object visitXmlTagNode(ht.XmlTagNode node) {
684 visitExpressions(node.expressions); 684 _visitExpressions(node.expressions);
685 return super.visitXmlTagNode(node); 685 return super.visitXmlTagNode(node);
686 } 686 }
687 687
688 /** 688 /**
689 * Visits [Expression]s of the given [XmlExpression]s. 689 * Visits [Expression]s of the given [XmlExpression]s.
690 */ 690 */
691 void visitExpressions(List<ht.XmlExpression> expressions) { 691 void _visitExpressions(List<ht.XmlExpression> expressions) {
692 for (ht.XmlExpression xmlExpression in expressions) { 692 for (ht.XmlExpression xmlExpression in expressions) {
693 if (xmlExpression is AngularXmlExpression) { 693 if (xmlExpression is AngularXmlExpression) {
694 AngularXmlExpression angularXmlExpression = xmlExpression; 694 AngularXmlExpression angularXmlExpression = xmlExpression;
695 List<Expression> dartExpressions = angularXmlExpression.expression.expre ssions; 695 List<Expression> dartExpressions = angularXmlExpression.expression.expre ssions;
696 for (Expression dartExpression in dartExpressions) { 696 for (Expression dartExpression in dartExpressions) {
697 visitExpression(dartExpression); 697 visitExpression(dartExpression);
698 } 698 }
699 } 699 }
700 if (xmlExpression is ht.RawXmlExpression) { 700 if (xmlExpression is ht.RawXmlExpression) {
701 ht.RawXmlExpression rawXmlExpression = xmlExpression; 701 ht.RawXmlExpression rawXmlExpression = xmlExpression;
(...skipping 254 matching lines...) Expand 10 before | Expand all | Expand 10 after
956 return unanalyzedSources; 956 return unanalyzedSources;
957 } else if (identical(_state, ProcessorState.STOPPED)) { 957 } else if (identical(_state, ProcessorState.STOPPED)) {
958 return unanalyzedSources; 958 return unanalyzedSources;
959 } else if (identical(_state, ProcessorState.RUNNING)) { 959 } else if (identical(_state, ProcessorState.RUNNING)) {
960 _state = ProcessorState.STOP_REQESTED; 960 _state = ProcessorState.STOP_REQESTED;
961 } 961 }
962 while (wait) { 962 while (wait) {
963 if (identical(_state, ProcessorState.STOPPED)) { 963 if (identical(_state, ProcessorState.STOPPED)) {
964 return unanalyzedSources; 964 return unanalyzedSources;
965 } 965 }
966 waitOneMs(); 966 _waitOneMs();
967 } 967 }
968 return unanalyzedSources; 968 return unanalyzedSources;
969 } 969 }
970 970
971 /** 971 /**
972 * Waits until processors will switch from "ready" to "running" state. 972 * Waits until processors will switch from "ready" to "running" state.
973 * 973 *
974 * @return `true` if processor is now actually in "running" state, e.g. not in "stopped" 974 * @return `true` if processor is now actually in "running" state, e.g. not in "stopped"
975 * state. 975 * state.
976 */ 976 */
977 bool waitForRunning() { 977 bool waitForRunning() {
978 while (identical(_state, ProcessorState.READY)) { 978 while (identical(_state, ProcessorState.READY)) {
979 threadYield(); 979 _threadYield();
980 } 980 }
981 return identical(_state, ProcessorState.RUNNING); 981 return identical(_state, ProcessorState.RUNNING);
982 } 982 }
983 983
984 /** 984 /**
985 * @return the [Source]s that are not indexed yet. 985 * @return the [Source]s that are not indexed yet.
986 */ 986 */
987 List<Source> get unanalyzedSources { 987 List<Source> get unanalyzedSources {
988 Set<Source> sources = new Set(); 988 Set<Source> sources = new Set();
989 for (IndexOperation operation in _queue.operations) { 989 for (IndexOperation operation in _queue.operations) {
990 if (operation is IndexUnitOperation) { 990 if (operation is IndexUnitOperation) {
991 Source source = operation.source; 991 Source source = operation.source;
992 sources.add(source); 992 sources.add(source);
993 } 993 }
994 } 994 }
995 return new List.from(sources); 995 return new List.from(sources);
996 } 996 }
997 997
998 /** 998 /**
999 * Return `true` if the current state is [ProcessorState#RUNNING]. 999 * Return `true` if the current state is [ProcessorState#RUNNING].
1000 * 1000 *
1001 * @return `true` if this processor is running 1001 * @return `true` if this processor is running
1002 */ 1002 */
1003 bool get isRunning => identical(_state, ProcessorState.RUNNING); 1003 bool get isRunning => identical(_state, ProcessorState.RUNNING);
1004 1004
1005 void threadYield() { 1005 void _threadYield() {
1006 } 1006 }
1007 1007
1008 void waitOneMs() { 1008 void _waitOneMs() {
1009 } 1009 }
1010 } 1010 }
1011 1011
1012 /** 1012 /**
1013 * The enumeration <code>ProcessorState</code> represents the possible states of an operation 1013 * The enumeration <code>ProcessorState</code> represents the possible states of an operation
1014 * processor. 1014 * processor.
1015 */ 1015 */
1016 class ProcessorState extends Enum<ProcessorState> { 1016 class ProcessorState extends Enum<ProcessorState> {
1017 /** 1017 /**
1018 * The processor is ready to be run (has not been run before). 1018 * The processor is ready to be run (has not been run before).
(...skipping 190 matching lines...) Expand 10 before | Expand all | Expand 10 after
1209 this._store = store; 1209 this._store = store;
1210 _indexContributor = new IndexContributor_AngularHtmlIndexContributor(store, this); 1210 _indexContributor = new IndexContributor_AngularHtmlIndexContributor(store, this);
1211 } 1211 }
1212 1212
1213 void visitExpression(Expression expression) { 1213 void visitExpression(Expression expression) {
1214 // NgFilter 1214 // NgFilter
1215 if (expression is SimpleIdentifier) { 1215 if (expression is SimpleIdentifier) {
1216 SimpleIdentifier identifier = expression; 1216 SimpleIdentifier identifier = expression;
1217 Element element = identifier.bestElement; 1217 Element element = identifier.bestElement;
1218 if (element is AngularElement) { 1218 if (element is AngularElement) {
1219 _store.recordRelationship(element, IndexConstants.ANGULAR_REFERENCE, cre ateLocationForIdentifier(identifier)); 1219 _store.recordRelationship(element, IndexConstants.ANGULAR_REFERENCE, _cr eateLocationForIdentifier(identifier));
1220 return; 1220 return;
1221 } 1221 }
1222 } 1222 }
1223 // index as a normal Dart expression 1223 // index as a normal Dart expression
1224 expression.accept(_indexContributor); 1224 expression.accept(_indexContributor);
1225 } 1225 }
1226 1226
1227 Object visitHtmlUnit(ht.HtmlUnit node) { 1227 Object visitHtmlUnit(ht.HtmlUnit node) {
1228 _htmlUnitElement = node.element; 1228 _htmlUnitElement = node.element;
1229 CompilationUnitElement dartUnitElement = _htmlUnitElement.angularCompilation Unit; 1229 CompilationUnitElement dartUnitElement = _htmlUnitElement.angularCompilation Unit;
1230 _indexContributor.enterScope(dartUnitElement); 1230 _indexContributor.enterScope(dartUnitElement);
1231 return super.visitHtmlUnit(node); 1231 return super.visitHtmlUnit(node);
1232 } 1232 }
1233 1233
1234 Object visitXmlAttributeNode(ht.XmlAttributeNode node) { 1234 Object visitXmlAttributeNode(ht.XmlAttributeNode node) {
1235 Element element = node.element; 1235 Element element = node.element;
1236 if (element != null) { 1236 if (element != null) {
1237 ht.Token nameToken = node.nameToken; 1237 ht.Token nameToken = node.nameToken;
1238 Location location = createLocationForToken(nameToken); 1238 Location location = _createLocationForToken(nameToken);
1239 _store.recordRelationship(element, IndexConstants.ANGULAR_REFERENCE, locat ion); 1239 _store.recordRelationship(element, IndexConstants.ANGULAR_REFERENCE, locat ion);
1240 } 1240 }
1241 return super.visitXmlAttributeNode(node); 1241 return super.visitXmlAttributeNode(node);
1242 } 1242 }
1243 1243
1244 Object visitXmlTagNode(ht.XmlTagNode node) { 1244 Object visitXmlTagNode(ht.XmlTagNode node) {
1245 Element element = node.element; 1245 Element element = node.element;
1246 if (element != null) { 1246 if (element != null) {
1247 // tag 1247 // tag
1248 { 1248 {
1249 ht.Token tagToken = node.tagToken; 1249 ht.Token tagToken = node.tagToken;
1250 Location location = createLocationForToken(tagToken); 1250 Location location = _createLocationForToken(tagToken);
1251 _store.recordRelationship(element, IndexConstants.ANGULAR_REFERENCE, loc ation); 1251 _store.recordRelationship(element, IndexConstants.ANGULAR_REFERENCE, loc ation);
1252 } 1252 }
1253 // maybe add closing tag range 1253 // maybe add closing tag range
1254 ht.Token closingTag = node.closingTag; 1254 ht.Token closingTag = node.closingTag;
1255 if (closingTag != null) { 1255 if (closingTag != null) {
1256 Location location = createLocationForToken(closingTag); 1256 Location location = _createLocationForToken(closingTag);
1257 _store.recordRelationship(element, IndexConstants.ANGULAR_CLOSING_TAG_RE FERENCE, location); 1257 _store.recordRelationship(element, IndexConstants.ANGULAR_CLOSING_TAG_RE FERENCE, location);
1258 } 1258 }
1259 } 1259 }
1260 return super.visitXmlTagNode(node); 1260 return super.visitXmlTagNode(node);
1261 } 1261 }
1262 1262
1263 Location createLocationForIdentifier(SimpleIdentifier identifier) => new Locat ion(_htmlUnitElement, identifier.offset, identifier.length); 1263 Location _createLocationForIdentifier(SimpleIdentifier identifier) => new Loca tion(_htmlUnitElement, identifier.offset, identifier.length);
1264 1264
1265 Location createLocationForToken(ht.Token token) => new Location(_htmlUnitEleme nt, token.offset, token.length); 1265 Location _createLocationForToken(ht.Token token) => new Location(_htmlUnitElem ent, token.offset, token.length);
1266 } 1266 }
1267 1267
1268 class IndexContributor_AngularHtmlIndexContributor extends IndexContributor { 1268 class IndexContributor_AngularHtmlIndexContributor extends IndexContributor {
1269 final AngularHtmlIndexContributor AngularHtmlIndexContributor_this; 1269 final AngularHtmlIndexContributor AngularHtmlIndexContributor_this;
1270 1270
1271 IndexContributor_AngularHtmlIndexContributor(IndexStore arg0, this.AngularHtml IndexContributor_this) : super(arg0); 1271 IndexContributor_AngularHtmlIndexContributor(IndexStore arg0, this.AngularHtml IndexContributor_this) : super(arg0);
1272 1272
1273 Element peekElement() => AngularHtmlIndexContributor_this._htmlUnitElement; 1273 Element peekElement() => AngularHtmlIndexContributor_this._htmlUnitElement;
1274 1274
1275 void recordRelationship(Element element, Relationship relationship, Location l ocation) { 1275 void recordRelationship(Element element, Relationship relationship, Location l ocation) {
(...skipping 269 matching lines...) Expand 10 before | Expand all | Expand 10 after
1545 info._periodEnd = invocation.period.end; 1545 info._periodEnd = invocation.period.end;
1546 } 1546 }
1547 } 1547 }
1548 // we need used Element 1548 // we need used Element
1549 if (usedElement == null) { 1549 if (usedElement == null) {
1550 return null; 1550 return null;
1551 } 1551 }
1552 // find ImportElement 1552 // find ImportElement
1553 String prefix = prefixNode.name; 1553 String prefix = prefixNode.name;
1554 Map<ImportElement, Set<Element>> importElementsMap = {}; 1554 Map<ImportElement, Set<Element>> importElementsMap = {};
1555 info._element = internalGetImportElement(libraryElement, prefix, usedElement , importElementsMap); 1555 info._element = _internalGetImportElement(libraryElement, prefix, usedElemen t, importElementsMap);
1556 if (info._element == null) { 1556 if (info._element == null) {
1557 return null; 1557 return null;
1558 } 1558 }
1559 return info; 1559 return info;
1560 } 1560 }
1561 1561
1562 /** 1562 /**
1563 * If the given expression has resolved type, returns the new location with th is type. 1563 * If the given expression has resolved type, returns the new location with th is type.
1564 * 1564 *
1565 * @param location the base location 1565 * @param location the base location
1566 * @param expression the expression assigned at the given location 1566 * @param expression the expression assigned at the given location
1567 */ 1567 */
1568 static Location getLocationWithExpressionType(Location location, Expression ex pression) { 1568 static Location _getLocationWithExpressionType(Location location, Expression e xpression) {
1569 if (expression != null) { 1569 if (expression != null) {
1570 return new LocationWithData<Type2>.con1(location, expression.bestType); 1570 return new LocationWithData<Type2>.con1(location, expression.bestType);
1571 } 1571 }
1572 return location; 1572 return location;
1573 } 1573 }
1574 1574
1575 /** 1575 /**
1576 * If the given node is the part of the [ConstructorFieldInitializer], returns location with 1576 * If the given node is the part of the [ConstructorFieldInitializer], returns location with
1577 * type of the initializer expression. 1577 * type of the initializer expression.
1578 */ 1578 */
1579 static Location getLocationWithInitializerType(SimpleIdentifier node, Location location) { 1579 static Location _getLocationWithInitializerType(SimpleIdentifier node, Locatio n location) {
1580 if (node.parent is ConstructorFieldInitializer) { 1580 if (node.parent is ConstructorFieldInitializer) {
1581 ConstructorFieldInitializer initializer = node.parent as ConstructorFieldI nitializer; 1581 ConstructorFieldInitializer initializer = node.parent as ConstructorFieldI nitializer;
1582 if (identical(initializer.fieldName, node)) { 1582 if (identical(initializer.fieldName, node)) {
1583 location = getLocationWithExpressionType(location, initializer.expressio n); 1583 location = _getLocationWithExpressionType(location, initializer.expressi on);
1584 } 1584 }
1585 } 1585 }
1586 return location; 1586 return location;
1587 } 1587 }
1588 1588
1589 /** 1589 /**
1590 * If the given identifier has a synthetic [PropertyAccessorElement], i.e. acc essor for 1590 * If the given identifier has a synthetic [PropertyAccessorElement], i.e. acc essor for
1591 * normal field, and it is LHS of assignment, then include [Type] of the assig ned value into 1591 * normal field, and it is LHS of assignment, then include [Type] of the assig ned value into
1592 * the [Location]. 1592 * the [Location].
1593 * 1593 *
1594 * @param identifier the identifier to record location 1594 * @param identifier the identifier to record location
1595 * @param element the element of the identifier 1595 * @param element the element of the identifier
1596 * @param location the raw location 1596 * @param location the raw location
1597 * @return the [Location] with the type of the assigned value 1597 * @return the [Location] with the type of the assigned value
1598 */ 1598 */
1599 static Location getLocationWithTypeAssignedToField(SimpleIdentifier identifier , Element element, Location location) { 1599 static Location _getLocationWithTypeAssignedToField(SimpleIdentifier identifie r, Element element, Location location) {
1600 // we need accessor 1600 // we need accessor
1601 if (element is! PropertyAccessorElement) { 1601 if (element is! PropertyAccessorElement) {
1602 return location; 1602 return location;
1603 } 1603 }
1604 PropertyAccessorElement accessor = element as PropertyAccessorElement; 1604 PropertyAccessorElement accessor = element as PropertyAccessorElement;
1605 // should be setter 1605 // should be setter
1606 if (!accessor.isSetter) { 1606 if (!accessor.isSetter) {
1607 return location; 1607 return location;
1608 } 1608 }
1609 // accessor should be synthetic, i.e. field normal 1609 // accessor should be synthetic, i.e. field normal
(...skipping 19 matching lines...) Expand all
1629 if (identical(prefixedIdentifier.identifier, node)) { 1629 if (identical(prefixedIdentifier.identifier, node)) {
1630 node = prefixedIdentifier; 1630 node = prefixedIdentifier;
1631 parent = prefixedIdentifier.parent; 1631 parent = prefixedIdentifier.parent;
1632 } 1632 }
1633 } 1633 }
1634 } 1634 }
1635 // OK, remember the type 1635 // OK, remember the type
1636 if (parent is AssignmentExpression) { 1636 if (parent is AssignmentExpression) {
1637 AssignmentExpression assignment = parent as AssignmentExpression; 1637 AssignmentExpression assignment = parent as AssignmentExpression;
1638 Expression rhs = assignment.rightHandSide; 1638 Expression rhs = assignment.rightHandSide;
1639 location = getLocationWithExpressionType(location, rhs); 1639 location = _getLocationWithExpressionType(location, rhs);
1640 } 1640 }
1641 // done 1641 // done
1642 return location; 1642 return location;
1643 } 1643 }
1644 1644
1645 /** 1645 /**
1646 * @return the [ImportElement] that declares given [PrefixElement] and imports library 1646 * @return the [ImportElement] that declares given [PrefixElement] and imports library
1647 * with given "usedElement". 1647 * with given "usedElement".
1648 */ 1648 */
1649 static ImportElement internalGetImportElement(LibraryElement libraryElement, S tring prefix, Element usedElement, Map<ImportElement, Set<Element>> importElemen tsMap) { 1649 static ImportElement _internalGetImportElement(LibraryElement libraryElement, String prefix, Element usedElement, Map<ImportElement, Set<Element>> importEleme ntsMap) {
1650 // validate Element 1650 // validate Element
1651 if (usedElement == null) { 1651 if (usedElement == null) {
1652 return null; 1652 return null;
1653 } 1653 }
1654 if (usedElement.enclosingElement is! CompilationUnitElement) { 1654 if (usedElement.enclosingElement is! CompilationUnitElement) {
1655 return null; 1655 return null;
1656 } 1656 }
1657 LibraryElement usedLibrary = usedElement.library; 1657 LibraryElement usedLibrary = usedElement.library;
1658 // find ImportElement that imports used library with used prefix 1658 // find ImportElement that imports used library with used prefix
1659 List<ImportElement> candidates = null; 1659 List<ImportElement> candidates = null;
(...skipping 49 matching lines...) Expand 10 before | Expand all | Expand 10 after
1709 return entry.getKey(); 1709 return entry.getKey();
1710 } 1710 }
1711 } 1711 }
1712 // not found 1712 // not found
1713 return null; 1713 return null;
1714 } 1714 }
1715 1715
1716 /** 1716 /**
1717 * @return `true` if given "node" is part of an import [Combinator]. 1717 * @return `true` if given "node" is part of an import [Combinator].
1718 */ 1718 */
1719 static bool isIdentifierInImportCombinator(SimpleIdentifier node) { 1719 static bool _isIdentifierInImportCombinator(SimpleIdentifier node) {
1720 AstNode parent = node.parent; 1720 AstNode parent = node.parent;
1721 return parent is Combinator; 1721 return parent is Combinator;
1722 } 1722 }
1723 1723
1724 /** 1724 /**
1725 * @return `true` if given "node" is part of [PrefixedIdentifier] "prefix.node ". 1725 * @return `true` if given "node" is part of [PrefixedIdentifier] "prefix.node ".
1726 */ 1726 */
1727 static bool isIdentifierInPrefixedIdentifier(SimpleIdentifier node) { 1727 static bool _isIdentifierInPrefixedIdentifier(SimpleIdentifier node) {
1728 AstNode parent = node.parent; 1728 AstNode parent = node.parent;
1729 return parent is PrefixedIdentifier && identical(parent.identifier, node); 1729 return parent is PrefixedIdentifier && identical(parent.identifier, node);
1730 } 1730 }
1731 1731
1732 /** 1732 /**
1733 * @return `true` if given [SimpleIdentifier] is "name" part of prefixed ident ifier or 1733 * @return `true` if given [SimpleIdentifier] is "name" part of prefixed ident ifier or
1734 * method invocation. 1734 * method invocation.
1735 */ 1735 */
1736 static bool isQualified(SimpleIdentifier node) { 1736 static bool _isQualified(SimpleIdentifier node) {
1737 AstNode parent = node.parent; 1737 AstNode parent = node.parent;
1738 if (parent is PrefixedIdentifier) { 1738 if (parent is PrefixedIdentifier) {
1739 return identical(parent.identifier, node); 1739 return identical(parent.identifier, node);
1740 } 1740 }
1741 if (parent is PropertyAccess) { 1741 if (parent is PropertyAccess) {
1742 return identical(parent.propertyName, node); 1742 return identical(parent.propertyName, node);
1743 } 1743 }
1744 if (parent is MethodInvocation) { 1744 if (parent is MethodInvocation) {
1745 MethodInvocation invocation = parent; 1745 MethodInvocation invocation = parent;
1746 return invocation.realTarget != null && identical(invocation.methodName, n ode); 1746 return invocation.realTarget != null && identical(invocation.methodName, n ode);
(...skipping 30 matching lines...) Expand all
1777 Element peekElement() { 1777 Element peekElement() {
1778 for (Element element in _elementStack) { 1778 for (Element element in _elementStack) {
1779 if (element != null) { 1779 if (element != null) {
1780 return element; 1780 return element;
1781 } 1781 }
1782 } 1782 }
1783 return null; 1783 return null;
1784 } 1784 }
1785 1785
1786 Object visitAssignmentExpression(AssignmentExpression node) { 1786 Object visitAssignmentExpression(AssignmentExpression node) {
1787 recordOperatorReference(node.operator, node.bestElement); 1787 _recordOperatorReference(node.operator, node.bestElement);
1788 return super.visitAssignmentExpression(node); 1788 return super.visitAssignmentExpression(node);
1789 } 1789 }
1790 1790
1791 Object visitBinaryExpression(BinaryExpression node) { 1791 Object visitBinaryExpression(BinaryExpression node) {
1792 recordOperatorReference(node.operator, node.bestElement); 1792 _recordOperatorReference(node.operator, node.bestElement);
1793 return super.visitBinaryExpression(node); 1793 return super.visitBinaryExpression(node);
1794 } 1794 }
1795 1795
1796 Object visitClassDeclaration(ClassDeclaration node) { 1796 Object visitClassDeclaration(ClassDeclaration node) {
1797 ClassElement element = node.element; 1797 ClassElement element = node.element;
1798 enterScope(element); 1798 enterScope(element);
1799 try { 1799 try {
1800 recordElementDefinition(element, IndexConstants.DEFINES_CLASS); 1800 _recordElementDefinition(element, IndexConstants.DEFINES_CLASS);
1801 { 1801 {
1802 ExtendsClause extendsClause = node.extendsClause; 1802 ExtendsClause extendsClause = node.extendsClause;
1803 if (extendsClause != null) { 1803 if (extendsClause != null) {
1804 TypeName superclassNode = extendsClause.superclass; 1804 TypeName superclassNode = extendsClause.superclass;
1805 recordSuperType(superclassNode, IndexConstants.IS_EXTENDED_BY); 1805 _recordSuperType(superclassNode, IndexConstants.IS_EXTENDED_BY);
1806 } else { 1806 } else {
1807 InterfaceType superType = element.supertype; 1807 InterfaceType superType = element.supertype;
1808 if (superType != null) { 1808 if (superType != null) {
1809 ClassElement objectElement = superType.element; 1809 ClassElement objectElement = superType.element;
1810 recordRelationship(objectElement, IndexConstants.IS_EXTENDED_BY, cre ateLocationFromOffset(node.name.offset, 0)); 1810 recordRelationship(objectElement, IndexConstants.IS_EXTENDED_BY, _cr eateLocationFromOffset(node.name.offset, 0));
1811 } 1811 }
1812 } 1812 }
1813 } 1813 }
1814 { 1814 {
1815 WithClause withClause = node.withClause; 1815 WithClause withClause = node.withClause;
1816 if (withClause != null) { 1816 if (withClause != null) {
1817 for (TypeName mixinNode in withClause.mixinTypes) { 1817 for (TypeName mixinNode in withClause.mixinTypes) {
1818 recordSuperType(mixinNode, IndexConstants.IS_MIXED_IN_BY); 1818 _recordSuperType(mixinNode, IndexConstants.IS_MIXED_IN_BY);
1819 } 1819 }
1820 } 1820 }
1821 } 1821 }
1822 { 1822 {
1823 ImplementsClause implementsClause = node.implementsClause; 1823 ImplementsClause implementsClause = node.implementsClause;
1824 if (implementsClause != null) { 1824 if (implementsClause != null) {
1825 for (TypeName interfaceNode in implementsClause.interfaces) { 1825 for (TypeName interfaceNode in implementsClause.interfaces) {
1826 recordSuperType(interfaceNode, IndexConstants.IS_IMPLEMENTED_BY); 1826 _recordSuperType(interfaceNode, IndexConstants.IS_IMPLEMENTED_BY);
1827 } 1827 }
1828 } 1828 }
1829 } 1829 }
1830 return super.visitClassDeclaration(node); 1830 return super.visitClassDeclaration(node);
1831 } finally { 1831 } finally {
1832 exitScope(); 1832 _exitScope();
1833 } 1833 }
1834 } 1834 }
1835 1835
1836 Object visitClassTypeAlias(ClassTypeAlias node) { 1836 Object visitClassTypeAlias(ClassTypeAlias node) {
1837 ClassElement element = node.element; 1837 ClassElement element = node.element;
1838 enterScope(element); 1838 enterScope(element);
1839 try { 1839 try {
1840 recordElementDefinition(element, IndexConstants.DEFINES_CLASS_ALIAS); 1840 _recordElementDefinition(element, IndexConstants.DEFINES_CLASS_ALIAS);
1841 { 1841 {
1842 TypeName superclassNode = node.superclass; 1842 TypeName superclassNode = node.superclass;
1843 if (superclassNode != null) { 1843 if (superclassNode != null) {
1844 recordSuperType(superclassNode, IndexConstants.IS_EXTENDED_BY); 1844 _recordSuperType(superclassNode, IndexConstants.IS_EXTENDED_BY);
1845 } 1845 }
1846 } 1846 }
1847 { 1847 {
1848 WithClause withClause = node.withClause; 1848 WithClause withClause = node.withClause;
1849 if (withClause != null) { 1849 if (withClause != null) {
1850 for (TypeName mixinNode in withClause.mixinTypes) { 1850 for (TypeName mixinNode in withClause.mixinTypes) {
1851 recordSuperType(mixinNode, IndexConstants.IS_MIXED_IN_BY); 1851 _recordSuperType(mixinNode, IndexConstants.IS_MIXED_IN_BY);
1852 } 1852 }
1853 } 1853 }
1854 } 1854 }
1855 { 1855 {
1856 ImplementsClause implementsClause = node.implementsClause; 1856 ImplementsClause implementsClause = node.implementsClause;
1857 if (implementsClause != null) { 1857 if (implementsClause != null) {
1858 for (TypeName interfaceNode in implementsClause.interfaces) { 1858 for (TypeName interfaceNode in implementsClause.interfaces) {
1859 recordSuperType(interfaceNode, IndexConstants.IS_IMPLEMENTED_BY); 1859 _recordSuperType(interfaceNode, IndexConstants.IS_IMPLEMENTED_BY);
1860 } 1860 }
1861 } 1861 }
1862 } 1862 }
1863 return super.visitClassTypeAlias(node); 1863 return super.visitClassTypeAlias(node);
1864 } finally { 1864 } finally {
1865 exitScope(); 1865 _exitScope();
1866 } 1866 }
1867 } 1867 }
1868 1868
1869 Object visitCompilationUnit(CompilationUnit node) { 1869 Object visitCompilationUnit(CompilationUnit node) {
1870 CompilationUnitElement unitElement = node.element; 1870 CompilationUnitElement unitElement = node.element;
1871 if (unitElement != null) { 1871 if (unitElement != null) {
1872 _elementStack.add(unitElement); 1872 _elementStack.add(unitElement);
1873 _libraryElement = unitElement.enclosingElement; 1873 _libraryElement = unitElement.enclosingElement;
1874 if (_libraryElement != null) { 1874 if (_libraryElement != null) {
1875 return super.visitCompilationUnit(node); 1875 return super.visitCompilationUnit(node);
1876 } 1876 }
1877 } 1877 }
1878 return null; 1878 return null;
1879 } 1879 }
1880 1880
1881 Object visitConstructorDeclaration(ConstructorDeclaration node) { 1881 Object visitConstructorDeclaration(ConstructorDeclaration node) {
1882 ConstructorElement element = node.element; 1882 ConstructorElement element = node.element;
1883 // define 1883 // define
1884 { 1884 {
1885 Location location; 1885 Location location;
1886 if (node.name != null) { 1886 if (node.name != null) {
1887 int start = node.period.offset; 1887 int start = node.period.offset;
1888 int end = node.name.end; 1888 int end = node.name.end;
1889 location = createLocationFromOffset(start, end - start); 1889 location = _createLocationFromOffset(start, end - start);
1890 } else { 1890 } else {
1891 int start = node.returnType.end; 1891 int start = node.returnType.end;
1892 location = createLocationFromOffset(start, 0); 1892 location = _createLocationFromOffset(start, 0);
1893 } 1893 }
1894 recordRelationship(element, IndexConstants.IS_DEFINED_BY, location); 1894 recordRelationship(element, IndexConstants.IS_DEFINED_BY, location);
1895 } 1895 }
1896 // visit children 1896 // visit children
1897 enterScope(element); 1897 enterScope(element);
1898 try { 1898 try {
1899 return super.visitConstructorDeclaration(node); 1899 return super.visitConstructorDeclaration(node);
1900 } finally { 1900 } finally {
1901 exitScope(); 1901 _exitScope();
1902 } 1902 }
1903 } 1903 }
1904 1904
1905 Object visitConstructorName(ConstructorName node) { 1905 Object visitConstructorName(ConstructorName node) {
1906 ConstructorElement element = node.staticElement; 1906 ConstructorElement element = node.staticElement;
1907 // in 'class B = A;' actually A constructors are invoked 1907 // in 'class B = A;' actually A constructors are invoked
1908 if (element != null && element.isSynthetic && element.redirectedConstructor != null) { 1908 if (element != null && element.isSynthetic && element.redirectedConstructor != null) {
1909 element = element.redirectedConstructor; 1909 element = element.redirectedConstructor;
1910 } 1910 }
1911 // prepare location 1911 // prepare location
1912 Location location; 1912 Location location;
1913 if (node.name != null) { 1913 if (node.name != null) {
1914 int start = node.period.offset; 1914 int start = node.period.offset;
1915 int end = node.name.end; 1915 int end = node.name.end;
1916 location = createLocationFromOffset(start, end - start); 1916 location = _createLocationFromOffset(start, end - start);
1917 } else { 1917 } else {
1918 int start = node.type.end; 1918 int start = node.type.end;
1919 location = createLocationFromOffset(start, 0); 1919 location = _createLocationFromOffset(start, 0);
1920 } 1920 }
1921 // record relationship 1921 // record relationship
1922 recordRelationship(element, IndexConstants.IS_REFERENCED_BY, location); 1922 recordRelationship(element, IndexConstants.IS_REFERENCED_BY, location);
1923 return super.visitConstructorName(node); 1923 return super.visitConstructorName(node);
1924 } 1924 }
1925 1925
1926 Object visitExportDirective(ExportDirective node) { 1926 Object visitExportDirective(ExportDirective node) {
1927 ExportElement element = node.element; 1927 ExportElement element = node.element;
1928 if (element != null) { 1928 if (element != null) {
1929 LibraryElement expLibrary = element.exportedLibrary; 1929 LibraryElement expLibrary = element.exportedLibrary;
1930 recordLibraryReference(node, expLibrary); 1930 _recordLibraryReference(node, expLibrary);
1931 } 1931 }
1932 return super.visitExportDirective(node); 1932 return super.visitExportDirective(node);
1933 } 1933 }
1934 1934
1935 Object visitFormalParameter(FormalParameter node) { 1935 Object visitFormalParameter(FormalParameter node) {
1936 ParameterElement element = node.element; 1936 ParameterElement element = node.element;
1937 enterScope(element); 1937 enterScope(element);
1938 try { 1938 try {
1939 return super.visitFormalParameter(node); 1939 return super.visitFormalParameter(node);
1940 } finally { 1940 } finally {
1941 exitScope(); 1941 _exitScope();
1942 } 1942 }
1943 } 1943 }
1944 1944
1945 Object visitFunctionDeclaration(FunctionDeclaration node) { 1945 Object visitFunctionDeclaration(FunctionDeclaration node) {
1946 Element element = node.element; 1946 Element element = node.element;
1947 recordElementDefinition(element, IndexConstants.DEFINES_FUNCTION); 1947 _recordElementDefinition(element, IndexConstants.DEFINES_FUNCTION);
1948 enterScope(element); 1948 enterScope(element);
1949 try { 1949 try {
1950 return super.visitFunctionDeclaration(node); 1950 return super.visitFunctionDeclaration(node);
1951 } finally { 1951 } finally {
1952 exitScope(); 1952 _exitScope();
1953 } 1953 }
1954 } 1954 }
1955 1955
1956 Object visitFunctionTypeAlias(FunctionTypeAlias node) { 1956 Object visitFunctionTypeAlias(FunctionTypeAlias node) {
1957 Element element = node.element; 1957 Element element = node.element;
1958 recordElementDefinition(element, IndexConstants.DEFINES_FUNCTION_TYPE); 1958 _recordElementDefinition(element, IndexConstants.DEFINES_FUNCTION_TYPE);
1959 return super.visitFunctionTypeAlias(node); 1959 return super.visitFunctionTypeAlias(node);
1960 } 1960 }
1961 1961
1962 Object visitImportDirective(ImportDirective node) { 1962 Object visitImportDirective(ImportDirective node) {
1963 ImportElement element = node.element; 1963 ImportElement element = node.element;
1964 if (element != null) { 1964 if (element != null) {
1965 LibraryElement impLibrary = element.importedLibrary; 1965 LibraryElement impLibrary = element.importedLibrary;
1966 recordLibraryReference(node, impLibrary); 1966 _recordLibraryReference(node, impLibrary);
1967 } 1967 }
1968 return super.visitImportDirective(node); 1968 return super.visitImportDirective(node);
1969 } 1969 }
1970 1970
1971 Object visitIndexExpression(IndexExpression node) { 1971 Object visitIndexExpression(IndexExpression node) {
1972 MethodElement element = node.bestElement; 1972 MethodElement element = node.bestElement;
1973 if (element is MethodElement) { 1973 if (element is MethodElement) {
1974 Token operator = node.leftBracket; 1974 Token operator = node.leftBracket;
1975 Location location = createLocationFromToken(operator); 1975 Location location = _createLocationFromToken(operator);
1976 recordRelationship(element, IndexConstants.IS_INVOKED_BY_QUALIFIED, locati on); 1976 recordRelationship(element, IndexConstants.IS_INVOKED_BY_QUALIFIED, locati on);
1977 } 1977 }
1978 return super.visitIndexExpression(node); 1978 return super.visitIndexExpression(node);
1979 } 1979 }
1980 1980
1981 Object visitMethodDeclaration(MethodDeclaration node) { 1981 Object visitMethodDeclaration(MethodDeclaration node) {
1982 ExecutableElement element = node.element; 1982 ExecutableElement element = node.element;
1983 enterScope(element); 1983 enterScope(element);
1984 try { 1984 try {
1985 return super.visitMethodDeclaration(node); 1985 return super.visitMethodDeclaration(node);
1986 } finally { 1986 } finally {
1987 exitScope(); 1987 _exitScope();
1988 } 1988 }
1989 } 1989 }
1990 1990
1991 Object visitMethodInvocation(MethodInvocation node) { 1991 Object visitMethodInvocation(MethodInvocation node) {
1992 SimpleIdentifier name = node.methodName; 1992 SimpleIdentifier name = node.methodName;
1993 Element element = name.bestElement; 1993 Element element = name.bestElement;
1994 if (element is MethodElement) { 1994 if (element is MethodElement) {
1995 Location location = createLocationFromNode(name); 1995 Location location = _createLocationFromNode(name);
1996 Relationship relationship; 1996 Relationship relationship;
1997 if (node.target != null) { 1997 if (node.target != null) {
1998 relationship = IndexConstants.IS_INVOKED_BY_QUALIFIED; 1998 relationship = IndexConstants.IS_INVOKED_BY_QUALIFIED;
1999 } else { 1999 } else {
2000 relationship = IndexConstants.IS_INVOKED_BY_UNQUALIFIED; 2000 relationship = IndexConstants.IS_INVOKED_BY_UNQUALIFIED;
2001 } 2001 }
2002 recordRelationship(element, relationship, location); 2002 recordRelationship(element, relationship, location);
2003 } 2003 }
2004 if (element is FunctionElement) { 2004 if (element is FunctionElement) {
2005 Location location = createLocationFromNode(name); 2005 Location location = _createLocationFromNode(name);
2006 recordRelationship(element, IndexConstants.IS_INVOKED_BY, location); 2006 recordRelationship(element, IndexConstants.IS_INVOKED_BY, location);
2007 } 2007 }
2008 recordImportElementReferenceWithoutPrefix(name); 2008 _recordImportElementReferenceWithoutPrefix(name);
2009 return super.visitMethodInvocation(node); 2009 return super.visitMethodInvocation(node);
2010 } 2010 }
2011 2011
2012 Object visitPartDirective(PartDirective node) { 2012 Object visitPartDirective(PartDirective node) {
2013 Element element = node.element; 2013 Element element = node.element;
2014 Location location = createLocationFromNode(node.uri); 2014 Location location = _createLocationFromNode(node.uri);
2015 recordRelationship(element, IndexConstants.IS_REFERENCED_BY, location); 2015 recordRelationship(element, IndexConstants.IS_REFERENCED_BY, location);
2016 return super.visitPartDirective(node); 2016 return super.visitPartDirective(node);
2017 } 2017 }
2018 2018
2019 Object visitPartOfDirective(PartOfDirective node) { 2019 Object visitPartOfDirective(PartOfDirective node) {
2020 Location location = createLocationFromNode(node.libraryName); 2020 Location location = _createLocationFromNode(node.libraryName);
2021 recordRelationship(node.element, IndexConstants.IS_REFERENCED_BY, location); 2021 recordRelationship(node.element, IndexConstants.IS_REFERENCED_BY, location);
2022 return null; 2022 return null;
2023 } 2023 }
2024 2024
2025 Object visitPostfixExpression(PostfixExpression node) { 2025 Object visitPostfixExpression(PostfixExpression node) {
2026 recordOperatorReference(node.operator, node.bestElement); 2026 _recordOperatorReference(node.operator, node.bestElement);
2027 return super.visitPostfixExpression(node); 2027 return super.visitPostfixExpression(node);
2028 } 2028 }
2029 2029
2030 Object visitPrefixExpression(PrefixExpression node) { 2030 Object visitPrefixExpression(PrefixExpression node) {
2031 recordOperatorReference(node.operator, node.bestElement); 2031 _recordOperatorReference(node.operator, node.bestElement);
2032 return super.visitPrefixExpression(node); 2032 return super.visitPrefixExpression(node);
2033 } 2033 }
2034 2034
2035 Object visitSimpleIdentifier(SimpleIdentifier node) { 2035 Object visitSimpleIdentifier(SimpleIdentifier node) {
2036 Element nameElement = new NameElementImpl(node.name); 2036 Element nameElement = new NameElementImpl(node.name);
2037 Location location = createLocationFromNode(node); 2037 Location location = _createLocationFromNode(node);
2038 // name in declaration 2038 // name in declaration
2039 if (node.inDeclarationContext()) { 2039 if (node.inDeclarationContext()) {
2040 recordRelationship(nameElement, IndexConstants.IS_DEFINED_BY, location); 2040 recordRelationship(nameElement, IndexConstants.IS_DEFINED_BY, location);
2041 return null; 2041 return null;
2042 } 2042 }
2043 // prepare information 2043 // prepare information
2044 Element element = node.bestElement; 2044 Element element = node.bestElement;
2045 // qualified name reference 2045 // qualified name reference
2046 recordQualifiedMemberReference(node, element, nameElement, location); 2046 _recordQualifiedMemberReference(node, element, nameElement, location);
2047 // stop if already handled 2047 // stop if already handled
2048 if (isAlreadyHandledName(node)) { 2048 if (_isAlreadyHandledName(node)) {
2049 return null; 2049 return null;
2050 } 2050 }
2051 // record specific relations 2051 // record specific relations
2052 if (element is ClassElement || element is FunctionElement || element is Func tionTypeAliasElement || element is LabelElement || element is TypeParameterEleme nt) { 2052 if (element is ClassElement || element is FunctionElement || element is Func tionTypeAliasElement || element is LabelElement || element is TypeParameterEleme nt) {
2053 recordRelationship(element, IndexConstants.IS_REFERENCED_BY, location); 2053 recordRelationship(element, IndexConstants.IS_REFERENCED_BY, location);
2054 } else if (element is FieldElement) { 2054 } else if (element is FieldElement) {
2055 location = getLocationWithInitializerType(node, location); 2055 location = _getLocationWithInitializerType(node, location);
2056 recordRelationship(element, IndexConstants.IS_REFERENCED_BY, location); 2056 recordRelationship(element, IndexConstants.IS_REFERENCED_BY, location);
2057 } else if (element is FieldFormalParameterElement) { 2057 } else if (element is FieldFormalParameterElement) {
2058 FieldFormalParameterElement fieldParameter = element; 2058 FieldFormalParameterElement fieldParameter = element;
2059 FieldElement field = fieldParameter.field; 2059 FieldElement field = fieldParameter.field;
2060 recordRelationship(field, IndexConstants.IS_REFERENCED_BY_QUALIFIED, locat ion); 2060 recordRelationship(field, IndexConstants.IS_REFERENCED_BY_QUALIFIED, locat ion);
2061 } else if (element is PrefixElement) { 2061 } else if (element is PrefixElement) {
2062 recordImportElementReferenceWithPrefix(node); 2062 _recordImportElementReferenceWithPrefix(node);
2063 } else if (element is PropertyAccessorElement || element is MethodElement) { 2063 } else if (element is PropertyAccessorElement || element is MethodElement) {
2064 location = getLocationWithTypeAssignedToField(node, element, location); 2064 location = _getLocationWithTypeAssignedToField(node, element, location);
2065 if (isQualified(node)) { 2065 if (_isQualified(node)) {
2066 recordRelationship(element, IndexConstants.IS_REFERENCED_BY_QUALIFIED, l ocation); 2066 recordRelationship(element, IndexConstants.IS_REFERENCED_BY_QUALIFIED, l ocation);
2067 } else { 2067 } else {
2068 recordRelationship(element, IndexConstants.IS_REFERENCED_BY_UNQUALIFIED, location); 2068 recordRelationship(element, IndexConstants.IS_REFERENCED_BY_UNQUALIFIED, location);
2069 } 2069 }
2070 } else if (element is ParameterElement || element is LocalVariableElement) { 2070 } else if (element is ParameterElement || element is LocalVariableElement) {
2071 bool inGetterContext = node.inGetterContext(); 2071 bool inGetterContext = node.inGetterContext();
2072 bool inSetterContext = node.inSetterContext(); 2072 bool inSetterContext = node.inSetterContext();
2073 if (inGetterContext && inSetterContext) { 2073 if (inGetterContext && inSetterContext) {
2074 recordRelationship(element, IndexConstants.IS_READ_WRITTEN_BY, location) ; 2074 recordRelationship(element, IndexConstants.IS_READ_WRITTEN_BY, location) ;
2075 } else if (inGetterContext) { 2075 } else if (inGetterContext) {
2076 recordRelationship(element, IndexConstants.IS_READ_BY, location); 2076 recordRelationship(element, IndexConstants.IS_READ_BY, location);
2077 } else if (inSetterContext) { 2077 } else if (inSetterContext) {
2078 recordRelationship(element, IndexConstants.IS_WRITTEN_BY, location); 2078 recordRelationship(element, IndexConstants.IS_WRITTEN_BY, location);
2079 } else { 2079 } else {
2080 recordRelationship(element, IndexConstants.IS_REFERENCED_BY, location); 2080 recordRelationship(element, IndexConstants.IS_REFERENCED_BY, location);
2081 } 2081 }
2082 } 2082 }
2083 recordImportElementReferenceWithoutPrefix(node); 2083 _recordImportElementReferenceWithoutPrefix(node);
2084 return super.visitSimpleIdentifier(node); 2084 return super.visitSimpleIdentifier(node);
2085 } 2085 }
2086 2086
2087 Object visitSuperConstructorInvocation(SuperConstructorInvocation node) { 2087 Object visitSuperConstructorInvocation(SuperConstructorInvocation node) {
2088 ConstructorElement element = node.staticElement; 2088 ConstructorElement element = node.staticElement;
2089 Location location; 2089 Location location;
2090 if (node.constructorName != null) { 2090 if (node.constructorName != null) {
2091 int start = node.period.offset; 2091 int start = node.period.offset;
2092 int end = node.constructorName.end; 2092 int end = node.constructorName.end;
2093 location = createLocationFromOffset(start, end - start); 2093 location = _createLocationFromOffset(start, end - start);
2094 } else { 2094 } else {
2095 int start = node.keyword.end; 2095 int start = node.keyword.end;
2096 location = createLocationFromOffset(start, 0); 2096 location = _createLocationFromOffset(start, 0);
2097 } 2097 }
2098 recordRelationship(element, IndexConstants.IS_REFERENCED_BY, location); 2098 recordRelationship(element, IndexConstants.IS_REFERENCED_BY, location);
2099 return super.visitSuperConstructorInvocation(node); 2099 return super.visitSuperConstructorInvocation(node);
2100 } 2100 }
2101 2101
2102 Object visitTopLevelVariableDeclaration(TopLevelVariableDeclaration node) { 2102 Object visitTopLevelVariableDeclaration(TopLevelVariableDeclaration node) {
2103 VariableDeclarationList variables = node.variables; 2103 VariableDeclarationList variables = node.variables;
2104 for (VariableDeclaration variableDeclaration in variables.variables) { 2104 for (VariableDeclaration variableDeclaration in variables.variables) {
2105 Element element = variableDeclaration.element; 2105 Element element = variableDeclaration.element;
2106 recordElementDefinition(element, IndexConstants.DEFINES_VARIABLE); 2106 _recordElementDefinition(element, IndexConstants.DEFINES_VARIABLE);
2107 } 2107 }
2108 return super.visitTopLevelVariableDeclaration(node); 2108 return super.visitTopLevelVariableDeclaration(node);
2109 } 2109 }
2110 2110
2111 Object visitTypeParameter(TypeParameter node) { 2111 Object visitTypeParameter(TypeParameter node) {
2112 TypeParameterElement element = node.element; 2112 TypeParameterElement element = node.element;
2113 enterScope(element); 2113 enterScope(element);
2114 try { 2114 try {
2115 return super.visitTypeParameter(node); 2115 return super.visitTypeParameter(node);
2116 } finally { 2116 } finally {
2117 exitScope(); 2117 _exitScope();
2118 } 2118 }
2119 } 2119 }
2120 2120
2121 Object visitVariableDeclaration(VariableDeclaration node) { 2121 Object visitVariableDeclaration(VariableDeclaration node) {
2122 VariableElement element = node.element; 2122 VariableElement element = node.element;
2123 // record declaration 2123 // record declaration
2124 { 2124 {
2125 SimpleIdentifier name = node.name; 2125 SimpleIdentifier name = node.name;
2126 Location location = createLocationFromNode(name); 2126 Location location = _createLocationFromNode(name);
2127 location = getLocationWithExpressionType(location, node.initializer); 2127 location = _getLocationWithExpressionType(location, node.initializer);
2128 recordRelationship(element, IndexConstants.IS_DEFINED_BY, location); 2128 recordRelationship(element, IndexConstants.IS_DEFINED_BY, location);
2129 } 2129 }
2130 // visit 2130 // visit
2131 enterScope(element); 2131 enterScope(element);
2132 try { 2132 try {
2133 return super.visitVariableDeclaration(node); 2133 return super.visitVariableDeclaration(node);
2134 } finally { 2134 } finally {
2135 exitScope(); 2135 _exitScope();
2136 } 2136 }
2137 } 2137 }
2138 2138
2139 Object visitVariableDeclarationList(VariableDeclarationList node) { 2139 Object visitVariableDeclarationList(VariableDeclarationList node) {
2140 NodeList<VariableDeclaration> variables = node.variables; 2140 NodeList<VariableDeclaration> variables = node.variables;
2141 if (variables != null) { 2141 if (variables != null) {
2142 // use first VariableDeclaration as Element for Location(s) in type 2142 // use first VariableDeclaration as Element for Location(s) in type
2143 { 2143 {
2144 TypeName type = node.type; 2144 TypeName type = node.type;
2145 if (type != null) { 2145 if (type != null) {
2146 for (VariableDeclaration variableDeclaration in variables) { 2146 for (VariableDeclaration variableDeclaration in variables) {
2147 enterScope(variableDeclaration.element); 2147 enterScope(variableDeclaration.element);
2148 try { 2148 try {
2149 type.accept(this); 2149 type.accept(this);
2150 } finally { 2150 } finally {
2151 exitScope(); 2151 _exitScope();
2152 } 2152 }
2153 // only one iteration 2153 // only one iteration
2154 break; 2154 break;
2155 } 2155 }
2156 } 2156 }
2157 } 2157 }
2158 // visit variables 2158 // visit variables
2159 variables.accept(this); 2159 variables.accept(this);
2160 } 2160 }
2161 return null; 2161 return null;
2162 } 2162 }
2163 2163
2164 /** 2164 /**
2165 * Record the given relationship between the given [Element] and [Location]. 2165 * Record the given relationship between the given [Element] and [Location].
2166 */ 2166 */
2167 void recordRelationship(Element element, Relationship relationship, Location l ocation) { 2167 void recordRelationship(Element element, Relationship relationship, Location l ocation) {
2168 if (element != null && location != null) { 2168 if (element != null && location != null) {
2169 _store.recordRelationship(element, relationship, location); 2169 _store.recordRelationship(element, relationship, location);
2170 } 2170 }
2171 } 2171 }
2172 2172
2173 /** 2173 /**
2174 * @return the [Location] representing location of the [AstNode]. 2174 * @return the [Location] representing location of the [AstNode].
2175 */ 2175 */
2176 Location createLocationFromNode(AstNode node) => createLocationFromOffset(node .offset, node.length); 2176 Location _createLocationFromNode(AstNode node) => _createLocationFromOffset(no de.offset, node.length);
2177 2177
2178 /** 2178 /**
2179 * @param offset the offset of the location within [Source] 2179 * @param offset the offset of the location within [Source]
2180 * @param length the length of the location 2180 * @param length the length of the location
2181 * @return the [Location] representing the given offset and length within the inner-most 2181 * @return the [Location] representing the given offset and length within the inner-most
2182 * [Element]. 2182 * [Element].
2183 */ 2183 */
2184 Location createLocationFromOffset(int offset, int length) { 2184 Location _createLocationFromOffset(int offset, int length) {
2185 Element element = peekElement(); 2185 Element element = peekElement();
2186 return new Location(element, offset, length); 2186 return new Location(element, offset, length);
2187 } 2187 }
2188 2188
2189 /** 2189 /**
2190 * @return the [Location] representing location of the [Token]. 2190 * @return the [Location] representing location of the [Token].
2191 */ 2191 */
2192 Location createLocationFromToken(Token token) => createLocationFromOffset(toke n.offset, token.length); 2192 Location _createLocationFromToken(Token token) => _createLocationFromOffset(to ken.offset, token.length);
2193 2193
2194 /** 2194 /**
2195 * Exit the current scope. 2195 * Exit the current scope.
2196 */ 2196 */
2197 void exitScope() { 2197 void _exitScope() {
2198 _elementStack.removeFirst(); 2198 _elementStack.removeFirst();
2199 } 2199 }
2200 2200
2201 /** 2201 /**
2202 * @return `true` if given node already indexed as more interesting reference, so it should 2202 * @return `true` if given node already indexed as more interesting reference, so it should
2203 * not be indexed again. 2203 * not be indexed again.
2204 */ 2204 */
2205 bool isAlreadyHandledName(SimpleIdentifier node) { 2205 bool _isAlreadyHandledName(SimpleIdentifier node) {
2206 AstNode parent = node.parent; 2206 AstNode parent = node.parent;
2207 if (parent is MethodInvocation) { 2207 if (parent is MethodInvocation) {
2208 Element element = node.staticElement; 2208 Element element = node.staticElement;
2209 if (element is MethodElement || element is FunctionElement) { 2209 if (element is MethodElement || element is FunctionElement) {
2210 return identical(parent.methodName, node); 2210 return identical(parent.methodName, node);
2211 } 2211 }
2212 } 2212 }
2213 return false; 2213 return false;
2214 } 2214 }
2215 2215
2216 /** 2216 /**
2217 * Records the [Element] definition in the library and universe. 2217 * Records the [Element] definition in the library and universe.
2218 */ 2218 */
2219 void recordElementDefinition(Element element, Relationship relationship) { 2219 void _recordElementDefinition(Element element, Relationship relationship) {
2220 Location location = createLocation(element); 2220 Location location = createLocation(element);
2221 recordRelationship(_libraryElement, relationship, location); 2221 recordRelationship(_libraryElement, relationship, location);
2222 recordRelationship(IndexConstants.UNIVERSE, relationship, location); 2222 recordRelationship(IndexConstants.UNIVERSE, relationship, location);
2223 } 2223 }
2224 2224
2225 /** 2225 /**
2226 * Records [ImportElement] reference if given [SimpleIdentifier] references so me 2226 * Records [ImportElement] reference if given [SimpleIdentifier] references so me
2227 * top-level element and not qualified with import prefix. 2227 * top-level element and not qualified with import prefix.
2228 */ 2228 */
2229 void recordImportElementReferenceWithoutPrefix(SimpleIdentifier node) { 2229 void _recordImportElementReferenceWithoutPrefix(SimpleIdentifier node) {
2230 if (isIdentifierInImportCombinator(node)) { 2230 if (_isIdentifierInImportCombinator(node)) {
2231 return; 2231 return;
2232 } 2232 }
2233 if (isIdentifierInPrefixedIdentifier(node)) { 2233 if (_isIdentifierInPrefixedIdentifier(node)) {
2234 return; 2234 return;
2235 } 2235 }
2236 Element element = node.staticElement; 2236 Element element = node.staticElement;
2237 ImportElement importElement = internalGetImportElement(_libraryElement, null , element, _importElementsMap); 2237 ImportElement importElement = _internalGetImportElement(_libraryElement, nul l, element, _importElementsMap);
2238 if (importElement != null) { 2238 if (importElement != null) {
2239 Location location = createLocationFromOffset(node.offset, 0); 2239 Location location = _createLocationFromOffset(node.offset, 0);
2240 recordRelationship(importElement, IndexConstants.IS_REFERENCED_BY, locatio n); 2240 recordRelationship(importElement, IndexConstants.IS_REFERENCED_BY, locatio n);
2241 } 2241 }
2242 } 2242 }
2243 2243
2244 /** 2244 /**
2245 * Records [ImportElement] that declares given prefix and imports library with element used 2245 * Records [ImportElement] that declares given prefix and imports library with element used
2246 * with given prefix node. 2246 * with given prefix node.
2247 */ 2247 */
2248 void recordImportElementReferenceWithPrefix(SimpleIdentifier prefixNode) { 2248 void _recordImportElementReferenceWithPrefix(SimpleIdentifier prefixNode) {
2249 IndexContributor_ImportElementInfo info = getImportElementInfo(prefixNode); 2249 IndexContributor_ImportElementInfo info = getImportElementInfo(prefixNode);
2250 if (info != null) { 2250 if (info != null) {
2251 int offset = prefixNode.offset; 2251 int offset = prefixNode.offset;
2252 int length = info._periodEnd - offset; 2252 int length = info._periodEnd - offset;
2253 Location location = createLocationFromOffset(offset, length); 2253 Location location = _createLocationFromOffset(offset, length);
2254 recordRelationship(info._element, IndexConstants.IS_REFERENCED_BY, locatio n); 2254 recordRelationship(info._element, IndexConstants.IS_REFERENCED_BY, locatio n);
2255 } 2255 }
2256 } 2256 }
2257 2257
2258 /** 2258 /**
2259 * Records reference to defining [CompilationUnitElement] of the given 2259 * Records reference to defining [CompilationUnitElement] of the given
2260 * [LibraryElement]. 2260 * [LibraryElement].
2261 */ 2261 */
2262 void recordLibraryReference(UriBasedDirective node, LibraryElement library) { 2262 void _recordLibraryReference(UriBasedDirective node, LibraryElement library) {
2263 if (library != null) { 2263 if (library != null) {
2264 Location location = createLocationFromNode(node.uri); 2264 Location location = _createLocationFromNode(node.uri);
2265 recordRelationship(library.definingCompilationUnit, IndexConstants.IS_REFE RENCED_BY, location); 2265 recordRelationship(library.definingCompilationUnit, IndexConstants.IS_REFE RENCED_BY, location);
2266 } 2266 }
2267 } 2267 }
2268 2268
2269 /** 2269 /**
2270 * Record reference to the given operator [Element] and name. 2270 * Record reference to the given operator [Element] and name.
2271 */ 2271 */
2272 void recordOperatorReference(Token operator, Element element) { 2272 void _recordOperatorReference(Token operator, Element element) {
2273 // prepare location 2273 // prepare location
2274 Location location = createLocationFromToken(operator); 2274 Location location = _createLocationFromToken(operator);
2275 // record name reference 2275 // record name reference
2276 { 2276 {
2277 String name = operator.lexeme; 2277 String name = operator.lexeme;
2278 if (name == "++") { 2278 if (name == "++") {
2279 name = "+"; 2279 name = "+";
2280 } 2280 }
2281 if (name == "--") { 2281 if (name == "--") {
2282 name = "-"; 2282 name = "-";
2283 } 2283 }
2284 if (StringUtilities.endsWithChar(name, 0x3D) && name != "==") { 2284 if (StringUtilities.endsWithChar(name, 0x3D) && name != "==") {
2285 name = name.substring(0, name.length - 1); 2285 name = name.substring(0, name.length - 1);
2286 } 2286 }
2287 Element nameElement = new NameElementImpl(name); 2287 Element nameElement = new NameElementImpl(name);
2288 Relationship relationship = element != null ? IndexConstants.IS_REFERENCED _BY_QUALIFIED_RESOLVED : IndexConstants.IS_REFERENCED_BY_QUALIFIED_UNRESOLVED; 2288 Relationship relationship = element != null ? IndexConstants.IS_REFERENCED _BY_QUALIFIED_RESOLVED : IndexConstants.IS_REFERENCED_BY_QUALIFIED_UNRESOLVED;
2289 recordRelationship(nameElement, relationship, location); 2289 recordRelationship(nameElement, relationship, location);
2290 } 2290 }
2291 // record element reference 2291 // record element reference
2292 if (element != null) { 2292 if (element != null) {
2293 recordRelationship(element, IndexConstants.IS_INVOKED_BY_QUALIFIED, locati on); 2293 recordRelationship(element, IndexConstants.IS_INVOKED_BY_QUALIFIED, locati on);
2294 } 2294 }
2295 } 2295 }
2296 2296
2297 /** 2297 /**
2298 * Records reference if the given [SimpleIdentifier] looks like a qualified pr operty access 2298 * Records reference if the given [SimpleIdentifier] looks like a qualified pr operty access
2299 * or method invocation. 2299 * or method invocation.
2300 */ 2300 */
2301 void recordQualifiedMemberReference(SimpleIdentifier node, Element element, El ement nameElement, Location location) { 2301 void _recordQualifiedMemberReference(SimpleIdentifier node, Element element, E lement nameElement, Location location) {
2302 if (isQualified(node)) { 2302 if (_isQualified(node)) {
2303 Relationship relationship = element != null ? IndexConstants.IS_REFERENCED _BY_QUALIFIED_RESOLVED : IndexConstants.IS_REFERENCED_BY_QUALIFIED_UNRESOLVED; 2303 Relationship relationship = element != null ? IndexConstants.IS_REFERENCED _BY_QUALIFIED_RESOLVED : IndexConstants.IS_REFERENCED_BY_QUALIFIED_UNRESOLVED;
2304 recordRelationship(nameElement, relationship, location); 2304 recordRelationship(nameElement, relationship, location);
2305 } 2305 }
2306 } 2306 }
2307 2307
2308 /** 2308 /**
2309 * Records extends/implements relationships between given [ClassElement] and [ Type] of 2309 * Records extends/implements relationships between given [ClassElement] and [ Type] of
2310 * "superNode". 2310 * "superNode".
2311 */ 2311 */
2312 void recordSuperType(TypeName superNode, Relationship relationship) { 2312 void _recordSuperType(TypeName superNode, Relationship relationship) {
2313 if (superNode != null) { 2313 if (superNode != null) {
2314 Identifier superName = superNode.name; 2314 Identifier superName = superNode.name;
2315 if (superName != null) { 2315 if (superName != null) {
2316 Element superElement = superName.staticElement; 2316 Element superElement = superName.staticElement;
2317 recordRelationship(superElement, relationship, createLocationFromNode(su perNode)); 2317 recordRelationship(superElement, relationship, _createLocationFromNode(s uperNode));
2318 } 2318 }
2319 } 2319 }
2320 } 2320 }
2321 } 2321 }
2322 2322
2323 /** 2323 /**
2324 * Information about [ImportElement] and place where it is referenced using 2324 * Information about [ImportElement] and place where it is referenced using
2325 * [PrefixElement]. 2325 * [PrefixElement].
2326 */ 2326 */
2327 class IndexContributor_ImportElementInfo { 2327 class IndexContributor_ImportElementInfo {
(...skipping 62 matching lines...) Expand 10 before | Expand all | Expand 10 after
2390 * before giving up and returning `null` 2390 * before giving up and returning `null`
2391 * @return the operation that was removed from the queue 2391 * @return the operation that was removed from the queue
2392 * @throws InterruptedException if the thread on which this method is running was interrupted 2392 * @throws InterruptedException if the thread on which this method is running was interrupted
2393 * while it was waiting for an operation to be added to the queue 2393 * while it was waiting for an operation to be added to the queue
2394 */ 2394 */
2395 IndexOperation dequeue(int timeout) { 2395 IndexOperation dequeue(int timeout) {
2396 if (_nonQueryOperations.isEmpty && (!_processQueries || _queryOperations.isE mpty)) { 2396 if (_nonQueryOperations.isEmpty && (!_processQueries || _queryOperations.isE mpty)) {
2397 if (timeout <= 0) { 2397 if (timeout <= 0) {
2398 return null; 2398 return null;
2399 } 2399 }
2400 waitForOperationAvailable(timeout); 2400 _waitForOperationAvailable(timeout);
2401 } 2401 }
2402 if (!_nonQueryOperations.isEmpty) { 2402 if (!_nonQueryOperations.isEmpty) {
2403 return _nonQueryOperations.removeFirst(); 2403 return _nonQueryOperations.removeFirst();
2404 } 2404 }
2405 if (_processQueries && !_queryOperations.isEmpty) { 2405 if (_processQueries && !_queryOperations.isEmpty) {
2406 return _queryOperations.removeFirst(); 2406 return _queryOperations.removeFirst();
2407 } 2407 }
2408 return null; 2408 return null;
2409 } 2409 }
2410 2410
2411 /** 2411 /**
2412 * Add the given operation to the tail of this queue. 2412 * Add the given operation to the tail of this queue.
2413 * 2413 *
2414 * @param operation the operation to be added to the queue 2414 * @param operation the operation to be added to the queue
2415 */ 2415 */
2416 void enqueue(IndexOperation operation) { 2416 void enqueue(IndexOperation operation) {
2417 if (operation is RemoveSourceOperation) { 2417 if (operation is RemoveSourceOperation) {
2418 Source source = operation.source; 2418 Source source = operation.source;
2419 removeForSource(source, _nonQueryOperations); 2419 _removeForSource(source, _nonQueryOperations);
2420 removeForSource(source, _queryOperations); 2420 _removeForSource(source, _queryOperations);
2421 } 2421 }
2422 if (operation.isQuery) { 2422 if (operation.isQuery) {
2423 _queryOperations.add(operation); 2423 _queryOperations.add(operation);
2424 } else { 2424 } else {
2425 _nonQueryOperations.add(operation); 2425 _nonQueryOperations.add(operation);
2426 } 2426 }
2427 notifyOperationAvailable(); 2427 _notifyOperationAvailable();
2428 } 2428 }
2429 2429
2430 /** 2430 /**
2431 * Return a list containing all of the operations that are currently on the qu eue. Modifying this 2431 * Return a list containing all of the operations that are currently on the qu eue. Modifying this
2432 * list will not affect the state of the queue. 2432 * list will not affect the state of the queue.
2433 * 2433 *
2434 * @return all of the operations that are currently on the queue 2434 * @return all of the operations that are currently on the queue
2435 */ 2435 */
2436 List<IndexOperation> get operations { 2436 List<IndexOperation> get operations {
2437 List<IndexOperation> operations = []; 2437 List<IndexOperation> operations = [];
2438 operations.addAll(_nonQueryOperations); 2438 operations.addAll(_nonQueryOperations);
2439 operations.addAll(_queryOperations); 2439 operations.addAll(_queryOperations);
2440 return operations; 2440 return operations;
2441 } 2441 }
2442 2442
2443 /** 2443 /**
2444 * Set whether the receiver's [dequeue] method should return query operations. 2444 * Set whether the receiver's [dequeue] method should return query operations.
2445 * 2445 *
2446 * @param processQueries `true` if the receiver's [dequeue] method should 2446 * @param processQueries `true` if the receiver's [dequeue] method should
2447 * return query operations or `false` if query operations should be q ueued but not 2447 * return query operations or `false` if query operations should be q ueued but not
2448 * returned by the receiver's [dequeue] method until this method is c alled 2448 * returned by the receiver's [dequeue] method until this method is c alled
2449 * with a value of `true`. 2449 * with a value of `true`.
2450 */ 2450 */
2451 void set processQueries(bool processQueries) { 2451 void set processQueries(bool processQueries) {
2452 if (this._processQueries != processQueries) { 2452 if (this._processQueries != processQueries) {
2453 this._processQueries = processQueries; 2453 this._processQueries = processQueries;
2454 if (processQueries && !_queryOperations.isEmpty) { 2454 if (processQueries && !_queryOperations.isEmpty) {
2455 notifyOperationAvailable(); 2455 _notifyOperationAvailable();
2456 } 2456 }
2457 } 2457 }
2458 } 2458 }
2459 2459
2460 /** 2460 /**
2461 * Return the number of operations on the queue. 2461 * Return the number of operations on the queue.
2462 * 2462 *
2463 * @return the number of operations on the queue 2463 * @return the number of operations on the queue
2464 */ 2464 */
2465 int size() => _nonQueryOperations.length + _queryOperations.length; 2465 int size() => _nonQueryOperations.length + _queryOperations.length;
2466 2466
2467 void notifyOperationAvailable() { 2467 void _notifyOperationAvailable() {
2468 } 2468 }
2469 2469
2470 /** 2470 /**
2471 * Removes operations that should be removed when given [Source] is removed. 2471 * Removes operations that should be removed when given [Source] is removed.
2472 */ 2472 */
2473 void removeForSource(Source source, Queue<IndexOperation> operations) { 2473 void _removeForSource(Source source, Queue<IndexOperation> operations) {
2474 operations.removeWhere((_) => _.removeWhenSourceRemoved(source)); 2474 operations.removeWhere((_) => _.removeWhenSourceRemoved(source));
2475 } 2475 }
2476 2476
2477 void waitForOperationAvailable(int timeout) { 2477 void _waitForOperationAvailable(int timeout) {
2478 } 2478 }
2479 } 2479 }
2480 2480
2481 /** 2481 /**
2482 * Special [Element] which is used to index references to the name without speci fying concrete 2482 * Special [Element] which is used to index references to the name without speci fying concrete
2483 * kind of this name - field, method or something else. 2483 * kind of this name - field, method or something else.
2484 */ 2484 */
2485 class NameElementImpl extends ElementImpl { 2485 class NameElementImpl extends ElementImpl {
2486 NameElementImpl(String name) : super.con2("name:${name}", -1); 2486 NameElementImpl(String name) : super.con2("name:${name}", -1);
2487 2487
(...skipping 12 matching lines...) Expand all
2500 AngularDartIndexContributor(IndexStore store) { 2500 AngularDartIndexContributor(IndexStore store) {
2501 this._store = store; 2501 this._store = store;
2502 } 2502 }
2503 2503
2504 Object visitClassDeclaration(ClassDeclaration node) { 2504 Object visitClassDeclaration(ClassDeclaration node) {
2505 ClassElement classElement = node.element; 2505 ClassElement classElement = node.element;
2506 if (classElement != null) { 2506 if (classElement != null) {
2507 List<ToolkitObjectElement> toolkitObjects = classElement.toolkitObjects; 2507 List<ToolkitObjectElement> toolkitObjects = classElement.toolkitObjects;
2508 for (ToolkitObjectElement object in toolkitObjects) { 2508 for (ToolkitObjectElement object in toolkitObjects) {
2509 if (object is AngularComponentElement) { 2509 if (object is AngularComponentElement) {
2510 indexComponent(object); 2510 _indexComponent(object);
2511 } 2511 }
2512 if (object is AngularDirectiveElement) { 2512 if (object is AngularDirectiveElement) {
2513 AngularDirectiveElement directive = object; 2513 AngularDirectiveElement directive = object;
2514 indexDirective(directive); 2514 _indexDirective(directive);
2515 } 2515 }
2516 } 2516 }
2517 } 2517 }
2518 // stop visiting 2518 // stop visiting
2519 return null; 2519 return null;
2520 } 2520 }
2521 2521
2522 Object visitCompilationUnitMember(CompilationUnitMember node) => null; 2522 Object visitCompilationUnitMember(CompilationUnitMember node) => null;
2523 2523
2524 void indexComponent(AngularComponentElement component) { 2524 void _indexComponent(AngularComponentElement component) {
2525 indexProperties(component.properties); 2525 _indexProperties(component.properties);
2526 } 2526 }
2527 2527
2528 void indexDirective(AngularDirectiveElement directive) { 2528 void _indexDirective(AngularDirectiveElement directive) {
2529 indexProperties(directive.properties); 2529 _indexProperties(directive.properties);
2530 } 2530 }
2531 2531
2532 /** 2532 /**
2533 * Index [FieldElement] references from [AngularPropertyElement]s. 2533 * Index [FieldElement] references from [AngularPropertyElement]s.
2534 */ 2534 */
2535 void indexProperties(List<AngularPropertyElement> properties) { 2535 void _indexProperties(List<AngularPropertyElement> properties) {
2536 for (AngularPropertyElement property in properties) { 2536 for (AngularPropertyElement property in properties) {
2537 FieldElement field = property.field; 2537 FieldElement field = property.field;
2538 if (field != null) { 2538 if (field != null) {
2539 int offset = property.fieldNameOffset; 2539 int offset = property.fieldNameOffset;
2540 if (offset == -1) { 2540 if (offset == -1) {
2541 continue; 2541 continue;
2542 } 2542 }
2543 int length = field.name.length; 2543 int length = field.name.length;
2544 Location location = new Location(property, offset, length); 2544 Location location = new Location(property, offset, length);
2545 // getter reference 2545 // getter reference
(...skipping 234 matching lines...) Expand 10 before | Expand all | Expand 10 after
2780 * element are available. For example, if the element is a field and the relat ionship is the 2780 * element are available. For example, if the element is a field and the relat ionship is the
2781 * is-referenced-by relationship, then this method will be invoked with each l ocation at which the 2781 * is-referenced-by relationship, then this method will be invoked with each l ocation at which the
2782 * field is referenced. 2782 * field is referenced.
2783 * 2783 *
2784 * @param element the [Element] that has the relationship with the locations 2784 * @param element the [Element] that has the relationship with the locations
2785 * @param relationship the relationship between the given element and the loca tions 2785 * @param relationship the relationship between the given element and the loca tions
2786 * @param locations the locations that were found 2786 * @param locations the locations that were found
2787 */ 2787 */
2788 void hasRelationships(Element element, Relationship relationship, List<Locatio n> locations); 2788 void hasRelationships(Element element, Relationship relationship, List<Locatio n> locations);
2789 } 2789 }
OLDNEW
« no previous file with comments | « pkg/analyzer/lib/src/generated/html.dart ('k') | pkg/analyzer/lib/src/generated/parser.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698