Search in sources :

Example 66 with Application

use of com.intellij.openapi.application.Application in project intellij-community by JetBrains.

the class PsiChangeHandler method updateChangesForDocument.

private void updateChangesForDocument(@NotNull final Document document) {
    ApplicationManager.getApplication().assertIsDispatchThread();
    if (myProject.isDisposed())
        return;
    List<Pair<PsiElement, Boolean>> toUpdate = changedElements.get(document);
    if (toUpdate == null) {
        // We may still need to rehighlight the file if there were changes inside highlighted ranges.
        if (UpdateHighlightersUtil.isWhitespaceOptimizationAllowed(document))
            return;
        // don't create PSI for files in other projects
        PsiElement file = PsiDocumentManager.getInstance(myProject).getCachedPsiFile(document);
        if (file == null)
            return;
        toUpdate = Collections.singletonList(Pair.create(file, true));
    }
    Application application = ApplicationManager.getApplication();
    final Editor editor = FileEditorManager.getInstance(myProject).getSelectedTextEditor();
    if (editor != null && !application.isUnitTestMode()) {
        application.invokeLater(() -> {
            if (!editor.isDisposed()) {
                EditorMarkupModel markupModel = (EditorMarkupModel) editor.getMarkupModel();
                PsiFile file = PsiDocumentManager.getInstance(myProject).getPsiFile(editor.getDocument());
                TrafficLightRenderer.setOrRefreshErrorStripeRenderer(markupModel, myProject, editor.getDocument(), file);
            }
        }, ModalityState.stateForComponent(editor.getComponent()), myProject.getDisposed());
    }
    for (Pair<PsiElement, Boolean> changedElement : toUpdate) {
        PsiElement element = changedElement.getFirst();
        Boolean whiteSpaceOptimizationAllowed = changedElement.getSecond();
        updateByChange(element, document, whiteSpaceOptimizationAllowed);
    }
    changedElements.remove(document);
}
Also used : Editor(com.intellij.openapi.editor.Editor) Application(com.intellij.openapi.application.Application) EditorMarkupModel(com.intellij.openapi.editor.ex.EditorMarkupModel) Pair(com.intellij.openapi.util.Pair)

Example 67 with Application

use of com.intellij.openapi.application.Application in project intellij-community by JetBrains.

the class Messages method setTestDialog.

@TestOnly
public static TestDialog setTestDialog(TestDialog newValue) {
    Application application = ApplicationManager.getApplication();
    if (application != null) {
        LOG.assertTrue(application.isUnitTestMode(), "This method is available for tests only");
    }
    TestDialog oldValue = ourTestImplementation;
    ourTestImplementation = newValue;
    return oldValue;
}
Also used : Application(com.intellij.openapi.application.Application)

Example 68 with Application

use of com.intellij.openapi.application.Application in project intellij-community by JetBrains.

the class Messages method setTestInputDialog.

@TestOnly
public static TestInputDialog setTestInputDialog(TestInputDialog newValue) {
    Application application = ApplicationManager.getApplication();
    if (application != null) {
        LOG.assertTrue(application.isUnitTestMode(), "This method is available for tests only");
    }
    TestInputDialog oldValue = ourTestInputImplementation;
    ourTestInputImplementation = newValue;
    return oldValue;
}
Also used : Application(com.intellij.openapi.application.Application)

Example 69 with Application

use of com.intellij.openapi.application.Application in project intellij-community by JetBrains.

the class FileInEditorProcessor method shouldNotify.

private boolean shouldNotify() {
    Application application = ApplicationManager.getApplication();
    if (application.isUnitTestMode() || application.isHeadlessEnvironment()) {
        return false;
    }
    EditorSettingsExternalizable.OptionSet editorOptions = EditorSettingsExternalizable.getInstance().getOptions();
    return editorOptions.SHOW_NOTIFICATION_AFTER_REFORMAT_CODE_ACTION && myEditor != null && !myProcessSelectedText;
}
Also used : Application(com.intellij.openapi.application.Application) EditorSettingsExternalizable(com.intellij.openapi.editor.ex.EditorSettingsExternalizable)

Example 70 with Application

use of com.intellij.openapi.application.Application in project intellij-community by JetBrains.

the class StatusBarUpdater method updateLater.

private void updateLater() {
    final Application application = ApplicationManager.getApplication();
    if (application.isUnitTestMode()) {
        myUpdateStatusRunnable.run();
    } else {
        updateStatusAlarm.cancelAllRequests();
        updateStatusAlarm.addRequest(myUpdateStatusRunnable, 100);
    }
}
Also used : Application(com.intellij.openapi.application.Application)

Aggregations

Application (com.intellij.openapi.application.Application)188 NotNull (org.jetbrains.annotations.NotNull)23 VirtualFile (com.intellij.openapi.vfs.VirtualFile)21 IOException (java.io.IOException)14 Project (com.intellij.openapi.project.Project)13 Nullable (org.jetbrains.annotations.Nullable)12 ProgressIndicator (com.intellij.openapi.progress.ProgressIndicator)9 ModalityState (com.intellij.openapi.application.ModalityState)8 Ref (com.intellij.openapi.util.Ref)7 ArrayList (java.util.ArrayList)7 List (java.util.List)6 ApplicationImpl (com.intellij.openapi.application.impl.ApplicationImpl)5 ApplicationManager (com.intellij.openapi.application.ApplicationManager)4 ApplicationEx (com.intellij.openapi.application.ex.ApplicationEx)4 Document (com.intellij.openapi.editor.Document)4 Module (com.intellij.openapi.module.Module)4 Computable (com.intellij.openapi.util.Computable)4 PsiFile (com.intellij.psi.PsiFile)4 File (java.io.File)4 Editor (com.intellij.openapi.editor.Editor)3