| 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' as | 8 import 'package:analysis_server/src/services/search/search_engine.dart' as |
| 9 engine; | 9 engine; |
| 10 import 'package:analyzer/src/generated/ast.dart' as engine; | 10 import 'package:analyzer/src/generated/ast.dart' as engine; |
| (...skipping 212 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 223 engine.AnalysisContext context = unitElement.context; | 223 engine.AnalysisContext context = unitElement.context; |
| 224 engine.Source source = unitElement.source; | 224 engine.Source source = unitElement.source; |
| 225 return _locationForArgs(context, source, range); | 225 return _locationForArgs(context, source, range); |
| 226 } | 226 } |
| 227 | 227 |
| 228 | 228 |
| 229 NavigationTarget newNavigationTarget_fromElement(engine.Element element, int | 229 NavigationTarget newNavigationTarget_fromElement(engine.Element element, int |
| 230 fileToIndex(String file)) { | 230 fileToIndex(String file)) { |
| 231 ElementKind kind = newElementKind_fromEngine(element.kind); | 231 ElementKind kind = newElementKind_fromEngine(element.kind); |
| 232 Location location = newLocation_fromElement(element); | 232 Location location = newLocation_fromElement(element); |
| 233 // TODO(scheglov) debug null Location |
| 234 if (location == null) { |
| 235 String desc = 'location == null'; |
| 236 try { |
| 237 desc += ' for: $element'; |
| 238 desc += ' of type: ${element.runtimeType}'; |
| 239 desc += ' element.location: ${element.location}'; |
| 240 desc += ' element.context: ${element.context}'; |
| 241 desc += ' element.source: ${element.source}'; |
| 242 } catch (e) { |
| 243 } |
| 244 throw new ArgumentError(desc); |
| 245 } |
| 233 String file = location.file; | 246 String file = location.file; |
| 234 int fileIndex = fileToIndex(file); | 247 int fileIndex = fileToIndex(file); |
| 235 return new NavigationTarget( | 248 return new NavigationTarget( |
| 236 kind, | 249 kind, |
| 237 fileIndex, | 250 fileIndex, |
| 238 location.offset, | 251 location.offset, |
| 239 location.length, | 252 location.length, |
| 240 location.startLine, | 253 location.startLine, |
| 241 location.startColumn); | 254 location.startColumn); |
| 242 } | 255 } |
| (...skipping 179 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 422 startColumn = offsetLocation.columnNumber; | 435 startColumn = offsetLocation.columnNumber; |
| 423 } | 436 } |
| 424 } | 437 } |
| 425 return new Location( | 438 return new Location( |
| 426 source.fullName, | 439 source.fullName, |
| 427 range.offset, | 440 range.offset, |
| 428 range.length, | 441 range.length, |
| 429 startLine, | 442 startLine, |
| 430 startColumn); | 443 startColumn); |
| 431 } | 444 } |
| OLD | NEW |