Bug 51911 - [Javadoc] @see method w/out ()
Summary: [Javadoc] @see method w/out ()
Status: VERIFIED FIXED
Alias: None
Product: JDT
Classification: Eclipse Project
Component: Core (show other bugs)
Version: 3.0   Edit
Hardware: PC All
: P3 normal (vote)
Target Milestone: 3.0 M9   Edit
Assignee: Frederic Fusier CLA
QA Contact:
URL:
Whiteboard:
Keywords:
: 54893 56754 58797 (view as bug list)
Depends on:
Blocks:
 
Reported: 2004-02-12 17:30 EST by Sebastian Davids CLA
Modified: 2004-07-29 09:24 EDT (History)
4 users (show)

See Also:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Sebastian Davids CLA 2004-02-12 17:30:45 EST
public class Test {

	/** @see Object#equals  */
	public boolean equals(Object obj) {
		return super.equals(obj);
	}
}

@@@@ 

The above should not flag "equals cannot be resolved or is not a field".

See fith exampe on:
http://java.sun.com/j2se/1.4.2/docs/tooldocs/windows/javadoc.html#seeexamples
Comment 1 Sebastian Davids CLA 2004-02-12 17:31:11 EST
fifth :D
Comment 2 Philipe Mulet CLA 2004-02-12 17:46:53 EST
Frederic - pls double check javadoc tool expectation before proceeding.

The example seems to allow it, but the further spec for @see tag doesn't 
mention it.
Comment 3 Sebastian Davids CLA 2004-02-12 18:10:20 EST
Using Javadoc (1.4.2) creates: 

@@@@

equals

public boolean equals(Object obj)

    See Also:
        Object.equals(java.lang.Object)

@@@@

I used Eclipse and checked "rt.jar" in the creation wizard.
Comment 4 Frederic Fusier CLA 2004-02-13 05:14:36 EST
This is correct, compiler should accept this syntax.

Here's the extract of spec which relates about this:
"...
If any method or constructor is entered as a name with no parentheses, such as 
getValue, and if there is no field with the same name, the Javadoc tool will 
correctly create a link to it, but will print a warning message reminding you 
to add the parentheses and arguments. If this method is overloaded, the Javadoc 
tool will link to the first method its search encounters, which is unspecified.
..."

I missed it while implementing it...
Comment 5 Frederic Fusier CLA 2004-03-24 16:08:13 EST
*** Bug 54893 has been marked as a duplicate of this bug. ***
Comment 6 Frederic Fusier CLA 2004-04-01 09:55:01 EST
*** Bug 56754 has been marked as a duplicate of this bug. ***
Comment 7 Dani Megert CLA 2004-04-15 03:15:46 EDT
Well, first I also thought it should not warn me (I even filed bug 56754) but I
changed my mind. Reason: the javadoc tool automatically replaces methods that
come without (...) with the first he finds, e.g.

a(int, float);
a();
a(String);

/**
 * @see #a
 */

will appear in Javadoc as:
 /**
  * @see <link to a(int, float)>
  */

Hence, #a does not denote all a's but will be replaced by exactly one of the
available methods.

I therefore vote to produce a warning for method references that have no (...).
Comment 8 Frederic Fusier CLA 2004-04-15 04:58:24 EDT
Thanks Daniel for the feedback.

I also agree that regarding Javadoc tool behavior, it would be better to let 
compiler warns user on this kind of syntax.

To make user life easier, perhaps a quick-fix could be to add all possible @see 
tags. In your example, then we would have after the quick-fix:

/**
 * @see #a(int, float)
 * @see #a()
 * @see #a(String)
 */

If all CCs agree, I will close this bug as RESOLVED INVALID...
Comment 9 Sebastian Davids CLA 2004-04-15 07:32:46 EDT
Change to a different warning is fine with me; something along the lines
"ambiguous type/field reference".

Having an accompanying quick fix would be appreciated but I'd consider it "if
time permits" for 3.0.

This PR is not about _not_ flagging a warning, but about an flagging an
appropriate warning, therefore RESOLVED-FIXED would be the right resolution in
my opinion =D
Comment 10 Frederic Fusier CLA 2004-04-15 10:46:03 EDT
Finally, I'll keep it this bug opened to track warning message change.

I also propose not to display this warning if there's no ambiguity on method 
name. For example, your initial example should not produce any warning as 
there's only one method equals on Object.

It would not make sense that compiler warns user on ambiguous reference 
although there was only one method, would it?
Comment 11 Dani Megert CLA 2004-04-15 10:51:43 EDT
Yes, correct. Though I'd say this is the luxury solution since AFAIK the Javadoc
reference specified that you either have to use "random text" or a _valid_
reference.
Comment 12 Frederic Fusier CLA 2004-04-26 06:22:47 EDT
Fixed.

Luxury solution was implemented (perhaps I have expensive tastes ;-):
1) message is only displayed when several methods exist on referenced class
2) message has been changed to:
"Javadoc: {0} is an ambiguous method reference or is not a field"

Note that in this case, this is now a JavadocMessageSend AST node which is 
stored in Javadoc.references array instead of JavadocFieldReference. 
Similarily, it's a MethodRef which replace initial Memberref stored in @see 
tagElement fragments. However, binding for this replaced MethodRef is null as 
we haven't enough information for the arguments...

[jdt-core-internal]
New message [508] added in IProblem/message.properties,
New method javadocAmbiguousMethodReference(FieldReference, int) added in 
ProblemReporter,
JavadocFieldReference.internalResolveType(Scope) modified to take into account 
possible method reference when field reference is not found,
Javadoc resolve(ClassScope) and resolve(MethodScope) methods modified to 
replace field reference by message send when unique method exists on referenced 
type.

Test cases added in JavadocTestMixed
Comment 13 Frederic Fusier CLA 2004-04-26 06:38:34 EDT
*** Bug 58797 has been marked as a duplicate of this bug. ***
Comment 14 Olivier Thomann CLA 2004-05-18 11:52:39 EDT
Verified in 200405180816