/** * Create a number literal. * * @param value literal value * @return literal */ public NumberLiteral numberLiteral(String value) { return m_ast.newNumberLiteral(value); } }
/** * Builds a new {@link NumberLiteral} instance. * * @param s the number literal value * @return a new number literal */ public NumberLiteral number(String s) { return ast.newNumberLiteral(s); }
/** * Builds a new {@link NumberLiteral} instance. * * @return a new number literal */ public NumberLiteral numberLiteral() { return ast.newNumberLiteral(); }
/** * Add a number literal operand to expression. * * @param value number literal operand */ public void addNumberLiteralOperand(String value) { addOperand(m_ast.newNumberLiteral(value)); }
@Override protected boolean addInitializer(final VariableDeclarationFragment fragment, final ASTNode declarationNode) { Assert.isNotNull(fragment); final Expression expression= fragment.getAST().newNumberLiteral(DEFAULT_EXPRESSION); if (expression != null) { fragment.setInitializer(expression); } return true; }
@Override public final void run(final IProgressMonitor monitor) throws InterruptedException { Assert.isNotNull(monitor); String id= computeId(declarationNode, monitor); fragment.setInitializer(fragment.getAST().newNumberLiteral(id)); } });
@Override protected boolean addInitializer(final VariableDeclarationFragment fragment, final ASTNode declarationNode) { Assert.isNotNull(fragment); final Expression expression= fragment.getAST().newNumberLiteral(DEFAULT_EXPRESSION); if (expression != null) fragment.setInitializer(expression); return true; }
@Override protected boolean addInitializer(final VariableDeclarationFragment fragment, final ASTNode declarationNode) { Assert.isNotNull(fragment); final Expression expression= fragment.getAST().newNumberLiteral(DEFAULT_EXPRESSION); if (expression != null) fragment.setInitializer(expression); return true; }
public final void run(final IProgressMonitor monitor) throws InterruptedException { Assert.isNotNull(monitor); String id= computeId(declarationNode, monitor); fragment.setInitializer(fragment.getAST().newNumberLiteral(id)); } });
/** * Set initializer as a number literal. * * @param value number literal */ public void setNumberInitializer(String value) { VariableDeclarationFragment frag = (VariableDeclarationFragment)m_field.fragments().get(0); frag.setInitializer(m_ast.newNumberLiteral(value)); } }
@Override public final void run(final IProgressMonitor monitor) throws InterruptedException { Assert.isNotNull(monitor); String id= computeId(declarationNode, monitor); fragment.setInitializer(fragment.getAST().newNumberLiteral(id)); } });
@Override protected boolean addInitializer(final VariableDeclarationFragment fragment, final ASTNode declarationNode) { Assert.isNotNull(fragment); try { String id = computeId(declarationNode, new NullProgressMonitor()); fragment.setInitializer(fragment.getAST().newNumberLiteral(id)); } catch (InterruptedException exception) { // Do nothing } return true; }
@Override protected boolean addInitializer(VariableDeclarationFragment fragment, ASTNode declarationNode) { ITypeBinding typeBinding = getTypeBinding(declarationNode); if (typeBinding == null) { return false; } Long id = fContext.getSerialVersionId(typeBinding); if (id == null) { return false; } fragment.setInitializer(fragment.getAST().newNumberLiteral(id.toString() + LONG_SUFFIX)); return true; }
@Override protected boolean addInitializer(VariableDeclarationFragment fragment, ASTNode declarationNode) { ITypeBinding typeBinding= getTypeBinding(declarationNode); if (typeBinding == null) return false; Long id= fContext.getSerialVersionId(typeBinding); if (id == null) return false; fragment.setInitializer(fragment.getAST().newNumberLiteral(id.toString() + LONG_SUFFIX)); return true; }
protected Expression createSubListInvocation(Expression memberAccess, Expression sizeAccess) { MethodInvocation subListInvocation= fAst.newMethodInvocation(); subListInvocation.setExpression(memberAccess); subListInvocation.setName(fAst.newSimpleName("subList")); //$NON-NLS-1$ subListInvocation.arguments().add(fAst.newNumberLiteral(String.valueOf(0))); MethodInvocation minInvocation= createMethodInvocation(addImport("java.lang.Math"), "min", sizeAccess); //$NON-NLS-1$ //$NON-NLS-2$ minInvocation.arguments().add(fAst.newSimpleName(fMaxLenVariableName)); subListInvocation.arguments().add(minInvocation); needMaxLenVariable= true; return subListInvocation; }
protected Expression createSubListInvocation(Expression memberAccess, Expression sizeAccess) { MethodInvocation subListInvocation= fAst.newMethodInvocation(); subListInvocation.setExpression(memberAccess); subListInvocation.setName(fAst.newSimpleName("subList")); //$NON-NLS-1$ subListInvocation.arguments().add(fAst.newNumberLiteral(String.valueOf(0))); MethodInvocation minInvocation= createMethodInvocation(addImport("java.lang.Math"), "min", sizeAccess); //$NON-NLS-1$ //$NON-NLS-2$ minInvocation.arguments().add(fAst.newSimpleName(fMaxLenVariableName)); subListInvocation.arguments().add(minInvocation); needMaxLenVariable= true; return subListInvocation; }
/** * @return a statement in form of <code>final int maxLen = 10;</code> */ protected VariableDeclarationStatement createMaxLenDeclaration() { VariableDeclarationFragment fragment= fAst.newVariableDeclarationFragment(); fragment.setName(fAst.newSimpleName(fMaxLenVariableName)); fragment.setInitializer(fAst.newNumberLiteral(String.valueOf(fContext.getLimitItemsValue()))); VariableDeclarationStatement declExpression= fAst.newVariableDeclarationStatement(fragment); declExpression.setType(fAst.newPrimitiveType(PrimitiveType.INT)); declExpression.modifiers().add(fAst.newModifier(ModifierKeyword.FINAL_KEYWORD)); return declExpression; }
/** * @return a statement in form of <code>final int maxLen = 10;</code> */ protected VariableDeclarationStatement createMaxLenDeclaration() { VariableDeclarationFragment fragment= fAst.newVariableDeclarationFragment(); fragment.setName(fAst.newSimpleName(fMaxLenVariableName)); fragment.setInitializer(fAst.newNumberLiteral(String.valueOf(fContext.getLimitItemsValue()))); VariableDeclarationStatement declExpression= fAst.newVariableDeclarationStatement(fragment); declExpression.setType(fAst.newPrimitiveType(PrimitiveType.INT)); declExpression.modifiers().add(fAst.newModifier(ModifierKeyword.FINAL_KEYWORD)); return declExpression; }
private static Expression createInfixInvocationFromPostPrefixExpression(InfixExpression.Operator operator, Expression getterExpression, AST ast, ITypeBinding variableType, boolean is50OrHigher) { InfixExpression infix= ast.newInfixExpression(); infix.setLeftOperand(getterExpression); infix.setOperator(operator); NumberLiteral number= ast.newNumberLiteral(); number.setToken("1"); //$NON-NLS-1$ infix.setRightOperand(number); ITypeBinding infixType= infix.resolveTypeBinding(); return createNarrowCastIfNessecary(infix, infixType, ast, variableType, is50OrHigher); }
private static Expression createInfixInvocationFromPostPrefixExpression(InfixExpression.Operator operator, Expression getterExpression, AST ast, ITypeBinding variableType, boolean is50OrHigher) { InfixExpression infix= ast.newInfixExpression(); infix.setLeftOperand(getterExpression); infix.setOperator(operator); NumberLiteral number= ast.newNumberLiteral(); number.setToken("1"); //$NON-NLS-1$ infix.setRightOperand(number); ITypeBinding infixType= infix.resolveTypeBinding(); return createNarrowCastIfNessecary(infix, infixType, ast, variableType, is50OrHigher); }