use of org.jetbrains.plugins.groovy.lang.psi.api.types.GrCodeReferenceElement in project intellij-community by JetBrains.
the class GrReferenceListImpl method getReferencedTypes.
@NotNull
@Override
public PsiClassType[] getReferencedTypes() {
if (myCachedTypes == null || !isValid()) {
final ArrayList<PsiClassType> types = new ArrayList<>();
for (GrCodeReferenceElement ref : getReferenceElementsGroovy()) {
types.add(new GrClassReferenceType(ref));
}
myCachedTypes = types.toArray(new PsiClassType[types.size()]);
}
return myCachedTypes;
}
use of org.jetbrains.plugins.groovy.lang.psi.api.types.GrCodeReferenceElement in project intellij-community by JetBrains.
the class GrImportStatementImpl method processSingleStaticImport.
private boolean processSingleStaticImport(@NotNull final PsiScopeProcessor processor, @NotNull ResolveState state, @NotNull String importedName, @Nullable PsiElement lastParent, @NotNull PsiElement place) {
final GrCodeReferenceElement ref = getImportReference();
if (ref == null)
return true;
PsiClass clazz = resolveQualifier();
if (clazz == null)
return true;
state = state.put(ClassHint.RESOLVE_CONTEXT, this);
final String refName = ref.getReferenceName();
for (PsiScopeProcessor each : GroovyResolverProcessor.allProcessors(processor)) {
if (!doProcessSingleStaticImport(each, state, importedName, lastParent, place, clazz, refName))
return false;
}
return true;
}
use of org.jetbrains.plugins.groovy.lang.psi.api.types.GrCodeReferenceElement in project intellij-community by JetBrains.
the class GrImportStatementImpl method processDeclarationsForMultipleElements.
private boolean processDeclarationsForMultipleElements(@NotNull final PsiScopeProcessor processor, @Nullable PsiElement lastParent, @NotNull PsiElement place, @NotNull ResolveState state) {
GrCodeReferenceElement ref = getImportReference();
if (ref == null)
return true;
if (isStatic()) {
final PsiElement resolved = ref.resolve();
if (resolved instanceof PsiClass) {
state = state.put(ClassHint.RESOLVE_CONTEXT, this);
final PsiClass clazz = (PsiClass) resolved;
for (final PsiScopeProcessor each : GroovyResolverProcessor.allProcessors(processor)) {
if (!clazz.processDeclarations(new DelegatingScopeProcessor(each) {
@Override
public boolean execute(@NotNull PsiElement element, @NotNull ResolveState state) {
if (element instanceof PsiMember && ((PsiMember) element).hasModifierProperty(PsiModifier.STATIC)) {
return super.execute(element, state);
}
return true;
}
}, state, lastParent, place))
return false;
}
}
} else {
if (ResolveUtil.shouldProcessClasses(processor.getHint(ElementClassHint.KEY))) {
String qName = PsiUtil.getQualifiedReferenceText(ref);
if (qName != null) {
PsiPackage aPackage = JavaPsiFacade.getInstance(getProject()).findPackage(qName);
if (aPackage != null && !((GroovyFile) getContainingFile()).getPackageName().equals(aPackage.getQualifiedName())) {
state = state.put(ClassHint.RESOLVE_CONTEXT, this);
if (!aPackage.processDeclarations(processor, state, lastParent, place))
return false;
}
}
}
}
return true;
}
use of org.jetbrains.plugins.groovy.lang.psi.api.types.GrCodeReferenceElement in project intellij-community by JetBrains.
the class GrImportStatementImpl method resolveQualifier.
@Nullable
private PsiClass resolveQualifier() {
return CachedValuesManager.getCachedValue(this, () -> {
GrCodeReferenceElement reference = getImportReference();
GrCodeReferenceElement qualifier = reference == null ? null : reference.getQualifier();
PsiElement target = qualifier == null ? null : qualifier.resolve();
PsiClass clazz = target instanceof PsiClass ? (PsiClass) target : null;
return CachedValueProvider.Result.create(clazz, PsiModificationTracker.JAVA_STRUCTURE_MODIFICATION_COUNT, this);
});
}
use of org.jetbrains.plugins.groovy.lang.psi.api.types.GrCodeReferenceElement in project intellij-community by JetBrains.
the class GrImportStatementImpl method resolveTargetClass.
@Nullable
@Override
public PsiClass resolveTargetClass() {
final GrCodeReferenceElement ref = getImportReference();
if (ref == null)
return null;
final PsiElement resolved;
if (!isStatic() || isOnDemand()) {
resolved = ref.resolve();
} else {
resolved = resolveQualifier();
}
return resolved instanceof PsiClass ? (PsiClass) resolved : null;
}
Aggregations