Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Eclipse Projects » Web Tools Project (WTP) » jsdt content assistence in object literals
jsdt content assistence in object literals [message #507662] Wed, 13 January 2010 23:56 Go to next message
Harald Finster is currently offline 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
jsdt content assistance and object members (was: jsdt content assistence in object literals) [message #507713 is a reply to message #507662] Thu, 14 January 2010 02:54 Go to previous messageGo to next message
Harald Finster is currently offline Harald Finster
Messages: 37
Registered: July 2009
Member
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
}
};


Harald Finster wrote:

>
> I observed a strange behaviour of the content assistance of the jsdt
> editor. Could someone please help with this?
>
Re: jsdt content assistance and object members [message #508426 is a reply to message #507713] Mon, 18 January 2010 13:11 Go to previous messageGo to next message
Nitin Dahyabhai is currently offline Nitin Dahyabhai
Messages: 2133
Registered: July 2009
Senior Member
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 WTP, IBM
Re: jsdt content assistance and object members [message #508585 is a reply to message #508426] Tue, 19 January 2010 09:45 Go to previous message
Harald Finster is currently offline Harald Finster
Messages: 37
Registered: July 2009
Member
Hello,

thanks for your reply!

Nitin Dahyabhai schrieb:

> 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
>

okay, I reported this bug (or you could say "missing feature")
and submitted a possible fix.

Kind regards

Harald
Previous Topic:JSP editor absent after installing JEE Dev Tools
Next Topic:Use Eclipse as Standard HTML-Editor
Goto Forum:
  


Current Time: Sun Apr 20 06:51:57 EDT 2014

Powered by FUDForum. Page generated in 0.01937 seconds