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

Unified Diff: pkg/analysis_server/lib/src/utilities/documentation.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
Index: pkg/analysis_server/lib/src/utilities/documentation.dart
diff --git a/pkg/analysis_server/lib/src/utilities/documentation.dart b/pkg/analysis_server/lib/src/utilities/documentation.dart
new file mode 100644
index 0000000000000000000000000000000000000000..8e8e6964aa1fbad1858d7a4b3e8882bb2554b2f6
--- /dev/null
+++ b/pkg/analysis_server/lib/src/utilities/documentation.dart
@@ -0,0 +1,69 @@
+// Copyright (c) 2015, the Dart project authors. Please see the AUTHORS file
+// for details. All rights reserved. Use of this source code is governed by a
+// BSD-style license that can be found in the LICENSE file.
+
+library analysis_server.src.utilities.documentation;
+
+String getDartDocSummary(String str) {
+ if (str == null) {
+ return null;
+ }
+ List<String> lines = str.split('\n');
+ StringBuffer sb = new StringBuffer();
+ bool firstLine = true;
+ for (String line in lines) {
+ if (sb.length != 0 && line.isEmpty) {
+ return sb.toString();
+ }
+ if (!firstLine) {
+ sb.write('\n');
+ }
+ firstLine = false;
+ sb.write(line);
+ }
+ return sb.toString();
+}
+
+/**
+ * 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 '* ' and '/// '
+ 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;
+}

Powered by Google App Engine
This is Rietveld 408576698