本文整理汇总了Java中com.intellij.psi.PsiLiteralExpression.getType方法的典型用法代码示例。如果您正苦于以下问题:Java PsiLiteralExpression.getType方法的具体用法?Java PsiLiteralExpression.getType怎么用?Java PsiLiteralExpression.getType使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类com.intellij.psi.PsiLiteralExpression
的用法示例。
在下文中一共展示了PsiLiteralExpression.getType方法的14个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: visitLiteralExpression
import com.intellij.psi.PsiLiteralExpression; //导入方法依赖的package包/类
@Override
public void visitLiteralExpression(@NotNull PsiLiteralExpression expression) {
super.visitLiteralExpression(expression);
final PsiType type = expression.getType();
if (type == null || !TypeUtils.isJavaLangString(type) && !type.equals(PsiType.CHAR)) {
return;
}
final String text = expression.getText();
final Matcher matcher = newlines.matcher(text);
int end = 0;
while (matcher.find(end)) {
final int start = matcher.start();
end = matcher.end();
registerErrorAtOffset(expression, start, end - start);
}
}
示例2: visitLiteralExpression
import com.intellij.psi.PsiLiteralExpression; //导入方法依赖的package包/类
@Override
public void visitLiteralExpression(
@NotNull PsiLiteralExpression expression) {
super.visitLiteralExpression(expression);
final PsiType type = expression.getType();
if (type == null) {
return;
}
if (!type.equals(PsiType.CHAR)) {
return;
}
final String text = expression.getText();
if (text == null) {
return;
}
if (text.equals(" ")) {
return;
}
if (ExpressionUtils.isDeclaredConstant(expression)) {
return;
}
if (NonNlsUtils.isNonNlsAnnotatedUse(expression)) {
return;
}
registerError(expression);
}
示例3: visitLiteralExpression
import com.intellij.psi.PsiLiteralExpression; //导入方法依赖的package包/类
@Override
public void visitLiteralExpression(
@NotNull PsiLiteralExpression expression) {
super.visitLiteralExpression(expression);
final PsiType type = expression.getType();
if (type == null) {
return;
}
if (!type.equals(PsiType.LONG)) {
return;
}
final String text = expression.getText();
if (text == null) {
return;
}
final int length = text.length();
if (length == 0) {
return;
}
if (text.charAt(length - 1) != 'l') {
return;
}
registerError(expression);
}
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:25,代码来源:LongLiteralsEndingWithLowercaseLInspection.java
示例4: satisfiedBy
import com.intellij.psi.PsiLiteralExpression; //导入方法依赖的package包/类
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();
if (text.startsWith("-")) {
text = text.substring(1);
}
if (!text.contains(".") && text.startsWith("0")) {
return false; //Octal integer
}
return !text.contains("e");
}
示例5: satisfiedBy
import com.intellij.psi.PsiLiteralExpression; //导入方法依赖的package包/类
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))) {
return false;
}
@NonNls final String text = expression.getText();
if (text.charAt(0) != '0') {
return true;
}
if (text.length() < 2) {
return true;
}
final char c1 = text.charAt(1);
if (c1 != '_' && (c1 < '0' || c1 > '7')) {
return true;
}
return false;
}
示例6: visitLiteralExpression
import com.intellij.psi.PsiLiteralExpression; //导入方法依赖的package包/类
@Override
public void visitLiteralExpression(
@NotNull PsiLiteralExpression literal) {
super.visitLiteralExpression(literal);
final PsiType type = literal.getType();
if (type == null) {
return;
}
if (!(type.equals(PsiType.FLOAT) || type.equals(PsiType.DOUBLE))) {
return;
}
final String text = literal.getText();
if (text == null) {
return;
}
if (!isConfusing(text)) {
return;
}
registerError(literal);
}
开发者ID:lshain-android-source,项目名称:tools-idea,代码行数:21,代码来源:ConfusingFloatingPointLiteralInspection.java
示例7: satisfiedBy
import com.intellij.psi.PsiLiteralExpression; //导入方法依赖的package包/类
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();
if (text.startsWith("-")) {
text = text.substring(1);
}
if (!text.contains("") && text.startsWith("0")) {
return false; //Octal integer
}
return !text.contains("e");
}
示例8: getType
import com.intellij.psi.PsiLiteralExpression; //导入方法依赖的package包/类
private static Class<?> getType(UExpression 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.getExpressionType();
if (type != null) {
Class<?> typeClass = getTypeClass(type);
return typeClass != null ? typeClass : Object.class;
}
return null;
}
示例9: visitLiteralExpression
import com.intellij.psi.PsiLiteralExpression; //导入方法依赖的package包/类
@Override
public void visitLiteralExpression(@NotNull PsiLiteralExpression literal) {
super.visitLiteralExpression(literal);
final PsiType type = literal.getType();
final String literalText = literal.getText();
if ((!PsiType.FLOAT.equals(type) && !PsiType.DOUBLE.equals(type)) || !isConfusing(literalText)) {
return;
}
if (ignoreScientificNotation && StringUtil.containsAnyChar(literalText, "EePp")) {
return;
}
registerError(literal);
}
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:14,代码来源:ConfusingFloatingPointLiteralInspection.java
示例10: isDecimalLiteral
import com.intellij.psi.PsiLiteralExpression; //导入方法依赖的package包/类
private static boolean isDecimalLiteral(PsiLiteralExpression literal) {
final PsiType type = literal.getType();
if (!PsiType.INT.equals(type) &&
!PsiType.LONG.equals(type)) {
return false;
}
final String text = literal.getText();
if ("0".equals(text)) {
return false;
}
return text.charAt(0) != '0';
}
示例11: isOctalLiteral
import com.intellij.psi.PsiLiteralExpression; //导入方法依赖的package包/类
private static boolean isOctalLiteral(PsiLiteralExpression literal) {
final PsiType type = literal.getType();
if (!PsiType.INT.equals(type) && !PsiType.LONG.equals(type)) {
return false;
}
@NonNls final String text = literal.getText();
if ("0".equals(text) || "0L".equals(text)) {
return false;
}
return text.charAt(0) == '0' && !text.startsWith("0x") &&
!text.startsWith("0X");
}
示例12: satisfiedBy
import com.intellij.psi.PsiLiteralExpression; //导入方法依赖的package包/类
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;
}
final String text = expression.getText();
return text != null && (text.contains("e") || text.contains("E"));
}
示例13: create
import com.intellij.psi.PsiLiteralExpression; //导入方法依赖的package包/类
@Nullable
public DfaValue create(PsiLiteralExpression expr)
{
PsiType type = expr.getType();
if(PsiType.NULL.equals(type))
{
return dfaNull;
}
Object value = expr.getValue();
if(value == null)
{
return null;
}
return createFromValue(value, type, null);
}
示例14: visitLiteralExpression
import com.intellij.psi.PsiLiteralExpression; //导入方法依赖的package包/类
@Override
public void visitLiteralExpression(PsiLiteralExpression expression) {
super.visitLiteralExpression(expression);
final PsiType type = expression.getType();
if (!PsiType.SHORT.equals(type) && !PsiType.INT.equals(type) && !PsiType.LONG.equals(type) &&
!PsiType.FLOAT.equals(type) && !PsiType.DOUBLE.equals(type)) {
return;
}
final String text = expression.getText();
if (text.startsWith("0") && !text.startsWith("0.")) {
// don't check octal, hexadecimal or binary literals
return;
}
if (!text.contains("_")) {
return;
}
boolean underscore = false;
boolean group = false;
boolean dot = false;
int digit = 0;
final int index = StringUtil.indexOfAny(text, "fledFLED"); // suffixes and floating point exponent
final int length = index > 0 ? index : text.length();
for (int i = 0; i < length; i++) {
final char c = text.charAt(i);
if (c == '_' || c == '.') {
if (underscore) {
return;
}
underscore = true;
if (digit != 3 && group || digit > 3) {
registerErrorAtOffset(expression, i - digit, digit);
}
group = true;
digit = 0;
if (c == '.') {
dot = true;
}
}
else if (Character.isDigit(c)) {
underscore = false;
digit++;
}
else {
return;
}
}
if (dot ? digit > 3 : digit != 3) {
registerErrorAtOffset(expression, length - digit, digit);
}
}