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


Java ProgressWrapper.wrap方法代码示例

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


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

示例1: invokeConcurrentlyUnderProgress

import com.intellij.openapi.progress.util.ProgressWrapper; //导入方法依赖的package包/类
@Override
public <T> boolean invokeConcurrentlyUnderProgress(@NotNull List<? extends T> things,
                                                   ProgressIndicator progress,
                                                   boolean runInReadAction,
                                                   boolean failFastOnAcquireReadAction,
                                                   @NotNull Processor<T> thingProcessor) {
  if (things.isEmpty()) {
    return true;
  }
  if (things.size() == 1) {
    T t = things.get(0);
    return thingProcessor.process(t);
  }

  // can be already wrapped
  final ProgressWrapper wrapper = progress instanceof ProgressWrapper ? (ProgressWrapper)progress : ProgressWrapper.wrap(progress);
  return invokeConcurrentlyForAll(things, runInReadAction, failFastOnAcquireReadAction, thingProcessor, wrapper);
}
 
开发者ID:lshain-android-source,项目名称:tools-idea,代码行数:19,代码来源:JobLauncherImpl.java

示例2: checkFile

import com.intellij.openapi.progress.util.ProgressWrapper; //导入方法依赖的package包/类
private void checkFile(final PsiFile file,
                       final InspectionManager manager,
                       GlobalInspectionContextBase context,
                       final RefManager refManager,
                       final ProblemDescriptionsProcessor processor) {
  if (!(file instanceof PropertiesFile)) return;
  if (!context.isToCheckFile(file, this)) return;
  final PsiSearchHelper searchHelper = PsiSearchHelper.SERVICE.getInstance(file.getProject());
  final PropertiesFile propertiesFile = (PropertiesFile)file;
  final List<IProperty> properties = propertiesFile.getProperties();
  Module module = ModuleUtilCore.findModuleForPsiElement(file);
  if (module == null) return;
  final GlobalSearchScope scope = CURRENT_FILE
                                  ? GlobalSearchScope.fileScope(file)
                                  : MODULE_WITH_DEPENDENCIES
                                    ? GlobalSearchScope.moduleWithDependenciesScope(module)
                                    : GlobalSearchScope.projectScope(file.getProject());
  final Map<String, Set<PsiFile>> processedValueToFiles = Collections.synchronizedMap(new HashMap<String, Set<PsiFile>>());
  final Map<String, Set<PsiFile>> processedKeyToFiles = Collections.synchronizedMap(new HashMap<String, Set<PsiFile>>());
  final ProgressIndicator original = ProgressManager.getInstance().getProgressIndicator();
  final ProgressIndicator progress = ProgressWrapper.wrap(original);
  ProgressManager.getInstance().runProcess(new Runnable() {
    @Override
    public void run() {
      if (!JobLauncher.getInstance().invokeConcurrentlyUnderProgress(properties, progress, false, new Processor<IProperty>() {
        @Override
        public boolean process(final IProperty property) {
          if (original != null) {
            if (original.isCanceled()) return false;
            original.setText2(PropertiesBundle.message("searching.for.property.key.progress.text", property.getUnescapedKey()));
          }
          processTextUsages(processedValueToFiles, property.getValue(), processedKeyToFiles, searchHelper, scope);
          processTextUsages(processedKeyToFiles, property.getUnescapedKey(), processedValueToFiles, searchHelper, scope);
          return true;
        }
      })) throw new ProcessCanceledException();

      List<ProblemDescriptor> problemDescriptors = new ArrayList<ProblemDescriptor>();
      Map<String, Set<String>> keyToDifferentValues = new HashMap<String, Set<String>>();
      if (CHECK_DUPLICATE_KEYS || CHECK_DUPLICATE_KEYS_WITH_DIFFERENT_VALUES) {
        prepareDuplicateKeysByFile(processedKeyToFiles, manager, keyToDifferentValues, problemDescriptors, file, original);
      }
      if (CHECK_DUPLICATE_VALUES) prepareDuplicateValuesByFile(processedValueToFiles, manager, problemDescriptors, file, original);
      if (CHECK_DUPLICATE_KEYS_WITH_DIFFERENT_VALUES) {
        processDuplicateKeysWithDifferentValues(keyToDifferentValues, processedKeyToFiles, problemDescriptors, manager, file, original);
      }
      if (!problemDescriptors.isEmpty()) {
        processor.addProblemElement(refManager.getReference(file),
                                    problemDescriptors.toArray(new ProblemDescriptor[problemDescriptors.size()]));
      }
    }
  }, progress);
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:54,代码来源:DuplicatePropertyInspection.java

示例3: checkFile

import com.intellij.openapi.progress.util.ProgressWrapper; //导入方法依赖的package包/类
private void checkFile(final PsiFile file, final InspectionManager manager, GlobalInspectionContextImpl context, final RefManager refManager, final ProblemDescriptionsProcessor processor) {
  if (!(file instanceof PropertiesFile)) return;
  if (!context.isToCheckFile(file, this)) return;
  final PsiSearchHelper searchHelper = PsiSearchHelper.SERVICE.getInstance(file.getProject());
  final PropertiesFile propertiesFile = (PropertiesFile)file;
  final List<IProperty> properties = propertiesFile.getProperties();
  Module module = ModuleUtil.findModuleForPsiElement(file);
  if (module == null) return;
  final GlobalSearchScope scope = CURRENT_FILE
                                  ? GlobalSearchScope.fileScope(file)
                                  : MODULE_WITH_DEPENDENCIES
                                    ? GlobalSearchScope.moduleWithDependenciesScope(module)
                                    : GlobalSearchScope.projectScope(file.getProject());
  final Map<String, Set<PsiFile>> processedValueToFiles = Collections.synchronizedMap(new HashMap<String, Set<PsiFile>>());
  final Map<String, Set<PsiFile>> processedKeyToFiles = Collections.synchronizedMap(new HashMap<String, Set<PsiFile>>());
  final ProgressIndicator original = ProgressManager.getInstance().getProgressIndicator();
  final ProgressIndicator progress = ProgressWrapper.wrap(original);
  ProgressManager.getInstance().runProcess(new Runnable() {
    @Override
    public void run() {
      if (!JobLauncher.getInstance().invokeConcurrentlyUnderProgress(properties, progress, false, new Processor<IProperty>() {
        @Override
        public boolean process(final IProperty property) {
          if (original != null) {
            if (original.isCanceled()) return false;
            original.setText2(PropertiesBundle.message("searching.for.property.key.progress.text", property.getUnescapedKey()));
          }
          processTextUsages(processedValueToFiles, property.getValue(), processedKeyToFiles, searchHelper, scope);
          processTextUsages(processedKeyToFiles, property.getUnescapedKey(), processedValueToFiles, searchHelper, scope);
          return true;
        }
      })) throw new ProcessCanceledException();

      List<ProblemDescriptor> problemDescriptors = new ArrayList<ProblemDescriptor>();
      Map<String, Set<String>> keyToDifferentValues = new HashMap<String, Set<String>>();
      if (CHECK_DUPLICATE_KEYS || CHECK_DUPLICATE_KEYS_WITH_DIFFERENT_VALUES) {
        prepareDuplicateKeysByFile(processedKeyToFiles, manager, keyToDifferentValues, problemDescriptors, file, original);
      }
      if (CHECK_DUPLICATE_VALUES) prepareDuplicateValuesByFile(processedValueToFiles, manager, problemDescriptors, file, original);
      if (CHECK_DUPLICATE_KEYS_WITH_DIFFERENT_VALUES) {
        processDuplicateKeysWithDifferentValues(keyToDifferentValues, processedKeyToFiles, problemDescriptors, manager, file, original);
      }
      if (!problemDescriptors.isEmpty()) {
        processor.addProblemElement(refManager.getReference(file),
                                    problemDescriptors.toArray(new ProblemDescriptor[problemDescriptors.size()]));
      }
    }
  }, progress);
}
 
开发者ID:lshain-android-source,项目名称:tools-idea,代码行数:50,代码来源:DuplicatePropertyInspection.java


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