| 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 145 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 156 return ElementKind.UNKNOWN; | 156 return ElementKind.UNKNOWN; |
| 157 } | 157 } |
| 158 | 158 |
| 159 /** | 159 /** |
| 160 * Create a Location based on an [engine.Element]. | 160 * Create a Location based on an [engine.Element]. |
| 161 */ | 161 */ |
| 162 Location newLocation_fromElement(engine.Element element) { | 162 Location newLocation_fromElement(engine.Element element) { |
| 163 engine.AnalysisContext context = element.context; | 163 engine.AnalysisContext context = element.context; |
| 164 engine.Source source = element.source; | 164 engine.Source source = element.source; |
| 165 if (context == null || source == null) { | 165 if (context == null || source == null) { |
| 166 print('element=$element context=$context source=$source'); | |
| 167 engine.Element e = element; | |
| 168 while (e != null) { | |
| 169 print(' (${e.runtimeType}) $e'); | |
| 170 e = e.enclosingElement; | |
| 171 } | |
| 172 return null; | 166 return null; |
| 173 } | 167 } |
| 174 String name = element.displayName; | 168 String name = element.displayName; |
| 175 int offset = element.nameOffset; | 169 int offset = element.nameOffset; |
| 176 int length = name != null ? name.length : 0; | 170 int length = name != null ? name.length : 0; |
| 177 if (element is engine.CompilationUnitElement) { | 171 if (element is engine.CompilationUnitElement) { |
| 178 offset = 0; | 172 offset = 0; |
| 179 length = 0; | 173 length = 0; |
| 180 } | 174 } |
| 181 engine.SourceRange range = new engine.SourceRange(offset, length); | 175 engine.SourceRange range = new engine.SourceRange(offset, length); |
| (...skipping 234 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 416 if (lineInfo != null) { | 410 if (lineInfo != null) { |
| 417 engine.LineInfo_Location offsetLocation = | 411 engine.LineInfo_Location offsetLocation = |
| 418 lineInfo.getLocation(range.offset); | 412 lineInfo.getLocation(range.offset); |
| 419 startLine = offsetLocation.lineNumber; | 413 startLine = offsetLocation.lineNumber; |
| 420 startColumn = offsetLocation.columnNumber; | 414 startColumn = offsetLocation.columnNumber; |
| 421 } | 415 } |
| 422 } | 416 } |
| 423 return new Location( | 417 return new Location( |
| 424 source.fullName, range.offset, range.length, startLine, startColumn); | 418 source.fullName, range.offset, range.length, startLine, startColumn); |
| 425 } | 419 } |
| OLD | NEW |