@Override
protected void internalPerform() throws AnalysisException {
//
// Then parse the token stream.
//
TimeCounterHandle timeCounterParse = PerformanceStatistics.parse.start();
try {
final RecordingErrorListener errorListener = new RecordingErrorListener();
Parser parser = new Parser(source, errorListener);
AnalysisOptions options = getContext().getAnalysisOptions();
parser.setParseFunctionBodies(options.getAnalyzeFunctionBodies());
parser.setParseAsync(options.getEnableAsync());
parser.setParseDeferredLibraries(options.getEnableDeferredLoading());
parser.setParseEnum(options.getEnableEnum());
unit = parser.parseCompilationUnit(tokenStream);
unit.setLineInfo(lineInfo);
AnalysisContext analysisContext = getContext();
for (Directive directive : unit.getDirectives()) {
if (directive instanceof PartOfDirective) {
containsPartOfDirective = true;
} else {
containsNonPartOfDirective = true;
if (directive instanceof UriBasedDirective) {
Source referencedSource = resolveDirective(
analysisContext,
source,
(UriBasedDirective) directive,
errorListener);
if (referencedSource != null) {
if (directive instanceof ExportDirective) {
exportedSources.add(referencedSource);
} else if (directive instanceof ImportDirective) {
importedSources.add(referencedSource);
} else if (directive instanceof PartDirective) {
if (!referencedSource.equals(source)) {
includedSources.add(referencedSource);
}
} else {
throw new AnalysisException(getClass().getSimpleName() + " failed to handle a "
+ directive.getClass().getName());
}
}
}
}
}
errors = errorListener.getErrorsForSource(source);
} finally {
timeCounterParse.stop();
}
}