本文整理汇总了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);
}
示例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);
}
示例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);
}