private static boolean isLiteral(Expression expression) { switch (expression.getNodeType()) { case ASTNode.BOOLEAN_LITERAL: case ASTNode.CHARACTER_LITERAL: case ASTNode.NULL_LITERAL: case ASTNode.NUMBER_LITERAL: case ASTNode.STRING_LITERAL: return true; default: return false; } }
public static boolean isLiteral(Expression expression) { int type= expression.getNodeType(); return type == ASTNode.BOOLEAN_LITERAL || type == ASTNode.CHARACTER_LITERAL || type == ASTNode.NULL_LITERAL || type == ASTNode.NUMBER_LITERAL || type == ASTNode.STRING_LITERAL || type == ASTNode.TYPE_LITERAL; }
private static boolean expressionTypeNeedsParentheses(Expression expression) { int type= expression.getNodeType(); return type == ASTNode.INFIX_EXPRESSION || type == ASTNode.CONDITIONAL_EXPRESSION || type == ASTNode.PREFIX_EXPRESSION || type == ASTNode.POSTFIX_EXPRESSION || type == ASTNode.CAST_EXPRESSION || type == ASTNode.INSTANCEOF_EXPRESSION || type == ASTNode.ARRAY_CREATION || type == ASTNode.ASSIGNMENT; }
public static boolean isLiteral(Expression expression) { int type= expression.getNodeType(); return type == ASTNode.BOOLEAN_LITERAL || type == ASTNode.CHARACTER_LITERAL || type == ASTNode.NULL_LITERAL || type == ASTNode.NUMBER_LITERAL || type == ASTNode.STRING_LITERAL || type == ASTNode.TYPE_LITERAL; }
@Override public boolean consumesLiteral(SemanticToken token) { Expression expr = token.getLiteral(); return expr != null && expr.getNodeType() == ASTNode.NUMBER_LITERAL; } }
@Override public boolean consumesLiteral(SemanticToken token) { Expression expr= token.getLiteral(); return expr != null && expr.getNodeType() == ASTNode.NUMBER_LITERAL; } }
@Override protected String convertExpression(Expression expression) { switch (expression.getNodeType()) { case ASTNode.QUALIFIED_NAME: case ASTNode.SIMPLE_NAME: return ((Name) expression).getFullyQualifiedName(); default: return null; } }
@Override public boolean consumesLiteral(SemanticToken token) { Expression expr= token.getLiteral(); return expr != null && expr.getNodeType() == ASTNode.NUMBER_LITERAL; } }
public static String resolveEnum(Expression expression) { if (expression == null) { return null; } switch (expression.getNodeType()) { case ASTNode.QUALIFIED_NAME: case ASTNode.SIMPLE_NAME: return resolveEnum((Name) expression); default: return null; } }
private boolean isVariable(final Expression expr) { switch (removeParentheses(expr).getNodeType()) { case SIMPLE_NAME: case QUALIFIED_NAME: case FIELD_ACCESS: return true; default: return false; } }
private RefactoringStatus checkInitializer(VariableDeclaration decl) { if (decl.getInitializer().getNodeType() == ASTNode.NULL_LITERAL) return RefactoringStatus.createFatalErrorStatus(RefactoringCoreMessages.InlineTemRefactoring_error_message_nulLiteralsCannotBeInlined); return null; }
private RefactoringStatus checkInitializer(VariableDeclaration decl) { if (decl.getInitializer().getNodeType() == ASTNode.NULL_LITERAL) return RefactoringStatus.createFatalErrorStatus(RefactoringCoreMessages.InlineTemRefactoring_error_message_nulLiteralsCannotBeInlined); return null; }
/** * check for a single expression with no surrounding braces, implying a * single-entry array */ @Override protected String[] convertExpression(Expression expression) { return (expression.getNodeType() == ASTNode.ARRAY_INITIALIZER) ? this.arrayConverter.convertArrayInitializer((ArrayInitializer) expression) : new String[] {this.elementConverter.convert(expression)}; }
/** * Returns whether the provided expressions represent the same local variable. * * @param expr1 the first expression to analyze * @param expr2 the second expression to analyze * @return {@code true} if the provided expressions represent the same local variable, {@code false} otherwise */ public static boolean isSameLocalVariable(Expression expr1, Expression expr2) { return expr1 != null && expr1.getNodeType() == SIMPLE_NAME && isSameLocalVariable(((SimpleName) expr1).resolveBinding(), expr2); }
private Object constValue(Expression expression) { switch (expression.getNodeType()) { case ASTNode.PREFIX_EXPRESSION: return constValue((PrefixExpression) expression); case ASTNode.SIMPLE_NAME: case ASTNode.QUALIFIED_NAME: return constValue((Name) expression); } return null; }
public static boolean isResolvedTypeInferredFromExpectedType(Expression invocation) { switch(invocation.getNodeType()) { case ASTNode.METHOD_INVOCATION: return ((MethodInvocation) invocation).isResolvedTypeInferredFromExpectedType(); case ASTNode.SUPER_METHOD_INVOCATION: return ((SuperMethodInvocation) invocation).isResolvedTypeInferredFromExpectedType(); case ASTNode.CONSTRUCTOR_INVOCATION: return false; default: throw new IllegalArgumentException(invocation.toString()); } }
public ExpressionVariable(Expression expression){ super(expression.resolveTypeBinding()); fSource= expression.toString(); ICompilationUnit cu= ASTCreator.getCu(expression); Assert.isNotNull(cu); fRange= new CompilationUnitRange(cu, expression); fExpressionBinding= resolveBinding(expression); fExpressionType= expression.getNodeType(); }
@Override protected String convertExpression(Expression expression) { if (expression.getNodeType() == ASTNode.TYPE_LITERAL) { org.eclipse.jdt.core.dom.Type type = ((TypeLiteral) expression).getType(); if (type.getNodeType() == ASTNode.PRIMITIVE_TYPE) { return ((PrimitiveType) type).getPrimitiveTypeCode().toString(); } } return null; }
public static ASTRewriteCorrectionProposal createCastProposal(IInvocationContext context, ITypeBinding castTypeBinding, Expression nodeToCast, int relevance) { ICompilationUnit cu= context.getCompilationUnit(); String label; String castType= BindingLabelProvider.getBindingLabel(castTypeBinding, JavaElementLabels.ALL_DEFAULT); if (nodeToCast.getNodeType() == ASTNode.CAST_EXPRESSION) { label= Messages.format(CorrectionMessages.TypeMismatchSubProcessor_changecast_description, castType); } else { label= Messages.format(CorrectionMessages.TypeMismatchSubProcessor_addcast_description, castType); } return new CastCompletionProposal(label, cu, nodeToCast, castTypeBinding, relevance); }
public static ASTRewriteCorrectionProposal createCastProposal(IInvocationContext context, ITypeBinding castTypeBinding, Expression nodeToCast, int relevance) { ICompilationUnit cu= context.getCompilationUnit(); String label; String castType= BindingLabelProvider.getBindingLabel(castTypeBinding, JavaElementLabels.ALL_DEFAULT); if (nodeToCast.getNodeType() == ASTNode.CAST_EXPRESSION) { label= Messages.format(CorrectionMessages.TypeMismatchSubProcessor_changecast_description, castType); } else { label= Messages.format(CorrectionMessages.TypeMismatchSubProcessor_addcast_description, castType); } return new CastCorrectionProposal(label, cu, nodeToCast, castTypeBinding, relevance); }