Skip to content
This repository was archived by the owner on Feb 25, 2025. It is now read-only.

Commit 1fe5565

Browse files
bwilkersoncommit-bot@chromium.org
authored andcommitted
Generate end-of-line doc comments in server and plugin packages
Change-Id: I1d5517932e1c78744cfe43fc6a768a104e527091 Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/129520 Reviewed-by: Phil Quitslund <pquitslund@google.com> Commit-Queue: Brian Wilkerson <brianwilkerson@google.com>
1 parent 1f6a0c2 commit 1fe5565

17 files changed

+13891
-20508
lines changed

pkg/analysis_server/lib/protocol/protocol_generated.dart

Lines changed: 3499 additions & 5696 deletions
Large diffs are not rendered by default.

pkg/analysis_server/test/integration/support/integration_test_methods.dart

Lines changed: 1959 additions & 2160 deletions
Large diffs are not rendered by default.

pkg/analysis_server/test/integration/support/protocol_matchers.dart

Lines changed: 1676 additions & 2178 deletions
Large diffs are not rendered by default.

pkg/analysis_server/tool/spec/codegen_dart_notification_handler.dart

Lines changed: 31 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -20,16 +20,47 @@ GeneratedFile clientTarget() {
2020
});
2121
}
2222

23+
_capitalize(String name) =>
24+
'${name.substring(0, 1).toUpperCase()}${name.substring(1)}';
25+
26+
List<String> _generateDartDoc(Element html) => html.children
27+
.where((Element elem) => elem.localName == 'p')
28+
.map<String>((Element elem) => elem.text.trim())
29+
.toList();
30+
31+
String _generateNotificationMethodName(String domainName, String event) =>
32+
'on${_capitalize(domainName)}${_capitalize(event)}';
33+
34+
String _generateParamTypeName(String domainName, String event) =>
35+
'${_capitalize(domainName)}${_capitalize(event)}Params';
36+
2337
/**
2438
* Visitor which produces Dart code representing the API.
2539
*/
2640
class CodegenNotificationHandlerVisitor extends DartCodegenVisitor
2741
with CodeGenerator {
2842
CodegenNotificationHandlerVisitor(Api api) : super(api) {
2943
codeGeneratorSettings.commentLineLength = 79;
44+
codeGeneratorSettings.docCommentStartMarker = null;
45+
codeGeneratorSettings.docCommentLineLeader = '/// ';
46+
codeGeneratorSettings.docCommentEndMarker = null;
3047
codeGeneratorSettings.languageName = 'dart';
3148
}
3249

50+
void emitDartdoc(List<String> dartdoc) {
51+
bool first = true;
52+
for (String paragraph in dartdoc) {
53+
if (first) {
54+
first = false;
55+
} else {
56+
writeln(' ///');
57+
}
58+
for (String line in paragraph.split(RegExp('\r?\n'))) {
59+
writeln(' /// ${line.trim()}');
60+
}
61+
}
62+
}
63+
3364
void emitImports() {
3465
writeln("import 'package:analysis_server_client/protocol.dart';");
3566
}
@@ -78,20 +109,6 @@ mixin NotificationHandler {
78109
writeln('}');
79110
}
80111

81-
void emitDartdoc(List<String> dartdoc) {
82-
bool first = true;
83-
for (String paragraph in dartdoc) {
84-
if (first) {
85-
first = false;
86-
} else {
87-
writeln(' ///');
88-
}
89-
for (String line in paragraph.split(RegExp('\r?\n'))) {
90-
writeln(' /// ${line.trim()}');
91-
}
92-
}
93-
}
94-
95112
@override
96113
visitApi() {
97114
outputHeader(year: '2018');
@@ -127,17 +144,3 @@ class _NotificationVisitor extends HierarchicalApiVisitor {
127144
_generateDartDoc(notification.html)));
128145
}
129146
}
130-
131-
List<String> _generateDartDoc(Element html) => html.children
132-
.where((Element elem) => elem.localName == 'p')
133-
.map<String>((Element elem) => elem.text.trim())
134-
.toList();
135-
136-
String _generateNotificationMethodName(String domainName, String event) =>
137-
'on${_capitalize(domainName)}${_capitalize(event)}';
138-
139-
String _generateParamTypeName(String domainName, String event) =>
140-
'${_capitalize(domainName)}${_capitalize(event)}Params';
141-
142-
_capitalize(String name) =>
143-
'${name.substring(0, 1).toUpperCase()}${name.substring(1)}';

pkg/analysis_server/tool/spec/codegen_dart_protocol.dart

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -119,6 +119,9 @@ class CodegenProtocolVisitor extends DartCodegenVisitor with CodeGenerator {
119119
impliedTypes = computeImpliedTypes(api),
120120
super(api) {
121121
codeGeneratorSettings.commentLineLength = 79;
122+
codeGeneratorSettings.docCommentStartMarker = null;
123+
codeGeneratorSettings.docCommentLineLeader = '/// ';
124+
codeGeneratorSettings.docCommentEndMarker = null;
122125
codeGeneratorSettings.languageName = 'dart';
123126
}
124127

@@ -324,9 +327,7 @@ class CodegenProtocolVisitor extends DartCodegenVisitor with CodeGenerator {
324327
writeln();
325328
}
326329

327-
writeln('/**');
328-
writeln(' * A list containing all of the enum values that are defined.');
329-
writeln(' */');
330+
writeln('/// A list containing all of the enum values that are defined.');
330331
write('static const List<');
331332
write(className);
332333
write('> VALUES = <');

pkg/analysis_server/tool/spec/codegen_inttest_methods.dart

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -53,6 +53,9 @@ class CodegenInttestMethodsVisitor extends DartCodegenVisitor
5353
: toHtmlVisitor = ToHtmlVisitor(api),
5454
super(api) {
5555
codeGeneratorSettings.commentLineLength = 79;
56+
codeGeneratorSettings.docCommentStartMarker = null;
57+
codeGeneratorSettings.docCommentLineLeader = '/// ';
58+
codeGeneratorSettings.docCommentEndMarker = null;
5659
codeGeneratorSettings.languageName = 'dart';
5760
}
5861

@@ -99,9 +102,7 @@ class CodegenInttestMethodsVisitor extends DartCodegenVisitor
99102
visitApi() {
100103
outputHeader(year: '2017');
101104
writeln();
102-
writeln('/**');
103-
writeln(' * Convenience methods for running integration tests');
104-
writeln(' */');
105+
writeln('/// Convenience methods for running integration tests.');
105106
writeln("import 'dart:async';");
106107
writeln();
107108
writeln("import 'package:$packageName/protocol/protocol_generated.dart';");
@@ -117,9 +118,7 @@ class CodegenInttestMethodsVisitor extends DartCodegenVisitor
117118
writeln("';");
118119
}
119120
writeln();
120-
writeln('/**');
121-
writeln(' * Convenience methods for running integration tests');
122-
writeln(' */');
121+
writeln('/// Convenience methods for running integration tests.');
123122
writeln('abstract class IntegrationTestMixin {');
124123
indent(() {
125124
writeln('Server get server;');

pkg/analysis_server/tool/spec/codegen_matchers.dart

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,9 @@ class CodegenMatchersVisitor extends HierarchicalApiVisitor with CodeGenerator {
3636
: toHtmlVisitor = ToHtmlVisitor(api),
3737
super(api) {
3838
codeGeneratorSettings.commentLineLength = 79;
39+
codeGeneratorSettings.docCommentStartMarker = null;
40+
codeGeneratorSettings.docCommentLineLeader = '/// ';
41+
codeGeneratorSettings.docCommentEndMarker = null;
3942
codeGeneratorSettings.languageName = 'dart';
4043
}
4144

@@ -98,9 +101,7 @@ class CodegenMatchersVisitor extends HierarchicalApiVisitor with CodeGenerator {
98101
visitApi() {
99102
outputHeader(year: '2017');
100103
writeln();
101-
writeln('/**');
102-
writeln(' * Matchers for data types defined in the analysis server API');
103-
writeln(' */');
104+
writeln('/// Matchers for data types defined in the analysis server API.');
104105
writeln("import 'package:test/test.dart';");
105106
writeln();
106107
writeln("import 'integration_tests.dart';");

pkg/analysis_server/tool/spec/codegen_protocol_constants.dart

Lines changed: 28 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -32,12 +32,40 @@ String generateConstName(String domainName, String kind, String name) {
3232
return _fromComponents(components);
3333
}
3434

35+
/**
36+
* Return a name generated by converting each of the given [components] to an
37+
* uppercase equivalent, then joining them with underscores.
38+
*/
39+
String _fromComponents(List<String> components) =>
40+
components.map((String component) => component.toUpperCase()).join('_');
41+
42+
/**
43+
* Return the components of the given [string] that are indicated by an upper
44+
* case letter.
45+
*/
46+
Iterable<String> _split(String first) {
47+
RegExp regExp = RegExp('[A-Z]');
48+
List<String> components = <String>[];
49+
int start = 1;
50+
int index = first.indexOf(regExp, start);
51+
while (index >= 0) {
52+
components.add(first.substring(start - 1, index));
53+
start = index + 1;
54+
index = first.indexOf(regExp, start);
55+
}
56+
components.add(first.substring(start - 1));
57+
return components;
58+
}
59+
3560
/**
3661
* A visitor that produces Dart code defining constants associated with the API.
3762
*/
3863
class CodegenVisitor extends DartCodegenVisitor with CodeGenerator {
3964
CodegenVisitor(Api api) : super(api) {
4065
codeGeneratorSettings.commentLineLength = 79;
66+
codeGeneratorSettings.docCommentStartMarker = null;
67+
codeGeneratorSettings.docCommentLineLeader = '/// ';
68+
codeGeneratorSettings.docCommentEndMarker = null;
4169
codeGeneratorSettings.languageName = 'dart';
4270
}
4371

@@ -153,28 +181,3 @@ class _ConstantVisitor extends HierarchicalApiVisitor {
153181
});
154182
}
155183
}
156-
157-
/**
158-
* Return a name generated by converting each of the given [components] to an
159-
* uppercase equivalent, then joining them with underscores.
160-
*/
161-
String _fromComponents(List<String> components) =>
162-
components.map((String component) => component.toUpperCase()).join('_');
163-
164-
/**
165-
* Return the components of the given [string] that are indicated by an upper
166-
* case letter.
167-
*/
168-
Iterable<String> _split(String first) {
169-
RegExp regExp = RegExp('[A-Z]');
170-
List<String> components = <String>[];
171-
int start = 1;
172-
int index = first.indexOf(regExp, start);
173-
while (index >= 0) {
174-
components.add(first.substring(start - 1, index));
175-
start = index + 1;
176-
index = first.indexOf(regExp, start);
177-
}
178-
components.add(first.substring(start - 1));
179-
return components;
180-
}

0 commit comments

Comments
 (0)