Eclipse Community Forums - RDF feed
https://www.eclipse.org/forums/
Eclipse Community Forumsjsdt content assistence in object literals
https://www.eclipse.org/forums/index.php/mv/msg/160649/507662/#msg_507662
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".
Harald]]>Harald Finster2010-01-14T04:56:06-00:00jsdt content assistance and object members (was: jsdt content assistence in object literals)
https://www.eclipse.org/forums/index.php/mv/msg/160649/507713/#msg_507713
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
}
};
Harald Finster wrote:
>
> I observed a strange behaviour of the content assistance of the jsdt
> editor. Could someone please help with this?
>]]>Harald Finster2010-01-14T07:54:02-00:00Re: jsdt content assistance and object members
https://www.eclipse.org/forums/index.php/mv/msg/160649/508426/#msg_508426
> 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
> }
> };
--
---
Nitin Dahyabhai
Eclipse WTP Source Editing
IBM Rational]]>Nitin Dahyabhai2010-01-18T18:11:32-00:00Re: jsdt content assistance and object members
https://www.eclipse.org/forums/index.php/mv/msg/160649/508585/#msg_508585
thanks for your reply!