本文整理汇总了Java中com.intellij.psi.PsiClassType.isAssignableFrom方法的典型用法代码示例。如果您正苦于以下问题:Java PsiClassType.isAssignableFrom方法的具体用法?Java PsiClassType.isAssignableFrom怎么用?Java PsiClassType.isAssignableFrom使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类com.intellij.psi.PsiClassType
的用法示例。
在下文中一共展示了PsiClassType.isAssignableFrom方法的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: isValidArrayOrPrimitiveType
import com.intellij.psi.PsiClassType; //导入方法依赖的package包/类
/**
* Returns false if <code>type</code> is a multiple levels of collections or arrays. Returns true
* otherwise.
*
* @param type The PsiType been validated.
* @param project The project that has the PsiElement associated with <code>type</code>.
*/
public boolean isValidArrayOrPrimitiveType(PsiType type, Project project) {
if (type instanceof PsiArrayType) {
PsiArrayType arrayType = (PsiArrayType) type;
if (arrayType.getComponentType() instanceof PsiPrimitiveType) {
return true;
} else {
return isValidInnerArrayType(arrayType.getComponentType(), project);
}
}
// Check if type is a Collection
PsiClassType collectionType =
JavaPsiFacade.getElementFactory(project).createTypeByFQClassName("java.util.Collection");
if (collectionType.isAssignableFrom(type)) {
assert (type instanceof PsiClassType);
PsiClassType classType = (PsiClassType) type;
PsiType[] typeParams = classType.getParameters();
assert (typeParams.length > 0);
return isValidInnerArrayType(typeParams[0], project);
}
return true;
}
开发者ID:GoogleCloudPlatform,项目名称:google-cloud-intellij,代码行数:31,代码来源:MethodParameterTypeInspection.java
示例2: isCollectionType
import com.intellij.psi.PsiClassType; //导入方法依赖的package包/类
private boolean isCollectionType(PsiType type, Project project) {
PsiClassType collectionType =
JavaPsiFacade.getElementFactory(project).createTypeByFQClassName("java.util.Collection");
if (collectionType.isAssignableFrom(type)) {
return true;
}
// hack because isAssignableFrom is broken
// todo(elharo): cover other collection types and non-generic collections
// todo(elharo): better regex on Java class names
String name = type.getCanonicalText();
if (name.matches("List<.+>")) {
return true;
}
return false;
}
示例3: isInjectedParameter
import com.intellij.psi.PsiClassType; //导入方法依赖的package包/类
/**
* Returns true if the raw or base type of <code>psiParameter</code> is one of endpoint injected
* type.
*/
public boolean isInjectedParameter(PsiType psiType, Project project) {
Set<PsiClassType> injectedClassTypes = createInjectedClassTypes(project);
for (PsiClassType classType : injectedClassTypes) {
if (classType.isAssignableFrom(psiType)) {
return true;
}
}
return false;
}
示例4: isValidCollectionType
import com.intellij.psi.PsiClassType; //导入方法依赖的package包/类
private boolean isValidCollectionType(Project project, PsiType type) {
// Check if type is a Collection
if (PsiUtils.isParameterizedType(type)) {
PsiClassType collectionType =
JavaPsiFacade.getElementFactory(project)
.createTypeByFQClassName("java.util.Collection");
PsiClassType collectionResponseType =
JavaPsiFacade.getElementFactory(project)
.createTypeByFQClassName("com.google.api.server.spi.response.CollectionResponse");
return collectionType.isAssignableFrom(type)
|| collectionResponseType.isAssignableFrom(type);
}
return false;
}
示例5: isValidInnerArrayType
import com.intellij.psi.PsiClassType; //导入方法依赖的package包/类
/**
* Returns false is <code>type</code> is an array or a java.util.Collection or one of its
* subtypes. Returns true otherwise.
*
* @param type The PsiType been validated.
* @param project The project that has the PsiElement associated with <code>type</code>.
*/
public boolean isValidInnerArrayType(PsiType type, Project project) {
if (type instanceof PsiArrayType) {
return false;
}
// Check if type is a Collection
PsiClassType collectionType =
JavaPsiFacade.getElementFactory(project).createTypeByFQClassName("java.util.Collection");
if (collectionType.isAssignableFrom(type)) {
return false;
}
return true;
}
开发者ID:GoogleCloudPlatform,项目名称:google-cloud-intellij,代码行数:22,代码来源:MethodParameterTypeInspection.java
示例6: visitClass
import com.intellij.psi.PsiClassType; //导入方法依赖的package包/类
@Override
public void visitClass(@NotNull PsiClass aClass)
{
if(aClass.isInterface() || aClass.isAnnotationType() || aClass.isEnum())
{
return;
}
final PsiClass superClass = aClass.getSuperClass();
if(!CollectionUtils.isConcreteCollectionClass(superClass))
{
return;
}
final String qualifiedName = superClass.getQualifiedName();
if("java.util.LinkedHashMap".equals(qualifiedName))
{
final PsiMethod[] methods = aClass.findMethodsByName("removeEldestEntry", false);
final PsiClassType entryType = TypeUtils.getType("java.util.Map.Entry", aClass);
for(PsiMethod method : methods)
{
if(!PsiType.BOOLEAN.equals(method.getReturnType()))
{
continue;
}
final PsiParameterList parameterList = method.getParameterList();
if(parameterList.getParametersCount() != 1)
{
continue;
}
final PsiParameter parameter = parameterList.getParameters()[0];
if(entryType.isAssignableFrom(parameter.getType()))
{
return;
}
}
}
registerClassError(aClass, superClass, aClass);
}
示例7: isMethodThrows
import com.intellij.psi.PsiClassType; //导入方法依赖的package包/类
private static boolean isMethodThrows(PsiMethod method, PsiClassType exception) {
PsiClassType[] throwsTypes = method.getThrowsList().getReferencedTypes();
for (PsiClassType throwsType : throwsTypes) {
if (throwsType.isAssignableFrom(exception)) {
return true;
}
}
return false;
}