當前位置: 首頁>>代碼示例>>Java>>正文


Java PackageScope.packageScope方法代碼示例

本文整理匯總了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;
}
 
開發者ID:jskierbi,項目名稱:intellij-ce-playground,代碼行數:35,代碼來源:PsiImplUtil.java

示例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));
        }
      }
    }
  }
}
 
開發者ID:jskierbi,項目名稱:intellij-ce-playground,代碼行數:33,代碼來源:JavaClassReference.java

示例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);
  }
}
 
開發者ID:lshain-android-source,項目名稱:tools-idea,代碼行數:40,代碼來源:PsiClassImplUtil.java

示例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;
  }
}
 
開發者ID:lshain-android-source,項目名稱:tools-idea,代碼行數:37,代碼來源:PsiImplUtil.java

示例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));
        }
      }
    }
  }
}
 
開發者ID:lshain-android-source,項目名稱:tools-idea,代碼行數:34,代碼來源:JavaClassReference.java

示例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));
				}
			}
		}
	}
}
 
開發者ID:consulo,項目名稱:consulo-java,代碼行數:41,代碼來源:JavaClassReference.java

示例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);
}
 
開發者ID:lshain-android-source,項目名稱:tools-idea,代碼行數:5,代碼來源:TestPackage.java

示例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);
	}
}
 
開發者ID:consulo,項目名稱:consulo-java,代碼行數:51,代碼來源:PsiClassImplUtil.java

示例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;
}
 
開發者ID:consulo,項目名稱:consulo-java,代碼行數:44,代碼來源:PsiImplUtil.java

示例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;
  }
}
 
開發者ID:consulo,項目名稱:consulo-java,代碼行數:58,代碼來源:ChangedConstantsDependencyProcessor.java


注:本文中的com.intellij.psi.search.PackageScope.packageScope方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。