| 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 208 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 219 */ | 219 */ |
| 220 Location newLocation_fromUnit(engine.CompilationUnit unit, | 220 Location newLocation_fromUnit(engine.CompilationUnit unit, |
| 221 engine.SourceRange range) { | 221 engine.SourceRange range) { |
| 222 engine.CompilationUnitElement unitElement = unit.element; | 222 engine.CompilationUnitElement unitElement = unit.element; |
| 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, | 229 NavigationTarget newNavigationTarget_fromElement(engine.Element element, int |
| 230 int 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 String file = location.file; | 233 String file = location.file; |
| 234 int fileIndex = fileToIndex(file); | 234 int fileIndex = fileToIndex(file); |
| 235 return new NavigationTarget( | 235 return new NavigationTarget( |
| 236 kind, | 236 kind, |
| 237 fileIndex, | 237 fileIndex, |
| 238 location.offset, | 238 location.offset, |
| 239 location.length, | 239 location.length, |
| 240 location.startLine, | 240 location.startLine, |
| (...skipping 70 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 311 element = element.enclosingElement; | 311 element = element.enclosingElement; |
| 312 } | 312 } |
| 313 } | 313 } |
| 314 return path; | 314 return path; |
| 315 } | 315 } |
| 316 | 316 |
| 317 | 317 |
| 318 String _getParametersString(engine.Element element) { | 318 String _getParametersString(engine.Element element) { |
| 319 // TODO(scheglov) expose the corresponding feature from ExecutableElement | 319 // TODO(scheglov) expose the corresponding feature from ExecutableElement |
| 320 if (element is engine.ExecutableElement) { | 320 if (element is engine.ExecutableElement) { |
| 321 var sb = new StringBuffer(); | 321 // valid getters don't have parameters |
| 322 if (element.kind == engine.ElementKind.GETTER && |
| 323 element.parameters.isEmpty) { |
| 324 return null; |
| 325 } |
| 326 // append parameters |
| 327 StringBuffer sb = new StringBuffer(); |
| 322 String closeOptionalString = ''; | 328 String closeOptionalString = ''; |
| 323 for (var parameter in element.parameters) { | 329 for (engine.ParameterElement parameter in element.parameters) { |
| 324 if (sb.isNotEmpty) { | 330 if (sb.isNotEmpty) { |
| 325 sb.write(', '); | 331 sb.write(', '); |
| 326 } | 332 } |
| 327 if (closeOptionalString.isEmpty) { | 333 if (closeOptionalString.isEmpty) { |
| 328 if (parameter.kind == engine.ParameterKind.NAMED) { | 334 if (parameter.kind == engine.ParameterKind.NAMED) { |
| 329 sb.write('{'); | 335 sb.write('{'); |
| 330 closeOptionalString = '}'; | 336 closeOptionalString = '}'; |
| 331 } | 337 } |
| 332 if (parameter.kind == engine.ParameterKind.POSITIONAL) { | 338 if (parameter.kind == engine.ParameterKind.POSITIONAL) { |
| 333 sb.write('['); | 339 sb.write('['); |
| (...skipping 82 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 416 startColumn = offsetLocation.columnNumber; | 422 startColumn = offsetLocation.columnNumber; |
| 417 } | 423 } |
| 418 } | 424 } |
| 419 return new Location( | 425 return new Location( |
| 420 source.fullName, | 426 source.fullName, |
| 421 range.offset, | 427 range.offset, |
| 422 range.length, | 428 range.length, |
| 423 startLine, | 429 startLine, |
| 424 startColumn); | 430 startColumn); |
| 425 } | 431 } |
| OLD | NEW |