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

Unified Diff: pkg/analysis_server/lib/src/computer/computer_hover.dart

Issue 1390463002: Rollback https://codereview.chromium.org/1380223003 (Closed) Base URL: git@github.com:dart-lang/sdk.git@master
Patch Set: Created 5 years, 2 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 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/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 f212d22fa0576ddb516c5109a069505bf892dfa8..c09668b73937075f70b217a00996969bfb677548 100644
--- a/pkg/analysis_server/lib/src/computer/computer_hover.dart
+++ b/pkg/analysis_server/lib/src/computer/computer_hover.dart
@@ -5,11 +5,54 @@
library computer.hover;
import 'package:analysis_server/src/protocol.dart' show HoverInformation;
-import 'package:analysis_server/src/utilities/documentation.dart';
import 'package:analyzer/src/generated/ast.dart';
import 'package:analyzer/src/generated/element.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;
+}
+
+/**
* A computer for the hover at the specified offset of a Dart [CompilationUnit].
*/
class DartUnitHoverComputer {
@@ -69,7 +112,7 @@ class DartUnitHoverComputer {
}
// documentation
String dartDoc = element.computeDocumentationComment();
- dartDoc = removeDartDocDelimiters(dartDoc);
+ dartDoc = _removeDartDocDelimiters(dartDoc);
hover.dartdoc = dartDoc;
}
// parameter
« no previous file with comments | « no previous file | pkg/analysis_server/lib/src/services/completion/suggestion_builder.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698