Search in sources :

Example 36 with PsiType

use of com.intellij.psi.PsiType in project intellij-community by JetBrains.

the class AtomicFieldUpdaterNotStaticFinalInspection method buildErrorString.

@NotNull
@Override
protected String buildErrorString(Object... infos) {
    final PsiField field = (PsiField) infos[0];
    final PsiType type = field.getType();
    final String typeText = type.getPresentableText();
    return InspectionGadgetsBundle.message("atomic.field.updater.not.static.final.problem.descriptor", typeText);
}
Also used : PsiField(com.intellij.psi.PsiField) PsiType(com.intellij.psi.PsiType) NotNull(org.jetbrains.annotations.NotNull)

Example 37 with PsiType

use of com.intellij.psi.PsiType in project intellij-community by JetBrains.

the class VolatileArrayFieldInspection method buildErrorString.

@Override
@NotNull
public String buildErrorString(Object... infos) {
    final PsiType type = (PsiType) infos[0];
    final String typeString = type.getPresentableText();
    return InspectionGadgetsBundle.message("volatile.field.problem.descriptor", typeString);
}
Also used : PsiType(com.intellij.psi.PsiType) NotNull(org.jetbrains.annotations.NotNull)

Example 38 with PsiType

use of com.intellij.psi.PsiType in project intellij-community by JetBrains.

the class ConvertIntegerToHexPredicate 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();
        return !(text.startsWith("0x") || text.startsWith("0X"));
    }
    if (PsiType.DOUBLE.equals(type) || PsiType.FLOAT.equals(type)) {
        if (!PsiUtil.isLanguageLevel5OrHigher(expression)) {
            return false;
        }
        @NonNls final String text = expression.getText();
        if (text == null) {
            return false;
        }
        return !text.startsWith("0x") && !text.startsWith("0X");
    }
    return false;
}
Also used : NonNls(org.jetbrains.annotations.NonNls) PsiLiteralExpression(com.intellij.psi.PsiLiteralExpression) PsiType(com.intellij.psi.PsiType)

Example 39 with PsiType

use of com.intellij.psi.PsiType in project intellij-community by JetBrains.

the class ConvertIntegerToOctalPredicate 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))) {
        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;
}
Also used : NonNls(org.jetbrains.annotations.NonNls) PsiLiteralExpression(com.intellij.psi.PsiLiteralExpression) PsiType(com.intellij.psi.PsiType)

Example 40 with PsiType

use of com.intellij.psi.PsiType in project intellij-community by JetBrains.

the class UserExpressionDescriptorImpl method getEvaluationCode.

protected PsiCodeFragment getEvaluationCode(final StackFrameContext context) throws EvaluateException {
    Pair<PsiElement, PsiType> psiClassAndType = DebuggerUtilsImpl.getPsiClassAndType(myTypeName, myProject);
    if (psiClassAndType.first == null) {
        throw EvaluateExceptionUtil.createEvaluateException(DebuggerBundle.message("evaluation.error.invalid.type.name", myTypeName));
    }
    PsiCodeFragment fragment = createCodeFragment(psiClassAndType.first);
    if (fragment instanceof JavaCodeFragment) {
        ((JavaCodeFragment) fragment).setThisType(psiClassAndType.second);
    }
    return fragment;
}
Also used : PsiCodeFragment(com.intellij.psi.PsiCodeFragment) JavaCodeFragment(com.intellij.psi.JavaCodeFragment) PsiElement(com.intellij.psi.PsiElement) PsiType(com.intellij.psi.PsiType)

Aggregations

PsiType (com.intellij.psi.PsiType)157 PsiElement (com.intellij.psi.PsiElement)34 Nullable (org.jetbrains.annotations.Nullable)24 GrExpression (org.jetbrains.plugins.groovy.lang.psi.api.statements.expressions.GrExpression)24 NotNull (org.jetbrains.annotations.NotNull)21 PsiClassType (com.intellij.psi.PsiClassType)20 PsiClass (com.intellij.psi.PsiClass)14 GrReferenceExpression (org.jetbrains.plugins.groovy.lang.psi.api.statements.expressions.GrReferenceExpression)13 PsiPrimitiveType (com.intellij.psi.PsiPrimitiveType)12 ArrayList (java.util.ArrayList)9 GrTypeElement (org.jetbrains.plugins.groovy.lang.psi.api.types.GrTypeElement)9 PsiArrayType (com.intellij.psi.PsiArrayType)7 PsiExpression (com.intellij.psi.PsiExpression)7 PsiField (com.intellij.psi.PsiField)7 NonNls (org.jetbrains.annotations.NonNls)7 GrVariable (org.jetbrains.plugins.groovy.lang.psi.api.statements.GrVariable)7 PsiLiteralExpression (com.intellij.psi.PsiLiteralExpression)6 PsiMethod (com.intellij.psi.PsiMethod)6 GrStatement (org.jetbrains.plugins.groovy.lang.psi.api.statements.GrStatement)6 GrLiteral (org.jetbrains.plugins.groovy.lang.psi.api.statements.expressions.literals.GrLiteral)6