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

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

Issue 152593002: Version 1.2.0-dev.3.1 (Closed) Base URL: http://dart.googlecode.com/svn/trunk/dart/
Patch Set: Created 6 years, 10 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 | Annotate | Revision Log
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 '../../../sdk/lib/_internal/compiler/compiler.dart' as api; 9 import '../../../sdk/lib/_internal/compiler/compiler.dart' as api;
10 import '../../../sdk/lib/_internal/compiler/implementation/apiimpl.dart'; 10 import '../../../sdk/lib/_internal/compiler/implementation/apiimpl.dart';
(...skipping 12 matching lines...) Expand all
23 * Use an identifiable suffix of the file uri as key. Use a fixed substring of 23 * Use an identifiable suffix of the file uri as key. Use a fixed substring of
24 * the error/warning message in the list of whitelistings for each file. 24 * the error/warning message in the list of whitelistings for each file.
25 */ 25 */
26 // TODO(johnniwinther): Support canonical URIs as keys and message kinds as 26 // TODO(johnniwinther): Support canonical URIs as keys and message kinds as
27 // values. 27 // values.
28 28
29 class CollectingDiagnosticHandler extends FormattingDiagnosticHandler { 29 class CollectingDiagnosticHandler extends FormattingDiagnosticHandler {
30 bool hasWarnings = false; 30 bool hasWarnings = false;
31 bool hasHint = false; 31 bool hasHint = false;
32 bool hasErrors = false; 32 bool hasErrors = false;
33 bool lastWasWhitelisted = false;
33 34
34 Map<String, Map<String, int>> whiteListMap 35 Map<String, Map<String, int>> whiteListMap
35 = new Map<String, Map<String, int>>(); 36 = new Map<String, Map<String, int>>();
36 37
37 CollectingDiagnosticHandler(Map<String, List<String>> whiteList, 38 CollectingDiagnosticHandler(Map<String, List<String>> whiteList,
38 SourceFileProvider provider) 39 SourceFileProvider provider)
39 : super(provider) { 40 : super(provider) {
40 whiteList.forEach((String file, List<String> messageParts) { 41 whiteList.forEach((String file, List<String> messageParts) {
41 var useMap = new Map<String,int>(); 42 var useMap = new Map<String,int>();
42 for (String messagePart in messageParts) { 43 for (String messagePart in messageParts) {
(...skipping 49 matching lines...) Expand 10 before | Expand all | Expand 10 after
92 } 93 }
93 } 94 }
94 return false; 95 return false;
95 } 96 }
96 97
97 void diagnosticHandler(Uri uri, int begin, int end, String message, 98 void diagnosticHandler(Uri uri, int begin, int end, String message,
98 api.Diagnostic kind) { 99 api.Diagnostic kind) {
99 if (kind == api.Diagnostic.WARNING) { 100 if (kind == api.Diagnostic.WARNING) {
100 if (checkWhiteList(uri, message)) { 101 if (checkWhiteList(uri, message)) {
101 // Suppress whitelisted warnings. 102 // Suppress whitelisted warnings.
103 lastWasWhitelisted = true;
102 return; 104 return;
103 } 105 }
104 hasWarnings = true; 106 hasWarnings = true;
105 } 107 }
106 if (kind == api.Diagnostic.HINT) { 108 if (kind == api.Diagnostic.HINT) {
107 if (checkWhiteList(uri, message)) { 109 if (checkWhiteList(uri, message)) {
108 // Suppress whitelisted hints. 110 // Suppress whitelisted hints.
111 lastWasWhitelisted = true;
109 return; 112 return;
110 } 113 }
111 hasHint = true; 114 hasHint = true;
112 } 115 }
113 if (kind == api.Diagnostic.ERROR) { 116 if (kind == api.Diagnostic.ERROR) {
114 if (checkWhiteList(uri, message)) { 117 if (checkWhiteList(uri, message)) {
115 // Suppress whitelisted errors. 118 // Suppress whitelisted errors.
119 lastWasWhitelisted = true;
116 return; 120 return;
117 } 121 }
118 hasErrors = true; 122 hasErrors = true;
119 } 123 }
124 if (kind == api.Diagnostic.INFO && lastWasWhitelisted) {
125 return;
126 }
127 lastWasWhitelisted = false;
120 super.diagnosticHandler(uri, begin, end, message, kind); 128 super.diagnosticHandler(uri, begin, end, message, kind);
121 } 129 }
122 } 130 }
123 131
124 Future analyze(List<Uri> uriList, 132 Future analyze(List<Uri> uriList,
125 Map<String, List<String>> whiteList, 133 Map<String, List<String>> whiteList,
126 {bool analyzeAll: true}) { 134 {bool analyzeAll: true}) {
127 String testFileName = 135 String testFileName =
128 relativize(Uri.base, Platform.script, Platform.isWindows); 136 relativize(Uri.base, Platform.script, Platform.isWindows);
129 137
(...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after
166 exit(1); 174 exit(1);
167 } 175 }
168 } 176 }
169 if (analyzeAll) { 177 if (analyzeAll) {
170 compiler.librariesToAnalyzeWhenRun = uriList; 178 compiler.librariesToAnalyzeWhenRun = uriList;
171 return compiler.run(null).then(onCompletion); 179 return compiler.run(null).then(onCompletion);
172 } else { 180 } else {
173 return compiler.run(uriList.single).then(onCompletion); 181 return compiler.run(uriList.single).then(onCompletion);
174 } 182 }
175 } 183 }
OLDNEW
« no previous file with comments | « tests/compiler/dart2js/analyze_api_test.dart ('k') | tests/compiler/dart2js/analyze_only_test.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698