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


Java TextElement类代码示例

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


TextElement类属于org.eclipse.jdt.core.dom包,在下文中一共展示了TextElement类的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));
		}
	}
}
 
开发者ID:eclipse,项目名称:eclipse.jdt.ls,代码行数:21,代码来源:JavadocTagsSubProcessor.java

示例2: getArgument

import org.eclipse.jdt.core.dom.TextElement; //导入依赖的package包/类
private static String getArgument(TagElement curr) {
	List<? extends ASTNode> fragments= curr.fragments();
	if (!fragments.isEmpty()) {
		Object first= fragments.get(0);
		if (first instanceof Name) {
			return ASTNodes.getSimpleNameIdentifier((Name) first);
		} else if (first instanceof TextElement && TagElement.TAG_PARAM.equals(curr.getTagName())) {
			String text= ((TextElement) first).getText();
			if ("<".equals(text) && fragments.size() >= 3) { //$NON-NLS-1$
				Object second= fragments.get(1);
				Object third= fragments.get(2);
				if (second instanceof Name && third instanceof TextElement && ">".equals(((TextElement) third).getText())) { //$NON-NLS-1$
					return '<' + ASTNodes.getSimpleNameIdentifier((Name) second) + '>';
				}
			} else if (text.startsWith(String.valueOf('<')) && text.endsWith(String.valueOf('>')) && text.length() > 2) {
				return text.substring(1, text.length() - 1);
			}
		}
	}
	return null;
}
 
开发者ID:eclipse,项目名称:eclipse.jdt.ls,代码行数:22,代码来源:JavadocTagsSubProcessor.java

示例3: 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;
}
 
开发者ID:eclipse,项目名称:che,代码行数:24,代码来源:DelegateCreator.java

示例4: 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));
    }
  }
}
 
开发者ID:eclipse,项目名称:che,代码行数:21,代码来源:JavadocTagsSubProcessor.java

示例5: getArgument

import org.eclipse.jdt.core.dom.TextElement; //导入依赖的package包/类
private static String getArgument(TagElement curr) {
  List<? extends ASTNode> fragments = curr.fragments();
  if (!fragments.isEmpty()) {
    Object first = fragments.get(0);
    if (first instanceof Name) {
      return ASTNodes.getSimpleNameIdentifier((Name) first);
    } else if (first instanceof TextElement && TagElement.TAG_PARAM.equals(curr.getTagName())) {
      String text = ((TextElement) first).getText();
      if ("<".equals(text) && fragments.size() >= 3) { // $NON-NLS-1$
        Object second = fragments.get(1);
        Object third = fragments.get(2);
        if (second instanceof Name
            && third instanceof TextElement
            && ">".equals(((TextElement) third).getText())) { // $NON-NLS-1$
          return '<' + ASTNodes.getSimpleNameIdentifier((Name) second) + '>';
        }
      } else if (text.startsWith(String.valueOf('<'))
          && text.endsWith(String.valueOf('>'))
          && text.length() > 2) {
        return text.substring(1, text.length() - 1);
      }
    }
  }
  return null;
}
 
开发者ID:eclipse,项目名称:che,代码行数:26,代码来源:JavadocTagsSubProcessor.java

示例6: newRegionUpdater

import org.eclipse.jdt.core.dom.TextElement; //导入依赖的package包/类
/**
 * Creates a new region updater for the given text edit contained within the
 * given node.
 * 
 * @param originalEdit the text edit
 * @param node the most-specific node that contains the text edit
 * @param referenceUpdater an reference updater knowledgeable about the
 *          refactoring that is taking place
 * @param matcher an AST matcher knowledgeable about refactoring that is
 *          taking place
 * @return a region updater instance for the given text edit
 * @throws RefactoringException if there was an error creating a region
 *           updater
 */
public static RegionUpdater newRegionUpdater(ReplaceEdit originalEdit,
    ASTNode node, ReferenceUpdater referenceUpdater, ASTMatcher matcher)
    throws RefactoringException {

  if (node instanceof Name) {
    return new NameRegionUpdater(originalEdit, referenceUpdater, (Name) node,
        matcher);

  } else if (node instanceof TextElement) {
    return new TextElementRegionUpdater(originalEdit, referenceUpdater,
        (TextElement) node, matcher);
  }

  throw new RefactoringException("This AST node type is not supported");
}
 
开发者ID:gwt-plugins,项目名称:gwt-eclipse-plugin,代码行数:30,代码来源:RegionUpdaterFactory.java

示例7: 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;
}
 
开发者ID:trylimits,项目名称:Eclipse-Postfix-Code-Completion,代码行数:24,代码来源:DelegateCreator.java

示例8: 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;
}
 
开发者ID:WalterMourao,项目名称:andromda,代码行数:12,代码来源:AndromdaHelper.java

示例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;
}
 
开发者ID:eclipse,项目名称:che,代码行数:12,代码来源:ChangeSignatureProcessor.java

示例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;
}
 
开发者ID:eclipse,项目名称:che,代码行数:15,代码来源:ChangeSignatureProcessor.java

示例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;
}
 
开发者ID:eclipse,项目名称:che,代码行数:15,代码来源:JavadocUtil.java

示例12: match

import org.eclipse.jdt.core.dom.TextElement; //导入依赖的package包/类
@Override
public boolean match(TextElement node, Object other) {
  if (!(other instanceof TextElement)) {
    return false;
  }
  TextElement o = (TextElement) other;
  return safeRenamedEquals(node.getText(), o.getText(), oldName, newName);
}
 
开发者ID:gwt-plugins,项目名称:gwt-eclipse-plugin,代码行数:9,代码来源:RenamedElementAstMatcher.java

示例13: createUpdatedEditForEquivalentNode

import org.eclipse.jdt.core.dom.TextElement; //导入依赖的package包/类
@Override
protected ReplaceEdit createUpdatedEditForEquivalentNode(
    TextElement equivalentNode) throws RefactoringException {
  // Adjust the offset based on the difference between start positions of
  // equivalent nodes
  int newOffset = getOriginalEdit().getOffset()
      + equivalentNode.getStartPosition()
      - getOriginalNode().getStartPosition();

  return new ReplaceEdit(newOffset, getOriginalEdit().getLength(),
      getOriginalEdit().getText());
}
 
开发者ID:gwt-plugins,项目名称:gwt-eclipse-plugin,代码行数:13,代码来源:TextElementRegionUpdater.java

示例14: 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;
}
 
开发者ID:trylimits,项目名称:Eclipse-Postfix-Code-Completion,代码行数:13,代码来源:ChangeSignatureProcessor.java

示例15: 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;
}
 
开发者ID:trylimits,项目名称:Eclipse-Postfix-Code-Completion,代码行数:16,代码来源:ChangeSignatureProcessor.java


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