Search in sources :

Example 56 with PsiExpression

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

the class ForIndexedPostfixTemplate method getTemplateString.

@Override
public final String getTemplateString(@NotNull PsiElement element) {
    PsiExpression expr = (PsiExpression) element;
    String bound = getExpressionBound(expr);
    if (bound == null) {
        return null;
    }
    return getStringTemplate(expr).replace("$bound$", bound).replace("$type$", suggestIndexType(expr));
}
Also used : PsiExpression(com.intellij.psi.PsiExpression)

Example 57 with PsiExpression

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

the class JavaFormattingModelBuilder method findNearestExpressionParent.

@Nullable
private static ASTNode findNearestExpressionParent(final ASTNode current) {
    ASTNode result = current;
    while (result != null) {
        PsiElement psi = result.getPsi();
        if (psi instanceof PsiExpression && !(psi.getParent() instanceof PsiExpression)) {
            break;
        }
        result = result.getTreeParent();
    }
    return result;
}
Also used : PsiExpression(com.intellij.psi.PsiExpression) ASTNode(com.intellij.lang.ASTNode) PsiElement(com.intellij.psi.PsiElement) Nullable(org.jetbrains.annotations.Nullable)

Example 58 with PsiExpression

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

the class JavaFormatterUtil method isMultilineExceptArguments.

public static boolean isMultilineExceptArguments(@NotNull PsiExpression[] arguments) {
    for (PsiExpression argument : arguments) {
        ASTNode beforeArgument = argument.getNode().getTreePrev();
        if (isWhiteSpaceWithLineFeed(beforeArgument))
            return true;
    }
    PsiExpression lastArgument = arguments[arguments.length - 1];
    ASTNode afterLastArgument = lastArgument.getNode().getTreeNext();
    return isWhiteSpaceWithLineFeed(afterLastArgument);
}
Also used : PsiExpression(com.intellij.psi.PsiExpression) ASTNode(com.intellij.lang.ASTNode)

Example 59 with PsiExpression

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

the class ExpressionChildrenRenderer method getChildValueExpression.

public PsiExpression getChildValueExpression(DebuggerTreeNode node, DebuggerContext context) throws EvaluateException {
    Value expressionValue = node.getParent().getDescriptor().getUserData(EXPRESSION_VALUE);
    if (expressionValue == null) {
        throw EvaluateExceptionUtil.createEvaluateException(DebuggerBundle.message("error.unable.to.evaluate.expression"));
    }
    NodeRenderer childrenRenderer = getChildrenRenderer(expressionValue, (ValueDescriptor) node.getParent().getDescriptor());
    PsiExpression childrenPsiExpression = myChildrenExpression.getPsiExpression(node.getProject());
    if (childrenPsiExpression == null) {
        return null;
    }
    return DebuggerTreeNodeExpression.substituteThis(childrenRenderer.getChildValueExpression(node, context), (PsiExpression) childrenPsiExpression.copy(), expressionValue);
}
Also used : PsiExpression(com.intellij.psi.PsiExpression) BooleanValue(com.sun.jdi.BooleanValue) Value(com.sun.jdi.Value)

Example 60 with PsiExpression

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

the class GuessContainerElementTypeTest method guessContainerElementTypes.

private PsiType[] guessContainerElementTypes() {
    int offset = getEditor().getCaretModel().getOffset();
    PsiElement element = getFile().findElementAt(offset);
    assertNotNull(element);
    PsiElement parent = element.getParent();
    assertTrue(parent instanceof PsiReferenceExpression);
    PsiExpression expr = (PsiExpression) parent;
    return GuessManager.getInstance(getProject()).guessContainerElementType(expr, null);
}
Also used : PsiExpression(com.intellij.psi.PsiExpression) PsiReferenceExpression(com.intellij.psi.PsiReferenceExpression) PsiElement(com.intellij.psi.PsiElement)

Aggregations

PsiExpression (com.intellij.psi.PsiExpression)67 PsiElement (com.intellij.psi.PsiElement)24 PsiReferenceExpression (com.intellij.psi.PsiReferenceExpression)11 PsiMethodCallExpression (com.intellij.psi.PsiMethodCallExpression)8 NonNls (org.jetbrains.annotations.NonNls)8 PsiLocalVariable (com.intellij.psi.PsiLocalVariable)7 PsiType (com.intellij.psi.PsiType)7 PsiAssignmentExpression (com.intellij.psi.PsiAssignmentExpression)6 PsiExpressionStatement (com.intellij.psi.PsiExpressionStatement)6 PsiPolyadicExpression (com.intellij.psi.PsiPolyadicExpression)6 PsiStatement (com.intellij.psi.PsiStatement)6 Nullable (org.jetbrains.annotations.Nullable)6 PsiBinaryExpression (com.intellij.psi.PsiBinaryExpression)5 PsiClass (com.intellij.psi.PsiClass)5 PsiDeclarationStatement (com.intellij.psi.PsiDeclarationStatement)5 PsiElementFactory (com.intellij.psi.PsiElementFactory)5 PsiField (com.intellij.psi.PsiField)5 PsiReference (com.intellij.psi.PsiReference)5 Nullable (com.android.annotations.Nullable)4 Project (com.intellij.openapi.project.Project)4