Search in sources :

Example 1 with DaemonCodeAnalyzerImpl

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

the class ShowIntentionActionsHandler method invoke.

@Override
public void invoke(@NotNull final Project project, @NotNull Editor editor, @NotNull PsiFile file) {
    PsiDocumentManager.getInstance(project).commitAllDocuments();
    if (editor instanceof EditorWindow) {
        editor = ((EditorWindow) editor).getDelegate();
        file = InjectedLanguageManager.getInstance(file.getProject()).getTopLevelFile(file);
    }
    final LookupEx lookup = LookupManager.getActiveLookup(editor);
    if (lookup != null) {
        lookup.showElementActions();
        return;
    }
    final DaemonCodeAnalyzerImpl codeAnalyzer = (DaemonCodeAnalyzerImpl) DaemonCodeAnalyzer.getInstance(project);
    letAutoImportComplete(editor, file, codeAnalyzer);
    ShowIntentionsPass.IntentionsInfo intentions = new ShowIntentionsPass.IntentionsInfo();
    ShowIntentionsPass.getActionsToShow(editor, file, intentions, -1);
    IntentionHintComponent hintComponent = codeAnalyzer.getLastIntentionHint();
    if (hintComponent != null) {
        IntentionHintComponent.PopupUpdateResult result = hintComponent.isForEditor(editor) ? hintComponent.updateActions(intentions) : IntentionHintComponent.PopupUpdateResult.HIDE_AND_RECREATE;
        if (result == IntentionHintComponent.PopupUpdateResult.HIDE_AND_RECREATE) {
            hintComponent.hide();
        }
    }
    if (HintManagerImpl.getInstanceImpl().performCurrentQuestionAction())
        return;
    //intentions check isWritable before modification: if (!file.isWritable()) return;
    TemplateState state = TemplateManagerImpl.getTemplateState(editor);
    if (state != null && !state.isFinished()) {
        return;
    }
    if (!intentions.isEmpty()) {
        IntentionHintComponent.showIntentionHint(project, file, editor, intentions, true);
    }
}
Also used : ShowIntentionsPass(com.intellij.codeInsight.daemon.impl.ShowIntentionsPass) DaemonCodeAnalyzerImpl(com.intellij.codeInsight.daemon.impl.DaemonCodeAnalyzerImpl) LookupEx(com.intellij.codeInsight.lookup.LookupEx) TemplateState(com.intellij.codeInsight.template.impl.TemplateState) EditorWindow(com.intellij.injected.editor.EditorWindow)

Example 2 with DaemonCodeAnalyzerImpl

use of com.intellij.codeInsight.daemon.impl.DaemonCodeAnalyzerImpl in project intellij-plugins by JetBrains.

the class FlexHighlightingTest method testDumbMode.

@JSTestOptions({ JSTestOption.WithFlexFacet, JSTestOption.WithGumboSdk })
@SuppressWarnings({ "ConstantConditions" })
public void testDumbMode() throws Exception {
    DumbServiceImpl.getInstance(getProject()).setDumb(true);
    ((DaemonCodeAnalyzerImpl) DaemonCodeAnalyzer.getInstance(getProject())).mustWaitForSmartMode(false, getTestRootDisposable());
    XmlNSDescriptor nsDescriptor;
    try {
        assertTrue(DumbService.isDumb(getProject()));
        configureByFile(getBasePath() + "/dumbMode.mxml");
        nsDescriptor = ((XmlFile) getFile()).getDocument().getRootTagNSDescriptor();
        assertTrue(nsDescriptor.toString(), nsDescriptor instanceof FlexMxmlNSDescriptor);
        doDoTest(true, true);
    } finally {
        DumbServiceImpl.getInstance(getProject()).setDumb(false);
    }
    nsDescriptor = ((XmlFile) getFile()).getDocument().getRootTagNSDescriptor();
    assertTrue(nsDescriptor.toString(), nsDescriptor instanceof FlexMxmlNSDescriptor);
    doDoTest(true, true);
}
Also used : XmlNSDescriptor(com.intellij.xml.XmlNSDescriptor) XmlFile(com.intellij.psi.xml.XmlFile) DaemonCodeAnalyzerImpl(com.intellij.codeInsight.daemon.impl.DaemonCodeAnalyzerImpl) FlexMxmlNSDescriptor(com.intellij.javascript.flex.mxml.schema.FlexMxmlNSDescriptor)

Example 3 with DaemonCodeAnalyzerImpl

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

the class DaemonAnalyzerTestCase method setUp.

@Override
protected void setUp() throws Exception {
    super.setUp();
    final LocalInspectionTool[] tools = configureLocalInspectionTools();
    InspectionsKt.configureInspections(tools, getProject(), getTestRootDisposable());
    DaemonCodeAnalyzerImpl daemonCodeAnalyzer = (DaemonCodeAnalyzerImpl) DaemonCodeAnalyzer.getInstance(getProject());
    daemonCodeAnalyzer.prepareForTest();
    final StartupManagerImpl startupManager = (StartupManagerImpl) StartupManagerEx.getInstanceEx(getProject());
    startupManager.runStartupActivities();
    startupManager.startCacheUpdate();
    startupManager.runPostStartupActivities();
    DaemonCodeAnalyzerSettings.getInstance().setImportHintEnabled(false);
    if (isStressTest()) {
        // hack to avoid slowdowns in PyExtensionFactory
        IntentionManager.getInstance().getAvailableIntentionActions();
        // to cache stuff
        PathManagerEx.getTestDataPath();
        // pre-load tons of classes
        ReferenceProvidersRegistry.getInstance();
        // zillion of Dom Sem classes
        InjectedLanguageManager.getInstance(getProject());
        // pile of annotator classes loads
        LanguageAnnotators.INSTANCE.allForLanguage(JavaLanguage.INSTANCE);
        LanguageAnnotators.INSTANCE.allForLanguage(StdLanguages.XML);
        ProblemHighlightFilter.EP_NAME.getExtensions();
        Extensions.getExtensions(ImplicitUsageProvider.EP_NAME);
        Extensions.getExtensions(XmlSchemaProvider.EP_NAME);
        Extensions.getExtensions(XmlFileNSInfoProvider.EP_NAME);
        Extensions.getExtensions(ExternalAnnotatorsFilter.EXTENSION_POINT_NAME);
        Extensions.getExtensions(IndexPatternBuilder.EP_NAME);
    }
}
Also used : StartupManagerImpl(com.intellij.ide.startup.impl.StartupManagerImpl) DaemonCodeAnalyzerImpl(com.intellij.codeInsight.daemon.impl.DaemonCodeAnalyzerImpl) LocalInspectionTool(com.intellij.codeInspection.LocalInspectionTool)

Example 4 with DaemonCodeAnalyzerImpl

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

the class DaemonAnalyzerTestCase method tearDown.

@Override
protected void tearDown() throws Exception {
    try {
        // return default value to avoid unnecessary save
        DaemonCodeAnalyzerSettings.getInstance().setImportHintEnabled(true);
        final Project project = getProject();
        if (project != null) {
            ((StartupManagerImpl) StartupManager.getInstance(project)).checkCleared();
            ((DaemonCodeAnalyzerImpl) DaemonCodeAnalyzer.getInstance(project)).cleanupAfterTest();
        }
    } finally {
        super.tearDown();
    }
//((VirtualFilePointerManagerImpl)VirtualFilePointerManager.getInstance()).assertPointersDisposed();
}
Also used : Project(com.intellij.openapi.project.Project) StartupManagerImpl(com.intellij.ide.startup.impl.StartupManagerImpl) DaemonCodeAnalyzerImpl(com.intellij.codeInsight.daemon.impl.DaemonCodeAnalyzerImpl)

Example 5 with DaemonCodeAnalyzerImpl

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

the class ShowErrorDescriptionAction method isEnabledForFile.

private static boolean isEnabledForFile(Project project, Editor editor, PsiFile file) {
    DaemonCodeAnalyzer codeAnalyzer = DaemonCodeAnalyzer.getInstance(project);
    HighlightInfo info = ((DaemonCodeAnalyzerImpl) codeAnalyzer).findHighlightByOffset(editor.getDocument(), editor.getCaretModel().getOffset(), false);
    return info != null && info.getDescription() != null;
}
Also used : DaemonCodeAnalyzer(com.intellij.codeInsight.daemon.DaemonCodeAnalyzer) HighlightInfo(com.intellij.codeInsight.daemon.impl.HighlightInfo) DaemonCodeAnalyzerImpl(com.intellij.codeInsight.daemon.impl.DaemonCodeAnalyzerImpl)

Aggregations

DaemonCodeAnalyzerImpl (com.intellij.codeInsight.daemon.impl.DaemonCodeAnalyzerImpl)7 HighlightInfo (com.intellij.codeInsight.daemon.impl.HighlightInfo)2 StartupManagerImpl (com.intellij.ide.startup.impl.StartupManagerImpl)2 DaemonCodeAnalyzer (com.intellij.codeInsight.daemon.DaemonCodeAnalyzer)1 ShowIntentionsPass (com.intellij.codeInsight.daemon.impl.ShowIntentionsPass)1 LookupEx (com.intellij.codeInsight.lookup.LookupEx)1 TemplateState (com.intellij.codeInsight.template.impl.TemplateState)1 LocalInspectionTool (com.intellij.codeInspection.LocalInspectionTool)1 EditorWindow (com.intellij.injected.editor.EditorWindow)1 FlexMxmlNSDescriptor (com.intellij.javascript.flex.mxml.schema.FlexMxmlNSDescriptor)1 Language (com.intellij.lang.Language)1 Annotator (com.intellij.lang.annotation.Annotator)1 Document (com.intellij.openapi.editor.Document)1 EditorEx (com.intellij.openapi.editor.ex.EditorEx)1 Project (com.intellij.openapi.project.Project)1 VirtualFile (com.intellij.openapi.vfs.VirtualFile)1 XmlFile (com.intellij.psi.xml.XmlFile)1 XmlNSDescriptor (com.intellij.xml.XmlNSDescriptor)1 GrImportStatement (org.jetbrains.plugins.groovy.lang.psi.api.toplevel.imports.GrImportStatement)1