Skip to content

Commit e69df8f

Browse files
committed
Revert "Initial commit"
This reverts commit d0e41ad.
1 parent b370648 commit e69df8f

File tree

6 files changed

+52
-130
lines changed

6 files changed

+52
-130
lines changed

lib/src/model/doc_comment.dart

Lines changed: 10 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -35,16 +35,11 @@ class DocComment {
3535

3636
Map<String, dynamic> toJson() => _$DocCommentToJson(this);
3737

38-
List<String> get descriptionLines {
39-
print('getting description lines ${_descriptionLines.length}');
40-
print('with annotations ${annotations.map((e) => e.toJson())}');
41-
return _descriptionLines.isNotEmpty
42-
? _descriptionLines
43-
: annotations
44-
.firstWhereOrNull((element) => element.name == 'description')
45-
?.bodyLines ??
46-
[];
47-
}
38+
List<String> get descriptionLines => _descriptionLines.isNotEmpty
39+
? _descriptionLines
40+
: annotations
41+
.firstWhereOrNull((element) => element.name == 'description')
42+
?.bodyLines ?? [];
4843

4944
set descriptionLines(List<String> descriptionLines) {
5045
List<String> cleanLines = [];
@@ -56,33 +51,16 @@ class DocComment {
5651
trimmedLine = '';
5752
}
5853

59-
cleanLines.add(trimmedLine);
60-
}
61-
}
62-
63-
// If the first line is empty, remove it
64-
if (cleanLines.isNotEmpty && cleanLines.first.isEmpty) {
65-
cleanLines.removeAt(0);
66-
}
67-
// If the last line is empty, remove it
68-
if (cleanLines.isNotEmpty && cleanLines.last.isEmpty) {
69-
cleanLines.removeLast();
70-
}
71-
72-
// When there are 2 blank strings back to back, remove one of them
73-
for (int i = 0; i < cleanLines.length - 1; i++) {
74-
if (cleanLines[i].isEmpty && cleanLines[i + 1].isEmpty) {
75-
cleanLines.removeAt(i);
54+
if (trimmedLine.isNotEmpty) {
55+
cleanLines.add(trimmedLine);
56+
}
7657
}
7758
}
78-
7959
_descriptionLines = cleanLines;
8060
}
8161

8262
/// Gets the description as a single line.
83-
String get description => descriptionLines
84-
.map((e) => e == '' ? '\n' : e)
85-
.join('');
63+
String get description => descriptionLines.join(' ');
8664

8765
List<DocCommentAnnotation> annotationsByName(String annotationName) {
8866
return annotations
@@ -99,7 +77,7 @@ class DocCommentAnnotation {
9977

10078
List<String> bodyLines = [];
10179

102-
String get body => bodyLines.map((e) => e.isEmpty ? '\n' : e).join('');
80+
String get body => bodyLines.join(' ');
10381

10482
DocCommentAnnotation(this.name, body) {
10583
if (body is String) {

lib/src/node/node.dart

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,5 +22,5 @@ String _parseFromDeclarationBody(String declarationBody) {
2222

2323
void main() {
2424
exports.reflect = allowInterop(
25-
(String declarationBody) => _parseFromDeclarationBody(declarationBody));
25+
(String declarationBody) => _parseFromDeclarationBody(declarationBody));
2626
}

lib/src/service/apex_listener.dart

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -145,10 +145,8 @@ class ApexClassListener extends ApexParserBaseListener {
145145
// We take and parse the first doc comment, in case it is the
146146
// start of a group.
147147
String potentialDocComment = allDocComments.first;
148-
print('potentialDocComment: $potentialDocComment');
149148
DocComment docCommentObject =
150149
ApexdocParser.parseFromBody(potentialDocComment);
151-
print('docCommentObject: ${docCommentObject.description}');
152150

153151
if (docCommentObject.annotations
154152
.any((element) => element.name.toLowerCase() == 'start-group')) {

lib/src/service/apexdoc_listener.dart

Lines changed: 3 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -17,11 +17,6 @@ class ApexdocListener extends ApexdocParserBaseListener {
1717
descriptionLines.add(_sanitizeLineStart(descriptionText));
1818
}
1919

20-
@override
21-
void enterDescriptionNewline(DescriptionNewlineContext ctx) {
22-
descriptionLines.add('');
23-
}
24-
2520
@override
2621
void exitDescriptionLine(DescriptionLineContext ctx) {
2722
generatedDocComment.descriptionLines = descriptionLines;
@@ -67,35 +62,11 @@ class ApexdocListener extends ApexdocParserBaseListener {
6762
}
6863

6964
List<String> _getContentLines(List<BlockTagContentContext> blockTagContents) {
70-
final contentLines = blockTagContents
71-
.map((e) => e.text)
65+
final rawContent = blockTagContents.map((e) => e.text).join('');
66+
return LineSplitter.split(rawContent)
7267
.map((e) => _sanitizeLineStart(e))
73-
.map((e) => LineSplitter.split(e)
74-
.map((e) => _sanitizeLineStart(e))
75-
.map((e) => e.trim())
76-
.join(''))
77-
.map((e) => e.trim())
68+
.where((element) => element.isNotEmpty)
7869
.toList();
79-
80-
// if there are 2 consecutive empty lines, remove one
81-
for (var i = 0; i < contentLines.length - 1; i++) {
82-
if (contentLines[i].isEmpty && contentLines[i + 1].isEmpty) {
83-
contentLines.removeAt(i);
84-
}
85-
}
86-
87-
// if the first line is empty, remove it
88-
if (contentLines.isNotEmpty && contentLines.first.isEmpty) {
89-
contentLines.removeAt(0);
90-
}
91-
92-
// if the last line is empty, remove it
93-
if (contentLines.isNotEmpty && contentLines.last.isEmpty) {
94-
contentLines.removeLast();
95-
}
96-
97-
print('about to return content lines $contentLines');
98-
return contentLines;
9970
}
10071

10172
String _sanitizeLineStart(String line) {

0 commit comments

Comments
 (0)