本文整理汇总了Java中com.intellij.util.Processor类的典型用法代码示例。如果您正苦于以下问题:Java Processor类的具体用法?Java Processor怎么用?Java Processor使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
Processor类属于com.intellij.util包,在下文中一共展示了Processor类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: doExecute
import com.intellij.util.Processor; //导入依赖的package包/类
private Boolean doExecute(ReferencesSearch.SearchParameters queryParameters, final Processor<PsiReference> consumer) {
final PsiElement element = queryParameters.getElementToSearch(); //was selector_identifier->redefined in
DictionaryComponent dictionaryComponent = null;
if (element instanceof DictionaryComponent) {
dictionaryComponent = (DictionaryComponent) element;
}
if (dictionaryComponent == null) return true;
final List<String> parts = dictionaryComponent.getNameIdentifiers();
if (parts.isEmpty())
return true;
final String componentName = dictionaryComponent.getName(); //or just getName()...
final PsiSearchHelper helper = PsiSearchHelper.SERVICE.getInstance(element.getProject());
String searchWord = parts.get(0);
return searchWord.isEmpty() || helper.processElementsWithWord(new MyOccurrenceProcessor(dictionaryComponent, componentName, consumer),
queryParameters.getScopeDeterminedByUser(), searchWord, UsageSearchContext.IN_CODE, true);
}
开发者ID:ant-druha,项目名称:AppleScript-IDEA,代码行数:21,代码来源:AppleScriptDictionaryComponentReferencesSearch.java
示例2: assertIndex
import com.intellij.util.Processor; //导入依赖的package包/类
public void assertIndex(@NotNull ID<String, ?> id, boolean notCondition, @NotNull String... keys) {
for (String key : keys) {
final Collection<VirtualFile> virtualFiles = new ArrayList<VirtualFile>();
FileBasedIndexImpl.getInstance().getFilesWithKey(id, new HashSet<String>(Arrays.asList(key)), new Processor<VirtualFile>() {
@Override
public boolean process(VirtualFile virtualFile) {
virtualFiles.add(virtualFile);
return true;
}
}, GlobalSearchScope.allScope(getProject()));
if(notCondition && virtualFiles.size() > 0) {
fail(String.format("Fail that ID '%s' not contains '%s'", id.toString(), key));
} else if(!notCondition && virtualFiles.size() == 0) {
fail(String.format("Fail that ID '%s' contains '%s'", id.toString(), key));
}
}
}
示例3: filterElements
import com.intellij.util.Processor; //导入依赖的package包/类
@Override
public boolean filterElements(@NotNull ChooseByNameBase base, @NotNull String pattern, boolean everywhere, @NotNull ProgressIndicator indicator, @NotNull Processor<Object> consumer) {
Collection<SearchResultElement> elements = getAllFilterItems();
if (elements != null) {
for (SearchResultElement element : elements) {
String value = element.getValue();
if (value == null) {
return false;
}
if (value.toLowerCase().contains(pattern.toLowerCase()) && !consumer.process(element)) {
return false;
}
}
}
return false;
}
示例4: processPackageDirectories
import com.intellij.util.Processor; //导入依赖的package包/类
@Override
public boolean processPackageDirectories(@NotNull PsiPackage psiPackage,
@NotNull final GlobalSearchScope scope,
@NotNull final Processor<PsiDirectory> consumer,
boolean includeLibrarySources) {
//System.out.println( "processDirectories() : " + psiPackage + " : " + scope );
final PsiManager psiManager = PsiManager.getInstance( _project );
return PackageIndex.getInstance( _project )
.getDirsByPackageName(psiPackage.getQualifiedName(), includeLibrarySources)
.forEach(new ReadActionProcessor<VirtualFile>() {
@Override
public boolean processInReadAction(final VirtualFile dir) {
if (!scope.contains(dir)) return true;
PsiDirectory psiDir = psiManager.findDirectory(dir);
return psiDir == null || consumer.process(psiDir);
}
});
}
示例5: findTagUsage
import com.intellij.util.Processor; //导入依赖的package包/类
private int findTagUsage(XmlTag element) {
final FindUsagesHandler handler = FindUsageUtils.getFindUsagesHandler(element, element.getProject());
if (handler != null) {
final FindUsagesOptions findUsagesOptions = handler.getFindUsagesOptions();
final PsiElement[] primaryElements = handler.getPrimaryElements();
final PsiElement[] secondaryElements = handler.getSecondaryElements();
Factory factory = new Factory() {
public UsageSearcher create() {
return FindUsageUtils.createUsageSearcher(primaryElements, secondaryElements, handler, findUsagesOptions, (PsiFile) null);
}
};
UsageSearcher usageSearcher = (UsageSearcher)factory.create();
final AtomicInteger mCount = new AtomicInteger(0);
usageSearcher.generate(new Processor<Usage>() {
@Override
public boolean process(Usage usage) {
if (ResourceUsageCountUtils.isUsefulUsageToCount(usage)) {
mCount.incrementAndGet();
}
return true;
}
});
return mCount.get();
}
return 0;
}
示例6: processTextOccurrence
import com.intellij.util.Processor; //导入依赖的package包/类
@Override
public boolean processTextOccurrence(@NotNull final PsiElement element, int offsetInElement, @NotNull Processor<PsiReference> consumer) {
String alias = getAlias(element);
if (alias == null) return true;
final PsiReference reference = element.getReference();
if (reference == null) {
return true;
}
if (!reference.isReferenceTo(myTarget instanceof GrAccessorMethod ? ((GrAccessorMethod)myTarget).getProperty() : myTarget)) {
return true;
}
final SearchRequestCollector collector = new SearchRequestCollector(mySession);
final SearchScope fileScope = new LocalSearchScope(element.getContainingFile());
collector.searchWord(alias, fileScope, UsageSearchContext.IN_CODE, true, myTarget);
if (prefix != null) {
collector.searchWord(prefix + GroovyPropertyUtils.capitalize(alias), fileScope, UsageSearchContext.IN_CODE, true, myTarget);
}
return PsiSearchHelper.SERVICE.getInstance(element.getProject()).processRequests(collector, consumer);
}
示例7: getBaseVersionContent
import com.intellij.util.Processor; //导入依赖的package包/类
@Override
public boolean getBaseVersionContent(FilePath filePath,
Processor<CharSequence> processor,
final String beforeVersionId,
List<String> warnings)
throws VcsException {
if (StringUtil.isEmptyOrSpaces(beforeVersionId) || filePath.getVirtualFile() == null) return false;
// apply if base revision id matches revision
final VirtualFile root = GitUtil.getGitRoot(filePath);
if (root == null) return false;
final SHAHash shaHash = GitChangeUtils.commitExists(myProject, root, beforeVersionId, null, "HEAD");
if (shaHash == null) {
throw new VcsException("Can not apply patch to " + filePath.getPath() + ".\nCan not find revision '" + beforeVersionId + "'.");
}
final ContentRevision content = GitVcs.getInstance(myProject).getDiffProvider()
.createFileContent(new GitRevisionNumber(shaHash.getValue()), filePath.getVirtualFile());
if (content == null) {
throw new VcsException("Can not load content of '" + filePath.getPath() + "' for revision '" + shaHash.getValue() + "'");
}
return ! processor.process(content.getContent());
}
示例8: searchDependencyUsages
import com.intellij.util.Processor; //导入依赖的package包/类
@NotNull
public static Set<MavenDomDependency> searchDependencyUsages(@NotNull final MavenDomProjectModel model,
@NotNull final DependencyConflictId dependencyId,
@NotNull final Set<MavenDomDependency> excludes) {
Project project = model.getManager().getProject();
final Set<MavenDomDependency> usages = new HashSet<MavenDomDependency>();
Processor<MavenDomProjectModel> collectProcessor = new Processor<MavenDomProjectModel>() {
public boolean process(MavenDomProjectModel mavenDomProjectModel) {
for (MavenDomDependency domDependency : mavenDomProjectModel.getDependencies().getDependencies()) {
if (excludes.contains(domDependency)) continue;
if (dependencyId.equals(DependencyConflictId.create(domDependency))) {
usages.add(domDependency);
}
}
return false;
}
};
processChildrenRecursively(model, collectProcessor, project, new HashSet<MavenDomProjectModel>(), true);
return usages;
}
示例9: buildChildren
import com.intellij.util.Processor; //导入依赖的package包/类
@NotNull
protected final Object[] buildChildren(@NotNull final HierarchyNodeDescriptor descriptor) {
final Object element = ((TypeHierarchyNodeDescriptor)descriptor).getPsiClass();
if (!(element instanceof PsiClass)) return ArrayUtil.EMPTY_OBJECT_ARRAY;
final PsiClass psiClass = (PsiClass)element;
if (CommonClassNames.JAVA_LANG_OBJECT.equals(psiClass.getQualifiedName())) {
return new Object[]{IdeBundle.message("node.hierarchy.java.lang.object")};
}
if (psiClass instanceof PsiAnonymousClass) return ArrayUtil.EMPTY_OBJECT_ARRAY;
if (psiClass.hasModifierProperty(PsiModifier.FINAL)) return ArrayUtil.EMPTY_OBJECT_ARRAY;
final SearchScope searchScope = psiClass.getUseScope().intersectWith(getSearchScope(myCurrentScopeType, psiClass));
final List<PsiClass> classes = new ArrayList<PsiClass>(ClassInheritorsSearch.search(psiClass, searchScope, false).findAll());
final List<HierarchyNodeDescriptor> descriptors = new ArrayList<HierarchyNodeDescriptor>(classes.size());
for (PsiClass aClass : classes) {
descriptors.add(new TypeHierarchyNodeDescriptor(myProject, descriptor, aClass, false));
}
FunctionalExpressionSearch.search(psiClass, searchScope).forEach(new Processor<PsiFunctionalExpression>() {
@Override
public boolean process(PsiFunctionalExpression expression) {
descriptors.add(new TypeHierarchyNodeDescriptor(myProject, descriptor, expression, false));
return true;
}
});
return descriptors.toArray(new HierarchyNodeDescriptor[descriptors.size()]);
}
示例10: getVirtualFilesByNameIgnoringCase
import com.intellij.util.Processor; //导入依赖的package包/类
@NotNull
private static Set<VirtualFile> getVirtualFilesByNameIgnoringCase(@NotNull final String name,
@NotNull final GlobalSearchScope scope,
@Nullable final IdFilter idFilter) {
final Set<String> keys = new THashSet<String>();
final FileBasedIndex index = FileBasedIndex.getInstance();
index.processAllKeys(NAME, new Processor<String>() {
@Override
public boolean process(String value) {
if (name.equalsIgnoreCase(value)) {
keys.add(value);
}
return true;
}
}, scope, idFilter);
// values accessed outside of provessAllKeys
final Set<VirtualFile> files = new THashSet<VirtualFile>();
for (String each : keys) {
files.addAll(index.getContainingFiles(NAME, each, scope));
}
return files;
}
示例11: processElements
import com.intellij.util.Processor; //导入依赖的package包/类
@Override
public <Key, Psi extends PsiElement> boolean processElements(@NotNull final StubIndexKey<Key, Psi> indexKey,
@NotNull final Key key,
@NotNull final Project project,
@Nullable final GlobalSearchScope scope,
@Nullable IdFilter idFilter,
@NotNull final Class<Psi> requiredClass,
@NotNull final Processor<? super Psi> processor) {
return doProcessStubs(indexKey, key, project, scope, new StubIdListContainerAction(idFilter, project) {
final PersistentFS fs = (PersistentFS)ManagingFS.getInstance();
@Override
protected boolean process(int id, StubIdList value) {
final VirtualFile file = IndexInfrastructure.findFileByIdIfCached(fs, id);
if (file == null || scope != null && !scope.contains(file)) {
return true;
}
return myStubProcessingHelper.processStubsInFile(project, file, value, processor, requiredClass);
}
});
}
示例12: copyUnversionedMembersOfDirectory
import com.intellij.util.Processor; //导入依赖的package包/类
private static void copyUnversionedMembersOfDirectory(final File src, final File dst) throws SvnBindException {
if (src.isDirectory()) {
final SvnBindException[] exc = new SvnBindException[1];
FileUtil.processFilesRecursively(src, new Processor<File>() {
@Override
public boolean process(File file) {
String relativePath = FileUtil.getRelativePath(src, file);
File newFile = new File(dst, relativePath);
if (!newFile.exists()) {
try {
FileUtil.copyFileOrDir(src, dst);
}
catch (IOException e) {
exc[0] = new SvnBindException(e);
return false;
}
}
return true;
}
});
if (exc[0] != null) {
throw exc[0];
}
}
}
示例13: fun
import com.intellij.util.Processor; //导入依赖的package包/类
public String fun(final PyFunction pyFunction) {
final StringBuilder builder = new StringBuilder("<html>Is overridden in:");
final AtomicInteger count = new AtomicInteger();
PyClassInheritorsSearch.search(pyFunction.getContainingClass(), true).forEach(new Processor<PyClass>() {
public boolean process(PyClass pyClass) {
if (count.incrementAndGet() >= 10) {
builder.setLength(0);
builder.append("Has overridden methods");
return false;
}
if (pyClass.findMethodByName(pyFunction.getName(), false) != null) {
builder.append("<br> ").append(pyClass.getName());
}
return true;
}
});
return builder.toString();
}
示例14: process
import com.intellij.util.Processor; //导入依赖的package包/类
/**
* Process control flow graph in depth first order
*/
public static boolean process(final Instruction[] flow, final int start, final Processor<Instruction> processor){
final int length = flow.length;
boolean[] visited = new boolean[length];
Arrays.fill(visited, false);
final IntStack stack = new IntStack(length);
stack.push(start);
while (!stack.empty()) {
ProgressManager.checkCanceled();
final int num = stack.pop();
final Instruction instruction = flow[num];
if (!processor.process(instruction)){
return false;
}
for (Instruction succ : instruction.allSucc()) {
final int succNum = succ.num();
if (!visited[succNum]) {
visited[succNum] = true;
stack.push(succNum);
}
}
}
return true;
}
示例15: computeFiles
import com.intellij.util.Processor; //导入依赖的package包/类
@Override
protected VirtualFile[] computeFiles(final PsiFile file, final boolean compileTimeOnly) {
final Set<VirtualFile> files = new THashSet<VirtualFile>();
processIncludes(file, new Processor<FileIncludeInfo>() {
@Override
public boolean process(FileIncludeInfo info) {
if (compileTimeOnly != info.runtimeOnly) {
PsiFileSystemItem item = resolveFileInclude(info, file);
if (item != null) {
ContainerUtil.addIfNotNull(files, item.getVirtualFile());
}
}
return true;
}
});
return VfsUtilCore.toVirtualFileArray(files);
}