jdk

Форк
0
/
LiteralTest.java 
148 строк · 3.4 Кб
1
/*
2
 * Copyright (c) 2012, 2022, Oracle and/or its affiliates. All rights reserved.
3
 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4
 *
5
 * This code is free software; you can redistribute it and/or modify it
6
 * under the terms of the GNU General Public License version 2 only, as
7
 * published by the Free Software Foundation.
8
 *
9
 * This code is distributed in the hope that it will be useful, but WITHOUT
10
 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
11
 * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
12
 * version 2 for more details (a copy is included in the LICENSE file that
13
 * accompanied this code).
14
 *
15
 * You should have received a copy of the GNU General Public License version
16
 * 2 along with this work; if not, write to the Free Software Foundation,
17
 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
18
 *
19
 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
20
 * or visit www.oracle.com if you need additional information or have any
21
 * questions.
22
 */
23

24
/*
25
 * @test
26
 * @bug 7021614  8241780 8273244 8284908
27
 * @summary extend com.sun.source API to support parsing javadoc comments
28
 * @modules jdk.compiler/com.sun.tools.javac.api
29
 *          jdk.compiler/com.sun.tools.javac.file
30
 *          jdk.compiler/com.sun.tools.javac.tree
31
 *          jdk.compiler/com.sun.tools.javac.util
32
 * @build DocCommentTester
33
 * @run main DocCommentTester LiteralTest.java
34
 */
35

36
class LiteralTest {
37
    /** {@literal if (a < b) { }} */
38
    void minimal() { }
39
/*
40
DocComment[DOC_COMMENT, pos:0
41
  firstSentence: 1
42
    Literal[LITERAL, pos:0, if_(a_<_b)_{_}]
43
  body: empty
44
  block tags: empty
45
]
46
*/
47

48
    /** [{@literal if (a < b) { }}] */
49
    void in_brackets() { }
50
/*
51
DocComment[DOC_COMMENT, pos:0
52
  firstSentence: 3
53
    Text[TEXT, pos:0, []
54
    Literal[LITERAL, pos:1, if_(a_<_b)_{_}]
55
    Text[TEXT, pos:26, ]]
56
  body: empty
57
  block tags: empty
58
]
59
*/
60

61
    /** [ {@literal if (a < b) { }} ] */
62
    void in_brackets_with_whitespace() { }
63
/*
64
DocComment[DOC_COMMENT, pos:0
65
  firstSentence: 3
66
    Text[TEXT, pos:0, [_]
67
    Literal[LITERAL, pos:2, if_(a_<_b)_{_}]
68
    Text[TEXT, pos:27, _]]
69
  body: empty
70
  block tags: empty
71
]
72
*/
73

74
    /**
75
     * {@literal {@literal nested} }
76
     */
77
    void nested() { }
78
/*
79
DocComment[DOC_COMMENT, pos:1
80
  firstSentence: 1
81
    Literal[LITERAL, pos:1, {@literal_nested}_]
82
  body: empty
83
  block tags: empty
84
]
85
*/
86

87
    /**
88
     * {@literal if (a < b) {
89
     *        }
90
     * }
91
     */
92
    void embedded_newline() { }
93
/*
94
DocComment[DOC_COMMENT, pos:1
95
  firstSentence: 1
96
    Literal[LITERAL, pos:1, if_(a_<_b)_{|________}|_]
97
  body: empty
98
  block tags: empty
99
]
100
*/
101

102
    /**
103
     * {@literal
104
     * @tag
105
     * }
106
     */
107
    void embedded_at() { }
108
/*
109
DocComment[DOC_COMMENT, pos:1
110
  firstSentence: 1
111
    Literal[LITERAL, pos:1, |_@tag|_]
112
  body: empty
113
  block tags: empty
114
]
115
*/
116

117

118
    /** {@literal if (a < b) { } */
119
    void unterminated_1() { }
120
/*
121
DocComment[DOC_COMMENT, pos:0
122
  firstSentence: 1
123
    Erroneous[ERRONEOUS, pos:0, prefPos:23
124
      code: compiler.err.dc.unterminated.inline.tag
125
      body: {@literal_if_(a_<_b)_{_}
126
    ]
127
  body: empty
128
  block tags: empty
129
]
130
*/
131

132
    /**
133
     * {@literal if (a < b) { }
134
     * @author jjg */
135
    void unterminated_2() { }
136
/*
137
DocComment[DOC_COMMENT, pos:1
138
  firstSentence: 1
139
    Erroneous[ERRONEOUS, pos:1, prefPos:37
140
      code: compiler.err.dc.unterminated.inline.tag
141
      body: {@literal_if_(a_<_b)_{_}|_@author_jjg
142
    ]
143
  body: empty
144
  block tags: empty
145
]
146
*/
147

148
}
149

150

Использование cookies

Мы используем файлы cookie в соответствии с Политикой конфиденциальности и Политикой использования cookies.

Нажимая кнопку «Принимаю», Вы даете АО «СберТех» согласие на обработку Ваших персональных данных в целях совершенствования нашего веб-сайта и Сервиса GitVerse, а также повышения удобства их использования.

Запретить использование cookies Вы можете самостоятельно в настройках Вашего браузера.