Bug 279974 - [content assist] [itd] ITD aware content assist inside of ITDs is broken
Summary: [content assist] [itd] ITD aware content assist inside of ITDs is broken
Status: RESOLVED FIXED
Alias: None
Product: AJDT
Classification: Tools
Component: Core (show other bugs)
Version: unspecified   Edit
Hardware: All All
: P3 normal (vote)
Target Milestone: 2.0.1   Edit
Assignee: AJDT-inbox CLA
QA Contact:
URL:
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2009-06-11 12:58 EDT by Andrew Eisenberg CLA
Modified: 2009-07-10 13:13 EDT (History)
0 users

See Also:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Andrew Eisenberg CLA 2009-06-11 12:58:45 EDT
Looks like the AspectsConvertingParser is not properly setting up the buffer for content assist inside of an ITD so that ITDs on target fields cannot be found.
Comment 1 Andrew Eisenberg CLA 2009-06-11 13:15:51 EDT
In AJCompilationUnit.codeComplete, there is a line:
((ProposalRequestorFilter)requestor).setAcceptMemberMode(false);

What this does is that it filters out all method and field ref proposals.  Presumably, this was set so that aspect fields do not erroneously appear as content assist proposals, but this also filters out method and field ref proposals from local variables.

Setting this to true, will mean that field and method refs from local vars will appear (good), but non-static aspect fields and methods will also appear (bad).

What needs to happen here is to have better analysis and use the following to filter proposals:
Is the field or method ref non-static and coming from the aspect?  If so filter, otherwise, don't filter.
Comment 2 Andrew Eisenberg CLA 2009-07-09 20:01:56 EDT
OK.  Did a bit of work here cleaning things up.  Also, found some more issues related to bug 283030.  I am now confident that that bug is fixed.

The problem here, more specifically is in this situation.  

Inside of an ITD, content assist happens in 2 phases.  In phase 1, a "this" field is prepended to the completion location (where "this" corresponds to a type of the target type.  Eg-

void Foo.x() {
  <here>
}
becomes
void Foo$x() {
  Foo ___ITD___;  ___ITD___.<here>
}
This allows the collector to pick up all declarations inside the target type and supers.  Then, content assist is run again without this mock local variable:
void Foo$x() {
  <here>
}
This time the collector is configured to ignore methods and fields (because they would presumably be coming from the aspect and should be ignored).  So, this allows the collector to get the local variables.

This works fine in the above situation and when content assist is on a prefix of a local variable or declaration from the target type.  However, in this situation, there is a problem:


void Foo.x() {
  List g = new LinkedList();
  g.<here>
}

In the first iteration of content assist, the "___ITD___" variable is prepended and since g is coming from the target type, this yields no results.  In the second iteration, all of g's methods (from List) are found but are filtered out for reasons described above.

The way to solve this is to be able to determine when we are in the first situation vs the second situation.  The difference between the two will be whether or not we apply filtering in the second iteration.  

We need to be able to check back from the completion position to the start of the current statement and see if there is a '.', which indicates that we should not do the filtering.



Comment 3 Andrew Eisenberg CLA 2009-07-10 13:13:21 EDT
Fixed with regression tests.