Bug 206345 - [javadoc] compiler should not interpret contents of {@literal} or {@code}
Summary: [javadoc] compiler should not interpret contents of {@literal} or {@code}
Status: VERIFIED FIXED
Alias: None
Product: JDT
Classification: Eclipse Project
Component: Core (show other bugs)
Version: 3.4   Edit
Hardware: PC Windows XP
: P3 normal with 4 votes (vote)
Target Milestone: 4.7 M4   Edit
Assignee: Eric Jodet CLA
QA Contact:
URL:
Whiteboard:
Keywords:
: 258706 260478 (view as bug list)
Depends on:
Blocks:
 
Reported: 2007-10-15 12:19 EDT by Markus Keller CLA
Modified: 2016-12-07 03:14 EST (History)
8 users (show)

See Also:
jarthana: review+


Attachments
[proposed patch + test case] on top v_858 - all jdt.core tests OK (4.37 KB, patch)
2008-05-06 00:43 EDT, Eric Jodet CLA
no flags Details | Diff
[proposed patch + test cases] on top v865 - all jdt.core tests OK (28.56 KB, patch)
2008-05-16 09:10 EDT, Eric Jodet CLA
no flags Details | Diff
Synced up patch (28.45 KB, patch)
2016-07-15 06:17 EDT, Jay Arthanareeswaran CLA
no flags Details | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Markus Keller CLA 2007-10-15 12:19:29 EDT
I20071010-1200

/**
 * This is {@literal raw text:
 * 		{@link Try} is just text}
 * }
 */
public class Try { }

Javadoc.exe compiles this without any warning. It also does not interpret the '{@link}' tag inside the '{@literal}'.

http://java.sun.com/j2se/1.5.0/docs/tooldocs/windows/javadoc.html#{@literal} says: "Displays text without interpreting the text as HTML markup or nested javadoc tags."

Eclipse should do the same as Javadoc.exe. Currently it errors 'Javadoc: Missing closing brace for inline tag' as soon as a '{' or a line delimiter appears inside an '{@literal}' tag.
Comment 1 Frederic Fusier CLA 2007-10-16 04:52:34 EDT
Looks similar to bug 206319 => I also think this inconsistency should be fixed for 3.4

Markus, have you verified the "text" portion in all other Javadoc tags than @see (bug 206319) and @literal (this bug)? If not, Eric please verify and open other bugs if necessary, thanks
Comment 2 Markus Keller CLA 2007-10-16 09:00:29 EDT
> [..] Currently it errors 'Javadoc:
> Missing closing brace for inline tag' as soon as a '{' or a line delimiter
> appears inside an '{@literal}' tag.
Sorry, line delimiters are not a problem here, just '{' inside inline tags.

This bug also applies to text inside {@code}.
Comment 3 Eric Jodet CLA 2008-05-06 00:41:10 EDT
(In reply to comment #1)
> (...) If not, Eric please verify and open other bugs if necessary, thanks
verified that only @literal and @code tags were presenting this issue.
Comment 4 Eric Jodet CLA 2008-05-06 00:43:12 EDT
Created attachment 98747 [details]
[proposed patch + test case] on top v_858 - all jdt.core tests OK
Comment 5 Frederic Fusier CLA 2008-05-06 04:42:52 EDT
(In reply to comment #4)
> Created an attachment (id=98747) [details]
> [proposed patch + test case] on top v_858 - all jdt.core tests OK
> 
With this patch, the structure of the Javadoc in the ASTView for the original test case is now:
TagElement
  + FRAGMENTS (5)
    + TextElement
    + TagElement
    + TagElement
    + TextElement
    + TextElement

This is not correct. As said in bug 206319, we only should have:
TagElement
  + FRAGMENTS (3)
    + TextElement
    + TagElement
      + FRAGMENTS (1)
        + TextElement
    + TextElement

Note that the last text element is due to the extra closing brace at the end of the javadoc, which, I guess, is a typo in the test case...

So, do not report the problem this is not enough, the javadoc parser needs to ignore inline tags inside @literal tags (and @code tags for bug 206319) and not be screwed up by any pair of braces...
Comment 6 Jerome Lanneluc CLA 2008-05-12 07:01:11 EDT
Tentatively targeting RC1
Comment 7 Jerome Lanneluc CLA 2008-05-12 10:14:38 EDT
Actually we won't have time for 3.4. Deferring
Comment 8 Eric Jodet CLA 2008-05-16 09:10:19 EDT
Created attachment 100634 [details]
[proposed patch + test cases] on top v865 - all jdt.core tests OK

improved fix + added corresponding ASTConverterJavadocTest test cases
Comment 9 Eric Jodet CLA 2008-05-16 09:13:05 EDT
frederic, jerome: please review - thanks
Comment 10 Jerome Lanneluc CLA 2008-05-20 07:25:53 EDT
This is not a regression comparing to 3.3.2. Will fix for 3.5
Comment 11 Frederic Fusier CLA 2008-09-12 11:54:07 EDT
Not sure I'll have enough time to validate and finalize the proposed patch...
Comment 12 Frederic Fusier CLA 2009-01-09 03:43:52 EST
*** Bug 260478 has been marked as a duplicate of this bug. ***
Comment 13 Frederic Fusier CLA 2009-01-09 03:46:31 EST
Update summary to make it clear that this bug fix should also work for {@code} tag...
Comment 14 Srikanth Sankaran CLA 2010-01-13 01:44:25 EST
Satyam, please investigate -- Thanks.
Comment 15 Dave Bort CLA 2012-01-11 15:35:24 EST
Still appears to be happening in

Version: 3.7.0
Build id: I20110613-1736
Comment 16 Markus Keller CLA 2014-03-30 20:40:36 EDT
*** Bug 258706 has been marked as a duplicate of this bug. ***
Comment 17 Christopher Tubbs CLA 2016-06-02 21:26:48 EDT
This is still happening in Mars.2:
  Version: Mars.2 (4.5.2)
  Build id: Z20160416-2208

This is causing a lot of frustration, because it's preventing multi-line @code comments in an otherwise warnings-free environment.
Comment 18 Jay Arthanareeswaran CLA 2016-07-15 06:17:47 EDT
Created attachment 263122 [details]
Synced up patch

The previous patch being very old couldn't be applied on HEAD. I have re created it on HEAD. I am yet to review or run all tests, but quickly checked it solves the problem mentioned in comment #0 and satisfies Fred's earlier comment.

Meant to push this to Gerrit, but looks lik Eric doesn't have CLA signed and it's been a long time since he was involved with Eclipse. Need to check with him.
Comment 19 Eclipse Genie CLA 2016-07-18 05:49:56 EDT
New Gerrit change created: https://git.eclipse.org/r/77462
Comment 20 Jay Arthanareeswaran CLA 2016-07-19 05:08:43 EDT
Looks like some of the recent changes are not working well with the patch. The problem position is not correct for the new tests. Needs more time for this.
Comment 21 Markus Keller CLA 2016-07-19 10:39:42 EDT
(In reply to Jay Arthanareeswaran from comment #18)
> Meant to push this to Gerrit, but looks lik Eric doesn't have CLA signed and
> it's been a long time since he was involved with Eclipse. Need to check with
> him.

Since you've re-created the changes, you can also set yourself as the Author and mention Eric in an "Also-By: " line in the commit message.
Comment 22 Jay Arthanareeswaran CLA 2016-12-05 08:05:47 EST
Just came back to this patch but one of the new tests is failing. Will take a look at it.
Comment 23 Eclipse Genie CLA 2016-12-05 08:41:32 EST
New Gerrit change created: https://git.eclipse.org/r/86364
Comment 24 Jay Arthanareeswaran CLA 2016-12-05 10:47:39 EST
The failures were due to problems in test case itself. Pushed after fixing them here:

http://git.eclipse.org/c/jdt/eclipse.jdt.core.git/commit/?id=0b0f856ffea622a77c7ebc01bae802a409925214
Comment 25 Sasikanth Bharadwaj CLA 2016-12-07 03:14:17 EST
Verified for 4.7 M4 using I20161205-2000 build