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

Side by Side Diff: pkg/analysis_server/lib/src/services/completion/dart/suggestion_builder.dart

Issue 1534043002: Cache element docs (and add to completions) (#23694). (Closed) Base URL: git@github.com:dart-lang/sdk.git@master
Patch Set: tweaks Created 5 years 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 services.completion.dart.suggestion.builder; 5 library services.completion.dart.suggestion.builder;
6 6
7 import 'package:analysis_server/src/protocol_server.dart' as protocol; 7 import 'package:analysis_server/src/protocol_server.dart' as protocol;
8 import 'package:analysis_server/src/protocol_server.dart' 8 import 'package:analysis_server/src/protocol_server.dart'
9 hide Element, ElementKind; 9 hide Element, ElementKind;
10 import 'package:analysis_server/src/provisional/completion/dart/completion_dart. dart'; 10 import 'package:analysis_server/src/provisional/completion/dart/completion_dart. dart';
11 import 'package:analysis_server/src/utilities/documentation.dart';
11 import 'package:analyzer/dart/element/element.dart'; 12 import 'package:analyzer/dart/element/element.dart';
12 import 'package:analyzer/dart/element/type.dart'; 13 import 'package:analyzer/dart/element/type.dart';
13 import 'package:analyzer/dart/element/visitor.dart'; 14 import 'package:analyzer/dart/element/visitor.dart';
14 import 'package:analyzer/src/generated/source.dart'; 15 import 'package:analyzer/src/generated/source.dart';
15 import 'package:analyzer/src/generated/utilities_dart.dart'; 16 import 'package:analyzer/src/generated/utilities_dart.dart';
16 import 'package:path/path.dart' as path; 17 import 'package:path/path.dart' as path;
17 18
18 const String DYNAMIC = 'dynamic'; 19 const String DYNAMIC = 'dynamic';
19 20
20 /** 21 /**
(...skipping 16 matching lines...) Expand all
37 } 38 }
38 bool isDeprecated = element.isDeprecated; 39 bool isDeprecated = element.isDeprecated;
39 CompletionSuggestion suggestion = new CompletionSuggestion( 40 CompletionSuggestion suggestion = new CompletionSuggestion(
40 kind, 41 kind,
41 isDeprecated ? DART_RELEVANCE_LOW : relevance, 42 isDeprecated ? DART_RELEVANCE_LOW : relevance,
42 completion, 43 completion,
43 completion.length, 44 completion.length,
44 0, 45 0,
45 isDeprecated, 46 isDeprecated,
46 false); 47 false);
48
49 // Attach docs.
50 String doc = removeDartDocDelimiters(element.documentationComment);
51 suggestion.docComplete = doc;
52 suggestion.docSummary = getDartDocSummary(doc);
53
47 suggestion.element = protocol.convertElement(element); 54 suggestion.element = protocol.convertElement(element);
48 Element enclosingElement = element.enclosingElement; 55 Element enclosingElement = element.enclosingElement;
49 if (enclosingElement is ClassElement) { 56 if (enclosingElement is ClassElement) {
50 suggestion.declaringType = enclosingElement.displayName; 57 suggestion.declaringType = enclosingElement.displayName;
51 } 58 }
52 suggestion.returnType = getReturnTypeString(element); 59 suggestion.returnType = getReturnTypeString(element);
53 if (element is ExecutableElement && element is! PropertyAccessorElement) { 60 if (element is ExecutableElement && element is! PropertyAccessorElement) {
54 suggestion.parameterNames = element.parameters 61 suggestion.parameterNames = element.parameters
55 .map((ParameterElement parameter) => parameter.name) 62 .map((ParameterElement parameter) => parameter.name)
56 .toList(); 63 .toList();
(...skipping 210 matching lines...) Expand 10 before | Expand all | Expand 10 after
267 @override 274 @override
268 visitTopLevelVariableElement(TopLevelVariableElement element) { 275 visitTopLevelVariableElement(TopLevelVariableElement element) {
269 if (!typesOnly) { 276 if (!typesOnly) {
270 int relevance = element.library == containingLibrary 277 int relevance = element.library == containingLibrary
271 ? DART_RELEVANCE_LOCAL_TOP_LEVEL_VARIABLE 278 ? DART_RELEVANCE_LOCAL_TOP_LEVEL_VARIABLE
272 : DART_RELEVANCE_DEFAULT; 279 : DART_RELEVANCE_DEFAULT;
273 addSuggestion(element, relevance: relevance); 280 addSuggestion(element, relevance: relevance);
274 } 281 }
275 } 282 }
276 } 283 }
OLDNEW
« no previous file with comments | « pkg/analysis_server/lib/src/computer/computer_hover.dart ('k') | pkg/analysis_server/lib/src/utilities/documentation.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698