Search in sources :

Example 1 with TAG_RESOURCES_PREFIX

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();
}
Also used : AndroidSdkType(org.jetbrains.android.sdk.AndroidSdkType) ResourceHelper.isViewPackageNeeded(com.android.tools.idea.res.ResourceHelper.isViewPackageNeeded) HyperlinkEvent(javax.swing.event.HyperlinkEvent) ResourceResolver(com.android.ide.common.resources.ResourceResolver) XmlFile(com.intellij.psi.xml.XmlFile) AndroidPlatform(org.jetbrains.android.sdk.AndroidPlatform) HighlightSeverity(com.intellij.lang.annotation.HighlightSeverity) JavaSdk(com.intellij.openapi.projectRoots.JavaSdk) VisibleForTesting(com.android.annotations.VisibleForTesting) Matcher(java.util.regex.Matcher) RenderErrorPanel(com.android.tools.idea.rendering.errors.ui.RenderErrorPanel) Messages(com.intellij.openapi.ui.Messages) AttributeDefinition(org.jetbrains.android.dom.attrs.AttributeDefinition) Logger(com.intellij.openapi.diagnostic.Logger) Module(com.intellij.openapi.module.Module) LintUtils.editDistance(com.android.tools.lint.detector.api.LintUtils.editDistance) XmlTag(com.intellij.psi.xml.XmlTag) JpsJavaCompilerOptions(org.jetbrains.jps.model.java.compiler.JpsJavaCompilerOptions) AndroidModuleInfo(com.android.tools.idea.model.AndroidModuleInfo) AndroidSdks(com.android.tools.idea.sdk.AndroidSdks) IndexNotReadyException(com.intellij.openapi.project.IndexNotReadyException) GlobalSearchScope(com.intellij.psi.search.GlobalSearchScope) Sets(com.google.common.collect.Sets) IAndroidTarget(com.android.sdklib.IAndroidTarget) Nullable(org.jetbrains.annotations.Nullable) HTMLDocument(javax.swing.text.html.HTMLDocument) ModuleRootManager(com.intellij.openapi.roots.ModuleRootManager) ProjectJdkTable(com.intellij.openapi.projectRoots.ProjectJdkTable) LayoutLog(com.android.ide.common.rendering.api.LayoutLog) AttributeFormat(org.jetbrains.android.dom.attrs.AttributeFormat) AndroidSdkAdditionalData(org.jetbrains.android.sdk.AndroidSdkAdditionalData) ApplicationManager(com.intellij.openapi.application.ApplicationManager) ClassInheritorsSearch(com.intellij.psi.search.searches.ClassInheritorsSearch) Pattern(java.util.regex.Pattern) NotNull(org.jetbrains.annotations.NotNull) CompilerManager(com.intellij.openapi.compiler.CompilerManager) CopyPasteManager(com.intellij.openapi.ide.CopyPasteManager) Application(org.jetbrains.android.dom.manifest.Application) java.util(java.util) ShowSettingsUtil(com.intellij.openapi.options.ShowSettingsUtil) DataContext(com.intellij.openapi.actionSystem.DataContext) AndroidManifest(com.android.xml.AndroidManifest) SdkConstants(com.android.SdkConstants) JavaPsiFacade(com.intellij.psi.JavaPsiFacade) Manifest(org.jetbrains.android.dom.manifest.Manifest) TAG_STILL_BUILDING(com.android.tools.idea.rendering.RenderLogger.TAG_STILL_BUILDING) LintUtils.stripIdPrefix(com.android.tools.lint.detector.api.LintUtils.stripIdPrefix) Computable(com.intellij.openapi.util.Computable) JavaSdkVersion(com.intellij.openapi.projectRoots.JavaSdkVersion) EditorDesignSurface(com.android.tools.idea.ui.designer.EditorDesignSurface) JAVA_VERSION(com.intellij.openapi.util.SystemInfo.JAVA_VERSION) PsiClass(com.intellij.psi.PsiClass) Lists(com.google.common.collect.Lists) Density(com.android.resources.Density) RenderSessionImpl(com.android.layoutlib.bridge.impl.RenderSessionImpl) StringSelection(java.awt.datatransfer.StringSelection) Project(com.intellij.openapi.project.Project) PsiFile(com.intellij.psi.PsiFile) RenderErrorModel(com.android.tools.idea.rendering.errors.ui.RenderErrorModel) HyperlinkListener(javax.swing.event.HyperlinkListener) AndroidTargetData(org.jetbrains.android.sdk.AndroidTargetData) StdFileTypes(com.intellij.openapi.fileTypes.StdFileTypes) StringUtil(com.intellij.openapi.util.text.StringUtil) HtmlBuilder(com.android.utils.HtmlBuilder) JavacConfiguration(com.intellij.compiler.impl.javaCompiler.javac.JavacConfiguration) Throwables(com.google.common.base.Throwables) AttributeDefinitions(org.jetbrains.android.dom.attrs.AttributeDefinitions) HTMLFrameHyperlinkEvent(javax.swing.text.html.HTMLFrameHyperlinkEvent) AndroidFacet(org.jetbrains.android.facet.AndroidFacet) IOException(java.io.IOException) ClasspathEditor(com.intellij.openapi.roots.ui.configuration.ClasspathEditor) Sdk(com.intellij.openapi.projectRoots.Sdk) ModulesConfigurator(com.intellij.openapi.roots.ui.configuration.ModulesConfigurator) SystemInfo(com.intellij.openapi.util.SystemInfo) File(java.io.File) ExtensionPointName(com.intellij.openapi.extensions.ExtensionPointName) TAG_RESOURCES_RESOLVE_THEME_ATTR(com.android.ide.common.rendering.api.LayoutLog.TAG_RESOURCES_RESOLVE_THEME_ATTR) WolfTheProblemSolver(com.intellij.problems.WolfTheProblemSolver) ProjectStructureConfigurable(com.intellij.openapi.roots.ui.configuration.ProjectStructureConfigurable) javax.swing(javax.swing) TAG_RESOURCES_PREFIX(com.android.ide.common.rendering.api.LayoutLog.TAG_RESOURCES_PREFIX) Project(com.intellij.openapi.project.Project) HtmlBuilder(com.android.utils.HtmlBuilder) Module(com.intellij.openapi.module.Module) WolfTheProblemSolver(com.intellij.problems.WolfTheProblemSolver)

Aggregations

SdkConstants (com.android.SdkConstants)1 VisibleForTesting (com.android.annotations.VisibleForTesting)1 LayoutLog (com.android.ide.common.rendering.api.LayoutLog)1 TAG_RESOURCES_PREFIX (com.android.ide.common.rendering.api.LayoutLog.TAG_RESOURCES_PREFIX)1 TAG_RESOURCES_RESOLVE_THEME_ATTR (com.android.ide.common.rendering.api.LayoutLog.TAG_RESOURCES_RESOLVE_THEME_ATTR)1 ResourceResolver (com.android.ide.common.resources.ResourceResolver)1 RenderSessionImpl (com.android.layoutlib.bridge.impl.RenderSessionImpl)1 Density (com.android.resources.Density)1 IAndroidTarget (com.android.sdklib.IAndroidTarget)1 AndroidModuleInfo (com.android.tools.idea.model.AndroidModuleInfo)1 TAG_STILL_BUILDING (com.android.tools.idea.rendering.RenderLogger.TAG_STILL_BUILDING)1 RenderErrorModel (com.android.tools.idea.rendering.errors.ui.RenderErrorModel)1 RenderErrorPanel (com.android.tools.idea.rendering.errors.ui.RenderErrorPanel)1 ResourceHelper.isViewPackageNeeded (com.android.tools.idea.res.ResourceHelper.isViewPackageNeeded)1 AndroidSdks (com.android.tools.idea.sdk.AndroidSdks)1 EditorDesignSurface (com.android.tools.idea.ui.designer.EditorDesignSurface)1 LintUtils.editDistance (com.android.tools.lint.detector.api.LintUtils.editDistance)1 LintUtils.stripIdPrefix (com.android.tools.lint.detector.api.LintUtils.stripIdPrefix)1 HtmlBuilder (com.android.utils.HtmlBuilder)1 AndroidManifest (com.android.xml.AndroidManifest)1