本文整理汇总了Java中org.eclipse.jdt.internal.corext.refactoring.util.JavadocUtil类的典型用法代码示例。如果您正苦于以下问题:Java JavadocUtil类的具体用法?Java JavadocUtil怎么用?Java JavadocUtil使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
JavadocUtil类属于org.eclipse.jdt.internal.corext.refactoring.util包,在下文中一共展示了JavadocUtil类的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: addParameterToConstructor
import org.eclipse.jdt.internal.corext.refactoring.util.JavadocUtil; //导入依赖的package包/类
private void addParameterToConstructor(final ASTRewrite rewrite, final MethodDeclaration declaration) throws JavaModelException {
Assert.isNotNull(rewrite);
Assert.isNotNull(declaration);
final AST ast= declaration.getAST();
final String name= getNameForEnclosingInstanceConstructorParameter();
final SingleVariableDeclaration variable= ast.newSingleVariableDeclaration();
variable.setType(createEnclosingType(ast));
variable.setName(ast.newSimpleName(name));
rewrite.getListRewrite(declaration, MethodDeclaration.PARAMETERS_PROPERTY).insertFirst(variable, null);
JavadocUtil.addParamJavadoc(name, declaration, rewrite, fType.getJavaProject(), null);
}
示例2: createMethodComment
import org.eclipse.jdt.internal.corext.refactoring.util.JavadocUtil; //导入依赖的package包/类
/**
* Creates the method comment for the target method declaration.
*
* @param rewrite
* the source ast rewrite
* @param declaration
* the source method declaration
* @throws JavaModelException
* if the argument references could not be generated
*/
protected void createMethodComment(final ASTRewrite rewrite, final MethodDeclaration declaration) throws JavaModelException {
Assert.isNotNull(rewrite);
Assert.isNotNull(declaration);
final Javadoc comment= declaration.getJavadoc();
if (comment != null) {
final List<TagElement> tags= new LinkedList<TagElement>(comment.tags());
final IVariableBinding[] bindings= getArgumentBindings(declaration);
final Map<String, TagElement> elements= new HashMap<String, TagElement>(bindings.length);
String name= null;
List<? extends ASTNode> fragments= null;
TagElement element= null;
TagElement reference= null;
IVariableBinding binding= null;
for (int index= 0; index < bindings.length; index++) {
binding= bindings[index];
for (final Iterator<TagElement> iterator= comment.tags().iterator(); iterator.hasNext();) {
element= iterator.next();
name= element.getTagName();
fragments= element.fragments();
if (name != null) {
if (name.equals(TagElement.TAG_PARAM) && !fragments.isEmpty() && fragments.get(0) instanceof SimpleName) {
final SimpleName simple= (SimpleName) fragments.get(0);
if (binding.getName().equals(simple.getIdentifier())) {
elements.put(binding.getKey(), element);
tags.remove(element);
}
} else if (reference == null)
reference= element;
}
}
}
if (bindings.length == 0 && reference == null) {
for (final Iterator<TagElement> iterator= comment.tags().iterator(); iterator.hasNext();) {
element= iterator.next();
name= element.getTagName();
fragments= element.fragments();
if (name != null && !name.equals(TagElement.TAG_PARAM))
reference= element;
}
}
final List<ASTNode> arguments= new ArrayList<ASTNode>(bindings.length + 1);
createArgumentList(declaration, arguments, new IArgumentFactory() {
public final ASTNode getArgumentNode(final IVariableBinding argument, final boolean last) throws JavaModelException {
Assert.isNotNull(argument);
if (elements.containsKey(argument.getKey()))
return rewrite.createCopyTarget(elements.get(argument.getKey()));
return JavadocUtil.createParamTag(argument.getName(), declaration.getAST(), fMethod.getJavaProject());
}
public final ASTNode getTargetNode() throws JavaModelException {
return JavadocUtil.createParamTag(fTargetName, declaration.getAST(), fMethod.getJavaProject());
}
});
final ListRewrite rewriter= rewrite.getListRewrite(comment, Javadoc.TAGS_PROPERTY);
ASTNode tag= null;
for (final Iterator<TagElement> iterator= comment.tags().iterator(); iterator.hasNext();) {
tag= iterator.next();
if (!tags.contains(tag))
rewriter.remove(tag, null);
}
for (final Iterator<ASTNode> iterator= arguments.iterator(); iterator.hasNext();) {
tag= iterator.next();
if (reference != null)
rewriter.insertBefore(tag, reference, null);
else
rewriter.insertLast(tag, null);
}
}
}