Java Code Examples for org.eclipse.jdt.core.dom.SuperMethodInvocation#arguments()

The following examples show how to use org.eclipse.jdt.core.dom.SuperMethodInvocation#arguments() . 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: CodeBlock.java    From SimFix with GNU General Public License v2.0 5 votes vote down vote up
private SuperMethodInv visit(SuperMethodInvocation node) {
	int startLine = _cunit.getLineNumber(node.getStartPosition());
	int endLine = _cunit.getLineNumber(node.getStartPosition() + node.getLength());
	SuperMethodInv superMethodInv = new SuperMethodInv(startLine, endLine, node);
	
	superMethodInv.setName(node.getName().getFullyQualifiedName());
	
	if(node.getQualifier() != null){
		Label label = (Label) process(node.getQualifier());
		label.setParent(superMethodInv);
		superMethodInv.setLabel(label);
	}
	
	List<Expr> arguments = new ArrayList<>();
	for(Object object : node.arguments()){
		Expr expr = (Expr) process((ASTNode) object);
		expr.setParent(superMethodInv);
		arguments.add(expr);
	}
	superMethodInv.setArguments(arguments);
	
	Pair<String, String> pair = NodeUtils.getTypeDecAndMethodDec(node);
	Type type = ProjectInfo.getMethodRetType(pair.getFirst(), pair.getSecond());
	superMethodInv.setType(type);
	
	return superMethodInv;
}
 
Example 2
Source File: OperationInvocation.java    From RefactoringMiner with MIT License 5 votes vote down vote up
public OperationInvocation(CompilationUnit cu, String filePath, SuperMethodInvocation invocation) {
	this.locationInfo = new LocationInfo(cu, filePath, invocation, CodeElementType.SUPER_METHOD_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());
	}
}
 
Example 3
Source File: PullUpRefactoringProcessor.java    From Eclipse-Postfix-Code-Completion with Eclipse Public License 1.0 5 votes vote down vote up
@Override
public final boolean visit(final SuperMethodInvocation node) {
	if (!fAnonymousClassDeclaration && !fTypeDeclarationStatement) {
		final IBinding superBinding= node.getName().resolveBinding();
		if (superBinding instanceof IMethodBinding) {
			final IMethodBinding extended= (IMethodBinding) superBinding;
			if (fEnclosingMethod != null && fEnclosingMethod.overrides(extended))
				return true;
			final ITypeBinding declaringBinding= extended.getDeclaringClass();
			if (declaringBinding != null) {
				final IType type= (IType) declaringBinding.getJavaElement();
				if (!fSuperReferenceType.equals(type))
					return true;
			}
		}
		final AST ast= node.getAST();
		final ThisExpression expression= ast.newThisExpression();
		final MethodInvocation invocation= ast.newMethodInvocation();
		final SimpleName simple= ast.newSimpleName(node.getName().getIdentifier());
		invocation.setName(simple);
		invocation.setExpression(expression);
		final List<Expression> arguments= node.arguments();
		if (arguments != null && arguments.size() > 0) {
			final ListRewrite rewriter= fRewrite.getListRewrite(invocation, MethodInvocation.ARGUMENTS_PROPERTY);
			ListRewrite superRewriter= fRewrite.getListRewrite(node, SuperMethodInvocation.ARGUMENTS_PROPERTY);
			ASTNode copyTarget= superRewriter.createCopyTarget(arguments.get(0), arguments.get(arguments.size() - 1));
			rewriter.insertLast(copyTarget, null);
		}
		fRewrite.replace(node, invocation, null);
		if (!fSourceRewriter.getCu().equals(fTargetRewriter.getCu()))
			fSourceRewriter.getImportRemover().registerRemovedNode(node);
		return true;
	}
	return false;
}
 
Example 4
Source File: FullConstraintCreator.java    From Eclipse-Postfix-Code-Completion with Eclipse Public License 1.0 5 votes vote down vote up
@Override
public ITypeConstraint[] create(SuperMethodInvocation invocation){
	List<Expression> arguments= invocation.arguments();
	List<ITypeConstraint> result= new ArrayList<ITypeConstraint>(arguments.size());
	IMethodBinding methodBinding= invocation.resolveMethodBinding();
	ITypeConstraint[] returnTypeConstraint= getReturnTypeConstraint(invocation, methodBinding);
	result.addAll(Arrays.asList(returnTypeConstraint));
	result.addAll(Arrays.asList(getArgumentConstraints(arguments, methodBinding)));
	return result.toArray(new ITypeConstraint[result.size()]);
}