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

Side by Side 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 unified diff | Download patch
OLDNEW
(Empty)
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
3 // BSD-style license that can be found in the LICENSE file.
4
5 library analysis_server.src.utilities.documentation;
6
7 String getDartDocSummary(String str) {
8 if (str == null) {
9 return null;
10 }
11 List<String> lines = str.split('\n');
12 StringBuffer sb = new StringBuffer();
13 bool firstLine = true;
14 for (String line in lines) {
15 if (sb.length != 0 && line.isEmpty) {
16 return sb.toString();
17 }
18 if (!firstLine) {
19 sb.write('\n');
20 }
21 firstLine = false;
22 sb.write(line);
23 }
24 return sb.toString();
25 }
26
27 /**
28 * Converts [str] from a Dart Doc string with slashes and stars to a plain text
29 * representation of the comment.
30 */
31 String removeDartDocDelimiters(String str) {
32 if (str == null) {
33 return null;
34 }
35 // remove /** */
36 if (str.startsWith('/**')) {
37 str = str.substring(3);
38 }
39 if (str.endsWith("*/")) {
40 str = str.substring(0, str.length - 2);
41 }
42 str = str.trim();
43 // remove leading '* ' and '/// '
44 List<String> lines = str.split('\n');
45 StringBuffer sb = new StringBuffer();
46 bool firstLine = true;
47 for (String line in lines) {
48 line = line.trim();
49 if (line.startsWith("*")) {
50 line = line.substring(1);
51 if (line.startsWith(" ")) {
52 line = line.substring(1);
53 }
54 } else if (line.startsWith("///")) {
55 line = line.substring(3);
56 if (line.startsWith(" ")) {
57 line = line.substring(1);
58 }
59 }
60 if (!firstLine) {
61 sb.write('\n');
62 }
63 firstLine = false;
64 sb.write(line);
65 }
66 str = sb.toString();
67 // done
68 return str;
69 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698