| 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 protocol.server; | 5 library protocol.server; |
| 6 | 6 |
| 7 import 'package:analysis_server/src/protocol.dart'; | 7 import 'package:analysis_server/src/protocol.dart'; |
| 8 import 'package:analysis_server/src/services/search/search_engine.dart' | 8 import 'package:analysis_server/src/services/search/search_engine.dart' |
| 9 as engine; | 9 as engine; |
| 10 import 'package:analyzer/src/generated/ast.dart' as engine; | 10 import 'package:analyzer/src/generated/ast.dart' as engine; |
| (...skipping 195 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 206 engine.CompilationUnitElement unitElement = unit.element; | 206 engine.CompilationUnitElement unitElement = unit.element; |
| 207 engine.AnalysisContext context = unitElement.context; | 207 engine.AnalysisContext context = unitElement.context; |
| 208 engine.Source source = unitElement.source; | 208 engine.Source source = unitElement.source; |
| 209 return _locationForArgs(context, source, range); | 209 return _locationForArgs(context, source, range); |
| 210 } | 210 } |
| 211 | 211 |
| 212 NavigationTarget newNavigationTarget_fromElement( | 212 NavigationTarget newNavigationTarget_fromElement( |
| 213 engine.Element element, int fileToIndex(String file)) { | 213 engine.Element element, int fileToIndex(String file)) { |
| 214 ElementKind kind = newElementKind_fromEngine(element.kind); | 214 ElementKind kind = newElementKind_fromEngine(element.kind); |
| 215 Location location = newLocation_fromElement(element); | 215 Location location = newLocation_fromElement(element); |
| 216 // TODO(scheglov) debug null Location | |
| 217 if (location == null) { | |
| 218 String desc = 'location == null'; | |
| 219 try { | |
| 220 desc += ' for: $element'; | |
| 221 desc += ' of type: ${element.runtimeType}'; | |
| 222 desc += ' element.location: ${element.location}'; | |
| 223 desc += ' element.context: ${element.context}'; | |
| 224 desc += ' element.source: ${element.source}'; | |
| 225 } catch (e) {} | |
| 226 throw new ArgumentError(desc); | |
| 227 } | |
| 228 String file = location.file; | 216 String file = location.file; |
| 229 int fileIndex = fileToIndex(file); | 217 int fileIndex = fileToIndex(file); |
| 230 return new NavigationTarget(kind, fileIndex, location.offset, location.length, | 218 return new NavigationTarget(kind, fileIndex, location.offset, location.length, |
| 231 location.startLine, location.startColumn); | 219 location.startLine, location.startColumn); |
| 232 } | 220 } |
| 233 | 221 |
| 234 /** | 222 /** |
| 235 * Construct based on an element from the analyzer engine. | 223 * Construct based on an element from the analyzer engine. |
| 236 */ | 224 */ |
| 237 OverriddenMember newOverriddenMember_fromEngine(engine.Element member) { | 225 OverriddenMember newOverriddenMember_fromEngine(engine.Element member) { |
| (...skipping 184 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 422 if (lineInfo != null) { | 410 if (lineInfo != null) { |
| 423 engine.LineInfo_Location offsetLocation = | 411 engine.LineInfo_Location offsetLocation = |
| 424 lineInfo.getLocation(range.offset); | 412 lineInfo.getLocation(range.offset); |
| 425 startLine = offsetLocation.lineNumber; | 413 startLine = offsetLocation.lineNumber; |
| 426 startColumn = offsetLocation.columnNumber; | 414 startColumn = offsetLocation.columnNumber; |
| 427 } | 415 } |
| 428 } | 416 } |
| 429 return new Location( | 417 return new Location( |
| 430 source.fullName, range.offset, range.length, startLine, startColumn); | 418 source.fullName, range.offset, range.length, startLine, startColumn); |
| 431 } | 419 } |
| OLD | NEW |