protected static Sdk createSdkOfType(final SdkModel sdkModel, final SdkType sdkType, final Consumer<Sdk> sdkCreatedCallback) { final Ref<Sdk> result = new Ref<Sdk>(null); SdkConfigurationUtil.selectSdkHome(sdkType, new Consumer<String>() { @Override public void consume(final String home) { String newSdkName = SdkConfigurationUtil.createUniqueSdkName(sdkType, home, Arrays.asList(sdkModel.getSdks())); final ProjectJdkImpl newJdk = new ProjectJdkImpl(newSdkName, sdkType); newJdk.setHomePath(home); sdkCreatedCallback.consume(newJdk); result.set(newJdk); } }); return result.get(); }
@NotNull public static MergeRequest createMergeRequest(@Nullable Project project, @NotNull Document document, @Nullable VirtualFile file, @NotNull List<String> contents, @Nullable String windowTitle, @NotNull List<String> titles, @Nullable Consumer<MergeResult> callback) throws InvalidDiffRequestException { assert contents.size() == 3; assert titles.size() == 3; if (windowTitle == null) windowTitle = getPatchTitle(file); String localTitle = StringUtil.notNullize(titles.get(0), VcsBundle.message("patch.apply.conflict.local.version")); String baseTitle = StringUtil.notNullize(titles.get(1), VcsBundle.message("patch.apply.conflict.merged.version")); String patchedTitle = StringUtil.notNullize(titles.get(2), VcsBundle.message("patch.apply.conflict.patched.version")); List<String> actualTitles = ContainerUtil.list(localTitle, baseTitle, patchedTitle); FileType fileType = file != null ? file.getFileType() : null; return DiffRequestFactory.getInstance().createMergeRequest(project, fileType, document, contents, windowTitle, actualTitles, callback); }
@NotNull @Override public LogData readAllHashes(@NotNull VirtualFile root, @NotNull Consumer<TimedVcsCommit> commitConsumer) throws VcsException { LOG.debug("readAllHashes"); try { myFullLogSemaphore.acquire(); } catch (InterruptedException e) { throw new RuntimeException(e); } LOG.debug("readAllHashes passed the semaphore"); assertRoot(root); for (TimedVcsCommit commit : myCommits) { commitConsumer.consume(commit); } return new LogDataImpl(myRefs, Collections.<VcsUser>emptySet()); }
public final void showNotify() { if (myWasEverShown) return; try { findParentDisposable().doWhenDone(new Consumer<Disposable>() { public void consume(Disposable parent) { Project project = null; if (ApplicationManager.getApplication() != null) { project = CommonDataKeys.PROJECT.getData(DataManager.getInstance().getDataContext()); } initialize(parent, myChild, project); Disposer.register(parent, myChild); } }); } finally { myWasEverShown = true; } }
public Pair<VcsRevisionNumber, List<CommittedChangeList>> getOutgoingChanges(final VirtualFile vcsRoot, final boolean findRemote) throws VcsException { LOG.debug("getOutgoingChanges root: " + vcsRoot.getPath()); final GitBranchesSearcher searcher = new GitBranchesSearcher(myProject, vcsRoot, findRemote); if (searcher.getLocal() == null || searcher.getRemote() == null) { return new Pair<VcsRevisionNumber, List<CommittedChangeList>>(null, Collections.<CommittedChangeList>emptyList()); } final GitRevisionNumber base = getMergeBase(myProject, vcsRoot, searcher.getLocal(), searcher.getRemote()); if (base == null) { return new Pair<VcsRevisionNumber, List<CommittedChangeList>>(null, Collections.<CommittedChangeList>emptyList()); } final List<GitCommittedChangeList> lists = GitUtil.getLocalCommittedChanges(myProject, vcsRoot, new Consumer<GitSimpleHandler>() { public void consume(final GitSimpleHandler handler) { handler.addParameters(base.asString() + "..HEAD"); } }); return new Pair<VcsRevisionNumber, List<CommittedChangeList>>(base, ObjectsConvertor.convert(lists, new Convertor<GitCommittedChangeList, CommittedChangeList>() { @Override public CommittedChangeList convert(GitCommittedChangeList o) { return o; } })); }
private void showLocalCommit() { final Collection<FilePath> files = gatherChangedPaths(); // for changes to be detected, we need switch to background change list manager update thread and back to dispatch thread // so callback is used; ok to be called after VCS update markup closed: no remote operations final ChangeListManager changeListManager = ChangeListManager.getInstance(myProject); changeListManager.invokeAfterUpdate(new Runnable() { public void run() { Collection<Change> changes = new ArrayList<Change>(); for (FilePath file : files) { ContainerUtil.addIfNotNull(changes, changeListManager.getChange(file)); } CommitChangeListDialog.commitChanges(myProject, changes, null, null, myMerger.getComment()); prepareAndShowResults(); } }, InvokeAfterUpdateMode.SYNCHRONOUS_CANCELLABLE, myTitle, new Consumer<VcsDirtyScopeManager>() { public void consume(final VcsDirtyScopeManager vcsDirtyScopeManager) { vcsDirtyScopeManager.filePathsDirty(files, null); } }, null); }
public Consumer<MouseEvent> getClickConsumer() { return new Consumer<MouseEvent>() { public void consume(MouseEvent mouseEvent) { final Project project = getProject(); if (project == null) return; final Editor editor = getEditor(); if (editor == null) return; final CommandProcessor processor = CommandProcessor.getInstance(); processor.executeCommand( project, new Runnable() { public void run() { final GotoLineNumberDialog dialog = new GotoLineNumberDialog(project, editor); dialog.show(); IdeDocumentHistory.getInstance(project).includeCurrentCommandAsNavigation(); } }, UIBundle.message("go.to.line.command.name"), null ); } }; }
@Override public Consumer<MouseEvent> getClickConsumer() { return new Consumer<MouseEvent>() { @Override public void consume(final MouseEvent e) { Point point = new Point(0, 0); final PsiFile file = getCurrentFile(); if (file != null) { if (!DaemonCodeAnalyzer.getInstance(file.getProject()).isHighlightingAvailable(file)) return; final HectorComponent component = new HectorComponent(file); final Dimension dimension = component.getPreferredSize(); point = new Point(point.x - dimension.width, point.y - dimension.height); component.showComponent(new RelativePoint(e.getComponent(), point)); } } }; }
@Override public void actionPerformed(@NotNull AnActionEvent e) { final Project project = e.getProject(); final boolean showFiles = project != null || PlatformProjectOpenProcessor.getInstanceIfItExists() != null; final FileChooserDescriptor descriptor = showFiles ? new ProjectOrFileChooserDescriptor() : new ProjectOnlyFileChooserDescriptor(); descriptor.putUserData(PathChooserDialog.PREFER_LAST_OVER_EXPLICIT, showFiles); FileChooser.chooseFiles(descriptor, project, VfsUtil.getUserHomeDir(), new Consumer<List<VirtualFile>>() { @Override public void consume(final List<VirtualFile> files) { for (VirtualFile file : files) { if (!descriptor.isFileSelectable(file)) { String message = IdeBundle.message("error.dir.contains.no.project", file.getPresentableUrl()); Messages.showInfoMessage(project, message, IdeBundle.message("title.cannot.open.project")); return; } } doOpenFile(project, files); } }); }
public void addListMultipleSelectionListener(final @NotNull Consumer<List<Change>> listener) { myTable.getSelectionModel().addListSelectionListener(new ListSelectionListener() { public void valueChanged(final ListSelectionEvent e) { List<GitCommit> commits = myTable.getSelectedObjects(); final List<Change> changes = new ArrayList<Change>(); // We need changes in asc order for zipChanges, and they are in desc order in Table ListIterator<GitCommit> iterator = commits.listIterator(commits.size()); while (iterator.hasPrevious()) { changes.addAll(iterator.previous().getChanges()); } listener.consume(CommittedChangesTreeBrowser.zipChanges(changes)); } }); }
/** * @return gradle api facade to use * @throws Exception in case of inability to return the facade */ @NotNull public RemoteExternalSystemFacade getFacade(@Nullable Project project, @NotNull String externalProjectPath, @NotNull ProjectSystemId externalSystemId) throws Exception { if (project == null) { project = ProjectManager.getInstance().getDefaultProject(); } IntegrationKey key = new IntegrationKey(project, externalSystemId, externalProjectPath); final RemoteExternalSystemFacade facade = myFacadeWrappers.get(key); if (facade == null) { final RemoteExternalSystemFacade newFacade = (RemoteExternalSystemFacade)Proxy.newProxyInstance( ExternalSystemFacadeManager.class.getClassLoader(), new Class[]{RemoteExternalSystemFacade.class, Consumer.class}, new MyHandler(key) ); myFacadeWrappers.putIfAbsent(key, newFacade); } return myFacadeWrappers.get(key); }
@NotNull public static Promise<Void> wrapAsVoid(@NotNull ActionCallback asyncResult) { final AsyncPromise<Void> promise = new AsyncPromise<Void>(); asyncResult.doWhenDone(new Runnable() { @Override public void run() { promise.setResult(null); } }).doWhenRejected(new Consumer<String>() { @Override public void consume(String error) { promise.setError(createError(error == null ? "Internal error" : error)); } }); return promise; }
protected void createContentEntry(@NotNull final Module module, @NotNull final VirtualFile srcRoot) { updateModel(module, new Consumer<ModifiableRootModel>() { @Override public void consume(ModifiableRootModel model) { Sdk sdk = getSdk(); if (sdk != null) { model.setSdk(sdk); } ContentEntry contentEntry = model.addContentEntry(srcRoot); contentEntry.addSourceFolder(srcRoot, false); configureModule(module, model, contentEntry); } }); }
public static void updateAuxModuleStructure(Module auxModule, Collection<VirtualFile> pluginDirs, MvcFramework framework) { final MvcProjectStructure structure = framework.createProjectStructure(auxModule, true); final List<Consumer<ModifiableRootModel>> actions = getUpdateProjectStructureActions(pluginDirs, structure); for (final ContentEntry root : ModuleRootManager.getInstance(auxModule).getContentEntries()) { if (!pluginDirs.contains(root.getFile())) { actions.add(removeStaleContentEntries(pluginDirs)); break; } } if (!actions.isEmpty()) { actions.add(exportDefaultLibrary(structure.getUserLibraryName())); } if (!actions.isEmpty()) { final ModifiableRootModel model = ModuleRootManager.getInstance(auxModule).getModifiableModel(); for (final Consumer<ModifiableRootModel> pluginsUpdateAction : actions) { pluginsUpdateAction.consume(model); } model.commit(); } }
/** * Run all contributors until any of them returns false or the list is exhausted. If from parameter is not null, contributors * will be run starting from the next one after that. * @param parameters * @param from * @param consumer * @return */ public void getVariantsFromContributors(final CompletionParameters parameters, @Nullable final CompletionContributor from, final Consumer<CompletionResult> consumer) { final List<CompletionContributor> contributors = CompletionContributor.forParameters(parameters); for (int i = contributors.indexOf(from) + 1; i < contributors.size(); i++) { final CompletionContributor contributor = contributors.get(i); final CompletionResultSet result = createResultSet(parameters, consumer, contributor); contributor.fillCompletionVariants(parameters, result); if (result.isStopped()) { return; } } }
@NotNull private LogInfo readFullLogFromVcs() throws VcsException { final StopWatch sw = StopWatch.start("read full log from VCS"); final LogInfo logInfo = new LogInfo(); new ProviderIterator() { @Override void each(@NotNull VirtualFile root, @NotNull VcsLogProvider provider) throws VcsException { final List<GraphCommit<Integer>> graphCommits = ContainerUtil.newArrayList(); VcsLogProvider.LogData data = provider.readAllHashes(root, new Consumer<TimedVcsCommit>() { @Override public void consume(@NotNull TimedVcsCommit commit) { graphCommits.add(compactCommit(commit)); } }); logInfo.put(root, graphCommits); logInfo.put(root, data.getRefs()); myUserRegistry.addUsers(data.getUsers()); sw.rootCompleted(root); } }.iterate(myProviders); myUserRegistry.flush(); sw.report(); return logInfo; }
public TextMergeRequestImpl(@Nullable Project project, @NotNull DocumentContent output, @NotNull CharSequence originalContent, @NotNull List<DocumentContent> contents, @Nullable String title, @NotNull List<String> contentTitles, @Nullable Consumer<MergeResult> applyCallback) { assert contents.size() == 3; assert contentTitles.size() == 3; myProject = project; myOutput = output; myOriginalContent = originalContent; myContents = contents; myTitles = contentTitles; myTitle = title; myApplyCallback = applyCallback; }
protected ActionListener createActionListener(final JTable table) { return new ActionListener() { @Override public void actionPerformed(ActionEvent e) { String initial = (String)getCellEditorValue(); VirtualFile initialFile = StringUtil.isNotEmpty(initial) ? LocalFileSystem.getInstance().findFileByPath(initial) : null; FileChooser.chooseFile(getFileChooserDescriptor(), myProject, table, initialFile, new Consumer<VirtualFile>() { @Override public void consume(VirtualFile file) { String path = file.getPresentableUrl(); if (SystemInfo.isWindows && path.length() == 2 && Character.isLetter(path.charAt(0)) && path.charAt(1) == ':') { path += "\\"; // make path absolute } myComponent.getChildComponent().setText(path); } }); } }; }
static void addExpectedClassMembers(CompletionParameters params, final CompletionResultSet result) { for (final TypeConstraint info : getExpectedTypeInfos(params)) { Consumer<LookupElement> consumer = new Consumer<LookupElement>() { @Override public void consume(LookupElement element) { result.addElement(element); } }; PsiType type = info.getType(); PsiType defType = info.getDefaultType(); boolean searchInheritors = params.getInvocationCount() > 1; if (type instanceof PsiClassType) { new GroovyMembersGetter((PsiClassType)type, params).processMembers(searchInheritors, consumer); } if (!defType.equals(type) && defType instanceof PsiClassType) { new GroovyMembersGetter((PsiClassType)defType, params).processMembers(searchInheritors, consumer); } } }
public IncomingChangesViewProvider(final Project project, final MessageBus bus) { myProject = project; myBus = bus; myListConsumer = new Consumer<List<CommittedChangeList>>() { @Override public void consume(final List<CommittedChangeList> lists) { UIUtil.invokeLaterIfNeeded(new Runnable() { @Override public void run() { myBrowser.getEmptyText().setText(VcsBundle.message("incoming.changes.empty.message")); myBrowser.setItems(lists, CommittedChangesBrowserUseCase.INCOMING); } }); } }; }
public boolean setError(@NotNull Throwable error) { if (state != State.PENDING) { return false; } result = error; state = State.REJECTED; Consumer<Throwable> rejected = this.rejected; clearHandlers(); if (rejected != null) { if (!isObsolete(rejected)) { rejected.consume(error); } } else { Promise.logError(LOG, error); } return true; }
public ActionCallback applySwitch() { final ActionCallback result = new ActionCallback(); if (isSessionActive()) { final boolean showSpots = mySession.isShowspots(); mySession.finish(false).doWhenDone(new Consumer<SwitchTarget>() { @Override public void consume(final SwitchTarget switchTarget) { mySession = null; IdeFocusManager.getGlobalInstance().doWhenFocusSettlesDown(new Runnable() { @Override public void run() { tryToInitSessionFromFocus(switchTarget, showSpots).doWhenProcessed(result.createSetDoneRunnable()); } }); } }); } else { result.setDone(); } return result; }
public void load(@NotNull Consumer<String> consumer) { File file = new File(url); FileInputStream stream = null; try { stream = new FileInputStream(file); StreamLoader loader = new StreamLoader(stream, file.getName()); loader.load(consumer); } catch (Exception e) { LOG.error(e); } finally { try { stream.close(); } catch (IOException ignored) { } } }
VcsLogFiltererImpl(@NotNull final Project project, @NotNull Map<VirtualFile, VcsLogProvider> providers, @NotNull VcsLogHashMap hashMap, @NotNull Map<Integer, VcsCommitMetadata> topCommitsDetailsCache, @NotNull CommitDetailsGetter detailsGetter, @NotNull final PermanentGraph.SortType initialSortType, @NotNull final Consumer<VisiblePack> visiblePackConsumer) { myVisiblePackBuilder = new VisiblePackBuilder(providers, hashMap, topCommitsDetailsCache, detailsGetter); myFilters = new VcsLogFilterCollectionImpl(null, null, null, null, null, null, null); mySortType = initialSortType; myTaskController = new SingleTaskController<Request, VisiblePack>(visiblePackConsumer) { @Override protected void startNewBackgroundTask() { UIUtil.invokeLaterIfNeeded(new Runnable() { @Override public void run() { ((ProgressManagerImpl)ProgressManager.getInstance()).runProcessWithProgressAsynchronously( new MyTask(project, "Applying filters...")); } }); } }; }
protected CompleteReferenceProcessor() { super(null, EnumSet.allOf(ResolveKind.class), myRefExpr, PsiType.EMPTY_ARRAY); myConsumer = new Consumer<LookupElement>() { @Override public void consume(LookupElement element) { myIsEmpty = false; CompleteReferenceExpression.this.myConsumer.consume(element); } }; myPreferredFieldNames = addAllRestrictedProperties(); mySkipPackages = shouldSkipPackages(); myEventListener = JavaPsiFacade.getInstance(myRefExpr.getProject()).findClass("java.util.EventListener", myRefExpr.getResolveScope()); myPropertyNames.addAll(myPreferredFieldNames); myFieldPointerOperator = myRefExpr.hasAt(); myMethodPointerOperator = myRefExpr.getDotTokenType() == GroovyTokenTypes.mMEMBER_POINTER; myIsMap = isMap(); final PsiType thisType = PsiImplUtil.getQualifierType(myRefExpr); mySubstitutorComputer = new SubstitutorComputer(thisType, PsiType.EMPTY_ARRAY, PsiType.EMPTY_ARRAY, myRefExpr, myRefExpr.getParent()); }
public static <T> T buildModuleGroupPath(final ModuleGroup group, T parentNode, final Map<ModuleGroup, T> map, final Consumer<ParentChildRelation<T>> insertNode, final Function<ModuleGroup, T> createNewNode) { final ArrayList<String> path = new ArrayList<String>(); final String[] groupPath = group.getGroupPath(); for (String pathElement : groupPath) { path.add(pathElement); final ModuleGroup moduleGroup = new ModuleGroup(ArrayUtil.toStringArray(path)); T moduleGroupNode = map.get(moduleGroup); if (moduleGroupNode == null) { moduleGroupNode = createNewNode.fun(moduleGroup); map.put(moduleGroup, moduleGroupNode); insertNode.consume(new ParentChildRelation<T>(parentNode, moduleGroupNode)); } parentNode = moduleGroupNode; } return parentNode; }
public VcsHistoryProviderBackgroundableProxy(final AbstractVcs vcs, final VcsHistoryProvider delegate, DiffProvider diffProvider) { myDelegate = delegate; myProject = vcs.getProject(); myConfiguration = VcsConfiguration.getInstance(myProject); myCachesHistory = myDelegate instanceof VcsCacheableHistorySessionFactory; myDiffProvider = diffProvider; myVcsHistoryCache = ProjectLevelVcsManager.getInstance(myProject).getVcsHistoryCache(); myType = vcs.getType(); myHistoryComputerFactory = new HistoryComputerFactory() { @Override public ThrowableComputable<VcsHistorySession, VcsException> create(FilePath filePath, Consumer<VcsHistorySession> consumer, VcsKey vcsKey) { if (myCachesHistory) { return new CachingHistoryComputer(filePath, consumer, vcsKey); } else { return new SimpelHistoryComputer(filePath, consumer); } } }; }
@Nullable private static JBPopup navigateOrCreatePopup(final NavigatablePsiElement[] targets, final String title, final String findUsagesTitle, final ListCellRenderer listRenderer, @Nullable final ListBackgroundUpdaterTask listUpdaterTask) { return navigateOrCreatePopup(targets, title, findUsagesTitle, listRenderer, listUpdaterTask, new Consumer<Object[]>() { @Override public void consume(Object[] selectedElements) { for (Object element : selectedElements) { PsiElement selected = (PsiElement)element; LOG.assertTrue(selected.isValid()); ((NavigatablePsiElement)selected).navigate(true); } } }); }
synchronized void setIgnored(@NotNull final DataNode<?> dataNode, final boolean isIgnored) { //noinspection unchecked final DataNode<ProjectData> projectDataNode = PROJECT.equals(dataNode.getKey()) ? (DataNode<ProjectData>)dataNode : ExternalSystemApiUtil.findParent(dataNode, PROJECT); if (projectDataNode == null) { return; } ExternalSystemApiUtil.visit(dataNode, new Consumer<DataNode<?>>() { @Override public void consume(DataNode node) { node.setIgnored(isIgnored); } }); saveInclusionSettings(projectDataNode); }
public Map<String, Set<String>> getState() { final Map<String, Set<String>> result = ContainerUtil.newHashMap(); Consumer<PostfixTemplateCheckedTreeNode> consumer = new Consumer<PostfixTemplateCheckedTreeNode>() { @Override public void consume(PostfixTemplateCheckedTreeNode template) { if (!template.isChecked()) { Set<String> templatesForLanguage = ContainerUtil.getOrCreate(result, template.getLang(), PostfixTemplatesSettings.SET_FACTORY); templatesForLanguage.add(template.getTemplate().getKey()); } } }; visit(consumer); return result; }
@Override public void startNotify() { addProcessListener(new ProcessAdapter() { @Override public void startNotified(ProcessEvent event) { try { myWaitFor.setTerminationCallback(new Consumer<Integer>() { @Override public void consume(Integer integer) { notifyProcessTerminated(integer); } }); } finally { removeProcessListener(this); } } }); super.startNotify(); }
@Override public void findDeclarationsAt(@NotNull PsiElement element, int offsetInElement, Consumer<PomTarget> consumer) { if (element instanceof AppleScriptSelectorId) { AppleScriptHandlerInterleavedParameters handler; final PsiElement contextElement = element.getContext() != null ? element.getContext().getContext() : null; if (contextElement instanceof AppleScriptHandlerInterleavedParameters) { handler = (AppleScriptHandlerInterleavedParameters) contextElement; consumer.consume(handler); } } }
@Nullable private PsiJavaFile createPackageInfoFile(PsiFile file, PsiPackage target) { DataManager.getInstance().getDataContextFromFocus().doWhenDone((Consumer<DataContext>) context -> { AnActionEvent event = new AnActionEvent(null, context, "", new Presentation(), ActionManager.getInstance(), 0); new CreatePackageInfoAction().actionPerformed(event); }); return packageInfoFile(target, file.getContainingDirectory()); }
@Override public boolean submit(@NotNull IdeaLoggingEvent[] events, @Nullable String additionalInfo, @NotNull Component parentComponent, @NotNull Consumer<SubmittedReportInfo> consumer) { log(events, additionalInfo); consumer.consume(new SubmittedReportInfo(null, null, NEW_ISSUE)); Messages.showInfoMessage(parentComponent, DEFAULT_RESPONSE, DEFAULT_RESPONSE_TITLE); return true; }
@NotNull @Override public TaskRepositoryEditor createEditor(PhabricatorRepository repository, Project project, Consumer<PhabricatorRepository> changeListener) { return new PhabricatorRepositoryEditor(project, repository, changeListener); }
public PhabricatorRepositoryEditor(Project project, PhabricatorRepository repository, Consumer<PhabricatorRepository> changeListener) { super(project, repository, changeListener); myUsernameLabel.setVisible(false); myUserNameText.setVisible(false); myPasswordLabel.setText("Token:"); installListener(myIconProjects); myTestButton.setEnabled(myRepository.isConfigured()); if (myRepository.isConfigured()) { ApplicationManager.getApplication().executeOnPooledThread(this::installProjectCompletion); } }
private CommittedChangesListener getPublisher(final Consumer<CommittedChangesListener> listener) { return ApplicationManager.getApplication().runReadAction(new Computable<CommittedChangesListener>() { @Override public CommittedChangesListener compute() { if (myProject.isDisposed()) throw new ProcessCanceledException(); return myBus.syncPublisher(COMMITTED_TOPIC); } }); }
public synchronized void purgeObsolete(long period) { myStorage.purge(period, myIntervalBetweenActivities, new Consumer<ChangeSet>() { public void consume(ChangeSet changeSet) { for (Content each : changeSet.getContentsToPurge()) { each.release(); } } }); }
@Override protected void processFolder(final HashSet<String> seenNames, PsiManager manager, VirtualFile folder) { if (!myExcludedFolders.contains(folder)) { final String name = folder.getName(); IdentifierSplitter.getInstance().split(name, TextRange.allOf(name), new Consumer<TextRange>() { @Override public void consume(TextRange textRange) { final String word = textRange.substring(name); addSeenWord(seenNames, word, Language.ANY); } }); } super.processFolder(seenNames, manager, folder); }
@Override protected void doFix(final Project project, ProblemDescriptor descriptor) throws IncorrectOperationException { final PsiExpression expression = getExpressionToExtract(descriptor.getPsiElement()); if (expression == null) { return; } final RefactoringActionHandler handler = JavaRefactoringActionHandlerFactory.getInstance().createIntroduceVariableHandler(); final AsyncResult<DataContext> dataContextContainer = DataManager.getInstance().getDataContextFromFocus(); dataContextContainer.doWhenDone(new Consumer<DataContext>() { @Override public void consume(DataContext dataContext) { handler.invoke(project, new PsiElement[]{expression}, dataContext); } }); }