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

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

Issue 137863002: Issue 8742. Preserve leading line comments during java2dart translation. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Test for block-style comment translation. Created 6 years, 11 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 153 matching lines...) Expand 10 before | Expand all | Expand 10 after
164 Map<AnalysisContext, Map<Source, Set<Source>>> _contextToUnitToLibraries = {}; 164 Map<AnalysisContext, Map<Source, Set<Source>>> _contextToUnitToLibraries = {};
165 165
166 int _sourceCount = 0; 166 int _sourceCount = 0;
167 167
168 int _keyCount = 0; 168 int _keyCount = 0;
169 169
170 int _locationCount = 0; 170 int _locationCount = 0;
171 171
172 bool aboutToIndex(AnalysisContext context, CompilationUnitElement unitElement) { 172 bool aboutToIndex(AnalysisContext context, CompilationUnitElement unitElement) {
173 context = unwrapContext(context); 173 context = unwrapContext(context);
174 // may be already removed in other thread
174 if (isRemovedContext(context)) { 175 if (isRemovedContext(context)) {
175 return false; 176 return false;
176 } 177 }
178 // validate unit
177 if (unitElement == null) { 179 if (unitElement == null) {
178 return false; 180 return false;
179 } 181 }
180 LibraryElement libraryElement = unitElement.library; 182 LibraryElement libraryElement = unitElement.library;
181 if (libraryElement == null) { 183 if (libraryElement == null) {
182 return false; 184 return false;
183 } 185 }
184 CompilationUnitElement definingUnitElement = libraryElement.definingCompilat ionUnit; 186 CompilationUnitElement definingUnitElement = libraryElement.definingCompilat ionUnit;
185 if (definingUnitElement == null) { 187 if (definingUnitElement == null) {
186 return false; 188 return false;
187 } 189 }
190 // prepare sources
188 Source library = definingUnitElement.source; 191 Source library = definingUnitElement.source;
189 Source unit = unitElement.source; 192 Source unit = unitElement.source;
193 // special handling for the defining library unit
190 if (unit == library) { 194 if (unit == library) {
195 // prepare new parts
191 Set<Source> newParts = new Set(); 196 Set<Source> newParts = new Set();
192 for (CompilationUnitElement part in libraryElement.parts) { 197 for (CompilationUnitElement part in libraryElement.parts) {
193 newParts.add(part.source); 198 newParts.add(part.source);
194 } 199 }
200 // prepare old parts
195 Map<Source, Set<Source>> libraryToUnits = _contextToLibraryToUnits[context ]; 201 Map<Source, Set<Source>> libraryToUnits = _contextToLibraryToUnits[context ];
196 if (libraryToUnits == null) { 202 if (libraryToUnits == null) {
197 libraryToUnits = {}; 203 libraryToUnits = {};
198 _contextToLibraryToUnits[context] = libraryToUnits; 204 _contextToLibraryToUnits[context] = libraryToUnits;
199 } 205 }
200 Set<Source> oldParts = libraryToUnits[library]; 206 Set<Source> oldParts = libraryToUnits[library];
207 // check if some parts are not in the library now
201 if (oldParts != null) { 208 if (oldParts != null) {
202 Set<Source> noParts = oldParts.difference(newParts); 209 Set<Source> noParts = oldParts.difference(newParts);
203 for (Source noPart in noParts) { 210 for (Source noPart in noParts) {
204 removeLocations(context, library, noPart); 211 removeLocations(context, library, noPart);
205 } 212 }
206 } 213 }
214 // remember new parts
207 libraryToUnits[library] = newParts; 215 libraryToUnits[library] = newParts;
208 } 216 }
217 // remember libraries in which unit is used
209 Map<Source, Set<Source>> unitToLibraries = _contextToUnitToLibraries[context ]; 218 Map<Source, Set<Source>> unitToLibraries = _contextToUnitToLibraries[context ];
210 if (unitToLibraries == null) { 219 if (unitToLibraries == null) {
211 unitToLibraries = {}; 220 unitToLibraries = {};
212 _contextToUnitToLibraries[context] = unitToLibraries; 221 _contextToUnitToLibraries[context] = unitToLibraries;
213 } 222 }
214 Set<Source> libraries = unitToLibraries[unit]; 223 Set<Source> libraries = unitToLibraries[unit];
215 if (libraries == null) { 224 if (libraries == null) {
216 libraries = new Set(); 225 libraries = new Set();
217 unitToLibraries[unit] = libraries; 226 unitToLibraries[unit] = libraries;
218 } 227 }
219 libraries.add(library); 228 libraries.add(library);
229 // remove locations
220 removeLocations(context, library, unit); 230 removeLocations(context, library, unit);
231 // remove keys
221 { 232 {
222 Map<MemoryIndexStoreImpl_Source2, Set<MemoryIndexStoreImpl_ElementRelation Key>> sourceToKeys = _contextToSourceToKeys[context]; 233 Map<MemoryIndexStoreImpl_Source2, Set<MemoryIndexStoreImpl_ElementRelation Key>> sourceToKeys = _contextToSourceToKeys[context];
223 if (sourceToKeys != null) { 234 if (sourceToKeys != null) {
224 MemoryIndexStoreImpl_Source2 source2 = new MemoryIndexStoreImpl_Source2( library, unit); 235 MemoryIndexStoreImpl_Source2 source2 = new MemoryIndexStoreImpl_Source2( library, unit);
225 sourceToKeys.remove(source2); 236 sourceToKeys.remove(source2);
226 } 237 }
227 } 238 }
239 // OK, we can index
228 return true; 240 return true;
229 } 241 }
230 242
231 bool aboutToIndex2(AnalysisContext context, Source source) { 243 bool aboutToIndex2(AnalysisContext context, Source source) {
232 context = unwrapContext(context); 244 context = unwrapContext(context);
245 // may be already removed in other thread
233 if (isRemovedContext(context)) { 246 if (isRemovedContext(context)) {
234 return false; 247 return false;
235 } 248 }
249 // remove locations
236 removeLocations(context, source, source); 250 removeLocations(context, source, source);
251 // remove keys
237 { 252 {
238 Map<MemoryIndexStoreImpl_Source2, Set<MemoryIndexStoreImpl_ElementRelation Key>> sourceToKeys = _contextToSourceToKeys[context]; 253 Map<MemoryIndexStoreImpl_Source2, Set<MemoryIndexStoreImpl_ElementRelation Key>> sourceToKeys = _contextToSourceToKeys[context];
239 if (sourceToKeys != null) { 254 if (sourceToKeys != null) {
240 MemoryIndexStoreImpl_Source2 source2 = new MemoryIndexStoreImpl_Source2( source, source); 255 MemoryIndexStoreImpl_Source2 source2 = new MemoryIndexStoreImpl_Source2( source, source);
241 sourceToKeys.remove(source2); 256 sourceToKeys.remove(source2);
242 } 257 }
243 } 258 }
259 // OK, we can index
244 return true; 260 return true;
245 } 261 }
246 262
247 List<Location> getRelationships(Element element, Relationship relationship) { 263 List<Location> getRelationships(Element element, Relationship relationship) {
248 MemoryIndexStoreImpl_ElementRelationKey key = new MemoryIndexStoreImpl_Eleme ntRelationKey(element, relationship); 264 MemoryIndexStoreImpl_ElementRelationKey key = new MemoryIndexStoreImpl_Eleme ntRelationKey(element, relationship);
249 Set<Location> locations = _keyToLocations[key]; 265 Set<Location> locations = _keyToLocations[key];
250 if (locations != null) { 266 if (locations != null) {
251 return new List.from(locations); 267 return new List.from(locations);
252 } 268 }
253 return Location.EMPTY_ARRAY; 269 return Location.EMPTY_ARRAY;
(...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after
287 } 303 }
288 } 304 }
289 return count; 305 return count;
290 } 306 }
291 307
292 void recordRelationship(Element element, Relationship relationship, Location l ocation) { 308 void recordRelationship(Element element, Relationship relationship, Location l ocation) {
293 if (element == null || location == null) { 309 if (element == null || location == null) {
294 return; 310 return;
295 } 311 }
296 location = location.clone(); 312 location = location.clone();
313 // at the index level we don't care about Member(s)
297 if (element is Member) { 314 if (element is Member) {
298 element = (element as Member).baseElement; 315 element = (element as Member).baseElement;
299 } 316 }
317 // prepare information
300 AnalysisContext elementContext = element.context; 318 AnalysisContext elementContext = element.context;
301 AnalysisContext locationContext = location.element.context; 319 AnalysisContext locationContext = location.element.context;
302 Source elementSource = element.source; 320 Source elementSource = element.source;
303 Source locationSource = location.element.source; 321 Source locationSource = location.element.source;
304 Source elementLibrarySource = getLibrarySourceOrNull(element); 322 Source elementLibrarySource = getLibrarySourceOrNull(element);
305 Source locationLibrarySource = getLibrarySourceOrNull(location.element); 323 Source locationLibrarySource = getLibrarySourceOrNull(location.element);
324 // sanity check
306 if (locationContext == null) { 325 if (locationContext == null) {
307 return; 326 return;
308 } 327 }
309 if (locationSource == null) { 328 if (locationSource == null) {
310 return; 329 return;
311 } 330 }
312 if (elementContext == null && element is! NameElementImpl && element is! Uni verseElementImpl) { 331 if (elementContext == null && element is! NameElementImpl && element is! Uni verseElementImpl) {
313 return; 332 return;
314 } 333 }
315 if (elementSource == null && element is! NameElementImpl && element is! Univ erseElementImpl) { 334 if (elementSource == null && element is! NameElementImpl && element is! Univ erseElementImpl) {
316 return; 335 return;
317 } 336 }
337 // may be already removed in other thread
318 if (isRemovedContext(elementContext)) { 338 if (isRemovedContext(elementContext)) {
319 return; 339 return;
320 } 340 }
321 if (isRemovedContext(locationContext)) { 341 if (isRemovedContext(locationContext)) {
322 return; 342 return;
323 } 343 }
344 // record: key -> location(s)
324 MemoryIndexStoreImpl_ElementRelationKey key = getCanonicalKey(element, relat ionship); 345 MemoryIndexStoreImpl_ElementRelationKey key = getCanonicalKey(element, relat ionship);
325 { 346 {
326 Set<Location> locations = _keyToLocations.remove(key); 347 Set<Location> locations = _keyToLocations.remove(key);
327 if (locations == null) { 348 if (locations == null) {
328 locations = createLocationIdentitySet(); 349 locations = createLocationIdentitySet();
329 } else { 350 } else {
330 _keyCount--; 351 _keyCount--;
331 } 352 }
332 _keyToLocations[key] = locations; 353 _keyToLocations[key] = locations;
333 _keyCount++; 354 _keyCount++;
334 locations.add(location); 355 locations.add(location);
335 _locationCount++; 356 _locationCount++;
336 } 357 }
358 // record: location -> key
337 location.internalKey = key; 359 location.internalKey = key;
360 // prepare source pairs
338 MemoryIndexStoreImpl_Source2 elementSource2 = new MemoryIndexStoreImpl_Sourc e2(elementLibrarySource, elementSource); 361 MemoryIndexStoreImpl_Source2 elementSource2 = new MemoryIndexStoreImpl_Sourc e2(elementLibrarySource, elementSource);
339 MemoryIndexStoreImpl_Source2 locationSource2 = new MemoryIndexStoreImpl_Sour ce2(locationLibrarySource, locationSource); 362 MemoryIndexStoreImpl_Source2 locationSource2 = new MemoryIndexStoreImpl_Sour ce2(locationLibrarySource, locationSource);
363 // record: element source -> keys
340 { 364 {
341 Map<MemoryIndexStoreImpl_Source2, Set<MemoryIndexStoreImpl_ElementRelation Key>> sourceToKeys = _contextToSourceToKeys[elementContext]; 365 Map<MemoryIndexStoreImpl_Source2, Set<MemoryIndexStoreImpl_ElementRelation Key>> sourceToKeys = _contextToSourceToKeys[elementContext];
342 if (sourceToKeys == null) { 366 if (sourceToKeys == null) {
343 sourceToKeys = {}; 367 sourceToKeys = {};
344 _contextToSourceToKeys[elementContext] = sourceToKeys; 368 _contextToSourceToKeys[elementContext] = sourceToKeys;
345 } 369 }
346 Set<MemoryIndexStoreImpl_ElementRelationKey> keys = sourceToKeys[elementSo urce2]; 370 Set<MemoryIndexStoreImpl_ElementRelationKey> keys = sourceToKeys[elementSo urce2];
347 if (keys == null) { 371 if (keys == null) {
348 keys = new Set(); 372 keys = new Set();
349 sourceToKeys[elementSource2] = keys; 373 sourceToKeys[elementSource2] = keys;
350 _sourceCount++; 374 _sourceCount++;
351 } 375 }
352 keys.remove(key); 376 keys.remove(key);
353 keys.add(key); 377 keys.add(key);
354 } 378 }
379 // record: location source -> locations
355 { 380 {
356 Map<MemoryIndexStoreImpl_Source2, List<Location>> sourceToLocations = _con textToSourceToLocations[locationContext]; 381 Map<MemoryIndexStoreImpl_Source2, List<Location>> sourceToLocations = _con textToSourceToLocations[locationContext];
357 if (sourceToLocations == null) { 382 if (sourceToLocations == null) {
358 sourceToLocations = {}; 383 sourceToLocations = {};
359 _contextToSourceToLocations[locationContext] = sourceToLocations; 384 _contextToSourceToLocations[locationContext] = sourceToLocations;
360 } 385 }
361 List<Location> locations = sourceToLocations[locationSource2]; 386 List<Location> locations = sourceToLocations[locationSource2];
362 if (locations == null) { 387 if (locations == null) {
363 locations = []; 388 locations = [];
364 sourceToLocations[locationSource2] = locations; 389 sourceToLocations[locationSource2] = locations;
365 } 390 }
366 locations.add(location); 391 locations.add(location);
367 } 392 }
368 } 393 }
369 394
370 void removeContext(AnalysisContext context) { 395 void removeContext(AnalysisContext context) {
371 context = unwrapContext(context); 396 context = unwrapContext(context);
372 if (context == null) { 397 if (context == null) {
373 return; 398 return;
374 } 399 }
400 // mark as removed
375 markRemovedContext(context); 401 markRemovedContext(context);
376 removeSources(context, null); 402 removeSources(context, null);
403 // remove context
377 _contextToSourceToKeys.remove(context); 404 _contextToSourceToKeys.remove(context);
378 _contextToSourceToLocations.remove(context); 405 _contextToSourceToLocations.remove(context);
379 _contextToLibraryToUnits.remove(context); 406 _contextToLibraryToUnits.remove(context);
380 _contextToUnitToLibraries.remove(context); 407 _contextToUnitToLibraries.remove(context);
381 } 408 }
382 409
383 void removeSource(AnalysisContext context, Source unit) { 410 void removeSource(AnalysisContext context, Source unit) {
384 context = unwrapContext(context); 411 context = unwrapContext(context);
385 if (context == null) { 412 if (context == null) {
386 return; 413 return;
387 } 414 }
415 // remove locations defined in source
388 Map<Source, Set<Source>> unitToLibraries = _contextToUnitToLibraries[context ]; 416 Map<Source, Set<Source>> unitToLibraries = _contextToUnitToLibraries[context ];
389 if (unitToLibraries != null) { 417 if (unitToLibraries != null) {
390 Set<Source> libraries = unitToLibraries.remove(unit); 418 Set<Source> libraries = unitToLibraries.remove(unit);
391 if (libraries != null) { 419 if (libraries != null) {
392 for (Source library in libraries) { 420 for (Source library in libraries) {
393 MemoryIndexStoreImpl_Source2 source2 = new MemoryIndexStoreImpl_Source 2(library, unit); 421 MemoryIndexStoreImpl_Source2 source2 = new MemoryIndexStoreImpl_Source 2(library, unit);
422 // remove locations defined in source
394 removeLocations(context, library, unit); 423 removeLocations(context, library, unit);
424 // remove keys for elements defined in source
395 Map<MemoryIndexStoreImpl_Source2, Set<MemoryIndexStoreImpl_ElementRela tionKey>> sourceToKeys = _contextToSourceToKeys[context]; 425 Map<MemoryIndexStoreImpl_Source2, Set<MemoryIndexStoreImpl_ElementRela tionKey>> sourceToKeys = _contextToSourceToKeys[context];
396 if (sourceToKeys != null) { 426 if (sourceToKeys != null) {
397 Set<MemoryIndexStoreImpl_ElementRelationKey> keys = sourceToKeys.rem ove(source2); 427 Set<MemoryIndexStoreImpl_ElementRelationKey> keys = sourceToKeys.rem ove(source2);
398 if (keys != null) { 428 if (keys != null) {
399 for (MemoryIndexStoreImpl_ElementRelationKey key in keys) { 429 for (MemoryIndexStoreImpl_ElementRelationKey key in keys) {
400 _canonicalKeys.remove(key); 430 _canonicalKeys.remove(key);
401 Set<Location> locations = _keyToLocations.remove(key); 431 Set<Location> locations = _keyToLocations.remove(key);
402 if (locations != null) { 432 if (locations != null) {
403 _keyCount--; 433 _keyCount--;
404 _locationCount -= locations.length; 434 _locationCount -= locations.length;
405 } 435 }
406 } 436 }
407 _sourceCount--; 437 _sourceCount--;
408 } 438 }
409 } 439 }
410 } 440 }
411 } 441 }
412 } 442 }
413 } 443 }
414 444
415 void removeSources(AnalysisContext context, SourceContainer container) { 445 void removeSources(AnalysisContext context, SourceContainer container) {
416 context = unwrapContext(context); 446 context = unwrapContext(context);
417 if (context == null) { 447 if (context == null) {
418 return; 448 return;
419 } 449 }
450 // remove sources #1
420 Map<MemoryIndexStoreImpl_Source2, Set<MemoryIndexStoreImpl_ElementRelationKe y>> sourceToKeys = _contextToSourceToKeys[context]; 451 Map<MemoryIndexStoreImpl_Source2, Set<MemoryIndexStoreImpl_ElementRelationKe y>> sourceToKeys = _contextToSourceToKeys[context];
421 if (sourceToKeys != null) { 452 if (sourceToKeys != null) {
422 List<MemoryIndexStoreImpl_Source2> sources = []; 453 List<MemoryIndexStoreImpl_Source2> sources = [];
423 for (MemoryIndexStoreImpl_Source2 source2 in sources) { 454 for (MemoryIndexStoreImpl_Source2 source2 in sources) {
424 Source source = source2._unitSource; 455 Source source = source2._unitSource;
425 if (container == null || container.contains(source)) { 456 if (container == null || container.contains(source)) {
426 removeSource(context, source); 457 removeSource(context, source);
427 } 458 }
428 } 459 }
429 } 460 }
461 // remove sources #2
430 Map<MemoryIndexStoreImpl_Source2, List<Location>> sourceToLocations = _conte xtToSourceToLocations[context]; 462 Map<MemoryIndexStoreImpl_Source2, List<Location>> sourceToLocations = _conte xtToSourceToLocations[context];
431 if (sourceToLocations != null) { 463 if (sourceToLocations != null) {
432 List<MemoryIndexStoreImpl_Source2> sources = []; 464 List<MemoryIndexStoreImpl_Source2> sources = [];
433 for (MemoryIndexStoreImpl_Source2 source2 in sources) { 465 for (MemoryIndexStoreImpl_Source2 source2 in sources) {
434 Source source = source2._unitSource; 466 Source source = source2._unitSource;
435 if (container == null || container.contains(source)) { 467 if (container == null || container.contains(source)) {
436 removeSource(context, source); 468 removeSource(context, source);
437 } 469 }
438 } 470 }
439 } 471 }
(...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after
478 Map<MemoryIndexStoreImpl_Source2, List<Location>> sourceToLocations = _conte xtToSourceToLocations[context]; 510 Map<MemoryIndexStoreImpl_Source2, List<Location>> sourceToLocations = _conte xtToSourceToLocations[context];
479 if (sourceToLocations != null) { 511 if (sourceToLocations != null) {
480 List<Location> sourceLocations = sourceToLocations.remove(source2); 512 List<Location> sourceLocations = sourceToLocations.remove(source2);
481 if (sourceLocations != null) { 513 if (sourceLocations != null) {
482 for (Location location in sourceLocations) { 514 for (Location location in sourceLocations) {
483 MemoryIndexStoreImpl_ElementRelationKey key = location.internalKey as MemoryIndexStoreImpl_ElementRelationKey; 515 MemoryIndexStoreImpl_ElementRelationKey key = location.internalKey as MemoryIndexStoreImpl_ElementRelationKey;
484 Set<Location> relLocations = _keyToLocations[key]; 516 Set<Location> relLocations = _keyToLocations[key];
485 if (relLocations != null) { 517 if (relLocations != null) {
486 relLocations.remove(location); 518 relLocations.remove(location);
487 _locationCount--; 519 _locationCount--;
520 // no locations with this key
488 if (relLocations.isEmpty) { 521 if (relLocations.isEmpty) {
489 _canonicalKeys.remove(key); 522 _canonicalKeys.remove(key);
490 _keyToLocations.remove(key); 523 _keyToLocations.remove(key);
491 _keyCount--; 524 _keyCount--;
492 } 525 }
493 } 526 }
494 } 527 }
495 } 528 }
496 } 529 }
497 } 530 }
(...skipping 372 matching lines...) Expand 10 before | Expand all | Expand 10 after
870 } 903 }
871 904
872 /** 905 /**
873 * Start processing operations. If the processor is already running on a diffe rent thread, then 906 * Start processing operations. If the processor is already running on a diffe rent thread, then
874 * this method will return immediately with no effect. Otherwise, this method will not return 907 * this method will return immediately with no effect. Otherwise, this method will not return
875 * until after the processor has been stopped from a different thread or until the thread running 908 * until after the processor has been stopped from a different thread or until the thread running
876 * the processor has been interrupted. 909 * the processor has been interrupted.
877 */ 910 */
878 void run() { 911 void run() {
879 { 912 {
913 // This processor is, or was, already running on a different thread.
880 if (_state != ProcessorState.READY) { 914 if (_state != ProcessorState.READY) {
881 throw new IllegalStateException("Operation processors can only be run on e time"); 915 throw new IllegalStateException("Operation processors can only be run on e time");
882 } 916 }
917 // OK, run.
883 _state = ProcessorState.RUNNING; 918 _state = ProcessorState.RUNNING;
884 } 919 }
885 try { 920 try {
886 while (isRunning) { 921 while (isRunning) {
922 // wait for operation
887 IndexOperation operation = null; 923 IndexOperation operation = null;
888 { 924 {
889 operation = _queue.dequeue(_WAIT_DURATION); 925 operation = _queue.dequeue(_WAIT_DURATION);
890 } 926 }
927 // perform operation
891 if (operation != null) { 928 if (operation != null) {
892 try { 929 try {
893 operation.performOperation(); 930 operation.performOperation();
894 } catch (exception) { 931 } catch (exception) {
895 AnalysisEngine.instance.logger.logError2("Exception in indexing oper ation: ${operation}", exception); 932 AnalysisEngine.instance.logger.logError2("Exception in indexing oper ation: ${operation}", exception);
896 } 933 }
897 } 934 }
898 } 935 }
899 } finally { 936 } finally {
900 { 937 {
(...skipping 556 matching lines...) Expand 10 before | Expand all | Expand 10 after
1457 IndexContributor_ImportElementInfo info = getImportElementInfo(prefixNode); 1494 IndexContributor_ImportElementInfo info = getImportElementInfo(prefixNode);
1458 return info != null ? info._element : null; 1495 return info != null ? info._element : null;
1459 } 1496 }
1460 1497
1461 /** 1498 /**
1462 * @return the [ImportElementInfo] with [ImportElement] that is referenced by this 1499 * @return the [ImportElementInfo] with [ImportElement] that is referenced by this
1463 * node with [PrefixElement], may be `null`. 1500 * node with [PrefixElement], may be `null`.
1464 */ 1501 */
1465 static IndexContributor_ImportElementInfo getImportElementInfo(SimpleIdentifie r prefixNode) { 1502 static IndexContributor_ImportElementInfo getImportElementInfo(SimpleIdentifie r prefixNode) {
1466 IndexContributor_ImportElementInfo info = new IndexContributor_ImportElement Info(); 1503 IndexContributor_ImportElementInfo info = new IndexContributor_ImportElement Info();
1504 // prepare environment
1467 ASTNode parent = prefixNode.parent; 1505 ASTNode parent = prefixNode.parent;
1468 CompilationUnit unit = prefixNode.getAncestor(CompilationUnit); 1506 CompilationUnit unit = prefixNode.getAncestor(CompilationUnit);
1469 LibraryElement libraryElement = unit.element.library; 1507 LibraryElement libraryElement = unit.element.library;
1508 // prepare used element
1470 Element usedElement = null; 1509 Element usedElement = null;
1471 if (parent is PrefixedIdentifier) { 1510 if (parent is PrefixedIdentifier) {
1472 PrefixedIdentifier prefixed = parent; 1511 PrefixedIdentifier prefixed = parent;
1473 usedElement = prefixed.staticElement; 1512 usedElement = prefixed.staticElement;
1474 info._periodEnd = prefixed.period.end; 1513 info._periodEnd = prefixed.period.end;
1475 } 1514 }
1476 if (parent is MethodInvocation) { 1515 if (parent is MethodInvocation) {
1477 MethodInvocation invocation = parent; 1516 MethodInvocation invocation = parent;
1478 usedElement = invocation.methodName.staticElement; 1517 usedElement = invocation.methodName.staticElement;
1479 info._periodEnd = invocation.period.end; 1518 info._periodEnd = invocation.period.end;
1480 } 1519 }
1520 // we need used Element
1481 if (usedElement == null) { 1521 if (usedElement == null) {
1482 return null; 1522 return null;
1483 } 1523 }
1524 // find ImportElement
1484 String prefix = prefixNode.name; 1525 String prefix = prefixNode.name;
1485 Map<ImportElement, Set<Element>> importElementsMap = {}; 1526 Map<ImportElement, Set<Element>> importElementsMap = {};
1486 info._element = getImportElement2(libraryElement, prefix, usedElement, impor tElementsMap); 1527 info._element = getImportElement2(libraryElement, prefix, usedElement, impor tElementsMap);
1487 if (info._element == null) { 1528 if (info._element == null) {
1488 return null; 1529 return null;
1489 } 1530 }
1490 return info; 1531 return info;
1491 } 1532 }
1492 1533
1493 /** 1534 /**
1494 * @return the [ImportElement] that declares given [PrefixElement] and imports library 1535 * @return the [ImportElement] that declares given [PrefixElement] and imports library
1495 * with given "usedElement". 1536 * with given "usedElement".
1496 */ 1537 */
1497 static ImportElement getImportElement2(LibraryElement libraryElement, String p refix, Element usedElement, Map<ImportElement, Set<Element>> importElementsMap) { 1538 static ImportElement getImportElement2(LibraryElement libraryElement, String p refix, Element usedElement, Map<ImportElement, Set<Element>> importElementsMap) {
1539 // validate Element
1498 if (usedElement == null) { 1540 if (usedElement == null) {
1499 return null; 1541 return null;
1500 } 1542 }
1501 if (usedElement.enclosingElement is! CompilationUnitElement) { 1543 if (usedElement.enclosingElement is! CompilationUnitElement) {
1502 return null; 1544 return null;
1503 } 1545 }
1504 LibraryElement usedLibrary = usedElement.library; 1546 LibraryElement usedLibrary = usedElement.library;
1547 // find ImportElement that imports used library with used prefix
1505 List<ImportElement> candidates = null; 1548 List<ImportElement> candidates = null;
1506 for (ImportElement importElement in libraryElement.imports) { 1549 for (ImportElement importElement in libraryElement.imports) {
1550 // required library
1507 if (importElement.importedLibrary != usedLibrary) { 1551 if (importElement.importedLibrary != usedLibrary) {
1508 continue; 1552 continue;
1509 } 1553 }
1554 // required prefix
1510 PrefixElement prefixElement = importElement.prefix; 1555 PrefixElement prefixElement = importElement.prefix;
1511 if (prefix == null) { 1556 if (prefix == null) {
1512 if (prefixElement != null) { 1557 if (prefixElement != null) {
1513 continue; 1558 continue;
1514 } 1559 }
1515 } else { 1560 } else {
1516 if (prefixElement == null) { 1561 if (prefixElement == null) {
1517 continue; 1562 continue;
1518 } 1563 }
1519 if (prefix != prefixElement.name) { 1564 if (prefix != prefixElement.name) {
1520 continue; 1565 continue;
1521 } 1566 }
1522 } 1567 }
1568 // no combinators => only possible candidate
1523 if (importElement.combinators.length == 0) { 1569 if (importElement.combinators.length == 0) {
1524 return importElement; 1570 return importElement;
1525 } 1571 }
1572 // OK, we have candidate
1526 if (candidates == null) { 1573 if (candidates == null) {
1527 candidates = []; 1574 candidates = [];
1528 } 1575 }
1529 candidates.add(importElement); 1576 candidates.add(importElement);
1530 } 1577 }
1578 // no candidates, probably element is defined in this library
1531 if (candidates == null) { 1579 if (candidates == null) {
1532 return null; 1580 return null;
1533 } 1581 }
1582 // one candidate
1534 if (candidates.length == 1) { 1583 if (candidates.length == 1) {
1535 return candidates[0]; 1584 return candidates[0];
1536 } 1585 }
1586 // ensure that each ImportElement has set of elements
1537 for (ImportElement importElement in candidates) { 1587 for (ImportElement importElement in candidates) {
1538 if (importElementsMap.containsKey(importElement)) { 1588 if (importElementsMap.containsKey(importElement)) {
1539 continue; 1589 continue;
1540 } 1590 }
1541 Namespace namespace = new NamespaceBuilder().createImportNamespace(importE lement); 1591 Namespace namespace = new NamespaceBuilder().createImportNamespace(importE lement);
1542 Set<Element> elements = new Set(); 1592 Set<Element> elements = new Set();
1543 importElementsMap[importElement] = elements; 1593 importElementsMap[importElement] = elements;
1544 } 1594 }
1595 // use import namespace to choose correct one
1545 for (MapEntry<ImportElement, Set<Element>> entry in getMapEntrySet(importEle mentsMap)) { 1596 for (MapEntry<ImportElement, Set<Element>> entry in getMapEntrySet(importEle mentsMap)) {
1546 if (entry.getValue().contains(usedElement)) { 1597 if (entry.getValue().contains(usedElement)) {
1547 return entry.getKey(); 1598 return entry.getKey();
1548 } 1599 }
1549 } 1600 }
1601 // not found
1550 return null; 1602 return null;
1551 } 1603 }
1552 1604
1553 /** 1605 /**
1554 * If the given expression has resolved type, returns the new location with th is type. 1606 * If the given expression has resolved type, returns the new location with th is type.
1555 * 1607 *
1556 * @param location the base location 1608 * @param location the base location
1557 * @param expression the expression assigned at the given location 1609 * @param expression the expression assigned at the given location
1558 */ 1610 */
1559 static Location getLocationWithExpressionType(Location location, Expression ex pression) { 1611 static Location getLocationWithExpressionType(Location location, Expression ex pression) {
(...skipping 21 matching lines...) Expand all
1581 * If the given identifier has a synthetic [PropertyAccessorElement], i.e. acc essor for 1633 * If the given identifier has a synthetic [PropertyAccessorElement], i.e. acc essor for
1582 * normal field, and it is LHS of assignment, then include [Type] of the assig ned value into 1634 * normal field, and it is LHS of assignment, then include [Type] of the assig ned value into
1583 * the [Location]. 1635 * the [Location].
1584 * 1636 *
1585 * @param identifier the identifier to record location 1637 * @param identifier the identifier to record location
1586 * @param element the element of the identifier 1638 * @param element the element of the identifier
1587 * @param location the raw location 1639 * @param location the raw location
1588 * @return the [Location] with the type of the assigned value 1640 * @return the [Location] with the type of the assigned value
1589 */ 1641 */
1590 static Location getLocationWithTypeAssignedToField(SimpleIdentifier identifier , Element element, Location location) { 1642 static Location getLocationWithTypeAssignedToField(SimpleIdentifier identifier , Element element, Location location) {
1643 // we need accessor
1591 if (element is! PropertyAccessorElement) { 1644 if (element is! PropertyAccessorElement) {
1592 return location; 1645 return location;
1593 } 1646 }
1594 PropertyAccessorElement accessor = element as PropertyAccessorElement; 1647 PropertyAccessorElement accessor = element as PropertyAccessorElement;
1648 // should be setter
1595 if (!accessor.isSetter) { 1649 if (!accessor.isSetter) {
1596 return location; 1650 return location;
1597 } 1651 }
1652 // accessor should be synthetic, i.e. field normal
1598 if (!accessor.isSynthetic) { 1653 if (!accessor.isSynthetic) {
1599 return location; 1654 return location;
1600 } 1655 }
1656 // should be LHS of assignment
1601 ASTNode parent; 1657 ASTNode parent;
1602 { 1658 {
1603 ASTNode node = identifier; 1659 ASTNode node = identifier;
1604 parent = node.parent; 1660 parent = node.parent;
1661 // new T().field = x;
1605 if (parent is PropertyAccess) { 1662 if (parent is PropertyAccess) {
1606 PropertyAccess propertyAccess = parent as PropertyAccess; 1663 PropertyAccess propertyAccess = parent as PropertyAccess;
1607 if (identical(propertyAccess.propertyName, node)) { 1664 if (identical(propertyAccess.propertyName, node)) {
1608 node = propertyAccess; 1665 node = propertyAccess;
1609 parent = propertyAccess.parent; 1666 parent = propertyAccess.parent;
1610 } 1667 }
1611 } 1668 }
1669 // obj.field = x;
1612 if (parent is PrefixedIdentifier) { 1670 if (parent is PrefixedIdentifier) {
1613 PrefixedIdentifier prefixedIdentifier = parent as PrefixedIdentifier; 1671 PrefixedIdentifier prefixedIdentifier = parent as PrefixedIdentifier;
1614 if (identical(prefixedIdentifier.identifier, node)) { 1672 if (identical(prefixedIdentifier.identifier, node)) {
1615 node = prefixedIdentifier; 1673 node = prefixedIdentifier;
1616 parent = prefixedIdentifier.parent; 1674 parent = prefixedIdentifier.parent;
1617 } 1675 }
1618 } 1676 }
1619 } 1677 }
1678 // OK, remember the type
1620 if (parent is AssignmentExpression) { 1679 if (parent is AssignmentExpression) {
1621 AssignmentExpression assignment = parent as AssignmentExpression; 1680 AssignmentExpression assignment = parent as AssignmentExpression;
1622 Expression rhs = assignment.rightHandSide; 1681 Expression rhs = assignment.rightHandSide;
1623 location = getLocationWithExpressionType(location, rhs); 1682 location = getLocationWithExpressionType(location, rhs);
1624 } 1683 }
1684 // done
1625 return location; 1685 return location;
1626 } 1686 }
1627 1687
1628 /** 1688 /**
1629 * @return `true` if given "node" is part of [PrefixedIdentifier] "prefix.node ". 1689 * @return `true` if given "node" is part of [PrefixedIdentifier] "prefix.node ".
1630 */ 1690 */
1631 static bool isIdentifierInPrefixedIdentifier(SimpleIdentifier node) { 1691 static bool isIdentifierInPrefixedIdentifier(SimpleIdentifier node) {
1632 ASTNode parent = node.parent; 1692 ASTNode parent = node.parent;
1633 return parent is PrefixedIdentifier && identical(parent.identifier, node); 1693 return parent is PrefixedIdentifier && identical(parent.identifier, node);
1634 } 1694 }
(...skipping 142 matching lines...) Expand 10 before | Expand all | Expand 10 after
1777 _libraryElement = unitElement.enclosingElement; 1837 _libraryElement = unitElement.enclosingElement;
1778 if (_libraryElement != null) { 1838 if (_libraryElement != null) {
1779 return super.visitCompilationUnit(node); 1839 return super.visitCompilationUnit(node);
1780 } 1840 }
1781 } 1841 }
1782 return null; 1842 return null;
1783 } 1843 }
1784 1844
1785 Object visitConstructorDeclaration(ConstructorDeclaration node) { 1845 Object visitConstructorDeclaration(ConstructorDeclaration node) {
1786 ConstructorElement element = node.element; 1846 ConstructorElement element = node.element;
1847 // define
1787 { 1848 {
1788 Location location; 1849 Location location;
1789 if (node.name != null) { 1850 if (node.name != null) {
1790 int start = node.period.offset; 1851 int start = node.period.offset;
1791 int end = node.name.end; 1852 int end = node.name.end;
1792 location = createLocation3(start, end - start); 1853 location = createLocation3(start, end - start);
1793 } else { 1854 } else {
1794 int start = node.returnType.end; 1855 int start = node.returnType.end;
1795 location = createLocation3(start, 0); 1856 location = createLocation3(start, 0);
1796 } 1857 }
1797 recordRelationship(element, IndexConstants.IS_DEFINED_BY, location); 1858 recordRelationship(element, IndexConstants.IS_DEFINED_BY, location);
1798 } 1859 }
1860 // visit children
1799 enterScope(element); 1861 enterScope(element);
1800 try { 1862 try {
1801 return super.visitConstructorDeclaration(node); 1863 return super.visitConstructorDeclaration(node);
1802 } finally { 1864 } finally {
1803 exitScope(); 1865 exitScope();
1804 } 1866 }
1805 } 1867 }
1806 1868
1807 Object visitConstructorName(ConstructorName node) { 1869 Object visitConstructorName(ConstructorName node) {
1808 ConstructorElement element = node.staticElement; 1870 ConstructorElement element = node.staticElement;
(...skipping 115 matching lines...) Expand 10 before | Expand all | Expand 10 after
1924 } 1986 }
1925 1987
1926 Object visitPrefixExpression(PrefixExpression node) { 1988 Object visitPrefixExpression(PrefixExpression node) {
1927 recordOperatorReference(node.operator, node.bestElement); 1989 recordOperatorReference(node.operator, node.bestElement);
1928 return super.visitPrefixExpression(node); 1990 return super.visitPrefixExpression(node);
1929 } 1991 }
1930 1992
1931 Object visitSimpleIdentifier(SimpleIdentifier node) { 1993 Object visitSimpleIdentifier(SimpleIdentifier node) {
1932 Element nameElement = new NameElementImpl(node.name); 1994 Element nameElement = new NameElementImpl(node.name);
1933 Location location = createLocation2(node); 1995 Location location = createLocation2(node);
1996 // name in declaration
1934 if (node.inDeclarationContext()) { 1997 if (node.inDeclarationContext()) {
1935 recordRelationship(nameElement, IndexConstants.IS_DEFINED_BY, location); 1998 recordRelationship(nameElement, IndexConstants.IS_DEFINED_BY, location);
1936 return null; 1999 return null;
1937 } 2000 }
2001 // prepare information
1938 Element element = node.bestElement; 2002 Element element = node.bestElement;
2003 // qualified name reference
1939 recordQualifiedMemberReference(node, element, nameElement, location); 2004 recordQualifiedMemberReference(node, element, nameElement, location);
2005 // stop if already handled
1940 if (isAlreadyHandledName(node)) { 2006 if (isAlreadyHandledName(node)) {
1941 return null; 2007 return null;
1942 } 2008 }
2009 // record specific relations
1943 if (element is ClassElement || element is FunctionElement || element is Func tionTypeAliasElement || element is LabelElement || element is TypeParameterEleme nt) { 2010 if (element is ClassElement || element is FunctionElement || element is Func tionTypeAliasElement || element is LabelElement || element is TypeParameterEleme nt) {
1944 recordRelationship(element, IndexConstants.IS_REFERENCED_BY, location); 2011 recordRelationship(element, IndexConstants.IS_REFERENCED_BY, location);
1945 } else if (element is FieldElement) { 2012 } else if (element is FieldElement) {
1946 location = getLocationWithInitializerType(node, location); 2013 location = getLocationWithInitializerType(node, location);
1947 recordRelationship(element, IndexConstants.IS_REFERENCED_BY, location); 2014 recordRelationship(element, IndexConstants.IS_REFERENCED_BY, location);
1948 } else if (element is FieldFormalParameterElement) { 2015 } else if (element is FieldFormalParameterElement) {
1949 FieldFormalParameterElement fieldParameter = element; 2016 FieldFormalParameterElement fieldParameter = element;
1950 FieldElement field = fieldParameter.field; 2017 FieldElement field = fieldParameter.field;
1951 recordRelationship(field, IndexConstants.IS_REFERENCED_BY_QUALIFIED, locat ion); 2018 recordRelationship(field, IndexConstants.IS_REFERENCED_BY_QUALIFIED, locat ion);
1952 } else if (element is PrefixElement) { 2019 } else if (element is PrefixElement) {
(...skipping 51 matching lines...) Expand 10 before | Expand all | Expand 10 after
2004 enterScope(element); 2071 enterScope(element);
2005 try { 2072 try {
2006 return super.visitTypeParameter(node); 2073 return super.visitTypeParameter(node);
2007 } finally { 2074 } finally {
2008 exitScope(); 2075 exitScope();
2009 } 2076 }
2010 } 2077 }
2011 2078
2012 Object visitVariableDeclaration(VariableDeclaration node) { 2079 Object visitVariableDeclaration(VariableDeclaration node) {
2013 VariableElement element = node.element; 2080 VariableElement element = node.element;
2081 // record declaration
2014 { 2082 {
2015 SimpleIdentifier name = node.name; 2083 SimpleIdentifier name = node.name;
2016 Location location = createLocation2(name); 2084 Location location = createLocation2(name);
2017 location = getLocationWithExpressionType(location, node.initializer); 2085 location = getLocationWithExpressionType(location, node.initializer);
2018 recordRelationship(element, IndexConstants.IS_DEFINED_BY, location); 2086 recordRelationship(element, IndexConstants.IS_DEFINED_BY, location);
2019 } 2087 }
2088 // visit
2020 enterScope(element); 2089 enterScope(element);
2021 try { 2090 try {
2022 return super.visitVariableDeclaration(node); 2091 return super.visitVariableDeclaration(node);
2023 } finally { 2092 } finally {
2024 exitScope(); 2093 exitScope();
2025 } 2094 }
2026 } 2095 }
2027 2096
2028 Object visitVariableDeclarationList(VariableDeclarationList node) { 2097 Object visitVariableDeclarationList(VariableDeclarationList node) {
2029 NodeList<VariableDeclaration> variables = node.variables; 2098 NodeList<VariableDeclaration> variables = node.variables;
2030 if (variables != null) { 2099 if (variables != null) {
2100 // use first VariableDeclaration as Element for Location(s) in type
2031 { 2101 {
2032 TypeName type = node.type; 2102 TypeName type = node.type;
2033 if (type != null) { 2103 if (type != null) {
2034 for (VariableDeclaration variableDeclaration in variables) { 2104 for (VariableDeclaration variableDeclaration in variables) {
2035 enterScope(variableDeclaration.element); 2105 enterScope(variableDeclaration.element);
2036 try { 2106 try {
2037 type.accept(this); 2107 type.accept(this);
2038 } finally { 2108 } finally {
2039 exitScope(); 2109 exitScope();
2040 } 2110 }
2111 // only one iteration
2041 break; 2112 break;
2042 } 2113 }
2043 } 2114 }
2044 } 2115 }
2116 // visit variables
2045 variables.accept(this); 2117 variables.accept(this);
2046 } 2118 }
2047 return null; 2119 return null;
2048 } 2120 }
2049 2121
2050 /** 2122 /**
2051 * @return the [Location] representing location of the [ASTNode]. 2123 * @return the [Location] representing location of the [ASTNode].
2052 */ 2124 */
2053 Location createLocation2(ASTNode node) => createLocation3(node.offset, node.le ngth); 2125 Location createLocation2(ASTNode node) => createLocation3(node.offset, node.le ngth);
2054 2126
(...skipping 82 matching lines...) Expand 10 before | Expand all | Expand 10 after
2137 if (library != null) { 2209 if (library != null) {
2138 Location location = createLocation2(node.uri); 2210 Location location = createLocation2(node.uri);
2139 recordRelationship(library.definingCompilationUnit, IndexConstants.IS_REFE RENCED_BY, location); 2211 recordRelationship(library.definingCompilationUnit, IndexConstants.IS_REFE RENCED_BY, location);
2140 } 2212 }
2141 } 2213 }
2142 2214
2143 /** 2215 /**
2144 * Record reference to the given operator [Element] and name. 2216 * Record reference to the given operator [Element] and name.
2145 */ 2217 */
2146 void recordOperatorReference(Token operator, Element element) { 2218 void recordOperatorReference(Token operator, Element element) {
2219 // prepare location
2147 Location location = createLocation4(operator); 2220 Location location = createLocation4(operator);
2221 // record name reference
2148 { 2222 {
2149 String name = operator.lexeme; 2223 String name = operator.lexeme;
2150 if (name == "++") { 2224 if (name == "++") {
2151 name = "+"; 2225 name = "+";
2152 } 2226 }
2153 if (name == "--") { 2227 if (name == "--") {
2154 name = "-"; 2228 name = "-";
2155 } 2229 }
2156 if (name.endsWith("=") && name != "==") { 2230 if (name.endsWith("=") && name != "==") {
2157 name = name.substring(0, name.length - 1); 2231 name = name.substring(0, name.length - 1);
2158 } 2232 }
2159 Element nameElement = new NameElementImpl(name); 2233 Element nameElement = new NameElementImpl(name);
2160 Relationship relationship = element != null ? IndexConstants.IS_REFERENCED _BY_QUALIFIED_RESOLVED : IndexConstants.IS_REFERENCED_BY_QUALIFIED_UNRESOLVED; 2234 Relationship relationship = element != null ? IndexConstants.IS_REFERENCED _BY_QUALIFIED_RESOLVED : IndexConstants.IS_REFERENCED_BY_QUALIFIED_UNRESOLVED;
2161 recordRelationship(nameElement, relationship, location); 2235 recordRelationship(nameElement, relationship, location);
2162 } 2236 }
2237 // record element reference
2163 if (element != null) { 2238 if (element != null) {
2164 recordRelationship(element, IndexConstants.IS_INVOKED_BY_QUALIFIED, locati on); 2239 recordRelationship(element, IndexConstants.IS_INVOKED_BY_QUALIFIED, locati on);
2165 } 2240 }
2166 } 2241 }
2167 2242
2168 /** 2243 /**
2169 * Records reference if the given [SimpleIdentifier] looks like a qualified pr operty access 2244 * Records reference if the given [SimpleIdentifier] looks like a qualified pr operty access
2170 * or method invocation. 2245 * or method invocation.
2171 */ 2246 */
2172 void recordQualifiedMemberReference(SimpleIdentifier node, Element element, El ement nameElement, Location location) { 2247 void recordQualifiedMemberReference(SimpleIdentifier node, Element element, El ement nameElement, Location location) {
(...skipping 235 matching lines...) Expand 10 before | Expand all | Expand 10 after
2408 for (ToolkitObjectElement object in toolkitObjects) { 2483 for (ToolkitObjectElement object in toolkitObjects) {
2409 if (object is AngularComponentElement) { 2484 if (object is AngularComponentElement) {
2410 indexComponent(object); 2485 indexComponent(object);
2411 } 2486 }
2412 if (object is AngularDirectiveElement) { 2487 if (object is AngularDirectiveElement) {
2413 AngularDirectiveElement directive = object; 2488 AngularDirectiveElement directive = object;
2414 indexDirective(directive); 2489 indexDirective(directive);
2415 } 2490 }
2416 } 2491 }
2417 } 2492 }
2493 // stop visiting
2418 return null; 2494 return null;
2419 } 2495 }
2420 2496
2421 Object visitCompilationUnitMember(CompilationUnitMember node) => null; 2497 Object visitCompilationUnitMember(CompilationUnitMember node) => null;
2422 2498
2423 void indexComponent(AngularComponentElement component) { 2499 void indexComponent(AngularComponentElement component) {
2424 indexProperties(component.properties); 2500 indexProperties(component.properties);
2425 } 2501 }
2426 2502
2427 void indexDirective(AngularDirectiveElement directive) { 2503 void indexDirective(AngularDirectiveElement directive) {
2428 indexProperties(directive.properties); 2504 indexProperties(directive.properties);
2429 } 2505 }
2430 2506
2431 void indexProperties(List<AngularPropertyElement> properties) { 2507 void indexProperties(List<AngularPropertyElement> properties) {
2432 for (AngularPropertyElement property in properties) { 2508 for (AngularPropertyElement property in properties) {
2433 FieldElement field = property.field; 2509 FieldElement field = property.field;
2434 if (field != null) { 2510 if (field != null) {
2435 int offset = property.fieldNameOffset; 2511 int offset = property.fieldNameOffset;
2436 int length = field.name.length; 2512 int length = field.name.length;
2437 Location location = new Location(property, offset, length); 2513 Location location = new Location(property, offset, length);
2438 _store.recordRelationship(field, IndexConstants.IS_REFERENCED_BY, locati on); 2514 // getter reference
2515 if (property.propertyKind.callsGetter()) {
2516 PropertyAccessorElement getter = field.getter;
2517 if (getter != null) {
2518 _store.recordRelationship(getter, IndexConstants.IS_REFERENCED_BY_QU ALIFIED, location);
2519 }
2520 }
2521 // setter reference
2522 if (property.propertyKind.callsSetter()) {
2523 PropertyAccessorElement setter = field.setter;
2524 if (setter != null) {
2525 _store.recordRelationship(setter, IndexConstants.IS_REFERENCED_BY_QU ALIFIED, location);
2526 }
2527 }
2439 } 2528 }
2440 } 2529 }
2441 } 2530 }
2442 } 2531 }
2443 2532
2444 /** 2533 /**
2445 * Instances of the [RemoveContextOperation] implement an operation that removes from the 2534 * Instances of the [RemoveContextOperation] implement an operation that removes from the
2446 * index any data based on the specified [AnalysisContext]. 2535 * index any data based on the specified [AnalysisContext].
2447 * 2536 *
2448 * @coverage dart.engine.index 2537 * @coverage dart.engine.index
(...skipping 229 matching lines...) Expand 10 before | Expand all | Expand 10 after
2678 * element are available. For example, if the element is a field and the relat ionship is the 2767 * element are available. For example, if the element is a field and the relat ionship is the
2679 * is-referenced-by relationship, then this method will be invoked with each l ocation at which the 2768 * is-referenced-by relationship, then this method will be invoked with each l ocation at which the
2680 * field is referenced. 2769 * field is referenced.
2681 * 2770 *
2682 * @param element the [Element] that has the relationship with the locations 2771 * @param element the [Element] that has the relationship with the locations
2683 * @param relationship the relationship between the given element and the loca tions 2772 * @param relationship the relationship between the given element and the loca tions
2684 * @param locations the locations that were found 2773 * @param locations the locations that were found
2685 */ 2774 */
2686 void hasRelationships(Element element, Relationship relationship, List<Locatio n> locations); 2775 void hasRelationships(Element element, Relationship relationship, List<Locatio n> locations);
2687 } 2776 }
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