use of com.intellij.psi.PsiType in project android by JetBrains.
the class PsiCFGPartialMethodSignatureBuilder method buildFromPsiMethod.
public static PsiCFGPartialMethodSignature buildFromPsiMethod(PsiMethod psiMethod) {
PsiCFGPartialMethodSignature retSignature = new PsiCFGPartialMethodSignature();
retSignature.methodName = psiMethod.getName().trim();
if (psiMethod.isVarArgs()) {
retSignature.isVarArgs = true;
}
PsiParameter[] paramList = psiMethod.getParameterList().getParameters();
if (paramList == null || paramList.length == 0) {
retSignature.parameterTypes = PsiType.EMPTY_ARRAY;
} else {
retSignature.parameterTypes = new PsiType[paramList.length];
for (int i = 0; i < paramList.length; i++) {
PsiType curParamType = paramList[i].getType();
retSignature.parameterTypes[i] = curParamType;
}
}
return retSignature;
}
use of com.intellij.psi.PsiType in project android by JetBrains.
the class GradleSettingsFile method getProjectLocation.
/**
* Obtains custom module location from the Gradle script. Currently it only recognizes File ctor invocation with a string constant.
*/
@Nullable
private static File getProjectLocation(@Nullable GrExpression rValue) {
if (rValue instanceof GrNewExpression) {
PsiType type = rValue.getType();
String typeName = type != null ? type.getCanonicalText() : null;
if (File.class.getName().equals(typeName) || File.class.getSimpleName().equals(typeName)) {
String path = getSingleStringArgumentValue(((GrNewExpression) rValue));
return path == null ? null : new File(path);
}
}
return null;
}
use of com.intellij.psi.PsiType in project intellij-community by JetBrains.
the class ConvertToScientificNotationPredicate method satisfiedBy.
public boolean satisfiedBy(PsiElement element) {
if (!(element instanceof PsiLiteralExpression)) {
return false;
}
final PsiLiteralExpression expression = (PsiLiteralExpression) element;
final PsiType type = expression.getType();
if (!PsiType.DOUBLE.equals(type) && !PsiType.FLOAT.equals(type)) {
return false;
}
String text = expression.getText();
if (text == null) {
return false;
}
text = text.toLowerCase();
text = StringUtil.trimStart(text, "-");
if (!text.contains(".") && text.startsWith("0")) {
//Octal integer
return false;
}
return !text.contains("e");
}
use of com.intellij.psi.PsiType in project intellij-community by JetBrains.
the class ConvertIntegerToDecimalPredicate method satisfiedBy.
public boolean satisfiedBy(PsiElement element) {
if (!(element instanceof PsiLiteralExpression)) {
return false;
}
final PsiLiteralExpression expression = (PsiLiteralExpression) element;
final PsiType type = expression.getType();
if (PsiType.INT.equals(type) || PsiType.LONG.equals(type)) {
@NonNls final String text = expression.getText();
if (text == null || text.length() < 2) {
return false;
}
if ("0".equals(text) || "0L".equals(text) || "0l".equals(text)) {
return false;
}
return text.charAt(0) == '0';
}
if (PsiType.DOUBLE.equals(type) || PsiType.FLOAT.equals(type)) {
@NonNls final String text = expression.getText();
if (text == null || text.length() < 2) {
return false;
}
return text.startsWith("0x") || text.startsWith("0X");
}
return false;
}
use of com.intellij.psi.PsiType in project intellij-community by JetBrains.
the class ConvertNumberIntentionBase method processIntention.
@Override
protected void processIntention(@NotNull final PsiElement element) throws IncorrectOperationException {
final PsiExpression expression = (PsiExpression) element;
final Number value = (Number) ExpressionUtils.computeConstantExpression(expression);
if (value == null)
return;
final PsiType type = expression.getType();
final boolean negated = ExpressionUtils.isNegative(expression);
final String resultString = convertValue(value, type, negated);
if (resultString == null)
return;
if (negated) {
PsiReplacementUtil.replaceExpression((PsiExpression) expression.getParent(), resultString);
} else {
PsiReplacementUtil.replaceExpression(expression, resultString);
}
}
Aggregations