use of com.intellij.psi.PsiClassType in project android-parcelable-intellij-plugin by mcharmas.
the class PsiUtils method getResolvedGenerics.
/**
* Resolves generics on the given type and returns them (if any) or null if there are none
*
* @param type
* @return
*/
public static List<PsiType> getResolvedGenerics(PsiType type) {
List<PsiType> psiTypes = null;
if (type instanceof PsiClassType) {
PsiClassType pct = (PsiClassType) type;
psiTypes = new ArrayList<PsiType>(pct.resolveGenerics().getSubstitutor().getSubstitutionMap().values());
}
return psiTypes;
}
use of com.intellij.psi.PsiClassType in project intellij-community by JetBrains.
the class GrSetStrongTypeIntention method getOrCreateTypeElement.
@NotNull
private static TypeInfo getOrCreateTypeElement(@NotNull PsiElement parent, @NotNull PsiElement elementToBuildTemplateOn) {
GrModifierList modifierList = getModifierList(parent);
if (modifierList != null && modifierList.hasModifierProperty(GrModifier.DEF) && modifierList.getModifiers().length == 1) {
PsiElement modifier = modifierList.getModifier(GrModifier.DEF);
LOG.assertTrue(modifier != null);
int modifierOffset = modifier.getTextRange().getEndOffset() - elementToBuildTemplateOn.getTextRange().getStartOffset();
return new TypeInfo(modifier, modifierOffset);
} else {
int nameElementOffset;
final PsiClassType typeToUse = TypesUtil.createType("Abc", parent);
if (elementToBuildTemplateOn instanceof GrVariableDeclaration) {
GrVariableDeclaration decl = (GrVariableDeclaration) elementToBuildTemplateOn;
decl.setType(typeToUse);
nameElementOffset = decl.getModifierList().getTextRange().getEndOffset() - elementToBuildTemplateOn.getTextRange().getStartOffset();
} else {
GrVariable var = (GrVariable) parent;
var.setType(typeToUse);
nameElementOffset = var.getNameIdentifierGroovy().getTextRange().getStartOffset() - elementToBuildTemplateOn.getTextRange().getStartOffset();
}
return new TypeInfo(getTypeElement(parent), nameElementOffset);
}
}
use of com.intellij.psi.PsiClassType in project intellij-community by JetBrains.
the class ExtractClosureHelperImpl method getSelectedType.
@Override
public PsiType getSelectedType() {
if (myForceDef)
return null;
if (myType == null) {
final GrClosableBlock closure = ExtractClosureProcessorBase.generateClosure(this);
PsiType type = closure.getType();
if (type instanceof PsiClassType) {
final PsiType[] parameters = ((PsiClassType) type).getParameters();
if (parameters.length == 1 && parameters[0] != null) {
if (parameters[0].equalsToText(PsiType.VOID.getBoxedTypeName())) {
type = ((PsiClassType) type).rawType();
}
}
}
myType = type;
}
return myType;
}
use of com.intellij.psi.PsiClassType in project intellij-community by JetBrains.
the class TargetType method create.
@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);
}
use of com.intellij.psi.PsiClassType in project intellij-community by JetBrains.
the class TargetType method create.
@Nullable
public static TargetType create(final PsiArrayType arrayType) {
PsiType currentComponentType = arrayType.getComponentType();
while (currentComponentType instanceof PsiArrayType) {
currentComponentType = ((PsiArrayType) currentComponentType).getComponentType();
}
if (!(currentComponentType instanceof PsiClassType)) {
return null;
}
final String targetQName = arrayType.getCanonicalText();
return new TargetType(targetQName, true, arrayType);
}
Aggregations