Bug 212207 - [dom][javadoc] Javadoc of body declarations are set only if the compiler option for javadoc is enabled
Summary: [dom][javadoc] Javadoc of body declarations are set only if the compiler opti...
Status: CLOSED WONTFIX
Alias: None
Product: JDT
Classification: Eclipse Project
Component: Core (show other bugs)
Version: 3.4   Edit
Hardware: PC Windows XP
: P3 normal (vote)
Target Milestone: ---   Edit
Assignee: JDT Core Triaged CLA
QA Contact:
URL:
Whiteboard: stalebug
Keywords:
Depends on:
Blocks:
 
Reported: 2007-12-06 17:00 EST by Olivier Thomann CLA
Modified: 2020-03-15 17:01 EDT (History)
5 users (show)

See Also:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Olivier Thomann CLA 2007-12-06 17:00:48 EST
When creating a DOM/AST tree, the javadoc of body declarations are not set if the compiler options passed to the ASTParser don't enable the compiler option JavaCore.COMPILER_DOC_COMMENT_SUPPORT.

I could not find in the spec of the body declaration node a mention that this option need to be set.
I think the javadoc node should be set regardless of the compiler option. I don't expect errors to be reported on the javadoc links, but I expect the Javadoc node to be available if any.
Comment 1 Frederic Fusier CLA 2007-12-07 09:39:28 EST
Do you mean that we have to force this option while building the DOM/AST nodes, even if the user hasn't set it on the compiler or should we change the spec to warn the user?
Comment 2 Olivier Thomann CLA 2007-12-07 09:46:10 EST
It should be clear when the javadoc nodes can be retrieved out of a DOM/AST tree.
I think we should have two options:
1) to set the javadoc node
2) to resolve the javadoc node

2) implies 1), but 1) doesn't need 2). This would also be useful for 1.6 purpose.
Comment 3 Michael Rennie CLA 2007-12-07 11:15:54 EST
We encountered this problem working on a javadoc tag updater for API tooling. We have a visitor which adds missing javadoc tags for  a variety of restrictions and in the case of interfaces, even if there is a javadoc section, we end up creating a new one to add a missing tag.

Consider the following example:

BEFORE

/**
 * A runnable that represents one logical evaluation
 * to be run in a target thread. 
 * <p>
 * Clients are intended to implement this interface.
 * </p>
 * 
 * @see org.eclipse.jdt.debug.core.IJavaThread#runEvaluation(IEvaluationRunnable, IProgressMonitor, int, boolean)
 * @since 2.0
 */ 
public interface IEvaluationRunnable {
...
}

AFTER

 /**
  * @noimplement This interface is not intended to be implemented by clients.
  */
/**
 * A runnable that represents one logical evaluation
 * to be run in a target thread. 
 * <p>
 * Clients are intended to implement this interface.
 * </p>
 * 
 * @see org.eclipse.jdt.debug.core.IJavaThread#runEvaluation(IEvaluationRunnable, IProgressMonitor, int, boolean)
 * @since 2.0
 */ 
public interface IEvaluationRunnable {
...
}

 note: the new tag should appear with the other tags in the javadoc block (and does for other TypeDeclarations)
Comment 4 Frederic Fusier CLA 2007-12-07 11:58:48 EST
The only thing you need to do to fix this issue is to set ON the compiler
option 'Process Javadoc comments'.
Its id is "org.eclipse.jdt.core.compiler.doc.comment.support" and the
corresponding boolean field of CompilerOptions is 'docCommentSupport'.

Then, the Javadoc node will be created while building the DOM/AST tree and your
tag will be added properly in the existing Javadoc node instead of creating a
new node...

Note that if there are warnings in existing code Javadoc comments, they would
be reported only if the binding were resolved. And after having discussed with
Olivier, I understood that it should be not the case for your need.

-----------------

You can verify this behavior using the JDT/UI's ASTView on the simple following
test case:
/**
 * @see Unknown
 */
public class Test {}

By default the ASTView resolve bindings, so you'll see at the bottom of the
view:
- > compiler problems(1)
   + Javadoc: Unknown cannot be resolved to a type

To have no problem, just open the ASTView contextual menu and uncheck 'Create
bindings' item. Then, at the bottom of the view, you can see now:
  > compiler problems(0)
Comment 5 Markus Keller CLA 2008-02-21 14:32:38 EST
Do we have a use case for having this option disabled? We could also just deprecate the option, enable it all the time and remove the preference in the UI.

Observations in I20080220-1400:
- content assist does not read the option (works always)
- code select does not read the option (works always)
- Javadoc nodes are flat in global comments list (as specified in JavaCore.COMPILER_DOC_COMMENT_SUPPORT), but getJavadoc() on ASTNodes returns null, not the flat node.
Comment 6 Frederic Fusier CLA 2009-09-29 10:58:59 EDT
Olivier, what do you want to do about this?
Comment 7 Olivier Thomann CLA 2009-09-29 15:38:02 EDT
Resolving javadoc has a side-effect on unused imports.
This is why this option (-enableJavadoc) is enabled by default in the Eclipse build.

What I want is to be able to get the javadoc comment without the need to resolve them. So deprecating the option and enabling it by default could be one way to do it as long as this doesn't have bad side-effect for existing code base.
Comment 8 Eclipse Genie CLA 2020-03-15 17:01:35 EDT
This bug hasn't had any activity in quite some time. Maybe the problem got resolved, was a duplicate of something else, or became less pressing for some reason - or maybe it's still relevant but just hasn't been looked at yet. As such, we're closing this bug.

If you have further information on the current state of the bug, please add it and reopen this bug. The information can be, for example, that the problem still occurs, that you still want the feature, that more information is needed, or that the bug is (for whatever reason) no longer relevant.

--
The automated Eclipse Genie.