Java 类org.eclipse.jdt.core.dom.TagElement 实例源码

项目:eclipse.jdt.ls    文件:ImportReferencesCollector.java   
@Override
public boolean visit(TagElement node) {
    String tagName= node.getTagName();
    List<? extends ASTNode> list= node.fragments();
    int idx= 0;
    if (tagName != null && !list.isEmpty()) {
        Object first= list.get(0);
        if (first instanceof Name) {
            if ("@throws".equals(tagName) || "@exception".equals(tagName)) {  //$NON-NLS-1$//$NON-NLS-2$
                typeRefFound((Name) first);
            } else if ("@see".equals(tagName) || "@link".equals(tagName) || "@linkplain".equals(tagName)) {  //$NON-NLS-1$//$NON-NLS-2$ //$NON-NLS-3$
                Name name= (Name) first;
                possibleTypeRefFound(name);
            }
            idx++;
        }
    }
    for (int i= idx; i < list.size(); i++) {
        doVisitNode(list.get(i));
    }
    return false;
}
项目:eclipse.jdt.ls    文件:JavaDoc2HTMLTextReader.java   
private void handleTag(String tag, String tagContent) {

        tagContent= tagContent.trim();

        if (TagElement.TAG_PARAM.equals(tag)) {
            fParameters.add(tagContent);
        } else if (TagElement.TAG_RETURN.equals(tag)) {
            fReturn= tagContent;
        } else if (TagElement.TAG_EXCEPTION.equals(tag)) {
            fExceptions.add(tagContent);
        } else if (TagElement.TAG_THROWS.equals(tag)) {
            fExceptions.add(tagContent);
        } else if (TagElement.TAG_AUTHOR.equals(tag)) {
            fAuthors.add(substituteQualification(tagContent));
        } else if (TagElement.TAG_SEE.equals(tag)) {
            fSees.add(substituteQualification(tagContent));
        } else if (TagElement.TAG_SINCE.equals(tag)) {
            fSince.add(substituteQualification(tagContent));
        } else if (tagContent != null) {
            fRest.add(new Pair(tag, tagContent));
        }
    }
项目:eclipse.jdt.ls    文件:JavadocTagsSubProcessor.java   
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));
        }
    }
}
项目:eclipse.jdt.ls    文件:JavadocTagsSubProcessor.java   
public static TagElement findTag(Javadoc javadoc, String name, String arg) {
    List<TagElement> tags= javadoc.tags();
    int nTags= tags.size();
    for (int i= 0; i < nTags; i++) {
        TagElement curr= tags.get(i);
        if (name.equals(curr.getTagName())) {
            if (arg != null) {
                String argument= getArgument(curr);
                if (arg.equals(argument)) {
                    return curr;
                }
            } else {
                return curr;
            }
        }
    }
    return null;
}
项目:eclipse.jdt.ls    文件:JavadocTagsSubProcessor.java   
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;
}
项目:eclipse.jdt.ls    文件:JavadocTagsSubProcessor.java   
public static void getRemoveJavadocTagProposals(IInvocationContext context, IProblemLocation problem,
        Collection<CUCorrectionProposal> proposals) {
    ASTNode node= problem.getCoveringNode(context.getASTRoot());
    while (node != null && !(node instanceof TagElement)) {
        node= node.getParent();
    }
    if (node == null) {
        return;
    }
    ASTRewrite rewrite= ASTRewrite.create(node.getAST());
    rewrite.remove(node, null);

    String label= CorrectionMessages.JavadocTagsSubProcessor_removetag_description;
    proposals.add(new ASTRewriteCorrectionProposal(label, context.getCompilationUnit(), rewrite,
            IProposalRelevance.REMOVE_TAG));
}
项目:che    文件:ImportReferencesCollector.java   
@Override
public boolean visit(TagElement node) {
  String tagName = node.getTagName();
  List<? extends ASTNode> list = node.fragments();
  int idx = 0;
  if (tagName != null && !list.isEmpty()) {
    Object first = list.get(0);
    if (first instanceof Name) {
      if ("@throws".equals(tagName) || "@exception".equals(tagName)) { // $NON-NLS-1$//$NON-NLS-2$
        typeRefFound((Name) first);
      } else if ("@see".equals(tagName)
          || "@link".equals(tagName)
          || "@linkplain".equals(tagName)) { // $NON-NLS-1$//$NON-NLS-2$ //$NON-NLS-3$
        Name name = (Name) first;
        possibleTypeRefFound(name);
      }
      idx++;
    }
  }
  for (int i = idx; i < list.size(); i++) {
    doVisitNode(list.get(i));
  }
  return false;
}
项目:che    文件:DelegateCreator.java   
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;
}
项目:che    文件:JavadocUtil.java   
/**
 * Adds a "param" javadoc tag for a new last parameter if necessary.
 *
 * @param parameterName
 * @param methodDeclaration
 * @param astRewrite
 * @param javaProject
 * @param groupDescription
 */
public static void addParamJavadoc(
    String parameterName,
    MethodDeclaration methodDeclaration,
    ASTRewrite astRewrite,
    IJavaProject javaProject,
    TextEditGroup groupDescription) {
  if (!shouldAddParamJavadoc(methodDeclaration)) return;

  ListRewrite tagsRewrite =
      astRewrite.getListRewrite(methodDeclaration.getJavadoc(), Javadoc.TAGS_PROPERTY);
  HashSet<String> leadingNames = new HashSet<String>();
  for (Iterator<SingleVariableDeclaration> iter = methodDeclaration.parameters().iterator();
      iter.hasNext(); ) {
    SingleVariableDeclaration curr = iter.next();
    leadingNames.add(curr.getName().getIdentifier());
  }
  TagElement parameterTag = createParamTag(parameterName, astRewrite.getAST(), javaProject);
  JavadocTagsSubProcessor.insertTag(tagsRewrite, parameterTag, leadingNames, groupDescription);
}
项目:che    文件:JavadocTagsSubProcessor.java   
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));
    }
  }
}
项目:che    文件:JavadocTagsSubProcessor.java   
public static TagElement findTag(Javadoc javadoc, String name, String arg) {
  List<TagElement> tags = javadoc.tags();
  int nTags = tags.size();
  for (int i = 0; i < nTags; i++) {
    TagElement curr = tags.get(i);
    if (name.equals(curr.getTagName())) {
      if (arg != null) {
        String argument = getArgument(curr);
        if (arg.equals(argument)) {
          return curr;
        }
      } else {
        return curr;
      }
    }
  }
  return null;
}
项目:che    文件:JavadocTagsSubProcessor.java   
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;
}
项目:che    文件:JavadocTagsSubProcessor.java   
public static void getRemoveJavadocTagProposals(
    IInvocationContext context, IProblemLocation problem, Collection<ICommandAccess> proposals) {
  ASTNode node = problem.getCoveringNode(context.getASTRoot());
  while (node != null && !(node instanceof TagElement)) {
    node = node.getParent();
  }
  if (node == null) {
    return;
  }
  ASTRewrite rewrite = ASTRewrite.create(node.getAST());
  rewrite.remove(node, null);

  String label = CorrectionMessages.JavadocTagsSubProcessor_removetag_description;
  Image image =
      JavaPluginImages.get(
          JavaPluginImages
              .IMG_TOOL_DELETE); // JavaPlugin.getDefault().getWorkbench().getSharedImages().getImage(ISharedImages.IMG_TOOL_DELETE);
  proposals.add(
      new ASTRewriteCorrectionProposal(
          label, context.getCompilationUnit(), rewrite, IProposalRelevance.REMOVE_TAG, image));
}
项目:che    文件:JavadocContentAccess2.java   
CharSequence getMainDescription() {
  if (fMainDescription == null) {
    fMainDescription = new StringBuffer();
    fBuf = fMainDescription;
    fLiteralContent = 0;

    List<TagElement> tags = fJavadoc.tags();
    for (Iterator<TagElement> iter = tags.iterator(); iter.hasNext(); ) {
      TagElement tag = iter.next();
      String tagName = tag.getTagName();
      if (tagName == null) {
        handleContentElements(tag.fragments());
        break;
      }
    }

    fBuf = null;
  }
  return fMainDescription.length() > 0 ? fMainDescription : null;
}
项目:che    文件:JavadocContentAccess2.java   
CharSequence getReturnDescription() {
  if (fReturnDescription == null) {
    fReturnDescription = new StringBuffer();
    fBuf = fReturnDescription;
    fLiteralContent = 0;

    List<TagElement> tags = fJavadoc.tags();
    for (Iterator<TagElement> iter = tags.iterator(); iter.hasNext(); ) {
      TagElement tag = iter.next();
      String tagName = tag.getTagName();
      if (TagElement.TAG_RETURN.equals(tagName)) {
        handleContentElements(tag.fragments());
        break;
      }
    }

    fBuf = null;
  }
  return fReturnDescription.length() > 0 ? fReturnDescription : null;
}
项目:che    文件:JavadocContentAccess2.java   
private void handleBlockTags(String title, List<TagElement> tags) {
  if (tags.isEmpty()) return;

  handleBlockTagTitle(title);

  for (Iterator<TagElement> iter = tags.iterator(); iter.hasNext(); ) {
    TagElement tag = iter.next();
    fBuf.append(BlOCK_TAG_ENTRY_START);
    if (TagElement.TAG_SEE.equals(tag.getTagName())) {
      handleSeeTag(tag);
    } else {
      handleContentElements(tag.fragments());
    }
    fBuf.append(BlOCK_TAG_ENTRY_END);
  }
}
项目:che    文件:JavadocContentAccess2.java   
private void handleExceptionTags(
    List<TagElement> tags, List<String> exceptionNames, CharSequence[] exceptionDescriptions) {
  if (tags.size() == 0 && containsOnlyNull(exceptionNames)) return;

  handleBlockTagTitle(JavaDocMessages.JavaDoc2HTMLTextReader_throws_section);

  for (Iterator<TagElement> iter = tags.iterator(); iter.hasNext(); ) {
    TagElement tag = iter.next();
    fBuf.append(BlOCK_TAG_ENTRY_START);
    handleThrowsTag(tag);
    fBuf.append(BlOCK_TAG_ENTRY_END);
  }
  for (int i = 0; i < exceptionDescriptions.length; i++) {
    CharSequence description = exceptionDescriptions[i];
    String name = exceptionNames.get(i);
    if (name != null) {
      fBuf.append(BlOCK_TAG_ENTRY_START);
      handleLink(Collections.singletonList(fJavadoc.getAST().newSimpleName(name)));
      if (description != null) {
        fBuf.append(JavaElementLabels.CONCAT_STRING);
        fBuf.append(description);
      }
      fBuf.append(BlOCK_TAG_ENTRY_END);
    }
  }
}
项目:che    文件:JavadocContentAccess2.java   
private void handleParameterTags(
    List<TagElement> tags, List<String> parameterNames, CharSequence[] parameterDescriptions) {
  if (tags.size() == 0 && containsOnlyNull(parameterNames)) return;

  handleBlockTagTitle(JavaDocMessages.JavaDoc2HTMLTextReader_parameters_section);

  for (Iterator<TagElement> iter = tags.iterator(); iter.hasNext(); ) {
    TagElement tag = iter.next();
    fBuf.append(BlOCK_TAG_ENTRY_START);
    handleParamTag(tag);
    fBuf.append(BlOCK_TAG_ENTRY_END);
  }
  for (int i = 0; i < parameterDescriptions.length; i++) {
    CharSequence description = parameterDescriptions[i];
    String name = parameterNames.get(i);
    if (name != null) {
      fBuf.append(BlOCK_TAG_ENTRY_START);
      fBuf.append(PARAM_NAME_START);
      fBuf.append(name);
      fBuf.append(PARAM_NAME_END);
      if (description != null) fBuf.append(description);
      fBuf.append(BlOCK_TAG_ENTRY_END);
    }
  }
}
项目:Eclipse-Postfix-Code-Completion    文件:ImportReferencesCollector.java   
@Override
public boolean visit(TagElement node) {
    String tagName= node.getTagName();
    List<? extends ASTNode> list= node.fragments();
    int idx= 0;
    if (tagName != null && !list.isEmpty()) {
        Object first= list.get(0);
        if (first instanceof Name) {
            if ("@throws".equals(tagName) || "@exception".equals(tagName)) {  //$NON-NLS-1$//$NON-NLS-2$
                typeRefFound((Name) first);
            } else if ("@see".equals(tagName) || "@link".equals(tagName) || "@linkplain".equals(tagName)) {  //$NON-NLS-1$//$NON-NLS-2$ //$NON-NLS-3$
                Name name= (Name) first;
                possibleTypeRefFound(name);
            }
            idx++;
        }
    }
    for (int i= idx; i < list.size(); i++) {
        doVisitNode(list.get(i));
    }
    return false;
}
项目:Eclipse-Postfix-Code-Completion    文件:JavaDoc2HTMLTextReader.java   
private void handleTag(String tag, String tagContent) {

        tagContent= tagContent.trim();

        if (TagElement.TAG_PARAM.equals(tag))
            fParameters.add(tagContent);
        else if (TagElement.TAG_RETURN.equals(tag))
            fReturn= tagContent;
        else if (TagElement.TAG_EXCEPTION.equals(tag))
            fExceptions.add(tagContent);
        else if (TagElement.TAG_THROWS.equals(tag))
            fExceptions.add(tagContent);
        else if (TagElement.TAG_AUTHOR.equals(tag))
            fAuthors.add(substituteQualification(tagContent));
        else if (TagElement.TAG_SEE.equals(tag))
            fSees.add(substituteQualification(tagContent));
        else if (TagElement.TAG_SINCE.equals(tag))
            fSince.add(substituteQualification(tagContent));
        else if (tagContent != null)
            fRest.add(new Pair(tag, tagContent));
    }
项目:Eclipse-Postfix-Code-Completion    文件:JavadocContentAccess2.java   
CharSequence getMainDescription() {
    if (fMainDescription == null) {
        fMainDescription= new StringBuffer();
        fBuf= fMainDescription;
        fLiteralContent= 0;

        List<TagElement> tags= fJavadoc.tags();
        for (Iterator<TagElement> iter= tags.iterator(); iter.hasNext(); ) {
            TagElement tag= iter.next();
            String tagName= tag.getTagName();
            if (tagName == null) {
                handleContentElements(tag.fragments());
                break;
            }
        }

        fBuf= null;
    }
    return fMainDescription.length() > 0 ? fMainDescription : null;
}
项目:Eclipse-Postfix-Code-Completion    文件:JavadocContentAccess2.java   
CharSequence getReturnDescription() {
    if (fReturnDescription == null) {
        fReturnDescription= new StringBuffer();
        fBuf= fReturnDescription;
        fLiteralContent= 0;

        List<TagElement> tags= fJavadoc.tags();
        for (Iterator<TagElement> iter= tags.iterator(); iter.hasNext(); ) {
            TagElement tag= iter.next();
            String tagName= tag.getTagName();
            if (TagElement.TAG_RETURN.equals(tagName)) {
                handleContentElements(tag.fragments());
                break;
            }
        }

        fBuf= null;
    }
    return fReturnDescription.length() > 0 ? fReturnDescription : null;
}
项目:Eclipse-Postfix-Code-Completion    文件:JavadocContentAccess2.java   
private void handleBlockTags(String title, List<TagElement> tags) {
    if (tags.isEmpty())
        return;

    handleBlockTagTitle(title);

    for (Iterator<TagElement> iter= tags.iterator(); iter.hasNext(); ) {
        TagElement tag= iter.next();
        fBuf.append(BlOCK_TAG_ENTRY_START);
        if (TagElement.TAG_SEE.equals(tag.getTagName())) {
            handleSeeTag(tag);
        } else {
            handleContentElements(tag.fragments());
        }
        fBuf.append(BlOCK_TAG_ENTRY_END);
    }
}
项目:Eclipse-Postfix-Code-Completion    文件:JavadocContentAccess2.java   
private void handleParameterTags(List<TagElement> tags, List<String> parameterNames, CharSequence[] parameterDescriptions) {
    if (tags.size() == 0 && containsOnlyNull(parameterNames))
        return;

    handleBlockTagTitle(JavaDocMessages.JavaDoc2HTMLTextReader_parameters_section);

    for (Iterator<TagElement> iter= tags.iterator(); iter.hasNext(); ) {
        TagElement tag= iter.next();
        fBuf.append(BlOCK_TAG_ENTRY_START);
        handleParamTag(tag);
        fBuf.append(BlOCK_TAG_ENTRY_END);
    }
    for (int i= 0; i < parameterDescriptions.length; i++) {
        CharSequence description= parameterDescriptions[i];
        String name= parameterNames.get(i);
        if (name != null) {
            fBuf.append(BlOCK_TAG_ENTRY_START);
            fBuf.append(PARAM_NAME_START);
            fBuf.append(name);
            fBuf.append(PARAM_NAME_END);
            if (description != null)
                fBuf.append(description);
            fBuf.append(BlOCK_TAG_ENTRY_END);
        }
    }
}
项目:Eclipse-Postfix-Code-Completion    文件:JavadocTagsSubProcessor.java   
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));
        }
    }
}
项目:Eclipse-Postfix-Code-Completion    文件:JavadocTagsSubProcessor.java   
public static TagElement findTag(Javadoc javadoc, String name, String arg) {
    List<TagElement> tags= javadoc.tags();
    int nTags= tags.size();
    for (int i= 0; i < nTags; i++) {
        TagElement curr= tags.get(i);
        if (name.equals(curr.getTagName())) {
            if (arg != null) {
                String argument= getArgument(curr);
                if (arg.equals(argument)) {
                    return curr;
                }
            } else {
                return curr;
            }
        }
    }
    return null;
}
项目:Eclipse-Postfix-Code-Completion    文件:JavadocTagsSubProcessor.java   
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;
}
项目:Eclipse-Postfix-Code-Completion-Juno38    文件:DelegateCreator.java   
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;
}
项目:Eclipse-Postfix-Code-Completion-Juno38    文件:ImportReferencesCollector.java   
@Override
public boolean visit(TagElement node) {
    String tagName= node.getTagName();
    List<? extends ASTNode> list= node.fragments();
    int idx= 0;
    if (tagName != null && !list.isEmpty()) {
        Object first= list.get(0);
        if (first instanceof Name) {
            if ("@throws".equals(tagName) || "@exception".equals(tagName)) {  //$NON-NLS-1$//$NON-NLS-2$
                typeRefFound((Name) first);
            } else if ("@see".equals(tagName) || "@link".equals(tagName) || "@linkplain".equals(tagName)) {  //$NON-NLS-1$//$NON-NLS-2$ //$NON-NLS-3$
                Name name= (Name) first;
                possibleTypeRefFound(name);
            }
            idx++;
        }
    }
    for (int i= idx; i < list.size(); i++) {
        doVisitNode(list.get(i));
    }
    return false;
}
项目:Eclipse-Postfix-Code-Completion-Juno38    文件:JavaDoc2HTMLTextReader.java   
private void handleTag(String tag, String tagContent) {

        tagContent= tagContent.trim();

        if (TagElement.TAG_PARAM.equals(tag))
            fParameters.add(tagContent);
        else if (TagElement.TAG_RETURN.equals(tag))
            fReturn= tagContent;
        else if (TagElement.TAG_EXCEPTION.equals(tag))
            fExceptions.add(tagContent);
        else if (TagElement.TAG_THROWS.equals(tag))
            fExceptions.add(tagContent);
        else if (TagElement.TAG_AUTHOR.equals(tag))
            fAuthors.add(substituteQualification(tagContent));
        else if (TagElement.TAG_SEE.equals(tag))
            fSees.add(substituteQualification(tagContent));
        else if (TagElement.TAG_SINCE.equals(tag))
            fSince.add(substituteQualification(tagContent));
        else if (tagContent != null)
            fRest.add(new Pair(tag, tagContent));
    }
项目:Eclipse-Postfix-Code-Completion-Juno38    文件:JavadocContentAccess2.java   
CharSequence getMainDescription() {
    if (fMainDescription == null) {
        fMainDescription= new StringBuffer();
        fBuf= fMainDescription;
        fLiteralContent= 0;

        List<TagElement> tags= fJavadoc.tags();
        for (Iterator<TagElement> iter= tags.iterator(); iter.hasNext(); ) {
            TagElement tag= iter.next();
            String tagName= tag.getTagName();
            if (tagName == null) {
                handleContentElements(tag.fragments());
                break;
            }
        }

        fBuf= null;
    }
    return fMainDescription.length() > 0 ? fMainDescription : null;
}
项目:Eclipse-Postfix-Code-Completion-Juno38    文件:JavadocContentAccess2.java   
CharSequence getReturnDescription() {
    if (fReturnDescription == null) {
        fReturnDescription= new StringBuffer();
        fBuf= fReturnDescription;
        fLiteralContent= 0;

        List<TagElement> tags= fJavadoc.tags();
        for (Iterator<TagElement> iter= tags.iterator(); iter.hasNext(); ) {
            TagElement tag= iter.next();
            String tagName= tag.getTagName();
            if (TagElement.TAG_RETURN.equals(tagName)) {
                handleContentElements(tag.fragments());
                break;
            }
        }

        fBuf= null;
    }
    return fReturnDescription.length() > 0 ? fReturnDescription : null;
}
项目:Eclipse-Postfix-Code-Completion-Juno38    文件:JavadocContentAccess2.java   
private void handleBlockTags(String title, List<TagElement> tags) {
    if (tags.isEmpty())
        return;

    handleBlockTagTitle(title);

    for (Iterator<TagElement> iter= tags.iterator(); iter.hasNext(); ) {
        TagElement tag= iter.next();
        fBuf.append(BlOCK_TAG_ENTRY_START);
        if (TagElement.TAG_SEE.equals(tag.getTagName())) {
            handleSeeTag(tag);
        } else {
            handleContentElements(tag.fragments());
        }
        fBuf.append(BlOCK_TAG_ENTRY_END);
    }
}
项目:Eclipse-Postfix-Code-Completion-Juno38    文件:JavadocContentAccess2.java   
private void handleExceptionTags(List<TagElement> tags, List<String> exceptionNames, CharSequence[] exceptionDescriptions) {
    if (tags.size() == 0 && containsOnlyNull(exceptionNames))
        return;

    handleBlockTagTitle(JavaDocMessages.JavaDoc2HTMLTextReader_throws_section);

    for (Iterator<TagElement> iter= tags.iterator(); iter.hasNext(); ) {
        TagElement tag= iter.next();
        fBuf.append(BlOCK_TAG_ENTRY_START);
        handleThrowsTag(tag);
        fBuf.append(BlOCK_TAG_ENTRY_END);
    }
    for (int i= 0; i < exceptionDescriptions.length; i++) {
        CharSequence description= exceptionDescriptions[i];
        String name= exceptionNames.get(i);
        if (name != null) {
            fBuf.append(BlOCK_TAG_ENTRY_START);
            handleLink(Collections.singletonList(fJavadoc.getAST().newSimpleName(name)));
            if (description != null) {
                fBuf.append(JavaElementLabels.CONCAT_STRING);
                fBuf.append(description);
            }
            fBuf.append(BlOCK_TAG_ENTRY_END);
        }
    }
}
项目:Eclipse-Postfix-Code-Completion-Juno38    文件:JavadocContentAccess2.java   
private void handleParameterTags(List<TagElement> tags, List<String> parameterNames, CharSequence[] parameterDescriptions) {
    if (tags.size() == 0 && containsOnlyNull(parameterNames))
        return;

    handleBlockTagTitle(JavaDocMessages.JavaDoc2HTMLTextReader_parameters_section);

    for (Iterator<TagElement> iter= tags.iterator(); iter.hasNext(); ) {
        TagElement tag= iter.next();
        fBuf.append(BlOCK_TAG_ENTRY_START);
        handleParamTag(tag);
        fBuf.append(BlOCK_TAG_ENTRY_END);
    }
    for (int i= 0; i < parameterDescriptions.length; i++) {
        CharSequence description= parameterDescriptions[i];
        String name= parameterNames.get(i);
        if (name != null) {
            fBuf.append(BlOCK_TAG_ENTRY_START);
            fBuf.append(PARAM_NAME_START);
            fBuf.append(name);
            fBuf.append(PARAM_NAME_END);
            if (description != null)
                fBuf.append(description);
            fBuf.append(BlOCK_TAG_ENTRY_END);
        }
    }
}
项目:Eclipse-Postfix-Code-Completion-Juno38    文件:JavadocTagsSubProcessor.java   
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));
        }
    }
}
项目:Eclipse-Postfix-Code-Completion-Juno38    文件:JavadocTagsSubProcessor.java   
public static TagElement findTag(Javadoc javadoc, String name, String arg) {
    List<TagElement> tags= javadoc.tags();
    int nTags= tags.size();
    for (int i= 0; i < nTags; i++) {
        TagElement curr= tags.get(i);
        if (name.equals(curr.getTagName())) {
            if (arg != null) {
                String argument= getArgument(curr);
                if (arg.equals(argument)) {
                    return curr;
                }
            } else {
                return curr;
            }
        }
    }
    return null;
}
项目:Eclipse-Postfix-Code-Completion-Juno38    文件:JavadocTagsSubProcessor.java   
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;
}
项目:RefDiff    文件:AstUtils.java   
public static boolean containsDeprecatedTag(Javadoc javadoc) {
    if (javadoc == null) {
        return false;
    }
    @SuppressWarnings("unchecked")
       List<TagElement> javadocTags = (List<TagElement>) javadoc.tags();
    for (TagElement tag : javadocTags) {
        if ("@deprecated".equals(tag.getTagName())) {
            return true;
        }
    }
    return false;
}
项目:RefDiff    文件:AstUtils.java   
public static boolean containsDeprecatedTag(Javadoc javadoc) {
    if (javadoc == null) {
        return false;
    }
    @SuppressWarnings("unchecked")
       List<TagElement> javadocTags = (List<TagElement>) javadoc.tags();
    for (TagElement tag : javadocTags) {
        if ("@deprecated".equals(tag.getTagName())) {
            return true;
        }
    }
    return false;
}