| 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.dart' as protocol; | 7 import 'package:analysis_server/src/protocol.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 12 matching lines...) Expand all Loading... |
| 23 | 23 |
| 24 /** | 24 /** |
| 25 * Returns the computed navigation regions, not `null`. | 25 * Returns the computed navigation regions, not `null`. |
| 26 */ | 26 */ |
| 27 List<protocol.NavigationRegion> compute() { | 27 List<protocol.NavigationRegion> compute() { |
| 28 _unit.accept(new _DartUnitNavigationComputerVisitor(this)); | 28 _unit.accept(new _DartUnitNavigationComputerVisitor(this)); |
| 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) { |
| 34 element = (element as FieldFormalParameterElement).field; |
| 35 } |
| 33 if (element == null || element == DynamicElementImpl.instance) { | 36 if (element == null || element == DynamicElementImpl.instance) { |
| 34 return; | 37 return; |
| 35 } | 38 } |
| 36 if (element is FieldFormalParameterElement) { | |
| 37 element = (element as FieldFormalParameterElement).field; | |
| 38 } | |
| 39 protocol.Element target = new protocol.Element.fromEngine(element); | 39 protocol.Element target = new protocol.Element.fromEngine(element); |
| 40 _regions.add(new protocol.NavigationRegion(offset, length, [target])); | 40 _regions.add(new protocol.NavigationRegion(offset, length, [target])); |
| 41 } | 41 } |
| 42 | 42 |
| 43 void _addRegionForNode(AstNode node, Element element) { | 43 void _addRegionForNode(AstNode node, Element element) { |
| 44 int offset = node.offset; | 44 int offset = node.offset; |
| 45 int length = node.length; | 45 int length = node.length; |
| 46 _addRegion(offset, length, element); | 46 _addRegion(offset, length, element); |
| 47 } | 47 } |
| 48 | 48 |
| (...skipping 149 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 198 | 198 |
| 199 @override | 199 @override |
| 200 visitSimpleIdentifier(SimpleIdentifier node) { | 200 visitSimpleIdentifier(SimpleIdentifier node) { |
| 201 if (node.parent is ConstructorDeclaration) { | 201 if (node.parent is ConstructorDeclaration) { |
| 202 } else { | 202 } else { |
| 203 computer._addRegionForNode(node, node.bestElement); | 203 computer._addRegionForNode(node, node.bestElement); |
| 204 } | 204 } |
| 205 return super.visitSimpleIdentifier(node); | 205 return super.visitSimpleIdentifier(node); |
| 206 } | 206 } |
| 207 } | 207 } |
| OLD | NEW |