Bug 306958 - [hotbug][Content Assist] No parameters populated for constructor for code completion
Summary: [hotbug][Content Assist] No parameters populated for constructor for code com...
Status: RESOLVED FIXED
Alias: None
Product: JSDT
Classification: WebTools
Component: General (show other bugs)
Version: unspecified   Edit
Hardware: PC Windows XP
: P2 major (vote)
Target Milestone: 3.2.5   Edit
Assignee: Ian Tewksbury CLA
QA Contact: Nitin Dahyabhai CLA
URL:
Whiteboard: WI63635
Keywords:
: 324690 (view as bug list)
Depends on:
Blocks: 330614 350975 350976
  Show dependency tree
 
Reported: 2010-03-24 12:02 EDT by Rosa Tse CLA
Modified: 2011-07-07 09:51 EDT (History)
4 users (show)

See Also:
thatnitind: review+
cmjaun: review+


Attachments
Fix Patch (21.83 KB, patch)
2010-08-26 17:15 EDT, Ian Tewksbury CLA
no flags Details | Diff
Fix Patch - Update 1 (23.03 KB, patch)
2010-08-27 17:06 EDT, Ian Tewksbury CLA
no flags Details | Diff
Fix Patch with JUnits - Update 2 (79.10 KB, text/plain)
2010-09-02 11:24 EDT, Ian Tewksbury CLA
no flags Details
Fix Patch with JUnits - Update 3 (77.76 KB, patch)
2010-09-07 16:08 EDT, Ian Tewksbury CLA
no flags Details | Diff
Testing ZIP (2.12 KB, application/octet-stream)
2010-09-07 16:09 EDT, Ian Tewksbury CLA
no flags Details
Fix Patch with JUnits - Update 4 (79.87 KB, patch)
2010-09-14 14:32 EDT, Ian Tewksbury CLA
no flags Details | Diff
inappropriate proposals shown with "new |" (24.71 KB, image/png)
2010-09-28 15:41 EDT, Nitin Dahyabhai CLA
no flags Details
Fix Patch with JUnits - Update 5 (92.05 KB, patch)
2010-09-29 13:35 EDT, Ian Tewksbury CLA
no flags Details | Diff
Testing ZIP - Update 1 (2.51 KB, application/octet-stream)
2010-09-29 13:36 EDT, Ian Tewksbury CLA
no flags Details
Fix Patch with JUnits - Update 6 (91.24 KB, patch)
2010-09-30 11:27 EDT, Ian Tewksbury CLA
no flags Details | Diff
Fix Patch with JUnits - Update 6 (89.84 KB, patch)
2010-09-30 14:05 EDT, Ian Tewksbury CLA
no flags Details | Diff
Fix Patch with JUnits - Update 7 (94.00 KB, patch)
2010-11-18 10:48 EST, Ian Tewksbury CLA
no flags Details | Diff
Testing ZIP - Update 2 (2.73 KB, application/octet-stream)
2010-11-18 10:49 EST, Ian Tewksbury CLA
no flags Details
Testing ZIP - Update 3 (3.34 KB, application/octet-stream)
2010-11-30 14:01 EST, Ian Tewksbury CLA
no flags Details
Fix Patch with JUnits - Update 8 (91.73 KB, patch)
2010-11-30 14:02 EST, Ian Tewksbury CLA
no flags Details | Diff
Fix Patch with JUnits - Update 9 (103.40 KB, patch)
2010-12-08 14:25 EST, Ian Tewksbury CLA
no flags Details | Diff
Fix Patch with JUnits - Update 10 (103.25 KB, patch)
2011-01-06 14:08 EST, Ian Tewksbury CLA
no flags Details | Diff
Fix Patch with JUnits - Update 11 (119.79 KB, patch)
2011-01-07 11:41 EST, Ian Tewksbury CLA
no flags Details | Diff
Fix Patch with JUnits - Update 12 (117.55 KB, patch)
2011-01-12 15:30 EST, Ian Tewksbury CLA
no flags Details | Diff
Fix Patch with JUnits - Update 13 (121.40 KB, patch)
2011-01-18 17:23 EST, Ian Tewksbury CLA
no flags Details | Diff
New Patch with Junits (162.25 KB, patch)
2011-01-21 14:19 EST, Ian Tewksbury CLA
no flags Details | Diff
New Patch with JUnits - Update 1 (160.59 KB, patch)
2011-06-09 17:07 EDT, Ian Tewksbury CLA
no flags Details | Diff
New Patch with JUnits - Update 2 (163.37 KB, patch)
2011-06-13 16:46 EDT, Ian Tewksbury CLA
no flags Details | Diff
New Patch with JUnits - Update 3 (160.03 KB, patch)
2011-06-15 10:58 EDT, Ian Tewksbury CLA
no flags Details | Diff
New Patch with JUnits - Update 4 (161.59 KB, patch)
2011-06-15 13:35 EDT, Ian Tewksbury CLA
no flags Details | Diff
New Patch with JUnits - Update 5 (185.35 KB, patch)
2011-06-16 12:03 EDT, Ian Tewksbury CLA
no flags Details | Diff
New Patch with JUnits - Update 6 (187.51 KB, patch)
2011-06-16 12:22 EDT, Ian Tewksbury CLA
no flags Details | Diff
patch with JUnits - Update 7 (187.55 KB, patch)
2011-06-20 16:31 EDT, Ian Tewksbury CLA
no flags Details | Diff
patch with JUnits - Update 8 (187.92 KB, patch)
2011-06-21 17:05 EDT, Ian Tewksbury CLA
no flags Details | Diff
Testing ZIP - Update 4 (3.72 KB, application/zip)
2011-06-29 15:01 EDT, Ian Tewksbury CLA
thatnitind: iplog+
Details
patch with JUnits - Update 9 (292.37 KB, patch)
2011-06-29 15:05 EDT, Ian Tewksbury CLA
no flags Details | Diff
Fix patch - Update 10 (292.78 KB, patch)
2011-06-30 16:32 EDT, Ian Tewksbury CLA
no flags Details | Diff
fix patch - update 12 (297.79 KB, patch)
2011-07-01 10:58 EDT, Ian Tewksbury CLA
no flags Details | Diff
fix patch - update 13 (297.82 KB, patch)
2011-07-01 11:07 EDT, Ian Tewksbury CLA
thatnitind: iplog+
Details | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Rosa Tse CLA 2010-03-24 12:02:22 EDT
Build Identifier: Eclipse 3.5.1 - JavaScript Developer Tools 1.1.2.v200908101420-77-FGCCcNBC-BhLcE_Pm - Build id: 20090917225226

Code completion does not populate parameters for constructor.

Animal.prototype=new Object();
function Animal(name){}; // when code completion is invoked, user has no idea the Animal constructor takes any param
Animal.prototype.property="";
Animal.prototype.eat=function(food){};

Reproducible: Always

Steps to Reproduce:
1. Define the above in your JavaScript.
2. Enter "var deer = new Ani" then Ctrl+Space. "Ani" is expanded to "Animal", but there is no bracket and param displayed.
3. Now complete the declaration so that it looks like:
var deer = new Animal('Sam');
4. Now type "deer.e" then Ctrl+Space, see that it's expanded to "deer.eat(food)".

Can code completion for constructors works like a regular function?
Comment 1 Rosa Tse CLA 2010-03-24 12:33:57 EDT
JSDoc is not shown for constructor as well.
Comment 2 Chris Jaun CLA 2010-04-02 11:40:11 EDT
I think the problem here is that the constructor function is not actually shown in content assist. It is only showing the name of class.
Comment 3 Nitin Dahyabhai CLA 2010-04-14 20:37:07 EDT
The AssistParser has been modified to just show type names, but without that modification we get all of the visible variable and function names instead (even if that includes constructors).
Comment 4 Rosa Tse CLA 2010-05-07 09:52:19 EDT
Adding information as per the WTP Hotbug policy
(http://wiki.eclipse.org/WTP/Hotbug_Policy):

1. Affiliation: RIM
2. Targeted Release: The fix needs to go into the final release of WTP 3.2 so
it's fixed in Eclipse 3.6.
3. Reason why this is a hotbug: This bug blocks our adoption of WTP because the
JavaScript code completion is a critical feature of our product. Fixing this bug would make code completion much more usable if the user knows what parameters the constructor(s) would accept.
Comment 5 Nitin Dahyabhai CLA 2010-05-20 13:54:24 EDT
Deferring.  Not enough time left.
Comment 6 Ian Tewksbury CLA 2010-08-26 17:15:24 EDT
Created attachment 177568 [details]
Fix Patch

This patch seems to work to get constructor content assist working.  But I have 102 failing existing JUnits I need to look into and write some new JUnits.
Comment 7 Ian Tewksbury CLA 2010-08-27 17:06:57 EDT
Created attachment 177649 [details]
Fix Patch - Update 1

These are the scenarios that Chris and I have identified that should work:

----
file1.js:

function Awesome(param1, param2) {
	this.param1 = param1;
	this.param2 = param2;
};

bar.Class1 = function(a, b) {};
bar.Class1.prototype = new Object();
----

With this setup the following should work in "file1.js" or a separate "file2.js" with "file1.js" being open or closed (in memory model or index model).

new Aw|
new b|
new bar.|
new bar.Cl|
new Cla|

With this new patch the only scenario that does not work is "new Cla|" in a separate "file2.js" with "file1.js" open or closed.

I know why this.  I just haven't figured out how to get around the problem.

With this patch all existing JUnits also pass.  Well 2 didn't but that was a case where the JUnit was now wrong so had to be updated.

----

Things to do:
* Write new JUnits to test new functionality
* get the one broken scenario working
Comment 8 Chris Jaun CLA 2010-08-27 17:13:43 EDT
Good work Ian.
Comment 9 Ian Tewksbury CLA 2010-09-02 11:24:45 EDT
Created attachment 178055 [details]
Fix Patch with JUnits - Update 2

Same fix now plus 20 new junits.  Still one more scenario to fix which is the one new junit that fails.  all existing junits pass.
Comment 10 Ian Tewksbury CLA 2010-09-07 16:08:26 EDT
Created attachment 178355 [details]
Fix Patch with JUnits - Update 3

Cleaned up patch.  Disabled JUnit for Bug 324690.  Bug 324960 will cover fixing the one case this patch does not deal with.

Patch ready for review.
Comment 11 Ian Tewksbury CLA 2010-09-07 16:09:48 EDT
Created attachment 178356 [details]
Testing ZIP

This Zip file needs to be placed in "org.eclipse.wst.jsdt.ui.tests/testresources/ContentAssist.zip" for the JUnits to work.
Comment 12 Ian Tewksbury CLA 2010-09-07 16:19:27 EDT
* Explain why you believe this is a stop-ship defect. Or, if it is a "hotbug" (requested by an adopter) please document it as such.

Hotbug requested by an adopter

* Is there a work-around? If so, why do you believe the work-around is insufficient?

No there is not.  Without this fix there is no content assist for constructors in JSDT

* How has the fix been tested? Is there a test case attached to the bugzilla record? Has a JUnit Test been added?

I have added 19 JUnits to cover every possibility I can think of.  I have also smoke tested the new and existing functionality.  All existing tests pass.

* Give a brief technical overview. Who has reviewed this fix?

JSDT Core had to be tweaked in many places to get content assist for constructors to show up.  The fix spans everything form the content assist code, the search engine code, the compiler, and the infer engine.  There is no one major fix in any one place just a lot of 1-10 line fixes here and there to get the story working.  The idea of constructors already existed it just wasn't fully flushed out for the content assist story.  Things are extra complicated by constructors for classes in packages.  No one part of this patch fixes anything on its own, only with all of the parts together does the full constructor content assist story work (except for the one case mentioned in Bug 324690)

* What is the risk associated with this fix?

Mitigated Medium.  It is Medium because there are changes here in the basic classes of JSDT when it comes to the search engine and the infer engine (again minor tweaks, but changes none-the-less).  But it is mitigated because of the extensive testing done on existing functionality and new functionality.
Comment 13 Ian Tewksbury CLA 2010-09-14 14:08:11 EDT
*** Bug 324690 has been marked as a duplicate of this bug. ***
Comment 14 Ian Tewksbury CLA 2010-09-14 14:32:29 EDT
Created attachment 178862 [details]
Fix Patch with JUnits - Update 4

This patch fixes the one scenario that was not working, represented by the following example:

File1.js
-----
bar.Class1 = function(a, b) {};
bar.Class1.prototype = new Object();
-----

File2.js
-----
new Cla|
-----

JUnit has been enabled to test this case (test zip does NOT need to be updated).
All existing JUnits pass.
Smoke test of content assist passes.
Comment 15 Nitin Dahyabhai CLA 2010-09-28 15:41:22 EDT
Created attachment 179784 [details]
inappropriate proposals shown with "new |"

Current patch (attachment 178862 [details]) seems to include all of the properties of Object and Global as potential constructors as well as the types that were shown pre-patch.

It should also patch the new test folder into that bundle's build.properties file.
Comment 16 Chris Jaun CLA 2010-09-28 15:43:29 EDT
Another problem...

function Class1() {
	this.a = 3;
}

var a = new Class1();


var Class2 = function() {};
Class2.prototype.meth = function() {};

new Clas*


When I attempt content assist I do not get the constructor for Class2.
Comment 17 Ian Tewksbury CLA 2010-09-29 13:35:11 EDT
Created attachment 179871 [details]
Fix Patch with JUnits - Update 5

Patch updated to deal with issues brought up in comment 15 and comment 16.

Also added more JUnits.
Comment 18 Ian Tewksbury CLA 2010-09-29 13:36:32 EDT
Created attachment 179872 [details]
Testing ZIP - Update 1

An updated testing zip for fix patch update 5.  Still needs to go in "org.eclipse.wst.jsdt.ui.tests/testresources/ContentAssist.zip"
Comment 19 Ian Tewksbury CLA 2010-09-30 11:27:50 EDT
Created attachment 179972 [details]
Fix Patch with JUnits - Update 6

Last patch accidentally included a testing println statement.
Comment 20 Ian Tewksbury CLA 2010-09-30 14:05:11 EDT
Created attachment 179983 [details]
Fix Patch with JUnits - Update 6

Found a couple more testing lines that snuck through.
Comment 21 Chris Jaun CLA 2010-11-17 17:07:16 EST
var o = {
		a: new *
}

Content assist at * returns all methods.
Comment 22 Ian Tewksbury CLA 2010-11-18 08:29:05 EST
(In reply to comment #21)
> var o = {
>         a: new *
> }
> 
> Content assist at * returns all methods.

Because that is also the current behavior and you have been worried about the size and scope of this patch already, my suggestion would be to put it in as is and open a separate report for that issue.  Unless you want me to grow the size and scope of this patch to include this issue as well.
Comment 23 Ian Tewksbury CLA 2010-11-18 09:20:09 EST
(In reply to comment #22)
> (In reply to comment #21)
> > var o = {
> >         a: new *
> > }
> > 
> > Content assist at * returns all methods.
> 
> Because that is also the current behavior and you have been worried about the
> size and scope of this patch already, my suggestion would be to put it in as is
> and open a separate report for that issue.  Unless you want me to grow the size
> and scope of this patch to include this issue as well.

I take that back.  When responding to comment 15 i thought I had fixed this.  And I sort of did for the case

new |

it would seem your case
var o = {
  a: new |
}

is somehow different.

Looking into why and see if I can fix it.
Comment 24 Ian Tewksbury CLA 2010-11-18 10:48:01 EST
Created attachment 183390 [details]
Fix Patch with JUnits - Update 7

Fixed issue mentioned in comment 21. Fix was needed in CompletionEngine#isAllocationExpression to deal with allocation expressions nested inside of other expressions.  Now using an ASTVisitor to determine if the completion expression is part of an allocation expression.

Added new junits to test for the scenario in comment 21.

Removed unnecessary changes to SearchPattern.  After further investigation must have been left over from some earlier attempt I made.
Comment 25 Ian Tewksbury CLA 2010-11-18 10:49:25 EST
Created attachment 183391 [details]
Testing ZIP - Update 2

An updated testing zip for fix patch update 7.  Still needs to go in
"org.eclipse.wst.jsdt.ui.tests/testresources/ContentAssist.zip"
Comment 26 Ian Tewksbury CLA 2010-11-18 16:30:03 EST
I opened Bug 330614 to track using working copies when available for content assist.
Comment 27 Ian Tewksbury CLA 2010-11-18 16:36:39 EST
(In reply to comment #26)
> I opened Bug 330614 to track using working copies when available for content
> assist.

Ignore this, with this patch the working copies are used.
Comment 28 Ian Tewksbury CLA 2010-11-30 14:01:04 EST
Created attachment 184171 [details]
Testing ZIP - Update 3

Updated testing zip for:
"org.eclipse.wst.jsdt.ui.tests/testresources/ContentAssist.zip"
Comment 29 Ian Tewksbury CLA 2010-11-30 14:02:00 EST
Created attachment 184172 [details]
Fix Patch with JUnits - Update 8

More JUnits added.
Comment 30 Ian Tewksbury CLA 2010-12-08 14:25:54 EST
Created attachment 184812 [details]
Fix Patch with JUnits - Update 9

Update the patch that gets rid of some unnecessary changes that suck their way in while developing.

Also fixes issue with <init>() being proposed in the case of
new |
For that case only constructors in the current document are suggested and <init>() was coming up because of an issue in MethodScope#createMethod.  Now for the blank document case doing new | will give the suggestions:
Global(), Object(), Window() which are the parent types of any given JS document.

I also fixed it so that in the allocation expression content assist case (aka: new *|) only constructors are now recommended.  There was an issue that when searching the namespace all bindings would be returned not just constructors.
Comment 31 Ian Tewksbury CLA 2011-01-06 14:08:39 EST
Created attachment 186212 [details]
Fix Patch with JUnits - Update 10

Updated patch to apply cleanly with latest code in 3.2.x stream but there seem to be some errors in the existing JUnits. Problem seems to be around the fix for comment #30.  I will update when I figure out whats going on.
Comment 32 Ian Tewksbury CLA 2011-01-07 11:41:15 EST
Created attachment 186287 [details]
Fix Patch with JUnits - Update 11

This patch updates Scope#getConstructor to work correctly with the rest of the patch, most notably not searching for "<init>" and not validating parameters.  This method is what was causing the JUnit fails after implementing comment 30.

This patch also updates all of the copyright years to 2011
Comment 33 Ian Tewksbury CLA 2011-01-12 15:30:36 EST
Created attachment 186670 [details]
Fix Patch with JUnits - Update 12

Resolved conflicts with latest 3.2.3 code and patch.
Comment 34 Ian Tewksbury CLA 2011-01-18 17:23:31 EST
Created attachment 187057 [details]
Fix Patch with JUnits - Update 13

Updated patch to update SourceTypeBinding to ensure that the scope for a method gets bound correctly.

Also updated JUnits that started to fail because of this, but it turns out that they were hard coded with a broken solution and the new solution is actually correct.

Testing ZIP does not need to change.
Comment 35 Ian Tewksbury CLA 2011-01-21 14:19:22 EST
Created attachment 187315 [details]
New Patch with Junits

This patch is different from the previous because it changes the type of completion node that is used.  Because of this and currently limitations on the parser this patch does not allow constructor content assist to work for the following case

new foo.bar.MyCo|

If this is the patch used then a new bug will have to be open to track fixes needed to the parser to support this case.
Comment 36 Nitin Dahyabhai CLA 2011-03-23 21:44:08 EDT
We found some more issues ad-hoc testing today.  Trying to apply a completion for the constructor for "com.foo" did nothing--it may have even removed what Chris was typing to filter his list down.

Far less important, the proposal icon's also still the Class image, not the function/method image.
Comment 37 Ian Tewksbury CLA 2011-03-24 08:16:41 EDT
(In reply to comment #36)
> We found some more issues ad-hoc testing today.  Trying to apply a completion
> for the constructor for "com.foo" did nothing--it may have even removed what
> Chris was typing to filter his list down.
> 

See comment #35.  That case is not going to work with the updated patch you asked for.  If you want to go back to my original patch that scenario works as expected.

> Far less important, the proposal icon's also still the Class image, not the
> function/method image.

That should not be to hard to fix.
Comment 38 Chris Jaun CLA 2011-03-24 09:28:54 EDT
(In reply to comment #36)
> We found some more issues ad-hoc testing today.  Trying to apply a completion
> for the constructor for "com.foo" did nothing--it may have even removed what
> Chris was typing to filter his list down.
> 
> Far less important, the proposal icon's also still the Class image, not the
> function/method image.

The image is not really an issue. It was just showing the type proposal.

The most important issue was the ArrayIndexOutOfBounds exception I was seeing.
Comment 39 Ian Tewksbury CLA 2011-03-24 09:36:17 EDT
(In reply to comment #38)
> (In reply to comment #36)
> > We found some more issues ad-hoc testing today.  Trying to apply a completion
> > for the constructor for "com.foo" did nothing--it may have even removed what
> > Chris was typing to filter his list down.
> > 
> > Far less important, the proposal icon's also still the Class image, not the
> > function/method image.
> 
> The image is not really an issue. It was just showing the type proposal.
> 
> The most important issue was the ArrayIndexOutOfBounds exception I was seeing.

I see no comment here about an ArrayIndexOutOfBounds.  Whats the stack?
Comment 40 Ian Tewksbury CLA 2011-06-09 17:07:13 EDT
Created attachment 197744 [details]
New Patch with JUnits - Update 1

Updates the patch to apply against latest 3.2m stream.  Tested and works.
Comment 41 Ian Tewksbury CLA 2011-06-09 17:20:16 EDT
Some high level info:

* index version updated because now constructors that were not in the index will now be in the index and thus projects need re-indexing

* add a new proposal type for constructors, idea taken from JDT

* completionengine updated so it can do searches looking only for constructors which are METHOD bindings that have isConstructor set to true

* updated a couple classes to stop ignoring working copies, ignoring working copies meant that no constructors from open files would be included in results

* updated enviorment and search of index to use regular expression so when matching on "Test|" will match on
Test
TestBar
foo.Test
foo.TestBar
test.foo.Bar

I did performance testing, no difference using or not using regex

* made it so the inferred name of a function will be used if the method declarion did not have a name, this helps with cases like foo = function() {}, also some other changes to support that

* updated some cases to fix up argument binding to the constructors, specifically getting the name and type of the arguments

* wrote a TON of JUnits that tests both general function content assist and constructor content assist.  There are also extra tests in there that are turned off for when comment 35 is addressed
Comment 42 Ian Tewksbury CLA 2011-06-13 16:46:06 EDT
Created attachment 197928 [details]
New Patch with JUnits - Update 2

Same as the last patch except for now cases like "new foo.bar.Aw|" now work.

CompletionParser#createAssistTypeForAllocation
* updated to take a CompletionOnMemberAccess and turn it into a CompletionOnSingleTypeReference
* this only happens when the COmpletionOnMememberAccess is in an AllocationExpression

CompletionOnMembmerAccess#isSpecial
*now overrides parent to return true because it is a special node because it is a completion node

ContentAssistTests
* added back all of the tests having to do with cases like "new foo.bar.Aw|"
Comment 43 Chris Jaun CLA 2011-06-15 10:26:22 EDT
The following junits are failing after applying this patch.....

InferTypesTest
- test068
- test069

Please investigate before we review the patch.
Comment 44 Ian Tewksbury CLA 2011-06-15 10:58:17 EDT
Created attachment 198031 [details]
New Patch with JUnits - Update 3

To address comment 43, not even sure how this test passed before my fix, there is a line in InferEngine that was commented out at some point that sets the type for a constructor, I added to my patch to add that line back.  All new and existing JUnits now pass.

I also updated Scope#getConstructor, I ran into an edge case that could cause some NPEing, that is now protected against.
Comment 45 Ian Tewksbury CLA 2011-06-15 13:35:00 EDT
Created attachment 198043 [details]
New Patch with JUnits - Update 4

Updated InferedType#addConstructorMethod to perform some actions that were being taken by every implementer, such as setting the new InferredMethod as a constructor and setting the return type.  Then updated all the callers to stop doing this on their own.  Basically duplicate code clean up.
Comment 46 Ian Tewksbury CLA 2011-06-16 12:03:06 EDT
Created attachment 198131 [details]
New Patch with JUnits - Update 5

Same as previous patch except I have updated SourceTypeBinding#buildMethods to correctly bind the arguments to the methods.  All new and existing JUnits pass.
Comment 47 Ian Tewksbury CLA 2011-06-16 12:22:01 EDT
Created attachment 198132 [details]
New Patch with JUnits - Update 6

Attached wrong file during the last patch.  This is the correct one.
Comment 48 Chris Jaun CLA 2011-06-20 12:03:16 EDT
Content assist for the short name is not working.....


For example....org.eclipse.MyClass

if I attempt content assist on MyClass I get no proposals.

I also had several time outs.
Comment 49 Ian Tewksbury CLA 2011-06-20 16:31:41 EDT
Created attachment 198290 [details]
patch with JUnits - Update 7

Chris found a small bug that if after invoking content assist the user starts typing, if the case of the user prefix does not match that of the suggested proposals they will be filtered out.

EX:

new comb|

suggestion is "foo.ComboBox", but if the user then types "o" the suggestion "foo.ComboBox" goes away because "combo" does match case of "ComboBox".  patch now updated so this works ignoring case.
Comment 50 Chris Jaun CLA 2011-06-21 16:23:58 EDT
Type:

var d = new D and attempt content assist.....it hangs for about 20 seconds and then I get:

on var d = new D
4:20:11 PM: Me: takes about 20 seconds and then....
4:20:12 PM: Me: !MESSAGE Exception when processing proposal for: dojox.grid.enhanced.plugins.filter._DataExpr()
!STACK 0
java.lang.IllegalArgumentException
	at org.eclipse.wst.jsdt.internal.core.util.Util.scanTypeSignature(Util.java:2240)
	at org.eclipse.wst.jsdt.core.Signature.getParameterCount(Signature.java:564)
	at org.eclipse.wst.jsdt.ui.text.java.CompletionProposalCollector.createMethodReferenceProposal(CompletionProposalCollector.java:724)
	at org.eclipse.wst.jsdt.ui.text.java.CompletionProposalCollector.createJavaCompletionProposal(CompletionProposalCollector.java:401)
	at org.eclipse.wst.jsdt.ui.text.java.CompletionProposalCollector.accept(CompletionProposalCollector.java:214)
	at org.eclipse.wst.jsdt.internal.codeassist.CompletionEngine.acceptBindings(CompletionEngine.java:854)
	at org.eclipse.wst.jsdt.internal.codeassist.CompletionEngine.findTypesAndPackages(CompletionEngine.java:5451)
	at org.eclipse.wst.jsdt.internal.codeassist.CompletionEngine.complete(CompletionEngine.java:1286)
	at org.eclipse.wst.jsdt.internal.codeassist.CompletionEngine.complete(CompletionEngine.java:2291)
	at org.eclipse.wst.jsdt.internal.core.Openable.codeComplete(Openable.java:135)
	at org.eclipse.wst.jsdt.internal.core.CompilationUnit.codeComplete(CompilationUnit.java:305)
	at org.eclipse.wst.jsdt.internal.core.CompilationUnit.codeComplete(CompilationUnit.java:298)
	at org.eclipse.wst.jsdt.internal.ui.text.java.JavaCompletionProposalComputer.internalComputeCompletionProposals(JavaCompletionProposalComputer.java:176)
	at org.eclipse.wst.jsdt.internal.ui.text.java.JavaCompletionProposalComputer.computeCompletionProposals(JavaCompletionProposalComputer.java:142)
	at org.eclipse.wst.jsdt.internal.ui.text.java.CompletionProposalComputerDescriptor.computeCompletionProposals(CompletionProposalComputerDescriptor.java:298)
	at org.eclipse.wst.jsdt.internal.ui.text.java.CompletionProposalCategory.computeCompletionProposals(CompletionProposalCategory.java:258)
	at org.eclipse.wst.jsdt.internal.ui.text.java.ContentAssistProcessor.collectProposals(ContentAssistProcessor.java:244)
	at org.eclipse.wst.jsdt.internal.ui.text.java.ContentAssistProcessor.computeCompletionProposals(ContentAssistProcessor.java:213)
	at org.eclipse.jface.text.contentassist.ContentAssistant.computeCompletionProposals(ContentAssistant.java:1834)
	at org.eclipse.jface.text.contentassist.CompletionProposalPopup.computeProposals(CompletionProposalPopup.java:556)
	at org.eclipse.jface.text.contentassist.CompletionProposalPopup.access$16(CompletionProposalPopup.java:553)
	at org.eclipse.jface.text.contentassist.CompletionProposalPopup$2.run(CompletionProposalPopup.java:488)
	at org.eclipse.swt.custom.BusyIndicator.showWhile(BusyIndicator.java:70)
	at org.eclipse.jface.text.contentassist.CompletionProposalPopup.showProposals(CompletionProposalPopup.java:482)
	at org.eclipse.jface.text.contentassist.ContentAssistant.showPossibleCompletions(ContentAssistant.java:1660)
	at org.eclipse.wst.jsdt.internal.ui.javaeditor.CompilationUnitEditor$AdaptedSourceViewer.doOperation(CompilationUnitEditor.java:168)
	at org.eclipse.ui.texteditor.ContentAssistAction$1.run(ContentAssistAction.java:82)
	at org.eclipse.swt.custom.BusyIndicator.showWhile(BusyIndicator.java:70)
	at org.eclipse.ui.texteditor.ContentAssistAction.run(ContentAssistAction.java:80)
	at org.eclipse.jface.action.Action.runWithEvent(Action.java:498)
	at org.eclipse.ui.commands.ActionHandler.execute(ActionHandler.java:185)
	at org.eclipse.ui.internal.handlers.LegacyHandlerWrapper.execute(LegacyHandlerWrapper.java:109)
	at org.eclipse.core.commands.Command.executeWithChecks(Command.java:476)
	at org.eclipse.core.commands.ParameterizedCommand.executeWithChecks(ParameterizedCommand.java:508)
	at org.eclipse.ui.internal.handlers.HandlerService.executeCommand(HandlerService.java:169)
	at org.eclipse.ui.internal.keys.WorkbenchKeyboard.executeCommand(WorkbenchKeyboard.java:468)
	at org.eclipse.ui.internal.keys.WorkbenchKeyboard.press(WorkbenchKeyboard.java:786)
	at org.eclipse.ui.internal.keys.WorkbenchKeyboard.processKeyEvent(WorkbenchKeyboard.java:885)
	at org.eclipse.ui.internal.keys.WorkbenchKeyboard.filterKeySequenceBindings(WorkbenchKeyboard.java:567)
	at org.eclipse.ui.internal.keys.WorkbenchKeyboard.access$3(WorkbenchKeyboard.java:508)
	at org.eclipse.ui.internal.keys.WorkbenchKeyboard$KeyDownFilter.handleEvent(WorkbenchKeyboard.java:123)
	at org.eclipse.swt.widgets.EventTable.sendEvent(EventTable.java:84)
	at org.eclipse.swt.widgets.Display.filterEvent(Display.java:1253)
	at org.eclipse.swt.widgets.Widget.sendEvent(Widget.java:1052)
	at org.eclipse.swt.widgets.Widget.sendEvent(Widget.java:1077)
	at org.eclipse.swt.widgets.Widget.sendEvent(Widget.java)
	at org.eclipse.swt.widgets.Widget.sendKeyEvent(Widget.java:1103)
	at org.eclipse.swt.widgets.Widget.sendKeyEvent(Widget.java:1099)
	at org.eclipse.swt.widgets.Widget.wmChar(Widget.java:1508)
	at org.eclipse.swt.widgets.Control.WM_CHAR(Control.java:4270)
	at org.eclipse.swt.widgets.Canvas.WM_CHAR(Canvas.java:345)
	at org.eclipse.swt.widgets.Control.windowProc(Control.java:4162)
	at org.eclipse.swt.widgets.Canvas.windowProc(Canvas.java:341)
	at org.eclipse.swt.widgets.Display.windowProc(Display.java:4873)
	at org.eclipse.swt.internal.win32.OS.DispatchMessageW(Native Method)
	at org.eclipse.swt.internal.win32.OS.DispatchMessage(OS.java:2459)
	at org.eclipse.swt.widgets.Display.readAndDispatch(Display.java:3655)
	at org.eclipse.ui.internal.Workbench.runEventLoop(Workbench.java:2640)
	at org.eclipse.ui.internal.Workbench.runUI(Workbench.java:2604)
	at org.eclipse.ui.internal.Workbench.access$4(Workbench.java:2438)
	at org.eclipse.ui.internal.Workbench$7.run(Workbench.java:671)
	at org.eclipse.core.databinding.observable.Realm.runWithDefault(Realm.java:332)
	at org.eclipse.ui.internal.Workbench.createAndRunWorkbench(Workbench.java:664)
	at org.eclipse.ui.PlatformUI.createAndRunWorkbench(PlatformUI.java:149)
	at org.eclipse.ui.internal.ide.application.IDEApplication.start(IDEApplication.java:115)
	at org.eclipse.equinox.internal.app.EclipseAppHandle.run(EclipseAppHandle.java:196)
	at org.eclipse.core.runtime.internal.adaptor.EclipseAppLauncher.runApplication(EclipseAppLauncher.java:110)
	at org.eclipse.core.runtime.internal.adaptor.EclipseAppLauncher.start(EclipseAppLauncher.java:79)
	at org.eclipse.core.runtime.adaptor.EclipseStarter.run(EclipseStarter.java:369)
	at org.eclipse.core.runtime.adaptor.EclipseStarter.run(EclipseStarter.java:179)
	at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
	at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:48)
	at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:37)
	at java.lang.reflect.Method.invoke(Method.java:600)
	at org.eclipse.equinox.launcher.Main.invokeFramework(Main.java:620)
	at org.eclipse.equinox.launcher.Main.basicRun(Main.java:575)
	at org.eclipse.equinox.launcher.Main.run(Main.java:1408)
	at org.eclipse.equinox.launcher.Main.main(Main.java:1384)
Comment 51 Ian Tewksbury CLA 2011-06-21 17:05:45 EDT
Created attachment 198364 [details]
patch with JUnits - Update 8

Same as previous patch except updates JavaMethodCompletionProposal#computeTriggerCharacters to use METHOD_NAME_TRIGGERS when the proposal type is either a METHDO_NAME_REFERENCE or a METHDO_REF.  The side affect of not doing this was that period was being included as a trigger character when invoking content assist like "foo.bar|" and thus then typing another period was causing the first suggestion to be inserted rather then continuing to filter the list.
Comment 52 Ian Tewksbury CLA 2011-06-22 09:05:33 EDT
I opened and supplied a patch to bug 350047 which deals with comment 50.
Comment 53 Ian Tewksbury CLA 2011-06-29 15:01:02 EDT
Created attachment 198853 [details]
Testing ZIP - Update 4

Updated test zip with files for new tests added in  the forthcoming new patch.
Still goes in "org.eclipse.wst.jsdt.ui.tests/testresources/ContentAssist.zip"
Comment 54 Ian Tewksbury CLA 2011-06-29 15:05:37 EDT
Created attachment 198854 [details]
patch with JUnits - Update 9

This patch is fundamentally different then the last patches because now constructors are stored in the index as constructors and then during content assist searched for in the index as constructors.  This is rather then saving them in the index as methods and searching all of the methods for constructors.  This approach makes content assist much much faster because the set of things to search is much small, and mor importantly no parsing/inferring/etc has to be done to find all of the constructor matches now.

All existing JUnits pass.
All new JUnits pass.
Added a couple new junits since the last patch, be sure to get the new test project zip.

Chris tested a slightly older version of this patch and much preferred the performance over the old patch.

All code in the patch is well documented both in line and with javadoc.  I have gone over every single line of changed code, we need it all.
Comment 55 Ian Tewksbury CLA 2011-06-29 16:44:55 EDT
Comment on attachment 198854 [details]
patch with JUnits - Update 9

Apparently I can not store the parameter arguments just like "String", it has to be stored as a signature like "QString;"
Comment 56 Chris Jaun CLA 2011-06-29 17:12:14 EDT
(In reply to comment #55)
> Comment on attachment 198854 [details]
> patch with JUnits - Update 9
> 
> Apparently I can not store the parameter arguments just like "String", it has
> to be stored as a signature like "QString;"

Yes, content assist proposals are quite dependent on signatures.
Comment 57 Ian Tewksbury CLA 2011-06-30 08:21:20 EDT
(In reply to comment #56)
> (In reply to comment #55)
> > Comment on attachment 198854 [details] [details]
> > patch with JUnits - Update 9
> > 
> > Apparently I can not store the parameter arguments just like "String", it has
> > to be stored as a signature like "QString;"
> 
> Yes, content assist proposals are quite dependent on signatures.

The constructor ones are not.  It seemed very much a convoluted system that gave no benefit.  So I am still looking if there is some way to enhance this code path so it can deal with the types as not a signature.
Comment 58 Ian Tewksbury CLA 2011-06-30 16:32:58 EDT
Created attachment 198935 [details]
Fix patch - Update 10

Same as last patch except I removed some unnecessary logging and fixed the constructor parameter type signature issue.
Comment 59 Ian Tewksbury CLA 2011-07-01 10:58:17 EDT
Created attachment 198972 [details]
fix patch - update 12

Somehow my last patch was missing a couple of my fixes.
Comment 60 Ian Tewksbury CLA 2011-07-01 11:07:03 EDT
Created attachment 198973 [details]
fix patch - update 13

merged patch with recent changes to maintenance stream.
Comment 61 Nitin Dahyabhai CLA 2011-07-01 18:42:44 EDT
Approved with caveats in bug 350975; committed to maintenance, opened bug 350976 for application to HEAD (attachment 198853 [details] will not apply cleanly).
Comment 62 Nitin Dahyabhai CLA 2011-07-01 18:48:32 EDT
(In reply to comment #61)
> Approved with caveats in bug 350975; committed to maintenance, opened bug
> 350976 for application to HEAD (patch will not apply cleanly).

That should instead refer to attachment 198973 [details].
Comment 63 Ian Tewksbury CLA 2011-07-07 09:51:36 EDT
I created Bug 351448 to put this fix as well as the bug 350975 into HEAD.