Search in sources :

Example 6 with DaemonCodeAnalyzer

use of com.intellij.codeInsight.daemon.DaemonCodeAnalyzer in project intellij-community by JetBrains.

the class LanguageConsoleBuilder method build.

@NotNull
public LanguageConsoleView build(@NotNull Project project, @NotNull Language language) {
    final MyHelper helper = new MyHelper(project, language.getDisplayName() + " Console", language, psiFileFactory);
    GutteredLanguageConsole consoleView = new GutteredLanguageConsole(helper, gutterContentProvider);
    if (oneLineInput) {
        consoleView.getConsoleEditor().setOneLineMode(true);
    }
    if (executeActionHandler != null) {
        assert historyType != null;
        doInitAction(consoleView, executeActionHandler, historyType);
    }
    if (processInputStateKey != null) {
        assert executeActionHandler != null;
        if (PropertiesComponent.getInstance().getBoolean(processInputStateKey)) {
            executeActionHandler.myUseProcessStdIn = true;
            DaemonCodeAnalyzer daemonCodeAnalyzer = DaemonCodeAnalyzer.getInstance(consoleView.getProject());
            daemonCodeAnalyzer.setHighlightingEnabled(consoleView.getFile(), false);
        }
        consoleView.addCustomConsoleAction(new UseConsoleInputAction(processInputStateKey));
    }
    return consoleView;
}
Also used : DaemonCodeAnalyzer(com.intellij.codeInsight.daemon.DaemonCodeAnalyzer) NotNull(org.jetbrains.annotations.NotNull)

Example 7 with DaemonCodeAnalyzer

use of com.intellij.codeInsight.daemon.DaemonCodeAnalyzer in project intellij-community by JetBrains.

the class ShowErrorDescriptionHandler method invoke.

@Override
public void invoke(@NotNull Project project, @NotNull Editor editor, @NotNull PsiFile file) {
    int offset = editor.getCaretModel().getOffset();
    DaemonCodeAnalyzer codeAnalyzer = DaemonCodeAnalyzer.getInstance(project);
    HighlightInfo info = ((DaemonCodeAnalyzerImpl) codeAnalyzer).findHighlightByOffset(editor.getDocument(), offset, false);
    if (info != null) {
        DaemonTooltipUtil.showInfoTooltip(info, editor, editor.getCaretModel().getOffset(), myWidth, myRequestFocus);
    }
}
Also used : DaemonCodeAnalyzer(com.intellij.codeInsight.daemon.DaemonCodeAnalyzer)

Example 8 with DaemonCodeAnalyzer

use of com.intellij.codeInsight.daemon.DaemonCodeAnalyzer in project intellij-community by JetBrains.

the class ShowIntentionsPass method getActionsToShow.

public static void getActionsToShow(@NotNull final Editor hostEditor, @NotNull final PsiFile hostFile, @NotNull final IntentionsInfo intentions, int passIdToShowIntentionsFor) {
    final PsiElement psiElement = hostFile.findElementAt(hostEditor.getCaretModel().getOffset());
    LOG.assertTrue(psiElement == null || psiElement.isValid(), psiElement);
    int offset = hostEditor.getCaretModel().getOffset();
    final Project project = hostFile.getProject();
    List<HighlightInfo.IntentionActionDescriptor> fixes = getAvailableFixes(hostEditor, hostFile, passIdToShowIntentionsFor);
    final DaemonCodeAnalyzer codeAnalyzer = DaemonCodeAnalyzer.getInstance(project);
    final Document hostDocument = hostEditor.getDocument();
    HighlightInfo infoAtCursor = ((DaemonCodeAnalyzerImpl) codeAnalyzer).findHighlightByOffset(hostDocument, offset, true);
    if (infoAtCursor == null) {
        intentions.errorFixesToShow.addAll(fixes);
    } else {
        final boolean isError = infoAtCursor.getSeverity() == HighlightSeverity.ERROR;
        for (HighlightInfo.IntentionActionDescriptor fix : fixes) {
            if (fix.isError() && isError) {
                intentions.errorFixesToShow.add(fix);
            } else {
                intentions.inspectionFixesToShow.add(fix);
            }
        }
    }
    for (final IntentionAction action : IntentionManager.getInstance().getAvailableIntentionActions()) {
        Pair<PsiFile, Editor> place = ShowIntentionActionsHandler.chooseBetweenHostAndInjected(hostFile, hostEditor, (psiFile, editor) -> ShowIntentionActionsHandler.availableFor(psiFile, editor, action));
        if (place != null) {
            List<IntentionAction> enableDisableIntentionAction = new ArrayList<>();
            enableDisableIntentionAction.add(new IntentionHintComponent.EnableDisableIntentionAction(action));
            enableDisableIntentionAction.add(new IntentionHintComponent.EditIntentionSettingsAction(action));
            HighlightInfo.IntentionActionDescriptor descriptor = new HighlightInfo.IntentionActionDescriptor(action, enableDisableIntentionAction, null);
            if (!fixes.contains(descriptor)) {
                intentions.intentionsToShow.add(descriptor);
            }
        }
    }
    if (HighlightingLevelManager.getInstance(project).shouldInspect(hostFile)) {
        PsiElement intentionElement = psiElement;
        int intentionOffset = offset;
        if (psiElement instanceof PsiWhiteSpace && offset == psiElement.getTextRange().getStartOffset() && offset > 0) {
            final PsiElement prev = hostFile.findElementAt(offset - 1);
            if (prev != null && prev.isValid()) {
                intentionElement = prev;
                intentionOffset = offset - 1;
            }
        }
        if (intentionElement != null && intentionElement.getManager().isInProject(intentionElement)) {
            collectIntentionsFromDoNotShowLeveledInspections(project, hostFile, intentionElement, intentionOffset, intentions);
        }
    }
    final int line = hostDocument.getLineNumber(offset);
    MarkupModelEx model = (MarkupModelEx) DocumentMarkupModel.forDocument(hostDocument, project, true);
    List<RangeHighlighterEx> result = new ArrayList<>();
    Processor<RangeHighlighterEx> processor = Processors.cancelableCollectProcessor(result);
    model.processRangeHighlightersOverlappingWith(hostDocument.getLineStartOffset(line), hostDocument.getLineEndOffset(line), processor);
    GutterIntentionAction.addActions(hostEditor, intentions, project, result);
    boolean cleanup = appendCleanupCode(intentions.inspectionFixesToShow, hostFile);
    if (!cleanup) {
        appendCleanupCode(intentions.errorFixesToShow, hostFile);
    }
    EditorNotificationActions.collectDescriptorsForEditor(hostEditor, intentions.notificationActionsToShow);
    intentions.filterActions(hostFile);
}
Also used : ArrayList(java.util.ArrayList) Document(com.intellij.openapi.editor.Document) IntentionHintComponent(com.intellij.codeInsight.intention.impl.IntentionHintComponent) RangeHighlighterEx(com.intellij.openapi.editor.ex.RangeHighlighterEx) DaemonCodeAnalyzer(com.intellij.codeInsight.daemon.DaemonCodeAnalyzer) PsiFile(com.intellij.psi.PsiFile) PsiElement(com.intellij.psi.PsiElement) Project(com.intellij.openapi.project.Project) MarkupModelEx(com.intellij.openapi.editor.ex.MarkupModelEx) IntentionAction(com.intellij.codeInsight.intention.IntentionAction) Editor(com.intellij.openapi.editor.Editor) PsiWhiteSpace(com.intellij.psi.PsiWhiteSpace)

Example 9 with DaemonCodeAnalyzer

use of com.intellij.codeInsight.daemon.DaemonCodeAnalyzer in project intellij-community by JetBrains.

the class TogglePopupHintsAction method actionPerformed.

@Override
public void actionPerformed(AnActionEvent e) {
    PsiFile psiFile = getTargetFile(e.getDataContext());
    LOG.assertTrue(psiFile != null);
    Project project = e.getProject();
    LOG.assertTrue(project != null);
    DaemonCodeAnalyzer codeAnalyzer = DaemonCodeAnalyzer.getInstance(project);
    codeAnalyzer.setImportHintsEnabled(psiFile, !codeAnalyzer.isImportHintsEnabled(psiFile));
    DaemonListeners.getInstance(project).updateStatusBar();
}
Also used : Project(com.intellij.openapi.project.Project) DaemonCodeAnalyzer(com.intellij.codeInsight.daemon.DaemonCodeAnalyzer) PsiFile(com.intellij.psi.PsiFile)

Example 10 with DaemonCodeAnalyzer

use of com.intellij.codeInsight.daemon.DaemonCodeAnalyzer in project intellij-community by JetBrains.

the class InputExpressionDialog method updateContext.

void updateContext(Collection<Namespace> namespaces, Collection<Variable> variables) {
    final HistoryElement selectedItem = myModel.getSelectedItem();
    final HistoryElement newElement;
    if (selectedItem != null) {
        newElement = selectedItem.changeContext(namespaces, variables);
    } else {
        newElement = new HistoryElement(myDocument.getText(), variables, namespaces);
    }
    myModel.setSelectedItem(newElement);
    // FIXME
    if (myNamespaceCache == null) {
        myContextProvider.getNamespaceContext().setMap(asMap(namespaces));
    }
    final DaemonCodeAnalyzer analyzer = DaemonCodeAnalyzer.getInstance(myProject);
    analyzer.restart(myXPathFile);
}
Also used : HistoryElement(org.intellij.plugins.xpathView.HistoryElement) DaemonCodeAnalyzer(com.intellij.codeInsight.daemon.DaemonCodeAnalyzer)

Aggregations

DaemonCodeAnalyzer (com.intellij.codeInsight.daemon.DaemonCodeAnalyzer)12 Project (com.intellij.openapi.project.Project)5 PsiFile (com.intellij.psi.PsiFile)4 Document (com.intellij.openapi.editor.Document)2 Editor (com.intellij.openapi.editor.Editor)2 PsiElement (com.intellij.psi.PsiElement)2 DaemonCodeAnalyzerImpl (com.intellij.codeInsight.daemon.impl.DaemonCodeAnalyzerImpl)1 HighlightInfo (com.intellij.codeInsight.daemon.impl.HighlightInfo)1 IntentionAction (com.intellij.codeInsight.intention.IntentionAction)1 IntentionHintComponent (com.intellij.codeInsight.intention.impl.IntentionHintComponent)1 InspectionProfileImpl (com.intellij.codeInspection.ex.InspectionProfileImpl)1 InspectionProfileWrapper (com.intellij.codeInspection.ex.InspectionProfileWrapper)1 Language (com.intellij.lang.Language)1 AnAction (com.intellij.openapi.actionSystem.AnAction)1 Application (com.intellij.openapi.application.Application)1 HectorComponentPanel (com.intellij.openapi.editor.HectorComponentPanel)1 DocumentEx (com.intellij.openapi.editor.ex.DocumentEx)1 MarkupModelEx (com.intellij.openapi.editor.ex.MarkupModelEx)1 RangeHighlighterEx (com.intellij.openapi.editor.ex.RangeHighlighterEx)1 ProjectFileIndex (com.intellij.openapi.roots.ProjectFileIndex)1