use of com.intellij.psi.PsiType in project intellij-community by JetBrains.
the class GrInplaceVariableIntroducer method addAdditionalVariables.
@Override
protected void addAdditionalVariables(TemplateBuilderImpl builder) {
GrVariable variable = getVariable();
assert variable != null && variable.getInitializerGroovy() != null;
final PsiType initializerType = variable.getInitializerGroovy().getType();
TypeConstraint[] constraints = initializerType != null && !initializerType.equals(PsiType.NULL) ? new SupertypeConstraint[] { SupertypeConstraint.create(initializerType) } : TypeConstraint.EMPTY_ARRAY;
ChooseTypeExpression typeExpression = new ChooseTypeExpression(constraints, variable.getManager(), variable.getResolveScope(), true, GroovyApplicationSettings.getInstance().INTRODUCE_LOCAL_SELECT_DEF);
PsiElement element = getTypeELementOrDef(variable);
if (element == null)
return;
builder.replaceElement(element, "Variable_type", typeExpression, true, true);
}
use of com.intellij.psi.PsiType in project timber by JakeWharton.
the class WrongTimberUsageDetector method getType.
private static Class<?> getType(PsiExpression expression) {
if (expression == null) {
return null;
}
if (expression instanceof PsiMethodCallExpression) {
PsiMethodCallExpression call = (PsiMethodCallExpression) expression;
PsiMethod method = call.resolveMethod();
if (method == null) {
return null;
}
String methodName = method.getName();
if (methodName.equals(GET_STRING_METHOD)) {
return String.class;
}
} else if (expression instanceof PsiLiteralExpression) {
PsiLiteralExpression literalExpression = (PsiLiteralExpression) expression;
PsiType expressionType = literalExpression.getType();
if (LintUtils.isString(expressionType)) {
return String.class;
} else if (expressionType == PsiType.INT) {
return Integer.TYPE;
} else if (expressionType == PsiType.FLOAT) {
return Float.TYPE;
} else if (expressionType == PsiType.CHAR) {
return Character.TYPE;
} else if (expressionType == PsiType.BOOLEAN) {
return Boolean.TYPE;
} else if (expressionType == PsiType.NULL) {
return Object.class;
}
}
PsiType type = expression.getType();
if (type != null) {
Class<?> typeClass = getTypeClass(type);
return typeClass != null ? typeClass : Object.class;
}
return null;
}
use of com.intellij.psi.PsiType 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);
}
use of com.intellij.psi.PsiType in project intellij-community by JetBrains.
the class StringBufferFieldInspection method buildErrorString.
@Override
@NotNull
public String buildErrorString(Object... infos) {
final PsiType type = (PsiType) infos[0];
final String typeName = type.getPresentableText();
return InspectionGadgetsBundle.message("stringbuffer.field.problem.descriptor", typeName);
}
use of com.intellij.psi.PsiType in project intellij-community by JetBrains.
the class BadExceptionThrownInspectionBase method buildErrorString.
@Override
@NotNull
public String buildErrorString(Object... infos) {
final PsiType type = (PsiType) infos[0];
final String exceptionName = type.getPresentableText();
return InspectionGadgetsBundle.message("bad.exception.thrown.problem.descriptor", exceptionName);
}
Aggregations