mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-09-10 13:17:09 +07:00
tests
This commit is contained in:
+13
-9
@@ -16,6 +16,7 @@
|
||||
package com.intellij.psi.impl.source.resolve;
|
||||
|
||||
import com.intellij.openapi.util.Key;
|
||||
import com.intellij.openapi.util.text.StringUtil;
|
||||
import com.intellij.psi.*;
|
||||
import com.intellij.psi.infos.CandidateInfo;
|
||||
import com.intellij.psi.infos.ClassCandidateInfo;
|
||||
@@ -91,6 +92,13 @@ public class ClassResolverProcessor extends BaseScopeProcessor implements NameHi
|
||||
}
|
||||
}
|
||||
|
||||
private static boolean isOnDemand(PsiElement fileContext, PsiClass psiClass) {
|
||||
if (fileContext instanceof PsiImportStatementBase && ((PsiImportStatementBase)fileContext).isOnDemand()) return true;
|
||||
String fqn = psiClass.getQualifiedName();
|
||||
if (fqn == null) return false;
|
||||
return "java.lang".equals(StringUtil.getPackageName(fqn));
|
||||
}
|
||||
|
||||
public boolean execute(PsiElement element, ResolveState state) {
|
||||
if (!(element instanceof PsiClass)) return true;
|
||||
final PsiClass aClass = (PsiClass)element;
|
||||
@@ -119,14 +127,11 @@ public class ClassResolverProcessor extends BaseScopeProcessor implements NameHi
|
||||
}
|
||||
|
||||
// single import wins over on-demand
|
||||
if (myCurrentFileContext instanceof PsiImportStatementBase &&
|
||||
info.getCurrentFileResolveScope() instanceof PsiImportStatementBase) {
|
||||
PsiImportStatementBase myImport = (PsiImportStatementBase)myCurrentFileContext;
|
||||
PsiImportStatementBase otherImport = (PsiImportStatementBase)info.getCurrentFileResolveScope();
|
||||
if (myImport.isOnDemand() && !otherImport.isOnDemand()) return true;
|
||||
if (!myImport.isOnDemand() && otherImport.isOnDemand()) {
|
||||
myCandidates.remove(i);
|
||||
}
|
||||
boolean myOnDemand = isOnDemand(myCurrentFileContext, aClass);
|
||||
boolean otherOnDemand = isOnDemand(info.getCurrentFileResolveScope(), otherClass);
|
||||
if (myOnDemand && !otherOnDemand) return true;
|
||||
if (!myOnDemand && otherOnDemand) {
|
||||
myCandidates.remove(i);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -140,7 +145,6 @@ public class ClassResolverProcessor extends BaseScopeProcessor implements NameHi
|
||||
if (!accessible) return true;
|
||||
if (!(myCurrentFileContext instanceof PsiImportStatementBase)) return false;
|
||||
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user