本文整理汇总了Java中com.intellij.psi.util.PsiUtilCore.getProjectInReadAction方法的典型用法代码示例。如果您正苦于以下问题:Java PsiUtilCore.getProjectInReadAction方法的具体用法?Java PsiUtilCore.getProjectInReadAction怎么用?Java PsiUtilCore.getProjectInReadAction使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类com.intellij.psi.util.PsiUtilCore
的用法示例。
在下文中一共展示了PsiUtilCore.getProjectInReadAction方法的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: SearchParameters
import com.intellij.psi.util.PsiUtilCore; //导入方法依赖的package包/类
public SearchParameters(@NotNull PsiMethod method, @NotNull SearchScope scope, boolean strictSignatureSearch, @Nullable SearchRequestCollector optimizer) {
myMethod = method;
myScope = scope;
myStrictSignatureSearch = strictSignatureSearch;
isSharedOptimizer = optimizer != null;
myOptimizer = optimizer != null ? optimizer : new SearchRequestCollector(new SearchSession());
myProject = PsiUtilCore.getProjectInReadAction(method);
}
示例2: search
import com.intellij.psi.util.PsiUtilCore; //导入方法依赖的package包/类
public static Query<PsiReference> search(final SearchParameters parameters) {
final Query<PsiReference> result = INSTANCE.createQuery(parameters);
if (parameters.isSharedOptimizer) {
return uniqueResults(result);
}
final SearchRequestCollector requests = parameters.getOptimizer();
Project project = PsiUtilCore.getProjectInReadAction(parameters.getMethod());
return uniqueResults(new MergeQuery<PsiReference>(result, new SearchRequestQuery(project, requests)));
}
示例3: SearchParameters
import com.intellij.psi.util.PsiUtilCore; //导入方法依赖的package包/类
public SearchParameters(@NotNull PsiElement elementToSearch, @NotNull SearchScope scope, boolean ignoreAccessScope, @Nullable SearchRequestCollector optimizer) {
myElementToSearch = elementToSearch;
myScope = scope;
myIgnoreAccessScope = ignoreAccessScope;
isSharedOptimizer = optimizer != null;
myOptimizer = optimizer == null ? new SearchRequestCollector(new SearchSession()) : optimizer;
myProject = PsiUtilCore.getProjectInReadAction(elementToSearch);
}
示例4: processInheritors
import com.intellij.psi.util.PsiUtilCore; //导入方法依赖的package包/类
private static void processInheritors(@NotNull final Processor<PsiClass> consumer,
@NotNull final PsiClass baseClass,
@NotNull final SearchScope searchScope,
@NotNull final ClassInheritorsSearch.SearchParameters parameters) {
if (baseClass instanceof PsiAnonymousClass || isFinal(baseClass)) return;
Project project = PsiUtilCore.getProjectInReadAction(baseClass);
if (isJavaLangObject(baseClass)) {
AllClassesSearch.search(searchScope, project, parameters.getNameCondition()).forEach(new Processor<PsiClass>() {
@Override
public boolean process(final PsiClass aClass) {
ProgressManager.checkCanceled();
return isJavaLangObject(aClass) || consumer.process(aClass);
}
});
return;
}
final Ref<PsiClass> currentBase = Ref.create(null);
final Stack<PsiAnchor> stack = new Stack<PsiAnchor>();
final Set<PsiAnchor> processed = ContainerUtil.newTroveSet();
final Processor<PsiClass> processor = new ReadActionProcessor<PsiClass>() {
@Override
public boolean processInReadAction(PsiClass candidate) {
ProgressManager.checkCanceled();
if (parameters.isCheckInheritance() || parameters.isCheckDeep() && !(candidate instanceof PsiAnonymousClass)) {
if (!candidate.isInheritor(currentBase.get(), false)) {
return true;
}
}
if (PsiSearchScopeUtil.isInScope(searchScope, candidate)) {
if (candidate instanceof PsiAnonymousClass) {
return consumer.process(candidate);
}
final String name = candidate.getName();
if (name != null && parameters.getNameCondition().value(name) && !consumer.process(candidate)) {
return false;
}
}
if (parameters.isCheckDeep() && !(candidate instanceof PsiAnonymousClass) && !isFinal(candidate)) {
stack.push(PsiAnchor.create(candidate));
}
return true;
}
};
ApplicationManager.getApplication().runReadAction(new Runnable() {
@Override
public void run() {
stack.push(PsiAnchor.create(baseClass));
}
});
final GlobalSearchScope projectScope = GlobalSearchScope.allScope(project);
while (!stack.isEmpty()) {
ProgressManager.checkCanceled();
final PsiAnchor anchor = stack.pop();
if (!processed.add(anchor)) continue;
PsiClass psiClass = ApplicationManager.getApplication().runReadAction(new Computable<PsiClass>() {
@Override
public PsiClass compute() {
return (PsiClass)anchor.retrieve();
}
});
if (psiClass == null) continue;
currentBase.set(psiClass);
if (!DirectClassInheritorsSearch.search(psiClass, projectScope, parameters.isIncludeAnonymous(), false).forEach(processor)) return;
}
}
示例5: execute
import com.intellij.psi.util.PsiUtilCore; //导入方法依赖的package包/类
@Override
public boolean execute(@NotNull final ReferencesSearch.SearchParameters queryParameters, @NotNull final Processor<PsiReference> consumer) {
final PsiElement elementToSearch = queryParameters.getElementToSearch();
if (elementToSearch instanceof PsiField) {
final PsiField field = (PsiField)elementToSearch;
final PsiClass containingClass = ApplicationManager.getApplication().runReadAction(new Computable<PsiClass>() {
@Override
public PsiClass compute() {
return field.getContainingClass();
}
});
if (containingClass != null) {
final String qualifiedName = ApplicationManager.getApplication().runReadAction(new Computable<String>() {
@Override
public String compute() {
return containingClass.getQualifiedName();
}
});
if (qualifiedName != null) {
Project project = PsiUtilCore.getProjectInReadAction(containingClass);
final List<PsiFile> fxmlWithController =
JavaFxControllerClassIndex.findFxmlWithController(project, qualifiedName);
for (final PsiFile file : fxmlWithController) {
ApplicationManager.getApplication().runReadAction(new Runnable() {
@Override
public void run() {
final String fieldName = field.getName();
final VirtualFile virtualFile = file.getViewProvider().getVirtualFile();
final SearchScope searchScope = queryParameters.getEffectiveSearchScope();
boolean contains = searchScope instanceof LocalSearchScope ? ((LocalSearchScope)searchScope).isInScope(virtualFile) :
((GlobalSearchScope)searchScope).contains(virtualFile);
if (contains) {
file.accept(new XmlRecursiveElementVisitor() {
@Override
public void visitXmlAttributeValue(final XmlAttributeValue value) {
final PsiReference reference = value.getReference();
if (reference != null) {
final PsiElement resolve = reference.resolve();
if (resolve instanceof XmlAttributeValue) {
final PsiElement parent = resolve.getParent();
if (parent instanceof XmlAttribute) {
final XmlAttribute attribute = (XmlAttribute)parent;
if (FxmlConstants.FX_ID.equals(attribute.getName()) && fieldName.equals(attribute.getValue())) {
consumer.process(reference);
}
}
}
}
}
});
}
}
});
}
}
}
}
return true;
}
示例6: execute
import com.intellij.psi.util.PsiUtilCore; //导入方法依赖的package包/类
@Override
public boolean execute(@NotNull SearchParameters queryParameters, @NotNull Processor<SchemaTypeDef> consumer) {
final SchemaTypeDef target = queryParameters.schemaTypeDef;
final Project project = PsiUtilCore.getProjectInReadAction(target);
Application application = ApplicationManager.getApplication();
List<SchemaTypeDef> candidates = application.runReadAction(
(Computable<List<SchemaTypeDef>>) () -> SchemaIndexUtil.findTypeDefs(project, null, null, SchemaSearchScopeUtil.getSearchScope(target))
);
final List<SchemaTypeDef> children = new ArrayList<>();
for (SchemaTypeDef candidate : candidates) {
ProgressManager.checkCanceled();
application.runReadAction(() -> {
List<SchemaTypeDef> candidateParents = candidate.extendsParents();
children.addAll(
candidateParents.stream()
.filter(target::equals)
.map(candidateParent -> candidate)
.collect(Collectors.toList()));
});
}
// -- process 'supplements'
if (target instanceof SchemaRecordTypeDef) {
SchemaRecordTypeDef recordTypeDef = (SchemaRecordTypeDef) target;
children.addAll(application.runReadAction((Computable<List<SchemaTypeDef>>) recordTypeDef::supplemented));
} else if (target instanceof SchemaEntityTypeDef) {
SchemaEntityTypeDef entityTypeDef = (SchemaEntityTypeDef) target;
children.addAll(application.runReadAction((Computable<List<SchemaTypeDef>>) entityTypeDef::supplemented));
}
// -- process 'supplement x with y'
application.runReadAction(() -> {
List<SchemaSupplementDef> supplements = SchemaIndexUtil.findSupplementsBySource(project, target);
for (SchemaSupplementDef supplement : supplements) {
children.addAll(supplement.supplemented());
}
});
children.forEach(consumer::process);
return true;
}
示例7: execute
import com.intellij.psi.util.PsiUtilCore; //导入方法依赖的package包/类
@Override
public boolean execute(@NotNull SearchParameters queryParameters, @NotNull Processor<SchemaTypeDef> consumer) {
final SchemaTypeDef target = queryParameters.schemaTypeDef;
final Project project = PsiUtilCore.getProjectInReadAction(target);
final VirtualFile targetVirtualFile = VirtualFileUtil.getOriginalVirtualFile(target.getContainingFile());
if (targetVirtualFile == null) return true;
final Application application = ApplicationManager.getApplication();
final List<SchemaTypeDef> parents = new ArrayList<>();
if (queryParameters.includeExtends) {
application.runReadAction(() -> {
parents.addAll(target.extendsParents());
});
}
// -- process 'supplements'
if (queryParameters.includeSupplements) {
List<SchemaTypeDef> candidates = application.runReadAction(
(Computable<List<SchemaTypeDef>>) () -> SchemaIndexUtil.findTypeDefs(project, null, null, GlobalSearchScope.allScope(project))
);
for (SchemaTypeDef candidate : candidates) {
ProgressManager.checkCanceled();
application.runReadAction(() -> {
// supplemented type must be in the candidate's search scope
final GlobalSearchScope candidateScope = SchemaSearchScopeUtil.getSearchScope(candidate);
if (candidateScope.contains(targetVirtualFile)) {
List<SchemaTypeDef> supplementedList = null;
if (candidate instanceof SchemaRecordTypeDef) {
SchemaRecordTypeDef recordTypeDef = (SchemaRecordTypeDef) candidate;
supplementedList = recordTypeDef.supplemented();
} else if (candidate instanceof SchemaEntityTypeDef) {
SchemaEntityTypeDef entityTypeDef = (SchemaEntityTypeDef) candidate;
supplementedList = entityTypeDef.supplemented();
}
if (supplementedList != null && supplementedList.stream().anyMatch(target::equals))
parents.add(candidate);
// parents.addAll(
// supplementedList.stream()
// .filter(target::equals)
// .map(candidateChild -> candidate)
// .collect(Collectors.toList()));
}
});
}
}
// -- process 'supplement x with y'
if (queryParameters.includeStandaloneSupplements) {
application.runReadAction(() -> {
List<SchemaSupplementDef> supplements = SchemaIndexUtil.findSupplementsBySupplemented(project, target);
parents.addAll(supplements.stream()
.map(SchemaSupplementDef::source)
.filter(Objects::nonNull)
.collect(Collectors.toList()));
});
}
parents.forEach(consumer::process);
return true;
}