use of org.apache.flex.compiler.internal.projects.CompilerProject in project vscode-nextgenas by BowlerHatLLC.
the class ActionScriptTextDocumentService method checkFilePathForAllProblems.
private boolean checkFilePathForAllProblems(Path path, Boolean quick) {
ICompilationUnit mainUnit = getCompilationUnit(path);
if (mainUnit == null) {
return false;
}
CompilerProject project = (CompilerProject) mainUnit.getProject();
Collection<ICompilerProblem> fatalProblems = project.getFatalProblems();
if (fatalProblems == null || fatalProblems.size() == 0) {
fatalProblems = project.getProblems();
}
if (fatalProblems != null && fatalProblems.size() > 0) {
URI uri = path.toUri();
PublishDiagnosticsParams publish = new PublishDiagnosticsParams();
publish.setDiagnostics(new ArrayList<>());
publish.setUri(uri.toString());
codeProblemTracker.trackFileWithProblems(uri);
for (ICompilerProblem problem : fatalProblems) {
addCompilerProblem(problem, publish);
}
codeProblemTracker.cleanUpStaleProblems();
if (languageClient != null) {
languageClient.publishDiagnostics(publish);
}
return true;
}
IASNode ast = null;
try {
ast = mainUnit.getSyntaxTreeRequest().get().getAST();
} catch (Exception e) {
System.err.println("Exception during build: " + e);
return false;
}
if (ast == null) {
return false;
}
Map<URI, PublishDiagnosticsParams> files = new HashMap<>();
try {
if (quick) {
PublishDiagnosticsParams params = checkCompilationUnitForAllProblems(mainUnit);
URI uri = Paths.get(mainUnit.getAbsoluteFilename()).toUri();
files.put(uri, params);
} else {
boolean continueCheckingForErrors = true;
while (continueCheckingForErrors) {
try {
for (ICompilationUnit unit : compilationUnits) {
if (unit == null || unit instanceof SWCCompilationUnit) {
//compiled compilation units won't have problems
continue;
}
PublishDiagnosticsParams params = checkCompilationUnitForAllProblems(unit);
URI uri = Paths.get(unit.getAbsoluteFilename()).toUri();
files.put(uri, params);
}
continueCheckingForErrors = false;
} catch (ConcurrentModificationException e) {
//when we finished building one of the compilation
//units, more were added to the collection, so we need
//to start over because we can't iterate over a modified
//collection.
}
}
//only clean up stale errors on a full check
codeProblemTracker.cleanUpStaleProblems();
}
} catch (Exception e) {
System.err.println("Exception during build: " + e);
e.printStackTrace();
return false;
}
if (languageClient != null) {
files.values().forEach(languageClient::publishDiagnostics);
}
return true;
}
Aggregations