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));
}
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;
}
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);
}
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);
}
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);
}
Aggregations