1755 return false; |
1755 return false; |
1756 } |
1756 } |
1757 return true; |
1757 return true; |
1758 } |
1758 } |
1759 |
1759 |
|
1760 // Notify the next DocTree handler to take necessary action |
|
1761 private boolean commentRemoved = false; |
|
1762 |
1760 /** |
1763 /** |
1761 * Converts inline tags and text to text strings, expanding the |
1764 * Converts inline tags and text to text strings, expanding the |
1762 * inline tags along the way. Called wherever text can contain |
1765 * inline tags along the way. Called wherever text can contain |
1763 * an inline tag, such as in comments or in free-form text arguments |
1766 * an inline tag, such as in comments or in free-form text arguments |
1764 * to non-inline tags. |
1767 * to non-inline tags. |
1780 } |
1783 } |
1781 }; |
1784 }; |
1782 CommentHelper ch = utils.getCommentHelper(element); |
1785 CommentHelper ch = utils.getCommentHelper(element); |
1783 // Array of all possible inline tags for this javadoc run |
1786 // Array of all possible inline tags for this javadoc run |
1784 configuration.tagletManager.checkTags(utils, element, tags, true); |
1787 configuration.tagletManager.checkTags(utils, element, tags, true); |
|
1788 commentRemoved = false; |
|
1789 |
1785 for (ListIterator<? extends DocTree> iterator = tags.listIterator(); iterator.hasNext();) { |
1790 for (ListIterator<? extends DocTree> iterator = tags.listIterator(); iterator.hasNext();) { |
|
1791 boolean isFirstNode = !iterator.hasPrevious(); |
1786 DocTree tag = iterator.next(); |
1792 DocTree tag = iterator.next(); |
1787 // zap block tags |
1793 boolean isLastNode = !iterator.hasNext(); |
1788 if (isFirstSentence && ignoreNonInlineTag(tag)) |
1794 |
1789 continue; |
1795 if (isFirstSentence) { |
1790 |
1796 // Ignore block tags |
1791 if (isFirstSentence && iterator.nextIndex() == tags.size() && |
1797 if (ignoreNonInlineTag(tag)) |
1792 (tag.getKind() == TEXT && isAllWhiteSpace(ch.getText(tag)))) |
1798 continue; |
1793 continue; |
1799 |
|
1800 // Ignore any trailing whitespace OR whitespace after removed html comment |
|
1801 if ((isLastNode || commentRemoved) |
|
1802 && tag.getKind() == TEXT |
|
1803 && isAllWhiteSpace(ch.getText(tag))) |
|
1804 continue; |
|
1805 |
|
1806 // Ignore any leading html comments |
|
1807 if ((isFirstNode || commentRemoved) && tag.getKind() == COMMENT) { |
|
1808 commentRemoved = true; |
|
1809 continue; |
|
1810 } |
|
1811 } |
1794 |
1812 |
1795 boolean allDone = new SimpleDocTreeVisitor<Boolean, Content>() { |
1813 boolean allDone = new SimpleDocTreeVisitor<Boolean, Content>() { |
1796 // notify the next DocTree handler to take necessary action |
|
1797 boolean commentRemoved = false; |
|
1798 |
|
1799 private boolean isLast(DocTree node) { |
|
1800 return node.equals(tags.get(tags.size() - 1)); |
|
1801 } |
|
1802 |
|
1803 private boolean isFirst(DocTree node) { |
|
1804 return node.equals(tags.get(0)); |
|
1805 } |
|
1806 |
1814 |
1807 private boolean inAnAtag() { |
1815 private boolean inAnAtag() { |
1808 if (utils.isStartElement(tag)) { |
1816 if (utils.isStartElement(tag)) { |
1809 StartElementTree st = (StartElementTree)tag; |
1817 StartElementTree st = (StartElementTree)tag; |
1810 Name name = st.getName(); |
1818 Name name = st.getName(); |
1845 if (utils.isText(dt) && inAnAtag()) { |
1853 if (utils.isText(dt) && inAnAtag()) { |
1846 String text = ((TextTree) dt).getBody(); |
1854 String text = ((TextTree) dt).getBody(); |
1847 if (text.startsWith("/..") && !configuration.docrootparent.isEmpty()) { |
1855 if (text.startsWith("/..") && !configuration.docrootparent.isEmpty()) { |
1848 result.addContent(configuration.docrootparent); |
1856 result.addContent(configuration.docrootparent); |
1849 docRootContent = new ContentBuilder(); |
1857 docRootContent = new ContentBuilder(); |
1850 result.addContent(textCleanup(text.substring(3), isLast(node))); |
1858 result.addContent(textCleanup(text.substring(3), isLastNode)); |
1851 } else { |
1859 } else { |
1852 if (!docRootContent.isEmpty()) { |
1860 if (!docRootContent.isEmpty()) { |
1853 docRootContent = copyDocRootContent(docRootContent); |
1861 docRootContent = copyDocRootContent(docRootContent); |
1854 } else { |
1862 } else { |
1855 text = redirectRelativeLinks(element, (TextTree) dt); |
1863 text = redirectRelativeLinks(element, (TextTree) dt); |
1856 } |
1864 } |
1857 result.addContent(textCleanup(text, isLast(node))); |
1865 result.addContent(textCleanup(text, isLastNode)); |
1858 } |
1866 } |
1859 } else { |
1867 } else { |
1860 docRootContent = copyDocRootContent(docRootContent); |
1868 docRootContent = copyDocRootContent(docRootContent); |
1861 dt.accept(this, docRootContent); |
1869 dt.accept(this, docRootContent); |
1862 } |
1870 } |
1866 return false; |
1874 return false; |
1867 } |
1875 } |
1868 |
1876 |
1869 @Override |
1877 @Override |
1870 public Boolean visitComment(CommentTree node, Content c) { |
1878 public Boolean visitComment(CommentTree node, Content c) { |
1871 if (isFirstSentence && isFirst(node)) { |
|
1872 commentRemoved = true; |
|
1873 return this.visit(iterator.next(), c); |
|
1874 } |
|
1875 result.addContent(new RawHtml(node.getBody())); |
1879 result.addContent(new RawHtml(node.getBody())); |
1876 return false; |
1880 return false; |
1877 } |
1881 } |
1878 |
1882 |
1879 private Content copyDocRootContent(Content content) { |
1883 private Content copyDocRootContent(Content content) { |
1994 } |
1998 } |
1995 |
1999 |
1996 @Override |
2000 @Override |
1997 public Boolean visitText(TextTree node, Content c) { |
2001 public Boolean visitText(TextTree node, Content c) { |
1998 String text = node.getBody(); |
2002 String text = node.getBody(); |
1999 result.addContent(new RawHtml(textCleanup(text, isLast(node), commentRemoved))); |
2003 result.addContent(new RawHtml(textCleanup(text, isLastNode, commentRemoved))); |
2000 commentRemoved = false; |
|
2001 return false; |
2004 return false; |
2002 } |
2005 } |
2003 |
2006 |
2004 @Override |
2007 @Override |
2005 protected Boolean defaultAction(DocTree node, Content c) { |
2008 protected Boolean defaultAction(DocTree node, Content c) { |