OLD | NEW |
1 // Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2012, 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 package com.google.dart.compiler.resolver; | 5 package com.google.dart.compiler.resolver; |
6 | 6 |
7 import com.google.common.base.Joiner; | 7 import com.google.common.base.Joiner; |
8 import com.google.common.base.Splitter; | 8 import com.google.common.base.Splitter; |
9 import com.google.common.collect.Lists; | 9 import com.google.common.collect.Lists; |
| 10 import com.google.common.collect.Sets; |
10 import com.google.dart.compiler.DartCompilationError; | 11 import com.google.dart.compiler.DartCompilationError; |
11 import com.google.dart.compiler.DartCompilerListener; | 12 import com.google.dart.compiler.DartCompilerListener; |
12 import com.google.dart.compiler.ErrorCode; | 13 import com.google.dart.compiler.ErrorCode; |
| 14 import com.google.dart.compiler.ast.ASTVisitor; |
13 import com.google.dart.compiler.ast.DartClass; | 15 import com.google.dart.compiler.ast.DartClass; |
14 import com.google.dart.compiler.ast.DartIdentifier; | 16 import com.google.dart.compiler.ast.DartIdentifier; |
15 import com.google.dart.compiler.ast.DartNode; | 17 import com.google.dart.compiler.ast.DartNode; |
16 import com.google.dart.compiler.ast.ASTVisitor; | |
17 import com.google.dart.compiler.ast.DartParameterizedTypeNode; | 18 import com.google.dart.compiler.ast.DartParameterizedTypeNode; |
18 import com.google.dart.compiler.ast.DartTypeNode; | 19 import com.google.dart.compiler.ast.DartTypeNode; |
19 import com.google.dart.compiler.ast.DartTypeParameter; | 20 import com.google.dart.compiler.ast.DartTypeParameter; |
20 import com.google.dart.compiler.ast.DartUnit; | 21 import com.google.dart.compiler.ast.DartUnit; |
21 import com.google.dart.compiler.ast.LibraryUnit; | 22 import com.google.dart.compiler.ast.LibraryUnit; |
22 import com.google.dart.compiler.ast.Modifiers; | 23 import com.google.dart.compiler.ast.Modifiers; |
23 import com.google.dart.compiler.common.ErrorExpectation; | 24 import com.google.dart.compiler.common.ErrorExpectation; |
24 import com.google.dart.compiler.parser.DartParser; | 25 import com.google.dart.compiler.parser.DartParser; |
25 import com.google.dart.compiler.parser.DartScannerParserContext; | |
26 import com.google.dart.compiler.testing.TestCompilerContext; | 26 import com.google.dart.compiler.testing.TestCompilerContext; |
27 import com.google.dart.compiler.type.DynamicType; | 27 import com.google.dart.compiler.type.DynamicType; |
28 import com.google.dart.compiler.type.InterfaceType; | 28 import com.google.dart.compiler.type.InterfaceType; |
29 import com.google.dart.compiler.type.Type; | 29 import com.google.dart.compiler.type.Type; |
30 import com.google.dart.compiler.type.Types; | 30 import com.google.dart.compiler.type.Types; |
31 import com.google.dart.compiler.util.DartSourceString; | 31 import com.google.dart.compiler.util.DartSourceString; |
32 | 32 |
33 import junit.framework.TestCase; | 33 import junit.framework.TestCase; |
34 | 34 |
35 import java.util.ArrayList; | 35 import java.util.ArrayList; |
(...skipping 303 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
339 } | 339 } |
340 return unit; | 340 return unit; |
341 } | 341 } |
342 | 342 |
343 protected DartUnit parseUnit(String firstLine, String secondLine, String... re
st) { | 343 protected DartUnit parseUnit(String firstLine, String secondLine, String... re
st) { |
344 return parseUnit(Joiner.on('\n').join(firstLine, secondLine, (Object[]) rest
).toString()); | 344 return parseUnit(Joiner.on('\n').join(firstLine, secondLine, (Object[]) rest
).toString()); |
345 } | 345 } |
346 | 346 |
347 protected DartUnit parseUnit(String string) { | 347 protected DartUnit parseUnit(String string) { |
348 DartSourceString source = new DartSourceString("<source string>", string); | 348 DartSourceString source = new DartSourceString("<source string>", string); |
349 DartParser parser = new DartParser(new DartScannerParserContext(source, stri
ng, getListener())); | 349 DartParser parser = new DartParser( |
350 return parser.parseUnit(source); | 350 source, |
| 351 string, |
| 352 false, |
| 353 Sets.<String>newHashSet(), |
| 354 getListener(), |
| 355 null); |
| 356 return parser.parseUnit(); |
351 } | 357 } |
352 | 358 |
353 private DartCompilerListener getListener() { | 359 private DartCompilerListener getListener() { |
354 return new DartCompilerListener.Empty() { | 360 return new DartCompilerListener.Empty() { |
355 @Override | 361 @Override |
356 public void onError(DartCompilationError event) { | 362 public void onError(DartCompilationError event) { |
357 parseErrors.add(event); | 363 parseErrors.add(event); |
358 } | 364 } |
359 }; | 365 }; |
360 } | 366 } |
(...skipping 184 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
545 public void onError(DartCompilationError event) { | 551 public void onError(DartCompilationError event) { |
546 resolveErrors.add(event); | 552 resolveErrors.add(event); |
547 } | 553 } |
548 }; | 554 }; |
549 // resolve and check errors | 555 // resolve and check errors |
550 resolveCompileTimeConst(unit, ctx); | 556 resolveCompileTimeConst(unit, ctx); |
551 ErrorExpectation.assertErrors(resolveErrors, expectedErrors); | 557 ErrorExpectation.assertErrors(resolveErrors, expectedErrors); |
552 return resolveErrors; | 558 return resolveErrors; |
553 } | 559 } |
554 } | 560 } |
OLD | NEW |