当前位置: 首页>>代码示例>>Java>>正文


Java LibraryUtil.classIsInLibrary方法代码示例

本文整理汇总了Java中com.siyeh.ig.psiutils.LibraryUtil.classIsInLibrary方法的典型用法代码示例。如果您正苦于以下问题:Java LibraryUtil.classIsInLibrary方法的具体用法?Java LibraryUtil.classIsInLibrary怎么用?Java LibraryUtil.classIsInLibrary使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在com.siyeh.ig.psiutils.LibraryUtil的用法示例。


在下文中一共展示了LibraryUtil.classIsInLibrary方法的11个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: typeIsConcreteClass

import com.siyeh.ig.psiutils.LibraryUtil; //导入方法依赖的package包/类
public static boolean typeIsConcreteClass(@Nullable PsiType type, boolean ignoreCastToAbstractClass) {
  if (type == null) {
    return false;
  }
  final PsiType baseType = type.getDeepComponentType();
  if (!(baseType instanceof PsiClassType)) {
    return false;
  }
  final PsiClassType classType = (PsiClassType)baseType;
  final PsiClass aClass = classType.resolve();
  if (aClass == null) {
    return false;
  }
  if (ignoreCastToAbstractClass && aClass.hasModifierProperty(PsiModifier.ABSTRACT)) {
    return false;
  }
  if (aClass.isInterface() || aClass.isEnum() || aClass.isAnnotationType()) {
    return false;
  }
  if (aClass instanceof PsiTypeParameter) {
    return false;
  }
  return !LibraryUtil.classIsInLibrary(aClass);
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:25,代码来源:ConcreteClassUtil.java

示例2: checkParameters

import com.siyeh.ig.psiutils.LibraryUtil; //导入方法依赖的package包/类
private void checkParameters(PsiMethod superMethod,
                             PsiParameter[] parameters) {
  if (m_ignoreOverridesOfLibraryMethods) {
    final PsiClass containingClass =
      superMethod.getContainingClass();
    if (containingClass != null &&
        LibraryUtil.classIsInLibrary(containingClass)) {
      return;
    }
  }
  final PsiParameterList superParameterList =
    superMethod.getParameterList();
  final PsiParameter[] superParameters =
    superParameterList.getParameters();
  for (int i = 0; i < parameters.length; i++) {
    final PsiParameter parameter = parameters[i];
    final String parameterName = parameter.getName();
    final String superParameterName = superParameters[i].getName();
    if (superParameterName == null) {
      continue;
    }
    if (superParameterName.equals(parameterName)) {
      continue;
    }
    if (m_ignoreSingleCharacterNames &&
        superParameterName.length() == 1) {
      continue;
    }
    registerVariableError(parameter, superParameterName);
  }
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:32,代码来源:ParameterNameDiffersFromOverriddenParameterInspectionBase.java

示例3: getInheritanceDepth

import com.siyeh.ig.psiutils.LibraryUtil; //导入方法依赖的package包/类
private int getInheritanceDepth(PsiClass aClass, Set<PsiClass> visited) {
  if (visited.contains(aClass)) {
    return 0;
  }
  visited.add(aClass);
  final PsiClass superClass = aClass.getSuperClass();
  if (superClass == null) {
    return 0;
  }
  if (LibraryUtil.classIsInLibrary(aClass) &&
      LibraryUtil.classIsInLibrary(superClass)) {
    return 0;
  }
  return getInheritanceDepth(superClass, visited) + 1;
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:16,代码来源:ClassInheritanceDepthInspection.java

示例4: addDependency

import com.siyeh.ig.psiutils.LibraryUtil; //导入方法依赖的package包/类
private void addDependency(PsiType type) {
  if (type == null) {
    return;
  }
  final PsiType baseType = type.getDeepComponentType();

  if (ClassUtils.isPrimitive(type)) {
    return;
  }
  final String qualifiedName = m_class.getQualifiedName();
  if (qualifiedName == null) {
    return;
  }
  if (baseType.equalsToText(qualifiedName)) {
    return;
  }
  final String baseTypeName = baseType.getCanonicalText();
  @NonNls final String javaPrefix = "java.";
  @NonNls final String javaxPrefix = "javax.";
  if (!m_includeJavaClasses &&
      (baseTypeName.startsWith(javaPrefix) ||
       baseTypeName.startsWith(javaxPrefix))) {
    return;
  }
  if (!m_includeLibraryClasses) {
    final Project project = m_class.getProject();
    final GlobalSearchScope searchScope = GlobalSearchScope.allScope(project);
    final PsiClass aClass = JavaPsiFacade.getInstance(project).findClass(baseTypeName, searchScope);
    if (aClass == null) {
      return;
    }
    if (LibraryUtil.classIsInLibrary(aClass)) {
      return;
    }
  }
  if (StringUtil.startsWithConcatenation(baseTypeName, qualifiedName, ".")) {
    return;
  }
  m_dependencies.add(baseTypeName);
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:41,代码来源:CouplingVisitor.java

示例5: isInstanceofOnLibraryClass

import com.siyeh.ig.psiutils.LibraryUtil; //导入方法依赖的package包/类
private boolean isInstanceofOnLibraryClass(
  PsiInstanceOfExpression instanceOfExpression) {
  final PsiTypeElement checkType =
    instanceOfExpression.getCheckType();
  if (checkType == null) {
    return false;
  }
  final PsiType type = checkType.getType();
  if (!(type instanceof PsiClassType)) {
    return false;
  }
  final PsiClassType classType = (PsiClassType)type;
  final PsiClass aClass = classType.resolve();
  return LibraryUtil.classIsInLibrary(aClass);
}
 
开发者ID:lshain-android-source,项目名称:tools-idea,代码行数:16,代码来源:InstanceofChainInspection.java

示例6: visitExpressionStatement

import com.siyeh.ig.psiutils.LibraryUtil; //导入方法依赖的package包/类
@Override
public void visitExpressionStatement(@NotNull PsiExpressionStatement statement) {
  super.visitExpressionStatement(statement);
  final PsiExpression expression = statement.getExpression();
  if (!(expression instanceof PsiMethodCallExpression)) {
    return;
  }
  final PsiMethodCallExpression call = (PsiMethodCallExpression)expression;
  final PsiMethod method = call.resolveMethod();
  if (method == null || method.isConstructor()) {
    return;
  }
  final PsiType returnType = method.getReturnType();
  if (PsiType.VOID.equals(returnType)) {
    return;
  }
  final PsiClass aClass = method.getContainingClass();
  if (aClass == null) {
    return;
  }
  if (PsiUtilCore.hasErrorElementChild(statement)) {
    return;
  }
  if (m_reportAllNonLibraryCalls && !LibraryUtil.classIsInLibrary(aClass)) {
    registerMethodCallError(call, aClass);
    return;
  }

  PsiAnnotation anno = ControlFlowAnalyzer.findContractAnnotation(method);
  boolean honorInferred = Registry.is("ide.ignore.call.result.inspection.honor.inferred.pure");
  if (anno != null && 
      (honorInferred || !AnnotationUtil.isInferredAnnotation(anno)) && 
      Boolean.TRUE.equals(AnnotationUtil.getBooleanAttributeValue(anno, "pure"))) {
    registerMethodCallError(call, aClass);
    return;
  }

  final PsiReferenceExpression methodExpression = call.getMethodExpression();
  final String methodName = methodExpression.getReferenceName();
  if (methodName == null) {
    return;
  }
  for (int i = 0; i < methodNamePatterns.size(); i++) {
    final String methodNamePattern = methodNamePatterns.get(i);
    if (!methodNamesMatch(methodName, methodNamePattern)) {
      continue;
    }
    final String className = classNames.get(i);
    if (!InheritanceUtil.isInheritor(aClass, className)) {
      continue;
    }
    registerMethodCallError(call, aClass);
    return;
  }
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:56,代码来源:IgnoreResultOfCallInspectionBase.java

示例7: visitMethod

import com.siyeh.ig.psiutils.LibraryUtil; //导入方法依赖的package包/类
@Override
public void visitMethod(@NotNull PsiMethod method) {
  super.visitMethod(method);
  if (method.isConstructor()) {
    return;
  }
  if (method.getNameIdentifier() == null) {
    return;
  }
  if (!method.hasModifierProperty(PsiModifier.PUBLIC)) {
    return;
  }
  if (method.hasModifierProperty(PsiModifier.STATIC)) {
    return;
  }
  final PsiClass containingClass = method.getContainingClass();
  if (containingClass == null) {
    return;
  }
  if (containingClass.isInterface() ||
      containingClass.isAnnotationType()) {
    return;
  }
  if (!containingClass.hasModifierProperty(PsiModifier.PUBLIC)) {
    return;
  }
  if (AnnotationUtil.isAnnotated(method, ignorableAnnotations)) {
    return;
  }
  if (onlyWarnIfContainingClassImplementsAnInterface) {
    final PsiClass[] superClasses = containingClass.getSupers();
    boolean implementsInterface = false;
    for (PsiClass superClass : superClasses) {
      if (superClass.isInterface() &&
          !LibraryUtil.classIsInLibrary(superClass)) {
        implementsInterface = true;
        break;
      }
    }
    if (!implementsInterface) {
      return;
    }
  }
  if (exposedInInterface(method)) {
    return;
  }
  if (TestUtils.isJUnitTestMethod(method)) {
    return;
  }
  registerMethodError(method, method);
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:52,代码来源:PublicMethodNotExposedInInterfaceInspectionBase.java

示例8: visitMethodCallExpression

import com.siyeh.ig.psiutils.LibraryUtil; //导入方法依赖的package包/类
@Override
public void visitMethodCallExpression(
  @NotNull PsiMethodCallExpression expression) {
  super.visitMethodCallExpression(expression);
  final PsiMethod method = expression.resolveMethod();
  if (method == null) {
    return;
  }
  final PsiClass calledClass = method.getContainingClass();
  if (calledClass == null) {
    return;
  }
  if (currentClass.equals(calledClass)) {
    return;
  }
  final Set<PsiClass> overAccessedClasses = m_overAccessedClasses;
  if (overAccessedClasses.contains(calledClass)) {
    return;
  }
  if (LibraryUtil.classIsInLibrary(calledClass)) {
    return;
  }
  if (PsiTreeUtil.isAncestor(currentClass, calledClass, true)) {
    return;
  }
  if (PsiTreeUtil.isAncestor(calledClass, currentClass, true)) {
    return;
  }
  PsiClass lexicallyEnclosingClass = currentClass;
  while (lexicallyEnclosingClass != null) {
    if (lexicallyEnclosingClass.isInheritor(calledClass, true)) {
      return;
    }
    lexicallyEnclosingClass =
      ClassUtils.getContainingClass(lexicallyEnclosingClass);
  }
  final Map<PsiClass, Integer> accessCounts = m_accessCounts;
  final Integer count = accessCounts.get(calledClass);
  if (count == null) {
    accessCounts.put(calledClass, 1);
  }
  else if (count.equals(Integer.valueOf(1))) {
    accessCounts.put(calledClass, 2);
  }
  else {
    overAccessedClasses.add(calledClass);
  }
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:49,代码来源:ClassAccessVisitor.java

示例9: addDependency

import com.siyeh.ig.psiutils.LibraryUtil; //导入方法依赖的package包/类
private void addDependency(PsiType type) {
  if (type == null) {
    return;
  }
  final PsiType baseType = type.getDeepComponentType();
  if (ClassUtils.isPrimitive(type)) {
    return;
  }
  final PsiClass containingClass = m_method.getContainingClass();
  if (containingClass == null) {
    return;
  }
  final String qualifiedName = containingClass.getQualifiedName();
  if (qualifiedName == null) {
    return;
  }
  if (baseType.equalsToText(qualifiedName)) {
    return;
  }
  @NonNls final String baseTypeName = baseType.getCanonicalText();
  if (!m_includeJavaClasses &&
      (baseTypeName.startsWith("java.") ||
       baseTypeName.startsWith("javax."))) {
    return;
  }
  if (StringUtil.startsWithConcatenation(baseTypeName, qualifiedName, ".")) {
    return;
  }
  if (!m_includeLibraryClasses) {
    final Project project = m_method.getProject();
    final GlobalSearchScope searchScope = GlobalSearchScope.allScope(project);
    final PsiClass aClass = JavaPsiFacade.getInstance(project).findClass(baseTypeName, searchScope);
    if (aClass == null) {
      return;
    }
    if (LibraryUtil.classIsInLibrary(aClass)) {
      return;
    }
  }
  m_dependencies.add(baseTypeName);
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:42,代码来源:CouplingVisitor.java

示例10: visitExpressionStatement

import com.siyeh.ig.psiutils.LibraryUtil; //导入方法依赖的package包/类
@Override
public void visitExpressionStatement(@NotNull PsiExpressionStatement statement) {
  super.visitExpressionStatement(statement);
  final PsiExpression expression = statement.getExpression();
  if (!(expression instanceof PsiMethodCallExpression)) {
    return;
  }
  final PsiMethodCallExpression call = (PsiMethodCallExpression)expression;
  final PsiMethod method = call.resolveMethod();
  if (method == null || method.isConstructor()) {
    return;
  }
  final PsiType returnType = method.getReturnType();
  if (PsiType.VOID.equals(returnType)) {
    return;
  }
  final PsiClass aClass = method.getContainingClass();
  if (aClass == null) {
    return;
  }
  if (PsiUtilCore.hasErrorElementChild(statement)) {
    return;
  }
  if (m_reportAllNonLibraryCalls && !LibraryUtil.classIsInLibrary(aClass)) {
    registerMethodCallError(call, aClass);
    return;
  }
  final PsiReferenceExpression methodExpression = call.getMethodExpression();
  final String methodName = methodExpression.getReferenceName();
  if (methodName == null) {
    return;
  }
  for (int i = 0; i < methodNamePatterns.size(); i++) {
    final String methodNamePattern = methodNamePatterns.get(i);
    if (!methodNamesMatch(methodName, methodNamePattern)) {
      continue;
    }
    final String className = classNames.get(i);
    if (!InheritanceUtil.isInheritor(aClass, className)) {
      continue;
    }
    registerMethodCallError(call, aClass);
    return;
  }
}
 
开发者ID:lshain-android-source,项目名称:tools-idea,代码行数:46,代码来源:IgnoreResultOfCallInspectionBase.java

示例11: visitMethodCallExpression

import com.siyeh.ig.psiutils.LibraryUtil; //导入方法依赖的package包/类
@Override
public void visitMethodCallExpression(
  @NotNull PsiMethodCallExpression expression) {
  super.visitMethodCallExpression(expression);
  final PsiMethod method = expression.resolveMethod();
  if (method == null) {
    return;
  }
  final PsiClass calledClass = method.getContainingClass();
  if (calledClass == null) {
    return;
  }
  if (currentClass.equals(calledClass)) {
    return;
  }
  final Set<PsiClass> overAccessedClasses = m_overAccessedClasses;
  if (overAccessedClasses.contains(calledClass)) {
    return;
  }
  if (LibraryUtil.classIsInLibrary(calledClass)) {
    return;
  }
  if (PsiTreeUtil.isAncestor(currentClass, calledClass, true)) {
    return;
  }
  if (PsiTreeUtil.isAncestor(calledClass, currentClass, true)) {
    return;
  }
  PsiClass lexicallyEnclosingClass = currentClass;
  while (lexicallyEnclosingClass != null) {
    if (lexicallyEnclosingClass.isInheritor(calledClass, true)) {
      return;
    }
    lexicallyEnclosingClass =
      ClassUtils.getContainingClass(lexicallyEnclosingClass);
  }
  final Map<PsiClass, Integer> accessCounts = m_accessCounts;
  final Integer count = accessCounts.get(calledClass);
  if (count == null) {
    accessCounts.put(calledClass, Integer.valueOf(1));
  }
  else if (count.equals(Integer.valueOf(1))) {
    accessCounts.put(calledClass, Integer.valueOf(2));
  }
  else {
    overAccessedClasses.add(calledClass);
  }
}
 
开发者ID:lshain-android-source,项目名称:tools-idea,代码行数:49,代码来源:ClassAccessVisitor.java


注:本文中的com.siyeh.ig.psiutils.LibraryUtil.classIsInLibrary方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。