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

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

Issue 1428673004: Rework codegen tools to avoid relying on CWD; integrate with task model graph. (Closed) Base URL: git@github.com:dart-lang/sdk.git@master
Patch Set: Created 5 years, 2 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/tool/task_dependency_graph/check_test.dart ('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 a98eaba6495734266af8b618bc24487892b69cd3..3a7bb121f800252f740ff37084971c8c9b67c28c 100644
--- a/pkg/analyzer/tool/task_dependency_graph/generate.dart
+++ b/pkg/analyzer/tool/task_dependency_graph/generate.dart
@@ -23,6 +23,7 @@ import 'dart:io' as io;
import 'package:analyzer/analyzer.dart';
import 'package:analyzer/file_system/file_system.dart';
import 'package:analyzer/file_system/physical_file_system.dart';
+import 'package:analyzer/src/codegen/tools.dart';
import 'package:analyzer/src/generated/constant.dart';
import 'package:analyzer/src/generated/element.dart';
import 'package:analyzer/src/generated/engine.dart';
@@ -32,14 +33,21 @@ import 'package:analyzer/src/generated/sdk_io.dart';
import 'package:analyzer/src/generated/source.dart';
import 'package:analyzer/src/generated/source_io.dart';
import 'package:path/path.dart' as path;
+import 'package:path/path.dart';
/**
* Generate the target .dot file.
*/
main() {
- new Driver().generateFile();
+ String script = Platform.script.toFilePath(windows: Platform.isWindows);
+ String pkgPath = normalize(join(dirname(script), '..', '..'));
+ target.generate(pkgPath);
}
+final GeneratedFile target = new GeneratedFile(
+ 'tool/task_dependency_graph/tasks.dot',
+ (String pkgPath) => new Driver(pkgPath).generateFileContents());
+
typedef void GetterFinderCallback(PropertyAccessorElement element);
class Driver {
@@ -52,9 +60,7 @@ class Driver {
InterfaceType extensionPointIdType;
final String rootDir;
- Driver()
- : rootDir =
- findRoot(Platform.script.toFilePath(windows: Platform.isWindows));
+ Driver(String pkgPath) : rootDir = new Directory(pkgPath).absolute.path;
/**
* Get an [io.File] object corresponding to the file in which the generated
@@ -64,18 +70,6 @@ class Driver {
path.join(rootDir, 'tool', 'task_dependency_graph', 'tasks.dot'));
/**
- * Determine if the output [file] contains the expected contents.
- */
- bool checkFile() {
- String expectedContents = generateFileContents();
- String actualContents = file.readAsStringSync();
- // Normalize Windows line endings to Unix line endings so that the
- // comparison doesn't fail on Windows.
- actualContents = actualContents.replaceAll('\r\n', '\n');
- return expectedContents == actualContents;
- }
-
- /**
* Starting at [node], find all calls to registerExtension() which refer to
* the given [extensionIdVariable], and execute [callback] for the associated
* result descriptors.
@@ -123,14 +117,6 @@ class Driver {
}
/**
- * Generate the task dependency graph and write it to the output [file].
- */
- void generateFile() {
- String fileContents = generateFileContents();
- file.writeAsStringSync(fileContents);
- }
-
- /**
* Generate the task dependency graph and return it as a [String].
*/
String generateFileContents() {
@@ -268,21 +254,6 @@ ${lines.join('\n')}
throw new Exception(
'Could not find extension ID corresponding to $resultListGetterName');
}
-
- /**
- * Find the root directory of the analyzer package by proceeding
- * upward to the 'tool' dir, and then going up one more directory.
- */
- static String findRoot(String pathname) {
- while (path.basename(pathname) != 'tool') {
- String parent = path.dirname(pathname);
- if (parent.length >= pathname.length) {
- throw new Exception("Can't find root directory");
- }
- pathname = parent;
- }
- return path.dirname(pathname);
- }
}
/**
« no previous file with comments | « pkg/analyzer/tool/task_dependency_graph/check_test.dart ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698