private static Expression parenthesizeIfRequired(Expression operand, int newOperatorPrecedence) { if (newOperatorPrecedence > OperatorPrecedence.getExpressionPrecedence(operand)) { return getParenthesizedExpression(operand.getAST(), operand); } return operand; }
private static Expression parenthesizeIfRequired(Expression operand, int newOperatorPrecedence) { if (newOperatorPrecedence > OperatorPrecedence.getExpressionPrecedence(operand)) { return getParenthesizedExpression(operand.getAST(), operand); } return operand; }
public InitializerTraversal(Expression initializer, HashSet staticImportsInInitializer, Expression newLocation, HashSet staticImportsInReference, CompilationUnitRewrite newLocationCuRewrite) { fInitializer= initializer; fInitializerRewrite= ASTRewrite.create(initializer.getAST()); fStaticImportsInInitializer2= staticImportsInInitializer; fNewLocation= newLocation; fStaticImportsInReference= staticImportsInReference; fNewLocationCuRewrite= newLocationCuRewrite; perform(initializer); }
private static ITypeBinding[] getParameterTypes(List args) { ITypeBinding[] params= new ITypeBinding[args.size()]; for (int i= 0; i < args.size(); i++) { Expression expr= (Expression) args.get(i); ITypeBinding curr= Bindings.normalizeTypeBinding(expr.resolveTypeBinding()); if (curr != null && curr.isWildcardType()) { curr= ASTResolving.normalizeWildcardType(curr, true, expr.getAST()); } if (curr == null) { curr= expr.getAST().resolveWellKnownType("java.lang.Object"); //$NON-NLS-1$ } params[i]= curr; } return params; }
private static Expression parenthesizeIfRequired(Expression operand, int newOperatorPrecedence) { if (newOperatorPrecedence < getExpressionPrecedence(operand)) { return getParenthesizedExpression(operand.getAST(), operand); } return operand; }
private static ITypeBinding[] getParameterTypes(List<Expression> args) { ITypeBinding[] params= new ITypeBinding[args.size()]; for (int i= 0; i < args.size(); i++) { Expression expr= args.get(i); ITypeBinding curr= Bindings.normalizeTypeBinding(expr.resolveTypeBinding()); if (curr != null && curr.isWildcardType()) { curr= ASTResolving.normalizeWildcardType(curr, true, expr.getAST()); } if (curr == null) { curr= expr.getAST().resolveWellKnownType("java.lang.Object"); //$NON-NLS-1$ } params[i]= curr; } return params; }
private static ITypeBinding[] getParameterTypes(List<Expression> args) { ITypeBinding[] params= new ITypeBinding[args.size()]; for (int i= 0; i < args.size(); i++) { Expression expr= args.get(i); ITypeBinding curr= Bindings.normalizeTypeBinding(expr.resolveTypeBinding()); if (curr != null && curr.isWildcardType()) { curr= ASTResolving.normalizeWildcardType(curr, true, expr.getAST()); } if (curr == null) { curr= expr.getAST().resolveWellKnownType("java.lang.Object"); //$NON-NLS-1$ } params[i]= curr; } return params; }
private static ITypeBinding[] getParameterTypes(List<Expression> args) { ITypeBinding[] params= new ITypeBinding[args.size()]; for (int i= 0; i < args.size(); i++) { Expression expr= args.get(i); ITypeBinding curr= Bindings.normalizeTypeBinding(expr.resolveTypeBinding()); if (curr != null && curr.isWildcardType()) { curr= ASTResolving.normalizeWildcardType(curr, true, expr.getAST()); } if (curr == null) { curr= expr.getAST().resolveWellKnownType("java.lang.Object"); //$NON-NLS-1$ } params[i]= curr; } return params; }
private static boolean isBoolean(Expression expression) { return expression.resolveTypeBinding() == expression.getAST().resolveWellKnownType("boolean"); //$NON-NLS-1$ } private static Expression getInversedInfixBooleanExpression(ASTRewrite rewrite, InfixExpression expression, InfixExpression.Operator newOperator, SimpleNameRenameProvider provider) {
private List<String> guessTempNamesFromExpression(Expression selectedExpression, String[] excluded) { ITypeBinding expressionBinding= Bindings.normalizeForDeclarationUse( selectedExpression.resolveTypeBinding(), selectedExpression.getAST()); String typeName= getQualifiedName(expressionBinding); if (typeName.length() == 0) typeName= expressionBinding.getName(); if (typeName.length() == 0) return Collections.emptyList(); int typeParamStart= typeName.indexOf("<"); //$NON-NLS-1$ if (typeParamStart != -1) typeName= typeName.substring(0, typeParamStart); String[] proposals= StubUtility.getLocalNameSuggestions(fSourceCU.getJavaProject(), typeName, expressionBinding.getDimensions(), excluded); return Arrays.asList(proposals); }
private static boolean isBoolean(Expression expression) { ITypeBinding typeBinding= expression.resolveTypeBinding(); AST ast= expression.getAST(); return typeBinding == ast.resolveWellKnownType("boolean") //$NON-NLS-1$ || typeBinding == ast.resolveWellKnownType("java.lang.Boolean"); //$NON-NLS-1$ }
private static boolean isBoolean(Expression expression) { ITypeBinding typeBinding= expression.resolveTypeBinding(); AST ast= expression.getAST(); return typeBinding == ast.resolveWellKnownType("boolean") //$NON-NLS-1$ || typeBinding == ast.resolveWellKnownType("java.lang.Boolean"); //$NON-NLS-1$ }
public InitializerTraversal(Expression initializer, HashSet<SimpleName> staticImportsInInitializer, Expression newLocation, HashSet<SimpleName> staticImportsInReference, CompilationUnitRewrite newLocationCuRewrite) { fInitializer= initializer; fInitializerRewrite= ASTRewrite.create(initializer.getAST()); fStaticImportsInInitializer2= staticImportsInInitializer; fNewLocation= newLocation; fStaticImportsInReference= staticImportsInReference; fNewLocationCuRewrite= newLocationCuRewrite; fNewLocationContext= new ContextSensitiveImportRewriteContext(fNewLocation, fNewLocationCuRewrite.getImportRewrite()); perform(initializer); }
/** * Build a new member value pair with the specified name and value. */ protected MemberValuePair newMemberValuePair(String name, Expression value) { AST ast = value.getAST(); MemberValuePair pair = ast.newMemberValuePair(); pair.setName(ast.newSimpleName(name)); pair.setValue(value); return pair; }
public InitializerTraversal(Expression initializer, HashSet<SimpleName> staticImportsInInitializer, Expression newLocation, HashSet<SimpleName> staticImportsInReference, CompilationUnitRewrite newLocationCuRewrite) { fInitializer= initializer; fInitializerRewrite= ASTRewrite.create(initializer.getAST()); fStaticImportsInInitializer2= staticImportsInInitializer; fNewLocation= newLocation; fStaticImportsInReference= staticImportsInReference; fNewLocationCuRewrite= newLocationCuRewrite; fNewLocationContext= new ContextSensitiveImportRewriteContext(fNewLocation, fNewLocationCuRewrite.getImportRewrite()); perform(initializer); }
protected void setValueSingleMemberAnnotation(Expression value, SingleMemberAnnotation annotation, ModifiedDeclaration declaration) { if (this.elementName.equals("value")) { // @Foo("yyy") => @Foo("xxx") annotation.setValue(value); } else { // @Foo("yyy") => @Foo(value="yyy", bar="xxx") Expression vv = annotation.getValue(); vv = (Expression) ASTNode.copySubtree(vv.getAST(), vv); NormalAnnotation normalAnnotation = this.annotationAdapter.newNormalAnnotation(declaration); this.addValue(vv, normalAnnotation, "value"); this.addValue(value, normalAnnotation); } }
private TType getBoxedType(ITypeBinding typeBinding, Expression expression) { if (typeBinding == null) return null; if (! typeBinding.isPrimitive()) return createTType(typeBinding); if (expression == null || ! expression.resolveBoxing()) return null; ITypeBinding boxed= Bindings.getBoxedTypeBinding(typeBinding, expression.getAST()); return createTType(boxed); }
private TType getBoxedType(ITypeBinding typeBinding, Expression expression) { if (typeBinding == null) return null; if (! typeBinding.isPrimitive()) return createTType(typeBinding); if (expression == null || ! expression.resolveBoxing()) return null; ITypeBinding boxed= Bindings.getBoxedTypeBinding(typeBinding, expression.getAST()); return createTType(boxed); }
private void addParameterInfo(CompilationUnitRewrite cuRewrite) throws JavaModelException { ITypeBinding typeBinding= Bindings.normalizeForDeclarationUse(fSelectedExpression.resolveTypeBinding(), fSelectedExpression.getAST()); String typeName= cuRewrite.getImportRewrite().addImport(typeBinding); String name= fParameterName != null ? fParameterName : guessedParameterName(); String defaultValue= fSourceCU.getBuffer().getText(fSelectedExpression.getStartPosition(), fSelectedExpression.getLength()); fParameter= ParameterInfo.createInfoForAddedParameter(typeBinding, typeName, name, defaultValue); if (fArguments == null) { List parameterInfos= fChangeSignatureRefactoring.getParameterInfos(); int parametersCount= parameterInfos.size(); if (parametersCount > 0 && ((ParameterInfo) parameterInfos.get(parametersCount - 1)).isOldVarargs()) parameterInfos.add(parametersCount - 1, fParameter); else parameterInfos.add(fParameter); } }
private TType getBoxedType(ITypeBinding typeBinding, Expression expression) { if (typeBinding == null) return null; if (! typeBinding.isPrimitive()) return createTType(typeBinding); if (expression == null || ! expression.resolveBoxing()) return null; String primitiveName= typeBinding.getName(); ITypeBinding boxed= expression.getAST().resolveWellKnownType(getBoxedTypeName(primitiveName)); return createTType(boxed); }