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

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

Issue 2345083003: dart2js: run dartfmt on tests (Closed)
Patch Set: revert another multipart test Created 4 years, 3 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
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 library dart2js.analyze_helpers.test; 5 library dart2js.analyze_helpers.test;
6 6
7 import 'dart:io'; 7 import 'dart:io';
8 8
9 import 'package:async_helper/async_helper.dart'; 9 import 'package:async_helper/async_helper.dart';
10 import 'package:compiler/compiler_new.dart' show 10 import 'package:compiler/compiler_new.dart' show Diagnostic;
11 Diagnostic; 11 import 'package:compiler/src/apiimpl.dart' show CompilerImpl;
12 import 'package:compiler/src/apiimpl.dart' show
13 CompilerImpl;
14 import 'package:compiler/src/commandline_options.dart'; 12 import 'package:compiler/src/commandline_options.dart';
15 import 'package:compiler/src/constants/expressions.dart' show 13 import 'package:compiler/src/constants/expressions.dart'
16 ConstructedConstantExpression; 14 show ConstructedConstantExpression;
17 import 'package:compiler/src/dart_types.dart' show 15 import 'package:compiler/src/dart_types.dart' show InterfaceType;
18 InterfaceType; 16 import 'package:compiler/src/diagnostics/source_span.dart' show SourceSpan;
19 import 'package:compiler/src/diagnostics/source_span.dart' show
20 SourceSpan;
21 import 'package:compiler/src/elements/elements.dart'; 17 import 'package:compiler/src/elements/elements.dart';
22 import 'package:compiler/src/filenames.dart' show 18 import 'package:compiler/src/filenames.dart' show nativeToUriPath;
23 nativeToUriPath;
24 import 'package:compiler/src/resolution/semantic_visitor.dart'; 19 import 'package:compiler/src/resolution/semantic_visitor.dart';
25 import 'package:compiler/src/resolution/tree_elements.dart' show 20 import 'package:compiler/src/resolution/tree_elements.dart' show TreeElements;
26 TreeElements; 21 import 'package:compiler/src/source_file_provider.dart'
27 import 'package:compiler/src/source_file_provider.dart' show 22 show FormattingDiagnosticHandler;
28 FormattingDiagnosticHandler;
29 import 'package:compiler/src/tree/tree.dart'; 23 import 'package:compiler/src/tree/tree.dart';
30 import 'package:compiler/src/universe/call_structure.dart' show 24 import 'package:compiler/src/universe/call_structure.dart' show CallStructure;
31 CallStructure;
32 import 'package:expect/expect.dart'; 25 import 'package:expect/expect.dart';
33 26
34 import 'memory_compiler.dart'; 27 import 'memory_compiler.dart';
35 28
36 main(List<String> arguments) { 29 main(List<String> arguments) {
37 bool verbose = arguments.contains('-v'); 30 bool verbose = arguments.contains('-v');
38 31
39 List<String> options = <String>[ 32 List<String> options = <String>[
40 Flags.analyzeOnly, 33 Flags.analyzeOnly,
41 Flags.analyzeMain, 34 Flags.analyzeMain,
42 '--categories=Client,Server']; 35 '--categories=Client,Server'
36 ];
43 if (verbose) { 37 if (verbose) {
44 options.add(Flags.verbose); 38 options.add(Flags.verbose);
45 } 39 }
46 asyncTest(() async { 40 asyncTest(() async {
47 CompilerImpl compiler = compilerFor( 41 CompilerImpl compiler =
48 options: options, showDiagnostics: verbose); 42 compilerFor(options: options, showDiagnostics: verbose);
49 FormattingDiagnosticHandler diagnostics = 43 FormattingDiagnosticHandler diagnostics =
50 new FormattingDiagnosticHandler(compiler.provider); 44 new FormattingDiagnosticHandler(compiler.provider);
51 Directory dir = 45 Directory dir =
52 new Directory.fromUri(Uri.base.resolve('pkg/compiler/lib/')); 46 new Directory.fromUri(Uri.base.resolve('pkg/compiler/lib/'));
53 String helpersUriPrefix = dir.uri.resolve('src/helpers/').toString(); 47 String helpersUriPrefix = dir.uri.resolve('src/helpers/').toString();
54 HelperAnalyzer analyzer = new HelperAnalyzer(diagnostics, helpersUriPrefix); 48 HelperAnalyzer analyzer = new HelperAnalyzer(diagnostics, helpersUriPrefix);
55 LibraryElement helperLibrary; 49 LibraryElement helperLibrary;
56 for (FileSystemEntity entity in dir.listSync(recursive: true)) { 50 for (FileSystemEntity entity in dir.listSync(recursive: true)) {
57 if (entity is File && entity.path.endsWith('.dart')) { 51 if (entity is File && entity.path.endsWith('.dart')) {
58 Uri file = Uri.base.resolve(nativeToUriPath(entity.path)); 52 Uri file = Uri.base.resolve(nativeToUriPath(entity.path));
(...skipping 56 matching lines...) Expand 10 before | Expand all | Expand 10 after
115 bool isHelper(Element element) { 109 bool isHelper(Element element) {
116 Uri uri = element.library.canonicalUri; 110 Uri uri = element.library.canonicalUri;
117 return '$uri'.startsWith(helpersUriPrefix); 111 return '$uri'.startsWith(helpersUriPrefix);
118 } 112 }
119 113
120 void checkAccess(Node node, MemberElement element) { 114 void checkAccess(Node node, MemberElement element) {
121 if (isHelper(element) && !isHelper(analyzedElement)) { 115 if (isHelper(element) && !isHelper(analyzedElement)) {
122 Uri uri = analyzedElement.implementation.sourcePosition.uri; 116 Uri uri = analyzedElement.implementation.sourcePosition.uri;
123 SourceSpan span = new SourceSpan.fromNode(uri, node); 117 SourceSpan span = new SourceSpan.fromNode(uri, node);
124 diagnostics.report(null, span.uri, span.begin, span.end, 118 diagnostics.report(null, span.uri, span.begin, span.end,
125 "Helper used in production code.", 119 "Helper used in production code.", Diagnostic.ERROR);
126 Diagnostic.ERROR);
127 errors.add(span); 120 errors.add(span);
128 } 121 }
129 } 122 }
130 123
131 @override 124 @override
132 void visitTopLevelFieldInvoke( 125 void visitTopLevelFieldInvoke(Send node, FieldElement field,
133 Send node, 126 NodeList arguments, CallStructure callStructure, _) {
134 FieldElement field,
135 NodeList arguments,
136 CallStructure callStructure,
137 _) {
138 checkAccess(node, field); 127 checkAccess(node, field);
139 apply(arguments); 128 apply(arguments);
140 } 129 }
141 130
142 @override 131 @override
143 void visitTopLevelGetterInvoke( 132 void visitTopLevelGetterInvoke(Send node, GetterElement getter,
144 Send node, 133 NodeList arguments, CallStructure callStructure, _) {
145 GetterElement getter,
146 NodeList arguments,
147 CallStructure callStructure,
148 _) {
149 checkAccess(node, getter); 134 checkAccess(node, getter);
150 apply(arguments); 135 apply(arguments);
151 } 136 }
152 137
153 @override 138 @override
154 void visitTopLevelFunctionInvoke( 139 void visitTopLevelFunctionInvoke(Send node, MethodElement method,
155 Send node, 140 NodeList arguments, CallStructure callStructure, _) {
156 MethodElement method,
157 NodeList arguments,
158 CallStructure callStructure,
159 _) {
160 checkAccess(node, method); 141 checkAccess(node, method);
161 apply(arguments); 142 apply(arguments);
162 } 143 }
163 144
164 @override 145 @override
165 void visitTopLevelFieldGet( 146 void visitTopLevelFieldGet(Send node, FieldElement field, _) {
166 Send node,
167 FieldElement field,
168 _) {
169 checkAccess(node, field); 147 checkAccess(node, field);
170 } 148 }
171 149
172 @override 150 @override
173 void visitTopLevelGetterGet( 151 void visitTopLevelGetterGet(Send node, GetterElement getter, _) {
174 Send node,
175 GetterElement getter,
176 _) {
177 checkAccess(node, getter); 152 checkAccess(node, getter);
178 } 153 }
179 154
180 @override 155 @override
181 void visitTopLevelFunctionGet( 156 void visitTopLevelFunctionGet(Send node, MethodElement method, _) {
182 Send node,
183 MethodElement method,
184 _) {
185 checkAccess(node, method); 157 checkAccess(node, method);
186 } 158 }
187 159
188 @override 160 @override
189 void visitGenerativeConstructorInvoke( 161 void visitGenerativeConstructorInvoke(
190 NewExpression node, 162 NewExpression node,
191 ConstructorElement constructor, 163 ConstructorElement constructor,
192 InterfaceType type, 164 InterfaceType type,
193 NodeList arguments, 165 NodeList arguments,
194 CallStructure callStructure, 166 CallStructure callStructure,
(...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after
230 InterfaceType effectiveTargetType, 202 InterfaceType effectiveTargetType,
231 NodeList arguments, 203 NodeList arguments,
232 CallStructure callStructure, 204 CallStructure callStructure,
233 _) { 205 _) {
234 checkAccess(node, constructor); 206 checkAccess(node, constructor);
235 apply(arguments); 207 apply(arguments);
236 } 208 }
237 209
238 @override 210 @override
239 void visitConstConstructorInvoke( 211 void visitConstConstructorInvoke(
240 NewExpression node, 212 NewExpression node, ConstructedConstantExpression constant, _) {
241 ConstructedConstantExpression constant,
242 _) {
243 checkAccess(node, constant.target); 213 checkAccess(node, constant.target);
244 } 214 }
245 } 215 }
OLDNEW
« no previous file with comments | « tests/compiler/dart2js/analyze_api_test.dart ('k') | tests/compiler/dart2js/analyze_dart2js_test.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698