use of com.android.tools.idea.rendering.errors.ui.RenderErrorModel in project android by JetBrains.
the class NlUsageTrackerManager method logRenderResult.
@Override
public void logRenderResult(@Nullable NlModel.ChangeType trigger, @NotNull RenderResult result, long totalRenderTimeMs) {
// Renders are a quite common event so we sample them
if (!shouldLog(LOG_RENDER_PERCENT)) {
return;
}
logStudioEvent(LayoutEditorEvent.LayoutEditorEventType.RENDER, (event) -> {
LayoutEditorRenderResult.Builder builder = LayoutEditorRenderResult.newBuilder().setResultCode(result.getRenderResult().getStatus().ordinal()).setTotalRenderTimeMs(totalRenderTimeMs);
if (trigger != null) {
switch(trigger) {
case RESOURCE_EDIT:
case RESOURCE_CHANGED:
builder.setTrigger(LayoutEditorRenderResult.Trigger.RESOURCE_CHANGE);
break;
case EDIT:
case ADD_COMPONENTS:
case DELETE:
case DND_COMMIT:
case DND_END:
case DROP:
case RESIZE_END:
case RESIZE_COMMIT:
builder.setTrigger(LayoutEditorRenderResult.Trigger.EDIT);
break;
case REQUEST_RENDER:
builder.setTrigger(LayoutEditorRenderResult.Trigger.USER);
break;
case BUILD:
builder.setTrigger(LayoutEditorRenderResult.Trigger.BUILD);
break;
case CONFIGURATION_CHANGE:
case UPDATE_HIERARCHY:
break;
}
}
builder.setComponentCount((int) result.getRootViews().stream().flatMap(s -> Stream.concat(s.getChildren().stream(), Stream.of(s))).count());
RenderErrorModel errorModel = RenderErrorModelFactory.createErrorModel(result, null);
builder.setTotalIssueCount(errorModel.getSize());
if (errorModel.getSize() > 0) {
int errorCount = 0;
int fidelityWarningCount = 0;
for (RenderErrorModel.Issue issue : errorModel.getIssues()) {
if (HighlightSeverity.ERROR.equals(issue.getSeverity())) {
errorCount++;
} else if (issue.getSummary().startsWith("Layout fid")) {
fidelityWarningCount++;
}
}
builder.setErrorCount(errorCount).setFidelityWarningCount(fidelityWarningCount);
}
event.setRenderResult(builder.build());
});
}
use of com.android.tools.idea.rendering.errors.ui.RenderErrorModel in project android by JetBrains.
the class DesignSurface method updateErrors.
/**
* When we have render errors for a given result, kick off a background computation
* of the error panel HTML, which when done will update the UI thread
*/
private void updateErrors(@Nullable final RenderResult result) {
assert result != null && result.getLogger().hasProblems();
getErrorQueue().cancelAllUpdates();
getErrorQueue().queue(new Update("errors") {
@Override
public void run() {
// Look up *current* result; a newer one could be available
final RenderResult result = myScreenView != null ? myScreenView.getResult() : null;
if (result == null) {
return;
}
RenderErrorModel model = BuildSettings.getInstance(myProject).getBuildMode() != null && result.getLogger().hasErrors() ? STILL_BUILDING_ERROR_MODEL : RenderErrorModelFactory.createErrorModel(result, DataManager.getInstance().getDataContext(myErrorPanel));
myErrorPanel.setModel(model);
setShowErrorPanel(model.getSize() != 0);
}
@Override
public boolean canEat(Update update) {
return true;
}
});
}
use of com.android.tools.idea.rendering.errors.ui.RenderErrorModel in project intellij by bazelbuild.
the class BlazeRenderErrorContributorTest method testReportMissingClassDependencies.
@Test
public void testReportMissingClassDependencies() {
createTargetMapWithMissingClassDependency();
RenderErrorModel errorModel = createRenderErrorModelWithMissingClasses("com.google.example.independent.LibraryView", "com.google.example.independent.LibraryView2", "com.google.example.independent.Library2View", "com.google.example.dependent.LibraryView", "com.google.example.ResourceView");
RenderErrorModel.Issue missingClassDependenciesIssue = Iterables.getOnlyElement(errorModel.getIssues().stream().filter(issue -> issue.getSummary().equals(MISSING_CLASS_DEPENDENCIES_ERROR)).collect(Collectors.toList()));
assertThat(missingClassDependenciesIssue.getHtmlContent()).isEqualTo("<A HREF=\"file:///src/com/google/example/BUILD\">" + "//com/google/example:resources</A> " + "contains resource files that reference these classes:" + "<DL>" + "<DD>-&NBSP;" + "<A HREF=\"openClass:com.google.example.independent.Library2View\">" + "com.google.example.independent.Library2View</A> " + "from <A HREF=\"file:///src/com/google/example/BUILD\">" + "//com/google/example/independent:library2</A> " + "<DD>-&NBSP;" + "<A HREF=\"openClass:com.google.example.independent.LibraryView\">" + "com.google.example.independent.LibraryView</A> " + "from <A HREF=\"file:///src/com/google/example/BUILD\">" + "//com/google/example/independent:library</A> " + "<DD>-&NBSP;" + "<A HREF=\"openClass:com.google.example.independent.LibraryView2\">" + "com.google.example.independent.LibraryView2</A> " + "from <A HREF=\"file:///src/com/google/example/BUILD\">" + "//com/google/example/independent:library</A> " + "</DL>" + "Please fix your dependencies so that " + "<A HREF=\"file:///src/com/google/example/BUILD\">" + "//com/google/example:resources</A> " + "correctly depends on these classes, then " + "<A HREF=\"action:sync\">sync the project</A> and " + "<A HREF=\"refreshRender\">refresh the layout</A>." + "<BR/>" + "<BR/>" + "<B>NOTE: blaze can still build with the incorrect dependencies " + "due to the way it handles resources, " + "but the layout editor needs them to be correct.</B>");
}
use of com.android.tools.idea.rendering.errors.ui.RenderErrorModel in project intellij by bazelbuild.
the class BlazeRenderErrorContributorTest method testReportNonStandardAndroidManifestName.
@Test
public void testReportNonStandardAndroidManifestName() {
createTargetMapWithNonStandardAndroidManifestName();
RenderErrorModel errorModel = createRenderErrorModelWithBrokenClasses();
RenderErrorModel.Issue nonStandardManifestNameIssue = Iterables.getOnlyElement(errorModel.getIssues().stream().filter(issue -> issue.getSummary().equals(NON_STANDARD_MANIFEST_NAME_ERROR)).collect(Collectors.toList()));
assertThat(nonStandardManifestNameIssue.getHtmlContent()).isEqualTo("<A HREF=\"file:///src/com/google/example/main/BUILD\">" + "//com/google/example:main</A> " + "uses a non-standard name for the Android manifest: " + "<A HREF=\"file:///src/com/google/example/main/WeirdManifest.xml\">" + "WeirdManifest.xml</A>" + "<BR/>" + "Please rename it to AndroidManifest.xml, then " + "<A HREF=\"action:sync\">sync the project</A> and " + "<A HREF=\"refreshRender\">refresh the layout</A>.");
}
use of com.android.tools.idea.rendering.errors.ui.RenderErrorModel in project intellij by bazelbuild.
the class BlazeRenderErrorContributorTest method testNoIssuesIfNoErrors.
@Test
public void testNoIssuesIfNoErrors() {
PsiFile file = new MockPsiFile(new MockPsiManager(project));
file.putUserData(ModuleUtilCore.KEY_MODULE, module);
RenderResult result = RenderResult.createBlank(file);
RenderErrorModel errorModel = RenderErrorModelFactory.createErrorModel(result, null);
assertThat(errorModel.getIssues()).isEmpty();
}
Aggregations