assert (configuration != null);
//TODO It would be nice to cache this; it cannot (?) be static, however,
// as the Configuration changes. Solution would be a static Map or some fancy logic?
// temporary compiler to get a syntax tree, for signature generation
final As3Compiler asc = new As3Compiler(configuration.getCompilerConfiguration());
asc.addCompilerExtension(SignatureExtension.getInstance());
// create a new CompilationUnit if no error occur
// then grab the signature if no signature error occur
CompilationUnit u = null;
// this is needed by Source.Resolver.resolve().
ThreadLocalToolkit.setCompatibilityVersion(configuration.getCompatibilityVersion());
// this swallows any parse errors -- they will get thrown when the file is
// officially reparsed for compilation
final Logger original = ThreadLocalToolkit.getLogger();
ThreadLocalToolkit.setLogger(new LocalLogger(null));
{
final Source tmpSource = asc.preprocess(
Source.newSource(source.getBackingFile(), source.getFileTime(),
source.getPathRoot(), source.getRelativePath(),
source.getShortName(), source.getOwner(),
source.isInternal(), source.isRoot(),
source.isDebuggable(), source.getFileIncludesSet(),
source.getFileIncludeTimes(), source.getLogger()));
// HACK: Forcefully disable any chance of signatures getting emitted to
// the filesystem -- since this code should be as fast as possible.
// Don't worry though, it WILL happen later during re-compilation.
final String tmp = SignatureExtension.signatureDirectory;
SignatureExtension.signatureDirectory = null;
{
u = asc.parse1(tmpSource, new SymbolTable(configuration));
}
SignatureExtension.signatureDirectory = tmp;
}
ThreadLocalToolkit.setLogger(original);