Package org.eclipse.jdt.core.dom

Examples of org.eclipse.jdt.core.dom.TagElement


                        Javadoc jdoc = aMethod.getJavadoc();
                        if(jdoc != null) {
                          List tags =  jdoc.tags();
                          List tagsToRemove = new ArrayList();
                          for(Iterator itTags = tags.iterator(); itTags.hasNext();) {
                              TagElement tag = (TagElement) itTags.next();
                              if (tag.toString().contains("@gwt")) {
                                  tagsToRemove.add(tag);
                             
                          }
                          tags.removeAll(tagsToRemove);
                        }
View Full Code Here


          {
            Javadoc javadoc = methodDeclaration.getJavadoc();
            if (javadoc != null) {
              List<TagElement> tags = DomGenerics.tags(javadoc);
              for (Iterator<TagElement> tagIter = tags.iterator(); tagIter.hasNext();) {
                TagElement tag = tagIter.next();
                if ("@gwt.typeArgs".equals(tag.getTagName())) {
                  tagIter.remove();
                } else if ("@return".equals(tag.getTagName())) {
                  if (!tag.fragments().isEmpty()) {
                    tag.setTagName("@param callback the callback to return");
                  } else {
                    tagIter.remove();
                  }
                } else if ("@wbp.gwt.Request".equals(tag.getTagName())) {
                  tagIter.remove();
                  addImport(serviceRoot, "com.google.gwt.http.client.Request");
                  methodDeclaration.setReturnType2(ast.newSimpleType(ast.newName("Request")));
                }
              }
View Full Code Here

    System.out.println(doc.get());
  }


  private ASTNode createNode(AST ast) {
    TagElement tag = ast.newTagElement();
    tag.setTagName(TagElement.TAG_SEE);
    MethodRef method = ast.newMethodRef();
    tag.fragments().add(method);
    SimpleName name = ast.newSimpleName("Test");
    method.setQualifier(ast.newQualifiedName(ast.newQualifiedName(ast.newName("org"), ast.newSimpleName("junit")), name));
    name = ast.newSimpleName("setUp");
    method.setName(name);
    return tag;
View Full Code Here

    final ASTNode node = parser.createAST(null);
    ASTVisitor visitor = new ASTVisitor(){
      @SuppressWarnings("unchecked")
      public boolean visit(Javadoc doc){
        AST ast = doc.getAST();
        TagElement tag = ast.newTagElement();
        tag.setTagName(TagElement.TAG_SEE);
        doc.tags().add(tag);
        MethodRef method = ast.newMethodRef();
        tag.fragments().add(method);
        SimpleName name = ast.newSimpleName("Test");
        method.setQualifier(ast.newQualifiedName(ast.newQualifiedName(ast.newName("org"), ast.newSimpleName("junit")), name));
        name = ast.newSimpleName("test");
        method.setName(name);
        return super.visit(doc);
View Full Code Here

  public void generatePackageJavadoc(AST ast,
      PackageDeclaration packageDeclaration, String... comment) {
    Javadoc javadoc = ast.newJavadoc();

    for (String actualComment : comment) {
      TagElement tagElement = ast.newTagElement();
      tagElement.setTagName(actualComment);
      javadoc.tags().add(tagElement);
    }

    packageDeclaration.setJavadoc(javadoc);
  }
View Full Code Here

  @SuppressWarnings("unchecked")
  private void generateJavadoc(AST ast, Comment comment, Javadoc javadoc) {
    String[] commentContents = parseComent(comment.getBody());
    for (String commentContent : commentContents) {
      TagElement tagElement = ast.newTagElement();
      tagElement.setTagName(commentContent);
      javadoc.tags().add(tagElement);
    }
  }
View Full Code Here

    }else{
      // find current params.
      int index = 0;
      HashMap<String, TagElement> current = new HashMap<String, TagElement>();
      for (int ii = 0; ii < tags.size(); ii++){
        TagElement tag = (TagElement)tags.get(ii);
        if(TagElement.TAG_PARAM.equals(tag.getTagName())){
          if(current.size() == 0){
            index = ii;
          }
          Object element = tag.fragments().size() > 0 ?
            tag.fragments().get(0) : null;
          if(element != null && element instanceof Name){
            String name = ((Name)element).getFullyQualifiedName();
            current.put(name, tag);
          }else{
            current.put(String.valueOf(ii), tag);
          }
        }else{
          if(current.size() > 0){
            break;
          }
          if(tag.getTagName() == null){
            index = ii + 1;
          }
        }
      }

      if(current.size() > 0){
        for (int ii = 0; ii < params.length; ii++){
          if(current.containsKey(params[ii])){
            TagElement tag = (TagElement)current.get(params[ii]);
            int currentIndex = tags.indexOf(tag);
            if(currentIndex != ii){
              tags.remove(tag);
              tags.add(index + ii, tag);
            }
View Full Code Here

        }else{
          // search starting from the bottom since @return should be near the
          // end.
          int index = tags.size();
          for (int ii = tags.size() - 1; ii >= 0; ii--){
            TagElement tag = (TagElement)tags.get(ii);
            // return tag already exists?
            if(TagElement.TAG_RETURN.equals(tag.getTagName())){
              index = -1;
              break;
            }
            // if we hit the param tags, or the main text, insert below them.
            if (TagElement.TAG_PARAM.equals(tag.getTagName()) ||
                tag.getTagName() == null)
            {
              index = ii + 1;
              break;
            }
            index = ii;
          }
          if(index > -1){
            addTag(javadoc, index, TagElement.TAG_RETURN, null);
          }
        }
      }else{
        // remove any return tag that may exist.
        for (int ii = tags.size() - 1; ii >= 0; ii--){
          TagElement tag = (TagElement)tags.get(ii);
          // return tag already exists?
          if(TagElement.TAG_RETURN.equals(tag.getTagName())){
            tags.remove(tag);
          }
          // if we hit the param tags, or the main text we can stop.
          if (TagElement.TAG_PARAM.equals(tag.getTagName()) ||
              tag.getTagName() == null)
          {
            break;
          }
        }
      }
View Full Code Here

    }else{
      // get current throws tags
      HashMap<String, TagElement> current = new HashMap<String, TagElement>();
      int index = tags.size();
      for (int ii = tags.size() - 1; ii >= 0; ii--){
        TagElement tag = (TagElement)tags.get(ii);
        if(TagElement.TAG_THROWS.equals(tag.getTagName())){
          index = index == tags.size() ? ii + 1 : index;
          Name name = tag.fragments().size() > 0 ?
            (Name)tag.fragments().get(0) : null;
          if(name != null){
            String text = name.getFullyQualifiedName();
            String key = THROWS_PATTERN.matcher(text).replaceFirst("$1");
            current.put(key, tag);
          }else{
            current.put(String.valueOf(ii), tag);
          }
        }
        // if we hit the return tag, a param tag, or the main text we can stop.
        if (TagElement.TAG_PARAM.equals(tag.getTagName()) ||
            TagElement.TAG_RETURN.equals(tag.getTagName()) ||
            tag.getTagName() == null)
        {
          break;
        }
      }
View Full Code Here

   */
  private void addTag(
      Javadoc javadoc, int index, String name, String text)
    throws Exception
  {
    TagElement tag = javadoc.getAST().newTagElement();
    tag.setTagName(name);

    if(text != null){
      TextElement textElement = javadoc.getAST().newTextElement();
      textElement.setText(text);

      @SuppressWarnings("unchecked")
      List<ASTNode> fragments = tag.fragments();
      fragments.add(textElement);
    }

    @SuppressWarnings("unchecked")
    List<TagElement> tags = javadoc.tags();
View Full Code Here

TOP

Related Classes of org.eclipse.jdt.core.dom.TagElement

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.