本文整理了Java中org.eclipse.jdt.core.dom.AST.newTypeParameter()
方法的一些代码示例,展示了AST.newTypeParameter()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。AST.newTypeParameter()
方法的具体详情如下:
包路径:org.eclipse.jdt.core.dom.AST
类名称:AST
方法名:newTypeParameter
[英]Creates and returns a new unparented type parameter type node with an unspecified type variable name and an empty list of type bounds.
[中]创建并返回一个新的未命名类型参数类型节点,该节点具有未指定的类型变量名和类型边界的空列表。
代码示例来源:origin: stackoverflow.com
TypeParameter tp = ast.newTypeParameter();
tp.setName(ast.newSimpleName("X"));
td.typeParameters().add(tp);
代码示例来源:origin: forge/roaster
@SuppressWarnings("unchecked")
@Override
public TypeVariableSource
{
TypeParameter tp2 = method.getAST().newTypeParameter();
method.typeParameters().add(tp2);
return new TypeVariableImpl
}
代码示例来源:origin: forge/roaster
@Override
public TypeVariableSource
{
TypeDeclaration type = (TypeDeclaration) body;
TypeParameter tp2 = unit.getAST().newTypeParameter();
type.typeParameters().add(tp2);
return new TypeVariableImpl
}
代码示例来源:origin: org.jboss.forge/roaster-jdt
@Override
public TypeVariableSource
{
TypeDeclaration type = (TypeDeclaration) body;
TypeParameter tp2 = unit.getAST().newTypeParameter();
type.typeParameters().add(tp2);
return new TypeVariableImpl
}
代码示例来源:origin: org.jboss.forge/roaster-jdt
@SuppressWarnings("unchecked")
@Override
public TypeVariableSource
{
TypeParameter tp2 = method.getAST().newTypeParameter();
method.typeParameters().add(tp2);
return new TypeVariableImpl
}
代码示例来源:origin: org.eclipse.jdt/org.eclipse.jdt.ui
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
final Set
TypeParameter parameter= null;
for (final Iterator
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
if (!names.contains(name)) {
parameter= type.getAST().newTypeParameter();
parameter.setName(type.getAST().newSimpleName(name));
rewriter.insertLast(parameter, null);
}
}
}
}
代码示例来源:origin: org.eclipse/org.eclipse.jdt.ui
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 existing= type.typeParameters();
final Set names= new HashSet();
TypeParameter parameter= null;
for (final Iterator iterator= existing.iterator(); iterator.hasNext();) {
parameter= (TypeParameter) 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
if (!names.contains(name)) {
parameter= type.getAST().newTypeParameter();
parameter.setName(type.getAST().newSimpleName(name));
rewriter.insertLast(parameter, null);
}
}
}
}
代码示例来源:origin: org.eclipse.scout.sdk.deps/org.eclipse.jdt.ui
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
final Set
TypeParameter parameter= null;
for (final Iterator
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
if (!names.contains(name)) {
parameter= type.getAST().newTypeParameter();
parameter.setName(type.getAST().newSimpleName(name));
rewriter.insertLast(parameter, null);
}
}
}
}
代码示例来源:origin: org.eclipse.jdt/org.eclipse.jdt.core.manipulation
public static void createTypeParameters(ImportRewrite imports, ImportRewriteContext context, AST ast, IMethodBinding binding, MethodDeclaration decl) {
ITypeBinding[] typeParams= binding.getTypeParameters();
List
for (int i= 0; 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
for (int k= 0; k
}
}
typeParameters.add(newTypeParam);
}
}
代码示例来源:origin: org.eclipse.scout.sdk.deps/org.eclipse.jdt.ui
private static void createTypeParameters(ImportRewrite imports, ImportRewriteContext context, AST ast, IMethodBinding binding, MethodDeclaration decl) {
ITypeBinding[] typeParams= binding.getTypeParameters();
List
for (int i= 0; 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
for (int k= 0; k
}
}
typeParameters.add(newTypeParam);
}
}
代码示例来源:origin: org.eclipse.scout.sdk.deps/org.eclipse.jdt.ui
private void copyTypeParameters(MethodDeclaration intermediary, CompilationUnitRewrite rew, ImportRewriteContext context) {
ITypeBinding[] typeParameters= fTargetMethodBinding.getTypeParameters();
for (int i= 0; i
TypeParameter parameter= rew.getAST().newTypeParameter();
parameter.setName(rew.getAST().newSimpleName(current.getName()));
ITypeBinding[] bounds= current.getTypeBounds();
for (int j= 0; j
parameter.typeBounds().add(rew.getImportRewrite().addImport(bounds[j], rew.getAST(), context));
intermediary.typeParameters().add(parameter);
}
}
代码示例来源:origin: org.eclipse/org.eclipse.jdt.ui
private void copyTypeParameters(MethodDeclaration intermediary, CompilationUnitRewrite rew) {
ITypeBinding[] typeParameters= fTargetMethodBinding.getTypeParameters();
for (int i= 0; i
TypeParameter parameter= rew.getAST().newTypeParameter();
parameter.setName(rew.getAST().newSimpleName(current.getName()));
ITypeBinding[] bounds= current.getTypeBounds();
for (int j= 0; j
parameter.typeBounds().add(rew.getImportRewrite().addImport(bounds[j], rew.getAST()));
intermediary.typeParameters().add(parameter);
}
}
代码示例来源:origin: org.eclipse.jdt/org.eclipse.jdt.ui
private void copyTypeParameters(MethodDeclaration intermediary, CompilationUnitRewrite rew, ImportRewriteContext context) {
ITypeBinding[] typeParameters= fTargetMethodBinding.getTypeParameters();
for (int i= 0; i
TypeParameter parameter= rew.getAST().newTypeParameter();
parameter.setName(rew.getAST().newSimpleName(current.getName()));
ITypeBinding[] bounds= current.getTypeBounds();
for (int j= 0; j
parameter.typeBounds().add(rew.getImportRewrite().addImport(bounds[j], rew.getAST(), context, TypeLocation.TYPE_BOUND));
intermediary.typeParameters().add(parameter);
}
}
代码示例来源:origin: org.eclipse/org.eclipse.jdt.ui
private void addTypeParameters(CompilationUnitRewrite imRewrite, List newTypeParameters, ITypeBinding parent) {
ITypeBinding enclosing= parent.getDeclaringClass();
if (enclosing != null)
addTypeParameters(imRewrite, newTypeParameters, enclosing);
ITypeBinding[] typeParameters= parent.getTypeParameters();
for (int i= 0; i
ntp.setName(imRewrite.getAST().newSimpleName(typeParameters[i].getName()));
ITypeBinding[] bounds= typeParameters[i].getTypeBounds();
for (int j= 0; j
ntp.typeBounds().add(imRewrite.getImportRewrite().addImport(bounds[j], imRewrite.getAST()));
newTypeParameters.add(ntp);
}
}
代码示例来源:origin: org.eclipse.scout.sdk.deps/org.eclipse.jdt.ui
private void addTypeParameters(CompilationUnitRewrite imRewrite, List
ITypeBinding enclosing= parent.getDeclaringClass();
if (enclosing != null)
addTypeParameters(imRewrite, list, enclosing, context);
ITypeBinding[] typeParameters= parent.getTypeParameters();
for (int i= 0; i
ntp.setName(imRewrite.getAST().newSimpleName(typeParameters[i].getName()));
ITypeBinding[] bounds= typeParameters[i].getTypeBounds();
for (int j= 0; j
ntp.typeBounds().add(imRewrite.getImportRewrite().addImport(bounds[j], imRewrite.getAST(), context));
list.add(ntp);
}
}
代码示例来源:origin: org.eclipse.jdt/org.eclipse.jdt.ui
private void addTypeParameters(CompilationUnitRewrite imRewrite, List
ITypeBinding enclosing= parent.getDeclaringClass();
if (enclosing != null)
addTypeParameters(imRewrite, list, enclosing, context);
ITypeBinding[] typeParameters= parent.getTypeParameters();
for (int i= 0; i
ntp.setName(imRewrite.getAST().newSimpleName(typeParameters[i].getName()));
ITypeBinding[] bounds= typeParameters[i].getTypeBounds();
for (int j= 0; j
ntp.typeBounds().add(imRewrite.getImportRewrite().addImport(bounds[j], imRewrite.getAST(), context, TypeLocation.TYPE_BOUND));
list.add(ntp);
}
}
代码示例来源:origin: org.eclipse.jdt/org.eclipse.jdt.ui
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
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);
}
代码示例来源:origin: org.eclipse/org.eclipse.jdt.ui
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
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);
}
代码示例来源:origin: org.eclipse.scout.sdk.deps/org.eclipse.jdt.ui
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
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);
}
代码示例来源:origin: forge/roaster
@SuppressWarnings("rawtypes")
@Override
public O setName(final String name)
{
AbstractTypeDeclaration typeDeclaration = getDeclaration();
TypeImpl
typeDeclaration.setName(unit.getAST().newSimpleName(type.getName()));
if (typeDeclaration instanceof TypeDeclaration)
{
TypeDeclaration td = (TypeDeclaration) typeDeclaration;
for (Type> arg : type.getTypeArguments())
{
TypeParameter typeParameter = unit.getAST().newTypeParameter();
typeParameter.setName(unit.getAST().newSimpleName(arg.getName()));
td.typeParameters().add(typeParameter);
}
}
return updateTypeNames(name);
}