Java Code Examples for org.eclipse.jdt.core.dom.SingleVariableDeclaration#setVarargs()
The following examples show how to use
org.eclipse.jdt.core.dom.SingleVariableDeclaration#setVarargs() .
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: IntroduceIndirectionRefactoring.java From Eclipse-Postfix-Code-Completion with Eclipse Public License 1.0 | 6 votes |
private void copyArguments(MethodDeclaration intermediary, CompilationUnitRewrite rew) throws JavaModelException { String[] names= fTargetMethod.getParameterNames(); ITypeBinding[] types= fTargetMethodBinding.getParameterTypes(); for (int i= 0; i < names.length; i++) { ITypeBinding typeBinding= types[i]; SingleVariableDeclaration newElement= rew.getAST().newSingleVariableDeclaration(); newElement.setName(rew.getAST().newSimpleName(names[i])); if (i == (names.length - 1) && fTargetMethodBinding.isVarargs()) { newElement.setVarargs(true); if (typeBinding.isArray()) typeBinding= typeBinding.getComponentType(); } newElement.setType(rew.getImportRewrite().addImport(typeBinding, rew.getAST())); intermediary.parameters().add(newElement); } }
Example 2
Source File: ChangeSignatureProcessor.java From Eclipse-Postfix-Code-Completion with Eclipse Public License 1.0 | 5 votes |
protected SingleVariableDeclaration createNewSingleVariableDeclaration(ParameterInfo info) { SingleVariableDeclaration newP= getASTRewrite().getAST().newSingleVariableDeclaration(); newP.setName(getASTRewrite().getAST().newSimpleName(info.getNewName())); newP.setType(createNewTypeNode(ParameterInfo.stripEllipsis(info.getNewTypeName()), info.getNewTypeBinding())); newP.setVarargs(info.isNewVarargs()); return newP; }
Example 3
Source File: IntroduceFactoryRefactoring.java From Eclipse-Postfix-Code-Completion with Eclipse Public License 1.0 | 5 votes |
/** * Creates and adds the necessary argument declarations to the given factory method.<br> * An argument is needed for each original constructor argument for which the * evaluation of the actual arguments across all calls was not able to be * pushed inside the factory method (e.g. arguments with side-effects, references * to fields if the factory method is to be static or reside in a factory class, * or arguments that varied across the set of constructor calls).<br> * <code>fArgTypes</code> identifies such arguments by a <code>null</code> value. * @param ast utility object used to create AST nodes * @param newMethod the <code>MethodDeclaration</code> for the factory method */ private void createFactoryMethodSignature(AST ast, MethodDeclaration newMethod) { List<SingleVariableDeclaration> argDecls= newMethod.parameters(); for(int i=0; i < fArgTypes.length; i++) { SingleVariableDeclaration argDecl= ast.newSingleVariableDeclaration(); Type argType; if (i == (fArgTypes.length - 1) && fCtorIsVarArgs) { // The trailing varargs arg has an extra array dimension, compared to // what we need to pass to setType()... argType= typeNodeForTypeBinding(fArgTypes[i].getElementType(), fArgTypes[i].getDimensions()-1, ast); argDecl.setVarargs(true); } else argType= typeNodeForTypeBinding(fArgTypes[i], 0, ast); argDecl.setName(ast.newSimpleName(fFormalArgNames[i])); argDecl.setType(argType); argDecls.add(argDecl); } ITypeBinding[] ctorExcepts= fCtorBinding.getExceptionTypes(); List<Type> exceptions= newMethod.thrownExceptionTypes(); for(int i=0; i < ctorExcepts.length; i++) { exceptions.add(fImportRewriter.addImport(ctorExcepts[i], ast)); } copyTypeParameters(ast, newMethod); }