| 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 71 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 82 return new AnalysisError( | 82 return new AnalysisError( |
| 83 severity, | 83 severity, |
| 84 type, | 84 type, |
| 85 location, | 85 location, |
| 86 message, | 86 message, |
| 87 correction: correction); | 87 correction: correction); |
| 88 } | 88 } |
| 89 | 89 |
| 90 | 90 |
| 91 /** | 91 /** |
| 92 * Construct from an analyzer engine element kind. | |
| 93 */ | |
| 94 CompletionSuggestionKind | |
| 95 newCompletionSuggestionKind_fromElementKind(engine.ElementKind kind) { | |
| 96 // ElementKind.ANGULAR_FORMATTER, | |
| 97 // ElementKind.ANGULAR_COMPONENT, | |
| 98 // ElementKind.ANGULAR_CONTROLLER, | |
| 99 // ElementKind.ANGULAR_DIRECTIVE, | |
| 100 // ElementKind.ANGULAR_PROPERTY, | |
| 101 // ElementKind.ANGULAR_SCOPE_PROPERTY, | |
| 102 // ElementKind.ANGULAR_SELECTOR, | |
| 103 // ElementKind.ANGULAR_VIEW, | |
| 104 if (kind == engine.ElementKind.CLASS) return CompletionSuggestionKind.CLASS; | |
| 105 // ElementKind.COMPILATION_UNIT, | |
| 106 if (kind == | |
| 107 engine.ElementKind.CONSTRUCTOR) return CompletionSuggestionKind.CONSTRUCTO
R; | |
| 108 // ElementKind.DYNAMIC, | |
| 109 // ElementKind.EMBEDDED_HTML_SCRIPT, | |
| 110 // ElementKind.ERROR, | |
| 111 // ElementKind.EXPORT, | |
| 112 // ElementKind.EXTERNAL_HTML_SCRIPT, | |
| 113 if (kind == engine.ElementKind.FIELD) return CompletionSuggestionKind.FIELD; | |
| 114 if (kind == | |
| 115 engine.ElementKind.FUNCTION) return CompletionSuggestionKind.FUNCTION; | |
| 116 if (kind == | |
| 117 engine.ElementKind.FUNCTION_TYPE_ALIAS) return | |
| 118 CompletionSuggestionKind.FUNCTION_TYPE_ALIAS; | |
| 119 if (kind == engine.ElementKind.GETTER) return CompletionSuggestionKind.GETTER; | |
| 120 // ElementKind.HTML, | |
| 121 if (kind == engine.ElementKind.IMPORT) return CompletionSuggestionKind.IMPORT; | |
| 122 // ElementKind.LABEL, | |
| 123 // ElementKind.LIBRARY, | |
| 124 if (kind == | |
| 125 engine.ElementKind.LOCAL_VARIABLE) return | |
| 126 CompletionSuggestionKind.LOCAL_VARIABLE; | |
| 127 if (kind == engine.ElementKind.METHOD) return CompletionSuggestionKind.METHOD; | |
| 128 // ElementKind.NAME, | |
| 129 if (kind == | |
| 130 engine.ElementKind.PARAMETER) return CompletionSuggestionKind.PARAMETER; | |
| 131 // ElementKind.POLYMER_ATTRIBUTE, | |
| 132 // ElementKind.POLYMER_TAG_DART, | |
| 133 // ElementKind.POLYMER_TAG_HTML, | |
| 134 // ElementKind.PREFIX, | |
| 135 if (kind == engine.ElementKind.SETTER) return CompletionSuggestionKind.SETTER; | |
| 136 if (kind == | |
| 137 engine.ElementKind.TOP_LEVEL_VARIABLE) return | |
| 138 CompletionSuggestionKind.TOP_LEVEL_VARIABLE; | |
| 139 // ElementKind.TYPE_PARAMETER, | |
| 140 // ElementKind.UNIVERSE | |
| 141 throw new ArgumentError('Unknown CompletionSuggestionKind for: $kind'); | |
| 142 } | |
| 143 | |
| 144 | |
| 145 | |
| 146 /** | |
| 147 * Construct based on a value from the analyzer engine. | 92 * Construct based on a value from the analyzer engine. |
| 148 */ | 93 */ |
| 149 ElementKind newElementKind_fromEngine(engine.ElementKind kind) { | 94 ElementKind newElementKind_fromEngine(engine.ElementKind kind) { |
| 150 if (kind == engine.ElementKind.CLASS) { | 95 if (kind == engine.ElementKind.CLASS) { |
| 151 return ElementKind.CLASS; | 96 return ElementKind.CLASS; |
| 152 } | 97 } |
| 153 if (kind == engine.ElementKind.COMPILATION_UNIT) { | 98 if (kind == engine.ElementKind.COMPILATION_UNIT) { |
| 154 return ElementKind.COMPILATION_UNIT; | 99 return ElementKind.COMPILATION_UNIT; |
| 155 } | 100 } |
| 156 if (kind == engine.ElementKind.CONSTRUCTOR) { | 101 if (kind == engine.ElementKind.CONSTRUCTOR) { |
| (...skipping 298 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 455 startColumn = offsetLocation.columnNumber; | 400 startColumn = offsetLocation.columnNumber; |
| 456 } | 401 } |
| 457 } | 402 } |
| 458 return new Location( | 403 return new Location( |
| 459 source.fullName, | 404 source.fullName, |
| 460 range.offset, | 405 range.offset, |
| 461 range.length, | 406 range.length, |
| 462 startLine, | 407 startLine, |
| 463 startColumn); | 408 startColumn); |
| 464 } | 409 } |
| OLD | NEW |