Skip to content

Commit ee708e3

Browse files
authored
Merge pull request #2777 from jcollins-g/nnbd-mastermerge-0907
Merge head to NNBD branch
2 parents ae72b68 + f51895d commit ee708e3

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

44 files changed

+4987
-4876
lines changed

CHANGELOG.md

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,14 @@
1+
## 3.0.0
2+
* BREAKING CHANGE: Refactor of Class, Enum, and Mixin types result in some
3+
deleted interfaces in templates and a change in class hierarchy. (#2770)
4+
* The experimental 'constructor-tearoffs' feature has been partially
5+
implemented in dartdoc and should work in simple cases. (#2655, #2770,
6+
#2768, #2766, #2763).
7+
* BREAKING CHANGE: The old lookup code has been deleted, along with the
8+
`--no-enhanced-reference-lookup` flag. (#2765)
9+
* Deprecated uses of pub have been removed. (#2764)
10+
* Some internal refactors to support NNBD migration.
11+
112
## 2.0.0
213
* BREAKING CHANGE: changes to dartdoc options API
314
to prepare for NNBD migration (#2745, #2744).

dartdoc_options.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
11
dartdoc:
22
linkToSource:
33
root: '.'
4-
uriTemplate: 'https://github.com/dart-lang/dartdoc/blob/v2.0.0/%f%#L%l%'
4+
uriTemplate: 'https://github.com/dart-lang/dartdoc/blob/v3.0.0/%f%#L%l%'

lib/src/comment_references/parser.dart

Lines changed: 75 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -96,7 +96,7 @@ class CommentReferenceParser {
9696
/// ```text
9797
/// <rawCommentReference> ::= <prefix>?<commentReference><suffix>?
9898
///
99-
/// <commentReference> ::= (<packageName> '.')? (<libraryName> '.')? <dartdocIdentifier> ('.' <identifier>)*
99+
/// <commentReference> ::= (<packageName> '.')? (<libraryName> '.')? <dartdocIdentifier> <typeArguments> ('.' <identifier> <typeArguments>)*
100100
/// ```
101101
List<CommentReferenceNode> _parseRawCommentReference() {
102102
var children = <CommentReferenceNode>[];
@@ -124,6 +124,17 @@ class CommentReferenceParser {
124124
} else if (identifierResult.type ==
125125
_IdentifierResultType.parsedIdentifier) {
126126
children.add(identifierResult.node);
127+
var typeVariablesResult = _parseTypeVariables();
128+
if (typeVariablesResult.type == _TypeVariablesResultType.endOfFile) {
129+
break;
130+
} else if (typeVariablesResult.type ==
131+
_TypeVariablesResultType.notTypeVariables) {
132+
// Do nothing, _index has not moved.
133+
;
134+
} else if (typeVariablesResult.type ==
135+
_TypeVariablesResultType.parsedTypeVariables) {
136+
children.add(typeVariablesResult.node);
137+
}
127138
}
128139
if (_atEnd || _thisChar != $dot) {
129140
break;
@@ -239,6 +250,22 @@ class CommentReferenceParser {
239250
IdentifierNode(codeRef.substring(startIndex, _index)));
240251
}
241252

253+
/// Parse a list of type variables (arguments or parameters).
254+
///
255+
/// Dartdoc isolates these where present and potentially valid, but we don't
256+
/// break them down.
257+
_TypeVariablesParseResult _parseTypeVariables() {
258+
if (_atEnd) {
259+
return _TypeVariablesParseResult.endOfFile;
260+
}
261+
var startIndex = _index;
262+
if (_matchBraces($lt, $gt)) {
263+
return _TypeVariablesParseResult.ok(
264+
TypeVariablesNode(codeRef.substring(startIndex + 1, _index - 1)));
265+
}
266+
return _TypeVariablesParseResult.notIdentifier;
267+
}
268+
242269
static const _callableHintSuffix = '()';
243270

244271
/// ```text
@@ -270,7 +297,7 @@ class CommentReferenceParser {
270297
if ((_thisChar == $exclamation || _thisChar == $question) && _nextAtEnd) {
271298
return _SuffixParseResult.junk;
272299
}
273-
if (_matchBraces($lparen, $rparen) || _matchBraces($lt, $gt)) {
300+
if (_matchBraces($lparen, $rparen)) {
274301
return _SuffixParseResult.junk;
275302
}
276303

@@ -334,8 +361,10 @@ class CommentReferenceParser {
334361
while (!_atEnd) {
335362
if (_thisChar == startChar) braceCount++;
336363
if (_thisChar == endChar) braceCount--;
337-
++_index;
338-
if (braceCount == 0) return true;
364+
_index++;
365+
if (braceCount == 0) {
366+
return true;
367+
}
339368
}
340369
_index = startIndex;
341370
return false;
@@ -395,6 +424,32 @@ class _IdentifierParseResult {
395424
_IdentifierParseResult._(_IdentifierResultType.notIdentifier, null);
396425
}
397426

427+
enum _TypeVariablesResultType {
428+
endOfFile, // Found end of file instead of the beginning of a list of type
429+
// variables.
430+
notTypeVariables, // Found something, but it isn't type variables.
431+
parsedTypeVariables, // Found type variables.
432+
}
433+
434+
class _TypeVariablesParseResult {
435+
final _TypeVariablesResultType type;
436+
437+
final TypeVariablesNode node;
438+
439+
const _TypeVariablesParseResult._(this.type, this.node);
440+
441+
factory _TypeVariablesParseResult.ok(TypeVariablesNode node) =>
442+
_TypeVariablesParseResult._(
443+
_TypeVariablesResultType.parsedTypeVariables, node);
444+
445+
static const _TypeVariablesParseResult endOfFile =
446+
_TypeVariablesParseResult._(_TypeVariablesResultType.endOfFile, null);
447+
448+
static const _TypeVariablesParseResult notIdentifier =
449+
_TypeVariablesParseResult._(
450+
_TypeVariablesResultType.notTypeVariables, null);
451+
}
452+
398453
enum _SuffixResultType {
399454
junk, // Found known types of junk it is OK to ignore.
400455
missing, // There is no suffix here. Same as EOF as this is a suffix.
@@ -459,3 +514,19 @@ class IdentifierNode extends CommentReferenceNode {
459514
@override
460515
String toString() => 'Identifier["$text"]';
461516
}
517+
518+
/// Represents one or more type variables, may be
519+
/// comma separated.
520+
class TypeVariablesNode extends CommentReferenceNode {
521+
@override
522+
523+
/// Note that this will contain commas, spaces, and other text, as
524+
/// generally type variables are a form of junk that comment references
525+
/// should ignore.
526+
final String text;
527+
528+
TypeVariablesNode(this.text);
529+
530+
@override
531+
String toString() => 'TypeVariablesNode["$text"]';
532+
}

lib/src/generator/generator_frontend.dart

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -170,14 +170,6 @@ class GeneratorFrontEnd implements Generator {
170170
indexAccumulator.add(mixin);
171171
_generatorBackend.generateMixin(writer, packageGraph, lib, mixin);
172172

173-
for (var constructor in filterNonDocumented(mixin.constructors)) {
174-
if (!constructor.isCanonical) continue;
175-
176-
indexAccumulator.add(constructor);
177-
_generatorBackend.generateConstructor(
178-
writer, packageGraph, lib, mixin, constructor);
179-
}
180-
181173
for (var constant in filterNonDocumented(mixin.constantFields)) {
182174
if (!constant.isCanonical) continue;
183175
indexAccumulator.add(constant);

lib/src/generator/template_data.dart

Lines changed: 25 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -175,34 +175,51 @@ class LibraryTemplateData extends TemplateData<Library>
175175
}
176176

177177
/// Template data for Dart 2.1-style mixin declarations.
178-
class MixinTemplateData extends ClassTemplateData<Mixin> {
179-
final Mixin mixin;
180-
178+
class MixinTemplateData extends InheritingContainerTemplateData<Mixin> {
181179
MixinTemplateData(
182180
TemplateOptions htmlOptions,
183181
PackageGraph packageGraph,
184182
Library library,
185-
this.mixin,
183+
Mixin mixin,
186184
LibrarySidebar _sidebarForLibrary,
187185
ContainerSidebar _sidebarForContainer)
188186
: super(htmlOptions, packageGraph, library, mixin, _sidebarForLibrary,
189187
_sidebarForContainer);
190188

189+
Mixin get mixin => clazz;
190+
191191
@override
192192
Mixin get self => mixin;
193193
}
194194

195+
/// Template data for Dart classes.
196+
class ClassTemplateData extends InheritingContainerTemplateData<Class> {
197+
ClassTemplateData(
198+
TemplateOptions htmlOptions,
199+
PackageGraph packageGraph,
200+
Library library,
201+
Class clazz,
202+
LibrarySidebar _sidebarForLibrary,
203+
ContainerSidebar _sidebarForContainer)
204+
: super(htmlOptions, packageGraph, library, clazz, _sidebarForLibrary,
205+
_sidebarForContainer);
206+
207+
@override
208+
Class get clazz => super.clazz;
209+
}
210+
195211
/// Base template data class for [Class], [Enum], and [Mixin].
196-
class ClassTemplateData<T extends Class> extends TemplateData<T>
212+
abstract class InheritingContainerTemplateData<T extends InheritingContainer>
213+
extends TemplateData<T>
197214
implements TemplateDataWithLibrary<T>, TemplateDataWithContainer<T> {
198-
final Class clazz;
215+
final InheritingContainer clazz;
199216
@override
200217
final Library library;
201218
Class _objectType;
202219
final LibrarySidebar _sidebarForLibrary;
203220
final ContainerSidebar _sidebarForContainer;
204221

205-
ClassTemplateData(
222+
InheritingContainerTemplateData(
206223
TemplateOptions htmlOptions,
207224
PackageGraph packageGraph,
208225
this.library,
@@ -337,7 +354,7 @@ class ConstructorTemplateData extends TemplateData<Constructor>
337354
'for the Dart programming language.';
338355
}
339356

340-
class EnumTemplateData extends ClassTemplateData<Enum> {
357+
class EnumTemplateData extends InheritingContainerTemplateData<Enum> {
341358
EnumTemplateData(
342359
TemplateOptions htmlOptions,
343360
PackageGraph packageGraph,

0 commit comments

Comments
 (0)