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;
}
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);
}
}
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);
}
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();
}
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);
}
Aggregations