Refine search
if (annotation.isSingleMemberAnnotation()) { org.eclipse.jdt.core.dom.SingleMemberAnnotation smAnn = (org.eclipse.jdt.core.dom.SingleMemberAnnotation) annotation; values.add(smAnn.getValue().toString()); } else if (annotation.isNormalAnnotation()) { org.eclipse.jdt.core.dom.NormalAnnotation normalAnn = (org.eclipse.jdt.core.dom.NormalAnnotation) annotation; signature.append("@").append(annotation.resolveTypeBinding().getQualifiedName()); if (!values.isEmpty()) { signature.append("(");
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 boolean visit(MethodInvocation node) { Expression receiver= node.getExpression(); if (receiver == null) { SimpleName name= node.getName(); if (fIgnoreBinding == null || !Bindings.equals(fIgnoreBinding, name.resolveBinding())) node.getName().accept(this); } else { receiver.accept(this); } accept(node.arguments()); return false; }
public boolean visit(MethodInvocation invocation) { if (invocation.getExpression() == null) qualifyUnqualifiedMemberNameIfNecessary(invocation.getName()); else invocation.getExpression().accept(this); for (Iterator it= invocation.arguments().iterator(); it.hasNext();) ((Expression) it.next()).accept(this); return false; }
public boolean isEnumNameMethodInvocation (MethodInvocation node) { return node.getName().getIdentifier().equals("name") && node.getExpression() != null && node.getExpression().resolveTypeBinding().isEnum(); }
public static String processMethodInvocation(MethodInvocation node) { StringBuilder sb = new StringBuilder(); sb.append(node.getName().getIdentifier()); sb.append("("); List<Expression> arguments = node.arguments(); if(arguments.size() > 0) { for(int i=0; i<arguments.size()-1; i++) sb.append(arguments.get(i).toString()).append(", "); sb.append(arguments.get(arguments.size()-1).toString()); } sb.append(")"); return sb.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(); }
private void replaceSelectedExpression(CompilationUnitRewrite cuRewrite) { if (! fSourceCU.equals(cuRewrite.getCu())) return; // TODO: do for all methodDeclarations and replace matching fragments? // cannot use fSelectedExpression here, since it could be from another AST (if method was replaced by overridden): Expression expression= (Expression) NodeFinder.perform(cuRewrite.getRoot(), fSelectedExpression.getStartPosition(), fSelectedExpression.getLength()); ASTNode newExpression= cuRewrite.getRoot().getAST().newSimpleName(fParameter.getNewName()); String description= RefactoringCoreMessages.IntroduceParameterRefactoring_replace; cuRewrite.getASTRewrite().replace(expression.getParent() instanceof ParenthesizedExpression ? expression.getParent() : expression, newExpression, cuRewrite.createGroupDescription(description)); }
private void replaceStringValueOfByArg0(final Expression toReplace, final MethodInvocation mi) { final ASTBuilder b = this.ctx.getASTBuilder(); final ITypeBinding expectedType = mi.resolveMethodBinding().getParameterTypes()[0]; final ITypeBinding actualType = arg0(mi).resolveTypeBinding(); if (!expectedType.equals(actualType) && !getBoxedTypeBinding(expectedType, mi.getAST()).equals(actualType)) { ctx.getRefactorings().replace(toReplace, b.cast(b.type(expectedType.getQualifiedName()), b.move(arg0(mi)))); } else { ctx.getRefactorings().replace(toReplace, b.parenthesizeIfNeeded(b.move(arg0(mi)))); } }
private Type evaluateParameterType(AST ast, Expression elem, String key, ImportRewriteContext context) { ITypeBinding binding= Bindings.normalizeTypeBinding(elem.resolveTypeBinding()); if (binding != null && binding.isWildcardType()) { binding= ASTResolving.normalizeWildcardType(binding, true, ast); } if (binding != null) { return getImportRewrite().addImport(binding, ast, context, TypeLocation.PARAMETER); } return ast.newSimpleType(ast.newSimpleName("Object")); //$NON-NLS-1$ }
private ISourceLocation resolveFieldAccess(FieldAccess node) { ITypeBinding tb = node.getExpression().resolveTypeBinding(); if (tb != null && tb.isArray() && "length".equals(node.getName().getIdentifier())) { ISourceLocation arrayType = resolveBinding(tb); return makeBinding("java+arrayLength", arrayType.getAuthority(), arrayType.getPath()); } return resolveBinding(node.resolveFieldBinding()); }
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); }
public boolean visit(ThrowStatement node) { ITypeBinding exception= node.getExpression().resolveTypeBinding(); if (isExitPoint(exception)) { SimpleName name= fAST.newSimpleName("xxxxx"); //$NON-NLS-1$ name.setSourceRange(node.getStartPosition(), 5); fResult.add(name); } return true; }
public OperationInvocation(CompilationUnit cu, String filePath, SuperMethodInvocation invocation) { this.locationInfo = new LocationInfo(cu, filePath, invocation); this.methodName = invocation.getName().getIdentifier(); this.typeArguments = invocation.arguments().size(); this.arguments = new ArrayList<String>(); this.expression = "super"; this.subExpressions.add("super"); List<Expression> args = invocation.arguments(); for(Expression argument : args) { this.arguments.add(argument.toString()); } }
private ITypeBinding getExpressionType(MethodInvocation invocation) { Expression expression= invocation.getExpression(); ITypeBinding typeBinding= null; if (expression == null) { typeBinding= invocation.resolveMethodBinding().getDeclaringClass(); } else { typeBinding= expression.resolveTypeBinding(); } Assert.isNotNull(typeBinding, "Type binding of target expression may not be null"); //$NON-NLS-1$ return typeBinding; }
public ITypeConstraint[] create(InstanceofExpression instanceofExpression){ Expression expression= instanceofExpression.getLeftOperand(); Type type= instanceofExpression.getRightOperand(); if (isClassBinding(expression.resolveTypeBinding()) && isClassBinding(type.resolveBinding())) { ConstraintVariable expressionVar= fConstraintVariableFactory.makeExpressionOrTypeVariable(expression, getContext()); ConstraintVariable typeVariable= fConstraintVariableFactory.makeTypeVariable(type); return createOrOrSubtypeConstraint(expressionVar, typeVariable); } else return new ITypeConstraint[0]; }
@Override public String getLiteralInitializer() { Expression expression = fragment.getInitializer(); return expression != null ? expression.toString() : null; }
public String getIntroducedVariableName() { if (fElementDeclaration != null) { return fElementDeclaration.getName().getIdentifier(); } else { ForStatement forStatement= getForStatement(); IJavaProject javaProject= ((CompilationUnit)forStatement.getRoot()).getJavaElement().getJavaProject(); String[] proposals= getVariableNameProposals(fArrayAccess.resolveTypeBinding(), javaProject); return proposals[0]; } }