< prev index next >

src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/toolkit/util/CommentHelper.java

Print this page


   1 /*
   2  * Copyright (c) 2015, 2017, Oracle and/or its affiliates. All rights reserved.
   3  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
   4  *
   5  * This code is free software; you can redistribute it and/or modify it
   6  * under the terms of the GNU General Public License version 2 only, as
   7  * published by the Free Software Foundation.  Oracle designates this
   8  * particular file as subject to the "Classpath" exception as provided
   9  * by Oracle in the LICENSE file that accompanied this code.
  10  *
  11  * This code is distributed in the hope that it will be useful, but WITHOUT
  12  * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
  13  * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
  14  * version 2 for more details (a copy is included in the LICENSE file that
  15  * accompanied this code).
  16  *
  17  * You should have received a copy of the GNU General Public License version
  18  * 2 along with this work; if not, write to the Free Software Foundation,
  19  * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
  20  *
  21  * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
  22  * or visit www.oracle.com if you need additional information or have any
  23  * questions.
  24  */
  25 
  26 package jdk.javadoc.internal.doclets.toolkit.util;
  27 
  28 import java.util.ArrayList;
  29 import java.util.Collections;
  30 import java.util.List;
  31 
  32 import javax.lang.model.element.Element;
  33 import javax.lang.model.element.ExecutableElement;
  34 import javax.lang.model.element.ModuleElement;

  35 import javax.lang.model.element.PackageElement;
  36 import javax.lang.model.element.TypeElement;
  37 import javax.lang.model.type.TypeMirror;
  38 
  39 import com.sun.source.doctree.AttributeTree;
  40 import com.sun.source.doctree.AttributeTree.ValueKind;
  41 import com.sun.source.doctree.AuthorTree;
  42 import com.sun.source.doctree.BlockTagTree;
  43 import com.sun.source.doctree.CommentTree;
  44 import com.sun.source.doctree.DeprecatedTree;
  45 import com.sun.source.doctree.DocCommentTree;
  46 import com.sun.source.doctree.DocTree;
  47 import com.sun.source.doctree.EndElementTree;
  48 import com.sun.source.doctree.EntityTree;
  49 import com.sun.source.doctree.IdentifierTree;
  50 import com.sun.source.doctree.InlineTagTree;
  51 import com.sun.source.doctree.LinkTree;
  52 import com.sun.source.doctree.LiteralTree;
  53 import com.sun.source.doctree.ParamTree;
  54 import com.sun.source.doctree.ProvidesTree;


 530         return (dtree.getKind() == THROWS || dtree.getKind() == EXCEPTION)
 531                 ? ((ThrowsTree)dtree).getExceptionName()
 532                 : null;
 533     }
 534 
 535     public IdentifierTree getName(DocTree dtree) {
 536         switch (dtree.getKind()) {
 537             case PARAM:
 538                 return ((ParamTree)dtree).getName();
 539             case SERIAL_FIELD:
 540                 return ((SerialFieldTree)dtree).getName();
 541             default:
 542                 return null;
 543             }
 544     }
 545 
 546     public List<? extends DocTree> getTags(BaseConfiguration c, DocTree dtree) {
 547         return new SimpleDocTreeVisitor<List<? extends DocTree>, Void>() {
 548             List<? extends DocTree> asList(String content) {
 549                 List<DocTree> out = new ArrayList<>();
 550                 out.add((TextTree)c.cmtUtils.makeTextTree(content));
 551                 return out;
 552             }
 553 
 554             @Override
 555             public List<? extends DocTree> visitAuthor(AuthorTree node, Void p) {
 556                 return node.getName();
 557             }
 558 
 559             @Override
 560             public List<? extends DocTree> visitComment(CommentTree node, Void p) {
 561                 return asList(node.getBody());
 562             }
 563 
 564             @Override
 565             public List<? extends DocTree> visitDeprecated(DeprecatedTree node, Void p) {
 566                 return node.getBody();
 567             }
 568 
 569             @Override
 570             public List<? extends DocTree> visitDocComment(DocCommentTree node, Void p) {


   1 /*
   2  * Copyright (c) 2015, 2019, Oracle and/or its affiliates. All rights reserved.
   3  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
   4  *
   5  * This code is free software; you can redistribute it and/or modify it
   6  * under the terms of the GNU General Public License version 2 only, as
   7  * published by the Free Software Foundation.  Oracle designates this
   8  * particular file as subject to the "Classpath" exception as provided
   9  * by Oracle in the LICENSE file that accompanied this code.
  10  *
  11  * This code is distributed in the hope that it will be useful, but WITHOUT
  12  * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
  13  * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
  14  * version 2 for more details (a copy is included in the LICENSE file that
  15  * accompanied this code).
  16  *
  17  * You should have received a copy of the GNU General Public License version
  18  * 2 along with this work; if not, write to the Free Software Foundation,
  19  * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
  20  *
  21  * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
  22  * or visit www.oracle.com if you need additional information or have any
  23  * questions.
  24  */
  25 
  26 package jdk.javadoc.internal.doclets.toolkit.util;
  27 
  28 import java.util.ArrayList;
  29 import java.util.Collections;
  30 import java.util.List;
  31 
  32 import javax.lang.model.element.Element;
  33 import javax.lang.model.element.ExecutableElement;
  34 import javax.lang.model.element.ModuleElement;
  35 import javax.lang.model.element.Name;
  36 import javax.lang.model.element.PackageElement;
  37 import javax.lang.model.element.TypeElement;
  38 import javax.lang.model.type.TypeMirror;
  39 
  40 import com.sun.source.doctree.AttributeTree;
  41 import com.sun.source.doctree.AttributeTree.ValueKind;
  42 import com.sun.source.doctree.AuthorTree;
  43 import com.sun.source.doctree.BlockTagTree;
  44 import com.sun.source.doctree.CommentTree;
  45 import com.sun.source.doctree.DeprecatedTree;
  46 import com.sun.source.doctree.DocCommentTree;
  47 import com.sun.source.doctree.DocTree;
  48 import com.sun.source.doctree.EndElementTree;
  49 import com.sun.source.doctree.EntityTree;
  50 import com.sun.source.doctree.IdentifierTree;
  51 import com.sun.source.doctree.InlineTagTree;
  52 import com.sun.source.doctree.LinkTree;
  53 import com.sun.source.doctree.LiteralTree;
  54 import com.sun.source.doctree.ParamTree;
  55 import com.sun.source.doctree.ProvidesTree;


 531         return (dtree.getKind() == THROWS || dtree.getKind() == EXCEPTION)
 532                 ? ((ThrowsTree)dtree).getExceptionName()
 533                 : null;
 534     }
 535 
 536     public IdentifierTree getName(DocTree dtree) {
 537         switch (dtree.getKind()) {
 538             case PARAM:
 539                 return ((ParamTree)dtree).getName();
 540             case SERIAL_FIELD:
 541                 return ((SerialFieldTree)dtree).getName();
 542             default:
 543                 return null;
 544             }
 545     }
 546 
 547     public List<? extends DocTree> getTags(BaseConfiguration c, DocTree dtree) {
 548         return new SimpleDocTreeVisitor<List<? extends DocTree>, Void>() {
 549             List<? extends DocTree> asList(String content) {
 550                 List<DocTree> out = new ArrayList<>();
 551                 out.add(c.cmtUtils.makeTextTree(content));
 552                 return out;
 553             }
 554 
 555             @Override
 556             public List<? extends DocTree> visitAuthor(AuthorTree node, Void p) {
 557                 return node.getName();
 558             }
 559 
 560             @Override
 561             public List<? extends DocTree> visitComment(CommentTree node, Void p) {
 562                 return asList(node.getBody());
 563             }
 564 
 565             @Override
 566             public List<? extends DocTree> visitDeprecated(DeprecatedTree node, Void p) {
 567                 return node.getBody();
 568             }
 569 
 570             @Override
 571             public List<? extends DocTree> visitDocComment(DocCommentTree node, Void p) {


< prev index next >