Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(197)

Side by Side Diff: pkg/analysis_services/lib/completion/completion_suggestion.dart

Issue 428313002: refactor code completion to allow for multiple suggestion computers (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: merge Created 6 years, 4 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
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 services.completion.suggestion; 5 library services.completion.suggestion;
6 6
7 import 'package:analysis_services/json.dart'; 7 import 'package:analysis_services/json.dart';
8 import 'package:analysis_services/constants.dart'; 8 import 'package:analysis_services/constants.dart';
9 import 'package:analyzer/src/generated/element.dart'; 9 import 'package:analyzer/src/generated/element.dart';
10 10
11 /** 11 /**
12 * A single completion suggestion. 12 * A single completion suggestion.
13 */ 13 */
14 class CompletionSuggestion implements HasToJson { 14 class CompletionSuggestion implements HasToJson {
15
16 /**
17 * The kind of element being suggested.
18 */
15 final CompletionSuggestionKind kind; 19 final CompletionSuggestionKind kind;
20
21 /**
22 * The relevance of this completion suggestion.
23 */
16 final CompletionRelevance relevance; 24 final CompletionRelevance relevance;
25
26 /**
27 * The identifier to be inserted if the suggestion is selected.
28 * If the suggestion is for a method or function, the client might want to
29 * additionally insert a template for the parameters.
30 * The information required in order to do so is contained in other fields.
31 */
17 final String completion; 32 final String completion;
33
34 /**
35 * The offset, relative to the beginning of the completion, of where
36 * the selection should be placed after insertion.
37 */
18 final int selectionOffset; 38 final int selectionOffset;
39
40 /**
41 * The number of characters that should be selected after insertion.
42 */
19 final int selectionLength; 43 final int selectionLength;
44
45 /**
46 * `true` if the suggested element is deprecated.
47 */
20 final bool isDeprecated; 48 final bool isDeprecated;
49
50 /**
51 * True if the element is not known to be valid for the target.
52 * This happens if the type of the target is dynamic.
53 */
21 final bool isPotential; 54 final bool isPotential;
22 55
56 // optional fields
57
58 // final String docSummary;
59 // final String docComplete;
60 // final String declaringType;
61 // final String returnType;
62 // final List<String> parameterNames;
63 // final List<String> parameterTypes;
64 // final int requiredParameterCount;
65 // final int positionalParameterCount;
66 // final String parameterName;
67 // final String parameterType;
68
23 CompletionSuggestion(this.kind, this.relevance, this.completion, 69 CompletionSuggestion(this.kind, this.relevance, this.completion,
24 this.selectionOffset, this.selectionLength, this.isDeprecated, 70 this.selectionOffset, this.selectionLength, this.isDeprecated,
25 this.isPotential); 71 this.isPotential);
26 72
27 factory CompletionSuggestion.fromJson(Map<String, Object> json) { 73 factory CompletionSuggestion.fromJson(Map<String, Object> json) {
28 return new CompletionSuggestion( 74 return new CompletionSuggestion(
29 CompletionSuggestionKind.valueOf(json[KIND]), 75 CompletionSuggestionKind.valueOf(json[KIND]),
30 CompletionRelevance.value(json[RELEVANCE]), 76 CompletionRelevance.value(json[RELEVANCE]),
31 json[COMPLETION], 77 json[COMPLETION],
32 json[SELECTION_OFFSET], 78 json[SELECTION_OFFSET],
(...skipping 147 matching lines...) Expand 10 before | Expand all | Expand 10 after
180 226
181 const CompletionRelevance(this.name); 227 const CompletionRelevance(this.name);
182 228
183 static CompletionRelevance value(String name) { 229 static CompletionRelevance value(String name) {
184 if (LOW.name == name) return LOW; 230 if (LOW.name == name) return LOW;
185 if (DEFAULT.name == name) return DEFAULT; 231 if (DEFAULT.name == name) return DEFAULT;
186 if (HIGH.name == name) return HIGH; 232 if (HIGH.name == name) return HIGH;
187 throw new ArgumentError('Unknown CompletionRelevance: $name'); 233 throw new ArgumentError('Unknown CompletionRelevance: $name');
188 } 234 }
189 } 235 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698