@NotNull @Override protected void invokeDialog(AnActionEvent e,Project project, PsiDirectory dir) { BaseDialog dialog = new BaseDialog("请输入基类前缀:",project); dialog.show(); if (dialog.getExitCode() == DialogWrapper.OK_EXIT_CODE) { String prefix = dialog.getClassNamePrefix(); if(prefix != null && !prefix.isEmpty()){ Application application = ApplicationManager.getApplication(); application.runWriteAction(() -> { PsiElement createdElement = createProjectDir(dir,prefix); final IdeView view = e.getData(LangDataKeys.IDE_VIEW); if(view != null&&createdElement != null){ view.selectElement(createdElement); } }); } } }
public void scheduleCourseListUpdate(Application application) { if (!checkNeeded()) { return; } application.getMessageBus().connect(application).subscribe(AppLifecycleListener.TOPIC, new AppLifecycleListener() { @Override public void appFrameCreated(String[] commandLineArgs, @NotNull Ref<Boolean> willOpenProject) { long timeToNextCheck = StudySettings.getInstance().getLastTimeChecked() + CHECK_INTERVAL - System.currentTimeMillis(); if (timeToNextCheck <= 0) { myCheckRunnable.run(); } else { queueNextCheck(timeToNextCheck); } } }); }
@NotNull @Override protected void invokeDialog(AnActionEvent e,Project project, PsiDirectory dir) { BaseDialog dialog = new BaseDialog("请输入基类前缀:",project); dialog.show(); if (dialog.getExitCode() == DialogWrapper.OK_EXIT_CODE) { String prefix = dialog.getClassNamePrefix(); if(prefix != null && !prefix.isEmpty()){ Application application = ApplicationManager.getApplication(); application.runWriteAction(() -> { PsiElement[] elements = createProjectDir(dir,prefix); final IdeView view = e.getData(LangDataKeys.IDE_VIEW); if(view != null){ for (PsiElement element : elements) { view.selectElement(element); } } }); } } }
@Override public void refreshIoFiles(@NotNull Iterable<File> files, boolean async, boolean recursive, @Nullable Runnable onFinish) { final VirtualFileManagerEx manager = (VirtualFileManagerEx)VirtualFileManager.getInstance(); Application app = ApplicationManager.getApplication(); boolean fireCommonRefreshSession = app.isDispatchThread() || app.isWriteAccessAllowed(); if (fireCommonRefreshSession) manager.fireBeforeRefreshStart(false); try { List<VirtualFile> filesToRefresh = new ArrayList<VirtualFile>(); for (File file : files) { final VirtualFile virtualFile = refreshAndFindFileByIoFile(file); if (virtualFile != null) { filesToRefresh.add(virtualFile); } } RefreshQueue.getInstance().refresh(async, recursive, onFinish, filesToRefresh); } finally { if (fireCommonRefreshSession) manager.fireAfterRefreshFinish(false); } }
public static void showError(final Project project, final String message, final boolean error) { final Application application = ApplicationManager.getApplication(); if (application.isUnitTestMode()) { return; } final String title = VcsBundle.message("patch.apply.dialog.title"); final Runnable messageShower = new Runnable() { @Override public void run() { if (error) { Messages.showErrorDialog(project, message, title); } else { Messages.showInfoMessage(project, message, title); } } }; WaitForProgressToShow.runOrInvokeLaterAboveProgress(new Runnable() { @Override public void run() { messageShower.run(); } }, null, project); }
public final void actionPerformed(final AnActionEvent anActionEvent) { logger.debug("entered actionPerformed"); // we're being called on the Swing event dispatch thread. Spin off another thread to do the // rearranging and let Swing's thread go. // Thread t = new Thread(new Runnable() { // public void run() // { // //To change body of implemented methods use Options | File Templates. final Application application = ApplicationManager.getApplication(); application.runWriteAction(new RearrangeIt(anActionEvent.getDataContext())); // } // }, "RearrangerThread"); // t.start(); // new RearrangeIt(anActionEvent.getDataContext()).run(); }
public LocalFileSystemImpl(@NotNull ManagingFS managingFS) { myManagingFS = managingFS; myWatcher = new FileWatcher(myManagingFS); if (myWatcher.isOperational()) { final int PERIOD = 1000; Runnable runnable = new Runnable() { public void run() { final Application application = ApplicationManager.getApplication(); if (application == null || application.isDisposed()) return; storeRefreshStatusToFiles(); JobScheduler.getScheduler().schedule(this, PERIOD, TimeUnit.MILLISECONDS); } }; JobScheduler.getScheduler().schedule(runnable, PERIOD, TimeUnit.MILLISECONDS); } }
@NotNull @Override protected PsiElement[] create(String componentName, PsiDirectory directory) { List<PsiElement> elements = new LinkedList<>(); Application application = ApplicationManager.getApplication(); application.runWriteAction(() -> { PsiDirectory componentDirectory = directory.createSubdirectory(componentName); elements.add(componentDirectory); String[] fileNames = getRequiredFileNames(componentName); for (String fileName : fileNames) { PsiFile file = componentDirectory.createFile(fileName); elements.add(file); } }); return elements.toArray(new PsiElement[elements.size()]); }
@Override public void beforeApplicationLoaded(@NotNull Application application, @NotNull String configPath) { // Invoke later is necessary to make showWarning work. // setFrameIcon is called to change icon of welcome screen and it is unclear // if invoke later can be invoked to early (in the future) so setFrameIcon // is called again on ClassicIcon#projectOpened just in case. // Important here is only setDockIcon and this would work without invoke later also. application.invokeLater(new Runnable() { @Override public void run() { if (SystemInfo.isMac) { setDockIcon(); } else { ClassicIcon.setFrameIcon(null); } } }); }
private void setUpFileWatcher() { final Application application = ApplicationManager.getApplication(); if (application.isDisposeInProgress() || !myWatcher.isOperational()) return; application.assertReadAccessAllowed(); synchronized (myLock) { final WatchRequestImpl[] watchRequests = normalizeRootsForRefresh(); final List<String> myRecursiveRoots = new ArrayList<String>(); final List<String> myFlatRoots = new ArrayList<String>(); for (WatchRequestImpl watchRequest : watchRequests) { if (watchRequest.isToWatchRecursively()) { myRecursiveRoots.add(watchRequest.myFSRootPath); } else { myFlatRoots.add(watchRequest.myFSRootPath); } } myWatcher.setWatchRoots(myRecursiveRoots, myFlatRoots); } }
/** * Get the value of an attribute in the {@link com.intellij.psi.xml.XmlFile} safely (meaning it will acquire the read lock first). */ @Nullable public static String getRootTagAttributeSafely(@NotNull final XmlFile file, @NotNull final String attribute, @Nullable final String namespace) { Application application = ApplicationManager.getApplication(); if (!application.isReadAccessAllowed()) { return application.runReadAction(new Computable<String>() { @Nullable @Override public String compute() { return getRootTagAttributeSafely(file, attribute, namespace); } }); } else { XmlTag tag = file.getRootTag(); if (tag != null) { XmlAttribute attr = namespace != null ? tag.getAttribute(attribute, namespace) : tag.getAttribute(attribute); if (attr != null) { return attr.getValue(); } } return null; } }
public static void run(final Project project, final Runnable action) { final ProjectLevelVcsManager plVcsManager = ProjectLevelVcsManager.getInstance(project); plVcsManager.startBackgroundVcsOperation(); try { action.run(); } finally { final Application application = ApplicationManager.getApplication(); if (application.isDispatchThread()) { application.executeOnPooledThread(new Runnable() { public void run() { plVcsManager.stopBackgroundVcsOperation(); } }); } else { plVcsManager.stopBackgroundVcsOperation(); } } }
@Override public void doFix(@NotNull final Project project, ProblemDescriptor descriptor) { final PsiElement constant = descriptor.getPsiElement(); final Application application = ApplicationManager.getApplication(); application.invokeLater(new Runnable() { @Override public void run() { if (!constant.isValid()) return; final JavaRefactoringActionHandlerFactory factory = JavaRefactoringActionHandlerFactory.getInstance(); final RefactoringActionHandler introduceHandler = factory.createIntroduceConstantHandler(); final DataManager dataManager = DataManager.getInstance(); final DataContext dataContext = dataManager.getDataContext(); introduceHandler.invoke(project, new PsiElement[]{constant}, dataContext); } }, project.getDisposed()); }
@NotNull public static IdeFocusManager getGlobalInstance() { IdeFocusManager fm = null; Application app = ApplicationManager.getApplication(); if (app != null && app.hasComponent(IdeFocusManager.class)) { fm = app.getComponent(IdeFocusManager.class); } if (fm == null) { // happens when app is semi-initialized (e.g. when IDEA server dialog is shown) fm = PassThroughIdeFocusManager.getInstance(); } return fm; }
private static void show(final Project project, final String message, final MessageType type, final boolean showOverChangesView, @Nullable final NamedRunnable[] notificationListener) { final Application application = ApplicationManager.getApplication(); if (application.isHeadlessEnvironment()) return; final Runnable showErrorAction = new Runnable() { public void run() { new VcsBalloonProblemNotifier(project, message, type, showOverChangesView, notificationListener).run(); } }; if (application.isDispatchThread()) { showErrorAction.run(); } else { application.invokeLater(showErrorAction); } }
@NotNull @Override public NamedNodeMap getAttributes() { Application application = ApplicationManager.getApplication(); if (!application.isReadAccessAllowed()) { return application.runReadAction(new Computable<NamedNodeMap>() { @Override public NamedNodeMap compute() { return getAttributes(); } }); } if (myAttributes == null) { XmlAttribute[] attributes = myTag.getAttributes(); if (attributes.length == 0) { myAttributes = EMPTY_ATTRIBUTES; } else { myAttributes = new DomNamedNodeMap(this, attributes); } } return myAttributes; }
public void clear() { final List<MyNotification> notifications; synchronized (myLock) { notifications = new ArrayList<MyNotification>(myState.values()); myState.clear(); } final Application application = ApplicationManager.getApplication(); final Runnable runnable = new Runnable() { public void run() { for (MyNotification notification : notifications) { notification.expire(); } } }; if (application.isDispatchThread()) { runnable.run(); } else { application.invokeLater(runnable, ModalityState.NON_MODAL, myProject.getDisposed()); } }
private static void checkCanPaint(Graphics g) { if (UIUtil.isPrinting(g)) return; /* wtf?? if (!isDisplayable()) { LOG.assertTrue(false, logSwingPath()); } */ final Application application = ApplicationManager.getApplication(); if (application != null) { application.assertIsDispatchThread(); } else if (!SwingUtilities.isEventDispatchThread()) { throw new RuntimeException(Thread.currentThread().toString()); } }
private void applyModifiersFromRegistry() { Application app = ApplicationManager.getApplication(); if (app != null && app.isUnitTestMode()) { return; } Set<String> vksSet = new THashSet<String>(); ContainerUtil.addAll(vksSet, getModifierRegistryValue().split(" ")); myModifierVks.clear(); int mask = getModifierMask(vksSet); myModifierVks.addAll(getModifiersVKs(mask)); reassignActionShortcut(SWITCH_UP, mask, KeyEvent.VK_UP); reassignActionShortcut(SWITCH_DOWN, mask, KeyEvent.VK_DOWN); reassignActionShortcut(SWITCH_LEFT, mask, KeyEvent.VK_LEFT); reassignActionShortcut(SWITCH_RIGHT, mask, KeyEvent.VK_RIGHT); reassignActionShortcut(SWITCH_APPLY, mask, KeyEvent.VK_ENTER); }
/** * Attach this path to a {@link DynamicWizard}, linking it to that wizard's state. */ @Override public final void attachToWizard(@NotNull DynamicWizard wizard) { Application application = ApplicationManager.getApplication(); if (application != null && !application.isUnitTestMode()) { application.assertIsDispatchThread(); } myWizard = wizard; myUpdateQueue = wizard.getUpdateQueue(); Map<String, Object> myCurrentValues = myState.flatten(); myState = new ScopedStateStore(ScopedStateStore.Scope.PATH, myWizard.getState(), this); for (String keyName : myCurrentValues.keySet()) { myState.put(myState.createKey(keyName, Object.class), myCurrentValues.get(keyName)); } init(); myIsInitialized = true; }
private void updateActions(boolean now, final boolean transparentOnly, final boolean forced) { final Runnable updateRunnable = new MyUpdateRunnable(this, transparentOnly, forced); final Application app = ApplicationManager.getApplication(); if (now || app.isUnitTestMode()) { updateRunnable.run(); } else { final IdeFocusManager fm = IdeFocusManager.getInstance(null); if (!app.isHeadlessEnvironment()) { if (app.isDispatchThread() && myComponent.isShowing()) { fm.doWhenFocusSettlesDown(updateRunnable); } else { UiNotifyConnector.doWhenFirstShown(myComponent, new Runnable() { @Override public void run() { fm.doWhenFocusSettlesDown(updateRunnable); } }); } } } }
@Override public void projectClosed() { final Application app = ApplicationManager.getApplication(); Runnable cleanupInspectionProfilesRunnable = new Runnable() { @Override public void run() { for (InspectionProfileWrapper wrapper : myName2Profile.values()) { wrapper.cleanup(myProject); } fireProfilesShutdown(); } }; if (app.isUnitTestMode() || app.isHeadlessEnvironment()) { cleanupInspectionProfilesRunnable.run(); } else { app.executeOnPooledThread(cleanupInspectionProfilesRunnable); } }
@Nullable public static <T> T getService(@NotNull Module module, @NotNull Class<T> serviceClass) { //noinspection unchecked T instance = (T)module.getPicoContainer().getComponentInstance(serviceClass.getName()); if (instance == null) { instance = module.getComponent(serviceClass); if (instance != null) { Application app = ApplicationManager.getApplication(); String message = serviceClass.getName() + " requested as a service, but it is a component - convert it to a service or change call to module.getComponent()"; if (app.isUnitTestMode()) { LOG.error(message); } else { LOG.warn(message); } } } return instance; }
@Nullable private static <T> T doGetService(@NotNull ComponentManager componentManager, @NotNull Class<T> serviceClass) { @SuppressWarnings("unchecked") T instance = (T)componentManager.getPicoContainer().getComponentInstance(serviceClass.getName()); if (instance == null) { instance = componentManager.getComponent(serviceClass); if (instance != null) { Application app = ApplicationManager.getApplication(); String message = serviceClass.getName() + " requested as a service, but it is a component - convert it to a service or change call to " + (componentManager == app ? "ApplicationManager.getApplication().getComponent()" : "project.getComponent()"); if (app.isUnitTestMode()) { LOG.error(message); } else { LOG.warn(message); } } } return instance; }
@NotNull public static IdeaPluginDescriptorImpl[] loadDescriptors(@Nullable StartupProgress progress, @NotNull List<String> errors) { if (ClassUtilCore.isLoadingOfExternalPluginsDisabled()) { return IdeaPluginDescriptorImpl.EMPTY_ARRAY; } final List<IdeaPluginDescriptorImpl> result = new ArrayList<IdeaPluginDescriptorImpl>(); int pluginsCount = countPlugins(PathManager.getPluginsPath()) + countPlugins(PathManager.getPreInstalledPluginsPath()); loadDescriptors(PathManager.getPluginsPath(), result, progress, pluginsCount); Application application = ApplicationManager.getApplication(); boolean fromSources = false; if (application == null || !application.isUnitTestMode()) { int size = result.size(); loadDescriptors(PathManager.getPreInstalledPluginsPath(), result, progress, pluginsCount); fromSources = size == result.size(); } loadDescriptorsFromProperty(result); loadDescriptorsFromClassPath(result, getClassLoaderUrls(), fromSources ? progress : null); return topoSortPlugins(result, errors); }
public void dispose() { super.dispose(); addToInvokeLater(new Runnable() { public void run() { disconnectListeners(); if (!myRunningTestNodes.isEmpty()) { Application application = ApplicationManager.getApplication(); if (!application.isHeadlessEnvironment() && !application.isUnitTestMode()) { logProblem("Not all events were processed!"); } } myRunningTestNodes.clear(); myNodeByIdMap.clear(); } }); }
@NotNull private static String getUrl(@NotNull IdeaPluginDescriptor descriptor, @Nullable String host, @Nullable BuildNumber buildNumber) throws URISyntaxException, MalformedURLException { if (host != null && descriptor instanceof PluginNode) { String url = ((PluginNode)descriptor).getDownloadUrl(); return new URI(url).isAbsolute() ? url : new URL(new URL(host), url).toExternalForm(); } else { Application app = ApplicationManager.getApplication(); ApplicationInfoEx appInfo = ApplicationInfoImpl.getShadowInstance(); String buildNumberAsString = buildNumber != null ? buildNumber.asString() : app != null ? ApplicationInfo.getInstance().getApiVersion() : appInfo.getBuild().asString(); String uuid = app != null ? UpdateChecker.getInstallationUID(PropertiesComponent.getInstance()) : UUID.randomUUID().toString(); URIBuilder uriBuilder = new URIBuilder(appInfo.getPluginsDownloadUrl()); uriBuilder.addParameter("action", "download"); uriBuilder.addParameter("id", descriptor.getPluginId().getIdString()); uriBuilder.addParameter("build", buildNumberAsString); uriBuilder.addParameter("uuid", uuid); return uriBuilder.build().toString(); } }
@Override public void waitForSmartMode() { if (!isDumb()) { return; } final Application application = ApplicationManager.getApplication(); if (application.isReadAccessAllowed() || application.isDispatchThread()) { throw new AssertionError("Don't invoke waitForSmartMode from inside read action in dumb mode"); } final Semaphore semaphore = new Semaphore(); semaphore.down(); runWhenSmart(new Runnable() { @Override public void run() { semaphore.up(); } }); while (true) { if (semaphore.waitFor(50)) { return; } ProgressManager.checkCanceled(); } }
@Nullable public static VirtualFile findValidParentUnderReadAction(final FilePath file) { if (file.getVirtualFile() != null) return file.getVirtualFile(); final Computable<VirtualFile> computable = new Computable<VirtualFile>() { @Override public VirtualFile compute() { return findValidParent(file); } }; final Application application = ApplicationManager.getApplication(); if (application.isReadAccessAllowed()) { return computable.compute(); } else { return application.runReadAction(computable); } }
public static VirtualFile waitForTheFile(final String path) { final VirtualFile[] file = new VirtualFile[1]; final Application app = ApplicationManager.getApplication(); Runnable action = new Runnable() { @Override public void run() { app.runWriteAction(new Runnable() { @Override public void run() { file[0] = LocalFileSystem.getInstance().refreshAndFindFileByPath(path); } }); } }; if (app.isDispatchThread()) { action.run(); } else { app.invokeAndWait(action, ModalityState.defaultModalityState()); } return file[0]; }
@Override public boolean isSoftWrappingEnabled() { if (!myUseSoftWraps || myEditor.isOneLineMode() || myEditor.isPurePaintingMode()) { return false; } // We check that current thread is EDT because attempt to retrieve information about visible area width may fail otherwise Application application = ApplicationManager.getApplication(); Thread lastEdt = myLastEdt.get(); Thread currentThread = Thread.currentThread(); if (lastEdt != currentThread) { if (application.isDispatchThread()) { myLastEdt = new SoftReference<Thread>(currentThread); } else { myLastEdt = new SoftReference<Thread>(null); return false; } } if (application.isUnitTestMode()) return true; Rectangle visibleArea = myEditor.getScrollingModel().getVisibleArea(); return visibleArea.width > 0 && visibleArea.height > 0; }
public void setPreviewText(@Nonnull String text) { final CommandProcessor processor = CommandProcessor.getInstance(); processor.executeCommand(null, () -> { final Application application = ApplicationManager.getApplication(); application.runWriteAction(() -> { previewDocument.replaceString(INITIAL_OFFSET, previewDocument.getTextLength(), text); final int textLength = previewDocument.getTextLength(); final CaretModel caret = previewEditor.getCaretModel(); if (caret.getOffset() >= textLength) { caret.moveToOffset(textLength); } }); }, null, null); }
public void setJson(@NotNull String json) { final CommandProcessor processor = CommandProcessor.getInstance(); processor.executeCommand(project, () -> { final Application application = ApplicationManager.getApplication(); application.runWriteAction(() -> { jsonDocument.replaceString(INITIAL_OFFSET, jsonDocument.getTextLength(), json); final int textLength = jsonDocument.getTextLength(); final CaretModel caret = jsonEditor.getCaretModel(); if (caret.getOffset() >= textLength) { caret.moveToOffset(textLength); } }); }, null, null); }
@Nonnull @CheckReturnValue protected Application getApplication() { if (fixture == null) { throw new AssertionError("getApplication() must call after setUp()"); } return ApplicationManager.getApplication(); }
public static void generateFromStudentCourse(Project project, Course course) { StudyTaskManager.getInstance(project).setCourse(course); course.setCourseMode(CCUtils.COURSE_MODE); final VirtualFile baseDir = project.getBaseDir(); final Application application = ApplicationManager.getApplication(); application.invokeAndWait(() -> application.runWriteAction(() -> { final VirtualFile[] children = baseDir.getChildren(); for (VirtualFile child : children) { StudyUtils.deleteFile(child); } StudyGenerator.createCourse(course, baseDir); })); baseDir.refresh(false, true); int index = 1; int taskIndex = 1; for (Lesson lesson : course.getLessons()) { final VirtualFile lessonDir = project.getBaseDir().findChild(EduNames.LESSON + String.valueOf(index)); lesson.setIndex(index); if (lessonDir == null) continue; for (Task task : lesson.getTaskList()) { final VirtualFile taskDir = lessonDir.findChild(EduNames.TASK + String.valueOf(taskIndex)); task.setIndex(taskIndex); task.setLesson(lesson); if (taskDir == null) continue; for (final Map.Entry<String, TaskFile> entry : task.getTaskFiles().entrySet()) { application.invokeAndWait(() -> application.runWriteAction(() -> createAnswerFile(project, taskDir, entry))); } taskIndex += 1; } index += 1; taskIndex = 1; } course.initCourse(true); application.invokeAndWait(() -> StudyUtils.registerStudyToolWindow(course, project)); synchronize(project); }
private void hotSwapSessions( final List<DebuggerSession> sessions ) { HotSwapProgressImpl findClassesProgress = new HotSwapProgressImpl( getIjProject() ); ApplicationManager.getApplication().executeOnPooledThread( () -> { final Map<DebuggerSession, Map<String, HotSwapFile>> modifiedClasses = scanForModifiedClassesWithProgress( sessions, findClassesProgress ); final Application application = ApplicationManager.getApplication(); if( modifiedClasses.isEmpty() ) { final String message = DebuggerBundle.message( "status.hotswap.uptodate" ); NotificationGroup.toolWindowGroup( "HotSwap", ToolWindowId.DEBUG ).createNotification( message, NotificationType.INFORMATION ).notify( getIjProject() ); return; } application.invokeLater( () -> { if( !modifiedClasses.isEmpty() ) { final HotSwapProgressImpl progress = new HotSwapProgressImpl( getIjProject() ); if( modifiedClasses.keySet().size() == 1 ) { //noinspection ConstantConditions progress.setSessionForActions( ContainerUtil.getFirstItem( modifiedClasses.keySet() ) ); } application.executeOnPooledThread( () -> reloadModifiedClasses( modifiedClasses, progress ) ); } }, ModalityState.NON_MODAL ); } ); }
@Override @Nullable public Position getPosition(@NonNull final Node node) { Application application = ApplicationManager.getApplication(); if (application.isReadAccessAllowed()) { return getPositionImmediate(node); } return application.runReadAction(new Computable<Position>() { @Override @Nullable public Position compute() { return getPositionImmediate(node); } }); }
private void askUserToDisablePlugins(Collection<IdeaPluginDescriptor> conflictingPlugins) { final String text = formatMessage(conflictingPlugins); NotificationGroup ng = NotificationGroup.balloonGroup("Conflicting Plugins"); ng.createNotification(PLUGIN_NAME, text, NotificationType.WARNING, (notification, event) -> { if (event.getEventType() == HyperlinkEvent.EventType.ACTIVATED) { for (IdeaPluginDescriptor foreignPlugin : conflictingPlugins) { PluginManager.disablePlugin(foreignPlugin.getPluginId().toString()); } Application application = ApplicationManager.getApplication(); application.restart(); } }).notify(project); }
/** * must be called from within an IDEA read-action thread. * * @param project * @param document * @param psiFile */ void buildLiveRearrangerData(final Project project, final Document document, final PsiFile psiFile, final int cursorOffset) { /** * Per instructions from IntelliJ, we have to commit any changes to the document to the Psi * tree. */ final PsiDocumentManager documentManager = PsiDocumentManager.getInstance(project); documentManager.commitDocument(document); final RearrangerSettings settings = new RearrangerSettings(); // use default settings with no rules settings.setAskBeforeRearranging(true); final Runnable task = new Runnable() { public void run() { logger.debug("liveRearrangeDocument task started"); liveRearrangeDocument(project, psiFile, settings, document, cursorOffset); } }; Thread t = new Thread(new Runnable() { public void run() { logger.debug("started thread " + Thread.currentThread().getName()); final Application application = ApplicationManager.getApplication(); application.runReadAction(new Runnable() { public void run() { logger.debug("enter application.runReadAction() on thread " + Thread.currentThread().getName()); task.run(); logger.debug("exit application.runReadAction() on thread " + Thread.currentThread().getName()); }}); } }, "Live Rearranger parser"); t.start(); logger.debug("exit buildLiveRearrangerData on thread " + Thread.currentThread().getName()); }