本文整理汇总了Java中com.intellij.psi.PsiClassType类的典型用法代码示例。如果您正苦于以下问题:Java PsiClassType类的具体用法?Java PsiClassType怎么用?Java PsiClassType使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
PsiClassType类属于com.intellij.psi包,在下文中一共展示了PsiClassType类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: tooComplexProvider
import com.intellij.psi.PsiClassType; //导入依赖的package包/类
@DataProvider
public static Object[][] tooComplexProvider() {
return testForEach(
new TestCase().withTypeMock(mock(PsiClassType.class))
.withQualifiedNameOf(String.class).thenExpectTheResult().toBeTooGeneric(),
new TestCase().withTypeMock(mock(PsiClassType.class))
.withQualifiedNameOf(Integer.class).thenExpectTheResult().toBeTooGeneric(),
new TestCase().withTypeMock(mock(PsiClassType.class))
.withQualifiedNameOf(List.class).thenExpectTheResult().toBeTooGeneric(),
new TestCase().withTypeMock(mock(PsiClassType.class))
.withQualifiedNameOf(Stream.class).thenExpectTheResult().toBeTooGeneric(),
new TestCase().withTypeMock(mock(PsiClassType.class))
.withQualifiedNameOf(BufferedReader.class).thenExpectTheResult().toBeTooGeneric(),
new TestCase().withTypeMock(mock(PsiType.class))
.withQualifiedName("some_qualified_name").thenExpectTheResult().toBeTooGeneric(),
new TestCase().withTypeMock(mock(PsiClassType.class))
.withQualifiedName(null).thenExpectTheResult().toBeTooGeneric(),
new TestCase().withTypeMock(mock(PsiClassType.class))
.withQualifiedName("myClass").thenExpectTheResult().toBeNotTooGeneric()
);
}
示例2: resolveCompletions
import com.intellij.psi.PsiClassType; //导入依赖的package包/类
@Override
public Stream<LookupElementBuilder> resolveCompletions(String propertyName, PsiType psiType) {
PsiType[] parameters = ((PsiClassReferenceType) psiType).getParameters();
Stream<PsiClass> psiClassStream = null;
if (parameters.length == 1 && parameters[0] instanceof PsiWildcardType) {
PsiWildcardType psiWildcardType = ((PsiWildcardType) parameters[0]);
if (psiWildcardType.isBounded()) {
if (psiWildcardType.isExtends()) {
psiClassStream = subClasses((PsiClassType) psiWildcardType.getExtendsBound()).stream();
} else if (psiWildcardType.isSuper()) {
psiClassStream = superClasses((PsiClassType) psiWildcardType.getSuperBound()).stream();
}
}
}
if (psiClassStream != null) {
return psiClassStream.map(this::buildClassLookup).filter(Optional::isPresent).map(Optional::get);
} else {
return Stream.empty();
}
}
示例3: resolveFieldConfigType
import com.intellij.psi.PsiClassType; //导入依赖的package包/类
Optional<PsiClass> resolveFieldConfigType(PsiField psiField) {
PsiType fieldType = psiField.getType();
if (fieldType instanceof PsiClassType) {
PsiClassType fieldClassType = ((PsiClassType) fieldType);
if (collectionType != null && collectionType.isAssignableFrom(fieldType) && fieldClassType.getParameterCount() == 1) {
return toPsiClass(fieldClassType.getParameters()[0]);
} else if (mapType != null && mapType.isAssignableFrom(fieldType) && fieldClassType.getParameterCount() == 2) {
return toPsiClass(fieldClassType.getParameters()[1]);
} else {
return toPsiClass(fieldType);
}
} else if (fieldType instanceof PsiArrayType) {
return toPsiClass(((PsiArrayType) fieldType).getComponentType());
} else {
return Optional.empty();
}
}
示例4: makeSrcType
import com.intellij.psi.PsiClassType; //导入依赖的package包/类
private SrcType makeSrcType( PsiType type )
{
SrcType srcType;
if( type instanceof PsiClassType )
{
srcType = new SrcType( ((PsiClassType)type).rawType().getCanonicalText() );
for( PsiType typeParam : ((PsiClassType)type).getParameters() )
{
srcType.addTypeParam( makeSrcType( typeParam ) );
}
}
else
{
srcType = new SrcType( type.getCanonicalText() );
}
return srcType;
}
示例5: maybeInferReturnType
import com.intellij.psi.PsiClassType; //导入依赖的package包/类
public static PsiType maybeInferReturnType( TypeVarToTypeMap inferenceMap, PsiType ownersType, PsiType fromReturnType, PsiType toReturnType )
{
int iCount = inferenceMap.size();
PsiType toCompType = toReturnType;
while( toCompType instanceof PsiArrayType )
{
toCompType = ((PsiArrayType)toCompType).getComponentType();
}
boolean bTypeVar = isTypeVariable( toCompType );
if( bTypeVar || isParameterizedType( toCompType ) )
{
inferTypeVariableTypesFromGenParamTypeAndConcreteType( toReturnType, fromReturnType, inferenceMap );
if( bTypeVar && inferenceMap.get( (PsiClassType)toCompType ) != null || inferenceMap.size() > iCount )
{
PsiType actualType = getActualType( toReturnType, inferenceMap, false );
toReturnType = actualType == null ? toReturnType : actualType;
}
}
return replaceTypeVariableTypeParametersWithBoundingTypes( toReturnType, ownersType );
}
示例6: makeDefaultParameterizedType
import com.intellij.psi.PsiClassType; //导入依赖的package包/类
public static PsiType makeDefaultParameterizedType( PsiType type )
{
if( type != null && !isStructuralInterface( type ) &&
!isParameterizedType( type ) && isGenericType( type ) )
{
PsiTypeParameter[] typeVars = type( type ).getTypeParameters();
PsiType[] boundingTypes = new PsiType[typeVars.length];
for( int i = 0; i < boundingTypes.length; i++ )
{
PsiTypeParameter typeVar = typeVars[i];
boundingTypes[i] = type( getBoundingType( typeVar ) );
if( isRecursiveType( (PsiClassType)type( typeVar ), boundingTypes[i] ) )
{
return type;
}
}
if( boundingTypes.length == 0 )
{
return type;
}
type = parameterizeType( (PsiClassType)type, boundingTypes );
}
return type;
}
示例7: getDefaultParameterizedType
import com.intellij.psi.PsiClassType; //导入依赖的package包/类
public static PsiType getDefaultParameterizedType( PsiType type, PsiManager mgr )
{
if( type.getArrayDimensions() > 0 )
{
PsiType defType = getDefaultParameterizedType( ((PsiArrayType)type).getComponentType(), mgr );
if( !defType.equals( type ) )
{
return new PsiArrayType( defType );
}
return type;
}
if( type instanceof PsiIntersectionType )
{
return makeDefaultParameterizedTypeForCompoundType( (PsiIntersectionType)type, mgr );
}
if( type instanceof PsiDisjunctionType )
{
return getDefaultParameterizedType( PsiTypesUtil.getLowestUpperBoundClassType( (PsiDisjunctionType)type ), mgr );
}
if( !isGenericType( type ) && !isParameterizedType( type ) )
{
return type;
}
type = ((PsiClassType)type).rawType();
return makeDefaultParameterizedType( type );
}
示例8: maybeGetLowerBound
import com.intellij.psi.PsiClassType; //导入依赖的package包/类
private static PsiType maybeGetLowerBound( PsiWildcardType type, TypeVarToTypeMap actualParamByVarName, boolean bKeepTypeVars, LinkedHashSet<PsiType> recursiveTypes )
{
PsiType lower = type.getSuperBound();
if( lower != PsiType.NULL && recursiveTypes.size() > 0 )
{
// This is a "super" (contravariant) wildcard
LinkedList<PsiType> list = new LinkedList<>( recursiveTypes );
PsiType enclType = list.getLast();
if( isParameterizedType( enclType ) )
{
PsiType genType = getActualType( ((PsiClassType)enclType).rawType(), actualParamByVarName, bKeepTypeVars, recursiveTypes );
if( LambdaUtil.isFunctionalType( genType ) )
{
// For functional interfaces we keep the lower bound as an upper bound so that blocks maintain contravariance wrt the single method's parameters
return lower;
}
}
}
return null;
}
示例9: mapActualTypeByVarName
import com.intellij.psi.PsiClassType; //导入依赖的package包/类
private static TypeVarToTypeMap mapActualTypeByVarName( PsiType ownersType )
{
TypeVarToTypeMap actualParamByVarName = new TypeVarToTypeMap();
PsiTypeParameter[] vars = type( ownersType ).getTypeParameters();
if( vars != null )
{
PsiType[] paramArgs = ((PsiClassType)ownersType).getParameters();
for( int i = 0; i < vars.length; i++ )
{
PsiClassType typeVar = (PsiClassType)type( vars[i] );
if( paramArgs.length > i )
{
actualParamByVarName.put( typeVar, paramArgs[i] );
}
}
}
return actualParamByVarName;
}
示例10: JavaCallHierarchyData
import com.intellij.psi.PsiClassType; //导入依赖的package包/类
public JavaCallHierarchyData(PsiClass originalClass,
PsiMethod methodToFind,
PsiClassType originalType,
PsiMethod method,
Set<PsiMethod> methodsToFind,
NodeDescriptor nodeDescriptor,
Map<PsiMember, NodeDescriptor> resultMap,
Project project) {
myOriginalClass = originalClass;
myMethodToFind = methodToFind;
myOriginalType = originalType;
myMethod = method;
myMethodsToFind = methodsToFind;
myNodeDescriptor = nodeDescriptor;
myResultMap = resultMap;
myProject = project;
}
示例11: create
import com.intellij.psi.PsiClassType; //导入依赖的package包/类
@Nullable
public static TargetType create(final PsiClassType classType) {
final PsiClassType.ClassResolveResult resolvedGenerics = classType.resolveGenerics();
final PsiClass resolvedClass = resolvedGenerics.getElement();
if (resolvedClass == null) {
return null;
}
final String classQName = resolvedClass.getQualifiedName();
if (classQName == null) {
return null;
}
if (resolvedClass.hasTypeParameters()) {
return null;
}
return new TargetType(classQName, false, classType);
}
示例12: visitVariable
import com.intellij.psi.PsiClassType; //导入依赖的package包/类
@Override
public void visitVariable(@NotNull PsiVariable variable) {
super.visitVariable(variable);
final PsiType type = variable.getType();
final PsiType componentType = type.getDeepComponentType();
if (!(componentType instanceof PsiClassType)) {
return;
}
final String className = ((PsiClassType)componentType).getClassName();
@NonNls final String javaLangReflect = "java.lang.reflect.";
if (!className.startsWith(javaLangReflect)) {
return;
}
final PsiTypeElement typeElement = variable.getTypeElement();
if (typeElement == null) {
return;
}
registerError(typeElement);
}
示例13: getName
import com.intellij.psi.PsiClassType; //导入依赖的package包/类
public String getName() {
PsiType type = psiType;
if (type instanceof PsiWildcardType) {
type = ((PsiWildcardType)type).getBound();
}
if (type instanceof PsiClassType) {
final PsiClass resolve = ((PsiClassType)type).resolve();
if (resolve != null) {
return resolve.getName();
}
final String canonicalText = type.getCanonicalText();
final int i = canonicalText.indexOf('<');
if (i < 0) return canonicalText;
return canonicalText.substring(0, i);
}
if (type == null) {
return "";
}
return type.getCanonicalText();
}
示例14: getNamedArguments
import com.intellij.psi.PsiClassType; //导入依赖的package包/类
@Override
public void getNamedArguments(@NotNull GrCall call,
@Nullable PsiElement resolve,
@Nullable String argumentName,
boolean forCompletion,
Map<String, NamedArgumentDescriptor> result) {
if (!forCompletion || !(resolve instanceof PsiMethod)) return;
PsiType returnType = ((PsiMethod)resolve).getReturnType();
if (!(returnType instanceof PsiClassType)) return;
Map<String, NamedArgumentDescriptor> map = new HashMap<String, NamedArgumentDescriptor>();
GroovyConstructorNamedArgumentProvider.processClass(call, (PsiClassType)returnType, argumentName, map);
for (String name : map.keySet()) {
result.put(name, NamedArgumentDescriptor.SIMPLE_UNLIKELY);
}
}
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:20,代码来源:GroovyMethodReturnNamedArgumentProvider.java
示例15: getReferenceElements
import com.intellij.psi.PsiClassType; //导入依赖的package包/类
@Override
@NotNull
public PsiJavaCodeReferenceElement[] getReferenceElements() {
PsiClassType[] types = getReferencedTypes();
if (types.length == 0) return PsiJavaCodeReferenceElement.EMPTY_ARRAY;
PsiManagerEx manager = getManager();
List<PsiJavaCodeReferenceElement> result = ContainerUtil.newArrayList();
for (PsiClassType type : types) {
PsiClassType.ClassResolveResult resolveResult = type.resolveGenerics();
PsiClass resolved = resolveResult.getElement();
if (resolved != null) {
result.add(new LightClassReference(manager, type.getCanonicalText(), resolved, resolveResult.getSubstitutor()));
}
}
return result.toArray(new PsiJavaCodeReferenceElement[result.size()]);
}