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

Side by Side Diff: pkg/analysis_server/lib/src/provisional/completion/completion_dart.dart

Issue 1467023002: step toward new completion API (Closed) Base URL: git@github.com:dart-lang/sdk.git@master
Patch Set: Created 5 years, 1 month 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
OLDNEW
1 // Copyright (c) 2015, the Dart project authors. Please see the AUTHORS file 1 // Copyright (c) 2015, 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 analysis_server.src.provisional.completion.completion_dart; 5 library analysis_server.src.provisional.completion.completion_dart;
6 6
7 import 'dart:async';
8
7 import 'package:analysis_server/plugin/protocol/protocol.dart'; 9 import 'package:analysis_server/plugin/protocol/protocol.dart';
8 import 'package:analysis_server/src/provisional/completion/completion_core.dart' ; 10 import 'package:analysis_server/src/provisional/completion/completion_core.dart' ;
9 import 'package:analysis_server/src/provisional/completion/dart/completion_targe t.dart'; 11 import 'package:analysis_server/src/provisional/completion/dart/completion_targe t.dart';
10 import 'package:analyzer/src/generated/ast.dart'; 12 import 'package:analyzer/src/generated/ast.dart';
11 import 'package:analyzer/src/generated/engine.dart';
12 import 'package:analyzer/src/generated/source.dart';
13 13
14 /** 14 /**
15 * An object used to produce completions for a specific error within a Dart 15 * An object used to produce completions at a specific location within a file.
Brian Wilkerson 2015/11/22 18:02:46 "file" --> "Dart file"
danrubel 2015/11/23 17:47:31 Done.
16 * file. Completion contributors are long-lived objects and must not retain any
17 * state between invocations of [computeSuggestions].
18 * 16 *
19 * Clients may extend this class when implementing plugins. 17 * Clients may implement this class when implementing plugins.
20 */ 18 */
21 abstract class DartCompletionContributor implements CompletionContributor { 19 abstract class DartCompletionContributor {
22 @override
23 List<CompletionSuggestion> computeSuggestions(CompletionRequest request) {
24 if (request is DartCompletionRequest) {
25 return internalComputeSuggestions(request);
26 }
27 AnalysisContext context = request.context;
28 Source source = request.source;
29 List<Source> libraries = context.getLibrariesContaining(source);
30 if (libraries.length < 1) {
31 return null;
32 }
33 // CompilationUnit unit =
34 // context.getResolvedCompilationUnit2(source, libraries[0]);
35 // bool isResolved = true;
36 // if (unit == null) {
37 // // TODO(brianwilkerson) Implement a method for getting a parsed
38 // // compilation unit without parsing the unit if it hasn't been parsed.
39 // unit = context.getParsedCompilationUnit(source);
40 // if (unit == null) {
41 // return null;
42 // }
43 // isResolved = false;
44 // }
45 // DartCompletionRequest dartRequest =
46 // new DartCompletionRequestImpl(request, unit, isResolved);
47 // return internalComputeSuggestions(dartRequest);
48 return null;
49 }
50
51 /** 20 /**
52 * Compute a list of completion suggestions based on the given completion 21 * Compute [suggestions] for the given completion [request].
scheglov 2015/11/22 05:19:01 Where is "suggestions" defined?
danrubel 2015/11/23 17:47:31 Revised similar to CompletionContributor.
53 * [request]. Return the suggestions that were computed. 22 * Return a [Future] that completes with a list of suggestions.
54 */ 23 */
55 List<CompletionSuggestion> internalComputeSuggestions( 24 Future<List<CompletionSuggestion>> computeSuggestions(
56 DartCompletionRequest request); 25 DartCompletionRequest request);
57 } 26 }
58 27
59 /** 28 /**
60 * The information about a requested list of completions within a Dart file. 29 * The information about a requested list of completions within a Dart file.
61 * 30 *
62 * Clients may not extend, implement or mix-in this class. 31 * Clients may not extend, implement or mix-in this class.
63 */ 32 */
64 abstract class DartCompletionRequest extends CompletionRequest { 33 abstract class DartCompletionRequest extends CompletionRequest {
65 /** 34 /**
66 * Return `true` if the compilation [unit] is resolved.
67 */
68 bool get isResolved;
69
70 /**
71 * Return the completion target. This determines what part of the parse tree 35 * Return the completion target. This determines what part of the parse tree
72 * will receive the newly inserted text. 36 * will receive the newly inserted text.
73 */ 37 */
74 CompletionTarget get target; 38 CompletionTarget get target;
75 39
76 /** 40 /**
77 * Cached information from a prior code completion operation. 41 * Return a [Future] that completes with a compilation unit in which
42 * all declarations in all scopes containing [target] have been resolved.
43 * Any any information obtained from [target] prior to calling this method
scheglov 2015/11/22 05:19:01 Really any! :-)
danrubel 2015/11/23 17:47:32 Fixed :)
44 * should be discarded as it may have changed.
Brian Wilkerson 2015/11/22 18:02:46 Needs to document that `null` can be returned and
danrubel 2015/11/23 17:47:31 Done.
78 */ 45 */
79 //DartCompletionCache get cache; 46 Future<CompilationUnit> resolveDeclarationsInScope();
80
81 /**
82 * Return the compilation unit in which the completion was requested.
83 */
84 CompilationUnit get unit;
85
86 /**
87 * Information about the types of suggestions that should be included.
88 */
89 //OpType get _optype;
90 } 47 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698