use of com.android.ide.common.rendering.api.LayoutLog.TAG_RESOURCES_PREFIX in project android by JetBrains.
the class RenderErrorContributor method reportRelevantCompilationErrors.
private void reportRelevantCompilationErrors(@NotNull RenderLogger logger, @NotNull RenderTask renderTask) {
Module module = logger.getModule();
if (module == null) {
return;
}
Project project = module.getProject();
WolfTheProblemSolver wolfgang = WolfTheProblemSolver.getInstance(project);
if (!wolfgang.hasProblemFilesBeneath(module)) {
return;
}
HtmlBuilder builder = new HtmlBuilder();
String summary = null;
if (logger.seenTagPrefix(TAG_RESOURCES_PREFIX)) {
// Do we have errors in the res/ files?
// See if it looks like we have aapt problems
boolean haveResourceErrors = wolfgang.hasProblemFilesBeneath(virtualFile -> virtualFile.getFileType() == StdFileTypes.XML);
if (haveResourceErrors) {
summary = "Resource errors";
builder.addBold("This project contains resource errors, so aapt did not succeed, " + "which can cause rendering failures. Fix resource problems first.").newline().newline();
}
} else if (renderTask.getLayoutlibCallback().isUsed()) {
boolean hasJavaErrors = wolfgang.hasProblemFilesBeneath(virtualFile -> virtualFile.getFileType() == StdFileTypes.JAVA);
if (hasJavaErrors) {
summary = "Compilation errors";
builder.addBold("This project contains Java compilation errors, " + "which can cause rendering failures for custom views. " + "Fix compilation problems first.").newline().newline();
}
}
if (summary == null) {
return;
}
addIssue().setSeverity(HighlightSeverity.ERROR).setSummary(summary).setHtmlContent(builder).build();
}
Aggregations