本文整理匯總了Java中com.intellij.psi.search.PackageScope.packageScope方法的典型用法代碼示例。如果您正苦於以下問題:Java PackageScope.packageScope方法的具體用法?Java PackageScope.packageScope怎麽用?Java PackageScope.packageScope使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類com.intellij.psi.search.PackageScope
的用法示例。
在下文中一共展示了PackageScope.packageScope方法的10個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。
示例1: getMemberUseScope
import com.intellij.psi.search.PackageScope; //導入方法依賴的package包/類
@NotNull
public static SearchScope getMemberUseScope(@NotNull PsiMember member) {
PsiFile file = member.getContainingFile();
PsiElement topElement = file == null ? member : file;
Project project = topElement.getProject();
final GlobalSearchScope maximalUseScope = ResolveScopeManager.getInstance(project).getUseScope(topElement);
if (isInServerPage(file)) return maximalUseScope;
PsiClass aClass = member.getContainingClass();
if (aClass instanceof PsiAnonymousClass) {
//member from anonymous class can be called from outside the class
PsiElement methodCallExpr = PsiUtil.isLanguageLevel8OrHigher(aClass) ? PsiTreeUtil.getTopmostParentOfType(aClass, PsiStatement.class)
: PsiTreeUtil.getParentOfType(aClass, PsiMethodCallExpression.class);
return new LocalSearchScope(methodCallExpr != null ? methodCallExpr : aClass);
}
PsiModifierList modifierList = member.getModifierList();
int accessLevel = modifierList == null ? PsiUtil.ACCESS_LEVEL_PUBLIC : PsiUtil.getAccessLevel(modifierList);
if (accessLevel == PsiUtil.ACCESS_LEVEL_PUBLIC || accessLevel == PsiUtil.ACCESS_LEVEL_PROTECTED) {
return maximalUseScope; // class use scope doesn't matter, since another very visible class can inherit from aClass
}
if (accessLevel == PsiUtil.ACCESS_LEVEL_PRIVATE) {
PsiClass topClass = PsiUtil.getTopLevelClass(member);
return topClass != null ? new LocalSearchScope(topClass) : file == null ? maximalUseScope : new LocalSearchScope(file);
}
if (file instanceof PsiJavaFile) {
PsiPackage aPackage = JavaPsiFacade.getInstance(project).findPackage(((PsiJavaFile)file).getPackageName());
if (aPackage != null) {
SearchScope scope = PackageScope.packageScope(aPackage, false);
return scope.intersectWith(maximalUseScope);
}
}
return maximalUseScope;
}
示例2: processSubclassVariants
import com.intellij.psi.search.PackageScope; //導入方法依賴的package包/類
public void processSubclassVariants(@NotNull PsiPackage context, @NotNull String[] extendClasses, Consumer<LookupElement> result) {
GlobalSearchScope packageScope = PackageScope.packageScope(context, true);
GlobalSearchScope scope = myJavaClassReferenceSet.getProvider().getScope(getElement().getProject());
if (scope != null) {
packageScope = packageScope.intersectWith(scope);
}
final GlobalSearchScope allScope = ProjectScope.getAllScope(context.getProject());
final boolean instantiatable = JavaClassReferenceProvider.INSTANTIATABLE.getBooleanValue(getOptions());
final boolean notInterface = JavaClassReferenceProvider.NOT_INTERFACE.getBooleanValue(getOptions());
final boolean notEnum = JavaClassReferenceProvider.NOT_ENUM.getBooleanValue(getOptions());
final boolean concrete = JavaClassReferenceProvider.CONCRETE.getBooleanValue(getOptions());
final ClassKind classKind = getClassKind();
for (String extendClassName : extendClasses) {
final PsiClass extendClass = JavaPsiFacade.getInstance(context.getProject()).findClass(extendClassName, allScope);
if (extendClass != null) {
// add itself
if (packageScope.contains(extendClass.getContainingFile().getVirtualFile())) {
if (isClassAccepted(extendClass, classKind, instantiatable, concrete, notInterface, notEnum)) {
result.consume(createSubclassLookupValue(extendClass, extendClassName));
}
}
for (final PsiClass clazz : ClassInheritorsSearch.search(extendClass, packageScope, true)) {
String qname = clazz.getQualifiedName();
if (qname != null && isClassAccepted(clazz, classKind, instantiatable, concrete, notInterface, notEnum)) {
result.consume(createSubclassLookupValue(clazz, qname));
}
}
}
}
}
示例3: getClassUseScope
import com.intellij.psi.search.PackageScope; //導入方法依賴的package包/類
@NotNull
public static SearchScope getClassUseScope(@NotNull PsiClass aClass) {
if (aClass instanceof PsiAnonymousClass) {
return new LocalSearchScope(aClass);
}
final GlobalSearchScope maximalUseScope = ResolveScopeManager.getElementUseScope(aClass);
PsiFile file = aClass.getContainingFile();
if (PsiImplUtil.isInServerPage(file)) return maximalUseScope;
final PsiClass containingClass = aClass.getContainingClass();
if (aClass.hasModifierProperty(PsiModifier.PUBLIC) ||
aClass.hasModifierProperty(PsiModifier.PROTECTED)) {
return containingClass == null ? maximalUseScope : containingClass.getUseScope();
}
else if (aClass.hasModifierProperty(PsiModifier.PRIVATE) || aClass instanceof PsiTypeParameter) {
PsiClass topClass = PsiUtil.getTopLevelClass(aClass);
return new LocalSearchScope(topClass == null ? aClass.getContainingFile() : topClass);
}
else {
PsiPackage aPackage = null;
if (file instanceof PsiJavaFile) {
aPackage = JavaPsiFacade.getInstance(aClass.getProject()).findPackage(((PsiJavaFile)file).getPackageName());
}
if (aPackage == null) {
PsiDirectory dir = file.getContainingDirectory();
if (dir != null) {
aPackage = JavaDirectoryService.getInstance().getPackage(dir);
}
}
if (aPackage != null) {
SearchScope scope = PackageScope.packageScope(aPackage, false);
scope = scope.intersectWith(maximalUseScope);
return scope;
}
return new LocalSearchScope(file);
}
}
示例4: getMemberUseScope
import com.intellij.psi.search.PackageScope; //導入方法依賴的package包/類
@NotNull
public static SearchScope getMemberUseScope(@NotNull PsiMember member) {
final GlobalSearchScope maximalUseScope = ResolveScopeManager.getElementUseScope(member);
PsiFile file = member.getContainingFile();
if (isInServerPage(file)) return maximalUseScope;
PsiClass aClass = member.getContainingClass();
if (aClass instanceof PsiAnonymousClass) {
//member from anonymous class can be called from outside the class
PsiElement methodCallExpr = PsiTreeUtil.getParentOfType(aClass, PsiMethodCallExpression.class);
return new LocalSearchScope(methodCallExpr != null ? methodCallExpr : aClass);
}
if (member.hasModifierProperty(PsiModifier.PUBLIC)) {
return maximalUseScope; // class use scope doesn't matter, since another very visible class can inherit from aClass
}
else if (member.hasModifierProperty(PsiModifier.PROTECTED)) {
return maximalUseScope; // class use scope doesn't matter, since another very visible class can inherit from aClass
}
else if (member.hasModifierProperty(PsiModifier.PRIVATE)) {
PsiClass topClass = PsiUtil.getTopLevelClass(member);
return topClass != null ? new LocalSearchScope(topClass) : file != null ? new LocalSearchScope(file) : maximalUseScope;
}
else {
if (file instanceof PsiJavaFile) {
PsiPackage aPackage = JavaPsiFacade.getInstance(member.getProject()).findPackage(((PsiJavaFile)file).getPackageName());
if (aPackage != null) {
SearchScope scope = PackageScope.packageScope(aPackage, false);
scope = scope.intersectWith(maximalUseScope);
return scope;
}
}
return maximalUseScope;
}
}
示例5: processSubclassVariants
import com.intellij.psi.search.PackageScope; //導入方法依賴的package包/類
@NotNull
public void processSubclassVariants(@NotNull PsiPackage context, @NotNull String[] extendClasses, Consumer<LookupElement> result) {
GlobalSearchScope packageScope = PackageScope.packageScope(context, true);
GlobalSearchScope scope = myJavaClassReferenceSet.getProvider().getScope(getElement().getProject());
if (scope != null) {
packageScope = packageScope.intersectWith(scope);
}
final GlobalSearchScope allScope = ProjectScope.getAllScope(context.getProject());
final boolean instantiatable = JavaClassReferenceProvider.INSTANTIATABLE.getBooleanValue(getOptions());
final boolean notInterface = JavaClassReferenceProvider.NOT_INTERFACE.getBooleanValue(getOptions());
final boolean notEnum = JavaClassReferenceProvider.NOT_ENUM.getBooleanValue(getOptions());
final boolean concrete = JavaClassReferenceProvider.CONCRETE.getBooleanValue(getOptions());
final ClassKind classKind = getClassKind();
for (String extendClassName : extendClasses) {
final PsiClass extendClass = JavaPsiFacade.getInstance(context.getProject()).findClass(extendClassName, allScope);
if (extendClass != null) {
// add itself
if (packageScope.contains(extendClass.getContainingFile().getVirtualFile())) {
if (isClassAccepted(extendClass, classKind, instantiatable, concrete, notInterface, notEnum)) {
result.consume(createSubclassLookupValue(extendClass, extendClassName));
}
}
for (final PsiClass clazz : ClassInheritorsSearch.search(extendClass, packageScope, true)) {
String qname = clazz.getQualifiedName();
if (qname != null && isClassAccepted(clazz, classKind, instantiatable, concrete, notInterface, notEnum)) {
result.consume(createSubclassLookupValue(clazz, qname));
}
}
}
}
}
示例6: processSubclassVariants
import com.intellij.psi.search.PackageScope; //導入方法依賴的package包/類
public void processSubclassVariants(@NotNull PsiJavaPackage context, @NotNull String[] extendClasses, Consumer<LookupElement> result)
{
GlobalSearchScope packageScope = PackageScope.packageScope(context, true);
GlobalSearchScope scope = myJavaClassReferenceSet.getProvider().getScope(getElement().getProject());
if(scope != null)
{
packageScope = packageScope.intersectWith(scope);
}
final GlobalSearchScope allScope = ProjectScope.getAllScope(context.getProject());
final boolean instantiatable = JavaClassReferenceProvider.INSTANTIATABLE.getBooleanValue(getOptions());
final boolean notInterface = JavaClassReferenceProvider.NOT_INTERFACE.getBooleanValue(getOptions());
final boolean notEnum = JavaClassReferenceProvider.NOT_ENUM.getBooleanValue(getOptions());
final boolean concrete = JavaClassReferenceProvider.CONCRETE.getBooleanValue(getOptions());
final ClassKind classKind = getClassKind();
for(String extendClassName : extendClasses)
{
final PsiClass extendClass = JavaPsiFacade.getInstance(context.getProject()).findClass(extendClassName, allScope);
if(extendClass != null)
{
// add itself
if(packageScope.contains(extendClass.getContainingFile().getVirtualFile()))
{
if(isClassAccepted(extendClass, classKind, instantiatable, concrete, notInterface, notEnum))
{
result.consume(createSubclassLookupValue(extendClass, extendClassName));
}
}
for(final PsiClass clazz : ClassInheritorsSearch.search(extendClass, packageScope, true))
{
String qname = clazz.getQualifiedName();
if(qname != null && isClassAccepted(clazz, classKind, instantiatable, concrete, notInterface, notEnum))
{
result.consume(createSubclassLookupValue(clazz, qname));
}
}
}
}
}
示例7: filterScope
import com.intellij.psi.search.PackageScope; //導入方法依賴的package包/類
protected GlobalSearchScope filterScope(final JUnitConfiguration.Data data) throws CantRunException {
final PsiPackage aPackage = getPackage(data);
return PackageScope.packageScope(aPackage, true);
}
示例8: getClassUseScope
import com.intellij.psi.search.PackageScope; //導入方法依賴的package包/類
@NotNull
public static SearchScope getClassUseScope(@NotNull PsiClass aClass)
{
if(aClass instanceof PsiAnonymousClass)
{
return new LocalSearchScope(aClass);
}
final GlobalSearchScope maximalUseScope = ResolveScopeManager.getElementUseScope(aClass);
PsiFile file = aClass.getContainingFile();
if(PsiImplUtil.isInServerPage(file))
{
return maximalUseScope;
}
final PsiClass containingClass = aClass.getContainingClass();
if(aClass.hasModifierProperty(PsiModifier.PUBLIC) || aClass.hasModifierProperty(PsiModifier.PROTECTED))
{
return containingClass == null ? maximalUseScope : containingClass.getUseScope();
}
else if(aClass.hasModifierProperty(PsiModifier.PRIVATE) || aClass instanceof PsiTypeParameter)
{
PsiClass topClass = PsiUtil.getTopLevelClass(aClass);
return new LocalSearchScope(topClass == null ? aClass.getContainingFile() : topClass);
}
else
{
PsiJavaPackage aPackage = null;
if(file instanceof PsiJavaFile)
{
aPackage = JavaPsiFacade.getInstance(aClass.getProject()).findPackage(((PsiJavaFile) file).getPackageName());
}
if(aPackage == null)
{
PsiDirectory dir = file.getContainingDirectory();
if(dir != null)
{
aPackage = JavaDirectoryService.getInstance().getPackage(dir);
}
}
if(aPackage != null)
{
SearchScope scope = PackageScope.packageScope(aPackage, false);
scope = scope.intersectWith(maximalUseScope);
return scope;
}
return new LocalSearchScope(file);
}
}
示例9: getMemberUseScope
import com.intellij.psi.search.PackageScope; //導入方法依賴的package包/類
@NotNull
public static SearchScope getMemberUseScope(@NotNull PsiMember member)
{
PsiFile file = member.getContainingFile();
PsiElement topElement = file == null ? member : file;
Project project = topElement.getProject();
final GlobalSearchScope maximalUseScope = ResolveScopeManager.getInstance(project).getUseScope(topElement);
if(isInServerPage(file))
{
return maximalUseScope;
}
PsiClass aClass = member.getContainingClass();
if(aClass instanceof PsiAnonymousClass)
{
//member from anonymous class can be called from outside the class
PsiElement methodCallExpr = PsiUtil.isLanguageLevel8OrHigher(aClass) ? PsiTreeUtil.getTopmostParentOfType(aClass, PsiStatement.class) : PsiTreeUtil.getParentOfType(aClass,
PsiMethodCallExpression.class);
return new LocalSearchScope(methodCallExpr != null ? methodCallExpr : aClass);
}
PsiModifierList modifierList = member.getModifierList();
int accessLevel = modifierList == null ? PsiUtil.ACCESS_LEVEL_PUBLIC : PsiUtil.getAccessLevel(modifierList);
if(accessLevel == PsiUtil.ACCESS_LEVEL_PUBLIC || accessLevel == PsiUtil.ACCESS_LEVEL_PROTECTED)
{
return maximalUseScope; // class use scope doesn't matter, since another very visible class can inherit from aClass
}
if(accessLevel == PsiUtil.ACCESS_LEVEL_PRIVATE)
{
PsiClass topClass = PsiUtil.getTopLevelClass(member);
return topClass != null ? new LocalSearchScope(topClass) : file == null ? maximalUseScope : new LocalSearchScope(file);
}
if(file instanceof PsiJavaFile)
{
PsiJavaPackage aPackage = JavaPsiFacade.getInstance(project).findPackage(((PsiJavaFile) file).getPackageName());
if(aPackage != null)
{
SearchScope scope = PackageScope.packageScope(aPackage, false);
return scope.intersectWith(maximalUseScope);
}
}
return maximalUseScope;
}
示例10: processFieldRemoved
import com.intellij.psi.search.PackageScope; //導入方法依賴的package包/類
private void processFieldRemoved(FieldInfo info, final PsiClass aClass) throws CacheCorruptedException {
if (info.isPrivate()) {
return; // optimization: don't need to search, cause may be used only in this class
}
SearchScope searchScope = GlobalSearchScope.projectScope(myProject);
if (info.isPackageLocal()) {
final PsiFile containingFile = aClass.getContainingFile();
if (containingFile instanceof PsiJavaFile) {
final String packageName = ((PsiJavaFile)containingFile).getPackageName();
final PsiJavaPackage aPackage = JavaPsiFacade.getInstance(myProject).findPackage(packageName);
if (aPackage != null) {
searchScope = PackageScope.packageScope(aPackage, false);
searchScope = searchScope.intersectWith(aClass.getUseScope());
}
}
}
final PsiSearchHelper psiSearchHelper = PsiSearchHelper.SERVICE.getInstance(myProject);
final Ref<CacheCorruptedException> exRef = new Ref<CacheCorruptedException>(null);
processIdentifiers(psiSearchHelper, new PsiElementProcessor<PsiIdentifier>() {
@Override
public synchronized boolean execute(@NotNull PsiIdentifier identifier) {
try {
final PsiElement parent = identifier.getParent();
if (parent instanceof PsiReferenceExpression) {
final PsiClass ownerClass = getOwnerClass(parent);
if (ownerClass != null && !ownerClass.equals(aClass)) {
final String _qName = ownerClass.getQualifiedName();
if (_qName != null) {
int qualifiedName = myDependencyCache.getSymbolTable().getId(_qName);
// should force marking of the class no matter was it compiled or not
// This will ensure the class was recompiled _after_ all the constants get their new values
if (myDependencyCache.markClass(qualifiedName, true)) {
if (LOG.isDebugEnabled()) {
LOG.debug("Mark dependent class " + myDependencyCache.resolve(qualifiedName) + "; reason: some constants were removed from " + myDependencyCache.resolve(myQName));
}
}
}
else {
LOG.warn("Class with null qualified name was not expected here: " + ownerClass);
}
}
}
return true;
}
catch (CacheCorruptedException e) {
exRef.set(e);
return false;
}
}
}, myDependencyCache.resolve(info.getName()), searchScope, UsageSearchContext.IN_CODE);
final CacheCorruptedException cacheCorruptedException = exRef.get();
if (cacheCorruptedException != null) {
throw cacheCorruptedException;
}
}