| 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.navigation; | 5 library computer.navigation; |
| 6 | 6 |
| 7 import 'package:analysis_server/src/protocol_server.dart' as protocol; | 7 import 'package:analysis_server/src/protocol_server.dart' as protocol; |
| 8 import 'package:analyzer/src/generated/ast.dart'; | 8 import 'package:analyzer/src/generated/ast.dart'; |
| 9 import 'package:analyzer/src/generated/element.dart'; | 9 import 'package:analyzer/src/generated/element.dart'; |
| 10 import 'package:analyzer/src/generated/scanner.dart'; | 10 import 'package:analyzer/src/generated/scanner.dart'; |
| (...skipping 18 matching lines...) Expand all Loading... |
| 29 return new List.from(_regions); | 29 return new List.from(_regions); |
| 30 } | 30 } |
| 31 | 31 |
| 32 void _addRegion(int offset, int length, Element element) { | 32 void _addRegion(int offset, int length, Element element) { |
| 33 if (element is FieldFormalParameterElement) { | 33 if (element is FieldFormalParameterElement) { |
| 34 element = (element as FieldFormalParameterElement).field; | 34 element = (element as FieldFormalParameterElement).field; |
| 35 } | 35 } |
| 36 if (element == null || element == DynamicElementImpl.instance) { | 36 if (element == null || element == DynamicElementImpl.instance) { |
| 37 return; | 37 return; |
| 38 } | 38 } |
| 39 if (element.location == null) { |
| 40 return; |
| 41 } |
| 39 protocol.Element target = protocol.newElement_fromEngine(element); | 42 protocol.Element target = protocol.newElement_fromEngine(element); |
| 40 _regions.add(new protocol.NavigationRegion(offset, length, [target])); | 43 _regions.add(new protocol.NavigationRegion(offset, length, [target])); |
| 41 } | 44 } |
| 42 | 45 |
| 43 void _addRegion_nodeStart_nodeEnd(AstNode a, AstNode b, Element element) { | 46 void _addRegion_nodeStart_nodeEnd(AstNode a, AstNode b, Element element) { |
| 44 int offset = a.offset; | 47 int offset = a.offset; |
| 45 int length = b.end - offset; | 48 int length = b.end - offset; |
| 46 _addRegion(offset, length, element); | 49 _addRegion(offset, length, element); |
| 47 } | 50 } |
| 48 | 51 |
| (...skipping 177 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 226 Element element = node.bestElement; | 229 Element element = node.bestElement; |
| 227 computer._addRegionForNode(node, element); | 230 computer._addRegionForNode(node, element); |
| 228 } | 231 } |
| 229 | 232 |
| 230 void _safelyVisit(AstNode node) { | 233 void _safelyVisit(AstNode node) { |
| 231 if (node != null) { | 234 if (node != null) { |
| 232 node.accept(this); | 235 node.accept(this); |
| 233 } | 236 } |
| 234 } | 237 } |
| 235 } | 238 } |
| OLD | NEW |