@Override public void execute(@NotNull Editor editor, @NotNull DataContext context) { // Deleting surround is just changing the surrounding to "nothing" final char charFrom = getChar(editor); if (charFrom == 0) { return; } WriteAction.run(() -> CSurroundHandler.change(editor, charFrom, null)); } }
AccessToken l = WriteAction.start(); try { for (Sdk sdk : sdksToDelete) {
@Override public void run(@NotNull ProgressIndicator indicator) { PerlSdkType.INSTANCE.setupSdkPaths(sdk); if (project != null) { WriteAction.runAndWait(() -> { if (!myProject.isDisposed()) { ProjectRootManagerEx.getInstanceEx(myProject).makeRootsChange(EmptyRunnable.getInstance(), false, true); DaemonCodeAnalyzer.getInstance(project).restart(); } }); } } }.queue();
VirtualFile vFile = WriteAction.computeAndWait(() -> VfsUtil.createDirectoryIfMissing(outPath)); PsiDirectory directory = PsiManager.getInstance(project).findDirectory(vFile); realPackageName = JavaUtils.getPackageName(directory, templateId);
@Override public void execute(@NotNull Editor editor, @NotNull DataContext context) { final char charFrom = getChar(editor); if (charFrom == 0) { return; } final char charTo = getChar(editor); if (charTo == 0) { return; } Pair<String, String> newSurround = getOrInputPair(charTo, editor); if (newSurround == null) { return; } WriteAction.run(() -> change(editor, charFrom, newSurround)); }
@Override public void execute(@NotNull Editor editor, @NotNull DataContext context) { final TextRange visualRange = VimPlugin.getMark().getVisualSelectionMarks(editor); if (visualRange == null) { return; } // NB: Operator ignores SelectionType anyway if (!new Operator().apply(editor, context, SelectionType.CHARACTER_WISE)) { return; } WriteAction.run(() -> { // Leave visual mode executeNormal(parseKeys("<Esc>"), editor); editor.getCaretModel().moveToOffset(visualRange.getStartOffset()); }); }
@Override public boolean apply(@NotNull Editor editor, @NotNull DataContext context, @NotNull SelectionType selectionType) { final char c = getChar(editor); if (c == 0) { return true; } final Pair<String, String> pair = getOrInputPair(c, editor); if (pair == null) { return false; } // XXX: Will it work with line-wise or block-wise selections? final TextRange range = getSurroundRange(editor); if (range == null) { return false; } WriteAction.run(() -> { final ChangeGroup change = VimPlugin.getChange(); final String leftSurround = pair.getFirst(); final Caret primaryCaret = editor.getCaretModel().getPrimaryCaret(); primaryCaret.moveToOffset(range.getStartOffset()); change.insertText(editor, primaryCaret, leftSurround); primaryCaret.moveToOffset(range.getEndOffset() + leftSurround.length()); change.insertText(editor, primaryCaret, pair.getSecond()); // Jump back to start executeNormal(parseKeys("`["), editor); }); return true; }
@Override public void projectSdkChanged(@Nullable Sdk sdk) { // First we get the date context from the focus (current project). AsyncResult<DataContext> dataContextFromFocus = DataManager.getInstance().getDataContextFromFocus(); // Get the result from the data context. DataContext result = dataContextFromFocus.getResult(); if (result == null) { return; } // Get the current project. Project project = DataKeys.PROJECT.getData(result); if (project == null) { return; } // Get all modules in the project. Module[] modules = ModuleManager.getInstance(project).getModules(); // Iterate through all modules. for (Module module : modules) { // Check whether the module is a Ballerina module. if (BallerinaSdkService.getInstance(project).isBallerinaModule(module)) { // If it is a Ballerina module, inherit the project SDK. WriteAction.run(() -> ModuleRootModificationUtil.setSdkInherited(module)); } } // Need to prompt a restart action to clear and re initiate language server instance from the new SDK. // Todo - Figure out a way to apply language server changes without restarting. if (isBallerinaSdk(sdk)) { ApplicationManager.getApplication().invokeLater(this::showRestartDialog); } }
public void setExternalLibraries(@NotNull List<VirtualFile> roots) { WriteAction.run(() -> { myPerlSettings.setExternalLibrariesPaths(Collections.emptyList()); addExternalLibraries(roots); }); }
public void setProjectSdk(@Nullable Sdk sdk) { WriteAction.run( () -> ProjectRootManagerEx.getInstanceEx(myProject).makeRootsChange( () -> myPerlSettings.setPerlInterpreter(sdk == null ? null : sdk.getName()), false, true) ); }
public void addExternalLibraries(@NotNull List<VirtualFile> roots) { WriteAction.run( () -> { List<String> paths = new ArrayList<>(myPerlSettings.getExternalLibrariesPaths()); boolean doChange = false; for (VirtualFile root : roots) { if (!root.isValid() || !root.isDirectory()) { return; } String canonicalPath = root.getCanonicalPath(); if (!paths.contains(canonicalPath)) { doChange = true; paths.add(canonicalPath); } } if (!doChange && !paths.isEmpty()) { return; } ProjectRootManagerEx.getInstanceEx(myProject).makeRootsChange(() -> myPerlSettings.setExternalLibrariesPaths(paths), false, true); } ); }
@Override public void apply() { boolean forceReparse = isStructureModified(); Set<String> extDiff = getDiff(mySettings.substitutedExtensions, substitutedExtensionsModel.getItems()); mySettings.substitutedExtensions.clear(); mySettings.substitutedExtensions.addAll(substitutedExtensionsModel.getItems()); mySettings.autoHandlerName = autohandlerName.getText(); mySettings.defaultHandlerName = defaulthandlerName.getText(); mySettings.globalVariables.clear(); for (VariableDescription variableDescription : new ArrayList<>(globalsModel.getItems())) { if (StringUtil.isNotEmpty(variableDescription.variableName)) { mySettings.globalVariables.add(variableDescription); } else { globalsModel.removeRow(globalsModel.indexOf(variableDescription)); } } mySettings.customTags.clear(); mySettings.customTags.addAll(customTagsModel.getItems()); mySettings.settingsUpdated(); if (!extDiff.isEmpty() || forceReparse) { // fixme move this logic to the settings WriteAction.run(() -> FileTypeManagerEx.getInstanceEx().fireFileTypesChanged()); } }
private void moveMavenModulesToGroup( final @NotNull Project project, final @NotNull List<Module> mavenModules, final @NotNull Map<String, String[]> mavenGroupMapping ) { AccessToken token = null; final ModifiableModuleModel modifiableModuleModel; try { token = ApplicationManager.getApplication().acquireReadActionLock(); modifiableModuleModel = ModuleManager.getInstance(project).getModifiableModel(); for (Module module : mavenModules) { module.setOption(HybrisConstants.DESCRIPTOR_TYPE, HybrisModuleDescriptorType.MAVEN.name()); final String[] groupPath = modifiableModuleModel.getModuleGroupPath(module); modifiableModuleModel.setModuleGroupPath(module, ArrayUtils.addAll(mavenGroupMapping.get(module.getName()), groupPath)); } } finally { if (token != null) { token.finish(); } } ApplicationManager.getApplication().invokeAndWait(() -> WriteAction.run(modifiableModuleModel::commit)); }
public void settingsUpdated() { createLazyObjects(); ApplicationManager.getApplication().invokeLater(() -> WriteAction.run( () -> ProjectRootManagerEx.getInstanceEx(myProject).makeRootsChange(EmptyRunnable.getInstance(), true, true))); }
@Override public void commit() { LOG.assertTrue(myOriginal != null, "Attempt to commit non-modifyable model"); if (isChanged()) { synchronized (myOriginal) { WriteAction.run( () -> ProjectRootManagerEx.getInstanceEx(myModule.getProject()).makeRootsChange(() -> { myOriginal.myRoots = new THashMap<>(myRoots); myOriginal.myModificationTracker++; }, false, true) ); } } }
.newProject(baseDir.getName(), baseDir.getPath(), true, false); if (project != null) { WriteAction.run(() -> { final Sdk sdk = DlangSdkType.findOrCreateSdk(); ProjectRootManager.getInstance(project).setProjectSdk(sdk);
public static void doGenerate(@NotNull Project project, @NotNull List<VirtualFile> bnfFiles) { Map<VirtualFile, VirtualFile> rootMap = ContainerUtil.newLinkedHashMap(); PsiManager psiManager = PsiManager.getInstance(project); WriteAction.run(() -> { for (VirtualFile file : bnfFiles) { if (!file.isValid()) continue;
@Override protected void moveOffsetAfter(boolean success) { RangeMarker exprMarker = getExprMarker(); WriteAction.run(() -> { Document document = myEditor.getDocument(); // todo restore original expression if not success PsiDocumentManager.getInstance(myProject).commitDocument(document); if (exprMarker != null && exprMarker.isValid()) { myEditor.getCaretModel().moveToOffset(exprMarker.getStartOffset()); myEditor.getScrollingModel().scrollToCaret(ScrollType.MAKE_VISIBLE); exprMarker.dispose(); } }); }
WriteAction.run(() -> myFixture.getFile().getVirtualFile().setWritable(false)); } catch (IOException e) { throw new RuntimeException(e);
Application application = ApplicationManager.getApplication(); application.invokeAndWait( () -> WriteAction.run(() -> { if (myProject.isDisposed()) { return;