本文整理汇总了Java中org.eclipse.jdt.core.dom.TextElement.setText方法的典型用法代码示例。如果您正苦于以下问题:Java TextElement.setText方法的具体用法?Java TextElement.setText怎么用?Java TextElement.setText使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.eclipse.jdt.core.dom.TextElement
的用法示例。
在下文中一共展示了TextElement.setText方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: insertAllMissingTypeTags
import org.eclipse.jdt.core.dom.TextElement; //导入方法依赖的package包/类
private void insertAllMissingTypeTags(ASTRewrite rewriter, TypeDeclaration typeDecl) {
AST ast= typeDecl.getAST();
Javadoc javadoc= typeDecl.getJavadoc();
ListRewrite tagsRewriter= rewriter.getListRewrite(javadoc, Javadoc.TAGS_PROPERTY);
List<TypeParameter> typeParams= typeDecl.typeParameters();
for (int i= typeParams.size() - 1; i >= 0; i--) {
TypeParameter decl= typeParams.get(i);
String name= '<' + decl.getName().getIdentifier() + '>';
if (findTag(javadoc, TagElement.TAG_PARAM, name) == null) {
TagElement newTag= ast.newTagElement();
newTag.setTagName(TagElement.TAG_PARAM);
TextElement text= ast.newTextElement();
text.setText(name);
newTag.fragments().add(text);
insertTabStop(rewriter, newTag.fragments(), "typeParam" + i); //$NON-NLS-1$
insertTag(tagsRewriter, newTag, getPreviousTypeParamNames(typeParams, decl));
}
}
}
示例2: getDelegateJavadocTag
import org.eclipse.jdt.core.dom.TextElement; //导入方法依赖的package包/类
private TagElement getDelegateJavadocTag(BodyDeclaration declaration) throws JavaModelException {
Assert.isNotNull(declaration);
String msg = RefactoringCoreMessages.DelegateCreator_use_member_instead;
int firstParam = msg.indexOf("{0}"); // $NON-NLS-1$
Assert.isTrue(firstParam != -1);
List<ASTNode> fragments = new ArrayList<ASTNode>();
TextElement text = getAst().newTextElement();
text.setText(msg.substring(0, firstParam).trim());
fragments.add(text);
fragments.add(createJavadocMemberReferenceTag(declaration, getAst()));
text = getAst().newTextElement();
text.setText(msg.substring(firstParam + 3).trim());
fragments.add(text);
final TagElement tag = getAst().newTagElement();
tag.setTagName(TagElement.TAG_DEPRECATED);
tag.fragments().addAll(fragments);
return tag;
}
示例3: insertAllMissingTypeTags
import org.eclipse.jdt.core.dom.TextElement; //导入方法依赖的package包/类
private void insertAllMissingTypeTags(ASTRewrite rewriter, TypeDeclaration typeDecl) {
AST ast = typeDecl.getAST();
Javadoc javadoc = typeDecl.getJavadoc();
ListRewrite tagsRewriter = rewriter.getListRewrite(javadoc, Javadoc.TAGS_PROPERTY);
List<TypeParameter> typeParams = typeDecl.typeParameters();
for (int i = typeParams.size() - 1; i >= 0; i--) {
TypeParameter decl = typeParams.get(i);
String name = '<' + decl.getName().getIdentifier() + '>';
if (findTag(javadoc, TagElement.TAG_PARAM, name) == null) {
TagElement newTag = ast.newTagElement();
newTag.setTagName(TagElement.TAG_PARAM);
TextElement text = ast.newTextElement();
text.setText(name);
newTag.fragments().add(text);
insertTabStop(rewriter, newTag.fragments(), "typeParam" + i); // $NON-NLS-1$
insertTag(tagsRewriter, newTag, getPreviousTypeParamNames(typeParams, decl));
}
}
}
示例4: getDelegateJavadocTag
import org.eclipse.jdt.core.dom.TextElement; //导入方法依赖的package包/类
private TagElement getDelegateJavadocTag(BodyDeclaration declaration) throws JavaModelException {
Assert.isNotNull(declaration);
String msg= RefactoringCoreMessages.DelegateCreator_use_member_instead;
int firstParam= msg.indexOf("{0}"); //$NON-NLS-1$
Assert.isTrue(firstParam != -1);
List<ASTNode> fragments= new ArrayList<ASTNode>();
TextElement text= getAst().newTextElement();
text.setText(msg.substring(0, firstParam).trim());
fragments.add(text);
fragments.add(createJavadocMemberReferenceTag(declaration, getAst()));
text= getAst().newTextElement();
text.setText(msg.substring(firstParam + 3).trim());
fragments.add(text);
final TagElement tag= getAst().newTagElement();
tag.setTagName(TagElement.TAG_DEPRECATED);
tag.fragments().addAll(fragments);
return tag;
}
示例5: createComment
import org.eclipse.jdt.core.dom.TextElement; //导入方法依赖的package包/类
@SuppressWarnings("unchecked")
public BodyDeclaration createComment(AST ast, BodyDeclaration bodyDeclaration, String comment){
final Javadoc javadoc= ast.newJavadoc();
final TextElement textElement=ast.newTextElement();
textElement.setText(comment);
final TagElement tagElement=ast.newTagElement();
tagElement.fragments().add(textElement);
javadoc.tags().add(tagElement);
bodyDeclaration.setJavadoc(javadoc);
return bodyDeclaration;
}
示例6: createReturnTag
import org.eclipse.jdt.core.dom.TextElement; //导入方法依赖的package包/类
private TagElement createReturnTag() {
TagElement returnNode = getASTRewrite().getAST().newTagElement();
returnNode.setTagName(TagElement.TAG_RETURN);
TextElement textElement = getASTRewrite().getAST().newTextElement();
String text = StubUtility.getTodoTaskTag(fCuRewrite.getCu().getJavaProject());
if (text != null) textElement.setText(text); // TODO: use template with {@todo} ...
returnNode.fragments().add(textElement);
return returnNode;
}
示例7: createExceptionTag
import org.eclipse.jdt.core.dom.TextElement; //导入方法依赖的package包/类
private TagElement createExceptionTag(String simpleName) {
TagElement excptNode = getASTRewrite().getAST().newTagElement();
excptNode.setTagName(TagElement.TAG_THROWS);
SimpleName nameNode = getASTRewrite().getAST().newSimpleName(simpleName);
excptNode.fragments().add(nameNode);
TextElement textElement = getASTRewrite().getAST().newTextElement();
String text = StubUtility.getTodoTaskTag(fCuRewrite.getCu().getJavaProject());
if (text != null) textElement.setText(text); // TODO: use template with {@todo} ...
excptNode.fragments().add(textElement);
return excptNode;
}
示例8: createParamTag
import org.eclipse.jdt.core.dom.TextElement; //导入方法依赖的package包/类
public static TagElement createParamTag(String parameterName, AST ast, IJavaProject javaProject) {
TagElement paramNode = ast.newTagElement();
paramNode.setTagName(TagElement.TAG_PARAM);
SimpleName simpleName = ast.newSimpleName(parameterName);
paramNode.fragments().add(simpleName);
TextElement textElement = ast.newTextElement();
String text = StubUtility.getTodoTaskTag(javaProject);
if (text != null) textElement.setText(text); // TODO: use template with {@todo} ...
paramNode.fragments().add(textElement);
return paramNode;
}
示例9: createReturnTag
import org.eclipse.jdt.core.dom.TextElement; //导入方法依赖的package包/类
private TagElement createReturnTag() {
TagElement returnNode= getASTRewrite().getAST().newTagElement();
returnNode.setTagName(TagElement.TAG_RETURN);
TextElement textElement= getASTRewrite().getAST().newTextElement();
String text= StubUtility.getTodoTaskTag(fCuRewrite.getCu().getJavaProject());
if (text != null)
textElement.setText(text); //TODO: use template with {@todo} ...
returnNode.fragments().add(textElement);
return returnNode;
}
示例10: createExceptionTag
import org.eclipse.jdt.core.dom.TextElement; //导入方法依赖的package包/类
private TagElement createExceptionTag(String simpleName) {
TagElement excptNode= getASTRewrite().getAST().newTagElement();
excptNode.setTagName(TagElement.TAG_THROWS);
SimpleName nameNode= getASTRewrite().getAST().newSimpleName(simpleName);
excptNode.fragments().add(nameNode);
TextElement textElement= getASTRewrite().getAST().newTextElement();
String text= StubUtility.getTodoTaskTag(fCuRewrite.getCu().getJavaProject());
if (text != null)
textElement.setText(text); //TODO: use template with {@todo} ...
excptNode.fragments().add(textElement);
return excptNode;
}
示例11: createParamTag
import org.eclipse.jdt.core.dom.TextElement; //导入方法依赖的package包/类
public static TagElement createParamTag(String parameterName, AST ast, IJavaProject javaProject) {
TagElement paramNode= ast.newTagElement();
paramNode.setTagName(TagElement.TAG_PARAM);
SimpleName simpleName= ast.newSimpleName(parameterName);
paramNode.fragments().add(simpleName);
TextElement textElement= ast.newTextElement();
String text= StubUtility.getTodoTaskTag(javaProject);
if (text != null)
textElement.setText(text); //TODO: use template with {@todo} ...
paramNode.fragments().add(textElement);
return paramNode;
}
示例12: insertTabStop
import org.eclipse.jdt.core.dom.TextElement; //导入方法依赖的package包/类
private void insertTabStop(ASTRewrite rewriter, List<ASTNode> fragments, String linkedName) {
TextElement textElement= rewriter.getAST().newTextElement();
textElement.setText(""); //$NON-NLS-1$
fragments.add(textElement);
}
示例13: insertTabStop
import org.eclipse.jdt.core.dom.TextElement; //导入方法依赖的package包/类
private void insertTabStop(ASTRewrite rewriter, List<ASTNode> fragments, String linkedName) {
TextElement textElement = rewriter.getAST().newTextElement();
textElement.setText(""); // $NON-NLS-1$
fragments.add(textElement);
addLinkedPosition(rewriter.track(textElement), false, linkedName);
}
示例14: insertTabStop
import org.eclipse.jdt.core.dom.TextElement; //导入方法依赖的package包/类
private void insertTabStop(ASTRewrite rewriter, List<ASTNode> fragments, String linkedName) {
TextElement textElement= rewriter.getAST().newTextElement();
textElement.setText(""); //$NON-NLS-1$
fragments.add(textElement);
addLinkedPosition(rewriter.track(textElement), false, linkedName);
}
示例15: addTypeDeclaration
import org.eclipse.jdt.core.dom.TextElement; //导入方法依赖的package包/类
/**
* Adds a type declaration to the compilation unit cu, which inherits from oldTD.
*/
private void addTypeDeclaration(CompilationUnit cu, TypeDeclaration oldTD) {
AST ast = cu.getAST();
TypeDeclaration td = ast.newTypeDeclaration();
cu.types().add(td);
List<Modifier> modifiers = ast.newModifiers(Modifier.PUBLIC + Modifier.ABSTRACT);
for (int i = 0; i < modifiers.size(); i++) {
td.modifiers().add(modifiers.get(i));
}
td.setName(ast.newSimpleName(oldTD.getName().getFullyQualifiedName() + "PW"));
Name oldName = (Name)ASTNode.copySubtree(ast, oldTD.getName());
if (oldTD.typeParameters().size() == 0) {
td.setSuperclassType(ast.newSimpleType(oldName));
}
else {
Type superType = ast.newSimpleType(oldName);
ParameterizedType superTypeP = ast.newParameterizedType(superType);
td.setSuperclassType(superTypeP);
for (int i = 0; i < oldTD.typeParameters().size(); i++) {
ASTNode param = (ASTNode)oldTD.typeParameters().get(i);
TypeParameter tp = (TypeParameter)ASTNode.copySubtree(ast, param);
td.typeParameters().add(tp);
SimpleName argName = (SimpleName)ASTNode.copySubtree(ast, tp.getName());
superTypeP.typeArguments().add(ast.newSimpleType(argName));
}
}
// add javadoc comment
Javadoc javadoc = ast.newJavadoc();
td.setJavadoc(javadoc);
TagElement infoTag = ast.newTagElement();
javadoc.tags().add(infoTag);
TextElement infoEl = ast.newTextElement();
infoTag.fragments().add(infoEl);
DateFormat dateFormat = new SimpleDateFormat("yyyy/MM/dd");
Date date = new Date();
String dateStr = dateFormat.format(date);
infoEl.setText("This class was automatically generated by the PWM tool on " +
dateStr + ".");
TagElement seeTag = ast.newTagElement();
javadoc.tags().add(seeTag);
seeTag.setTagName("@see");
seeTag.fragments().add(ast.newName(NameResolver.getFullName(oldTD)));
}