@@ -15,7 +15,6 @@ import 'package:analyzer/dart/ast/ast.dart'
1515 AnnotatedNode,
1616 AstNode,
1717 CommentReference,
18- Declaration,
1918 Expression,
2019 InstanceCreationExpression;
2120import 'package:analyzer/dart/element/element.dart' ;
@@ -3038,6 +3037,7 @@ abstract class ModelElement extends Canonicalization
30383037 }
30393038
30403039 AstNode _astNode;
3040+ @override
30413041 AstNode get astNode {
30423042 _astNode ?? = element? .computeNode ();
30433043 return _astNode;
@@ -3994,33 +3994,34 @@ abstract class ModelElement extends Canonicalization
39943994 });
39953995 int invocationIndex = 0 ;
39963996 return await _replaceAllMappedAsync (rawDocs, basicToolRegExp,
3997- (basicMatch) async {
3998- List <String > args = _splitUpQuotedArgs (basicMatch[1 ]).toList ();
3999- // Tool name must come first.
4000- if (args.isEmpty) {
4001- warn (PackageWarning .toolError,
4002- message: 'Must specify a tool to execute for the @tool directive.' );
4003- return Future .value ('' );
4004- }
4005- // Count the number of invocations of tools in this dartdoc block,
4006- // so that tools can differentiate different blocks from each other.
4007- invocationIndex++ ;
4008- return await runner.run (args,
4009- content: basicMatch[2 ],
4010- environment: {
4011- 'SOURCE_LINE' : lineAndColumn? .item1? .toString (),
4012- 'SOURCE_COLUMN' : lineAndColumn? .item2? .toString (),
4013- 'SOURCE_PATH' : (sourceFileName == null ||
3997+ (basicMatch) async {
3998+ List <String > args = _splitUpQuotedArgs (basicMatch[1 ]).toList ();
3999+ // Tool name must come first.
4000+ if (args.isEmpty) {
4001+ warn (PackageWarning .toolError,
4002+ message:
4003+ 'Must specify a tool to execute for the @tool directive.' );
4004+ return Future .value ('' );
4005+ }
4006+ // Count the number of invocations of tools in this dartdoc block,
4007+ // so that tools can differentiate different blocks from each other.
4008+ invocationIndex++ ;
4009+ return await runner.run (args,
4010+ content: basicMatch[2 ],
4011+ environment: {
4012+ 'SOURCE_LINE' : lineAndColumn? .item1? .toString (),
4013+ 'SOURCE_COLUMN' : lineAndColumn? .item2? .toString (),
4014+ 'SOURCE_PATH' : (sourceFileName == null ||
40144015 package? .packagePath == null )
4015- ? null
4016- : pathLib.relative (sourceFileName, from: package.packagePath),
4017- 'PACKAGE_PATH' : package? .packagePath,
4018- 'PACKAGE_NAME' : package? .name,
4019- 'LIBRARY_NAME' : library? .fullyQualifiedName,
4020- 'ELEMENT_NAME' : fullyQualifiedNameWithoutLibrary,
4021- 'INVOCATION_INDEX' : invocationIndex.toString (),
4022- }..removeWhere ((key, value) => value == null ));
4023- }).whenComplete (runner.dispose);
4016+ ? null
4017+ : pathLib.relative (sourceFileName, from: package.packagePath),
4018+ 'PACKAGE_PATH' : package? .packagePath,
4019+ 'PACKAGE_NAME' : package? .name,
4020+ 'LIBRARY_NAME' : library? .fullyQualifiedName,
4021+ 'ELEMENT_NAME' : fullyQualifiedNameWithoutLibrary,
4022+ 'INVOCATION_INDEX' : invocationIndex.toString (),
4023+ }..removeWhere ((key, value) => value == null ));
4024+ }).whenComplete (runner.dispose);
40244025 } else {
40254026 return rawDocs;
40264027 }
@@ -4730,27 +4731,6 @@ class PackageGraph {
47304731 /// Dartdoc's configuration flags.
47314732 final DartdocOptionContext config;
47324733
4733- Map <String , Map <String , dynamic >> __crossdartJson;
4734- // TODO(jcollins-g): move to [Package]
4735- Map <String , Map <String , dynamic >> get crossdartJson {
4736- if (__crossdartJson == null ) {
4737- // TODO(jcollins-g): allow crossdart.json location to be configurable
4738- var crossdartFile =
4739- new File (pathLib.join (config.inputDir, 'crossdart.json' ));
4740- if (crossdartFile.existsSync ()) {
4741- Map <String , dynamic > __crossdartJsonTmp =
4742- json.decode (crossdartFile.readAsStringSync ());
4743- __crossdartJson = {};
4744- for (String key in __crossdartJsonTmp.keys) {
4745- __crossdartJson[pathLib.canonicalize (key)] = __crossdartJsonTmp[key];
4746- }
4747- } else {
4748- __crossdartJson = {};
4749- }
4750- }
4751- return __crossdartJson;
4752- }
4753-
47544734 Package _defaultPackage;
47554735 Package get defaultPackage {
47564736 if (_defaultPackage == null ) {
@@ -6107,13 +6087,7 @@ class Parameter extends ModelElement implements EnclosedElement {
61076087}
61086088
61096089abstract class SourceCodeMixin implements Documentable {
6110- String get crossdartHtmlTag {
6111- if (config.addCrossdart && _crossdartUrl != null ) {
6112- return "<a class='crossdart' href='${_crossdartUrl }'>Link to Crossdart</a>" ;
6113- } else {
6114- return "" ;
6115- }
6116- }
6090+ AstNode get astNode;
61176091
61186092 Tuple2 <int , int > get lineAndColumn;
61196093
@@ -6141,12 +6115,7 @@ abstract class SourceCodeMixin implements Documentable {
61416115 var start = node.offset - (node.offset - i);
61426116 String source = contents.substring (start, node.end);
61436117
6144- if (config.addCrossdart) {
6145- source = crossdartifySource (config.inputDir, packageGraph.crossdartJson,
6146- source, element, start);
6147- } else {
6148- source = const HtmlEscape ().convert (source);
6149- }
6118+ source = const HtmlEscape ().convert (source);
61506119 source = stripIndentFromSource (source);
61516120 source = stripDartdocCommentsFromSource (source);
61526121
@@ -6163,54 +6132,6 @@ abstract class SourceCodeMixin implements Documentable {
61636132 }
61646133 return _sourceCode;
61656134 }
6166-
6167- String get _crossdartPath {
6168- var node = element.computeNode ();
6169- if (node is Declaration && node.declaredElement != null ) {
6170- var source = node.declaredElement.source;
6171- var filePath = source.fullName;
6172- var uri = source.uri.toString ();
6173- var packageMeta = library.packageGraph.packageMeta;
6174- if (uri.startsWith ('package:' )) {
6175- var splittedUri =
6176- uri.replaceAll (new RegExp (r'^package:' ), '' ).split ('/' );
6177- var packageName = splittedUri.first;
6178- var packageVersion;
6179- if (packageName == packageMeta.name) {
6180- packageVersion = packageMeta.version;
6181- } else {
6182- var match = new RegExp (
6183- '.pub-cache/(hosted/pub.dartlang.org|git)/${packageName }-([^/]+)' )
6184- .firstMatch (filePath);
6185- if (match != null ) {
6186- packageVersion = match[2 ];
6187- }
6188- }
6189- if (packageVersion != null ) {
6190- return '${packageName }/${packageVersion }/${splittedUri .skip (1 ).join ("/" )}' ;
6191- } else {
6192- return null ;
6193- }
6194- } else if (uri.startsWith ('dart:' )) {
6195- var packageName = 'sdk' ;
6196- var packageVersion = packageGraph.sdk.sdkVersion;
6197- return '${packageName }/${packageVersion }/lib/${uri .replaceAll (new RegExp (r"^dart:" ), "" )}' ;
6198- } else {
6199- return null ;
6200- }
6201- } else {
6202- return null ;
6203- }
6204- }
6205-
6206- String get _crossdartUrl {
6207- if (lineAndColumn != null && _crossdartPath != null ) {
6208- String url = '//www.crossdart.info/p/${_crossdartPath }.html' ;
6209- return '${url }#line-${lineAndColumn .item1 }' ;
6210- } else {
6211- return null ;
6212- }
6213- }
62146135}
62156136
62166137abstract class TypeParameters implements ModelElement {
0 commit comments