Search in sources :

Example 1 with WolfTheProblemSolver

use of com.intellij.problems.WolfTheProblemSolver in project intellij-community by JetBrains.

the class CompilerTask method informWolf.

private void informWolf(final CompilerMessage message) {
    WolfTheProblemSolver wolf = WolfTheProblemSolver.getInstance(myProject);
    VirtualFile file = getVirtualFile(message);
    wolf.queue(file);
}
Also used : VirtualFile(com.intellij.openapi.vfs.VirtualFile) WolfTheProblemSolver(com.intellij.problems.WolfTheProblemSolver)

Example 2 with WolfTheProblemSolver

use of com.intellij.problems.WolfTheProblemSolver in project intellij-community by JetBrains.

the class GeneralHighlightingPass method reportErrorsToWolf.

private void reportErrorsToWolf() {
    // e.g. errors in evaluate expression
    if (!getFile().getViewProvider().isPhysical())
        return;
    Project project = getFile().getProject();
    // do not report problems in libraries
    if (!PsiManager.getInstance(project).isInProject(getFile()))
        return;
    VirtualFile file = getFile().getVirtualFile();
    if (file == null)
        return;
    List<Problem> problems = convertToProblems(getInfos(), file, myHasErrorElement);
    WolfTheProblemSolver wolf = WolfTheProblemSolver.getInstance(project);
    boolean hasErrors = DaemonCodeAnalyzerEx.hasErrors(project, getDocument());
    if (!hasErrors || isWholeFileHighlighting()) {
        wolf.reportProblems(file, problems);
    } else {
        wolf.weHaveGotProblems(file, problems);
    }
}
Also used : VirtualFile(com.intellij.openapi.vfs.VirtualFile) Project(com.intellij.openapi.project.Project) Problem(com.intellij.problems.Problem) WolfTheProblemSolver(com.intellij.problems.WolfTheProblemSolver)

Example 3 with WolfTheProblemSolver

use of com.intellij.problems.WolfTheProblemSolver in project intellij-community by JetBrains.

the class OutputParser method processJavacMessages.

private static void processJavacMessages(final List<String> javacMessages, final AntBuildMessageView messageView, final Project project) {
    if (javacMessages == null) {
        return;
    }
    final com.intellij.compiler.OutputParser outputParser = new JavacOutputParser(project);
    com.intellij.compiler.OutputParser.Callback callback = new com.intellij.compiler.OutputParser.Callback() {

        private int myIndex = -1;

        @Nullable
        public String getCurrentLine() {
            if (myIndex >= javacMessages.size()) {
                return null;
            }
            return javacMessages.get(myIndex);
        }

        public String getNextLine() {
            final int size = javacMessages.size();
            final int next = Math.min(myIndex + 1, javacMessages.size());
            myIndex = next;
            if (next >= size) {
                return null;
            }
            return javacMessages.get(next);
        }

        @Override
        public void pushBack(String line) {
            myIndex--;
        }

        public void message(final CompilerMessageCategory category, final String message, final String url, final int lineNum, final int columnNum) {
            StringTokenizer tokenizer = new StringTokenizer(message, "\n", false);
            final String[] strings = new String[tokenizer.countTokens()];
            //noinspection ForLoopThatDoesntUseLoopVariable
            for (int idx = 0; tokenizer.hasMoreTokens(); idx++) {
                strings[idx] = tokenizer.nextToken();
            }
            ApplicationManager.getApplication().runReadAction(() -> {
                VirtualFile file = url == null ? null : VirtualFileManager.getInstance().findFileByUrl(url);
                messageView.outputJavacMessage(convertCategory(category), strings, file, url, lineNum, columnNum);
                if (file != null && category == CompilerMessageCategory.ERROR) {
                    final WolfTheProblemSolver wolf = WolfTheProblemSolver.getInstance(project);
                    final Problem problem = wolf.convertToProblem(file, lineNum, columnNum, strings);
                    wolf.weHaveGotNonIgnorableProblems(file, Collections.singletonList(problem));
                }
            });
        }

        public void setProgressText(String text) {
        }

        public void fileProcessed(String path) {
        }

        public void fileGenerated(String path) {
        }
    };
    try {
        while (true) {
            if (!outputParser.processMessageLine(callback)) {
                break;
            }
        }
    } catch (Exception e) {
    //ignore
    }
}
Also used : CompilerMessageCategory(com.intellij.openapi.compiler.CompilerMessageCategory) VirtualFile(com.intellij.openapi.vfs.VirtualFile) WolfTheProblemSolver(com.intellij.problems.WolfTheProblemSolver) JavacOutputParser(com.intellij.compiler.impl.javaCompiler.javac.JavacOutputParser) StringTokenizer(com.intellij.util.text.StringTokenizer) Problem(com.intellij.problems.Problem) JavacOutputParser(com.intellij.compiler.impl.javaCompiler.javac.JavacOutputParser)

Example 4 with WolfTheProblemSolver

use of com.intellij.problems.WolfTheProblemSolver in project intellij-community by JetBrains.

the class AntBuildMessageView method outputError.

public void outputError(String error, int priority) {
    updateErrorAndWarningCounters(priority);
    final AntMessage message = createErrorMessage(priority, error);
    addCommand(new AddMessageCommand(message));
    WolfTheProblemSolver wolf = WolfTheProblemSolver.getInstance(myProject);
    wolf.queue(message.getFile());
}
Also used : WolfTheProblemSolver(com.intellij.problems.WolfTheProblemSolver)

Example 5 with WolfTheProblemSolver

use of com.intellij.problems.WolfTheProblemSolver 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

WolfTheProblemSolver (com.intellij.problems.WolfTheProblemSolver)7 VirtualFile (com.intellij.openapi.vfs.VirtualFile)3 Project (com.intellij.openapi.project.Project)2 Problem (com.intellij.problems.Problem)2 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