use of com.intellij.psi.PsiLiteralExpression in project intellij-community by JetBrains.
the class ShiftUtils method isPowerOfTwo.
public static boolean isPowerOfTwo(PsiExpression rhs) {
if (!(rhs instanceof PsiLiteralExpression)) {
return false;
}
final PsiLiteralExpression literal = (PsiLiteralExpression) rhs;
final Object value = literal.getValue();
if (!(value instanceof Number)) {
return false;
}
if (value instanceof Double || value instanceof Float) {
return false;
}
int intValue = ((Number) value).intValue();
if (intValue <= 1) {
return false;
}
while (intValue % 2 == 0) {
intValue >>= 1;
}
return intValue == 1;
}
use of com.intellij.psi.PsiLiteralExpression in project intellij-community by JetBrains.
the class ShiftUtils method isIntLiteral.
public static boolean isIntLiteral(PsiExpression rhs) {
if (!(rhs instanceof PsiLiteralExpression)) {
return false;
}
final PsiLiteralExpression literal = (PsiLiteralExpression) rhs;
final Object value = literal.getValue();
if (!(value instanceof Number)) {
return false;
}
return !(value instanceof Double) && !(value instanceof Float);
}
use of com.intellij.psi.PsiLiteralExpression in project intellij-community by JetBrains.
the class ShiftUtils method isPowerOfTwo.
public static boolean isPowerOfTwo(PsiExpression rhs) {
if (!(rhs instanceof PsiLiteralExpression)) {
return false;
}
final PsiLiteralExpression literal = (PsiLiteralExpression) rhs;
final Object value = literal.getValue();
if (!(value instanceof Number)) {
return false;
}
if (value instanceof Double || value instanceof Float) {
return false;
}
int intValue = ((Number) value).intValue();
if (intValue <= 0) {
return false;
}
while (intValue % 2 == 0) {
intValue >>= 1;
}
return intValue == 1;
}
Aggregations