128 |
128 |
129 List<DCTree> body = blockContent(); |
129 List<DCTree> body = blockContent(); |
130 List<DCTree> tags = blockTags(); |
130 List<DCTree> tags = blockTags(); |
131 |
131 |
132 // split body into first sentence and body |
132 // split body into first sentence and body |
133 ListBuffer<DCTree> fs = new ListBuffer<DCTree>(); |
133 ListBuffer<DCTree> fs = new ListBuffer<>(); |
134 loop: |
134 loop: |
135 for (; body.nonEmpty(); body = body.tail) { |
135 for (; body.nonEmpty(); body = body.tail) { |
136 DCTree t = body.head; |
136 DCTree t = body.head; |
137 switch (t.getKind()) { |
137 switch (t.getKind()) { |
138 case TEXT: |
138 case TEXT: |
192 * Terminated by the end of input, or the beginning of the next block tag: |
192 * Terminated by the end of input, or the beginning of the next block tag: |
193 * i.e. @ as the first non-whitespace character on a line. |
193 * i.e. @ as the first non-whitespace character on a line. |
194 */ |
194 */ |
195 @SuppressWarnings("fallthrough") |
195 @SuppressWarnings("fallthrough") |
196 protected List<DCTree> blockContent() { |
196 protected List<DCTree> blockContent() { |
197 ListBuffer<DCTree> trees = new ListBuffer<DCTree>(); |
197 ListBuffer<DCTree> trees = new ListBuffer<>(); |
198 textStart = -1; |
198 textStart = -1; |
199 |
199 |
200 loop: |
200 loop: |
201 while (bp < buflen) { |
201 while (bp < buflen) { |
202 switch (ch) { |
202 switch (ch) { |
263 * Read a series of block tags, including their content. |
263 * Read a series of block tags, including their content. |
264 * Standard tags parse their content appropriately. |
264 * Standard tags parse their content appropriately. |
265 * Non-standard tags are represented by {@link UnknownBlockTag}. |
265 * Non-standard tags are represented by {@link UnknownBlockTag}. |
266 */ |
266 */ |
267 protected List<DCTree> blockTags() { |
267 protected List<DCTree> blockTags() { |
268 ListBuffer<DCTree> tags = new ListBuffer<DCTree>(); |
268 ListBuffer<DCTree> tags = new ListBuffer<>(); |
269 while (ch == '@') |
269 while (ch == '@') |
270 tags.add(blockTag()); |
270 tags.add(blockTag()); |
271 return tags.toList(); |
271 return tags.toList(); |
272 } |
272 } |
273 |
273 |
533 List<JCTree> parseParams(String s) throws ParseException { |
533 List<JCTree> parseParams(String s) throws ParseException { |
534 if (s.trim().isEmpty()) |
534 if (s.trim().isEmpty()) |
535 return List.nil(); |
535 return List.nil(); |
536 |
536 |
537 JavacParser p = fac.newParser(s.replace("...", "[]"), false, false, false); |
537 JavacParser p = fac.newParser(s.replace("...", "[]"), false, false, false); |
538 ListBuffer<JCTree> paramTypes = new ListBuffer<JCTree>(); |
538 ListBuffer<JCTree> paramTypes = new ListBuffer<>(); |
539 paramTypes.add(p.parseType()); |
539 paramTypes.add(p.parseType()); |
540 |
540 |
541 if (p.token().kind == TokenKind.IDENTIFIER) |
541 if (p.token().kind == TokenKind.IDENTIFIER) |
542 p.nextToken(); |
542 p.nextToken(); |
543 |
543 |
612 * Matching pairs of { } are skipped; the text is terminated by the first |
612 * Matching pairs of { } are skipped; the text is terminated by the first |
613 * unmatched }. It is an error if the beginning of the next tag is detected. |
613 * unmatched }. It is an error if the beginning of the next tag is detected. |
614 */ |
614 */ |
615 @SuppressWarnings("fallthrough") |
615 @SuppressWarnings("fallthrough") |
616 protected List<DCTree> inlineContent() { |
616 protected List<DCTree> inlineContent() { |
617 ListBuffer<DCTree> trees = new ListBuffer<DCTree>(); |
617 ListBuffer<DCTree> trees = new ListBuffer<>(); |
618 |
618 |
619 skipWhitespace(); |
619 skipWhitespace(); |
620 int pos = bp; |
620 int pos = bp; |
621 int depth = 1; |
621 int depth = 1; |
622 textStart = -1; |
622 textStart = -1; |
790 * Read a series of HTML attributes, terminated by {@literal > }. |
790 * Read a series of HTML attributes, terminated by {@literal > }. |
791 * Each attribute is of the form {@literal identifier[=value] }. |
791 * Each attribute is of the form {@literal identifier[=value] }. |
792 * "value" may be unquoted, single-quoted, or double-quoted. |
792 * "value" may be unquoted, single-quoted, or double-quoted. |
793 */ |
793 */ |
794 protected List<DCTree> htmlAttrs() { |
794 protected List<DCTree> htmlAttrs() { |
795 ListBuffer<DCTree> attrs = new ListBuffer<DCTree>(); |
795 ListBuffer<DCTree> attrs = new ListBuffer<>(); |
796 skipWhitespace(); |
796 skipWhitespace(); |
797 |
797 |
798 loop: |
798 loop: |
799 while (isIdentifierStart(ch)) { |
799 while (isIdentifierStart(ch)) { |
800 int namePos = bp; |
800 int namePos = bp; |
801 Name name = readIdentifier(); |
801 Name name = readIdentifier(); |
802 skipWhitespace(); |
802 skipWhitespace(); |
803 List<DCTree> value = null; |
803 List<DCTree> value = null; |
804 ValueKind vkind = ValueKind.EMPTY; |
804 ValueKind vkind = ValueKind.EMPTY; |
805 if (ch == '=') { |
805 if (ch == '=') { |
806 ListBuffer<DCTree> v = new ListBuffer<DCTree>(); |
806 ListBuffer<DCTree> v = new ListBuffer<>(); |
807 nextChar(); |
807 nextChar(); |
808 skipWhitespace(); |
808 skipWhitespace(); |
809 if (ch == '\'' || ch == '"') { |
809 if (ch == '\'' || ch == '"') { |
810 vkind = (ch == '\'') ? ValueKind.SINGLE : ValueKind.DOUBLE; |
810 vkind = (ch == '\'') ? ValueKind.SINGLE : ValueKind.DOUBLE; |
811 char quote = ch; |
811 char quote = ch; |
988 } |
988 } |
989 return -1; |
989 return -1; |
990 } |
990 } |
991 |
991 |
992 |
992 |
993 Set<String> htmlBlockTags = new HashSet<String>(Arrays.asList( |
993 Set<String> htmlBlockTags = new HashSet<>(Arrays.asList( |
994 "h1", "h2", "h3", "h4", "h5", "h6", "p", "pre")); |
994 "h1", "h2", "h3", "h4", "h5", "h6", "p", "pre")); |
995 |
995 |
996 protected boolean isSentenceBreak(Name n) { |
996 protected boolean isSentenceBreak(Name n) { |
997 return htmlBlockTags.contains(StringUtils.toLowerCase(n.toString())); |
997 return htmlBlockTags.contains(StringUtils.toLowerCase(n.toString())); |
998 } |
998 } |