本文整理汇总了Java中com.intellij.psi.PsiClassType.getParameters方法的典型用法代码示例。如果您正苦于以下问题:Java PsiClassType.getParameters方法的具体用法?Java PsiClassType.getParameters怎么用?Java PsiClassType.getParameters使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类com.intellij.psi.PsiClassType
的用法示例。
在下文中一共展示了PsiClassType.getParameters方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: guessResourceName
import com.intellij.psi.PsiClassType; //导入方法依赖的package包/类
/**
* If the return type of {@code method} is a parameterized collection, this function
* constructs the resource name from the parameterized parameters of the return type else it
* returns {@code null}.
*
* @param method the method in which the resource name will be generated from
* @return the guessed resource name
*/
@Override
@Nullable
public String guessResourceName(PsiMethod method) {
Project project = getProject(method);
if (project == null) {
return null;
}
PsiType returnType = method.getReturnType();
if (isValidCollectionType(project, returnType)) {
assert (returnType instanceof PsiClassType);
PsiClassType classType = (PsiClassType) returnType;
PsiType[] typeParams = classType.getParameters();
// TODO: Add inspection to verify that the the type parameter is specified
// for paramerterized types, since trying to generate client libs without one generates
// a : "Object type T not supported"
return typeParams.length > 0 ? getSimpleName(project, typeParams[0]).toLowerCase() : null;
}
return null;
}
示例2: 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
示例3: visitClassType
import com.intellij.psi.PsiClassType; //导入方法依赖的package包/类
@Nullable
@Override
public TypeBuilder visitClassType(PsiClassType classType) {
String name = (classType instanceof PsiClassReferenceType) ?
((PsiClassReferenceType) classType).getReference().getQualifiedName() :
classType.getClassName();
String mappedName = typeParameterMap.containsKey(name) ? typeParameterMap.get(name) : name;
typeBuilder.withName(mappedName);
for (PsiType param : classType.getParameters()) {
PsiTypeParameterConverter converter = new PsiTypeParameterConverter(typeParameterMap);
param.accept(converter);
typeBuilder.withTypeBinding(converter.getTypeParameterBuilder());
}
return super.visitClassType(classType);
}
示例4: getOptionalElementType
import com.intellij.psi.PsiClassType; //导入方法依赖的package包/类
@Contract("null -> null")
private static PsiType getOptionalElementType(PsiExpression expression)
{
if(expression == null)
{
return null;
}
PsiClassType type = ObjectUtils.tryCast(expression.getType(), PsiClassType.class);
if(type == null)
{
return null;
}
String rawName = type.rawType().getCanonicalText();
if(!rawName.equals(JAVA_UTIL_OPTIONAL) && !rawName.equals(GUAVA_OPTIONAL))
{
return null;
}
PsiType[] parameters = type.getParameters();
if(parameters.length != 1)
{
return null;
}
return parameters[0];
}
示例5: findParameterizedType_Reverse
import com.intellij.psi.PsiClassType; //导入方法依赖的package包/类
public static PsiClassType findParameterizedType_Reverse( PsiClassType sourceType, PsiClassType targetType )
{
if( sourceType == null || targetType == null )
{
return null;
}
if( !isParameterizedType( sourceType ) )
{
return null;
}
// List<Z>
PsiClassType sourceTypeInHier = findParameterizedType( targetType, sourceType.rawType() );
if( sourceTypeInHier == null || !isParameterizedType( sourceTypeInHier ) )
{
return null;
}
TypeVarToTypeMap map = new TypeVarToTypeMap();
PsiType[] params = sourceTypeInHier.getParameters();
for( int iPos = 0; iPos < params.length; iPos++ )
{
if( isTypeVariable( params[iPos] ) )
{
map.put( (PsiClassType)params[iPos], sourceType.getParameters()[iPos] );
}
}
// ArrayList<Foo>
return (PsiClassType)getActualType( targetType, map, true );
}