当前位置: 首页>>代码示例>>Java>>正文


Java TypeParameter.setName方法代码示例

本文整理汇总了Java中org.eclipse.jdt.core.dom.TypeParameter.setName方法的典型用法代码示例。如果您正苦于以下问题:Java TypeParameter.setName方法的具体用法?Java TypeParameter.setName怎么用?Java TypeParameter.setName使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在org.eclipse.jdt.core.dom.TypeParameter的用法示例。


在下文中一共展示了TypeParameter.setName方法的14个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: createTypeParameters

import org.eclipse.jdt.core.dom.TypeParameter; //导入方法依赖的package包/类
private static void createTypeParameters(
    ImportRewrite imports,
    ImportRewriteContext context,
    AST ast,
    IMethodBinding binding,
    MethodDeclaration decl) {
  ITypeBinding[] typeParams = binding.getTypeParameters();
  List<TypeParameter> typeParameters = decl.typeParameters();
  for (int i = 0; i < typeParams.length; i++) {
    ITypeBinding curr = typeParams[i];
    TypeParameter newTypeParam = ast.newTypeParameter();
    newTypeParam.setName(ast.newSimpleName(curr.getName()));
    ITypeBinding[] typeBounds = curr.getTypeBounds();
    if (typeBounds.length != 1
        || !"java.lang.Object".equals(typeBounds[0].getQualifiedName())) { // $NON-NLS-1$
      List<Type> newTypeBounds = newTypeParam.typeBounds();
      for (int k = 0; k < typeBounds.length; k++) {
        newTypeBounds.add(imports.addImport(typeBounds[k], ast, context));
      }
    }
    typeParameters.add(newTypeParam);
  }
}
 
开发者ID:eclipse,项目名称:che,代码行数:24,代码来源:StubUtility2.java

示例2: createTypeParameters

import org.eclipse.jdt.core.dom.TypeParameter; //导入方法依赖的package包/类
private static void createTypeParameters(ImportRewrite imports, ImportRewriteContext context, AST ast, IMethodBinding binding, MethodDeclaration decl) {
	ITypeBinding[] typeParams= binding.getTypeParameters();
	List<TypeParameter> typeParameters= decl.typeParameters();
	for (int i= 0; i < typeParams.length; i++) {
		ITypeBinding curr= typeParams[i];
		TypeParameter newTypeParam= ast.newTypeParameter();
		newTypeParam.setName(ast.newSimpleName(curr.getName()));
		ITypeBinding[] typeBounds= curr.getTypeBounds();
		if (typeBounds.length != 1 || !"java.lang.Object".equals(typeBounds[0].getQualifiedName())) {//$NON-NLS-1$
			List<Type> newTypeBounds= newTypeParam.typeBounds();
			for (int k= 0; k < typeBounds.length; k++) {
				newTypeBounds.add(imports.addImport(typeBounds[k], ast, context, TypeLocation.TYPE_BOUND));
			}
		}
		typeParameters.add(newTypeParam);
	}
}
 
开发者ID:eclipse,项目名称:eclipse.jdt.ls,代码行数:18,代码来源:StubUtility2.java

示例3: addTypeParameters

import org.eclipse.jdt.core.dom.TypeParameter; //导入方法依赖的package包/类
private void addTypeParameters(
    CompilationUnitRewrite imRewrite, List<TypeParameter> list, ITypeBinding parent) {

  ITypeBinding enclosing = parent.getDeclaringClass();
  if (enclosing != null) addTypeParameters(imRewrite, list, enclosing);

  ITypeBinding[] typeParameters = parent.getTypeParameters();
  for (int i = 0; i < typeParameters.length; i++) {
    TypeParameter ntp = imRewrite.getAST().newTypeParameter();
    ntp.setName(imRewrite.getAST().newSimpleName(typeParameters[i].getName()));
    ITypeBinding[] bounds = typeParameters[i].getTypeBounds();
    for (int j = 0; j < bounds.length; j++)
      if (!"java.lang.Object".equals(bounds[j].getQualifiedName())) // $NON-NLS-1$
      ntp.typeBounds().add(imRewrite.getImportRewrite().addImport(bounds[j], imRewrite.getAST()));
    list.add(ntp);
  }
}
 
开发者ID:eclipse,项目名称:che,代码行数:18,代码来源:IntroduceIndirectionRefactoring.java

示例4: copyTypeParameters

import org.eclipse.jdt.core.dom.TypeParameter; //导入方法依赖的package包/类
/**
 * Copies the constructor's parent type's type parameters, if any, as method type parameters of
 * the new static factory method. (Recall that static methods can't refer to type arguments of the
 * enclosing class, since they have no instance to serve as a context.)<br>
 * Makes sure to copy the bounds from the owning type, to ensure that the return type of the
 * factory method satisfies the bounds of the type being instantiated.<br>
 * E.g., for ctor Foo() in the type Foo<T extends Number>, be sure that the factory method is
 * declared as<br>
 * <code>static <T extends Number> Foo<T> createFoo()</code><br>
 * and not simply<br>
 * <code>static <T> Foo<T> createFoo()</code><br>
 * or the compiler will bark.
 *
 * @param ast utility object needed to create ASTNode's for the new method
 * @param newMethod the method onto which to copy the type parameters
 */
private void copyTypeParameters(AST ast, MethodDeclaration newMethod) {
  ITypeBinding[] ctorOwnerTypeParms = fCtorBinding.getDeclaringClass().getTypeParameters();
  List<TypeParameter> factoryMethodTypeParms = newMethod.typeParameters();
  for (int i = 0; i < ctorOwnerTypeParms.length; i++) {
    TypeParameter newParm = ast.newTypeParameter();
    ITypeBinding[] parmTypeBounds = ctorOwnerTypeParms[i].getTypeBounds();
    List<Type> newParmBounds = newParm.typeBounds();

    newParm.setName(ast.newSimpleName(ctorOwnerTypeParms[i].getName()));
    for (int b = 0; b < parmTypeBounds.length; b++) {
      if (parmTypeBounds[b].isClass() && parmTypeBounds[b].getSuperclass() == null) continue;

      Type newBound = fImportRewriter.addImport(parmTypeBounds[b], ast);

      newParmBounds.add(newBound);
    }
    factoryMethodTypeParms.add(newParm);
  }
}
 
开发者ID:eclipse,项目名称:che,代码行数:36,代码来源:IntroduceFactoryRefactoring.java

示例5: addEnclosingInstanceTypeParameters

import org.eclipse.jdt.core.dom.TypeParameter; //导入方法依赖的package包/类
private void addEnclosingInstanceTypeParameters(final ITypeBinding[] parameters, final AbstractTypeDeclaration declaration, final ASTRewrite rewrite) {
	Assert.isNotNull(parameters);
	Assert.isNotNull(declaration);
	Assert.isNotNull(rewrite);
	if (declaration instanceof TypeDeclaration) {
		final TypeDeclaration type= (TypeDeclaration) declaration;
		final List<TypeParameter> existing= type.typeParameters();
		final Set<String> names= new HashSet<String>();
		TypeParameter parameter= null;
		for (final Iterator<TypeParameter> iterator= existing.iterator(); iterator.hasNext();) {
			parameter= iterator.next();
			names.add(parameter.getName().getIdentifier());
		}
		final ListRewrite rewriter= rewrite.getListRewrite(type, TypeDeclaration.TYPE_PARAMETERS_PROPERTY);
		String name= null;
		for (int index= 0; index < parameters.length; index++) {
			name= parameters[index].getName();
			if (!names.contains(name)) {
				parameter= type.getAST().newTypeParameter();
				parameter.setName(type.getAST().newSimpleName(name));
				rewriter.insertLast(parameter, null);
			}
		}
	}
}
 
开发者ID:trylimits,项目名称:Eclipse-Postfix-Code-Completion,代码行数:26,代码来源:MoveInnerToTopRefactoring.java

示例6: addTypeParameters

import org.eclipse.jdt.core.dom.TypeParameter; //导入方法依赖的package包/类
private void addTypeParameters(CompilationUnitRewrite imRewrite, List<TypeParameter> list, ITypeBinding parent) {

		ITypeBinding enclosing= parent.getDeclaringClass();
		if (enclosing != null)
			addTypeParameters(imRewrite, list, enclosing);

		ITypeBinding[] typeParameters= parent.getTypeParameters();
		for (int i= 0; i < typeParameters.length; i++) {
			TypeParameter ntp= imRewrite.getAST().newTypeParameter();
			ntp.setName(imRewrite.getAST().newSimpleName(typeParameters[i].getName()));
			ITypeBinding[] bounds= typeParameters[i].getTypeBounds();
			for (int j= 0; j < bounds.length; j++)
				if (!"java.lang.Object".equals(bounds[j].getQualifiedName())) //$NON-NLS-1$
					ntp.typeBounds().add(imRewrite.getImportRewrite().addImport(bounds[j], imRewrite.getAST()));
			list.add(ntp);
		}
	}
 
开发者ID:trylimits,项目名称:Eclipse-Postfix-Code-Completion,代码行数:18,代码来源:IntroduceIndirectionRefactoring.java

示例7: copyTypeParameters

import org.eclipse.jdt.core.dom.TypeParameter; //导入方法依赖的package包/类
/**
 * Copies the constructor's parent type's type parameters, if any, as
 * method type parameters of the new static factory method. (Recall
 * that static methods can't refer to type arguments of the enclosing
 * class, since they have no instance to serve as a context.)<br>
 * Makes sure to copy the bounds from the owning type, to ensure that the
 * return type of the factory method satisfies the bounds of the type
 * being instantiated.<br>
 * E.g., for ctor Foo() in the type Foo<T extends Number>, be sure that
 * the factory method is declared as<br>
 * <code>static <T extends Number> Foo<T> createFoo()</code><br>
 * and not simply<br>
 * <code>static <T> Foo<T> createFoo()</code><br>
 * or the compiler will bark.
 * @param ast utility object needed to create ASTNode's for the new method
 * @param newMethod the method onto which to copy the type parameters
 */
private void copyTypeParameters(AST ast, MethodDeclaration newMethod) {
	ITypeBinding[] ctorOwnerTypeParms= fCtorBinding.getDeclaringClass().getTypeParameters();
	List<TypeParameter> factoryMethodTypeParms= newMethod.typeParameters();
	for(int i= 0; i < ctorOwnerTypeParms.length; i++) {
           TypeParameter newParm= ast.newTypeParameter();
           ITypeBinding[] parmTypeBounds= ctorOwnerTypeParms[i].getTypeBounds();
           List<Type> newParmBounds= newParm.typeBounds();

           newParm.setName(ast.newSimpleName(ctorOwnerTypeParms[i].getName()));
           for(int b=0; b < parmTypeBounds.length; b++) {
           	if (parmTypeBounds[b].isClass() && parmTypeBounds[b].getSuperclass() == null)
           		continue;

           	Type newBound= fImportRewriter.addImport(parmTypeBounds[b], ast);

               newParmBounds.add(newBound);
           }
		factoryMethodTypeParms.add(newParm);
	}
}
 
开发者ID:trylimits,项目名称:Eclipse-Postfix-Code-Completion,代码行数:38,代码来源:IntroduceFactoryRefactoring.java

示例8: createTypeParameters

import org.eclipse.jdt.core.dom.TypeParameter; //导入方法依赖的package包/类
private static void createTypeParameters(ImportRewrite imports, ImportRewriteContext context, AST ast, IMethodBinding binding, MethodDeclaration decl) {
	ITypeBinding[] typeParams= binding.getTypeParameters();
	List<TypeParameter> typeParameters= decl.typeParameters();
	for (int i= 0; i < typeParams.length; i++) {
		ITypeBinding curr= typeParams[i];
		TypeParameter newTypeParam= ast.newTypeParameter();
		newTypeParam.setName(ast.newSimpleName(curr.getName()));
		ITypeBinding[] typeBounds= curr.getTypeBounds();
		if (typeBounds.length != 1 || !"java.lang.Object".equals(typeBounds[0].getQualifiedName())) {//$NON-NLS-1$
			List<Type> newTypeBounds= newTypeParam.typeBounds();
			for (int k= 0; k < typeBounds.length; k++) {
				newTypeBounds.add(imports.addImport(typeBounds[k], ast, context));
			}
		}
		typeParameters.add(newTypeParam);
	}
}
 
开发者ID:trylimits,项目名称:Eclipse-Postfix-Code-Completion,代码行数:18,代码来源:StubUtility2.java

示例9: copyTypeParameters

import org.eclipse.jdt.core.dom.TypeParameter; //导入方法依赖的package包/类
private void copyTypeParameters(MethodDeclaration intermediary, CompilationUnitRewrite rew) {
  ITypeBinding[] typeParameters = fTargetMethodBinding.getTypeParameters();
  for (int i = 0; i < typeParameters.length; i++) {
    ITypeBinding current = typeParameters[i];

    TypeParameter parameter = rew.getAST().newTypeParameter();
    parameter.setName(rew.getAST().newSimpleName(current.getName()));
    ITypeBinding[] bounds = current.getTypeBounds();
    for (int j = 0; j < bounds.length; j++)
      if (!"java.lang.Object".equals(bounds[j].getQualifiedName())) // $NON-NLS-1$
      parameter.typeBounds().add(rew.getImportRewrite().addImport(bounds[j], rew.getAST()));

    intermediary.typeParameters().add(parameter);
  }
}
 
开发者ID:eclipse,项目名称:che,代码行数:16,代码来源:IntroduceIndirectionRefactoring.java

示例10: updateConstructorReference

import org.eclipse.jdt.core.dom.TypeParameter; //导入方法依赖的package包/类
private void updateConstructorReference(ITypeBinding[] parameters, ParameterizedType type, CompilationUnitRewrite targetRewrite, ICompilationUnit cu, TextEditGroup group) throws CoreException {
	final ListRewrite rewrite= targetRewrite.getASTRewrite().getListRewrite(type, ParameterizedType.TYPE_ARGUMENTS_PROPERTY);
	TypeParameter parameter= null;
	for (int index= type.typeArguments().size(); index < parameters.length; index++) {
		parameter= targetRewrite.getRoot().getAST().newTypeParameter();
		parameter.setName(targetRewrite.getRoot().getAST().newSimpleName(parameters[index].getName()));
		rewrite.insertLast(parameter, group);
	}
	if (type.getParent() instanceof ClassInstanceCreation)
		updateConstructorReference((ClassInstanceCreation) type.getParent(), targetRewrite, cu, group);
}
 
开发者ID:trylimits,项目名称:Eclipse-Postfix-Code-Completion,代码行数:12,代码来源:MoveInnerToTopRefactoring.java

示例11: copyTypeParameters

import org.eclipse.jdt.core.dom.TypeParameter; //导入方法依赖的package包/类
private void copyTypeParameters(MethodDeclaration intermediary, CompilationUnitRewrite rew) {
	ITypeBinding[] typeParameters= fTargetMethodBinding.getTypeParameters();
	for (int i= 0; i < typeParameters.length; i++) {
		ITypeBinding current= typeParameters[i];

		TypeParameter parameter= rew.getAST().newTypeParameter();
		parameter.setName(rew.getAST().newSimpleName(current.getName()));
		ITypeBinding[] bounds= current.getTypeBounds();
		for (int j= 0; j < bounds.length; j++)
			if (!"java.lang.Object".equals(bounds[j].getQualifiedName())) //$NON-NLS-1$
				parameter.typeBounds().add(rew.getImportRewrite().addImport(bounds[j], rew.getAST()));

		intermediary.typeParameters().add(parameter);
	}
}
 
开发者ID:trylimits,项目名称:Eclipse-Postfix-Code-Completion,代码行数:16,代码来源:IntroduceIndirectionRefactoring.java

示例12: createNewNestedClass

import org.eclipse.jdt.core.dom.TypeParameter; //导入方法依赖的package包/类
private AbstractTypeDeclaration createNewNestedClass(
    CompilationUnitRewrite rewrite, ITypeBinding[] typeParameters) throws CoreException {
  final AST ast = fAnonymousInnerClassNode.getAST();

  final TypeDeclaration newDeclaration = ast.newTypeDeclaration();
  newDeclaration.setInterface(false);
  newDeclaration.setJavadoc(null);
  newDeclaration
      .modifiers()
      .addAll(ASTNodeFactory.newModifiers(ast, createModifiersForNestedClass()));
  newDeclaration.setName(ast.newSimpleName(fClassName));

  TypeParameter parameter = null;
  for (int index = 0; index < typeParameters.length; index++) {
    parameter = ast.newTypeParameter();
    parameter.setName(ast.newSimpleName(typeParameters[index].getName()));
    newDeclaration.typeParameters().add(parameter);
  }
  setSuperType(newDeclaration);

  IJavaProject project = fCu.getJavaProject();

  IVariableBinding[] bindings = getUsedLocalVariables();
  ArrayList<String> fieldNames = new ArrayList<String>();
  for (int i = 0; i < bindings.length; i++) {
    String name = StubUtility.getBaseName(bindings[i], project);
    String[] fieldNameProposals =
        StubUtility.getVariableNameSuggestions(
            NamingConventions.VK_INSTANCE_FIELD, project, name, 0, fieldNames, true);
    fieldNames.add(fieldNameProposals[0]);

    if (fLinkedProposalModel != null) {
      LinkedProposalPositionGroup positionGroup =
          fLinkedProposalModel.getPositionGroup(KEY_FIELD_NAME_EXT + i, true);
      for (int k = 0; k < fieldNameProposals.length; k++) {
        positionGroup.addProposal(fieldNameProposals[k], null, fieldNameProposals.length - k);
      }
    }
  }
  String[] allFieldNames = fieldNames.toArray(new String[fieldNames.size()]);

  List<BodyDeclaration> newBodyDeclarations = newDeclaration.bodyDeclarations();

  createFieldsForAccessedLocals(rewrite, bindings, allFieldNames, newBodyDeclarations);

  MethodDeclaration newConstructorDecl = createNewConstructor(rewrite, bindings, allFieldNames);
  if (newConstructorDecl != null) {
    newBodyDeclarations.add(newConstructorDecl);
  }

  updateAndMoveBodyDeclarations(
      rewrite, bindings, allFieldNames, newBodyDeclarations, newConstructorDecl);

  if (doAddComments()) {
    String[] parameterNames = new String[typeParameters.length];
    for (int index = 0; index < parameterNames.length; index++) {
      parameterNames[index] = typeParameters[index].getName();
    }
    String string =
        CodeGeneration.getTypeComment(
            rewrite.getCu(), fClassName, parameterNames, StubUtility.getLineDelimiterUsed(fCu));
    if (string != null) {
      Javadoc javadoc =
          (Javadoc) rewrite.getASTRewrite().createStringPlaceholder(string, ASTNode.JAVADOC);
      newDeclaration.setJavadoc(javadoc);
    }
  }
  if (fLinkedProposalModel != null) {
    addLinkedPosition(KEY_TYPE_NAME, newDeclaration.getName(), rewrite.getASTRewrite(), false);
    ModifierCorrectionSubProcessor.installLinkedVisibilityProposals(
        fLinkedProposalModel, rewrite.getASTRewrite(), newDeclaration.modifiers(), false);
  }

  return newDeclaration;
}
 
开发者ID:eclipse,项目名称:che,代码行数:76,代码来源:ConvertAnonymousToNestedRefactoring.java

示例13: createNewNestedClass

import org.eclipse.jdt.core.dom.TypeParameter; //导入方法依赖的package包/类
private AbstractTypeDeclaration createNewNestedClass(CompilationUnitRewrite rewrite, ITypeBinding[] typeParameters) throws CoreException {
	final AST ast= fAnonymousInnerClassNode.getAST();

	final TypeDeclaration newDeclaration= ast.newTypeDeclaration();
	newDeclaration.setInterface(false);
	newDeclaration.setJavadoc(null);
	newDeclaration.modifiers().addAll(ASTNodeFactory.newModifiers(ast, createModifiersForNestedClass()));
	newDeclaration.setName(ast.newSimpleName(fClassName));

	TypeParameter parameter= null;
	for (int index= 0; index < typeParameters.length; index++) {
		parameter= ast.newTypeParameter();
		parameter.setName(ast.newSimpleName(typeParameters[index].getName()));
		newDeclaration.typeParameters().add(parameter);
	}
	setSuperType(newDeclaration);

	IJavaProject project= fCu.getJavaProject();

	IVariableBinding[] bindings= getUsedLocalVariables();
	ArrayList<String> fieldNames= new ArrayList<String>();
	for (int i= 0; i < bindings.length; i++) {
		String name= StubUtility.getBaseName(bindings[i], project);
		String[] fieldNameProposals= StubUtility.getVariableNameSuggestions(NamingConventions.VK_INSTANCE_FIELD, project, name, 0, fieldNames, true);
		fieldNames.add(fieldNameProposals[0]);


		if (fLinkedProposalModel != null) {
			LinkedProposalPositionGroup positionGroup= fLinkedProposalModel.getPositionGroup(KEY_FIELD_NAME_EXT + i, true);
			for (int k= 0; k < fieldNameProposals.length; k++) {
				positionGroup.addProposal(fieldNameProposals[k], null, fieldNameProposals.length - k);
			}
		}
	}
	String[] allFieldNames= fieldNames.toArray(new String[fieldNames.size()]);

	List<BodyDeclaration> newBodyDeclarations= newDeclaration.bodyDeclarations();

	createFieldsForAccessedLocals(rewrite, bindings, allFieldNames, newBodyDeclarations);

	MethodDeclaration newConstructorDecl= createNewConstructor(rewrite, bindings, allFieldNames);
	if (newConstructorDecl != null) {
		newBodyDeclarations.add(newConstructorDecl);
	}

	updateAndMoveBodyDeclarations(rewrite, bindings, allFieldNames, newBodyDeclarations, newConstructorDecl);

	if (doAddComments()) {
		String[] parameterNames= new String[typeParameters.length];
		for (int index= 0; index < parameterNames.length; index++) {
			parameterNames[index]= typeParameters[index].getName();
		}
		String string= CodeGeneration.getTypeComment(rewrite.getCu(), fClassName, parameterNames, StubUtility.getLineDelimiterUsed(fCu));
		if (string != null) {
			Javadoc javadoc= (Javadoc) rewrite.getASTRewrite().createStringPlaceholder(string, ASTNode.JAVADOC);
			newDeclaration.setJavadoc(javadoc);
		}
	}
	if (fLinkedProposalModel != null) {
		addLinkedPosition(KEY_TYPE_NAME, newDeclaration.getName(), rewrite.getASTRewrite(), false);
		ModifierCorrectionSubProcessor.installLinkedVisibilityProposals(fLinkedProposalModel, rewrite.getASTRewrite(), newDeclaration.modifiers(), false);
	}

	return newDeclaration;
}
 
开发者ID:trylimits,项目名称:Eclipse-Postfix-Code-Completion,代码行数:66,代码来源:ConvertAnonymousToNestedRefactoring.java

示例14: createConstructorStub

import org.eclipse.jdt.core.dom.TypeParameter; //导入方法依赖的package包/类
public static MethodDeclaration createConstructorStub(ICompilationUnit unit, ASTRewrite rewrite, ImportRewrite imports, ImportRewriteContext context, IMethodBinding binding, String type, int modifiers, boolean omitSuperForDefConst, boolean todo, CodeGenerationSettings settings) throws CoreException {
	AST ast= rewrite.getAST();
	MethodDeclaration decl= ast.newMethodDeclaration();
	decl.modifiers().addAll(ASTNodeFactory.newModifiers(ast, modifiers & ~Modifier.ABSTRACT & ~Modifier.NATIVE));
	decl.setName(ast.newSimpleName(type));
	decl.setConstructor(true);

	ITypeBinding[] typeParams= binding.getTypeParameters();
	List<TypeParameter> typeParameters= decl.typeParameters();
	for (int i= 0; i < typeParams.length; i++) {
		ITypeBinding curr= typeParams[i];
		TypeParameter newTypeParam= ast.newTypeParameter();
		newTypeParam.setName(ast.newSimpleName(curr.getName()));
		ITypeBinding[] typeBounds= curr.getTypeBounds();
		if (typeBounds.length != 1 || !"java.lang.Object".equals(typeBounds[0].getQualifiedName())) {//$NON-NLS-1$
			List<Type> newTypeBounds= newTypeParam.typeBounds();
			for (int k= 0; k < typeBounds.length; k++) {
				newTypeBounds.add(imports.addImport(typeBounds[k], ast, context));
			}
		}
		typeParameters.add(newTypeParam);
	}

	List<SingleVariableDeclaration> parameters= createParameters(unit.getJavaProject(), imports, context, ast, binding, decl);

	List<Name> thrownExceptions= decl.thrownExceptions();
	ITypeBinding[] excTypes= binding.getExceptionTypes();
	for (int i= 0; i < excTypes.length; i++) {
		String excTypeName= imports.addImport(excTypes[i], context);
		thrownExceptions.add(ASTNodeFactory.newName(ast, excTypeName));
	}

	Block body= ast.newBlock();
	decl.setBody(body);

	String delimiter= StubUtility.getLineDelimiterUsed(unit);
	String bodyStatement= ""; //$NON-NLS-1$
	if (!omitSuperForDefConst || !parameters.isEmpty()) {
		SuperConstructorInvocation invocation= ast.newSuperConstructorInvocation();
		SingleVariableDeclaration varDecl= null;
		for (Iterator<SingleVariableDeclaration> iterator= parameters.iterator(); iterator.hasNext();) {
			varDecl= iterator.next();
			invocation.arguments().add(ast.newSimpleName(varDecl.getName().getIdentifier()));
		}
		bodyStatement= ASTNodes.asFormattedString(invocation, 0, delimiter, unit.getJavaProject().getOptions(true));
	}

	if (todo) {
		String placeHolder= CodeGeneration.getMethodBodyContent(unit, type, binding.getName(), true, bodyStatement, delimiter);
		if (placeHolder != null) {
			ReturnStatement todoNode= (ReturnStatement) rewrite.createStringPlaceholder(placeHolder, ASTNode.RETURN_STATEMENT);
			body.statements().add(todoNode);
		}
	} else {
		ReturnStatement statementNode= (ReturnStatement) rewrite.createStringPlaceholder(bodyStatement, ASTNode.RETURN_STATEMENT);
		body.statements().add(statementNode);
	}

	if (settings != null && settings.createComments) {
		String string= CodeGeneration.getMethodComment(unit, type, decl, binding, delimiter);
		if (string != null) {
			Javadoc javadoc= (Javadoc) rewrite.createStringPlaceholder(string, ASTNode.JAVADOC);
			decl.setJavadoc(javadoc);
		}
	}
	return decl;
}
 
开发者ID:trylimits,项目名称:Eclipse-Postfix-Code-Completion-Juno38,代码行数:68,代码来源:StubUtility2.java


注:本文中的org.eclipse.jdt.core.dom.TypeParameter.setName方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。