本文整理汇总了Java中com.siyeh.ig.psiutils.CollectionUtils.isCollectionClass方法的典型用法代码示例。如果您正苦于以下问题:Java CollectionUtils.isCollectionClass方法的具体用法?Java CollectionUtils.isCollectionClass怎么用?Java CollectionUtils.isCollectionClass使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类com.siyeh.ig.psiutils.CollectionUtils
的用法示例。
在下文中一共展示了CollectionUtils.isCollectionClass方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: visitClass
import com.siyeh.ig.psiutils.CollectionUtils; //导入方法依赖的package包/类
@Override
public void visitClass(@NotNull PsiClass aClass) {
if (aClass.isInterface() || aClass.isAnnotationType() || aClass.isEnum()) {
return;
}
final PsiClass superClass = aClass.getSuperClass();
if (superClass == null) {
return;
}
if (!CollectionUtils.isCollectionClass(superClass)) {
return;
}
registerClassError(aClass, superClass, aClass);
}
示例2: visitVariable
import com.siyeh.ig.psiutils.CollectionUtils; //导入方法依赖的package包/类
@Override
public void visitVariable(@NotNull PsiVariable variable) {
if (isOnTheFly() && !isCheapEnoughToSearch(variable)) {
return;
}
if (ignoreLocalVariables && variable instanceof PsiLocalVariable) {
return;
}
if (ignorePrivateMethodsAndFields) {
if (variable instanceof PsiField) {
if (variable.hasModifierProperty(PsiModifier.PRIVATE)) {
return;
}
}
}
if (variable instanceof PsiParameter) {
final PsiParameter parameter = (PsiParameter)variable;
final PsiElement scope = parameter.getDeclarationScope();
if (scope instanceof PsiMethod) {
if (ignorePrivateMethodsAndFields) {
final PsiMethod method = (PsiMethod)scope;
if (method.hasModifierProperty(PsiModifier.PRIVATE)) {
return;
}
}
}
else if (ignoreLocalVariables) {
return;
}
}
final PsiType type = variable.getType();
if (!CollectionUtils.isCollectionClass(type)) {
return;
}
if (LibraryUtil.isOverrideOfLibraryMethodParameter(variable)) {
return;
}
final PsiTypeElement typeElement = variable.getTypeElement();
if (typeElement == null) {
return;
}
final PsiJavaCodeReferenceElement reference =
typeElement.getInnermostComponentReferenceElement();
if (reference == null) {
return;
}
final PsiElement nameElement = reference.getReferenceNameElement();
if (nameElement == null) {
return;
}
final Collection<PsiClass> weaklings =
WeakestTypeFinder.calculateWeakestClassesNecessary(variable,
false, true);
if (weaklings.isEmpty()) {
return;
}
final List<PsiClass> weaklingList = new ArrayList(weaklings);
final PsiClassType javaLangObject = TypeUtils.getObjectType(variable);
final PsiClass objectClass = javaLangObject.resolve();
weaklingList.remove(objectClass);
if (weaklingList.isEmpty()) {
final String typeText = type.getCanonicalText();
final String interfaceText =
CollectionUtils.getInterfaceForClass(typeText);
registerError(nameElement, interfaceText);
}
else {
final PsiClass weakling = weaklingList.get(0);
final String qualifiedName = weakling.getQualifiedName();
registerError(nameElement, qualifiedName);
}
}
开发者ID:lshain-android-source,项目名称:tools-idea,代码行数:73,代码来源:DeclareCollectionAsInterfaceInspection.java
示例3: visitMethod
import com.siyeh.ig.psiutils.CollectionUtils; //导入方法依赖的package包/类
@Override
public void visitMethod(@NotNull PsiMethod method) {
super.visitMethod(method);
if (ignorePrivateMethodsAndFields &&
method.hasModifierProperty(PsiModifier.PRIVATE)) {
return;
}
if (isOnTheFly() && !isCheapEnoughToSearch(method)) {
return;
}
final PsiType type = method.getReturnType();
if (type == null || !CollectionUtils.isCollectionClass(type)) {
return;
}
if (LibraryUtil.isOverrideOfLibraryMethod(method)) {
return;
}
final PsiTypeElement typeElement = method.getReturnTypeElement();
if (typeElement == null) {
return;
}
final PsiJavaCodeReferenceElement referenceElement =
typeElement.getInnermostComponentReferenceElement();
if (referenceElement == null) {
return;
}
final PsiElement nameElement =
referenceElement.getReferenceNameElement();
if (nameElement == null) {
return;
}
final Collection<PsiClass> weaklings =
WeakestTypeFinder.calculateWeakestClassesNecessary(method,
false, true);
if (weaklings.isEmpty()) {
return;
}
final List<PsiClass> weaklingList = new ArrayList(weaklings);
final PsiClassType javaLangObject = TypeUtils.getObjectType(method);
final PsiClass objectClass = javaLangObject.resolve();
weaklingList.remove(objectClass);
if (weaklingList.isEmpty()) {
final String typeText = type.getCanonicalText();
final String interfaceText =
CollectionUtils.getInterfaceForClass(typeText);
registerError(nameElement, interfaceText);
}
else {
final PsiClass weakling = weaklingList.get(0);
registerError(nameElement, weakling.getQualifiedName());
}
}
开发者ID:lshain-android-source,项目名称:tools-idea,代码行数:53,代码来源:DeclareCollectionAsInterfaceInspection.java