Java Code Examples for org.eclipse.jdt.core.dom.SuperConstructorInvocation#arguments()
The following examples show how to use
org.eclipse.jdt.core.dom.SuperConstructorInvocation#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 | 6 votes |
private SuperConstructorInv visit(SuperConstructorInvocation node) { int startLine = _cunit.getLineNumber(node.getStartPosition()); int endLine = _cunit.getLineNumber(node.getStartPosition() + node.getLength()); SuperConstructorInv superConstructorInv = new SuperConstructorInv(startLine, endLine, node); if(node.getExpression() != null){ Expr expression = (Expr) process(node.getExpression()); expression.setParent(superConstructorInv); superConstructorInv.setExpression(expression); } List<Expr> arguments = new ArrayList<>(); for(Object object : node.arguments()){ Expr arg = (Expr) process((ASTNode) object); arg.setParent(superConstructorInv); arguments.add(arg); } superConstructorInv.setArguments(arguments); return superConstructorInv; }
Example 2
Source File: OperationInvocation.java From RefactoringMiner with MIT License | 5 votes |
public OperationInvocation(CompilationUnit cu, String filePath, SuperConstructorInvocation invocation) { this.locationInfo = new LocationInfo(cu, filePath, invocation, CodeElementType.SUPER_CONSTRUCTOR_INVOCATION); this.methodName = "super"; this.typeArguments = invocation.arguments().size(); this.arguments = new ArrayList<String>(); List<Expression> args = invocation.arguments(); for(Expression argument : args) { this.arguments.add(argument.toString()); } if(invocation.getExpression() != null) { this.expression = invocation.getExpression().toString(); processExpression(invocation.getExpression(), this.subExpressions); } }
Example 3
Source File: FullConstraintCreator.java From Eclipse-Postfix-Code-Completion with Eclipse Public License 1.0 | 5 votes |
@Override public ITypeConstraint[] create(SuperConstructorInvocation invocation){ List<Expression> arguments= invocation.arguments(); List<ITypeConstraint> result= new ArrayList<ITypeConstraint>(arguments.size()); IMethodBinding methodBinding= invocation.resolveConstructorBinding(); result.addAll(Arrays.asList(getArgumentConstraints(arguments, methodBinding))); return result.toArray(new ITypeConstraint[result.size()]); }
Example 4
Source File: ConstructorFromSuperclassProposal.java From eclipse.jdt.ls with Eclipse Public License 2.0 | 4 votes |
private MethodDeclaration createNewMethodDeclaration(AST ast, IMethodBinding binding, ASTRewrite rewrite, ImportRewriteContext importRewriteContext, CodeGenerationSettings commentSettings) throws CoreException { String name= fTypeNode.getName().getIdentifier(); MethodDeclaration decl= ast.newMethodDeclaration(); decl.setConstructor(true); decl.setName(ast.newSimpleName(name)); Block body= ast.newBlock(); decl.setBody(body); SuperConstructorInvocation invocation= null; List<SingleVariableDeclaration> parameters= decl.parameters(); String[] paramNames= getArgumentNames(binding); ITypeBinding enclosingInstance= getEnclosingInstance(); if (enclosingInstance != null) { invocation= addEnclosingInstanceAccess(rewrite, importRewriteContext, parameters, paramNames, enclosingInstance); } if (binding == null) { decl.modifiers().add(ast.newModifier(Modifier.ModifierKeyword.PUBLIC_KEYWORD)); } else { decl.modifiers().addAll(ASTNodeFactory.newModifiers(ast, binding.getModifiers())); ITypeBinding[] params= binding.getParameterTypes(); for (int i= 0; i < params.length; i++) { SingleVariableDeclaration var= ast.newSingleVariableDeclaration(); var.setType(getImportRewrite().addImport(params[i], ast, importRewriteContext, TypeLocation.LOCAL_VARIABLE)); var.setName(ast.newSimpleName(paramNames[i])); parameters.add(var); } List<Type> thrownExceptions= decl.thrownExceptionTypes(); ITypeBinding[] excTypes= binding.getExceptionTypes(); for (int i= 0; i < excTypes.length; i++) { Type excType= getImportRewrite().addImport(excTypes[i], ast, importRewriteContext, TypeLocation.EXCEPTION); thrownExceptions.add(excType); } if (invocation == null) { invocation= ast.newSuperConstructorInvocation(); } List<Expression> arguments= invocation.arguments(); for (int i= 0; i < paramNames.length; i++) { Name argument= ast.newSimpleName(paramNames[i]); arguments.add(argument); addLinkedPosition(rewrite.track(argument), false, "arg_name_" + paramNames[i]); //$NON-NLS-1$ } } String bodyStatement = (invocation == null) ? "" : ASTNodes.asFormattedString(invocation, 0, String.valueOf('\n'), getCompilationUnit().getJavaProject().getOptions(true)); //$NON-NLS-1$ String placeHolder= CodeGeneration.getMethodBodyContent(getCompilationUnit(), name, name, true, bodyStatement, String.valueOf('\n')); if (placeHolder != null) { ASTNode todoNode= rewrite.createStringPlaceholder(placeHolder, ASTNode.RETURN_STATEMENT); body.statements().add(todoNode); } if (commentSettings != null) { String string= CodeGeneration.getMethodComment(getCompilationUnit(), name, decl, null, String.valueOf('\n')); if (string != null) { Javadoc javadoc= (Javadoc) rewrite.createStringPlaceholder(string, ASTNode.JAVADOC); decl.setJavadoc(javadoc); } } return decl; }
Example 5
Source File: ConstructorFromSuperclassProposal.java From Eclipse-Postfix-Code-Completion with Eclipse Public License 1.0 | 4 votes |
private MethodDeclaration createNewMethodDeclaration(AST ast, IMethodBinding binding, ASTRewrite rewrite, ImportRewriteContext importRewriteContext, CodeGenerationSettings commentSettings) throws CoreException { String name= fTypeNode.getName().getIdentifier(); MethodDeclaration decl= ast.newMethodDeclaration(); decl.setConstructor(true); decl.setName(ast.newSimpleName(name)); Block body= ast.newBlock(); decl.setBody(body); SuperConstructorInvocation invocation= null; List<SingleVariableDeclaration> parameters= decl.parameters(); String[] paramNames= getArgumentNames(binding); ITypeBinding enclosingInstance= getEnclosingInstance(); if (enclosingInstance != null) { invocation= addEnclosingInstanceAccess(rewrite, importRewriteContext, parameters, paramNames, enclosingInstance); } if (binding == null) { decl.modifiers().add(ast.newModifier(Modifier.ModifierKeyword.PUBLIC_KEYWORD)); } else { decl.modifiers().addAll(ASTNodeFactory.newModifiers(ast, binding.getModifiers())); ITypeBinding[] params= binding.getParameterTypes(); for (int i= 0; i < params.length; i++) { SingleVariableDeclaration var= ast.newSingleVariableDeclaration(); var.setType(getImportRewrite().addImport(params[i], ast, importRewriteContext)); var.setName(ast.newSimpleName(paramNames[i])); parameters.add(var); } List<Type> thrownExceptions= decl.thrownExceptionTypes(); ITypeBinding[] excTypes= binding.getExceptionTypes(); for (int i= 0; i < excTypes.length; i++) { Type excType= getImportRewrite().addImport(excTypes[i], ast, importRewriteContext); thrownExceptions.add(excType); } if (invocation == null) { invocation= ast.newSuperConstructorInvocation(); } List<Expression> arguments= invocation.arguments(); for (int i= 0; i < paramNames.length; i++) { Name argument= ast.newSimpleName(paramNames[i]); arguments.add(argument); addLinkedPosition(rewrite.track(argument), false, "arg_name_" + paramNames[i]); //$NON-NLS-1$ } } String bodyStatement= (invocation == null) ? "" : ASTNodes.asFormattedString(invocation, 0, String.valueOf('\n'), getCompilationUnit().getJavaProject().getOptions(true)); //$NON-NLS-1$ String placeHolder= CodeGeneration.getMethodBodyContent(getCompilationUnit(), name, name, true, bodyStatement, String.valueOf('\n')); if (placeHolder != null) { ASTNode todoNode= rewrite.createStringPlaceholder(placeHolder, ASTNode.RETURN_STATEMENT); body.statements().add(todoNode); } if (commentSettings != null) { String string= CodeGeneration.getMethodComment(getCompilationUnit(), name, decl, null, String.valueOf('\n')); if (string != null) { Javadoc javadoc= (Javadoc) rewrite.createStringPlaceholder(string, ASTNode.JAVADOC); decl.setJavadoc(javadoc); } } return decl; }