本文整理汇总了Java中com.intellij.psi.scope.BaseScopeProcessor类的典型用法代码示例。如果您正苦于以下问题:Java BaseScopeProcessor类的具体用法?Java BaseScopeProcessor怎么用?Java BaseScopeProcessor使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
BaseScopeProcessor类属于com.intellij.psi.scope包,在下文中一共展示了BaseScopeProcessor类的9个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: inferCastType
import com.intellij.psi.scope.BaseScopeProcessor; //导入依赖的package包/类
@Nullable
private static PsiType inferCastType(@NotNull GrExpression caller, @NotNull PsiMethod method, @NotNull GroovyPsiElement context) {
final PsiType type = caller.getType();
if (type instanceof PsiIntersectionType) {
final PsiType[] conjuncts = ((PsiIntersectionType)type).getConjuncts();
for (PsiType conjunct : conjuncts) {
final GenerationUtil.CheckProcessElement processor = new GenerationUtil.CheckProcessElement(method);
ResolveUtil.processAllDeclarationsSeparately(conjunct, processor, new BaseScopeProcessor() {
@Override
public boolean execute(@NotNull PsiElement element, @NotNull ResolveState state) {
return false;
}
}, ResolveState.initial(), context);
if (processor.isFound()) return conjunct;
}
}
return type;
}
示例2: inferCastType
import com.intellij.psi.scope.BaseScopeProcessor; //导入依赖的package包/类
@Nullable
private static PsiType inferCastType(@NotNull GrExpression caller, @NotNull PsiMethod method, @NotNull GroovyPsiElement context) {
final PsiType type = caller.getType();
if (type instanceof PsiIntersectionType) {
final PsiType[] conjuncts = ((PsiIntersectionType)type).getConjuncts();
for (PsiType conjunct : conjuncts) {
final CheckProcessElement processor = new CheckProcessElement(method);
ResolveUtil.processAllDeclarationsSeparately(conjunct, processor, new BaseScopeProcessor() {
@Override
public boolean execute(@NotNull PsiElement element, ResolveState state) {
return false;
}
}, ResolveState.initial(), context);
if (processor.isFound()) return conjunct;
}
}
return type;
}
示例3: processExecutors
import com.intellij.psi.scope.BaseScopeProcessor; //导入依赖的package包/类
private static void processExecutors(PsiType qtype, GrReferenceExpression ref, final ArrayList<ClosureDescriptor> descriptors) {
GroovyDslFileIndex.processExecutors(qtype, ref, new BaseScopeProcessor() {
@Override
public boolean execute(@NotNull PsiElement element, @NotNull ResolveState state) {
if (element instanceof ClosureDescriptor) {
descriptors.add((ClosureDescriptor)element);
}
return true;
}
}, ResolveState.initial());
}
示例4: isCastNeeded
import com.intellij.psi.scope.BaseScopeProcessor; //导入依赖的package包/类
public static boolean isCastNeeded(@NotNull GrExpression qualifier, @NotNull final PsiMember member, ExpressionContext context) {
PsiType declared = getDeclaredType(qualifier, context);
if (declared == null) return false;
final CheckProcessElement checker = new CheckProcessElement(member);
ResolveUtil.processAllDeclarationsSeparately(declared, checker, new BaseScopeProcessor() {
@Override
public boolean execute(@NotNull PsiElement element, @NotNull ResolveState state) {
return false;
}
}, ResolveState.initial(), qualifier);
return !checker.isFound();
}
示例5: processExecutors
import com.intellij.psi.scope.BaseScopeProcessor; //导入依赖的package包/类
private static void processExecutors(PsiType qtype, GrReferenceExpression ref, final ArrayList<ClosureDescriptor> descriptors) {
GroovyDslFileIndex.processExecutors(qtype, ref, new BaseScopeProcessor() {
@Override
public boolean execute(@NotNull PsiElement element, ResolveState state) {
if (element instanceof ClosureDescriptor) {
descriptors.add((ClosureDescriptor)element);
}
return true;
}
}, ResolveState.initial());
}
示例6: isCastNeeded
import com.intellij.psi.scope.BaseScopeProcessor; //导入依赖的package包/类
public static boolean isCastNeeded(@NotNull GrExpression qualifier, @NotNull final PsiMember member, ExpressionContext context) {
PsiType declared = getDeclaredType(qualifier, context);
if (declared == null) return false;
final CheckProcessElement checker = new CheckProcessElement(member);
ResolveUtil.processAllDeclarationsSeparately(declared, checker, new BaseScopeProcessor() {
@Override
public boolean execute(@NotNull PsiElement element, ResolveState state) {
return false;
}
}, ResolveState.initial(), qualifier);
return !checker.isFound();
}
示例7: isUsedNamespace
import com.intellij.psi.scope.BaseScopeProcessor; //导入依赖的package包/类
@RequiredReadAction
private boolean isUsedNamespace(String namespace, PsiElement target, PsiElement element)
{
return !CSharpResolveUtil.walkUsing(new BaseScopeProcessor()
{
@Override
@RequiredReadAction
public boolean execute(@NotNull PsiElement psiElement, ResolveState resolveState)
{
if(psiElement instanceof CSharpUsingTypeStatement)
{
DotNetTypeResolveResult typeResolveResult = ((CSharpUsingTypeStatement) psiElement).getTypeRef().resolve();
if(target.isEquivalentTo(typeResolveResult.getElement()))
{
return false;
}
}
else if(psiElement instanceof CSharpUsingNamespaceStatement)
{
String referenceText = ((CSharpUsingNamespaceStatement) psiElement).getReferenceText();
if(Objects.equals(namespace, referenceText))
{
return false;
}
}
return true;
}
}, element, null, ResolveState.initial());
}
示例8: collectItems
import com.intellij.psi.scope.BaseScopeProcessor; //导入依赖的package包/类
private LookupElement[] collectItems() {
Set<LookupElement> items = new LinkedHashSet<LookupElement>();
boolean qualified = myRefExpr.getQualifierExpression() != null;
if (!qualified && !(myRefExpr.getParent() instanceof PsiMethodCallExpression)) {
PsiVariable[] vars = CreateFromUsageUtils.guessMatchingVariables(myRefExpr);
for (PsiVariable var : vars) {
items.add(LookupElementBuilder.create(var.getName()));
}
} else {
class MyScopeProcessor extends BaseScopeProcessor {
ArrayList<PsiElement> myResult = new ArrayList<PsiElement>();
boolean myFilterMethods;
boolean myFilterStatics = false;
MyScopeProcessor(PsiReferenceExpression refExpression) {
myFilterMethods = refExpression.getParent() instanceof PsiMethodCallExpression;
PsiExpression qualifier = refExpression.getQualifierExpression();
if (qualifier instanceof PsiReferenceExpression) {
PsiElement e = ((PsiReferenceExpression) qualifier).resolve();
myFilterStatics = e instanceof PsiClass;
} else if (qualifier == null) {
PsiModifierListOwner scope = PsiTreeUtil.getParentOfType(refExpression, PsiModifierListOwner.class);
myFilterStatics = scope != null && scope.hasModifierProperty(PsiModifier.STATIC);
}
}
@Override
public boolean execute(@NotNull PsiElement element, @NotNull ResolveState state) {
if (element instanceof PsiNamedElement
&& element instanceof PsiModifierListOwner
&& myFilterMethods == element instanceof PsiMethod) {
if (((PsiModifierListOwner)element).hasModifierProperty(PsiModifier.STATIC) == myFilterStatics) {
myResult.add(element);
}
}
return true;
}
public PsiElement[] getVariants () {
return PsiUtilCore.toPsiElementArray(myResult);
}
}
items.add(LookupElementBuilder.create(myRefExpr.getReferenceName()));
MyScopeProcessor processor = new MyScopeProcessor(myRefExpr);
myRefExpr.processVariants(processor);
PsiElement[] variants = processor.getVariants();
for (PsiElement variant : variants) {
items.add(LookupElementBuilder.create(((PsiNamedElement)variant).getName()));
}
}
return items.toArray(new LookupElement[items.size()]);
}
示例9: collectItems
import com.intellij.psi.scope.BaseScopeProcessor; //导入依赖的package包/类
private LookupElement[] collectItems() {
Set<LookupElement> items = new LinkedHashSet<LookupElement>();
boolean qualified = myRefExpr.getQualifierExpression() != null;
if (!qualified && !(myRefExpr.getParent() instanceof PsiMethodCallExpression)) {
PsiVariable[] vars = CreateFromUsageUtils.guessMatchingVariables(myRefExpr);
for (PsiVariable var : vars) {
items.add(LookupElementBuilder.create(var.getName()));
}
} else {
class MyScopeProcessor extends BaseScopeProcessor {
ArrayList<PsiElement> myResult = new ArrayList<PsiElement>();
boolean myFilterMethods;
boolean myFilterStatics = false;
MyScopeProcessor(PsiReferenceExpression refExpression) {
myFilterMethods = refExpression.getParent() instanceof PsiMethodCallExpression;
PsiExpression qualifier = refExpression.getQualifierExpression();
if (qualifier instanceof PsiReferenceExpression) {
PsiElement e = ((PsiReferenceExpression) qualifier).resolve();
myFilterStatics = e instanceof PsiClass;
} else if (qualifier == null) {
PsiModifierListOwner scope = PsiTreeUtil.getParentOfType(refExpression, PsiModifierListOwner.class);
myFilterStatics = scope != null && scope.hasModifierProperty(PsiModifier.STATIC);
}
}
@Override
public boolean execute(@NotNull PsiElement element, ResolveState state) {
if (element instanceof PsiNamedElement
&& element instanceof PsiModifierListOwner
&& myFilterMethods == element instanceof PsiMethod) {
if (((PsiModifierListOwner)element).hasModifierProperty(PsiModifier.STATIC) == myFilterStatics) {
myResult.add(element);
}
}
return true;
}
public PsiElement[] getVariants () {
return PsiUtilCore.toPsiElementArray(myResult);
}
}
items.add(LookupElementBuilder.create(myRefExpr.getReferenceName()));
MyScopeProcessor processor = new MyScopeProcessor(myRefExpr);
myRefExpr.processVariants(processor);
PsiElement[] variants = processor.getVariants();
for (PsiElement variant : variants) {
items.add(LookupElementBuilder.create(((PsiNamedElement)variant).getName()));
}
}
return items.toArray(new LookupElement[items.size()]);
}