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

Unified Diff: pkg/analyzer/tool/task_dependency_graph/generate.dart

Issue 1817913002: Generate the task model graph as an HTML file and put it in the doc directory. (Closed) Base URL: https://github.com/dart-lang/sdk.git@master
Patch Set: Copy support files into local directory Created 4 years, 8 months 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « pkg/analyzer/doc/tasks.html ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: pkg/analyzer/tool/task_dependency_graph/generate.dart
diff --git a/pkg/analyzer/tool/task_dependency_graph/generate.dart b/pkg/analyzer/tool/task_dependency_graph/generate.dart
index 766ca03a8c6d341c26903bd126364d7568b69f3d..2b904bb7e308b5007ccccb61f1cb7a8155f86d17 100644
--- a/pkg/analyzer/tool/task_dependency_graph/generate.dart
+++ b/pkg/analyzer/tool/task_dependency_graph/generate.dart
@@ -42,9 +42,12 @@ import 'package:path/path.dart';
main() {
String script = Platform.script.toFilePath(windows: Platform.isWindows);
String pkgPath = normalize(join(dirname(script), '..', '..'));
- GeneratedContent.generateAll(pkgPath, <GeneratedContent>[target]);
+ GeneratedContent.generateAll(pkgPath, <GeneratedContent>[target, htmlTarget]);
}
+final GeneratedFile htmlTarget = new GeneratedFile(
+ 'doc/tasks.html', (String pkgPath) => new Driver(pkgPath).generateHtml());
+
final GeneratedFile target = new GeneratedFile(
'tool/task_dependency_graph/tasks.dot',
(String pkgPath) => new Driver(pkgPath).generateFileContents());
@@ -52,6 +55,7 @@ final GeneratedFile target = new GeneratedFile(
typedef void GetterFinderCallback(PropertyAccessorElement element);
class Driver {
+ static bool hasInitializedPlugins = false;
PhysicalResourceProvider resourceProvider;
AnalysisContext context;
InterfaceType resultDescriptorType;
@@ -59,6 +63,7 @@ class Driver {
ClassElement enginePluginClass;
CompilationUnitElement taskUnitElement;
InterfaceType extensionPointIdType;
+
final String rootDir;
Driver(String pkgPath) : rootDir = new Directory(pkgPath).absolute.path;
@@ -121,7 +126,28 @@ class Driver {
* Generate the task dependency graph and return it as a [String].
*/
String generateFileContents() {
- AnalysisEngine.instance.processRequiredPlugins();
+ return '''
+// Copyright (c) 2015, the Dart project authors. Please see the AUTHORS file
+// for details. All rights reserved. Use of this source code is governed by a
+// BSD-style license that can be found in the LICENSE file.
+//
+// This file has been automatically generated. Please do not edit it manually.
+// To regenerate the file, use the script
+// "pkg/analyzer/tool/task_dependency_graph/generate.dart".
+//
+// To render this graph using Graphviz (www.graphviz.org) use the command:
+// "dot tasks.dot -Tpdf -O".
+digraph G {
+${generateGraphData()}
+}
+''';
+ }
+
+ String generateGraphData() {
+ if (!hasInitializedPlugins) {
+ AnalysisEngine.instance.processRequiredPlugins();
+ hasInitializedPlugins = true;
+ }
List<String> lines = <String>[];
resourceProvider = PhysicalResourceProvider.INSTANCE;
DartSdk sdk = DirectoryBasedDartSdk.defaultSdk;
@@ -197,20 +223,32 @@ class Driver {
lines.add(' $result [shape=box]');
}
lines.sort();
+ return lines.join('\n');
+ }
+
+ String generateHtml() {
return '''
-// Copyright (c) 2015, the Dart project authors. Please see the AUTHORS file
-// for details. All rights reserved. Use of this source code is governed by a
-// BSD-style license that can be found in the LICENSE file.
-//
-// This file has been automatically generated. Please do not edit it manually.
-// To regenerate the file, use the script
-// "pkg/analyzer/tool/task_dependency_graph/generate.dart".
-//
-// To render this graph using Graphviz (www.graphviz.org) use the command:
-// "dot tasks.dot -Tpdf -O".
+<!DOCTYPE html>
+<html>
+<head>
+ <title>Analysis Task Dependency Graph</title>
+ <link rel="stylesheet" href="support/style.css">
+ <script src="support/viz.js"></script>
+ <script type="application/dart" src="support/web_app.dart.js"></script>
+ <script src="support/dart.js"></script>
+</head>
+<body>
+<button id="zoomBtn">Zoom</button>
+<script type="text/vnd.graphviz" id="dot">
digraph G {
-${lines.join('\n')}
+ tooltip="Analysis Task Dependency Graph";
+ node [fontname=Helvetica];
+ edge [fontname=Helvetica, fontcolor=gray];
+${generateGraphData()}
}
+</script>
+</body>
+</html>
''';
}
« no previous file with comments | « pkg/analyzer/doc/tasks.html ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698