Some Eclipse Foundation services are deprecated, or will be soon. Please ensure you've read this important communication.
Bug 327191 - Additional information in content-assist shows up only for types, not for functions
Summary: Additional information in content-assist shows up only for types, not for fun...
Status: RESOLVED FIXED
Alias: None
Product: JSDT
Classification: WebTools
Component: General (show other bugs)
Version: 3.2.2   Edit
Hardware: PC Mac OS X - Carbon (unsup.)
: P3 normal (vote)
Target Milestone: 3.2.3   Edit
Assignee: Jacek Pospychala CLA
QA Contact: Nitin Dahyabhai CLA
URL:
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2010-10-07 04:46 EDT by Jacek Pospychala CLA
Modified: 2010-11-17 18:06 EST (History)
1 user (show)

See Also:
thatnitind: review+
cmjaun: review+


Attachments
screenshot (67.54 KB, image/png)
2010-10-07 04:53 EDT, Jacek Pospychala CLA
no flags Details
patch (2.00 KB, patch)
2010-10-07 06:06 EDT, Jacek Pospychala CLA
no flags Details | Diff
patch v2 (1.13 KB, patch)
2010-10-08 03:34 EDT, Jacek Pospychala CLA
no flags Details | Diff
patch v2 alternative (2.00 KB, patch)
2010-10-08 03:44 EDT, Jacek Pospychala CLA
thatnitind: iplog+
Details | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Jacek Pospychala CLA 2010-10-07 04:46:41 EDT
Given following code:

/**
 * Returns the sum of a and b.
 */
function sum(a, b) {
	return a + b;
}

/**
 * Summarizer
 * 
 * @constructor
 */
function Sum() {
	
}

After invoking content-assist, for e.g. "su", you should see three proposals: sum(a, b), Sum as type as Sum() function call. 
Additional information with jsdoc appears only for Sum as type and not for functions.
Comment 1 Jacek Pospychala CLA 2010-10-07 04:53:08 EDT
Created attachment 180397 [details]
screenshot
Comment 2 Jacek Pospychala CLA 2010-10-07 05:29:56 EDT
the problem is somewhere in MethodProposalInfo.resolveMember().
Trying to find enclosing type of a method results with null:

javaProject.findType("/p/aa.js") returns null
"/p/aa.js" is the name of file in this case, because methods are declared directly in file.
Comment 3 Jacek Pospychala CLA 2010-10-07 06:06:21 EDT
Created attachment 180405 [details]
patch

It's caused by changes to bug 316327
Proposed changes in MethodProposalInfo.resolveMember():
1. construct like below will never enter the loop. So I modified loop a bit.

IFunction func = null; 
for(int i = 0; i < types.length && func != null; ++i) { ... loop... }

2. javaPropect.getTypes(typeName) can return 1-element array with null, when type was not found. In this case it's worth trying also javaProject.findTypeRoot(typeName), so I removed "else".
Comment 4 Jacek Pospychala CLA 2010-10-07 06:08:08 EDT
Take a look at this patch guys.
Comment 5 Nitin Dahyabhai CLA 2010-10-07 18:20:27 EDT
Don't we get the same result by fixing the for loop so the condition is "i < types.length && func == null" ?
Comment 6 Jacek Pospychala CLA 2010-10-08 03:33:28 EDT
yes, this works as well.
but there's still need to support calling javaProject.findTypeRoot() if javaProject.findTypes() returned IType[1] {null}.
Comment 7 Jacek Pospychala CLA 2010-10-08 03:34:05 EDT
Created attachment 180475 [details]
patch v2

improved patch
Comment 8 Jacek Pospychala CLA 2010-10-08 03:43:09 EDT
btw. probably it's a separate issue that javaProject.findTypes() sometimes returns IType[1] {null}. It should return null instead.
Comment 9 Jacek Pospychala CLA 2010-10-08 03:44:43 EDT
Created attachment 180476 [details]
patch v2 alternative

Different patch, that fixes problem with returned value in javaProject.findTypes(name) and changes "!=" to "==" in MethodProposalInfo.
Comment 10 Nitin Dahyabhai CLA 2010-11-17 18:06:22 EST
Nice fix, Jacek, thanks!