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

Side by Side Diff: pkg/analyzer/tool/task_dependency_graph.dart

Issue 1287003006: Fix task dependency graph computation. (Closed) Base URL: git@github.com:dart-lang/sdk.git@master
Patch Set: Created 5 years, 4 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 unified diff | Download patch
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2015, the Dart project authors. Please see the AUTHORS file 1 // Copyright (c) 2015, the Dart project authors. Please see the AUTHORS file
2 // for details. All rights reserved. Use of this source code is governed by a 2 // for details. All rights reserved. Use of this source code is governed by a
3 // BSD-style license that can be found in the LICENSE file. 3 // BSD-style license that can be found in the LICENSE file.
4 4
5 /** 5 /**
6 * This file contains code to output a description of tasks and their 6 * This file contains code to output a description of tasks and their
7 * dependencies in ".dot" format. Prior to running, the user should run "pub 7 * dependencies in ".dot" format. Prior to running, the user should run "pub
8 * get" in the analyzer directory to ensure that a "packages" folder exists. 8 * get" in the analyzer directory to ensure that a "packages" folder exists.
9 * 9 *
10 * The ".dot" file is output to standard out. To convert it to a pdf, store it 10 * The ".dot" file is output to standard out. To convert it to a pdf, store it
(...skipping 65 matching lines...) Expand 10 before | Expand all | Expand 10 after
76 CompilationUnit getUnit(Source source) => 76 CompilationUnit getUnit(Source source) =>
77 context.resolveCompilationUnit2(source, source); 77 context.resolveCompilationUnit2(source, source);
78 78
79 void run() { 79 void run() {
80 rootDir = findRoot(Platform.script.toFilePath(windows: Platform.isWindows)); 80 rootDir = findRoot(Platform.script.toFilePath(windows: Platform.isWindows));
81 resourceProvider = PhysicalResourceProvider.INSTANCE; 81 resourceProvider = PhysicalResourceProvider.INSTANCE;
82 DartSdk sdk = DirectoryBasedDartSdk.defaultSdk; 82 DartSdk sdk = DirectoryBasedDartSdk.defaultSdk;
83 context = AnalysisEngine.instance.createAnalysisContext(); 83 context = AnalysisEngine.instance.createAnalysisContext();
84 JavaFile packagesDir = new JavaFile(path.join(rootDir, 'packages')); 84 JavaFile packagesDir = new JavaFile(path.join(rootDir, 'packages'));
85 List<UriResolver> uriResolvers = [ 85 List<UriResolver> uriResolvers = [
86 new FileUriResolver(),
87 new DartUriResolver(sdk), 86 new DartUriResolver(sdk),
88 new PackageUriResolver(<JavaFile>[packagesDir]) 87 new PackageUriResolver(<JavaFile>[packagesDir]),
88 new FileUriResolver()
89 ]; 89 ];
90 context.sourceFactory = new SourceFactory(uriResolvers); 90 context.sourceFactory = new SourceFactory(uriResolvers);
91 Source taskSource = 91 Source taskSource =
92 setupSource(path.join('lib', 'src', 'task', 'dart.dart')); 92 setupSource(path.join('lib', 'src', 'task', 'dart.dart'));
93 Source modelSource = setupSource(path.join('lib', 'task', 'model.dart')); 93 Source modelSource = setupSource(path.join('lib', 'task', 'model.dart'));
94 CompilationUnitElement modelElement = getUnit(modelSource).element; 94 CompilationUnitElement modelElement = getUnit(modelSource).element;
95 InterfaceType analysisTaskType = modelElement.getType('AnalysisTask').type; 95 InterfaceType analysisTaskType = modelElement.getType('AnalysisTask').type;
96 DartType dynamicType = context.typeProvider.dynamicType; 96 DartType dynamicType = context.typeProvider.dynamicType;
97 resultDescriptorType = modelElement.getType('ResultDescriptor').type 97 resultDescriptorType = modelElement.getType('ResultDescriptor').type
98 .substitute4([dynamicType]); 98 .substitute4([dynamicType]);
(...skipping 20 matching lines...) Expand all
119 for (String result in results) { 119 for (String result in results) {
120 print(' $result [shape=box]'); 120 print(' $result [shape=box]');
121 } 121 }
122 print('}'); 122 print('}');
123 } 123 }
124 124
125 Source setupSource(String filename) { 125 Source setupSource(String filename) {
126 String filePath = path.join(rootDir, filename); 126 String filePath = path.join(rootDir, filename);
127 File file = resourceProvider.getResource(filePath); 127 File file = resourceProvider.getResource(filePath);
128 Source source = file.createSource(); 128 Source source = file.createSource();
129 Uri restoredUri = context.sourceFactory.restoreUri(source);
130 if (restoredUri != null) {
131 source = file.createSource(restoredUri);
132 }
129 ChangeSet changeSet = new ChangeSet(); 133 ChangeSet changeSet = new ChangeSet();
130 changeSet.addedSource(source); 134 changeSet.addedSource(source);
131 context.applyChanges(changeSet); 135 context.applyChanges(changeSet);
132 return source; 136 return source;
133 } 137 }
134 } 138 }
135 139
136 class ResultDescriptorFinder extends GeneralizingAstVisitor { 140 class ResultDescriptorFinder extends GeneralizingAstVisitor {
137 final InterfaceType resultDescriptorType; 141 final InterfaceType resultDescriptorType;
138 final ResultDescriptorFinderCallback callback; 142 final ResultDescriptorFinderCallback callback;
139 143
140 ResultDescriptorFinder(this.resultDescriptorType, this.callback); 144 ResultDescriptorFinder(this.resultDescriptorType, this.callback);
141 145
142 @override 146 @override
143 visitIdentifier(Identifier node) { 147 visitIdentifier(Identifier node) {
144 Element element = node.staticElement; 148 Element element = node.staticElement;
145 if (element is PropertyAccessorElement && 149 if (element is PropertyAccessorElement &&
146 element.isGetter && 150 element.isGetter &&
147 element.returnType.isSubtypeOf(resultDescriptorType)) { 151 element.returnType.isSubtypeOf(resultDescriptorType)) {
148 callback(element); 152 callback(element);
149 } 153 }
150 } 154 }
151 } 155 }
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698