src/jdk.compiler/share/classes/com/sun/tools/javac/tree/DocTreeMaker.java
author mcimadamore
Fri, 08 Jun 2018 16:33:40 +0100
changeset 50468 4a5fd709e286
parent 48028 9e022f580a9d
child 52487 5d1d07b72f15
permissions -rw-r--r--
8204610: Compiler confused by parenthesized "this" in final fields assignments Summary: parenthesis are not skipped consistently in DA/DU, forward reference analysis Reviewed-by: vromero
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
14541
36f9d11fc9aa 7021614: extend com.sun.source API to support parsing javadoc comments
jjg
parents:
diff changeset
     1
/*
46184
f1325703ea85 8173425: Javadoc needs a new tag to specify the summary.
ksrini
parents: 42831
diff changeset
     2
 * Copyright (c) 2011, 2017, Oracle and/or its affiliates. All rights reserved.
14541
36f9d11fc9aa 7021614: extend com.sun.source API to support parsing javadoc comments
jjg
parents:
diff changeset
     3
 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
36f9d11fc9aa 7021614: extend com.sun.source API to support parsing javadoc comments
jjg
parents:
diff changeset
     4
 *
36f9d11fc9aa 7021614: extend com.sun.source API to support parsing javadoc comments
jjg
parents:
diff changeset
     5
 * This code is free software; you can redistribute it and/or modify it
36f9d11fc9aa 7021614: extend com.sun.source API to support parsing javadoc comments
jjg
parents:
diff changeset
     6
 * under the terms of the GNU General Public License version 2 only, as
36f9d11fc9aa 7021614: extend com.sun.source API to support parsing javadoc comments
jjg
parents:
diff changeset
     7
 * published by the Free Software Foundation.  Oracle designates this
36f9d11fc9aa 7021614: extend com.sun.source API to support parsing javadoc comments
jjg
parents:
diff changeset
     8
 * particular file as subject to the "Classpath" exception as provided
36f9d11fc9aa 7021614: extend com.sun.source API to support parsing javadoc comments
jjg
parents:
diff changeset
     9
 * by Oracle in the LICENSE file that accompanied this code.
36f9d11fc9aa 7021614: extend com.sun.source API to support parsing javadoc comments
jjg
parents:
diff changeset
    10
 *
36f9d11fc9aa 7021614: extend com.sun.source API to support parsing javadoc comments
jjg
parents:
diff changeset
    11
 * This code is distributed in the hope that it will be useful, but WITHOUT
36f9d11fc9aa 7021614: extend com.sun.source API to support parsing javadoc comments
jjg
parents:
diff changeset
    12
 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
36f9d11fc9aa 7021614: extend com.sun.source API to support parsing javadoc comments
jjg
parents:
diff changeset
    13
 * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
36f9d11fc9aa 7021614: extend com.sun.source API to support parsing javadoc comments
jjg
parents:
diff changeset
    14
 * version 2 for more details (a copy is included in the LICENSE file that
36f9d11fc9aa 7021614: extend com.sun.source API to support parsing javadoc comments
jjg
parents:
diff changeset
    15
 * accompanied this code).
36f9d11fc9aa 7021614: extend com.sun.source API to support parsing javadoc comments
jjg
parents:
diff changeset
    16
 *
36f9d11fc9aa 7021614: extend com.sun.source API to support parsing javadoc comments
jjg
parents:
diff changeset
    17
 * You should have received a copy of the GNU General Public License version
36f9d11fc9aa 7021614: extend com.sun.source API to support parsing javadoc comments
jjg
parents:
diff changeset
    18
 * 2 along with this work; if not, write to the Free Software Foundation,
36f9d11fc9aa 7021614: extend com.sun.source API to support parsing javadoc comments
jjg
parents:
diff changeset
    19
 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
36f9d11fc9aa 7021614: extend com.sun.source API to support parsing javadoc comments
jjg
parents:
diff changeset
    20
 *
36f9d11fc9aa 7021614: extend com.sun.source API to support parsing javadoc comments
jjg
parents:
diff changeset
    21
 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
36f9d11fc9aa 7021614: extend com.sun.source API to support parsing javadoc comments
jjg
parents:
diff changeset
    22
 * or visit www.oracle.com if you need additional information or have any
36f9d11fc9aa 7021614: extend com.sun.source API to support parsing javadoc comments
jjg
parents:
diff changeset
    23
 * questions.
36f9d11fc9aa 7021614: extend com.sun.source API to support parsing javadoc comments
jjg
parents:
diff changeset
    24
 */
36f9d11fc9aa 7021614: extend com.sun.source API to support parsing javadoc comments
jjg
parents:
diff changeset
    25
36f9d11fc9aa 7021614: extend com.sun.source API to support parsing javadoc comments
jjg
parents:
diff changeset
    26
package com.sun.tools.javac.tree;
36f9d11fc9aa 7021614: extend com.sun.source API to support parsing javadoc comments
jjg
parents:
diff changeset
    27
33360
d8ef08003d35 8078320: Improve DocTrees parsing.
ksrini
parents: 25874
diff changeset
    28
import java.text.BreakIterator;
d8ef08003d35 8078320: Improve DocTrees parsing.
ksrini
parents: 25874
diff changeset
    29
import java.util.ArrayList;
d8ef08003d35 8078320: Improve DocTrees parsing.
ksrini
parents: 25874
diff changeset
    30
import java.util.Collection;
48028
9e022f580a9d 8190552: Augment the Compiler API tree with APIs to represent HTML content
ksrini
parents: 47216
diff changeset
    31
import java.util.Collections;
33360
d8ef08003d35 8078320: Improve DocTrees parsing.
ksrini
parents: 25874
diff changeset
    32
import java.util.EnumSet;
35346
c0614a805fad 8146208: Add a public DocTreeFactory to the Compiler Tree API
jjg
parents: 34567
diff changeset
    33
import java.util.List;
33360
d8ef08003d35 8078320: Improve DocTrees parsing.
ksrini
parents: 25874
diff changeset
    34
import java.util.ListIterator;
d8ef08003d35 8078320: Improve DocTrees parsing.
ksrini
parents: 25874
diff changeset
    35
35346
c0614a805fad 8146208: Add a public DocTreeFactory to the Compiler Tree API
jjg
parents: 34567
diff changeset
    36
import javax.lang.model.element.Name;
c0614a805fad 8146208: Add a public DocTreeFactory to the Compiler Tree API
jjg
parents: 34567
diff changeset
    37
import javax.tools.Diagnostic;
c0614a805fad 8146208: Add a public DocTreeFactory to the Compiler Tree API
jjg
parents: 34567
diff changeset
    38
import javax.tools.JavaFileObject;
c0614a805fad 8146208: Add a public DocTreeFactory to the Compiler Tree API
jjg
parents: 34567
diff changeset
    39
14541
36f9d11fc9aa 7021614: extend com.sun.source API to support parsing javadoc comments
jjg
parents:
diff changeset
    40
import com.sun.source.doctree.AttributeTree.ValueKind;
48028
9e022f580a9d 8190552: Augment the Compiler API tree with APIs to represent HTML content
ksrini
parents: 47216
diff changeset
    41
import com.sun.source.doctree.DocCommentTree;
33360
d8ef08003d35 8078320: Improve DocTrees parsing.
ksrini
parents: 25874
diff changeset
    42
import com.sun.source.doctree.DocTree;
14541
36f9d11fc9aa 7021614: extend com.sun.source API to support parsing javadoc comments
jjg
parents:
diff changeset
    43
import com.sun.source.doctree.DocTree.Kind;
33360
d8ef08003d35 8078320: Improve DocTrees parsing.
ksrini
parents: 25874
diff changeset
    44
import com.sun.source.doctree.EndElementTree;
35346
c0614a805fad 8146208: Add a public DocTreeFactory to the Compiler Tree API
jjg
parents: 34567
diff changeset
    45
import com.sun.source.doctree.IdentifierTree;
c0614a805fad 8146208: Add a public DocTreeFactory to the Compiler Tree API
jjg
parents: 34567
diff changeset
    46
import com.sun.source.doctree.ReferenceTree;
33360
d8ef08003d35 8078320: Improve DocTrees parsing.
ksrini
parents: 25874
diff changeset
    47
import com.sun.source.doctree.StartElementTree;
33424
e6bd5406e2cf 8132096: Augment the Compiler Tree API to support the new Simplified Doclet API
ksrini
parents: 33360
diff changeset
    48
import com.sun.source.doctree.TextTree;
42831
feff6f296019 8160196: Module summary page should display information based on "api" or "detail" mode.
bpatel
parents: 41452
diff changeset
    49
import com.sun.source.doctree.ProvidesTree;
feff6f296019 8160196: Module summary page should display information based on "api" or "detail" mode.
bpatel
parents: 41452
diff changeset
    50
import com.sun.source.doctree.UsesTree;
35346
c0614a805fad 8146208: Add a public DocTreeFactory to the Compiler Tree API
jjg
parents: 34567
diff changeset
    51
import com.sun.source.util.DocTreeFactory;
33360
d8ef08003d35 8078320: Improve DocTrees parsing.
ksrini
parents: 25874
diff changeset
    52
import com.sun.tools.doclint.HtmlTag;
33424
e6bd5406e2cf 8132096: Augment the Compiler Tree API to support the new Simplified Doclet API
ksrini
parents: 33360
diff changeset
    53
import com.sun.tools.javac.api.JavacTrees;
35346
c0614a805fad 8146208: Add a public DocTreeFactory to the Compiler Tree API
jjg
parents: 34567
diff changeset
    54
import com.sun.tools.javac.parser.ParserFactory;
c0614a805fad 8146208: Add a public DocTreeFactory to the Compiler Tree API
jjg
parents: 34567
diff changeset
    55
import com.sun.tools.javac.parser.ReferenceParser;
14541
36f9d11fc9aa 7021614: extend com.sun.source API to support parsing javadoc comments
jjg
parents:
diff changeset
    56
import com.sun.tools.javac.parser.Tokens.Comment;
36276
37bd10863a8a 8150130: NPE building javafx docs with new doclet
ksrini
parents: 35346
diff changeset
    57
import com.sun.tools.javac.parser.Tokens.Comment.CommentStyle;
33360
d8ef08003d35 8078320: Improve DocTrees parsing.
ksrini
parents: 25874
diff changeset
    58
import com.sun.tools.javac.tree.DCTree.DCAttribute;
d8ef08003d35 8078320: Improve DocTrees parsing.
ksrini
parents: 25874
diff changeset
    59
import com.sun.tools.javac.tree.DCTree.DCAuthor;
d8ef08003d35 8078320: Improve DocTrees parsing.
ksrini
parents: 25874
diff changeset
    60
import com.sun.tools.javac.tree.DCTree.DCComment;
d8ef08003d35 8078320: Improve DocTrees parsing.
ksrini
parents: 25874
diff changeset
    61
import com.sun.tools.javac.tree.DCTree.DCDeprecated;
d8ef08003d35 8078320: Improve DocTrees parsing.
ksrini
parents: 25874
diff changeset
    62
import com.sun.tools.javac.tree.DCTree.DCDocComment;
d8ef08003d35 8078320: Improve DocTrees parsing.
ksrini
parents: 25874
diff changeset
    63
import com.sun.tools.javac.tree.DCTree.DCDocRoot;
48028
9e022f580a9d 8190552: Augment the Compiler API tree with APIs to represent HTML content
ksrini
parents: 47216
diff changeset
    64
import com.sun.tools.javac.tree.DCTree.DCDocType;
33360
d8ef08003d35 8078320: Improve DocTrees parsing.
ksrini
parents: 25874
diff changeset
    65
import com.sun.tools.javac.tree.DCTree.DCEndElement;
d8ef08003d35 8078320: Improve DocTrees parsing.
ksrini
parents: 25874
diff changeset
    66
import com.sun.tools.javac.tree.DCTree.DCEntity;
d8ef08003d35 8078320: Improve DocTrees parsing.
ksrini
parents: 25874
diff changeset
    67
import com.sun.tools.javac.tree.DCTree.DCErroneous;
37009
476d8d615222 8073100: [javadoc] Provide an ability to suppress document generation for specific elements.
ksrini
parents: 36276
diff changeset
    68
import com.sun.tools.javac.tree.DCTree.DCHidden;
33360
d8ef08003d35 8078320: Improve DocTrees parsing.
ksrini
parents: 25874
diff changeset
    69
import com.sun.tools.javac.tree.DCTree.DCIdentifier;
34567
c74f68484156 8144287: Enhance DocTree API to support @index javadoc tags.
ksrini
parents: 33424
diff changeset
    70
import com.sun.tools.javac.tree.DCTree.DCIndex;
33360
d8ef08003d35 8078320: Improve DocTrees parsing.
ksrini
parents: 25874
diff changeset
    71
import com.sun.tools.javac.tree.DCTree.DCInheritDoc;
d8ef08003d35 8078320: Improve DocTrees parsing.
ksrini
parents: 25874
diff changeset
    72
import com.sun.tools.javac.tree.DCTree.DCLink;
d8ef08003d35 8078320: Improve DocTrees parsing.
ksrini
parents: 25874
diff changeset
    73
import com.sun.tools.javac.tree.DCTree.DCLiteral;
d8ef08003d35 8078320: Improve DocTrees parsing.
ksrini
parents: 25874
diff changeset
    74
import com.sun.tools.javac.tree.DCTree.DCParam;
42831
feff6f296019 8160196: Module summary page should display information based on "api" or "detail" mode.
bpatel
parents: 41452
diff changeset
    75
import com.sun.tools.javac.tree.DCTree.DCProvides;
33360
d8ef08003d35 8078320: Improve DocTrees parsing.
ksrini
parents: 25874
diff changeset
    76
import com.sun.tools.javac.tree.DCTree.DCReference;
d8ef08003d35 8078320: Improve DocTrees parsing.
ksrini
parents: 25874
diff changeset
    77
import com.sun.tools.javac.tree.DCTree.DCReturn;
d8ef08003d35 8078320: Improve DocTrees parsing.
ksrini
parents: 25874
diff changeset
    78
import com.sun.tools.javac.tree.DCTree.DCSee;
d8ef08003d35 8078320: Improve DocTrees parsing.
ksrini
parents: 25874
diff changeset
    79
import com.sun.tools.javac.tree.DCTree.DCSerial;
d8ef08003d35 8078320: Improve DocTrees parsing.
ksrini
parents: 25874
diff changeset
    80
import com.sun.tools.javac.tree.DCTree.DCSerialData;
d8ef08003d35 8078320: Improve DocTrees parsing.
ksrini
parents: 25874
diff changeset
    81
import com.sun.tools.javac.tree.DCTree.DCSerialField;
d8ef08003d35 8078320: Improve DocTrees parsing.
ksrini
parents: 25874
diff changeset
    82
import com.sun.tools.javac.tree.DCTree.DCSince;
d8ef08003d35 8078320: Improve DocTrees parsing.
ksrini
parents: 25874
diff changeset
    83
import com.sun.tools.javac.tree.DCTree.DCStartElement;
46184
f1325703ea85 8173425: Javadoc needs a new tag to specify the summary.
ksrini
parents: 42831
diff changeset
    84
import com.sun.tools.javac.tree.DCTree.DCSummary;
33360
d8ef08003d35 8078320: Improve DocTrees parsing.
ksrini
parents: 25874
diff changeset
    85
import com.sun.tools.javac.tree.DCTree.DCText;
d8ef08003d35 8078320: Improve DocTrees parsing.
ksrini
parents: 25874
diff changeset
    86
import com.sun.tools.javac.tree.DCTree.DCThrows;
d8ef08003d35 8078320: Improve DocTrees parsing.
ksrini
parents: 25874
diff changeset
    87
import com.sun.tools.javac.tree.DCTree.DCUnknownBlockTag;
d8ef08003d35 8078320: Improve DocTrees parsing.
ksrini
parents: 25874
diff changeset
    88
import com.sun.tools.javac.tree.DCTree.DCUnknownInlineTag;
42831
feff6f296019 8160196: Module summary page should display information based on "api" or "detail" mode.
bpatel
parents: 41452
diff changeset
    89
import com.sun.tools.javac.tree.DCTree.DCUses;
33360
d8ef08003d35 8078320: Improve DocTrees parsing.
ksrini
parents: 25874
diff changeset
    90
import com.sun.tools.javac.tree.DCTree.DCValue;
d8ef08003d35 8078320: Improve DocTrees parsing.
ksrini
parents: 25874
diff changeset
    91
import com.sun.tools.javac.tree.DCTree.DCVersion;
14541
36f9d11fc9aa 7021614: extend com.sun.source API to support parsing javadoc comments
jjg
parents:
diff changeset
    92
import com.sun.tools.javac.util.Context;
35346
c0614a805fad 8146208: Add a public DocTreeFactory to the Compiler Tree API
jjg
parents: 34567
diff changeset
    93
import com.sun.tools.javac.util.DefinedBy;
c0614a805fad 8146208: Add a public DocTreeFactory to the Compiler Tree API
jjg
parents: 34567
diff changeset
    94
import com.sun.tools.javac.util.DefinedBy.Api;
14541
36f9d11fc9aa 7021614: extend com.sun.source API to support parsing javadoc comments
jjg
parents:
diff changeset
    95
import com.sun.tools.javac.util.DiagnosticSource;
36f9d11fc9aa 7021614: extend com.sun.source API to support parsing javadoc comments
jjg
parents:
diff changeset
    96
import com.sun.tools.javac.util.JCDiagnostic;
36f9d11fc9aa 7021614: extend com.sun.source API to support parsing javadoc comments
jjg
parents:
diff changeset
    97
import com.sun.tools.javac.util.JCDiagnostic.DiagnosticPosition;
33360
d8ef08003d35 8078320: Improve DocTrees parsing.
ksrini
parents: 25874
diff changeset
    98
import com.sun.tools.javac.util.ListBuffer;
d8ef08003d35 8078320: Improve DocTrees parsing.
ksrini
parents: 25874
diff changeset
    99
import com.sun.tools.javac.util.Pair;
14541
36f9d11fc9aa 7021614: extend com.sun.source API to support parsing javadoc comments
jjg
parents:
diff changeset
   100
import com.sun.tools.javac.util.Position;
36f9d11fc9aa 7021614: extend com.sun.source API to support parsing javadoc comments
jjg
parents:
diff changeset
   101
33360
d8ef08003d35 8078320: Improve DocTrees parsing.
ksrini
parents: 25874
diff changeset
   102
import static com.sun.tools.doclint.HtmlTag.*;
d8ef08003d35 8078320: Improve DocTrees parsing.
ksrini
parents: 25874
diff changeset
   103
14541
36f9d11fc9aa 7021614: extend com.sun.source API to support parsing javadoc comments
jjg
parents:
diff changeset
   104
/**
36f9d11fc9aa 7021614: extend com.sun.source API to support parsing javadoc comments
jjg
parents:
diff changeset
   105
 *
36f9d11fc9aa 7021614: extend com.sun.source API to support parsing javadoc comments
jjg
parents:
diff changeset
   106
 *  <p><b>This is NOT part of any supported API.
36f9d11fc9aa 7021614: extend com.sun.source API to support parsing javadoc comments
jjg
parents:
diff changeset
   107
 *  If you write code that depends on this, you do so at your own risk.
36f9d11fc9aa 7021614: extend com.sun.source API to support parsing javadoc comments
jjg
parents:
diff changeset
   108
 *  This code and its internal interfaces are subject to change or
36f9d11fc9aa 7021614: extend com.sun.source API to support parsing javadoc comments
jjg
parents:
diff changeset
   109
 *  deletion without notice.</b>
36f9d11fc9aa 7021614: extend com.sun.source API to support parsing javadoc comments
jjg
parents:
diff changeset
   110
 */
35346
c0614a805fad 8146208: Add a public DocTreeFactory to the Compiler Tree API
jjg
parents: 34567
diff changeset
   111
public class DocTreeMaker implements DocTreeFactory {
14541
36f9d11fc9aa 7021614: extend com.sun.source API to support parsing javadoc comments
jjg
parents:
diff changeset
   112
36f9d11fc9aa 7021614: extend com.sun.source API to support parsing javadoc comments
jjg
parents:
diff changeset
   113
    /** The context key for the tree factory. */
22163
3651128c74eb 8030244: Update langtools to use Diamond
briangoetz
parents: 14541
diff changeset
   114
    protected static final Context.Key<DocTreeMaker> treeMakerKey = new Context.Key<>();
14541
36f9d11fc9aa 7021614: extend com.sun.source API to support parsing javadoc comments
jjg
parents:
diff changeset
   115
33360
d8ef08003d35 8078320: Improve DocTrees parsing.
ksrini
parents: 25874
diff changeset
   116
    // A subset of block tags, which acts as sentence breakers, appearing
d8ef08003d35 8078320: Improve DocTrees parsing.
ksrini
parents: 25874
diff changeset
   117
    // anywhere but the zero'th position in the first sentence.
d8ef08003d35 8078320: Improve DocTrees parsing.
ksrini
parents: 25874
diff changeset
   118
    final EnumSet<HtmlTag> sentenceBreakTags;
d8ef08003d35 8078320: Improve DocTrees parsing.
ksrini
parents: 25874
diff changeset
   119
14541
36f9d11fc9aa 7021614: extend com.sun.source API to support parsing javadoc comments
jjg
parents:
diff changeset
   120
    /** Get the TreeMaker instance. */
36f9d11fc9aa 7021614: extend com.sun.source API to support parsing javadoc comments
jjg
parents:
diff changeset
   121
    public static DocTreeMaker instance(Context context) {
36f9d11fc9aa 7021614: extend com.sun.source API to support parsing javadoc comments
jjg
parents:
diff changeset
   122
        DocTreeMaker instance = context.get(treeMakerKey);
36f9d11fc9aa 7021614: extend com.sun.source API to support parsing javadoc comments
jjg
parents:
diff changeset
   123
        if (instance == null)
36f9d11fc9aa 7021614: extend com.sun.source API to support parsing javadoc comments
jjg
parents:
diff changeset
   124
            instance = new DocTreeMaker(context);
36f9d11fc9aa 7021614: extend com.sun.source API to support parsing javadoc comments
jjg
parents:
diff changeset
   125
        return instance;
36f9d11fc9aa 7021614: extend com.sun.source API to support parsing javadoc comments
jjg
parents:
diff changeset
   126
    }
36f9d11fc9aa 7021614: extend com.sun.source API to support parsing javadoc comments
jjg
parents:
diff changeset
   127
36f9d11fc9aa 7021614: extend com.sun.source API to support parsing javadoc comments
jjg
parents:
diff changeset
   128
    /** The position at which subsequent trees will be created.
36f9d11fc9aa 7021614: extend com.sun.source API to support parsing javadoc comments
jjg
parents:
diff changeset
   129
     */
36f9d11fc9aa 7021614: extend com.sun.source API to support parsing javadoc comments
jjg
parents:
diff changeset
   130
    public int pos = Position.NOPOS;
36f9d11fc9aa 7021614: extend com.sun.source API to support parsing javadoc comments
jjg
parents:
diff changeset
   131
36f9d11fc9aa 7021614: extend com.sun.source API to support parsing javadoc comments
jjg
parents:
diff changeset
   132
    /** Access to diag factory for ErroneousTrees. */
36f9d11fc9aa 7021614: extend com.sun.source API to support parsing javadoc comments
jjg
parents:
diff changeset
   133
    private final JCDiagnostic.Factory diags;
36f9d11fc9aa 7021614: extend com.sun.source API to support parsing javadoc comments
jjg
parents:
diff changeset
   134
33424
e6bd5406e2cf 8132096: Augment the Compiler Tree API to support the new Simplified Doclet API
ksrini
parents: 33360
diff changeset
   135
    private final JavacTrees trees;
e6bd5406e2cf 8132096: Augment the Compiler Tree API to support the new Simplified Doclet API
ksrini
parents: 33360
diff changeset
   136
35346
c0614a805fad 8146208: Add a public DocTreeFactory to the Compiler Tree API
jjg
parents: 34567
diff changeset
   137
    /** Utility class to parse reference signatures. */
c0614a805fad 8146208: Add a public DocTreeFactory to the Compiler Tree API
jjg
parents: 34567
diff changeset
   138
    private final ReferenceParser referenceParser;
c0614a805fad 8146208: Add a public DocTreeFactory to the Compiler Tree API
jjg
parents: 34567
diff changeset
   139
14541
36f9d11fc9aa 7021614: extend com.sun.source API to support parsing javadoc comments
jjg
parents:
diff changeset
   140
    /** Create a tree maker with NOPOS as initial position.
36f9d11fc9aa 7021614: extend com.sun.source API to support parsing javadoc comments
jjg
parents:
diff changeset
   141
     */
36f9d11fc9aa 7021614: extend com.sun.source API to support parsing javadoc comments
jjg
parents:
diff changeset
   142
    protected DocTreeMaker(Context context) {
36f9d11fc9aa 7021614: extend com.sun.source API to support parsing javadoc comments
jjg
parents:
diff changeset
   143
        context.put(treeMakerKey, this);
36f9d11fc9aa 7021614: extend com.sun.source API to support parsing javadoc comments
jjg
parents:
diff changeset
   144
        diags = JCDiagnostic.Factory.instance(context);
36f9d11fc9aa 7021614: extend com.sun.source API to support parsing javadoc comments
jjg
parents:
diff changeset
   145
        this.pos = Position.NOPOS;
33424
e6bd5406e2cf 8132096: Augment the Compiler Tree API to support the new Simplified Doclet API
ksrini
parents: 33360
diff changeset
   146
        trees = JavacTrees.instance(context);
35346
c0614a805fad 8146208: Add a public DocTreeFactory to the Compiler Tree API
jjg
parents: 34567
diff changeset
   147
        referenceParser = new ReferenceParser(ParserFactory.instance(context));
33360
d8ef08003d35 8078320: Improve DocTrees parsing.
ksrini
parents: 25874
diff changeset
   148
        sentenceBreakTags = EnumSet.of(H1, H2, H3, H4, H5, H6, PRE, P);
14541
36f9d11fc9aa 7021614: extend com.sun.source API to support parsing javadoc comments
jjg
parents:
diff changeset
   149
    }
36f9d11fc9aa 7021614: extend com.sun.source API to support parsing javadoc comments
jjg
parents:
diff changeset
   150
36f9d11fc9aa 7021614: extend com.sun.source API to support parsing javadoc comments
jjg
parents:
diff changeset
   151
    /** Reassign current position.
36f9d11fc9aa 7021614: extend com.sun.source API to support parsing javadoc comments
jjg
parents:
diff changeset
   152
     */
35346
c0614a805fad 8146208: Add a public DocTreeFactory to the Compiler Tree API
jjg
parents: 34567
diff changeset
   153
    @Override @DefinedBy(Api.COMPILER_TREE)
14541
36f9d11fc9aa 7021614: extend com.sun.source API to support parsing javadoc comments
jjg
parents:
diff changeset
   154
    public DocTreeMaker at(int pos) {
36f9d11fc9aa 7021614: extend com.sun.source API to support parsing javadoc comments
jjg
parents:
diff changeset
   155
        this.pos = pos;
36f9d11fc9aa 7021614: extend com.sun.source API to support parsing javadoc comments
jjg
parents:
diff changeset
   156
        return this;
36f9d11fc9aa 7021614: extend com.sun.source API to support parsing javadoc comments
jjg
parents:
diff changeset
   157
    }
36f9d11fc9aa 7021614: extend com.sun.source API to support parsing javadoc comments
jjg
parents:
diff changeset
   158
36f9d11fc9aa 7021614: extend com.sun.source API to support parsing javadoc comments
jjg
parents:
diff changeset
   159
    /** Reassign current position.
36f9d11fc9aa 7021614: extend com.sun.source API to support parsing javadoc comments
jjg
parents:
diff changeset
   160
     */
36f9d11fc9aa 7021614: extend com.sun.source API to support parsing javadoc comments
jjg
parents:
diff changeset
   161
    public DocTreeMaker at(DiagnosticPosition pos) {
36f9d11fc9aa 7021614: extend com.sun.source API to support parsing javadoc comments
jjg
parents:
diff changeset
   162
        this.pos = (pos == null ? Position.NOPOS : pos.getStartPosition());
36f9d11fc9aa 7021614: extend com.sun.source API to support parsing javadoc comments
jjg
parents:
diff changeset
   163
        return this;
36f9d11fc9aa 7021614: extend com.sun.source API to support parsing javadoc comments
jjg
parents:
diff changeset
   164
    }
36f9d11fc9aa 7021614: extend com.sun.source API to support parsing javadoc comments
jjg
parents:
diff changeset
   165
35346
c0614a805fad 8146208: Add a public DocTreeFactory to the Compiler Tree API
jjg
parents: 34567
diff changeset
   166
    @Override @DefinedBy(Api.COMPILER_TREE)
c0614a805fad 8146208: Add a public DocTreeFactory to the Compiler Tree API
jjg
parents: 34567
diff changeset
   167
    public DCAttribute newAttributeTree(javax.lang.model.element.Name name, ValueKind vkind, java.util.List<? extends DocTree> value) {
c0614a805fad 8146208: Add a public DocTreeFactory to the Compiler Tree API
jjg
parents: 34567
diff changeset
   168
        DCAttribute tree = new DCAttribute(name, vkind, cast(value));
14541
36f9d11fc9aa 7021614: extend com.sun.source API to support parsing javadoc comments
jjg
parents:
diff changeset
   169
        tree.pos = pos;
36f9d11fc9aa 7021614: extend com.sun.source API to support parsing javadoc comments
jjg
parents:
diff changeset
   170
        return tree;
36f9d11fc9aa 7021614: extend com.sun.source API to support parsing javadoc comments
jjg
parents:
diff changeset
   171
    }
36f9d11fc9aa 7021614: extend com.sun.source API to support parsing javadoc comments
jjg
parents:
diff changeset
   172
35346
c0614a805fad 8146208: Add a public DocTreeFactory to the Compiler Tree API
jjg
parents: 34567
diff changeset
   173
    @Override @DefinedBy(Api.COMPILER_TREE)
c0614a805fad 8146208: Add a public DocTreeFactory to the Compiler Tree API
jjg
parents: 34567
diff changeset
   174
    public DCAuthor newAuthorTree(java.util.List<? extends DocTree> name) {
c0614a805fad 8146208: Add a public DocTreeFactory to the Compiler Tree API
jjg
parents: 34567
diff changeset
   175
        DCAuthor tree = new DCAuthor(cast(name));
14541
36f9d11fc9aa 7021614: extend com.sun.source API to support parsing javadoc comments
jjg
parents:
diff changeset
   176
        tree.pos = pos;
36f9d11fc9aa 7021614: extend com.sun.source API to support parsing javadoc comments
jjg
parents:
diff changeset
   177
        return tree;
36f9d11fc9aa 7021614: extend com.sun.source API to support parsing javadoc comments
jjg
parents:
diff changeset
   178
    }
36f9d11fc9aa 7021614: extend com.sun.source API to support parsing javadoc comments
jjg
parents:
diff changeset
   179
35346
c0614a805fad 8146208: Add a public DocTreeFactory to the Compiler Tree API
jjg
parents: 34567
diff changeset
   180
    @Override @DefinedBy(Api.COMPILER_TREE)
c0614a805fad 8146208: Add a public DocTreeFactory to the Compiler Tree API
jjg
parents: 34567
diff changeset
   181
    public DCLiteral newCodeTree(TextTree text) {
c0614a805fad 8146208: Add a public DocTreeFactory to the Compiler Tree API
jjg
parents: 34567
diff changeset
   182
        DCLiteral tree = new DCLiteral(Kind.CODE, (DCText) text);
14541
36f9d11fc9aa 7021614: extend com.sun.source API to support parsing javadoc comments
jjg
parents:
diff changeset
   183
        tree.pos = pos;
36f9d11fc9aa 7021614: extend com.sun.source API to support parsing javadoc comments
jjg
parents:
diff changeset
   184
        return tree;
36f9d11fc9aa 7021614: extend com.sun.source API to support parsing javadoc comments
jjg
parents:
diff changeset
   185
    }
36f9d11fc9aa 7021614: extend com.sun.source API to support parsing javadoc comments
jjg
parents:
diff changeset
   186
35346
c0614a805fad 8146208: Add a public DocTreeFactory to the Compiler Tree API
jjg
parents: 34567
diff changeset
   187
    @Override @DefinedBy(Api.COMPILER_TREE)
c0614a805fad 8146208: Add a public DocTreeFactory to the Compiler Tree API
jjg
parents: 34567
diff changeset
   188
    public DCComment newCommentTree(String text) {
14541
36f9d11fc9aa 7021614: extend com.sun.source API to support parsing javadoc comments
jjg
parents:
diff changeset
   189
        DCComment tree = new DCComment(text);
36f9d11fc9aa 7021614: extend com.sun.source API to support parsing javadoc comments
jjg
parents:
diff changeset
   190
        tree.pos = pos;
36f9d11fc9aa 7021614: extend com.sun.source API to support parsing javadoc comments
jjg
parents:
diff changeset
   191
        return tree;
36f9d11fc9aa 7021614: extend com.sun.source API to support parsing javadoc comments
jjg
parents:
diff changeset
   192
    }
36f9d11fc9aa 7021614: extend com.sun.source API to support parsing javadoc comments
jjg
parents:
diff changeset
   193
35346
c0614a805fad 8146208: Add a public DocTreeFactory to the Compiler Tree API
jjg
parents: 34567
diff changeset
   194
    @Override @DefinedBy(Api.COMPILER_TREE)
c0614a805fad 8146208: Add a public DocTreeFactory to the Compiler Tree API
jjg
parents: 34567
diff changeset
   195
    public DCDeprecated newDeprecatedTree(List<? extends DocTree> text) {
c0614a805fad 8146208: Add a public DocTreeFactory to the Compiler Tree API
jjg
parents: 34567
diff changeset
   196
        DCDeprecated tree = new DCDeprecated(cast(text));
14541
36f9d11fc9aa 7021614: extend com.sun.source API to support parsing javadoc comments
jjg
parents:
diff changeset
   197
        tree.pos = pos;
36f9d11fc9aa 7021614: extend com.sun.source API to support parsing javadoc comments
jjg
parents:
diff changeset
   198
        return tree;
36f9d11fc9aa 7021614: extend com.sun.source API to support parsing javadoc comments
jjg
parents:
diff changeset
   199
    }
36f9d11fc9aa 7021614: extend com.sun.source API to support parsing javadoc comments
jjg
parents:
diff changeset
   200
48028
9e022f580a9d 8190552: Augment the Compiler API tree with APIs to represent HTML content
ksrini
parents: 47216
diff changeset
   201
    @Override @DefinedBy(Api.COMPILER_TREE)
9e022f580a9d 8190552: Augment the Compiler API tree with APIs to represent HTML content
ksrini
parents: 47216
diff changeset
   202
    public DCDocComment newDocCommentTree(List<? extends DocTree> fullBody, List<? extends DocTree> tags) {
33360
d8ef08003d35 8078320: Improve DocTrees parsing.
ksrini
parents: 25874
diff changeset
   203
        Pair<List<DCTree>, List<DCTree>> pair = splitBody(fullBody);
48028
9e022f580a9d 8190552: Augment the Compiler API tree with APIs to represent HTML content
ksrini
parents: 47216
diff changeset
   204
        List<DCTree> preamble = Collections.emptyList();
9e022f580a9d 8190552: Augment the Compiler API tree with APIs to represent HTML content
ksrini
parents: 47216
diff changeset
   205
        List<DCTree> postamble = Collections.emptyList();
9e022f580a9d 8190552: Augment the Compiler API tree with APIs to represent HTML content
ksrini
parents: 47216
diff changeset
   206
9e022f580a9d 8190552: Augment the Compiler API tree with APIs to represent HTML content
ksrini
parents: 47216
diff changeset
   207
        return newDocCommentTree(fullBody, tags, preamble, postamble);
9e022f580a9d 8190552: Augment the Compiler API tree with APIs to represent HTML content
ksrini
parents: 47216
diff changeset
   208
    }
9e022f580a9d 8190552: Augment the Compiler API tree with APIs to represent HTML content
ksrini
parents: 47216
diff changeset
   209
9e022f580a9d 8190552: Augment the Compiler API tree with APIs to represent HTML content
ksrini
parents: 47216
diff changeset
   210
    public DCDocComment newDocCommentTree(Comment comment,
9e022f580a9d 8190552: Augment the Compiler API tree with APIs to represent HTML content
ksrini
parents: 47216
diff changeset
   211
                                          List<? extends DocTree> fullBody,
9e022f580a9d 8190552: Augment the Compiler API tree with APIs to represent HTML content
ksrini
parents: 47216
diff changeset
   212
                                          List<? extends DocTree> tags,
9e022f580a9d 8190552: Augment the Compiler API tree with APIs to represent HTML content
ksrini
parents: 47216
diff changeset
   213
                                          List<? extends DocTree> preamble,
9e022f580a9d 8190552: Augment the Compiler API tree with APIs to represent HTML content
ksrini
parents: 47216
diff changeset
   214
                                          List<? extends DocTree> postamble) {
9e022f580a9d 8190552: Augment the Compiler API tree with APIs to represent HTML content
ksrini
parents: 47216
diff changeset
   215
        Pair<List<DCTree>, List<DCTree>> pair = splitBody(fullBody);
9e022f580a9d 8190552: Augment the Compiler API tree with APIs to represent HTML content
ksrini
parents: 47216
diff changeset
   216
        DCDocComment tree = new DCDocComment(comment, cast(fullBody), pair.fst, pair.snd,
9e022f580a9d 8190552: Augment the Compiler API tree with APIs to represent HTML content
ksrini
parents: 47216
diff changeset
   217
                cast(tags), cast(preamble), cast(postamble));
33424
e6bd5406e2cf 8132096: Augment the Compiler Tree API to support the new Simplified Doclet API
ksrini
parents: 33360
diff changeset
   218
        tree.pos = pos;
e6bd5406e2cf 8132096: Augment the Compiler Tree API to support the new Simplified Doclet API
ksrini
parents: 33360
diff changeset
   219
        return tree;
e6bd5406e2cf 8132096: Augment the Compiler Tree API to support the new Simplified Doclet API
ksrini
parents: 33360
diff changeset
   220
    }
e6bd5406e2cf 8132096: Augment the Compiler Tree API to support the new Simplified Doclet API
ksrini
parents: 33360
diff changeset
   221
e6bd5406e2cf 8132096: Augment the Compiler Tree API to support the new Simplified Doclet API
ksrini
parents: 33360
diff changeset
   222
    /*
e6bd5406e2cf 8132096: Augment the Compiler Tree API to support the new Simplified Doclet API
ksrini
parents: 33360
diff changeset
   223
     * Primarily to produce a DocCommenTree when given a
e6bd5406e2cf 8132096: Augment the Compiler Tree API to support the new Simplified Doclet API
ksrini
parents: 33360
diff changeset
   224
     * first sentence and a body, this is useful, in cases
e6bd5406e2cf 8132096: Augment the Compiler Tree API to support the new Simplified Doclet API
ksrini
parents: 33360
diff changeset
   225
     * where the trees are being synthesized by a tool.
e6bd5406e2cf 8132096: Augment the Compiler Tree API to support the new Simplified Doclet API
ksrini
parents: 33360
diff changeset
   226
     */
35346
c0614a805fad 8146208: Add a public DocTreeFactory to the Compiler Tree API
jjg
parents: 34567
diff changeset
   227
    @Override @DefinedBy(Api.COMPILER_TREE)
48028
9e022f580a9d 8190552: Augment the Compiler API tree with APIs to represent HTML content
ksrini
parents: 47216
diff changeset
   228
    public DCDocComment newDocCommentTree(List<? extends DocTree> fullBody,
9e022f580a9d 8190552: Augment the Compiler API tree with APIs to represent HTML content
ksrini
parents: 47216
diff changeset
   229
                                          List<? extends DocTree> tags,
9e022f580a9d 8190552: Augment the Compiler API tree with APIs to represent HTML content
ksrini
parents: 47216
diff changeset
   230
                                          List<? extends DocTree> preamble,
9e022f580a9d 8190552: Augment the Compiler API tree with APIs to represent HTML content
ksrini
parents: 47216
diff changeset
   231
                                          List<? extends DocTree> postamble) {
33424
e6bd5406e2cf 8132096: Augment the Compiler Tree API to support the new Simplified Doclet API
ksrini
parents: 33360
diff changeset
   232
        ListBuffer<DCTree> lb = new ListBuffer<>();
41452
ddaef4bba083 8165991: Fix DocTreeFactory newDocCommentTree
ksrini
parents: 37009
diff changeset
   233
        lb.addAll(cast(fullBody));
ddaef4bba083 8165991: Fix DocTreeFactory newDocCommentTree
ksrini
parents: 37009
diff changeset
   234
        List<DCTree> fBody = lb.toList();
36276
37bd10863a8a 8150130: NPE building javafx docs with new doclet
ksrini
parents: 35346
diff changeset
   235
37bd10863a8a 8150130: NPE building javafx docs with new doclet
ksrini
parents: 35346
diff changeset
   236
        // A dummy comment to keep the diagnostics logic happy.
37bd10863a8a 8150130: NPE building javafx docs with new doclet
ksrini
parents: 35346
diff changeset
   237
        Comment c = new Comment() {
37bd10863a8a 8150130: NPE building javafx docs with new doclet
ksrini
parents: 35346
diff changeset
   238
            @Override
37bd10863a8a 8150130: NPE building javafx docs with new doclet
ksrini
parents: 35346
diff changeset
   239
            public String getText() {
37bd10863a8a 8150130: NPE building javafx docs with new doclet
ksrini
parents: 35346
diff changeset
   240
                return null;
37bd10863a8a 8150130: NPE building javafx docs with new doclet
ksrini
parents: 35346
diff changeset
   241
            }
37bd10863a8a 8150130: NPE building javafx docs with new doclet
ksrini
parents: 35346
diff changeset
   242
37bd10863a8a 8150130: NPE building javafx docs with new doclet
ksrini
parents: 35346
diff changeset
   243
            @Override
37bd10863a8a 8150130: NPE building javafx docs with new doclet
ksrini
parents: 35346
diff changeset
   244
            public int getSourcePos(int index) {
37bd10863a8a 8150130: NPE building javafx docs with new doclet
ksrini
parents: 35346
diff changeset
   245
                return Position.NOPOS;
37bd10863a8a 8150130: NPE building javafx docs with new doclet
ksrini
parents: 35346
diff changeset
   246
            }
37bd10863a8a 8150130: NPE building javafx docs with new doclet
ksrini
parents: 35346
diff changeset
   247
37bd10863a8a 8150130: NPE building javafx docs with new doclet
ksrini
parents: 35346
diff changeset
   248
            @Override
37bd10863a8a 8150130: NPE building javafx docs with new doclet
ksrini
parents: 35346
diff changeset
   249
            public CommentStyle getStyle() {
37bd10863a8a 8150130: NPE building javafx docs with new doclet
ksrini
parents: 35346
diff changeset
   250
                return CommentStyle.JAVADOC;
37bd10863a8a 8150130: NPE building javafx docs with new doclet
ksrini
parents: 35346
diff changeset
   251
            }
37bd10863a8a 8150130: NPE building javafx docs with new doclet
ksrini
parents: 35346
diff changeset
   252
37bd10863a8a 8150130: NPE building javafx docs with new doclet
ksrini
parents: 35346
diff changeset
   253
            @Override
37bd10863a8a 8150130: NPE building javafx docs with new doclet
ksrini
parents: 35346
diff changeset
   254
            public boolean isDeprecated() {
37bd10863a8a 8150130: NPE building javafx docs with new doclet
ksrini
parents: 35346
diff changeset
   255
                return false;
37bd10863a8a 8150130: NPE building javafx docs with new doclet
ksrini
parents: 35346
diff changeset
   256
            }
37bd10863a8a 8150130: NPE building javafx docs with new doclet
ksrini
parents: 35346
diff changeset
   257
        };
41452
ddaef4bba083 8165991: Fix DocTreeFactory newDocCommentTree
ksrini
parents: 37009
diff changeset
   258
        Pair<List<DCTree>, List<DCTree>> pair = splitBody(fullBody);
48028
9e022f580a9d 8190552: Augment the Compiler API tree with APIs to represent HTML content
ksrini
parents: 47216
diff changeset
   259
        DCDocComment tree = new DCDocComment(c, fBody, pair.fst, pair.snd, cast(tags),
9e022f580a9d 8190552: Augment the Compiler API tree with APIs to represent HTML content
ksrini
parents: 47216
diff changeset
   260
                                             cast(preamble), cast(postamble));
14541
36f9d11fc9aa 7021614: extend com.sun.source API to support parsing javadoc comments
jjg
parents:
diff changeset
   261
        return tree;
36f9d11fc9aa 7021614: extend com.sun.source API to support parsing javadoc comments
jjg
parents:
diff changeset
   262
    }
36f9d11fc9aa 7021614: extend com.sun.source API to support parsing javadoc comments
jjg
parents:
diff changeset
   263
35346
c0614a805fad 8146208: Add a public DocTreeFactory to the Compiler Tree API
jjg
parents: 34567
diff changeset
   264
    @Override @DefinedBy(Api.COMPILER_TREE)
c0614a805fad 8146208: Add a public DocTreeFactory to the Compiler Tree API
jjg
parents: 34567
diff changeset
   265
    public DCDocRoot newDocRootTree() {
14541
36f9d11fc9aa 7021614: extend com.sun.source API to support parsing javadoc comments
jjg
parents:
diff changeset
   266
        DCDocRoot tree = new DCDocRoot();
36f9d11fc9aa 7021614: extend com.sun.source API to support parsing javadoc comments
jjg
parents:
diff changeset
   267
        tree.pos = pos;
36f9d11fc9aa 7021614: extend com.sun.source API to support parsing javadoc comments
jjg
parents:
diff changeset
   268
        return tree;
36f9d11fc9aa 7021614: extend com.sun.source API to support parsing javadoc comments
jjg
parents:
diff changeset
   269
    }
36f9d11fc9aa 7021614: extend com.sun.source API to support parsing javadoc comments
jjg
parents:
diff changeset
   270
35346
c0614a805fad 8146208: Add a public DocTreeFactory to the Compiler Tree API
jjg
parents: 34567
diff changeset
   271
    @Override @DefinedBy(Api.COMPILER_TREE)
48028
9e022f580a9d 8190552: Augment the Compiler API tree with APIs to represent HTML content
ksrini
parents: 47216
diff changeset
   272
    public DCDocType newDocTypeTree(String text) {
9e022f580a9d 8190552: Augment the Compiler API tree with APIs to represent HTML content
ksrini
parents: 47216
diff changeset
   273
        DCDocType tree = new DCDocType(text);
9e022f580a9d 8190552: Augment the Compiler API tree with APIs to represent HTML content
ksrini
parents: 47216
diff changeset
   274
        tree.pos = pos;
9e022f580a9d 8190552: Augment the Compiler API tree with APIs to represent HTML content
ksrini
parents: 47216
diff changeset
   275
        return tree;
9e022f580a9d 8190552: Augment the Compiler API tree with APIs to represent HTML content
ksrini
parents: 47216
diff changeset
   276
    }
9e022f580a9d 8190552: Augment the Compiler API tree with APIs to represent HTML content
ksrini
parents: 47216
diff changeset
   277
9e022f580a9d 8190552: Augment the Compiler API tree with APIs to represent HTML content
ksrini
parents: 47216
diff changeset
   278
    @Override @DefinedBy(Api.COMPILER_TREE)
35346
c0614a805fad 8146208: Add a public DocTreeFactory to the Compiler Tree API
jjg
parents: 34567
diff changeset
   279
    public DCEndElement newEndElementTree(Name name) {
14541
36f9d11fc9aa 7021614: extend com.sun.source API to support parsing javadoc comments
jjg
parents:
diff changeset
   280
        DCEndElement tree = new DCEndElement(name);
36f9d11fc9aa 7021614: extend com.sun.source API to support parsing javadoc comments
jjg
parents:
diff changeset
   281
        tree.pos = pos;
36f9d11fc9aa 7021614: extend com.sun.source API to support parsing javadoc comments
jjg
parents:
diff changeset
   282
        return tree;
36f9d11fc9aa 7021614: extend com.sun.source API to support parsing javadoc comments
jjg
parents:
diff changeset
   283
    }
36f9d11fc9aa 7021614: extend com.sun.source API to support parsing javadoc comments
jjg
parents:
diff changeset
   284
35346
c0614a805fad 8146208: Add a public DocTreeFactory to the Compiler Tree API
jjg
parents: 34567
diff changeset
   285
    @Override @DefinedBy(Api.COMPILER_TREE)
c0614a805fad 8146208: Add a public DocTreeFactory to the Compiler Tree API
jjg
parents: 34567
diff changeset
   286
    public DCEntity newEntityTree(Name name) {
14541
36f9d11fc9aa 7021614: extend com.sun.source API to support parsing javadoc comments
jjg
parents:
diff changeset
   287
        DCEntity tree = new DCEntity(name);
36f9d11fc9aa 7021614: extend com.sun.source API to support parsing javadoc comments
jjg
parents:
diff changeset
   288
        tree.pos = pos;
36f9d11fc9aa 7021614: extend com.sun.source API to support parsing javadoc comments
jjg
parents:
diff changeset
   289
        return tree;
36f9d11fc9aa 7021614: extend com.sun.source API to support parsing javadoc comments
jjg
parents:
diff changeset
   290
    }
36f9d11fc9aa 7021614: extend com.sun.source API to support parsing javadoc comments
jjg
parents:
diff changeset
   291
35346
c0614a805fad 8146208: Add a public DocTreeFactory to the Compiler Tree API
jjg
parents: 34567
diff changeset
   292
    @Override @DefinedBy(Api.COMPILER_TREE)
c0614a805fad 8146208: Add a public DocTreeFactory to the Compiler Tree API
jjg
parents: 34567
diff changeset
   293
    public DCErroneous newErroneousTree(String text, Diagnostic<JavaFileObject> diag) {
c0614a805fad 8146208: Add a public DocTreeFactory to the Compiler Tree API
jjg
parents: 34567
diff changeset
   294
        DCErroneous tree = new DCErroneous(text, (JCDiagnostic) diag);
c0614a805fad 8146208: Add a public DocTreeFactory to the Compiler Tree API
jjg
parents: 34567
diff changeset
   295
        tree.pos = pos;
c0614a805fad 8146208: Add a public DocTreeFactory to the Compiler Tree API
jjg
parents: 34567
diff changeset
   296
        return tree;
c0614a805fad 8146208: Add a public DocTreeFactory to the Compiler Tree API
jjg
parents: 34567
diff changeset
   297
    }
c0614a805fad 8146208: Add a public DocTreeFactory to the Compiler Tree API
jjg
parents: 34567
diff changeset
   298
c0614a805fad 8146208: Add a public DocTreeFactory to the Compiler Tree API
jjg
parents: 34567
diff changeset
   299
    public DCErroneous newErroneousTree(String text, DiagnosticSource diagSource, String code, Object... args) {
14541
36f9d11fc9aa 7021614: extend com.sun.source API to support parsing javadoc comments
jjg
parents:
diff changeset
   300
        DCErroneous tree = new DCErroneous(text, diags, diagSource, code, args);
36f9d11fc9aa 7021614: extend com.sun.source API to support parsing javadoc comments
jjg
parents:
diff changeset
   301
        tree.pos = pos;
36f9d11fc9aa 7021614: extend com.sun.source API to support parsing javadoc comments
jjg
parents:
diff changeset
   302
        return tree;
36f9d11fc9aa 7021614: extend com.sun.source API to support parsing javadoc comments
jjg
parents:
diff changeset
   303
    }
36f9d11fc9aa 7021614: extend com.sun.source API to support parsing javadoc comments
jjg
parents:
diff changeset
   304
35346
c0614a805fad 8146208: Add a public DocTreeFactory to the Compiler Tree API
jjg
parents: 34567
diff changeset
   305
    @Override @DefinedBy(Api.COMPILER_TREE)
c0614a805fad 8146208: Add a public DocTreeFactory to the Compiler Tree API
jjg
parents: 34567
diff changeset
   306
    public DCThrows newExceptionTree(ReferenceTree name, List<? extends DocTree> description) {
c0614a805fad 8146208: Add a public DocTreeFactory to the Compiler Tree API
jjg
parents: 34567
diff changeset
   307
        // TODO: verify the reference is just to a type (not a field or method)
c0614a805fad 8146208: Add a public DocTreeFactory to the Compiler Tree API
jjg
parents: 34567
diff changeset
   308
        DCThrows tree = new DCThrows(Kind.EXCEPTION, (DCReference) name, cast(description));
14541
36f9d11fc9aa 7021614: extend com.sun.source API to support parsing javadoc comments
jjg
parents:
diff changeset
   309
        tree.pos = pos;
36f9d11fc9aa 7021614: extend com.sun.source API to support parsing javadoc comments
jjg
parents:
diff changeset
   310
        return tree;
36f9d11fc9aa 7021614: extend com.sun.source API to support parsing javadoc comments
jjg
parents:
diff changeset
   311
    }
36f9d11fc9aa 7021614: extend com.sun.source API to support parsing javadoc comments
jjg
parents:
diff changeset
   312
35346
c0614a805fad 8146208: Add a public DocTreeFactory to the Compiler Tree API
jjg
parents: 34567
diff changeset
   313
    @Override @DefinedBy(Api.COMPILER_TREE)
37009
476d8d615222 8073100: [javadoc] Provide an ability to suppress document generation for specific elements.
ksrini
parents: 36276
diff changeset
   314
    public DCHidden newHiddenTree(List<? extends DocTree> text) {
476d8d615222 8073100: [javadoc] Provide an ability to suppress document generation for specific elements.
ksrini
parents: 36276
diff changeset
   315
        DCHidden tree = new DCHidden(cast(text));
476d8d615222 8073100: [javadoc] Provide an ability to suppress document generation for specific elements.
ksrini
parents: 36276
diff changeset
   316
        tree.pos = pos;
476d8d615222 8073100: [javadoc] Provide an ability to suppress document generation for specific elements.
ksrini
parents: 36276
diff changeset
   317
        return tree;
476d8d615222 8073100: [javadoc] Provide an ability to suppress document generation for specific elements.
ksrini
parents: 36276
diff changeset
   318
    }
476d8d615222 8073100: [javadoc] Provide an ability to suppress document generation for specific elements.
ksrini
parents: 36276
diff changeset
   319
476d8d615222 8073100: [javadoc] Provide an ability to suppress document generation for specific elements.
ksrini
parents: 36276
diff changeset
   320
    @Override @DefinedBy(Api.COMPILER_TREE)
35346
c0614a805fad 8146208: Add a public DocTreeFactory to the Compiler Tree API
jjg
parents: 34567
diff changeset
   321
    public DCIdentifier newIdentifierTree(Name name) {
14541
36f9d11fc9aa 7021614: extend com.sun.source API to support parsing javadoc comments
jjg
parents:
diff changeset
   322
        DCIdentifier tree = new DCIdentifier(name);
36f9d11fc9aa 7021614: extend com.sun.source API to support parsing javadoc comments
jjg
parents:
diff changeset
   323
        tree.pos = pos;
36f9d11fc9aa 7021614: extend com.sun.source API to support parsing javadoc comments
jjg
parents:
diff changeset
   324
        return tree;
36f9d11fc9aa 7021614: extend com.sun.source API to support parsing javadoc comments
jjg
parents:
diff changeset
   325
    }
36f9d11fc9aa 7021614: extend com.sun.source API to support parsing javadoc comments
jjg
parents:
diff changeset
   326
35346
c0614a805fad 8146208: Add a public DocTreeFactory to the Compiler Tree API
jjg
parents: 34567
diff changeset
   327
    @Override @DefinedBy(Api.COMPILER_TREE)
c0614a805fad 8146208: Add a public DocTreeFactory to the Compiler Tree API
jjg
parents: 34567
diff changeset
   328
    public DCIndex newIndexTree(DocTree term, List<? extends DocTree> description) {
c0614a805fad 8146208: Add a public DocTreeFactory to the Compiler Tree API
jjg
parents: 34567
diff changeset
   329
        DCIndex tree = new DCIndex((DCTree) term, cast(description));
34567
c74f68484156 8144287: Enhance DocTree API to support @index javadoc tags.
ksrini
parents: 33424
diff changeset
   330
        tree.pos = pos;
c74f68484156 8144287: Enhance DocTree API to support @index javadoc tags.
ksrini
parents: 33424
diff changeset
   331
        return tree;
c74f68484156 8144287: Enhance DocTree API to support @index javadoc tags.
ksrini
parents: 33424
diff changeset
   332
    }
c74f68484156 8144287: Enhance DocTree API to support @index javadoc tags.
ksrini
parents: 33424
diff changeset
   333
35346
c0614a805fad 8146208: Add a public DocTreeFactory to the Compiler Tree API
jjg
parents: 34567
diff changeset
   334
    @Override @DefinedBy(Api.COMPILER_TREE)
c0614a805fad 8146208: Add a public DocTreeFactory to the Compiler Tree API
jjg
parents: 34567
diff changeset
   335
    public DCInheritDoc newInheritDocTree() {
14541
36f9d11fc9aa 7021614: extend com.sun.source API to support parsing javadoc comments
jjg
parents:
diff changeset
   336
        DCInheritDoc tree = new DCInheritDoc();
36f9d11fc9aa 7021614: extend com.sun.source API to support parsing javadoc comments
jjg
parents:
diff changeset
   337
        tree.pos = pos;
36f9d11fc9aa 7021614: extend com.sun.source API to support parsing javadoc comments
jjg
parents:
diff changeset
   338
        return tree;
36f9d11fc9aa 7021614: extend com.sun.source API to support parsing javadoc comments
jjg
parents:
diff changeset
   339
    }
36f9d11fc9aa 7021614: extend com.sun.source API to support parsing javadoc comments
jjg
parents:
diff changeset
   340
35346
c0614a805fad 8146208: Add a public DocTreeFactory to the Compiler Tree API
jjg
parents: 34567
diff changeset
   341
    @Override @DefinedBy(Api.COMPILER_TREE)
c0614a805fad 8146208: Add a public DocTreeFactory to the Compiler Tree API
jjg
parents: 34567
diff changeset
   342
    public DCLink newLinkTree(ReferenceTree ref, List<? extends DocTree> label) {
c0614a805fad 8146208: Add a public DocTreeFactory to the Compiler Tree API
jjg
parents: 34567
diff changeset
   343
        DCLink tree = new DCLink(Kind.LINK, (DCReference) ref, cast(label));
14541
36f9d11fc9aa 7021614: extend com.sun.source API to support parsing javadoc comments
jjg
parents:
diff changeset
   344
        tree.pos = pos;
36f9d11fc9aa 7021614: extend com.sun.source API to support parsing javadoc comments
jjg
parents:
diff changeset
   345
        return tree;
36f9d11fc9aa 7021614: extend com.sun.source API to support parsing javadoc comments
jjg
parents:
diff changeset
   346
    }
36f9d11fc9aa 7021614: extend com.sun.source API to support parsing javadoc comments
jjg
parents:
diff changeset
   347
35346
c0614a805fad 8146208: Add a public DocTreeFactory to the Compiler Tree API
jjg
parents: 34567
diff changeset
   348
    @Override @DefinedBy(Api.COMPILER_TREE)
c0614a805fad 8146208: Add a public DocTreeFactory to the Compiler Tree API
jjg
parents: 34567
diff changeset
   349
    public DCLink newLinkPlainTree(ReferenceTree ref, List<? extends DocTree> label) {
c0614a805fad 8146208: Add a public DocTreeFactory to the Compiler Tree API
jjg
parents: 34567
diff changeset
   350
        DCLink tree = new DCLink(Kind.LINK_PLAIN, (DCReference) ref, cast(label));
c0614a805fad 8146208: Add a public DocTreeFactory to the Compiler Tree API
jjg
parents: 34567
diff changeset
   351
        tree.pos = pos;
c0614a805fad 8146208: Add a public DocTreeFactory to the Compiler Tree API
jjg
parents: 34567
diff changeset
   352
        return tree;
c0614a805fad 8146208: Add a public DocTreeFactory to the Compiler Tree API
jjg
parents: 34567
diff changeset
   353
    }
c0614a805fad 8146208: Add a public DocTreeFactory to the Compiler Tree API
jjg
parents: 34567
diff changeset
   354
c0614a805fad 8146208: Add a public DocTreeFactory to the Compiler Tree API
jjg
parents: 34567
diff changeset
   355
    @Override @DefinedBy(Api.COMPILER_TREE)
c0614a805fad 8146208: Add a public DocTreeFactory to the Compiler Tree API
jjg
parents: 34567
diff changeset
   356
    public DCLiteral newLiteralTree(TextTree text) {
c0614a805fad 8146208: Add a public DocTreeFactory to the Compiler Tree API
jjg
parents: 34567
diff changeset
   357
        DCLiteral tree = new DCLiteral(Kind.LITERAL, (DCText) text);
14541
36f9d11fc9aa 7021614: extend com.sun.source API to support parsing javadoc comments
jjg
parents:
diff changeset
   358
        tree.pos = pos;
36f9d11fc9aa 7021614: extend com.sun.source API to support parsing javadoc comments
jjg
parents:
diff changeset
   359
        return tree;
36f9d11fc9aa 7021614: extend com.sun.source API to support parsing javadoc comments
jjg
parents:
diff changeset
   360
    }
36f9d11fc9aa 7021614: extend com.sun.source API to support parsing javadoc comments
jjg
parents:
diff changeset
   361
35346
c0614a805fad 8146208: Add a public DocTreeFactory to the Compiler Tree API
jjg
parents: 34567
diff changeset
   362
    @Override @DefinedBy(Api.COMPILER_TREE)
c0614a805fad 8146208: Add a public DocTreeFactory to the Compiler Tree API
jjg
parents: 34567
diff changeset
   363
    public DCParam newParamTree(boolean isTypeParameter, IdentifierTree name, List<? extends DocTree> description) {
c0614a805fad 8146208: Add a public DocTreeFactory to the Compiler Tree API
jjg
parents: 34567
diff changeset
   364
        DCParam tree = new DCParam(isTypeParameter, (DCIdentifier) name, cast(description));
14541
36f9d11fc9aa 7021614: extend com.sun.source API to support parsing javadoc comments
jjg
parents:
diff changeset
   365
        tree.pos = pos;
36f9d11fc9aa 7021614: extend com.sun.source API to support parsing javadoc comments
jjg
parents:
diff changeset
   366
        return tree;
36f9d11fc9aa 7021614: extend com.sun.source API to support parsing javadoc comments
jjg
parents:
diff changeset
   367
    }
36f9d11fc9aa 7021614: extend com.sun.source API to support parsing javadoc comments
jjg
parents:
diff changeset
   368
35346
c0614a805fad 8146208: Add a public DocTreeFactory to the Compiler Tree API
jjg
parents: 34567
diff changeset
   369
    @Override @DefinedBy(Api.COMPILER_TREE)
42831
feff6f296019 8160196: Module summary page should display information based on "api" or "detail" mode.
bpatel
parents: 41452
diff changeset
   370
    public DCProvides newProvidesTree(ReferenceTree name, List<? extends DocTree> description) {
feff6f296019 8160196: Module summary page should display information based on "api" or "detail" mode.
bpatel
parents: 41452
diff changeset
   371
        DCProvides tree = new DCProvides((DCReference) name, cast(description));
feff6f296019 8160196: Module summary page should display information based on "api" or "detail" mode.
bpatel
parents: 41452
diff changeset
   372
        tree.pos = pos;
feff6f296019 8160196: Module summary page should display information based on "api" or "detail" mode.
bpatel
parents: 41452
diff changeset
   373
        return tree;
feff6f296019 8160196: Module summary page should display information based on "api" or "detail" mode.
bpatel
parents: 41452
diff changeset
   374
    }
feff6f296019 8160196: Module summary page should display information based on "api" or "detail" mode.
bpatel
parents: 41452
diff changeset
   375
feff6f296019 8160196: Module summary page should display information based on "api" or "detail" mode.
bpatel
parents: 41452
diff changeset
   376
    @Override @DefinedBy(Api.COMPILER_TREE)
35346
c0614a805fad 8146208: Add a public DocTreeFactory to the Compiler Tree API
jjg
parents: 34567
diff changeset
   377
    public DCReference newReferenceTree(String signature) {
c0614a805fad 8146208: Add a public DocTreeFactory to the Compiler Tree API
jjg
parents: 34567
diff changeset
   378
        try {
c0614a805fad 8146208: Add a public DocTreeFactory to the Compiler Tree API
jjg
parents: 34567
diff changeset
   379
            ReferenceParser.Reference ref = referenceParser.parse(signature);
c0614a805fad 8146208: Add a public DocTreeFactory to the Compiler Tree API
jjg
parents: 34567
diff changeset
   380
            DCReference tree = new DCReference(signature, ref.qualExpr, ref.member, ref.paramTypes);
c0614a805fad 8146208: Add a public DocTreeFactory to the Compiler Tree API
jjg
parents: 34567
diff changeset
   381
            tree.pos = pos;
c0614a805fad 8146208: Add a public DocTreeFactory to the Compiler Tree API
jjg
parents: 34567
diff changeset
   382
            return tree;
c0614a805fad 8146208: Add a public DocTreeFactory to the Compiler Tree API
jjg
parents: 34567
diff changeset
   383
        } catch (ReferenceParser.ParseException e) {
c0614a805fad 8146208: Add a public DocTreeFactory to the Compiler Tree API
jjg
parents: 34567
diff changeset
   384
            throw new IllegalArgumentException("invalid signature", e);
c0614a805fad 8146208: Add a public DocTreeFactory to the Compiler Tree API
jjg
parents: 34567
diff changeset
   385
        }
14541
36f9d11fc9aa 7021614: extend com.sun.source API to support parsing javadoc comments
jjg
parents:
diff changeset
   386
    }
36f9d11fc9aa 7021614: extend com.sun.source API to support parsing javadoc comments
jjg
parents:
diff changeset
   387
35346
c0614a805fad 8146208: Add a public DocTreeFactory to the Compiler Tree API
jjg
parents: 34567
diff changeset
   388
    public DCReference newReferenceTree(String signature, JCTree qualExpr, Name member, List<JCTree> paramTypes) {
14541
36f9d11fc9aa 7021614: extend com.sun.source API to support parsing javadoc comments
jjg
parents:
diff changeset
   389
        DCReference tree = new DCReference(signature, qualExpr, member, paramTypes);
36f9d11fc9aa 7021614: extend com.sun.source API to support parsing javadoc comments
jjg
parents:
diff changeset
   390
        tree.pos = pos;
36f9d11fc9aa 7021614: extend com.sun.source API to support parsing javadoc comments
jjg
parents:
diff changeset
   391
        return tree;
36f9d11fc9aa 7021614: extend com.sun.source API to support parsing javadoc comments
jjg
parents:
diff changeset
   392
    }
36f9d11fc9aa 7021614: extend com.sun.source API to support parsing javadoc comments
jjg
parents:
diff changeset
   393
35346
c0614a805fad 8146208: Add a public DocTreeFactory to the Compiler Tree API
jjg
parents: 34567
diff changeset
   394
    @Override @DefinedBy(Api.COMPILER_TREE)
c0614a805fad 8146208: Add a public DocTreeFactory to the Compiler Tree API
jjg
parents: 34567
diff changeset
   395
    public DCReturn newReturnTree(List<? extends DocTree> description) {
c0614a805fad 8146208: Add a public DocTreeFactory to the Compiler Tree API
jjg
parents: 34567
diff changeset
   396
        DCReturn tree = new DCReturn(cast(description));
14541
36f9d11fc9aa 7021614: extend com.sun.source API to support parsing javadoc comments
jjg
parents:
diff changeset
   397
        tree.pos = pos;
36f9d11fc9aa 7021614: extend com.sun.source API to support parsing javadoc comments
jjg
parents:
diff changeset
   398
        return tree;
36f9d11fc9aa 7021614: extend com.sun.source API to support parsing javadoc comments
jjg
parents:
diff changeset
   399
    }
36f9d11fc9aa 7021614: extend com.sun.source API to support parsing javadoc comments
jjg
parents:
diff changeset
   400
35346
c0614a805fad 8146208: Add a public DocTreeFactory to the Compiler Tree API
jjg
parents: 34567
diff changeset
   401
    @Override @DefinedBy(Api.COMPILER_TREE)
c0614a805fad 8146208: Add a public DocTreeFactory to the Compiler Tree API
jjg
parents: 34567
diff changeset
   402
    public DCSee newSeeTree(List<? extends DocTree> reference) {
c0614a805fad 8146208: Add a public DocTreeFactory to the Compiler Tree API
jjg
parents: 34567
diff changeset
   403
        DCSee tree = new DCSee(cast(reference));
14541
36f9d11fc9aa 7021614: extend com.sun.source API to support parsing javadoc comments
jjg
parents:
diff changeset
   404
        tree.pos = pos;
36f9d11fc9aa 7021614: extend com.sun.source API to support parsing javadoc comments
jjg
parents:
diff changeset
   405
        return tree;
36f9d11fc9aa 7021614: extend com.sun.source API to support parsing javadoc comments
jjg
parents:
diff changeset
   406
    }
36f9d11fc9aa 7021614: extend com.sun.source API to support parsing javadoc comments
jjg
parents:
diff changeset
   407
35346
c0614a805fad 8146208: Add a public DocTreeFactory to the Compiler Tree API
jjg
parents: 34567
diff changeset
   408
    @Override @DefinedBy(Api.COMPILER_TREE)
c0614a805fad 8146208: Add a public DocTreeFactory to the Compiler Tree API
jjg
parents: 34567
diff changeset
   409
    public DCSerial newSerialTree(List<? extends DocTree> description) {
c0614a805fad 8146208: Add a public DocTreeFactory to the Compiler Tree API
jjg
parents: 34567
diff changeset
   410
        DCSerial tree = new DCSerial(cast(description));
14541
36f9d11fc9aa 7021614: extend com.sun.source API to support parsing javadoc comments
jjg
parents:
diff changeset
   411
        tree.pos = pos;
36f9d11fc9aa 7021614: extend com.sun.source API to support parsing javadoc comments
jjg
parents:
diff changeset
   412
        return tree;
36f9d11fc9aa 7021614: extend com.sun.source API to support parsing javadoc comments
jjg
parents:
diff changeset
   413
    }
36f9d11fc9aa 7021614: extend com.sun.source API to support parsing javadoc comments
jjg
parents:
diff changeset
   414
35346
c0614a805fad 8146208: Add a public DocTreeFactory to the Compiler Tree API
jjg
parents: 34567
diff changeset
   415
    @Override @DefinedBy(Api.COMPILER_TREE)
c0614a805fad 8146208: Add a public DocTreeFactory to the Compiler Tree API
jjg
parents: 34567
diff changeset
   416
    public DCSerialData newSerialDataTree(List<? extends DocTree> description) {
c0614a805fad 8146208: Add a public DocTreeFactory to the Compiler Tree API
jjg
parents: 34567
diff changeset
   417
        DCSerialData tree = new DCSerialData(cast(description));
14541
36f9d11fc9aa 7021614: extend com.sun.source API to support parsing javadoc comments
jjg
parents:
diff changeset
   418
        tree.pos = pos;
36f9d11fc9aa 7021614: extend com.sun.source API to support parsing javadoc comments
jjg
parents:
diff changeset
   419
        return tree;
36f9d11fc9aa 7021614: extend com.sun.source API to support parsing javadoc comments
jjg
parents:
diff changeset
   420
    }
36f9d11fc9aa 7021614: extend com.sun.source API to support parsing javadoc comments
jjg
parents:
diff changeset
   421
35346
c0614a805fad 8146208: Add a public DocTreeFactory to the Compiler Tree API
jjg
parents: 34567
diff changeset
   422
    @Override @DefinedBy(Api.COMPILER_TREE)
c0614a805fad 8146208: Add a public DocTreeFactory to the Compiler Tree API
jjg
parents: 34567
diff changeset
   423
    public DCSerialField newSerialFieldTree(IdentifierTree name, ReferenceTree type, List<? extends DocTree> description) {
c0614a805fad 8146208: Add a public DocTreeFactory to the Compiler Tree API
jjg
parents: 34567
diff changeset
   424
        DCSerialField tree = new DCSerialField((DCIdentifier) name, (DCReference) type, cast(description));
14541
36f9d11fc9aa 7021614: extend com.sun.source API to support parsing javadoc comments
jjg
parents:
diff changeset
   425
        tree.pos = pos;
36f9d11fc9aa 7021614: extend com.sun.source API to support parsing javadoc comments
jjg
parents:
diff changeset
   426
        return tree;
36f9d11fc9aa 7021614: extend com.sun.source API to support parsing javadoc comments
jjg
parents:
diff changeset
   427
    }
36f9d11fc9aa 7021614: extend com.sun.source API to support parsing javadoc comments
jjg
parents:
diff changeset
   428
35346
c0614a805fad 8146208: Add a public DocTreeFactory to the Compiler Tree API
jjg
parents: 34567
diff changeset
   429
    @Override @DefinedBy(Api.COMPILER_TREE)
c0614a805fad 8146208: Add a public DocTreeFactory to the Compiler Tree API
jjg
parents: 34567
diff changeset
   430
    public DCSince newSinceTree(List<? extends DocTree> text) {
c0614a805fad 8146208: Add a public DocTreeFactory to the Compiler Tree API
jjg
parents: 34567
diff changeset
   431
        DCSince tree = new DCSince(cast(text));
14541
36f9d11fc9aa 7021614: extend com.sun.source API to support parsing javadoc comments
jjg
parents:
diff changeset
   432
        tree.pos = pos;
36f9d11fc9aa 7021614: extend com.sun.source API to support parsing javadoc comments
jjg
parents:
diff changeset
   433
        return tree;
36f9d11fc9aa 7021614: extend com.sun.source API to support parsing javadoc comments
jjg
parents:
diff changeset
   434
    }
36f9d11fc9aa 7021614: extend com.sun.source API to support parsing javadoc comments
jjg
parents:
diff changeset
   435
35346
c0614a805fad 8146208: Add a public DocTreeFactory to the Compiler Tree API
jjg
parents: 34567
diff changeset
   436
    @Override @DefinedBy(Api.COMPILER_TREE)
c0614a805fad 8146208: Add a public DocTreeFactory to the Compiler Tree API
jjg
parents: 34567
diff changeset
   437
    public DCStartElement newStartElementTree(Name name, List<? extends DocTree> attrs, boolean selfClosing) {
c0614a805fad 8146208: Add a public DocTreeFactory to the Compiler Tree API
jjg
parents: 34567
diff changeset
   438
        DCStartElement tree = new DCStartElement(name, cast(attrs), selfClosing);
14541
36f9d11fc9aa 7021614: extend com.sun.source API to support parsing javadoc comments
jjg
parents:
diff changeset
   439
        tree.pos = pos;
36f9d11fc9aa 7021614: extend com.sun.source API to support parsing javadoc comments
jjg
parents:
diff changeset
   440
        return tree;
36f9d11fc9aa 7021614: extend com.sun.source API to support parsing javadoc comments
jjg
parents:
diff changeset
   441
    }
36f9d11fc9aa 7021614: extend com.sun.source API to support parsing javadoc comments
jjg
parents:
diff changeset
   442
35346
c0614a805fad 8146208: Add a public DocTreeFactory to the Compiler Tree API
jjg
parents: 34567
diff changeset
   443
    @Override @DefinedBy(Api.COMPILER_TREE)
46184
f1325703ea85 8173425: Javadoc needs a new tag to specify the summary.
ksrini
parents: 42831
diff changeset
   444
    public DCSummary newSummaryTree(List<? extends DocTree> text) {
f1325703ea85 8173425: Javadoc needs a new tag to specify the summary.
ksrini
parents: 42831
diff changeset
   445
        DCSummary tree = new DCSummary(cast(text));
f1325703ea85 8173425: Javadoc needs a new tag to specify the summary.
ksrini
parents: 42831
diff changeset
   446
        tree.pos = pos;
f1325703ea85 8173425: Javadoc needs a new tag to specify the summary.
ksrini
parents: 42831
diff changeset
   447
        return tree;
f1325703ea85 8173425: Javadoc needs a new tag to specify the summary.
ksrini
parents: 42831
diff changeset
   448
    }
f1325703ea85 8173425: Javadoc needs a new tag to specify the summary.
ksrini
parents: 42831
diff changeset
   449
f1325703ea85 8173425: Javadoc needs a new tag to specify the summary.
ksrini
parents: 42831
diff changeset
   450
    @Override @DefinedBy(Api.COMPILER_TREE)
35346
c0614a805fad 8146208: Add a public DocTreeFactory to the Compiler Tree API
jjg
parents: 34567
diff changeset
   451
    public DCText newTextTree(String text) {
14541
36f9d11fc9aa 7021614: extend com.sun.source API to support parsing javadoc comments
jjg
parents:
diff changeset
   452
        DCText tree = new DCText(text);
36f9d11fc9aa 7021614: extend com.sun.source API to support parsing javadoc comments
jjg
parents:
diff changeset
   453
        tree.pos = pos;
36f9d11fc9aa 7021614: extend com.sun.source API to support parsing javadoc comments
jjg
parents:
diff changeset
   454
        return tree;
36f9d11fc9aa 7021614: extend com.sun.source API to support parsing javadoc comments
jjg
parents:
diff changeset
   455
    }
36f9d11fc9aa 7021614: extend com.sun.source API to support parsing javadoc comments
jjg
parents:
diff changeset
   456
35346
c0614a805fad 8146208: Add a public DocTreeFactory to the Compiler Tree API
jjg
parents: 34567
diff changeset
   457
    @Override @DefinedBy(Api.COMPILER_TREE)
c0614a805fad 8146208: Add a public DocTreeFactory to the Compiler Tree API
jjg
parents: 34567
diff changeset
   458
    public DCThrows newThrowsTree(ReferenceTree name, List<? extends DocTree> description) {
c0614a805fad 8146208: Add a public DocTreeFactory to the Compiler Tree API
jjg
parents: 34567
diff changeset
   459
        // TODO: verify the reference is just to a type (not a field or method)
c0614a805fad 8146208: Add a public DocTreeFactory to the Compiler Tree API
jjg
parents: 34567
diff changeset
   460
        DCThrows tree = new DCThrows(Kind.THROWS, (DCReference) name, cast(description));
14541
36f9d11fc9aa 7021614: extend com.sun.source API to support parsing javadoc comments
jjg
parents:
diff changeset
   461
        tree.pos = pos;
36f9d11fc9aa 7021614: extend com.sun.source API to support parsing javadoc comments
jjg
parents:
diff changeset
   462
        return tree;
36f9d11fc9aa 7021614: extend com.sun.source API to support parsing javadoc comments
jjg
parents:
diff changeset
   463
    }
36f9d11fc9aa 7021614: extend com.sun.source API to support parsing javadoc comments
jjg
parents:
diff changeset
   464
35346
c0614a805fad 8146208: Add a public DocTreeFactory to the Compiler Tree API
jjg
parents: 34567
diff changeset
   465
    @Override @DefinedBy(Api.COMPILER_TREE)
c0614a805fad 8146208: Add a public DocTreeFactory to the Compiler Tree API
jjg
parents: 34567
diff changeset
   466
    public DCUnknownBlockTag newUnknownBlockTagTree(Name name, List<? extends DocTree> content) {
c0614a805fad 8146208: Add a public DocTreeFactory to the Compiler Tree API
jjg
parents: 34567
diff changeset
   467
        DCUnknownBlockTag tree = new DCUnknownBlockTag(name, cast(content));
14541
36f9d11fc9aa 7021614: extend com.sun.source API to support parsing javadoc comments
jjg
parents:
diff changeset
   468
        tree.pos = pos;
36f9d11fc9aa 7021614: extend com.sun.source API to support parsing javadoc comments
jjg
parents:
diff changeset
   469
        return tree;
36f9d11fc9aa 7021614: extend com.sun.source API to support parsing javadoc comments
jjg
parents:
diff changeset
   470
    }
36f9d11fc9aa 7021614: extend com.sun.source API to support parsing javadoc comments
jjg
parents:
diff changeset
   471
35346
c0614a805fad 8146208: Add a public DocTreeFactory to the Compiler Tree API
jjg
parents: 34567
diff changeset
   472
    @Override @DefinedBy(Api.COMPILER_TREE)
c0614a805fad 8146208: Add a public DocTreeFactory to the Compiler Tree API
jjg
parents: 34567
diff changeset
   473
    public DCUnknownInlineTag newUnknownInlineTagTree(Name name, List<? extends DocTree> content) {
c0614a805fad 8146208: Add a public DocTreeFactory to the Compiler Tree API
jjg
parents: 34567
diff changeset
   474
        DCUnknownInlineTag tree = new DCUnknownInlineTag(name, cast(content));
14541
36f9d11fc9aa 7021614: extend com.sun.source API to support parsing javadoc comments
jjg
parents:
diff changeset
   475
        tree.pos = pos;
36f9d11fc9aa 7021614: extend com.sun.source API to support parsing javadoc comments
jjg
parents:
diff changeset
   476
        return tree;
36f9d11fc9aa 7021614: extend com.sun.source API to support parsing javadoc comments
jjg
parents:
diff changeset
   477
    }
36f9d11fc9aa 7021614: extend com.sun.source API to support parsing javadoc comments
jjg
parents:
diff changeset
   478
35346
c0614a805fad 8146208: Add a public DocTreeFactory to the Compiler Tree API
jjg
parents: 34567
diff changeset
   479
    @Override @DefinedBy(Api.COMPILER_TREE)
42831
feff6f296019 8160196: Module summary page should display information based on "api" or "detail" mode.
bpatel
parents: 41452
diff changeset
   480
    public DCUses newUsesTree(ReferenceTree name, List<? extends DocTree> description) {
feff6f296019 8160196: Module summary page should display information based on "api" or "detail" mode.
bpatel
parents: 41452
diff changeset
   481
        DCUses tree = new DCUses((DCReference) name, cast(description));
feff6f296019 8160196: Module summary page should display information based on "api" or "detail" mode.
bpatel
parents: 41452
diff changeset
   482
        tree.pos = pos;
feff6f296019 8160196: Module summary page should display information based on "api" or "detail" mode.
bpatel
parents: 41452
diff changeset
   483
        return tree;
feff6f296019 8160196: Module summary page should display information based on "api" or "detail" mode.
bpatel
parents: 41452
diff changeset
   484
    }
feff6f296019 8160196: Module summary page should display information based on "api" or "detail" mode.
bpatel
parents: 41452
diff changeset
   485
feff6f296019 8160196: Module summary page should display information based on "api" or "detail" mode.
bpatel
parents: 41452
diff changeset
   486
    @Override @DefinedBy(Api.COMPILER_TREE)
35346
c0614a805fad 8146208: Add a public DocTreeFactory to the Compiler Tree API
jjg
parents: 34567
diff changeset
   487
    public DCValue newValueTree(ReferenceTree ref) {
c0614a805fad 8146208: Add a public DocTreeFactory to the Compiler Tree API
jjg
parents: 34567
diff changeset
   488
        // TODO: verify the reference is to a constant value
c0614a805fad 8146208: Add a public DocTreeFactory to the Compiler Tree API
jjg
parents: 34567
diff changeset
   489
        DCValue tree = new DCValue((DCReference) ref);
14541
36f9d11fc9aa 7021614: extend com.sun.source API to support parsing javadoc comments
jjg
parents:
diff changeset
   490
        tree.pos = pos;
36f9d11fc9aa 7021614: extend com.sun.source API to support parsing javadoc comments
jjg
parents:
diff changeset
   491
        return tree;
36f9d11fc9aa 7021614: extend com.sun.source API to support parsing javadoc comments
jjg
parents:
diff changeset
   492
    }
36f9d11fc9aa 7021614: extend com.sun.source API to support parsing javadoc comments
jjg
parents:
diff changeset
   493
35346
c0614a805fad 8146208: Add a public DocTreeFactory to the Compiler Tree API
jjg
parents: 34567
diff changeset
   494
    @Override @DefinedBy(Api.COMPILER_TREE)
c0614a805fad 8146208: Add a public DocTreeFactory to the Compiler Tree API
jjg
parents: 34567
diff changeset
   495
    public DCVersion newVersionTree(List<? extends DocTree> text) {
c0614a805fad 8146208: Add a public DocTreeFactory to the Compiler Tree API
jjg
parents: 34567
diff changeset
   496
        DCVersion tree = new DCVersion(cast(text));
14541
36f9d11fc9aa 7021614: extend com.sun.source API to support parsing javadoc comments
jjg
parents:
diff changeset
   497
        tree.pos = pos;
36f9d11fc9aa 7021614: extend com.sun.source API to support parsing javadoc comments
jjg
parents:
diff changeset
   498
        return tree;
36f9d11fc9aa 7021614: extend com.sun.source API to support parsing javadoc comments
jjg
parents:
diff changeset
   499
    }
33360
d8ef08003d35 8078320: Improve DocTrees parsing.
ksrini
parents: 25874
diff changeset
   500
35346
c0614a805fad 8146208: Add a public DocTreeFactory to the Compiler Tree API
jjg
parents: 34567
diff changeset
   501
    @Override @DefinedBy(Api.COMPILER_TREE)
33360
d8ef08003d35 8078320: Improve DocTrees parsing.
ksrini
parents: 25874
diff changeset
   502
    public java.util.List<DocTree> getFirstSentence(java.util.List<? extends DocTree> list) {
d8ef08003d35 8078320: Improve DocTrees parsing.
ksrini
parents: 25874
diff changeset
   503
        Pair<List<DCTree>, List<DCTree>> pair = splitBody(list);
d8ef08003d35 8078320: Improve DocTrees parsing.
ksrini
parents: 25874
diff changeset
   504
        return new ArrayList<>(pair.fst);
d8ef08003d35 8078320: Improve DocTrees parsing.
ksrini
parents: 25874
diff changeset
   505
    }
d8ef08003d35 8078320: Improve DocTrees parsing.
ksrini
parents: 25874
diff changeset
   506
d8ef08003d35 8078320: Improve DocTrees parsing.
ksrini
parents: 25874
diff changeset
   507
    /*
d8ef08003d35 8078320: Improve DocTrees parsing.
ksrini
parents: 25874
diff changeset
   508
     * Breaks up the body tags into the first sentence and its successors.
33424
e6bd5406e2cf 8132096: Augment the Compiler Tree API to support the new Simplified Doclet API
ksrini
parents: 33360
diff changeset
   509
     * The first sentence is determined with the presence of a period,
e6bd5406e2cf 8132096: Augment the Compiler Tree API to support the new Simplified Doclet API
ksrini
parents: 33360
diff changeset
   510
     * block tag, or a sentence break, as returned by the BreakIterator.
e6bd5406e2cf 8132096: Augment the Compiler Tree API to support the new Simplified Doclet API
ksrini
parents: 33360
diff changeset
   511
     * Trailing whitespaces are trimmed.
33360
d8ef08003d35 8078320: Improve DocTrees parsing.
ksrini
parents: 25874
diff changeset
   512
     */
33424
e6bd5406e2cf 8132096: Augment the Compiler Tree API to support the new Simplified Doclet API
ksrini
parents: 33360
diff changeset
   513
    private Pair<List<DCTree>, List<DCTree>> splitBody(Collection<? extends DocTree> list) {
e6bd5406e2cf 8132096: Augment the Compiler Tree API to support the new Simplified Doclet API
ksrini
parents: 33360
diff changeset
   514
        // pos is modified as we create trees, therefore
e6bd5406e2cf 8132096: Augment the Compiler Tree API to support the new Simplified Doclet API
ksrini
parents: 33360
diff changeset
   515
        // we save the pos and restore it later.
e6bd5406e2cf 8132096: Augment the Compiler Tree API to support the new Simplified Doclet API
ksrini
parents: 33360
diff changeset
   516
        final int savedpos = this.pos;
e6bd5406e2cf 8132096: Augment the Compiler Tree API to support the new Simplified Doclet API
ksrini
parents: 33360
diff changeset
   517
        try {
e6bd5406e2cf 8132096: Augment the Compiler Tree API to support the new Simplified Doclet API
ksrini
parents: 33360
diff changeset
   518
            ListBuffer<DCTree> body = new ListBuffer<>();
e6bd5406e2cf 8132096: Augment the Compiler Tree API to support the new Simplified Doclet API
ksrini
parents: 33360
diff changeset
   519
            // split body into first sentence and body
e6bd5406e2cf 8132096: Augment the Compiler Tree API to support the new Simplified Doclet API
ksrini
parents: 33360
diff changeset
   520
            ListBuffer<DCTree> fs = new ListBuffer<>();
e6bd5406e2cf 8132096: Augment the Compiler Tree API to support the new Simplified Doclet API
ksrini
parents: 33360
diff changeset
   521
            if (list.isEmpty()) {
e6bd5406e2cf 8132096: Augment the Compiler Tree API to support the new Simplified Doclet API
ksrini
parents: 33360
diff changeset
   522
                return new Pair<>(fs.toList(), body.toList());
33360
d8ef08003d35 8078320: Improve DocTrees parsing.
ksrini
parents: 25874
diff changeset
   523
            }
33424
e6bd5406e2cf 8132096: Augment the Compiler Tree API to support the new Simplified Doclet API
ksrini
parents: 33360
diff changeset
   524
            boolean foundFirstSentence = false;
e6bd5406e2cf 8132096: Augment the Compiler Tree API to support the new Simplified Doclet API
ksrini
parents: 33360
diff changeset
   525
            ArrayList<DocTree> alist = new ArrayList<>(list);
e6bd5406e2cf 8132096: Augment the Compiler Tree API to support the new Simplified Doclet API
ksrini
parents: 33360
diff changeset
   526
            ListIterator<DocTree> itr = alist.listIterator();
e6bd5406e2cf 8132096: Augment the Compiler Tree API to support the new Simplified Doclet API
ksrini
parents: 33360
diff changeset
   527
            while (itr.hasNext()) {
e6bd5406e2cf 8132096: Augment the Compiler Tree API to support the new Simplified Doclet API
ksrini
parents: 33360
diff changeset
   528
                boolean isFirst = !itr.hasPrevious();
e6bd5406e2cf 8132096: Augment the Compiler Tree API to support the new Simplified Doclet API
ksrini
parents: 33360
diff changeset
   529
                DocTree dt = itr.next();
e6bd5406e2cf 8132096: Augment the Compiler Tree API to support the new Simplified Doclet API
ksrini
parents: 33360
diff changeset
   530
                int spos = ((DCTree) dt).pos;
e6bd5406e2cf 8132096: Augment the Compiler Tree API to support the new Simplified Doclet API
ksrini
parents: 33360
diff changeset
   531
                if (foundFirstSentence) {
e6bd5406e2cf 8132096: Augment the Compiler Tree API to support the new Simplified Doclet API
ksrini
parents: 33360
diff changeset
   532
                    body.add((DCTree) dt);
e6bd5406e2cf 8132096: Augment the Compiler Tree API to support the new Simplified Doclet API
ksrini
parents: 33360
diff changeset
   533
                    continue;
e6bd5406e2cf 8132096: Augment the Compiler Tree API to support the new Simplified Doclet API
ksrini
parents: 33360
diff changeset
   534
                }
e6bd5406e2cf 8132096: Augment the Compiler Tree API to support the new Simplified Doclet API
ksrini
parents: 33360
diff changeset
   535
                switch (dt.getKind()) {
46184
f1325703ea85 8173425: Javadoc needs a new tag to specify the summary.
ksrini
parents: 42831
diff changeset
   536
                    case SUMMARY:
f1325703ea85 8173425: Javadoc needs a new tag to specify the summary.
ksrini
parents: 42831
diff changeset
   537
                        foundFirstSentence = true;
f1325703ea85 8173425: Javadoc needs a new tag to specify the summary.
ksrini
parents: 42831
diff changeset
   538
                        break;
33424
e6bd5406e2cf 8132096: Augment the Compiler Tree API to support the new Simplified Doclet API
ksrini
parents: 33360
diff changeset
   539
                    case TEXT:
e6bd5406e2cf 8132096: Augment the Compiler Tree API to support the new Simplified Doclet API
ksrini
parents: 33360
diff changeset
   540
                        DCText tt = (DCText) dt;
e6bd5406e2cf 8132096: Augment the Compiler Tree API to support the new Simplified Doclet API
ksrini
parents: 33360
diff changeset
   541
                        String s = tt.getBody();
e6bd5406e2cf 8132096: Augment the Compiler Tree API to support the new Simplified Doclet API
ksrini
parents: 33360
diff changeset
   542
                        DocTree peekedNext = itr.hasNext()
e6bd5406e2cf 8132096: Augment the Compiler Tree API to support the new Simplified Doclet API
ksrini
parents: 33360
diff changeset
   543
                                ? alist.get(itr.nextIndex())
e6bd5406e2cf 8132096: Augment the Compiler Tree API to support the new Simplified Doclet API
ksrini
parents: 33360
diff changeset
   544
                                : null;
e6bd5406e2cf 8132096: Augment the Compiler Tree API to support the new Simplified Doclet API
ksrini
parents: 33360
diff changeset
   545
                        int sbreak = getSentenceBreak(s, peekedNext);
e6bd5406e2cf 8132096: Augment the Compiler Tree API to support the new Simplified Doclet API
ksrini
parents: 33360
diff changeset
   546
                        if (sbreak > 0) {
e6bd5406e2cf 8132096: Augment the Compiler Tree API to support the new Simplified Doclet API
ksrini
parents: 33360
diff changeset
   547
                            s = removeTrailingWhitespace(s.substring(0, sbreak));
35346
c0614a805fad 8146208: Add a public DocTreeFactory to the Compiler Tree API
jjg
parents: 34567
diff changeset
   548
                            DCText text = this.at(spos).newTextTree(s);
33360
d8ef08003d35 8078320: Improve DocTrees parsing.
ksrini
parents: 25874
diff changeset
   549
                            fs.add(text);
33424
e6bd5406e2cf 8132096: Augment the Compiler Tree API to support the new Simplified Doclet API
ksrini
parents: 33360
diff changeset
   550
                            foundFirstSentence = true;
e6bd5406e2cf 8132096: Augment the Compiler Tree API to support the new Simplified Doclet API
ksrini
parents: 33360
diff changeset
   551
                            int nwPos = skipWhiteSpace(tt.getBody(), sbreak);
e6bd5406e2cf 8132096: Augment the Compiler Tree API to support the new Simplified Doclet API
ksrini
parents: 33360
diff changeset
   552
                            if (nwPos > 0) {
35346
c0614a805fad 8146208: Add a public DocTreeFactory to the Compiler Tree API
jjg
parents: 34567
diff changeset
   553
                                DCText text2 = this.at(spos + nwPos).newTextTree(tt.getBody().substring(nwPos));
33424
e6bd5406e2cf 8132096: Augment the Compiler Tree API to support the new Simplified Doclet API
ksrini
parents: 33360
diff changeset
   554
                                body.add(text2);
e6bd5406e2cf 8132096: Augment the Compiler Tree API to support the new Simplified Doclet API
ksrini
parents: 33360
diff changeset
   555
                            }
e6bd5406e2cf 8132096: Augment the Compiler Tree API to support the new Simplified Doclet API
ksrini
parents: 33360
diff changeset
   556
                            continue;
e6bd5406e2cf 8132096: Augment the Compiler Tree API to support the new Simplified Doclet API
ksrini
parents: 33360
diff changeset
   557
                        } else if (itr.hasNext()) {
e6bd5406e2cf 8132096: Augment the Compiler Tree API to support the new Simplified Doclet API
ksrini
parents: 33360
diff changeset
   558
                            // if the next doctree is a break, remove trailing spaces
e6bd5406e2cf 8132096: Augment the Compiler Tree API to support the new Simplified Doclet API
ksrini
parents: 33360
diff changeset
   559
                            peekedNext = alist.get(itr.nextIndex());
e6bd5406e2cf 8132096: Augment the Compiler Tree API to support the new Simplified Doclet API
ksrini
parents: 33360
diff changeset
   560
                            boolean sbrk = isSentenceBreak(peekedNext, false);
e6bd5406e2cf 8132096: Augment the Compiler Tree API to support the new Simplified Doclet API
ksrini
parents: 33360
diff changeset
   561
                            if (sbrk) {
e6bd5406e2cf 8132096: Augment the Compiler Tree API to support the new Simplified Doclet API
ksrini
parents: 33360
diff changeset
   562
                                DocTree next = itr.next();
e6bd5406e2cf 8132096: Augment the Compiler Tree API to support the new Simplified Doclet API
ksrini
parents: 33360
diff changeset
   563
                                s = removeTrailingWhitespace(s);
35346
c0614a805fad 8146208: Add a public DocTreeFactory to the Compiler Tree API
jjg
parents: 34567
diff changeset
   564
                                DCText text = this.at(spos).newTextTree(s);
33424
e6bd5406e2cf 8132096: Augment the Compiler Tree API to support the new Simplified Doclet API
ksrini
parents: 33360
diff changeset
   565
                                fs.add(text);
e6bd5406e2cf 8132096: Augment the Compiler Tree API to support the new Simplified Doclet API
ksrini
parents: 33360
diff changeset
   566
                                body.add((DCTree) next);
e6bd5406e2cf 8132096: Augment the Compiler Tree API to support the new Simplified Doclet API
ksrini
parents: 33360
diff changeset
   567
                                foundFirstSentence = true;
e6bd5406e2cf 8132096: Augment the Compiler Tree API to support the new Simplified Doclet API
ksrini
parents: 33360
diff changeset
   568
                                continue;
e6bd5406e2cf 8132096: Augment the Compiler Tree API to support the new Simplified Doclet API
ksrini
parents: 33360
diff changeset
   569
                            }
e6bd5406e2cf 8132096: Augment the Compiler Tree API to support the new Simplified Doclet API
ksrini
parents: 33360
diff changeset
   570
                        }
e6bd5406e2cf 8132096: Augment the Compiler Tree API to support the new Simplified Doclet API
ksrini
parents: 33360
diff changeset
   571
                        break;
e6bd5406e2cf 8132096: Augment the Compiler Tree API to support the new Simplified Doclet API
ksrini
parents: 33360
diff changeset
   572
                    default:
e6bd5406e2cf 8132096: Augment the Compiler Tree API to support the new Simplified Doclet API
ksrini
parents: 33360
diff changeset
   573
                        if (isSentenceBreak(dt, isFirst)) {
e6bd5406e2cf 8132096: Augment the Compiler Tree API to support the new Simplified Doclet API
ksrini
parents: 33360
diff changeset
   574
                            body.add((DCTree) dt);
33360
d8ef08003d35 8078320: Improve DocTrees parsing.
ksrini
parents: 25874
diff changeset
   575
                            foundFirstSentence = true;
d8ef08003d35 8078320: Improve DocTrees parsing.
ksrini
parents: 25874
diff changeset
   576
                            continue;
d8ef08003d35 8078320: Improve DocTrees parsing.
ksrini
parents: 25874
diff changeset
   577
                        }
33424
e6bd5406e2cf 8132096: Augment the Compiler Tree API to support the new Simplified Doclet API
ksrini
parents: 33360
diff changeset
   578
                        break;
e6bd5406e2cf 8132096: Augment the Compiler Tree API to support the new Simplified Doclet API
ksrini
parents: 33360
diff changeset
   579
                }
e6bd5406e2cf 8132096: Augment the Compiler Tree API to support the new Simplified Doclet API
ksrini
parents: 33360
diff changeset
   580
                fs.add((DCTree) dt);
33360
d8ef08003d35 8078320: Improve DocTrees parsing.
ksrini
parents: 25874
diff changeset
   581
            }
33424
e6bd5406e2cf 8132096: Augment the Compiler Tree API to support the new Simplified Doclet API
ksrini
parents: 33360
diff changeset
   582
            return new Pair<>(fs.toList(), body.toList());
e6bd5406e2cf 8132096: Augment the Compiler Tree API to support the new Simplified Doclet API
ksrini
parents: 33360
diff changeset
   583
        } finally {
e6bd5406e2cf 8132096: Augment the Compiler Tree API to support the new Simplified Doclet API
ksrini
parents: 33360
diff changeset
   584
            this.pos = savedpos;
33360
d8ef08003d35 8078320: Improve DocTrees parsing.
ksrini
parents: 25874
diff changeset
   585
        }
33424
e6bd5406e2cf 8132096: Augment the Compiler Tree API to support the new Simplified Doclet API
ksrini
parents: 33360
diff changeset
   586
    }
e6bd5406e2cf 8132096: Augment the Compiler Tree API to support the new Simplified Doclet API
ksrini
parents: 33360
diff changeset
   587
e6bd5406e2cf 8132096: Augment the Compiler Tree API to support the new Simplified Doclet API
ksrini
parents: 33360
diff changeset
   588
    private boolean isTextTree(DocTree tree) {
e6bd5406e2cf 8132096: Augment the Compiler Tree API to support the new Simplified Doclet API
ksrini
parents: 33360
diff changeset
   589
        return tree.getKind() == Kind.TEXT;
33360
d8ef08003d35 8078320: Improve DocTrees parsing.
ksrini
parents: 25874
diff changeset
   590
    }
d8ef08003d35 8078320: Improve DocTrees parsing.
ksrini
parents: 25874
diff changeset
   591
d8ef08003d35 8078320: Improve DocTrees parsing.
ksrini
parents: 25874
diff changeset
   592
    /*
33424
e6bd5406e2cf 8132096: Augment the Compiler Tree API to support the new Simplified Doclet API
ksrini
parents: 33360
diff changeset
   593
     * Computes the first sentence break, a simple dot-space algorithm.
33360
d8ef08003d35 8078320: Improve DocTrees parsing.
ksrini
parents: 25874
diff changeset
   594
     */
35346
c0614a805fad 8146208: Add a public DocTreeFactory to the Compiler Tree API
jjg
parents: 34567
diff changeset
   595
    private int defaultSentenceBreak(String s) {
33360
d8ef08003d35 8078320: Improve DocTrees parsing.
ksrini
parents: 25874
diff changeset
   596
        // scan for period followed by whitespace
d8ef08003d35 8078320: Improve DocTrees parsing.
ksrini
parents: 25874
diff changeset
   597
        int period = -1;
d8ef08003d35 8078320: Improve DocTrees parsing.
ksrini
parents: 25874
diff changeset
   598
        for (int i = 0; i < s.length(); i++) {
d8ef08003d35 8078320: Improve DocTrees parsing.
ksrini
parents: 25874
diff changeset
   599
            switch (s.charAt(i)) {
d8ef08003d35 8078320: Improve DocTrees parsing.
ksrini
parents: 25874
diff changeset
   600
                case '.':
d8ef08003d35 8078320: Improve DocTrees parsing.
ksrini
parents: 25874
diff changeset
   601
                    period = i;
d8ef08003d35 8078320: Improve DocTrees parsing.
ksrini
parents: 25874
diff changeset
   602
                    break;
d8ef08003d35 8078320: Improve DocTrees parsing.
ksrini
parents: 25874
diff changeset
   603
d8ef08003d35 8078320: Improve DocTrees parsing.
ksrini
parents: 25874
diff changeset
   604
                case ' ':
d8ef08003d35 8078320: Improve DocTrees parsing.
ksrini
parents: 25874
diff changeset
   605
                case '\f':
d8ef08003d35 8078320: Improve DocTrees parsing.
ksrini
parents: 25874
diff changeset
   606
                case '\n':
d8ef08003d35 8078320: Improve DocTrees parsing.
ksrini
parents: 25874
diff changeset
   607
                case '\r':
d8ef08003d35 8078320: Improve DocTrees parsing.
ksrini
parents: 25874
diff changeset
   608
                case '\t':
d8ef08003d35 8078320: Improve DocTrees parsing.
ksrini
parents: 25874
diff changeset
   609
                    if (period >= 0) {
d8ef08003d35 8078320: Improve DocTrees parsing.
ksrini
parents: 25874
diff changeset
   610
                        return i;
d8ef08003d35 8078320: Improve DocTrees parsing.
ksrini
parents: 25874
diff changeset
   611
                    }
d8ef08003d35 8078320: Improve DocTrees parsing.
ksrini
parents: 25874
diff changeset
   612
                    break;
d8ef08003d35 8078320: Improve DocTrees parsing.
ksrini
parents: 25874
diff changeset
   613
d8ef08003d35 8078320: Improve DocTrees parsing.
ksrini
parents: 25874
diff changeset
   614
                default:
d8ef08003d35 8078320: Improve DocTrees parsing.
ksrini
parents: 25874
diff changeset
   615
                    period = -1;
d8ef08003d35 8078320: Improve DocTrees parsing.
ksrini
parents: 25874
diff changeset
   616
                    break;
d8ef08003d35 8078320: Improve DocTrees parsing.
ksrini
parents: 25874
diff changeset
   617
            }
d8ef08003d35 8078320: Improve DocTrees parsing.
ksrini
parents: 25874
diff changeset
   618
        }
d8ef08003d35 8078320: Improve DocTrees parsing.
ksrini
parents: 25874
diff changeset
   619
        return -1;
d8ef08003d35 8078320: Improve DocTrees parsing.
ksrini
parents: 25874
diff changeset
   620
    }
d8ef08003d35 8078320: Improve DocTrees parsing.
ksrini
parents: 25874
diff changeset
   621
33424
e6bd5406e2cf 8132096: Augment the Compiler Tree API to support the new Simplified Doclet API
ksrini
parents: 33360
diff changeset
   622
    /*
e6bd5406e2cf 8132096: Augment the Compiler Tree API to support the new Simplified Doclet API
ksrini
parents: 33360
diff changeset
   623
     * Computes the first sentence, if using a default breaker,
e6bd5406e2cf 8132096: Augment the Compiler Tree API to support the new Simplified Doclet API
ksrini
parents: 33360
diff changeset
   624
     * the break is returned, if not then a -1, indicating that
e6bd5406e2cf 8132096: Augment the Compiler Tree API to support the new Simplified Doclet API
ksrini
parents: 33360
diff changeset
   625
     * more doctree elements are required to be examined.
e6bd5406e2cf 8132096: Augment the Compiler Tree API to support the new Simplified Doclet API
ksrini
parents: 33360
diff changeset
   626
     *
e6bd5406e2cf 8132096: Augment the Compiler Tree API to support the new Simplified Doclet API
ksrini
parents: 33360
diff changeset
   627
     * BreakIterator.next points to the the start of the following sentence,
e6bd5406e2cf 8132096: Augment the Compiler Tree API to support the new Simplified Doclet API
ksrini
parents: 33360
diff changeset
   628
     * and does not provide an easy way to disambiguate between "sentence break",
e6bd5406e2cf 8132096: Augment the Compiler Tree API to support the new Simplified Doclet API
ksrini
parents: 33360
diff changeset
   629
     * "possible sentence break" and "not a sentence break" at the end of the input.
e6bd5406e2cf 8132096: Augment the Compiler Tree API to support the new Simplified Doclet API
ksrini
parents: 33360
diff changeset
   630
     * For example, BreakIterator.next returns the index for the end
e6bd5406e2cf 8132096: Augment the Compiler Tree API to support the new Simplified Doclet API
ksrini
parents: 33360
diff changeset
   631
     * of the string for all of these examples,
e6bd5406e2cf 8132096: Augment the Compiler Tree API to support the new Simplified Doclet API
ksrini
parents: 33360
diff changeset
   632
     * using vertical bars to delimit the bounds of the example text
e6bd5406e2cf 8132096: Augment the Compiler Tree API to support the new Simplified Doclet API
ksrini
parents: 33360
diff changeset
   633
     * |Abc|        (not a valid end of sentence break, if followed by more text)
e6bd5406e2cf 8132096: Augment the Compiler Tree API to support the new Simplified Doclet API
ksrini
parents: 33360
diff changeset
   634
     * |Abc.|       (maybe a valid end of sentence break, depending on the following text)
e6bd5406e2cf 8132096: Augment the Compiler Tree API to support the new Simplified Doclet API
ksrini
parents: 33360
diff changeset
   635
     * |Abc. |      (maybe a valid end of sentence break, depending on the following text)
e6bd5406e2cf 8132096: Augment the Compiler Tree API to support the new Simplified Doclet API
ksrini
parents: 33360
diff changeset
   636
     * |"Abc." |    (maybe a valid end of sentence break, depending on the following text)
e6bd5406e2cf 8132096: Augment the Compiler Tree API to support the new Simplified Doclet API
ksrini
parents: 33360
diff changeset
   637
     * |Abc.  |     (definitely a valid end of sentence break)
e6bd5406e2cf 8132096: Augment the Compiler Tree API to support the new Simplified Doclet API
ksrini
parents: 33360
diff changeset
   638
     * |"Abc."  |   (definitely a valid end of sentence break)
e6bd5406e2cf 8132096: Augment the Compiler Tree API to support the new Simplified Doclet API
ksrini
parents: 33360
diff changeset
   639
     * Therefore, we have to probe further to determine whether
e6bd5406e2cf 8132096: Augment the Compiler Tree API to support the new Simplified Doclet API
ksrini
parents: 33360
diff changeset
   640
     * there really is a sentence break or not at the end of this run of text.
e6bd5406e2cf 8132096: Augment the Compiler Tree API to support the new Simplified Doclet API
ksrini
parents: 33360
diff changeset
   641
     */
35346
c0614a805fad 8146208: Add a public DocTreeFactory to the Compiler Tree API
jjg
parents: 34567
diff changeset
   642
    private int getSentenceBreak(String s, DocTree dt) {
33424
e6bd5406e2cf 8132096: Augment the Compiler Tree API to support the new Simplified Doclet API
ksrini
parents: 33360
diff changeset
   643
        BreakIterator breakIterator = trees.getBreakIterator();
e6bd5406e2cf 8132096: Augment the Compiler Tree API to support the new Simplified Doclet API
ksrini
parents: 33360
diff changeset
   644
        if (breakIterator == null) {
33360
d8ef08003d35 8078320: Improve DocTrees parsing.
ksrini
parents: 25874
diff changeset
   645
            return defaultSentenceBreak(s);
d8ef08003d35 8078320: Improve DocTrees parsing.
ksrini
parents: 25874
diff changeset
   646
        }
33424
e6bd5406e2cf 8132096: Augment the Compiler Tree API to support the new Simplified Doclet API
ksrini
parents: 33360
diff changeset
   647
        breakIterator.setText(s);
e6bd5406e2cf 8132096: Augment the Compiler Tree API to support the new Simplified Doclet API
ksrini
parents: 33360
diff changeset
   648
        final int sbrk = breakIterator.next();
e6bd5406e2cf 8132096: Augment the Compiler Tree API to support the new Simplified Doclet API
ksrini
parents: 33360
diff changeset
   649
        // This is the last doctree, found the droid we are looking for
e6bd5406e2cf 8132096: Augment the Compiler Tree API to support the new Simplified Doclet API
ksrini
parents: 33360
diff changeset
   650
        if (dt == null) {
e6bd5406e2cf 8132096: Augment the Compiler Tree API to support the new Simplified Doclet API
ksrini
parents: 33360
diff changeset
   651
            return sbrk;
e6bd5406e2cf 8132096: Augment the Compiler Tree API to support the new Simplified Doclet API
ksrini
parents: 33360
diff changeset
   652
        }
e6bd5406e2cf 8132096: Augment the Compiler Tree API to support the new Simplified Doclet API
ksrini
parents: 33360
diff changeset
   653
e6bd5406e2cf 8132096: Augment the Compiler Tree API to support the new Simplified Doclet API
ksrini
parents: 33360
diff changeset
   654
        // If the break is well within the span of the string ie. not
e6bd5406e2cf 8132096: Augment the Compiler Tree API to support the new Simplified Doclet API
ksrini
parents: 33360
diff changeset
   655
        // at EOL, then we have a clear break.
e6bd5406e2cf 8132096: Augment the Compiler Tree API to support the new Simplified Doclet API
ksrini
parents: 33360
diff changeset
   656
        if (sbrk < s.length() - 1) {
e6bd5406e2cf 8132096: Augment the Compiler Tree API to support the new Simplified Doclet API
ksrini
parents: 33360
diff changeset
   657
            return sbrk;
e6bd5406e2cf 8132096: Augment the Compiler Tree API to support the new Simplified Doclet API
ksrini
parents: 33360
diff changeset
   658
        }
e6bd5406e2cf 8132096: Augment the Compiler Tree API to support the new Simplified Doclet API
ksrini
parents: 33360
diff changeset
   659
e6bd5406e2cf 8132096: Augment the Compiler Tree API to support the new Simplified Doclet API
ksrini
parents: 33360
diff changeset
   660
        if (isTextTree(dt)) {
e6bd5406e2cf 8132096: Augment the Compiler Tree API to support the new Simplified Doclet API
ksrini
parents: 33360
diff changeset
   661
            // Two adjacent text trees, a corner case, perhaps
e6bd5406e2cf 8132096: Augment the Compiler Tree API to support the new Simplified Doclet API
ksrini
parents: 33360
diff changeset
   662
            // produced by a tool synthesizing a doctree. In
e6bd5406e2cf 8132096: Augment the Compiler Tree API to support the new Simplified Doclet API
ksrini
parents: 33360
diff changeset
   663
            // this case, does the break lie within the first span,
e6bd5406e2cf 8132096: Augment the Compiler Tree API to support the new Simplified Doclet API
ksrini
parents: 33360
diff changeset
   664
            // then we have the droid, otherwise allow the callers
e6bd5406e2cf 8132096: Augment the Compiler Tree API to support the new Simplified Doclet API
ksrini
parents: 33360
diff changeset
   665
            // logic to handle the break in the adjacent doctree.
e6bd5406e2cf 8132096: Augment the Compiler Tree API to support the new Simplified Doclet API
ksrini
parents: 33360
diff changeset
   666
            TextTree ttnext = (TextTree) dt;
e6bd5406e2cf 8132096: Augment the Compiler Tree API to support the new Simplified Doclet API
ksrini
parents: 33360
diff changeset
   667
            String combined = s + ttnext.getBody();
e6bd5406e2cf 8132096: Augment the Compiler Tree API to support the new Simplified Doclet API
ksrini
parents: 33360
diff changeset
   668
            breakIterator.setText(combined);
e6bd5406e2cf 8132096: Augment the Compiler Tree API to support the new Simplified Doclet API
ksrini
parents: 33360
diff changeset
   669
            int sbrk2 = breakIterator.next();
e6bd5406e2cf 8132096: Augment the Compiler Tree API to support the new Simplified Doclet API
ksrini
parents: 33360
diff changeset
   670
            if (sbrk < sbrk2) {
e6bd5406e2cf 8132096: Augment the Compiler Tree API to support the new Simplified Doclet API
ksrini
parents: 33360
diff changeset
   671
                return sbrk;
e6bd5406e2cf 8132096: Augment the Compiler Tree API to support the new Simplified Doclet API
ksrini
parents: 33360
diff changeset
   672
            }
e6bd5406e2cf 8132096: Augment the Compiler Tree API to support the new Simplified Doclet API
ksrini
parents: 33360
diff changeset
   673
        }
e6bd5406e2cf 8132096: Augment the Compiler Tree API to support the new Simplified Doclet API
ksrini
parents: 33360
diff changeset
   674
e6bd5406e2cf 8132096: Augment the Compiler Tree API to support the new Simplified Doclet API
ksrini
parents: 33360
diff changeset
   675
        // Is the adjacent tree a sentence breaker ?
e6bd5406e2cf 8132096: Augment the Compiler Tree API to support the new Simplified Doclet API
ksrini
parents: 33360
diff changeset
   676
        if (isSentenceBreak(dt, false)) {
e6bd5406e2cf 8132096: Augment the Compiler Tree API to support the new Simplified Doclet API
ksrini
parents: 33360
diff changeset
   677
            return sbrk;
e6bd5406e2cf 8132096: Augment the Compiler Tree API to support the new Simplified Doclet API
ksrini
parents: 33360
diff changeset
   678
        }
e6bd5406e2cf 8132096: Augment the Compiler Tree API to support the new Simplified Doclet API
ksrini
parents: 33360
diff changeset
   679
e6bd5406e2cf 8132096: Augment the Compiler Tree API to support the new Simplified Doclet API
ksrini
parents: 33360
diff changeset
   680
        // At this point the adjacent tree is either a javadoc tag ({@..),
e6bd5406e2cf 8132096: Augment the Compiler Tree API to support the new Simplified Doclet API
ksrini
parents: 33360
diff changeset
   681
        // html tag (<..) or an entity (&..). Perform a litmus test, by
e6bd5406e2cf 8132096: Augment the Compiler Tree API to support the new Simplified Doclet API
ksrini
parents: 33360
diff changeset
   682
        // concatenating a sentence, to validate the break earlier identified.
e6bd5406e2cf 8132096: Augment the Compiler Tree API to support the new Simplified Doclet API
ksrini
parents: 33360
diff changeset
   683
        String combined = s + "Dummy Sentence.";
e6bd5406e2cf 8132096: Augment the Compiler Tree API to support the new Simplified Doclet API
ksrini
parents: 33360
diff changeset
   684
        breakIterator.setText(combined);
e6bd5406e2cf 8132096: Augment the Compiler Tree API to support the new Simplified Doclet API
ksrini
parents: 33360
diff changeset
   685
        int sbrk2 = breakIterator.next();
e6bd5406e2cf 8132096: Augment the Compiler Tree API to support the new Simplified Doclet API
ksrini
parents: 33360
diff changeset
   686
        if (sbrk2 <= sbrk) {
e6bd5406e2cf 8132096: Augment the Compiler Tree API to support the new Simplified Doclet API
ksrini
parents: 33360
diff changeset
   687
            return sbrk2;
e6bd5406e2cf 8132096: Augment the Compiler Tree API to support the new Simplified Doclet API
ksrini
parents: 33360
diff changeset
   688
        }
e6bd5406e2cf 8132096: Augment the Compiler Tree API to support the new Simplified Doclet API
ksrini
parents: 33360
diff changeset
   689
        return -1; // indeterminate at this time
33360
d8ef08003d35 8078320: Improve DocTrees parsing.
ksrini
parents: 25874
diff changeset
   690
    }
d8ef08003d35 8078320: Improve DocTrees parsing.
ksrini
parents: 25874
diff changeset
   691
35346
c0614a805fad 8146208: Add a public DocTreeFactory to the Compiler Tree API
jjg
parents: 34567
diff changeset
   692
    private boolean isSentenceBreak(javax.lang.model.element.Name tagName) {
33360
d8ef08003d35 8078320: Improve DocTrees parsing.
ksrini
parents: 25874
diff changeset
   693
        return sentenceBreakTags.contains(get(tagName));
d8ef08003d35 8078320: Improve DocTrees parsing.
ksrini
parents: 25874
diff changeset
   694
    }
d8ef08003d35 8078320: Improve DocTrees parsing.
ksrini
parents: 25874
diff changeset
   695
35346
c0614a805fad 8146208: Add a public DocTreeFactory to the Compiler Tree API
jjg
parents: 34567
diff changeset
   696
    private boolean isSentenceBreak(DocTree dt, boolean isFirstDocTree) {
33360
d8ef08003d35 8078320: Improve DocTrees parsing.
ksrini
parents: 25874
diff changeset
   697
        switch (dt.getKind()) {
d8ef08003d35 8078320: Improve DocTrees parsing.
ksrini
parents: 25874
diff changeset
   698
            case START_ELEMENT:
d8ef08003d35 8078320: Improve DocTrees parsing.
ksrini
parents: 25874
diff changeset
   699
                    StartElementTree set = (StartElementTree)dt;
d8ef08003d35 8078320: Improve DocTrees parsing.
ksrini
parents: 25874
diff changeset
   700
                    return !isFirstDocTree && ((DCTree) dt).pos > 1 && isSentenceBreak(set.getName());
d8ef08003d35 8078320: Improve DocTrees parsing.
ksrini
parents: 25874
diff changeset
   701
            case END_ELEMENT:
d8ef08003d35 8078320: Improve DocTrees parsing.
ksrini
parents: 25874
diff changeset
   702
                    EndElementTree eet = (EndElementTree)dt;
d8ef08003d35 8078320: Improve DocTrees parsing.
ksrini
parents: 25874
diff changeset
   703
                    return !isFirstDocTree && ((DCTree) dt).pos > 1 && isSentenceBreak(eet.getName());
d8ef08003d35 8078320: Improve DocTrees parsing.
ksrini
parents: 25874
diff changeset
   704
            default:
d8ef08003d35 8078320: Improve DocTrees parsing.
ksrini
parents: 25874
diff changeset
   705
                return false;
d8ef08003d35 8078320: Improve DocTrees parsing.
ksrini
parents: 25874
diff changeset
   706
        }
d8ef08003d35 8078320: Improve DocTrees parsing.
ksrini
parents: 25874
diff changeset
   707
    }
d8ef08003d35 8078320: Improve DocTrees parsing.
ksrini
parents: 25874
diff changeset
   708
d8ef08003d35 8078320: Improve DocTrees parsing.
ksrini
parents: 25874
diff changeset
   709
    /*
d8ef08003d35 8078320: Improve DocTrees parsing.
ksrini
parents: 25874
diff changeset
   710
     * Returns the position of the the first non-white space
d8ef08003d35 8078320: Improve DocTrees parsing.
ksrini
parents: 25874
diff changeset
   711
     */
35346
c0614a805fad 8146208: Add a public DocTreeFactory to the Compiler Tree API
jjg
parents: 34567
diff changeset
   712
    private int skipWhiteSpace(String s, int start) {
33360
d8ef08003d35 8078320: Improve DocTrees parsing.
ksrini
parents: 25874
diff changeset
   713
        for (int i = start; i < s.length(); i++) {
d8ef08003d35 8078320: Improve DocTrees parsing.
ksrini
parents: 25874
diff changeset
   714
            char c = s.charAt(i);
d8ef08003d35 8078320: Improve DocTrees parsing.
ksrini
parents: 25874
diff changeset
   715
            if (!Character.isWhitespace(c)) {
d8ef08003d35 8078320: Improve DocTrees parsing.
ksrini
parents: 25874
diff changeset
   716
                return i;
d8ef08003d35 8078320: Improve DocTrees parsing.
ksrini
parents: 25874
diff changeset
   717
            }
d8ef08003d35 8078320: Improve DocTrees parsing.
ksrini
parents: 25874
diff changeset
   718
        }
d8ef08003d35 8078320: Improve DocTrees parsing.
ksrini
parents: 25874
diff changeset
   719
        return -1;
d8ef08003d35 8078320: Improve DocTrees parsing.
ksrini
parents: 25874
diff changeset
   720
    }
d8ef08003d35 8078320: Improve DocTrees parsing.
ksrini
parents: 25874
diff changeset
   721
35346
c0614a805fad 8146208: Add a public DocTreeFactory to the Compiler Tree API
jjg
parents: 34567
diff changeset
   722
    private String removeTrailingWhitespace(String s) {
33424
e6bd5406e2cf 8132096: Augment the Compiler Tree API to support the new Simplified Doclet API
ksrini
parents: 33360
diff changeset
   723
        for (int i = s.length() - 1 ; i >= 0 ; i--) {
33360
d8ef08003d35 8078320: Improve DocTrees parsing.
ksrini
parents: 25874
diff changeset
   724
            char ch = s.charAt(i);
d8ef08003d35 8078320: Improve DocTrees parsing.
ksrini
parents: 25874
diff changeset
   725
            if (!Character.isWhitespace(ch)) {
d8ef08003d35 8078320: Improve DocTrees parsing.
ksrini
parents: 25874
diff changeset
   726
                return s.substring(0, i + 1);
d8ef08003d35 8078320: Improve DocTrees parsing.
ksrini
parents: 25874
diff changeset
   727
            }
d8ef08003d35 8078320: Improve DocTrees parsing.
ksrini
parents: 25874
diff changeset
   728
        }
d8ef08003d35 8078320: Improve DocTrees parsing.
ksrini
parents: 25874
diff changeset
   729
        return s;
d8ef08003d35 8078320: Improve DocTrees parsing.
ksrini
parents: 25874
diff changeset
   730
    }
35346
c0614a805fad 8146208: Add a public DocTreeFactory to the Compiler Tree API
jjg
parents: 34567
diff changeset
   731
c0614a805fad 8146208: Add a public DocTreeFactory to the Compiler Tree API
jjg
parents: 34567
diff changeset
   732
    @SuppressWarnings("unchecked")
c0614a805fad 8146208: Add a public DocTreeFactory to the Compiler Tree API
jjg
parents: 34567
diff changeset
   733
    private List<DCTree> cast(List<? extends DocTree> list) {
c0614a805fad 8146208: Add a public DocTreeFactory to the Compiler Tree API
jjg
parents: 34567
diff changeset
   734
        return (List<DCTree>) list;
c0614a805fad 8146208: Add a public DocTreeFactory to the Compiler Tree API
jjg
parents: 34567
diff changeset
   735
    }
14541
36f9d11fc9aa 7021614: extend com.sun.source API to support parsing javadoc comments
jjg
parents:
diff changeset
   736
}