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

Unified Diff: pkg/analysis_server/lib/src/computer/computer_hover.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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | pkg/analysis_server/lib/src/services/completion/dart/suggestion_builder.dart » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: pkg/analysis_server/lib/src/computer/computer_hover.dart
diff --git a/pkg/analysis_server/lib/src/computer/computer_hover.dart b/pkg/analysis_server/lib/src/computer/computer_hover.dart
index 1238489bb23023bee79b9d10516e439e0efc0bbb..45467ca10933d700ffff61251fa1a3d92c55e685 100644
--- a/pkg/analysis_server/lib/src/computer/computer_hover.dart
+++ b/pkg/analysis_server/lib/src/computer/computer_hover.dart
@@ -6,52 +6,10 @@ library computer.hover;
import 'package:analysis_server/plugin/protocol/protocol.dart'
show HoverInformation;
+import 'package:analysis_server/src/utilities/documentation.dart';
import 'package:analyzer/dart/element/element.dart';
import 'package:analyzer/src/generated/ast.dart';
-
-/**
- * Converts [str] from a Dart Doc string with slashes and stars to a plain text
- * representation of the comment.
- */
-String _removeDartDocDelimiters(String str) {
- if (str == null) {
- return null;
- }
- // remove /** */
- if (str.startsWith('/**')) {
- str = str.substring(3);
- }
- if (str.endsWith("*/")) {
- str = str.substring(0, str.length - 2);
- }
- str = str.trim();
- // remove leading '* '
- List<String> lines = str.split('\n');
- StringBuffer sb = new StringBuffer();
- bool firstLine = true;
- for (String line in lines) {
- line = line.trim();
- if (line.startsWith("*")) {
- line = line.substring(1);
- if (line.startsWith(" ")) {
- line = line.substring(1);
- }
- } else if (line.startsWith("///")) {
- line = line.substring(3);
- if (line.startsWith(" ")) {
- line = line.substring(1);
- }
- }
- if (!firstLine) {
- sb.write('\n');
- }
- firstLine = false;
- sb.write(line);
- }
- str = sb.toString();
- // done
- return str;
-}
+import 'package:analyzer/src/generated/element.dart';
/**
* A computer for the hover at the specified offset of a Dart [CompilationUnit].
@@ -111,6 +69,7 @@ class DartUnitHoverComputer {
hover.containingLibraryPath = library.source.fullName;
}
}
+
// documentation
hover.dartdoc = _computeDocumentation(element);
}
@@ -132,8 +91,7 @@ class DartUnitHoverComputer {
if (element is ParameterElement) {
element = element.enclosingElement;
}
- String dartDoc = element.computeDocumentationComment();
- return _removeDartDocDelimiters(dartDoc);
+ return removeDartDocDelimiters(element.documentationComment);
}
static _safeToString(obj) => obj != null ? obj.toString() : null;
« no previous file with comments | « no previous file | pkg/analysis_server/lib/src/services/completion/dart/suggestion_builder.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698