| Summary: | [hotbug][Code Assist] Namespace not supported - no proposal after "new" keyword | ||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
| Product: | [WebTools] JSDT | Reporter: | Rosa Tse <bunnyyappi> | ||||||||||||||
| Component: | General | Assignee: | Chris Jaun <cmjaun> | ||||||||||||||
| Status: | RESOLVED FIXED | QA Contact: | Nitin Dahyabhai <thatnitind> | ||||||||||||||
| Severity: | major | ||||||||||||||||
| Priority: | P2 | CC: | chrismarx, cmjaun, eclipse, patrick.myles, yenlu | ||||||||||||||
| Version: | unspecified | Flags: | thatnitind:
review+
|
||||||||||||||
| Target Milestone: | 3.2.1 | ||||||||||||||||
| Hardware: | PC | ||||||||||||||||
| OS: | Windows XP | ||||||||||||||||
| Whiteboard: | |||||||||||||||||
| Attachments: |
|
||||||||||||||||
Created attachment 161887 [details]
Animal listed as a proposal after typing "new a"
Created attachment 161888 [details]
"a.b" as proposal after typing "new b"
Thank you for the detailed bug report. This is a problem we don't have a good solution for right now. Not sure if we'll have time for this in WTP 3.2, but we'll take a look at it when planning our next milestone. I think I found out why it does not consider matches in packages/namespaces. In org.eclipse.wst.jsdt.internal.codeassist.CompletionEngine, findTypesAndPackages, the find packages code has been commented out. Packages in JSDT are mostly leftover from when it was cloned from JDT. We don't really use them, other than the "default" package for our searching. Generally when we infer something as a type we use the entire string as the type name. In this case we probably use "a.b" as the complete type name. The "." is just considered part of the name, not as a package separator. (In reply to comment #5) > Packages in JSDT are mostly leftover from when it was cloned from JDT. > > We don't really use them, other than the "default" package for our searching. > > Generally when we infer something as a type we use the entire string as the > type name. > > In this case we probably use "a.b" as the complete type name. The "." is just > considered part of the name, not as a package separator. We are trying to provide code completion for a library that relies HEAVILY on namespace/package. This is a show-stopper for us. Who should I talk to about this? See issue #284833 (https://bugs.eclipse.org/bugs/show_bug.cgi?id=284833). I think after having sth. like a spec for a library (with included namespaces) it's also easy for library authors to "create autocompletion". As a library author I would feel fine with that option. For sure it takes time to implement... Just wanted to add my support for including autocomplete for namespaced variables. I often do this
var com = {
cornell:{
myproject:{}
}
}
and then
com.cornell.myproject = function(){
//etc.
}
this is usually dont with a namespacing script for convenience. but once i namespace variables like this, the autocomplete offers no suggestions :(
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. We need to provide code completion for a library that relies heavily on namespace. The feature cannot be implemented without this bug fix. Created attachment 168827 [details]
Proposed patch
Attached a patch for a proposed fix. This fix has some risk and requires significant additional testing before I would be willing to put it into an 3.2 RC build. Asking Nitin to review to get any initial comments from him. First patch doesn't work for working copies...marked obsolete. Created attachment 168831 [details]
New patch with working copy fix
My concern now is the confusing nature of how the proposals are sorted in the content assist popup for large libraries.
Further testing of this patch has found it breaks type hierarchy construction. I have marked obsolete. This will not make RC2 and therefore will likely have to be re-targeted for 3.2.1. (In reply to comment #14) > Further testing of this patch has found it breaks type hierarchy construction. > I have marked obsolete. > > This will not make RC2 and therefore will likely have to be re-targeted for > 3.2.1. Thanks for attempting the fix. Would it be possible for this fix to go into Eclipse 3.6 release? Created attachment 169730 [details]
Updated patch
My latest attempt at this....some quick testing looked good. Needs lots more before I'd consider included in the build.
Created attachment 169843 [details]
More updates to thie patch
I think this is ready for your review Nitin. Don't suppose it should be checking instanceof ISuperReference instead of SuperReference? I don't know. I suppose it could. Fix checked into 3.2.1 Just upgraded to Helios, great to see that namespacing works for prototyped functions, but it doesn't appear to work for static or literal objects. This works:
com.cornell.project = function(){};
com.cornell.project.prototype.init = function(){};
this doesn't:
com.cornell.project = {
init:function(){},
etc:function(){}
}
files with that kind of object don't show up in the Javascript Resource source folder, but files with the prototyped variety do. Is this intentional? bug?
|
Build Identifier: 3.5.1 M20090917-0800 I would like to know how I can get code completion to work for class in a namespace. If I define the following: Animal.prototype=new Object(); function Animal(){}; Animal.prototype.property=""; Animal.prototype.eat=function(food){}; Animal.prototype.sleep=function(){}; Animal.prototype.speak=function(){ return ""; }; After typing "new A", I can get Animal as one of the proposals. However if I define something like this: a = new Object(); a.b = new Object(); a.b.prototype = new Object(); a.b = function(){}; a.b.prototype.operationA=function(){}; a.b.prototype.operationB=function(){}; When I type "new a", I don't get any proposal. However, if I type "new b", then I see "a.b" listed. Reproducible: Always Steps to Reproduce: 1. Use these 2 extensions: org.eclipse.wst.jsdt.ui.JsGlobalScopeContainerPage, org.eclipse.wst.jsdt.core.JsGlobalScopeContainerInitializer 2. In the JS file referenced by the initializer's library, define Animal and a.b as listed in details. 3. Create a web project, add the JavaScript library. 4. Create a JS file. 5. Type "var obj = new a", type Ctrl+Space to invoke code assistance. Only "Animal" listed in proposal, "a.b" is not there. 6. Type "var obj = new b", type Ctrl+Space to invoke code assistance. Notice "a.b" is listed.