@NotNull private static String getSrcLocation(@NotNull String version) { if (ApplicationManager.getApplication().isUnitTestMode()) { return "src/pkg"; } if (version.startsWith("devel")) { return "src"; } if (version.length() > 2 && StringUtil.parseDouble(version.substring(0, 3), 1.4) < 1.4) { return "src/pkg"; } return "src"; }
public static void clearError() { if (ApplicationManager.getApplication().isUnitTestMode()) { getInstance().error = false; } }
public void output(@NotNull String text) { myText = text; if (!ApplicationManager.getApplication().isUnitTestMode()) { ExOutputPanel.getInstance(myEditor).setText(text); } }
@Override @Nullable public ProblemDescriptor[] checkFile(@NotNull PsiFile file, @NotNull InspectionManager manager, boolean isOnTheFly) { // does not work in tests since CodeInsightTestCase copies file into temporary location if (ApplicationManager.getApplication().isUnitTestMode()) { return new ProblemDescriptor[0]; } if (!(file instanceof BallerinaFile)) { return new ProblemDescriptor[0]; } List<ProblemDescriptor> problemDescriptors = new LinkedList<>(); LocalQuickFix[] availableFixes = new LocalQuickFix[0]; Collection<BallerinaIdentifier> nameReferenceNodes = PsiTreeUtil.findChildrenOfType(file, BallerinaIdentifier.class); problemDescriptors.addAll(getUnresolvedNameReferenceDescriptors(manager, isOnTheFly, availableFixes, nameReferenceNodes)); return problemDescriptors.toArray(new ProblemDescriptor[0]); }
/** * Indicate to the user that an error has occurred. Just beep. */ public static void indicateError() { if (ApplicationManager.getApplication().isUnitTestMode()) { getInstance().error = true; } else if (!Options.getInstance().isSet("visualbell")) { Toolkit.getDefaultToolkit().beep(); } }
private static void setHighlighting(@NotNull PsiElement element, @NotNull AnnotationHolder holder, @NotNull TextAttributesKey key) { holder.createInfoAnnotation(element, null).setEnforcedTextAttributes(TextAttributes.ERASE_MARKER); String description = ApplicationManager.getApplication().isUnitTestMode() ? key.getExternalName() : null; holder.createInfoAnnotation(element, description).setTextAttributes(key); }
@Override public void initComponent() { if (!ApplicationManager.getApplication().isUnitTestMode()) { EditorFactory.getInstance().addEditorFactoryListener(myListener, this); } }
@Nullable public static String retrieveGoPathFromEnvironment() { if (ApplicationManager.getApplication().isUnitTestMode()) return null; String path = EnvironmentUtil.getValue(GoConstants.GO_PATH); return path != null ? path : PathMacros.getInstance().getValue(GoConstants.GO_PATH); } }
public void clear() { myText = null; if (!ApplicationManager.getApplication().isUnitTestMode()) { ExOutputPanel.getInstance(myEditor).deactivate(false); } }
@Override public final void init() { if (ApplicationManager.getApplication().isUnitTestMode()) { initOnce(); } else { if (!myInitialized) { myInitialized = true; initOnce(); } } }
public GoModuleLibrariesInitializer(@NotNull Module module) { myModule = module; myAlarm = ApplicationManager.getApplication().isUnitTestMode() ? new Alarm() : new Alarm(Alarm.ThreadToUse.POOLED_THREAD, myModule); myConnection = myModule.getMessageBus().connect(); }
private static void startTemplate(@NotNull Editor editor, @NotNull Template template, @NotNull Project project) { Runnable runnable = () -> { if (project.isDisposed() || editor.isDisposed()) return; CommandProcessor.getInstance().executeCommand(project, () -> TemplateManager.getInstance(project).startTemplate(editor, template, null), "Introduce function", null); }; if (ApplicationManager.getApplication().isUnitTestMode()) { runnable.run(); } else { ApplicationManager.getApplication().invokeLater(runnable); } }
@Override public void performInDumbMode(@NotNull ProgressIndicator indicator) { if (!project.isDisposed()) { final PerformanceWatcher.Snapshot snapshot = PerformanceWatcher.takeSnapshot(); final List<Runnable> tasks = ReadAction.compute(() -> rootUpdateTaskList(project, sdkSet)); PushedFilePropertiesUpdaterImpl.invokeConcurrentlyIfPossible(tasks); if (!ApplicationManager.getApplication().isUnitTestMode()) { snapshot.logResponsivenessSinceCreation( "Pushing Elixir language level to " + tasks.size() + " roots in " + sdkSet.size() + " SDKs"); } } } };
public boolean execute(@NotNull Editor editor, @NotNull final DataContext context, @NotNull ExCommand cmd) throws ExException { final String actionName = cmd.getArgument().trim(); final AnAction action = ActionManager.getInstance().getAction(actionName); if (action == null) { VimPlugin.showMessage("Action not found: " + actionName); return false; } final Application application = ApplicationManager.getApplication(); if (application.isUnitTestMode()) { executeAction(editor, cmd, action, context, actionName); } else { UiHelper.runAfterGotFocus(() -> executeAction(editor, cmd, action, context, actionName)); } return true; }
/** * Returns a single key stroke from the user input similar to 'getchar()'. */ @NotNull public static KeyStroke inputKeyStroke(@NotNull Editor editor) { final KeyStroke key; if (ApplicationManager.getApplication().isUnitTestMode()) { key = TestInputModel.getInstance(editor).nextKeyStroke(); } else { final Ref<KeyStroke> ref = Ref.create(); ModalEntry.activate(new Processor<KeyStroke>() { @Override public boolean process(KeyStroke stroke) { ref.set(stroke); return false; } }); key = ref.get(); } return key != null ? key : KeyStroke.getKeyStroke((char)KeyEvent.VK_ESCAPE); }
public BallerinaModuleLibrariesInitializer(@NotNull Module module) { myModule = module; myAlarm = ApplicationManager.getApplication().isUnitTestMode() ? new Alarm() : new Alarm(Alarm.ThreadToUse.POOLED_THREAD, myModule); myConnection = myModule.getMessageBus().connect(); }
/** * Show the dialog. * * @throws IllegalStateException if the method is invoked not on the event dispatch thread * @see #showAndGet() * @see #showAndGetOk() */ @Override public void show() { if (ApplicationManager.getApplication().isUnitTestMode()) { dispose(); return; } super.show(); }
@Override public void invoke(@NotNull Project project, @NotNull PsiFile file, @NotNull PsiElement startElement, @NotNull PsiElement endElement) { if (!FileModificationService.getInstance().preparePsiElementsForWrite(startElement)) return; Runnable runnable = () -> { AsyncResult<DataContext> dataContextContainer = DataManager.getInstance().getDataContextFromFocus(); dataContextContainer.doWhenDone(new Consumer<DataContext>() { @Override public void consume(DataContext dataContext) { RenameHandler renameHandler = RenameHandlerRegistry.getInstance().getRenameHandler(dataContext); if (renameHandler != null) { renameHandler.invoke(project, new PsiElement[]{startElement}, dataContext); } else { RefactoringActionHandler renameRefactoringHandler = RefactoringActionHandlerFactory.getInstance().createRenameHandler(); renameRefactoringHandler.invoke(project, new PsiElement[]{startElement}, dataContext); } } }); }; if (ApplicationManager.getApplication().isUnitTestMode()) { runnable.run(); } else { ApplicationManager.getApplication().invokeLater(runnable, project.getDisposed()); } }
/** * Turns off the ex entry field and optionally puts the focus back to the original component */ public void deactivate(boolean refocusOwningEditor) { logger.info("deactivate"); if (!active) return; active = false; if (!ApplicationManager.getApplication().isUnitTestMode()) { if (refocusOwningEditor && parent != null) { UiHelper.requestFocus(parent); } oldGlass.removeComponentListener(adapter); oldGlass.setVisible(false); oldGlass.remove(this); oldGlass.setOpaque(wasOpaque); oldGlass.setLayout(oldLayout); if (isIncSearchEnabled(label.getText())) { entry.getDocument().removeDocumentListener(documentListener); final Editor editor = entry.getEditor(); editor.getScrollingModel().scrollVertically(verticalOffset); editor.getScrollingModel().scrollHorizontally(horizontalOffset); if (incHighlighter != null) { editor.getMarkupModel().removeHighlighter(incHighlighter); } } } parent = null; }
@Override public void initComponent() { LOG.debug("initComponent"); Notifications.Bus.register(IDEAVIM_STICKY_NOTIFICATION_ID, NotificationDisplayType.STICKY_BALLOON); ApplicationManager.getApplication().invokeLater(new Runnable() { public void run() { updateState(); } }); final TypedAction typedAction = EditorActionManager.getInstance().getTypedAction(); EventFacade.getInstance().setupTypedActionHandler(new VimTypedActionHandler(typedAction.getRawHandler())); // Register vim actions in command mode RegisterActions.registerActions(); // Add some listeners so we can handle special events setupListeners(); // Register ex handlers CommandParser.getInstance().registerHandlers(); if (!ApplicationManager.getApplication().isUnitTestMode()) { final File ideaVimRc = VimScriptParser.findIdeaVimRc(); if (ideaVimRc != null) { VimScriptParser.executeFile(ideaVimRc); } } LOG.debug("done"); }