org.eclipse.jdt.core.dom.PrimitiveType Java Examples
The following examples show how to use
org.eclipse.jdt.core.dom.PrimitiveType.
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: DelegateMethodCreator.java From eclipse.jdt.ls with Eclipse Public License 2.0 | 7 votes |
/** * Creates the corresponding statement for the method invocation, based on * the return type. * * @param declaration the method declaration where the invocation statement * is inserted * @param invocation the method invocation being encapsulated by the * resulting statement * @return the corresponding statement */ protected Statement createMethodInvocation(final MethodDeclaration declaration, final MethodInvocation invocation) { Assert.isNotNull(declaration); Assert.isNotNull(invocation); Statement statement= null; final Type type= declaration.getReturnType2(); if (type == null) { statement= createExpressionStatement(invocation); } else { if (type instanceof PrimitiveType) { final PrimitiveType primitive= (PrimitiveType) type; if (primitive.getPrimitiveTypeCode().equals(PrimitiveType.VOID)) { statement= createExpressionStatement(invocation); } else { statement= createReturnStatement(invocation); } } else { statement= createReturnStatement(invocation); } } return statement; }
Example #2
Source File: GenerateHashCodeEqualsOperation.java From Eclipse-Postfix-Code-Completion with Eclipse Public License 1.0 | 6 votes |
private Expression createShiftAssignment(Expression shift1, Expression shift2) { // (int)(element ^ (element >>> 32)); // see implementation in Arrays.hashCode(), Double.hashCode() and // Long.hashCode() CastExpression ce= fAst.newCastExpression(); ce.setType(fAst.newPrimitiveType(PrimitiveType.INT)); InfixExpression unsignedShiftRight= fAst.newInfixExpression(); unsignedShiftRight.setLeftOperand(shift1); unsignedShiftRight.setRightOperand(fAst.newNumberLiteral("32")); //$NON-NLS-1$ unsignedShiftRight.setOperator(Operator.RIGHT_SHIFT_UNSIGNED); InfixExpression xor= fAst.newInfixExpression(); xor.setLeftOperand(shift2); xor.setRightOperand(parenthesize(unsignedShiftRight)); xor.setOperator(InfixExpression.Operator.XOR); ce.setExpression(parenthesize(xor)); return ce; }
Example #3
Source File: JavaASTFlattener.java From xtext-xtend with Eclipse Public License 2.0 | 6 votes |
public boolean isBooleanType(final Expression expression) { if ((expression instanceof BooleanLiteral)) { return true; } if ((expression instanceof SimpleName)) { final Type declType = this._aSTFlattenerUtils.findDeclaredType(((SimpleName)expression)); if ((declType != null)) { boolean _matched = false; boolean _isPrimitiveType = declType.isPrimitiveType(); if (_isPrimitiveType) { _matched=true; PrimitiveType.Code _primitiveTypeCode = ((PrimitiveType) declType).getPrimitiveTypeCode(); return Objects.equal(_primitiveTypeCode, PrimitiveType.BOOLEAN); } } } return false; }
Example #4
Source File: RefactoringAvailabilityTester.java From Eclipse-Postfix-Code-Completion with Eclipse Public License 1.0 | 6 votes |
public static boolean isGeneralizeTypeAvailable(final IJavaElement element) throws JavaModelException { if (element != null && element.exists()) { String type= null; if (element instanceof IMethod) type= ((IMethod) element).getReturnType(); else if (element instanceof IField) { final IField field= (IField) element; if (JdtFlags.isEnum(field)) return false; type= field.getTypeSignature(); } else if (element instanceof ILocalVariable) return true; else if (element instanceof IType) { final IType clazz= (IType) element; if (JdtFlags.isEnum(clazz)) return false; return true; } if (type == null || PrimitiveType.toCode(Signature.toString(type)) != null) return false; return true; } return false; }
Example #5
Source File: RefactoringAvailabilityTester.java From Eclipse-Postfix-Code-Completion with Eclipse Public License 1.0 | 6 votes |
public static boolean isGeneralizeTypeAvailable(final IStructuredSelection selection) throws JavaModelException { if (selection.size() == 1) { final Object element= selection.getFirstElement(); if (element instanceof IMethod) { final IMethod method= (IMethod) element; if (!method.exists()) return false; final String type= method.getReturnType(); if (PrimitiveType.toCode(Signature.toString(type)) == null) return Checks.isAvailable(method); } else if (element instanceof IField) { final IField field= (IField) element; if (!field.exists()) return false; if (!JdtFlags.isEnum(field)) return Checks.isAvailable(field); } } return false; }
Example #6
Source File: DelegateMethodCreator.java From Eclipse-Postfix-Code-Completion with Eclipse Public License 1.0 | 6 votes |
/** * Creates the corresponding statement for the method invocation, based on * the return type. * * @param declaration the method declaration where the invocation statement * is inserted * @param invocation the method invocation being encapsulated by the * resulting statement * @return the corresponding statement */ protected Statement createMethodInvocation(final MethodDeclaration declaration, final MethodInvocation invocation) { Assert.isNotNull(declaration); Assert.isNotNull(invocation); Statement statement= null; final Type type= declaration.getReturnType2(); if (type == null) statement= createExpressionStatement(invocation); else { if (type instanceof PrimitiveType) { final PrimitiveType primitive= (PrimitiveType) type; if (primitive.getPrimitiveTypeCode().equals(PrimitiveType.VOID)) statement= createExpressionStatement(invocation); else statement= createReturnStatement(invocation); } else statement= createReturnStatement(invocation); } return statement; }
Example #7
Source File: ChangeSignatureProcessor.java From Eclipse-Postfix-Code-Completion with Eclipse Public License 1.0 | 6 votes |
private void addNewConstructorToSubclass(AbstractTypeDeclaration subclass, CompilationUnitRewrite cuRewrite) { AST ast= subclass.getAST(); MethodDeclaration newConstructor= ast.newMethodDeclaration(); newConstructor.setName(ast.newSimpleName(subclass.getName().getIdentifier())); newConstructor.setConstructor(true); newConstructor.setJavadoc(null); newConstructor.modifiers().addAll(ASTNodeFactory.newModifiers(ast, getAccessModifier(subclass))); newConstructor.setReturnType2(ast.newPrimitiveType(PrimitiveType.VOID)); Block body= ast.newBlock(); newConstructor.setBody(body); SuperConstructorInvocation superCall= ast.newSuperConstructorInvocation(); addArgumentsToNewSuperConstructorCall(superCall, cuRewrite); body.statements().add(superCall); String msg= RefactoringCoreMessages.ChangeSignatureRefactoring_add_constructor; TextEditGroup description= cuRewrite.createGroupDescription(msg); cuRewrite.getASTRewrite().getListRewrite(subclass, subclass.getBodyDeclarationsProperty()).insertFirst(newConstructor, description); // TODO use AbstractTypeDeclaration }
Example #8
Source File: ChangeTypeAction.java From Eclipse-Postfix-Code-Completion with Eclipse Public License 1.0 | 6 votes |
private static IMember getMember(IStructuredSelection selection) throws JavaModelException { if (selection.size() != 1) return null; Object element= selection.getFirstElement(); if (!(element instanceof IMember)) return null; if (element instanceof IMethod) { IMethod method= (IMethod)element; String returnType= method.getReturnType(); if (PrimitiveType.toCode(Signature.toString(returnType)) != null) return null; return method; } else if (element instanceof IField && !JdtFlags.isEnum((IMember) element)) { return (IField)element; } return null; }
Example #9
Source File: CreateAsyncMethodProposal.java From gwt-eclipse-plugin with Eclipse Public License 1.0 | 6 votes |
@Override protected MethodDeclaration createMethodDeclaration(AST ast) { MethodDeclaration asyncMethodDecl = ast.newMethodDeclaration(); // New method has same name as original String methodName = getSyncMethodDeclaration().getName().getIdentifier(); asyncMethodDecl.setName(ast.newSimpleName(methodName)); // Async method has void return type by default (the user can also use // Request or RequestBuilder as the return type to get more functionality). // TODO: investigate whether we can enter linked mode after the fix is // applied, so the user can choose what return type to use. See // LinkedCorrectionProposal, which is a subclass of // ASTRewriteCorrectionProposal. asyncMethodDecl.setReturnType2(ast.newPrimitiveType(PrimitiveType.VOID)); addAsyncParameters(ast, asyncMethodDecl); // TODO: generate comments for new method return asyncMethodDecl; }
Example #10
Source File: CodeBlock.java From SimFix with GNU General Public License v2.0 | 6 votes |
private InstanceofExpr visit(InstanceofExpression node) { int startLine = _cunit.getLineNumber(node.getStartPosition()); int endLine = _cunit.getLineNumber(node.getStartPosition() + node.getLength()); InstanceofExpr instanceofExpr = new InstanceofExpr(startLine, endLine, node); Expr expression = (Expr) process(node.getLeftOperand()); expression.setParent(instanceofExpr); instanceofExpr.setExpression(expression); instanceofExpr.setInstanceType(node.getRightOperand()); AST ast = AST.newAST(AST.JLS8); Type exprType = ast.newPrimitiveType(PrimitiveType.BOOLEAN); instanceofExpr.setType(exprType); return instanceofExpr; }
Example #11
Source File: NodeUtils.java From SimFix with GNU General Public License v2.0 | 6 votes |
private static Type parsePreExprType(Expr expr, String operator){ AST ast = AST.newAST(AST.JLS8); switch(operator){ case "++": case "--": return ast.newPrimitiveType(PrimitiveType.INT); case "+": case "-": return expr.getType(); case "~": case "!": return ast.newPrimitiveType(PrimitiveType.BOOLEAN); default : return null; } }
Example #12
Source File: StyledStringVisitor.java From JDeodorant with MIT License | 6 votes |
public boolean visit(PrimitiveType type) { /* * PrimitiveType: byte short char int long float double boolean void */ styledString.append(type.getPrimitiveTypeCode().toString(), determineDiffStyle(type, new StyledStringStyler(keywordStyle))); return false; }
Example #13
Source File: Utils.java From txtUML with Eclipse Public License 1.0 | 5 votes |
public static boolean isVoid(Type type) { if (type instanceof PrimitiveType) { return ((PrimitiveType) type).getPrimitiveTypeCode().equals(PrimitiveType.VOID); } else { return false; } }
Example #14
Source File: Utils.java From txtUML with Eclipse Public License 1.0 | 5 votes |
public static boolean isBoolean(Type type) { if (type instanceof PrimitiveType) { return ((PrimitiveType) type).getPrimitiveTypeCode().equals(PrimitiveType.BOOLEAN); } else { return false; } }
Example #15
Source File: TreedUtils.java From compiler with Apache License 2.0 | 5 votes |
public static String buildASTLabel(ASTNode node) { String label = node.getClass().getSimpleName(); if (node instanceof Expression) { if (node.getClass().getSimpleName().endsWith("Literal")) { return label + "(" + node.toString() + ")"; } int type = node.getNodeType(); switch (type) { case ASTNode.INFIX_EXPRESSION: return label + "(" + ((InfixExpression) node).getOperator().toString() + ")"; case ASTNode.SIMPLE_NAME: return label + "(" + node.toString() + ")"; case ASTNode.POSTFIX_EXPRESSION: return label + "(" + ((PostfixExpression) node).getOperator().toString() + ")"; case ASTNode.PREFIX_EXPRESSION: return label + "(" + ((PrefixExpression) node).getOperator().toString() + ")"; default: break; } } else if (node instanceof Modifier) { return label + "(" + node.toString() + ")"; } else if (node instanceof Type) { if (node instanceof PrimitiveType) return label + "(" + node.toString() + ")"; } else if (node instanceof TextElement) { return label + "(" + node.toString() + ")"; } else if (node instanceof TagElement) { String tag = ((TagElement) node).getTagName(); if (tag == null) return label; return label + "(" + tag + ")"; } return label; }
Example #16
Source File: CodeBlock.java From SimFix with GNU General Public License v2.0 | 5 votes |
private BoolLiteral visit(BooleanLiteral node) { int startLine = _cunit.getLineNumber(node.getStartPosition()); int endLine = _cunit.getLineNumber(node.getStartPosition() + node.getLength()); BoolLiteral literal = new BoolLiteral(startLine, endLine, node); literal.setValue(node.booleanValue()); AST ast = AST.newAST(AST.JLS8); Type type = ast.newPrimitiveType(PrimitiveType.BOOLEAN); literal.setType(type); return literal; }
Example #17
Source File: ASTResolving.java From Eclipse-Postfix-Code-Completion with Eclipse Public License 1.0 | 5 votes |
public static ITypeBinding[] getNarrowingTypes(AST ast, ITypeBinding type) { ArrayList<ITypeBinding> res= new ArrayList<ITypeBinding>(); res.add(type); if (type.isPrimitive()) { Code code= PrimitiveType.toCode(type.getName()); for (int i= 0; i < CODE_ORDER.length && code != CODE_ORDER[i]; i++) { String typeName= CODE_ORDER[i].toString(); res.add(ast.resolveWellKnownType(typeName)); } } return res.toArray(new ITypeBinding[res.size()]); }
Example #18
Source File: CodeBlock.java From SimFix with GNU General Public License v2.0 | 5 votes |
private CharLiteral visit(CharacterLiteral node) { int startLine = _cunit.getLineNumber(node.getStartPosition()); int endLine = _cunit.getLineNumber(node.getStartPosition() + node.getLength()); CharLiteral charLiteral = new CharLiteral(startLine, endLine, node); charLiteral.setValue(node.charValue()); AST ast = AST.newAST(AST.JLS8); Type type = ast.newPrimitiveType(PrimitiveType.CHAR); charLiteral.setType(type); return charLiteral; }
Example #19
Source File: ASTResolving.java From Eclipse-Postfix-Code-Completion with Eclipse Public License 1.0 | 5 votes |
public static ITypeBinding[] getRelaxingTypes(AST ast, ITypeBinding type) { ArrayList<ITypeBinding> res= new ArrayList<ITypeBinding>(); res.add(type); if (type.isArray()) { res.add(ast.resolveWellKnownType("java.lang.Object")); //$NON-NLS-1$ // The following two types are not available in some j2me implementations, see https://bugs.eclipse.org/bugs/show_bug.cgi?id=288060 : ITypeBinding serializable= ast.resolveWellKnownType("java.io.Serializable"); //$NON-NLS-1$ if (serializable != null) res.add(serializable); ITypeBinding cloneable= ast.resolveWellKnownType("java.lang.Cloneable"); //$NON-NLS-1$ if (cloneable != null) res.add(cloneable); } else if (type.isPrimitive()) { Code code= PrimitiveType.toCode(type.getName()); boolean found= false; for (int i= 0; i < CODE_ORDER.length; i++) { if (found) { String typeName= CODE_ORDER[i].toString(); res.add(ast.resolveWellKnownType(typeName)); } if (code == CODE_ORDER[i]) { found= true; } } } else { collectRelaxingTypes(res, type); } return res.toArray(new ITypeBinding[res.size()]); }
Example #20
Source File: BindingSignatureVisitor.java From JDeodorant with MIT License | 5 votes |
private void handleType(Type type) { if (type instanceof PrimitiveType) { visit((PrimitiveType) type); } else if (type instanceof ArrayType) { visit((ArrayType) type); } else if (type instanceof SimpleType) { visit((SimpleType) type); } else if (type instanceof QualifiedType) { visit((QualifiedType) type); } else if (type instanceof ParameterizedType) { visit((ParameterizedType) type); } else if (type instanceof WildcardType) { visit((WildcardType) type); } }
Example #21
Source File: JavaSourceFileParser.java From BUILD_file_generator with Apache License 2.0 | 5 votes |
/** * Returns true iff 'methodDeclaration' represents a void static method named 'main' that takes a * single String[] parameter. */ private static boolean isMainMethod(MethodDeclaration methodDeclaration) { // Is it static? if ((methodDeclaration.getModifiers() & Modifier.STATIC) == 0) { return false; } // Does it return void? Type returnType = methodDeclaration.getReturnType2(); if (!returnType.isPrimitiveType()) { return false; } if (((PrimitiveType) returnType).getPrimitiveTypeCode() != PrimitiveType.VOID) { return false; } // Is it called 'main'? if (!"main".equals(methodDeclaration.getName().getIdentifier())) { return false; } // Does it have a single parameter? if (methodDeclaration.parameters().size() != 1) { return false; } // Is the parameter's type String[]? SingleVariableDeclaration pt = getOnlyElement((List<SingleVariableDeclaration>) methodDeclaration.parameters()); IVariableBinding vb = pt.resolveBinding(); if (vb == null) { return false; } ITypeBinding tb = vb.getType(); return tb != null && "java.lang.String[]".equals(tb.getQualifiedName()); }
Example #22
Source File: ParameterGuesser.java From Eclipse-Postfix-Code-Completion with Eclipse Public License 1.0 | 5 votes |
private PrimitiveType.Code getPrimitiveTypeCode(String type) { PrimitiveType.Code code= PrimitiveType.toCode(type); if (code != null) { return code; } if (fEnclosingElement != null && JavaModelUtil.is50OrHigher(fEnclosingElement.getJavaProject())) { if (code == PrimitiveType.SHORT) { if ("java.lang.Short".equals(type)) { //$NON-NLS-1$ return code; } } else if (code == PrimitiveType.INT) { if ("java.lang.Integer".equals(type)) { //$NON-NLS-1$ return code; } } else if (code == PrimitiveType.LONG) { if ("java.lang.Long".equals(type)) { //$NON-NLS-1$ return code; } } else if (code == PrimitiveType.FLOAT) { if ("java.lang.Float".equals(type)) { //$NON-NLS-1$ return code; } } else if (code == PrimitiveType.DOUBLE) { if ("java.lang.Double".equals(type)) { //$NON-NLS-1$ return code; } } else if (code == PrimitiveType.CHAR) { if ("java.lang.Character".equals(type)) { //$NON-NLS-1$ return code; } } else if (code == PrimitiveType.BYTE) { if ("java.lang.Byte".equals(type)) { //$NON-NLS-1$ return code; } } } return null; }
Example #23
Source File: IntroduceIndirectionRefactoring.java From Eclipse-Postfix-Code-Completion with Eclipse Public License 1.0 | 5 votes |
private Statement encapsulateInvocation(MethodDeclaration declaration, MethodInvocation invocation) { final Type type= declaration.getReturnType2(); if (type == null || (type instanceof PrimitiveType && PrimitiveType.VOID.equals( ((PrimitiveType) type).getPrimitiveTypeCode()))) return invocation.getAST().newExpressionStatement(invocation); ReturnStatement statement= invocation.getAST().newReturnStatement(); statement.setExpression(invocation); return statement; }
Example #24
Source File: TypeContextChecker.java From Eclipse-Postfix-Code-Completion with Eclipse Public License 1.0 | 5 votes |
private static boolean isVoidArrayType(Type type){ if (! type.isArrayType()) return false; ArrayType arrayType= (ArrayType)type; if (! arrayType.getElementType().isPrimitiveType()) return false; PrimitiveType primitiveType= (PrimitiveType) arrayType.getElementType(); return (primitiveType.getPrimitiveTypeCode() == PrimitiveType.VOID); }
Example #25
Source File: TypeContextChecker.java From Eclipse-Postfix-Code-Completion with Eclipse Public License 1.0 | 5 votes |
private static Type parseSuperType(String superType, boolean isInterface) { if (! superType.trim().equals(superType)) { return null; } StringBuffer cuBuff= new StringBuffer(); if (isInterface) cuBuff.append("class __X__ implements "); //$NON-NLS-1$ else cuBuff.append("class __X__ extends "); //$NON-NLS-1$ int offset= cuBuff.length(); cuBuff.append(superType).append(" {}"); //$NON-NLS-1$ ASTParser p= ASTParser.newParser(ASTProvider.SHARED_AST_LEVEL); p.setSource(cuBuff.toString().toCharArray()); Map<String, String> options= new HashMap<String, String>(); JavaModelUtil.setComplianceOptions(options, JavaModelUtil.VERSION_LATEST); p.setCompilerOptions(options); CompilationUnit cu= (CompilationUnit) p.createAST(null); ASTNode selected= NodeFinder.perform(cu, offset, superType.length()); if (selected instanceof Name) selected= selected.getParent(); if (selected.getStartPosition() != offset || selected.getLength() != superType.length() || ! (selected instanceof Type) || selected instanceof PrimitiveType) { return null; } Type type= (Type) selected; String typeNodeRange= cuBuff.substring(type.getStartPosition(), ASTNodes.getExclusiveEnd(type)); if (! superType.equals(typeNodeRange)){ return null; } return type; }
Example #26
Source File: GetterSetterUtil.java From Eclipse-Postfix-Code-Completion with Eclipse Public License 1.0 | 5 votes |
/** * Checks if the assignment needs a downcast and inserts it if necessary * * @param expression the right hand-side * @param expressionType the type of the right hand-side. Can be null * @param ast the AST * @param variableType the Type of the variable the expression will be assigned to * @param is50OrHigher if <code>true</code> java 5.0 code will be assumed * @return the casted expression if necessary */ private static Expression createNarrowCastIfNessecary(Expression expression, ITypeBinding expressionType, AST ast, ITypeBinding variableType, boolean is50OrHigher) { PrimitiveType castTo= null; if (variableType.isEqualTo(expressionType)) return expression; //no cast for same type if (is50OrHigher) { if (ast.resolveWellKnownType("java.lang.Character").isEqualTo(variableType)) //$NON-NLS-1$ castTo= ast.newPrimitiveType(PrimitiveType.CHAR); if (ast.resolveWellKnownType("java.lang.Byte").isEqualTo(variableType)) //$NON-NLS-1$ castTo= ast.newPrimitiveType(PrimitiveType.BYTE); if (ast.resolveWellKnownType("java.lang.Short").isEqualTo(variableType)) //$NON-NLS-1$ castTo= ast.newPrimitiveType(PrimitiveType.SHORT); } if (ast.resolveWellKnownType("char").isEqualTo(variableType)) //$NON-NLS-1$ castTo= ast.newPrimitiveType(PrimitiveType.CHAR); if (ast.resolveWellKnownType("byte").isEqualTo(variableType)) //$NON-NLS-1$ castTo= ast.newPrimitiveType(PrimitiveType.BYTE); if (ast.resolveWellKnownType("short").isEqualTo(variableType)) //$NON-NLS-1$ castTo= ast.newPrimitiveType(PrimitiveType.SHORT); if (castTo != null) { CastExpression cast= ast.newCastExpression(); if (NecessaryParenthesesChecker.needsParentheses(expression, cast, CastExpression.EXPRESSION_PROPERTY)) { ParenthesizedExpression parenthesized= ast.newParenthesizedExpression(); parenthesized.setExpression(expression); cast.setExpression(parenthesized); } else cast.setExpression(expression); cast.setType(castTo); return cast; } return expression; }
Example #27
Source File: GenerateHashCodeEqualsOperation.java From Eclipse-Postfix-Code-Completion with Eclipse Public License 1.0 | 5 votes |
private boolean isPrimitiveType(ITypeBinding type, PrimitiveType.Code[] codes) { for (int i= 0; i < codes.length; i++) { PrimitiveType.Code code= codes[i]; if (isPrimitiveType(type, code)) return true; } return false; }
Example #28
Source File: ASTNodeFactory.java From Eclipse-Postfix-Code-Completion with Eclipse Public License 1.0 | 5 votes |
/** * Returns an expression that is assignable to the given type. <code>null</code> is * returned if the type is the 'void' type. * * @param ast The AST to create the expression for * @param type The type of the returned expression * @param extraDimensions Extra dimensions to the type * @return the Null-literal for reference types, a boolean-literal for a boolean type, a number * literal for primitive types or <code>null</code> if the type is void. */ public static Expression newDefaultExpression(AST ast, Type type, int extraDimensions) { if (extraDimensions == 0 && type.isPrimitiveType()) { PrimitiveType primitiveType= (PrimitiveType) type; if (primitiveType.getPrimitiveTypeCode() == PrimitiveType.BOOLEAN) { return ast.newBooleanLiteral(false); } else if (primitiveType.getPrimitiveTypeCode() == PrimitiveType.VOID) { return null; } else { return ast.newNumberLiteral("0"); //$NON-NLS-1$ } } return ast.newNullLiteral(); }
Example #29
Source File: AbstractToStringGenerator.java From Eclipse-Postfix-Code-Completion with Eclipse Public License 1.0 | 5 votes |
/** * @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; }
Example #30
Source File: GenerateHashCodeEqualsOperation.java From Eclipse-Postfix-Code-Completion with Eclipse Public License 1.0 | 5 votes |
private Statement createSimpleComparison(IVariableBinding binding) { if (isPrimitiveType(binding.getType(), PrimitiveType.FLOAT)) { return createReturningIfStatement(createFloatInvocation(getThisAccessForEquals(binding.getName())), createFloatInvocation(getOtherAccess(binding .getName())), Operator.NOT_EQUALS, false); } else if (isPrimitiveType(binding.getType(), PrimitiveType.DOUBLE)) { return createReturningIfStatement(createDoubleInvocation(getThisAccessForEquals(binding.getName())), createDoubleInvocation(getOtherAccess(binding .getName())), Operator.NOT_EQUALS, false); } else return createReturningIfStatement(getThisAccessForEquals(binding.getName()), getOtherAccess(binding.getName()), Operator.NOT_EQUALS, false); }