jsdt content assistence in object literals [message #507662] |
Thu, 14 January 2010 04:56 |
Harald Finster Messages: 37 Registered: July 2009 |
Member |
|
|
Hello,
I observed a strange behaviour of the content assistance of the jsdt
editor. Could someone please help with this?
If I use the editor in conjunction with object literals
assigned to variables, everything works as expected.
The "type" of an object (i.e. its members) is derived
even if I the type of a variable is only known across
multiple assignments as shown in the example below:
var a = {
name : "a",
foo : function() {
this.name; // works
}
};
var b = {
name : "b",
other : a,
foo : function() {
this.name; // works
// works:
// jsdt derives the "type" of
// "other" and suggests "name".
// It "follows" the "assignment" "other : a"
// and thus knows the "type" of "a"
//
this.other.name;
}
};
However, this does not seem to work with the following
example using nested object literals:
var root = {
c : {
name : "c",
foo : function() {
this.name; // works
}
},
d : {
name : "d",
other : root.c, // works
foo : function() {
this.name; // works
// !! does not work !!
// jsdt does not supply any suggestions
// for "other" in this case.
// ("No Default Proposals")
//
//
this.other.name;
}
}
};
My first assumption was, that jsdt is unable to "follow" the
"assignments" within the object literal, because the object is not
complete at the time of editing. However, content assist seems
to work when I try to auto-complete the "root." at "other : root.c".
I am currently using:
JavaScript Developer Tools
Version: 1.1.2.v200908101420-77-FGCCcNBC-BhLcE_Pm
Build id: 20090917225226
Thanks a lot for any feedback.
Kind regards
Harald
|
|
|
|
Re: jsdt content assistance and object members [message #508426 is a reply to message #507713] |
Mon, 18 January 2010 18:11 |
|
On 1/14/2010 7:53 AM, Harald Finster wrote:
> Hello again,
>
> more investigation seems to indicate that the problem is
> not (exclusively) related to the use of object lieterals.
> See examples below.
>
> jsdt makes correct suggestions for all examples given
> in the sample code, except for the expression
> "this.s.a" within function "foo2".
>
>
> var x = {
> x1 : {
> a : "a",
> b : "b"
> }
> };
>
> x.x1; // okay
>
> var y = x;
>
> y.x1; // okay
> y.x1.a; // okay
> y.x1.b; // okay
>
> var z = x.x1;
> z.a; // okay
> z.b; // okay
>
> var l = {
> r : x,
> foo1 : function() {
> this.r.x1; // okay
> },
> s : x.x1, // okay
> foo2 : function() {
> /**
> * does not work
> * i.e. typing "this.s. Control-Space" does
> * not make any proposals
> */
> this.s.a;
> },
> t : {
> u : {
> m : 3
> }
> },
> foo3 : function() {
> this.t; // okay
> this.t.u; // okay
> this.t.u.m; // okay
> }
> };
This sounds like a bug. Please report it at
https://bugs.eclipse.org/bugs/enter_bug.cgi?product=WTP%20So urce%20Editing&component=wst.jsdt
--
---
Nitin Dahyabhai
Eclipse WTP Source Editing
IBM Rational
_
Nitin Dahyabhai
Eclipse Web Tools Platform
|
|
|
|
Powered by
FUDForum. Page generated in 0.02850 seconds