| 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 'dart:collection'; | 7 import 'dart:collection'; |
| 8 | 8 |
| 9 import 'package:analysis_server/src/protocol_server.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'; |
| (...skipping 26 matching lines...) Expand all Loading... |
| 37 if (element is FieldFormalParameterElement) { | 37 if (element is FieldFormalParameterElement) { |
| 38 element = (element as FieldFormalParameterElement).field; | 38 element = (element as FieldFormalParameterElement).field; |
| 39 } | 39 } |
| 40 if (element == null || element == DynamicElementImpl.instance) { | 40 if (element == null || element == DynamicElementImpl.instance) { |
| 41 return; | 41 return; |
| 42 } | 42 } |
| 43 if (element.location == null) { | 43 if (element.location == null) { |
| 44 return; | 44 return; |
| 45 } | 45 } |
| 46 int targetIndex = _addTarget(element); | 46 int targetIndex = _addTarget(element); |
| 47 // TODO(scheglov) Fix the enclosing element problem in the incremental |
| 48 // resolver and remove this. |
| 49 if (targetIndex == null) { |
| 50 return; |
| 51 } |
| 47 regions.add( | 52 regions.add( |
| 48 new protocol.NavigationRegion(offset, length, <int>[targetIndex])); | 53 new protocol.NavigationRegion(offset, length, <int>[targetIndex])); |
| 49 } | 54 } |
| 50 | 55 |
| 51 int _addTarget(Element element) { | 56 int _addTarget(Element element) { |
| 52 int index = targetMap[element]; | 57 int index = targetMap[element]; |
| 53 if (index == null) { | 58 if (index == null) { |
| 54 index = targets.length; | 59 index = targets.length; |
| 55 protocol.NavigationTarget target = | 60 protocol.NavigationTarget target = |
| 56 protocol.newNavigationTarget_fromElement(element, _addFile); | 61 protocol.newNavigationTarget_fromElement(element, _addFile); |
| 62 // TODO(scheglov) Fix the enclosing element problem in the incremental |
| 63 // resolver and remove this. |
| 64 if (target == null) { |
| 65 return null; |
| 66 } |
| 57 targets.add(target); | 67 targets.add(target); |
| 58 targetMap[element] = index; | 68 targetMap[element] = index; |
| 59 } | 69 } |
| 60 return index; | 70 return index; |
| 61 } | 71 } |
| 62 | 72 |
| 63 int _addFile(String file) { | 73 int _addFile(String file) { |
| 64 int index = fileMap[file]; | 74 int index = fileMap[file]; |
| 65 if (index == null) { | 75 if (index == null) { |
| 66 index = files.length; | 76 index = files.length; |
| (...skipping 177 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 244 Element element = node.bestElement; | 254 Element element = node.bestElement; |
| 245 computer._addRegionForNode(node, element); | 255 computer._addRegionForNode(node, element); |
| 246 } | 256 } |
| 247 | 257 |
| 248 void _safelyVisit(AstNode node) { | 258 void _safelyVisit(AstNode node) { |
| 249 if (node != null) { | 259 if (node != null) { |
| 250 node.accept(this); | 260 node.accept(this); |
| 251 } | 261 } |
| 252 } | 262 } |
| 253 } | 263 } |
| OLD | NEW |