| OLD | NEW |
| 1 // Copyright (c) 2014, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2014, the Dart project authors. Please see the AUTHORS file |
| 2 // for details. All rights reserved. Use of this source code is governed by a | 2 // for details. All rights reserved. Use of this source code is governed by a |
| 3 // BSD-style license that can be found in the LICENSE file. | 3 // BSD-style license that can be found in the LICENSE file. |
| 4 | 4 |
| 5 library computer.occurrences; | 5 library computer.occurrences; |
| 6 | 6 |
| 7 import 'dart:collection'; | 7 import 'dart:collection'; |
| 8 | 8 |
| 9 import 'package:analysis_server/src/computer/element.dart' as server; | 9 import 'package:analysis_server/src/computer/element.dart' as server; |
| 10 import 'package:analysis_services/constants.dart'; | 10 import 'package:analysis_services/constants.dart'; |
| (...skipping 21 matching lines...) Expand all Loading... |
| 32 List<Occurrences> occurrences = <Occurrences>[]; | 32 List<Occurrences> occurrences = <Occurrences>[]; |
| 33 _elementsOffsets.forEach((engineElement, offsets) { | 33 _elementsOffsets.forEach((engineElement, offsets) { |
| 34 var serverElement = new server.Element.fromEngine(engineElement); | 34 var serverElement = new server.Element.fromEngine(engineElement); |
| 35 var length = engineElement.displayName.length; | 35 var length = engineElement.displayName.length; |
| 36 occurrences.add(new Occurrences(serverElement, offsets, length)); | 36 occurrences.add(new Occurrences(serverElement, offsets, length)); |
| 37 }); | 37 }); |
| 38 return occurrences; | 38 return occurrences; |
| 39 } | 39 } |
| 40 | 40 |
| 41 void _addOccurrence(Element element, int offset) { | 41 void _addOccurrence(Element element, int offset) { |
| 42 if (element == null || element == DynamicElementImpl.instance) { |
| 43 return; |
| 44 } |
| 42 element = _canonicalizeElement(element); | 45 element = _canonicalizeElement(element); |
| 43 List<int> offsets = _elementsOffsets[element]; | 46 List<int> offsets = _elementsOffsets[element]; |
| 44 if (offsets == null) { | 47 if (offsets == null) { |
| 45 offsets = <int>[]; | 48 offsets = <int>[]; |
| 46 _elementsOffsets[element] = offsets; | 49 _elementsOffsets[element] = offsets; |
| 47 } | 50 } |
| 48 offsets.add(offset); | 51 offsets.add(offset); |
| 49 } | 52 } |
| 50 | 53 |
| 51 Element _canonicalizeElement(Element element) { | 54 Element _canonicalizeElement(Element element) { |
| (...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 97 | 100 |
| 98 @override | 101 @override |
| 99 visitSimpleIdentifier(SimpleIdentifier node) { | 102 visitSimpleIdentifier(SimpleIdentifier node) { |
| 100 Element element = node.bestElement; | 103 Element element = node.bestElement; |
| 101 if (element != null) { | 104 if (element != null) { |
| 102 computer._addOccurrence(element, node.offset); | 105 computer._addOccurrence(element, node.offset); |
| 103 } | 106 } |
| 104 return super.visitSimpleIdentifier(node); | 107 return super.visitSimpleIdentifier(node); |
| 105 } | 108 } |
| 106 } | 109 } |
| OLD | NEW |