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

Side by Side Diff: pkg/analysis_server/lib/src/computer/computer_occurrences.dart

Issue 628293004: Remove references to Engine classes from protocol.dart (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Created 6 years, 2 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
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 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/protocol.dart' as protocol; 9 import 'package:analysis_server/src/protocol_server.dart' as protocol;
10 import 'package:analyzer/src/generated/ast.dart'; 10 import 'package:analyzer/src/generated/ast.dart';
11 import 'package:analyzer/src/generated/element.dart'; 11 import 'package:analyzer/src/generated/element.dart';
12 12
13 13
14 /** 14 /**
15 * A computer for elements occurrences in a Dart [CompilationUnit]. 15 * A computer for elements occurrences in a Dart [CompilationUnit].
16 */ 16 */
17 class DartUnitOccurrencesComputer { 17 class DartUnitOccurrencesComputer {
18 final CompilationUnit _unit; 18 final CompilationUnit _unit;
19 19
20 final Map<Element, List<int>> _elementsOffsets = 20 final Map<Element, List<int>> _elementsOffsets =
21 new HashMap<Element, List<int>>(); 21 new HashMap<Element, List<int>>();
22 22
23 DartUnitOccurrencesComputer(this._unit); 23 DartUnitOccurrencesComputer(this._unit);
24 24
25 /** 25 /**
26 * Returns the computed occurrences, not `null`. 26 * Returns the computed occurrences, not `null`.
27 */ 27 */
28 List<protocol.Occurrences> compute() { 28 List<protocol.Occurrences> compute() {
29 _unit.accept(new _DartUnitOccurrencesComputerVisitor(this)); 29 _unit.accept(new _DartUnitOccurrencesComputerVisitor(this));
30 List<protocol.Occurrences> occurrences = <protocol.Occurrences>[]; 30 List<protocol.Occurrences> occurrences = <protocol.Occurrences>[];
31 _elementsOffsets.forEach((engineElement, offsets) { 31 _elementsOffsets.forEach((engineElement, offsets) {
32 var serverElement = new protocol.Element.fromEngine(engineElement); 32 var serverElement = protocol.newElement_fromEngine(engineElement);
33 var length = engineElement.displayName.length; 33 var length = engineElement.displayName.length;
34 occurrences.add(new protocol.Occurrences(serverElement, offsets, length)); 34 occurrences.add(new protocol.Occurrences(serverElement, offsets, length));
35 }); 35 });
36 return occurrences; 36 return occurrences;
37 } 37 }
38 38
39 void _addOccurrence(Element element, int offset) { 39 void _addOccurrence(Element element, int offset) {
40 if (element == null || element == DynamicElementImpl.instance) { 40 if (element == null || element == DynamicElementImpl.instance) {
41 return; 41 return;
42 } 42 }
(...skipping 28 matching lines...) Expand all
71 71
72 @override 72 @override
73 visitSimpleIdentifier(SimpleIdentifier node) { 73 visitSimpleIdentifier(SimpleIdentifier node) {
74 Element element = node.bestElement; 74 Element element = node.bestElement;
75 if (element != null) { 75 if (element != null) {
76 computer._addOccurrence(element, node.offset); 76 computer._addOccurrence(element, node.offset);
77 } 77 }
78 return super.visitSimpleIdentifier(node); 78 return super.visitSimpleIdentifier(node);
79 } 79 }
80 } 80 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698