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

Side by Side Diff: tests/compiler/dart2js/analyze_helper.dart

Issue 1235563003: Add interfaces for a new compiler API. (Closed) Base URL: https://github.com/dart-lang/sdk.git@master
Patch Set: Rebased Created 5 years, 5 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 | « pkg/docgen/lib/src/generator.dart ('k') | tests/compiler/dart2js/bad_loop_test.dart » ('j') | 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) 2013, the Dart project authors. Please see the AUTHORS file 1 // Copyright (c) 2013, 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 library analyze_helper; 5 library analyze_helper;
6 6
7 import 'dart:async'; 7 import 'dart:async';
8 import 'dart:io'; 8 import 'dart:io';
9 import 'package:compiler/compiler.dart' as api; 9 import 'package:compiler/compiler.dart' as api;
10 import 'package:compiler/src/apiimpl.dart'; 10 import 'package:compiler/src/apiimpl.dart';
(...skipping 77 matching lines...) Expand 10 before | Expand all | Expand 10 after
88 if (message.contains(messagePart)) { 88 if (message.contains(messagePart)) {
89 whiteListMap[file][messagePart]++; 89 whiteListMap[file][messagePart]++;
90 return true; 90 return true;
91 } 91 }
92 } 92 }
93 } 93 }
94 } 94 }
95 return false; 95 return false;
96 } 96 }
97 97
98 void diagnosticHandler(Uri uri, int begin, int end, String message, 98 @override
99 api.Diagnostic kind) { 99 void report(Uri uri, int begin, int end, String message,
100 api.Diagnostic kind) {
100 if (kind == api.Diagnostic.WARNING) { 101 if (kind == api.Diagnostic.WARNING) {
101 if (checkWhiteList(uri, message)) { 102 if (checkWhiteList(uri, message)) {
102 // Suppress whitelisted warnings. 103 // Suppress whitelisted warnings.
103 lastWasWhitelisted = true; 104 lastWasWhitelisted = true;
104 return; 105 return;
105 } 106 }
106 hasWarnings = true; 107 hasWarnings = true;
107 } 108 }
108 if (kind == api.Diagnostic.HINT) { 109 if (kind == api.Diagnostic.HINT) {
109 if (checkWhiteList(uri, message)) { 110 if (checkWhiteList(uri, message)) {
110 // Suppress whitelisted hints. 111 // Suppress whitelisted hints.
111 lastWasWhitelisted = true; 112 lastWasWhitelisted = true;
112 return; 113 return;
113 } 114 }
114 hasHint = true; 115 hasHint = true;
115 } 116 }
116 if (kind == api.Diagnostic.ERROR) { 117 if (kind == api.Diagnostic.ERROR) {
117 if (checkWhiteList(uri, message)) { 118 if (checkWhiteList(uri, message)) {
118 // Suppress whitelisted errors. 119 // Suppress whitelisted errors.
119 lastWasWhitelisted = true; 120 lastWasWhitelisted = true;
120 return; 121 return;
121 } 122 }
122 hasErrors = true; 123 hasErrors = true;
123 } 124 }
124 if (kind == api.Diagnostic.INFO && lastWasWhitelisted) { 125 if (kind == api.Diagnostic.INFO && lastWasWhitelisted) {
125 return; 126 return;
126 } 127 }
127 lastWasWhitelisted = false; 128 lastWasWhitelisted = false;
128 super.diagnosticHandler(uri, begin, end, message, kind); 129 super.report(uri, begin, end, message, kind);
129 } 130 }
130 } 131 }
131 132
132 typedef bool CheckResults(Compiler compiler, 133 typedef bool CheckResults(Compiler compiler,
133 CollectingDiagnosticHandler handler); 134 CollectingDiagnosticHandler handler);
134 135
135 Future analyze(List<Uri> uriList, 136 Future analyze(List<Uri> uriList,
136 Map<String, List<String>> whiteList, 137 Map<String, List<String>> whiteList,
137 {bool analyzeAll: true, 138 {bool analyzeAll: true,
138 CheckResults checkResults}) { 139 CheckResults checkResults}) {
(...skipping 12 matching lines...) Expand all
151 152
152 var libraryRoot = currentDirectory.resolve('sdk/'); 153 var libraryRoot = currentDirectory.resolve('sdk/');
153 var packageRoot = 154 var packageRoot =
154 currentDirectory.resolveUri(new Uri.file('${Platform.packageRoot}/')); 155 currentDirectory.resolveUri(new Uri.file('${Platform.packageRoot}/'));
155 var provider = new CompilerSourceFileProvider(); 156 var provider = new CompilerSourceFileProvider();
156 var handler = new CollectingDiagnosticHandler(whiteList, provider); 157 var handler = new CollectingDiagnosticHandler(whiteList, provider);
157 var options = <String>['--analyze-only', '--categories=Client,Server', 158 var options = <String>['--analyze-only', '--categories=Client,Server',
158 '--show-package-warnings']; 159 '--show-package-warnings'];
159 if (analyzeAll) options.add('--analyze-all'); 160 if (analyzeAll) options.add('--analyze-all');
160 var compiler = new Compiler( 161 var compiler = new Compiler(
161 provider.readStringFromUri, 162 provider,
162 null, 163 null,
163 handler.diagnosticHandler, 164 handler,
164 libraryRoot, packageRoot, 165 libraryRoot,
166 packageRoot,
165 options, 167 options,
166 {}); 168 {});
167 String MESSAGE = """ 169 String MESSAGE = """
168 170
169 171
170 === 172 ===
171 === ERROR: Unexpected result of analysis. 173 === ERROR: Unexpected result of analysis.
172 === 174 ===
173 === Please update [WHITE_LIST] in $testFileName 175 === Please update [WHITE_LIST] in $testFileName
174 === 176 ===
(...skipping 11 matching lines...) Expand all
186 exit(1); 188 exit(1);
187 } 189 }
188 } 190 }
189 if (analyzeAll) { 191 if (analyzeAll) {
190 compiler.librariesToAnalyzeWhenRun = uriList; 192 compiler.librariesToAnalyzeWhenRun = uriList;
191 return compiler.run(null).then(onCompletion); 193 return compiler.run(null).then(onCompletion);
192 } else { 194 } else {
193 return compiler.run(uriList.single).then(onCompletion); 195 return compiler.run(uriList.single).then(onCompletion);
194 } 196 }
195 } 197 }
OLDNEW
« no previous file with comments | « pkg/docgen/lib/src/generator.dart ('k') | tests/compiler/dart2js/bad_loop_test.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698