| OLD | NEW |
| 1 // Copyright (c) 2011, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2011, 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; | 5 package com.google.dart.compiler; |
| 6 | 6 |
| 7 import com.google.dart.compiler.ast.DartUnit; | 7 import com.google.dart.compiler.ast.DartUnit; |
| 8 import com.google.dart.compiler.ast.LibraryUnit; | 8 import com.google.dart.compiler.ast.LibraryUnit; |
| 9 import com.google.dart.compiler.metrics.CompilerMetrics; | 9 import com.google.dart.compiler.metrics.CompilerMetrics; |
| 10 import com.google.dart.compiler.parser.DartParser; | 10 import com.google.dart.compiler.parser.DartParser; |
| 11 import com.google.dart.compiler.resolver.ResolverErrorCode; |
| 12 import com.google.dart.compiler.resolver.TypeErrorCode; |
| 11 | 13 |
| 12 import java.io.IOException; | 14 import java.io.IOException; |
| 13 import java.io.Reader; | 15 import java.io.Reader; |
| 14 import java.io.Writer; | 16 import java.io.Writer; |
| 15 import java.net.URI; | 17 import java.net.URI; |
| 16 import java.util.concurrent.atomic.AtomicBoolean; | 18 import java.util.concurrent.atomic.AtomicBoolean; |
| 17 import java.util.concurrent.atomic.AtomicInteger; | 19 import java.util.concurrent.atomic.AtomicInteger; |
| 18 | 20 |
| 19 /** | 21 /** |
| 20 * An overall context for the Dart compiler providing an adapter and forwarding | 22 * An overall context for the Dart compiler providing an adapter and forwarding |
| (...skipping 20 matching lines...) Expand all Loading... |
| 41 DartCompilerMainContext(LibrarySource lib, DartArtifactProvider provider, | 43 DartCompilerMainContext(LibrarySource lib, DartArtifactProvider provider, |
| 42 DartCompilerListener listener, | 44 DartCompilerListener listener, |
| 43 CompilerConfiguration compilerConfiguration) { | 45 CompilerConfiguration compilerConfiguration) { |
| 44 this.lib = lib; | 46 this.lib = lib; |
| 45 this.provider = provider; | 47 this.provider = provider; |
| 46 this.listener = listener; | 48 this.listener = listener; |
| 47 this.compilerConfiguration = compilerConfiguration; | 49 this.compilerConfiguration = compilerConfiguration; |
| 48 } | 50 } |
| 49 | 51 |
| 50 @Override | 52 @Override |
| 51 public void compilationError(DartCompilationError event) { | 53 public void onError(DartCompilationError event) { |
| 52 incrementErrorCount(); | 54 if (event.getErrorCode().getSubSystem() == SubSystem.STATIC_TYPE |
| 53 listener.compilationError(event); | 55 && (!shouldWarnOnNoSuchType() || ( |
| 56 (event.getErrorCode() != TypeErrorCode.CANNOT_BE_RESOLVED) && |
| 57 (event.getErrorCode() != TypeErrorCode.NO_SUCH_TYPE) && |
| 58 (event.getErrorCode() != TypeErrorCode.INTERFACE_HAS_NO_METHOD_NAMED
)))) { |
| 59 incrementTypeErrorCount(); |
| 60 } else if (event.getErrorCode().getErrorSeverity() == ErrorSeverity.ERROR) { |
| 61 incrementErrorCount(); |
| 62 } else if (event.getErrorCode().getErrorSeverity() == ErrorSeverity.WARNING)
{ |
| 63 incrementWarningCount(); |
| 64 } |
| 65 listener.onError(event); |
| 54 } | 66 } |
| 55 | 67 |
| 56 @Override | 68 @Override |
| 57 public void compilationWarning(DartCompilationError event) { | |
| 58 incrementWarningCount(); | |
| 59 listener.compilationWarning(event); | |
| 60 } | |
| 61 | |
| 62 @Override | |
| 63 public void typeError(DartCompilationError event) { | |
| 64 if (!shouldWarnOnNoSuchType() | |
| 65 || ((event.getErrorCode() != DartCompilerErrorCode.CANNOT_BE_RESOLVED) | |
| 66 && (event.getErrorCode() != DartCompilerErrorCode.NO_SUCH_TYPE) | |
| 67 && (event.getErrorCode() != DartCompilerErrorCode.INTERFACE_HAS_NO_M
ETHOD_NAMED))) { | |
| 68 | |
| 69 incrementTypeErrorCount(); | |
| 70 } | |
| 71 listener.typeError(event); | |
| 72 } | |
| 73 | |
| 74 @Override | |
| 75 public LibraryUnit getApplicationUnit() { | 69 public LibraryUnit getApplicationUnit() { |
| 76 return getAppLibraryUnit(); | 70 return getAppLibraryUnit(); |
| 77 } | 71 } |
| 78 | 72 |
| 79 @Override | 73 @Override |
| 80 public LibraryUnit getAppLibraryUnit() { | 74 public LibraryUnit getAppLibraryUnit() { |
| 81 // use double-checked looking pattern with use of volatile | 75 // use double-checked looking pattern with use of volatile |
| 82 if (appLibraryUnit == null) { | 76 if (appLibraryUnit == null) { |
| 83 synchronized (this) { | 77 synchronized (this) { |
| 84 if (appLibraryUnit == null) { | 78 if (appLibraryUnit == null) { |
| 85 try { | 79 try { |
| 86 appLibraryUnit = | 80 appLibraryUnit = |
| 87 DartParser.getSourceParser(lib, listener).preProcessLibraryDirec
tives(lib); | 81 DartParser.getSourceParser(lib, listener).preProcessLibraryDirec
tives(lib); |
| 88 } catch (IOException ex) { | 82 } catch (IOException e) { |
| 89 compilationError(new DartCompilationError(lib, ex)); | 83 onError(new DartCompilationError(lib, DartCompilerErrorCode.IO, e.ge
tMessage())); |
| 90 return null; | 84 return null; |
| 91 } | 85 } |
| 92 } | 86 } |
| 93 } | 87 } |
| 94 } | 88 } |
| 95 return appLibraryUnit; | 89 return appLibraryUnit; |
| 96 } | 90 } |
| 97 | 91 |
| 98 @Override | 92 @Override |
| 99 public Reader getArtifactReader(Source source, String part, String extension) | 93 public Reader getArtifactReader(Source source, String part, String extension) |
| (...skipping 24 matching lines...) Expand all Loading... |
| 124 return typeErrorCount.get(); | 118 return typeErrorCount.get(); |
| 125 } | 119 } |
| 126 | 120 |
| 127 @Override | 121 @Override |
| 128 public LibraryUnit getLibraryUnit(LibrarySource libSrc) { | 122 public LibraryUnit getLibraryUnit(LibrarySource libSrc) { |
| 129 if (libSrc == lib) { | 123 if (libSrc == lib) { |
| 130 return getApplicationUnit(); | 124 return getApplicationUnit(); |
| 131 } | 125 } |
| 132 try { | 126 try { |
| 133 return DartParser.getSourceParser(libSrc, listener).preProcessLibraryDirec
tives(libSrc); | 127 return DartParser.getSourceParser(libSrc, listener).preProcessLibraryDirec
tives(libSrc); |
| 134 } catch (IOException ex) { | 128 } catch (IOException e) { |
| 135 compilationError(new DartCompilationError(libSrc, ex)); | 129 onError(new DartCompilationError(libSrc, DartCompilerErrorCode.IO, e.getMe
ssage())); |
| 136 return null; | 130 return null; |
| 137 } | 131 } |
| 138 } | 132 } |
| 139 | 133 |
| 140 @Override | 134 @Override |
| 141 public boolean isOutOfDate(Source source, Source base, String extension) { | 135 public boolean isOutOfDate(Source source, Source base, String extension) { |
| 142 return provider.isOutOfDate(source, base, extension); | 136 return provider.isOutOfDate(source, base, extension); |
| 143 } | 137 } |
| 144 | 138 |
| 145 protected void incrementErrorCount() { | 139 protected void incrementErrorCount() { |
| (...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 183 @Override | 177 @Override |
| 184 public LibrarySource getSystemLibraryFor(String importSpec) { | 178 public LibrarySource getSystemLibraryFor(String importSpec) { |
| 185 return compilerConfiguration.getSystemLibraryFor(importSpec); | 179 return compilerConfiguration.getSystemLibraryFor(importSpec); |
| 186 } | 180 } |
| 187 | 181 |
| 188 @Override | 182 @Override |
| 189 public void unitCompiled(DartUnit unit) { | 183 public void unitCompiled(DartUnit unit) { |
| 190 listener.unitCompiled(unit); | 184 listener.unitCompiled(unit); |
| 191 } | 185 } |
| 192 } | 186 } |
| OLD | NEW |