当前位置: 首页>>代码示例>>Java>>正文


Java AsyncResult.doWhenDone方法代码示例

本文整理汇总了Java中com.intellij.openapi.util.AsyncResult.doWhenDone方法的典型用法代码示例。如果您正苦于以下问题:Java AsyncResult.doWhenDone方法的具体用法?Java AsyncResult.doWhenDone怎么用?Java AsyncResult.doWhenDone使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在com.intellij.openapi.util.AsyncResult的用法示例。


在下文中一共展示了AsyncResult.doWhenDone方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: downloadArtifacts

import com.intellij.openapi.util.AsyncResult; //导入方法依赖的package包/类
protected MavenArtifactDownloader.DownloadResult downloadArtifacts(Collection<MavenProject> projects,
                                                                   List<MavenArtifact> artifacts) {
  final MavenArtifactDownloader.DownloadResult[] unresolved = new MavenArtifactDownloader.DownloadResult[1];

  AsyncResult<MavenArtifactDownloader.DownloadResult> result = new AsyncResult<MavenArtifactDownloader.DownloadResult>();
  result.doWhenDone(new Consumer<MavenArtifactDownloader.DownloadResult>() {
    @Override
    public void consume(MavenArtifactDownloader.DownloadResult unresolvedArtifacts) {
      unresolved[0] = unresolvedArtifacts;
    }
  });

  myProjectsManager.scheduleArtifactsDownloading(projects, artifacts, true, true, result);
  myProjectsManager.waitForArtifactsDownloadingCompletion();

  return unresolved[0];
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:18,代码来源:MavenImportingTestCase.java

示例2: doFix

import com.intellij.openapi.util.AsyncResult; //导入方法依赖的package包/类
@Override
public void doFix(final Project project, final ProblemDescriptor descriptor) {
  final PsiElement nameIdentifier = descriptor.getPsiElement();
  final PsiElement elementToRename = nameIdentifier.getParent();
  if (m_targetName == null) {
    final AsyncResult<DataContext> contextFromFocus = DataManager.getInstance().getDataContextFromFocus();
    contextFromFocus.doWhenDone(new Consumer<DataContext>() {
      @Override
      public void consume(DataContext context) {
        final RenameHandler renameHandler = RenameHandlerRegistry.getInstance().getRenameHandler(context);
        if (renameHandler == null) {
          return;
        }
        renameHandler.invoke(project, new PsiElement[]{elementToRename}, context);
      }
    });
  }
  else {
    final RefactoringFactory factory = RefactoringFactory.getInstance(project);
    final RenameRefactoring renameRefactoring =
      factory.createRename(elementToRename, m_targetName, m_searchInStrings, m_searchInNonJavaFiles);
    renameRefactoring.run();
  }
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:25,代码来源:RenameFix.java

示例3: doFix

import com.intellij.openapi.util.AsyncResult; //导入方法依赖的package包/类
@Override
protected void doFix(@NotNull final Project project, ProblemDescriptor descriptor) throws IncorrectOperationException {
  final PsiElement location = descriptor.getPsiElement();
  final PsiMethod method = (PsiMethod)location.getParent();
  final RefactoringActionHandler moveHandler = RefactoringActionHandlerFactory.getInstance().createMoveHandler();
  final AsyncResult<DataContext> result = DataManager.getInstance().getDataContextFromFocus();
  result.doWhenDone(new Consumer<DataContext>() {
    @Override
    public void consume(final DataContext originalContext) {
      final DataContext dataContext = new DataContext() {
        @Override
        public Object getData(@NonNls String name) {
          if (LangDataKeys.TARGET_PSI_ELEMENT.is(name)) {
            return usageClass.getElement();
          }
          return originalContext.getData(name);
        }
      };
      moveHandler.invoke(project, new PsiElement[]{method}, dataContext);
    }
  });
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:23,代码来源:StaticMethodOnlyUsedInOneClassInspection.java

示例4: downloadArtifacts

import com.intellij.openapi.util.AsyncResult; //导入方法依赖的package包/类
protected MavenArtifactDownloader.DownloadResult downloadArtifacts(Collection<MavenProject> projects,
                                                                   List<MavenArtifact> artifacts) {
  final MavenArtifactDownloader.DownloadResult[] unresolved = new MavenArtifactDownloader.DownloadResult[1];

  AsyncResult<MavenArtifactDownloader.DownloadResult> result = new AsyncResult<MavenArtifactDownloader.DownloadResult>();
  result.doWhenDone(new AsyncResult.Handler<MavenArtifactDownloader.DownloadResult>() {
    @Override
    public void run(MavenArtifactDownloader.DownloadResult unresolvedArtifacts) {
      unresolved[0] = unresolvedArtifacts;
    }
  });

  myProjectsManager.scheduleArtifactsDownloading(projects, artifacts, true, true, result);
  myProjectsManager.waitForArtifactsDownloadingCompletion();

  return unresolved[0];
}
 
开发者ID:lshain-android-source,项目名称:tools-idea,代码行数:18,代码来源:MavenImportingTestCase.java

示例5: doFix

import com.intellij.openapi.util.AsyncResult; //导入方法依赖的package包/类
@Override
public void doFix(final Project project, final ProblemDescriptor descriptor) {
  final PsiElement nameIdentifier = descriptor.getPsiElement();
  final PsiElement elementToRename = nameIdentifier.getParent();
  if (m_targetName == null) {
    final AsyncResult<DataContext> contextFromFocus = DataManager.getInstance().getDataContextFromFocus();
    contextFromFocus.doWhenDone(new AsyncResult.Handler<DataContext>() {
      @Override
      public void run(DataContext context) {
        final RenameHandler renameHandler = RenameHandlerRegistry.getInstance().getRenameHandler(context);
        if (renameHandler == null) {
          return;
        }
        renameHandler.invoke(project, new PsiElement[]{elementToRename}, context);
      }
    });
  }
  else {
    final RefactoringFactory factory = RefactoringFactory.getInstance(project);
    final RenameRefactoring renameRefactoring =
      factory.createRename(elementToRename, m_targetName, m_searchInStrings, m_searchInNonJavaFiles);
    renameRefactoring.run();
  }
}
 
开发者ID:lshain-android-source,项目名称:tools-idea,代码行数:25,代码来源:RenameFix.java

示例6: doFix

import com.intellij.openapi.util.AsyncResult; //导入方法依赖的package包/类
@Override
protected void doFix(@NotNull final Project project, ProblemDescriptor descriptor) throws IncorrectOperationException {
  final PsiElement location = descriptor.getPsiElement();
  final PsiMethod method = (PsiMethod)location.getParent();
  final RefactoringActionHandler moveHandler = RefactoringActionHandlerFactory.getInstance().createMoveHandler();
  final AsyncResult<DataContext> result = DataManager.getInstance().getDataContextFromFocus();
  result.doWhenDone(new AsyncResult.Handler<DataContext>() {
    @Override
    public void run(final DataContext originalContext) {
      final DataContext dataContext = new DataContext() {
        @Override
        public Object getData(@NonNls String name) {
          if (LangDataKeys.TARGET_PSI_ELEMENT.is(name)) {
            return usageClass.getElement();
          }
          return originalContext.getData(name);
        }
      };
      moveHandler.invoke(project, new PsiElement[]{method}, dataContext);
    }
  });
}
 
开发者ID:lshain-android-source,项目名称:tools-idea,代码行数:23,代码来源:StaticMethodOnlyUsedInOneClassInspection.java

示例7: doFix

import com.intellij.openapi.util.AsyncResult; //导入方法依赖的package包/类
@Override
public void doFix(final Project project, final ProblemDescriptor descriptor)
{
	final PsiElement nameIdentifier = descriptor.getPsiElement();
	final PsiElement elementToRename = nameIdentifier.getParent();
	if(m_targetName == null)
	{
		final AsyncResult<DataContext> contextFromFocus = DataManager.getInstance().getDataContextFromFocus();
		contextFromFocus.doWhenDone(context -> {
			final RenameHandler renameHandler = RenameHandlerRegistry.getInstance().getRenameHandler(context);
			if(renameHandler == null)
			{
				return;
			}
			renameHandler.invoke(project, new PsiElement[]{elementToRename}, context);
		});
	}
	else
	{
		final RefactoringFactory factory = RefactoringFactory.getInstance(project);
		final RenameRefactoring renameRefactoring = factory.createRename(elementToRename, m_targetName, m_searchInStrings, m_searchInNonJavaFiles);
		renameRefactoring.run();
	}
}
 
开发者ID:consulo,项目名称:consulo-java,代码行数:25,代码来源:RenameFix.java

示例8: applyFix

import com.intellij.openapi.util.AsyncResult; //导入方法依赖的package包/类
@Override
public void applyFix(@NotNull final Project project, @NotNull final ProblemDescriptor descriptor) {
  final PsiElement element = PsiTreeUtil.getParentOfType(descriptor.getPsiElement(), PsiJavaCodeReferenceElement.class);
  if (element instanceof PsiJavaCodeReferenceElement) {
    final PsiJavaCodeReferenceElement referenceElement = (PsiJavaCodeReferenceElement)element;
    Collections.sort(originalClasses, new PsiProximityComparator(referenceElement.getElement()));
    final JList list = new JBList(originalClasses.toArray(new PsiClass[originalClasses.size()]));
    list.setCellRenderer(new FQNameCellRenderer());
    final Runnable runnable = new Runnable() {
      @Override
      public void run() {
        if (!element.isValid()) return;
        final int index = list.getSelectedIndex();
        if (index < 0) return;
        new WriteCommandAction(project, element.getContainingFile()){
          @Override
          protected void run(@NotNull final Result result) throws Throwable {
            final PsiClass psiClass = originalClasses.get(index);
            if (psiClass.isValid()) {
              PsiDocumentManager.getInstance(project).commitAllDocuments();
              referenceElement.bindToElement(psiClass);
            }
          }
        }.execute();
      }
    };
    final AsyncResult<DataContext> asyncResult = DataManager.getInstance().getDataContextFromFocus();
    asyncResult.doWhenDone(new Consumer<DataContext>() {
      @Override
      public void consume(DataContext dataContext) {
        new PopupChooserBuilder(list).
          setTitle(QuickFixBundle.message("add.qualifier.original.class.chooser.title")).
          setItemChoosenCallback(runnable).
          createPopup().
          showInBestPositionFor(dataContext);
      }
    });
  }
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:40,代码来源:JavaDocReferenceInspection.java

示例9: doFix

import com.intellij.openapi.util.AsyncResult; //导入方法依赖的package包/类
@Override
protected void doFix(final Project project, ProblemDescriptor descriptor) throws IncorrectOperationException {
  final PsiElement element = PsiTreeUtil.getParentOfType(descriptor.getPsiElement(), PsiClass.class, PsiMethod.class);
  final AsyncResult<DataContext> context = DataManager.getInstance().getDataContextFromFocus();
  context.doWhenDone(new Consumer<DataContext>() {
    @Override
    public void consume(DataContext dataContext) {
      final JavaRefactoringActionHandlerFactory factory = JavaRefactoringActionHandlerFactory.getInstance();
      final RefactoringActionHandler handler = factory.createReplaceConstructorWithFactoryHandler();
      handler.invoke(project, new PsiElement[]{element}, dataContext);
    }
  });
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:14,代码来源:PublicConstructorInspection.java

示例10: doFix

import com.intellij.openapi.util.AsyncResult; //导入方法依赖的package包/类
@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);
    }
  });
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:16,代码来源:IntroduceVariableFix.java

示例11: applyFix

import com.intellij.openapi.util.AsyncResult; //导入方法依赖的package包/类
@Override
public void applyFix(@NotNull final Project project, @NotNull ProblemDescriptor descriptor) {
  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[]{myExpr}, dataContext);
    }
  });
  // how to automatically annotate the variable after it has been introduced?
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:13,代码来源:PatternValidator.java

示例12: applyFix

import com.intellij.openapi.util.AsyncResult; //导入方法依赖的package包/类
@Override
public void applyFix(@NotNull final Project project, @NotNull final ProblemDescriptor descriptor) {
  final PsiElement element = PsiTreeUtil.getParentOfType(descriptor.getPsiElement(), PsiJavaCodeReferenceElement.class);
  if (element instanceof PsiJavaCodeReferenceElement) {
    final PsiJavaCodeReferenceElement referenceElement = (PsiJavaCodeReferenceElement)element;
    Collections.sort(originalClasses, new PsiProximityComparator(referenceElement.getElement()));
    final JList list = new JBList(originalClasses.toArray(new PsiClass[originalClasses.size()]));
    list.setCellRenderer(new FQNameCellRenderer());
    final Runnable runnable = new Runnable() {
      @Override
      public void run() {
        if (!element.isValid()) return;
        final int index = list.getSelectedIndex();
        if (index < 0) return;
        new WriteCommandAction(project, element.getContainingFile()){
          @Override
          protected void run(final Result result) throws Throwable {
            final PsiClass psiClass = originalClasses.get(index);
            if (psiClass.isValid()) {
              PsiDocumentManager.getInstance(project).commitAllDocuments();
              referenceElement.bindToElement(psiClass);
            }
          }
        }.execute();
      }
    };
    final AsyncResult<DataContext> asyncResult = DataManager.getInstance().getDataContextFromFocus();
    asyncResult.doWhenDone(new AsyncResult.Handler<DataContext>() {
      @Override
      public void run(DataContext dataContext) {
        new PopupChooserBuilder(list).
          setTitle(QuickFixBundle.message("add.qualifier.original.class.chooser.title")).
          setItemChoosenCallback(runnable).
          createPopup().
          showInBestPositionFor(dataContext);
      }
    });
  }
}
 
开发者ID:lshain-android-source,项目名称:tools-idea,代码行数:40,代码来源:JavaDocReferenceInspection.java

示例13: doFix

import com.intellij.openapi.util.AsyncResult; //导入方法依赖的package包/类
@Override
protected void doFix(final Project project, ProblemDescriptor descriptor) throws IncorrectOperationException {
  final PsiElement element = PsiTreeUtil.getParentOfType(descriptor.getPsiElement(), PsiClass.class, PsiMethod.class);
  final AsyncResult<DataContext> context = DataManager.getInstance().getDataContextFromFocus();
  context.doWhenDone(new AsyncResult.Handler<DataContext>() {
    @Override
    public void run(DataContext dataContext) {
      final JavaRefactoringActionHandlerFactory factory = JavaRefactoringActionHandlerFactory.getInstance();
      final RefactoringActionHandler handler = factory.createReplaceConstructorWithFactoryHandler();
      handler.invoke(project, new PsiElement[]{element}, dataContext);
    }
  });
}
 
开发者ID:lshain-android-source,项目名称:tools-idea,代码行数:14,代码来源:PublicConstructorInspection.java

示例14: doFix

import com.intellij.openapi.util.AsyncResult; //导入方法依赖的package包/类
@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 AsyncResult.Handler<DataContext>() {
    @Override
    public void run(DataContext dataContext) {
      handler.invoke(project, new PsiElement[]{expression}, dataContext);
    }
  });
}
 
开发者ID:lshain-android-source,项目名称:tools-idea,代码行数:16,代码来源:IntroduceVariableFix.java

示例15: applyFix

import com.intellij.openapi.util.AsyncResult; //导入方法依赖的package包/类
public void applyFix(@NotNull final Project project, @NotNull ProblemDescriptor descriptor) {
  final RefactoringActionHandler handler = JavaRefactoringActionHandlerFactory.getInstance().createIntroduceVariableHandler();
  final AsyncResult<DataContext> dataContextContainer = DataManager.getInstance().getDataContextFromFocus();
  dataContextContainer.doWhenDone(new AsyncResult.Handler<DataContext>() {
    public void run(DataContext dataContext) {
      handler.invoke(project, new PsiElement[]{myExpr}, dataContext);
    }
  });
  // how to automatically annotate the variable after it has been introduced?
}
 
开发者ID:lshain-android-source,项目名称:tools-idea,代码行数:11,代码来源:PatternValidator.java


注:本文中的com.intellij.openapi.util.AsyncResult.doWhenDone方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。