Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Eclipse Projects » Web Tools Project (WTP) » "document" unresolved for javascript files
"document" unresolved for javascript files [message #208876] Wed, 20 February 2008 23:33 Go to next message
Kevin McGuire is currently offline Kevin McGuire
Messages: 12
Registered: July 2009
Junior Member
Hi folks,

I wanted to try out the javascript editor for WTP R3.0 M5, so downloaded:

1) Eclipse SDK 3.4 M5
2) Web Standard Tools 3.0 M5
http://www.eclipse.org/downloads/download.php?file=/webtools /downloads/drops/R3.0/S-3.0M5-20080218021547/wtp-wst-sdk-S-3 .0M5-20080218021547.zip
(Note also tried the "Web Tools Platform Complete" with same results).
3) As noted in the download page
http://download.eclipse.org/webtools/downloads/drops/R3.0/S- 3.0M5-20080218021547/
- EMF runtime,
- XSD-runtime,
- GEF

When authoring a Javascript file (e.g. test.js), I get code completion
fine for javascript'y things like function, var, etc. (great!) but oddly
a line like
document.getElementByID("something");
gets a compile error on 'document' being unresolved.

Am I missing something that will properly add in resolution to things
like document?

Thanks in advance,
Kevin
Re: "document" unresolved for javascript files [message #208890 is a reply to message #208876] Thu, 21 February 2008 11:40 Go to previous messageGo to next message
Nitin Dahyabhai is currently offline Nitin Dahyabhai
Messages: 2310
Registered: July 2009
Senior Member
Kevin McGuire wrote:
> When authoring a Javascript file (e.g. test.js), I get code completion
> fine for javascript'y things like function, var, etc. (great!) but oddly
> a line like
> document.getElementByID("something");
> gets a compile error on 'document' being unresolved.
>
> Am I missing something that will properly add in resolution to things
> like document?

Possibly. Go to your project's Properties dialog and look for the
Javascript Libraries page. From Libraries tab you'll want to "Add
Runtime Library...", and choose the Base Web Browser Library. That
should make available the browser objects you're used to seeing.

---
Nitin Dahyabhai
Eclipse WTP Source Editing
IBM Rational


---
Nitin Dahyabhai
Eclipse WTP, IBM
Re: "document" unresolved for javascript files [message #208915 is a reply to message #208890] Thu, 21 February 2008 18:18 Go to previous messageGo to next message
Kevin McGuire is currently offline Kevin McGuire
Messages: 12
Registered: July 2009
Junior Member
Fantastic Nitin, thanks for the prompt help!

Btw, is this a bug? (Should I report it?) It seems that library should
be default available.

Final stupid question: shouldn't "document" with a lower case 'd' be
available in the ECMA bindings?

Kevin

Nitin Dahyabhai wrote:
> Kevin McGuire wrote:
>> When authoring a Javascript file (e.g. test.js), I get code completion
>> fine for javascript'y things like function, var, etc. (great!) but
>> oddly a line like
>> document.getElementByID("something");
>> gets a compile error on 'document' being unresolved.
>>
>> Am I missing something that will properly add in resolution to things
>> like document?
>
> Possibly. Go to your project's Properties dialog and look for the
> Javascript Libraries page. From Libraries tab you'll want to "Add
> Runtime Library...", and choose the Base Web Browser Library. That
> should make available the browser objects you're used to seeing.
>
> ---
> Nitin Dahyabhai
> Eclipse WTP Source Editing
> IBM Rational
Re: "document" unresolved for javascript files [message #208962 is a reply to message #208915] Fri, 22 February 2008 16:41 Go to previous messageGo to next message
Nitin Dahyabhai is currently offline Nitin Dahyabhai
Messages: 2310
Registered: July 2009
Senior Member
Kevin McGuire wrote:
> Final stupid question: shouldn't "document" with a lower case 'd' be
> available in the ECMA bindings?

I think "document" is a variable only available if you set the super
type to a web Browser object. I don't know what "Document" refers
to, but I'm guessing it is a W3C DOM object, but then I'm not an
expert in Javascript. For all I know they're unrelated.

---
Nitin Dahyabhai
Eclipse WTP Source Editing
IBM Rational


---
Nitin Dahyabhai
Eclipse WTP, IBM
Re: "document" unresolved for javascript files [message #208979 is a reply to message #208962] Fri, 22 February 2008 19:25 Go to previous messageGo to next message
Kevin McGuire is currently offline Kevin McGuire
Messages: 12
Registered: July 2009
Junior Member
Hi Nitin,

Thanks for the response. Sorry I don't understand. The super type of
whom? I should be able to write:

<script type="text/javascript">
function doit() {
var newString = "hello world";
var content = document.getElementById("content");
alert(content);
content.innerHTML = newString;
}
</script>

Both document and alert() get compile errors (yet this is normal legal
javascript AFAIK and runs just fine in Firefox).

Btw, the "Document" choice is quite odd. Its a browser class alright
that you'll find in a Javascript book, but I don't think you typically
send static methods to it and code completion offers instance method
choices on the static.

I've logged:
https://bugs.eclipse.org/bugs/show_bug.cgi?id=219886 :: "document" shows
as error even with ECMA 3 lib added
https://bugs.eclipse.org/bugs/show_bug.cgi?id=219880 :: Code completion
offers illegal choices

The first one might be a bug or might be a UI issue (not guiding the
user to the right configation), the second is definitely fishy.

Its a very nice javascript editor otherwise! :)

Cheers,
Kevin McGuire


Nitin Dahyabhai wrote:
> Kevin McGuire wrote:
>> Final stupid question: shouldn't "document" with a lower case 'd' be
>> available in the ECMA bindings?
>
> I think "document" is a variable only available if you set the super
> type to a web Browser object. I don't know what "Document" refers to,
> but I'm guessing it is a W3C DOM object, but then I'm not an expert in
> Javascript. For all I know they're unrelated.
>
> ---
> Nitin Dahyabhai
> Eclipse WTP Source Editing
> IBM Rational
Re: "document" unresolved for javascript files [message #209065 is a reply to message #208979] Mon, 25 February 2008 15:20 Go to previous messageGo to next message
Bradley Childs is currently offline Bradley Childs
Messages: 14
Registered: July 2009
Junior Member
The super type of a project is the type who's fields / methods are inherited
by all .js (and .html files if in a web project).

By definition for .js files the super type is (an instance of) the Global()
object. When JavaScript is running within the context of a browser,
inheritance is Global()--->Window() and [an instance of]Window() is the
super type. 'document' is a field in the Window object of type Document().



-Brad
"Kevin McGuire" <eclipse@kevin.mcguireclan.net> wrote in message
news:fpn7ka$tdm$1@build.eclipse.org...
> Hi Nitin,
>
> Thanks for the response. Sorry I don't understand. The super type of
> whom? I should be able to write:
>
> <script type="text/javascript">
> function doit() {
> var newString = "hello world";
> var content = document.getElementById("content");
> alert(content);
> content.innerHTML = newString;
> }
> </script>
>
> Both document and alert() get compile errors (yet this is normal legal
> javascript AFAIK and runs just fine in Firefox).
>
> Btw, the "Document" choice is quite odd. Its a browser class alright that
> you'll find in a Javascript book, but I don't think you typically send
> static methods to it and code completion offers instance method choices on
> the static.
>
> I've logged:
> https://bugs.eclipse.org/bugs/show_bug.cgi?id=219886 :: "document" shows
> as error even with ECMA 3 lib added
> https://bugs.eclipse.org/bugs/show_bug.cgi?id=219880 :: Code completion
> offers illegal choices
>
> The first one might be a bug or might be a UI issue (not guiding the user
> to the right configation), the second is definitely fishy.
>
> Its a very nice javascript editor otherwise! :)
>
> Cheers,
> Kevin McGuire
>
>
> Nitin Dahyabhai wrote:
>> Kevin McGuire wrote:
>>> Final stupid question: shouldn't "document" with a lower case 'd' be
>>> available in the ECMA bindings?
>>
>> I think "document" is a variable only available if you set the super type
>> to a web Browser object. I don't know what "Document" refers to, but I'm
>> guessing it is a W3C DOM object, but then I'm not an expert in
>> Javascript. For all I know they're unrelated.
>>
>> ---
>> Nitin Dahyabhai
>> Eclipse WTP Source Editing
>> IBM Rational
Re: "document" unresolved for javascript files [message #209072 is a reply to message #209065] Mon, 25 February 2008 18:07 Go to previous message
Kevin McGuire is currently offline Kevin McGuire
Messages: 12
Registered: July 2009
Junior Member
Thanks Bradley! By selecting the project and going into
Properties->JavaScript Libraries -> Global Order/Super Type and changing
the dropdown at the bottom of that page to "Window" I now have my little
example working.

I'll comment though that this isn't at all obvious (apparently <g>). So
there's some usability concern around getting novice developers going
quickly.

Thanks again,
Kevin McGuire

Bradley Childs wrote:
> The super type of a project is the type who's fields / methods are inherited
> by all .js (and .html files if in a web project).
>
> By definition for .js files the super type is (an instance of) the Global()
> object. When JavaScript is running within the context of a browser,
> inheritance is Global()--->Window() and [an instance of]Window() is the
> super type. 'document' is a field in the Window object of type Document().
>
>
>
> -Brad
> "Kevin McGuire" <eclipse@kevin.mcguireclan.net> wrote in message
> news:fpn7ka$tdm$1@build.eclipse.org...
>> Hi Nitin,
>>
>> Thanks for the response. Sorry I don't understand. The super type of
>> whom? I should be able to write:
>>
>> <script type="text/javascript">
>> function doit() {
>> var newString = "hello world";
>> var content = document.getElementById("content");
>> alert(content);
>> content.innerHTML = newString;
>> }
>> </script>
>>
>> Both document and alert() get compile errors (yet this is normal legal
>> javascript AFAIK and runs just fine in Firefox).
>>
>> Btw, the "Document" choice is quite odd. Its a browser class alright that
>> you'll find in a Javascript book, but I don't think you typically send
>> static methods to it and code completion offers instance method choices on
>> the static.
>>
>> I've logged:
>> https://bugs.eclipse.org/bugs/show_bug.cgi?id=219886 :: "document" shows
>> as error even with ECMA 3 lib added
>> https://bugs.eclipse.org/bugs/show_bug.cgi?id=219880 :: Code completion
>> offers illegal choices
>>
>> The first one might be a bug or might be a UI issue (not guiding the user
>> to the right configation), the second is definitely fishy.
>>
>> Its a very nice javascript editor otherwise! :)
>>
>> Cheers,
>> Kevin McGuire
>>
>>
>> Nitin Dahyabhai wrote:
>>> Kevin McGuire wrote:
>>>> Final stupid question: shouldn't "document" with a lower case 'd' be
>>>> available in the ECMA bindings?
>>> I think "document" is a variable only available if you set the super type
>>> to a web Browser object. I don't know what "Document" refers to, but I'm
>>> guessing it is a W3C DOM object, but then I'm not an expert in
>>> Javascript. For all I know they're unrelated.
>>>
>>> ---
>>> Nitin Dahyabhai
>>> Eclipse WTP Source Editing
>>> IBM Rational
>
>
Previous Topic:Runtime "J2EE Preview" is invalid
Next Topic:Re: J2EE runtime directory
Goto Forum:
  


Current Time: Sat Oct 25 16:48:14 GMT 2014

Powered by FUDForum. Page generated in 0.02668 seconds
.:: Contact :: Home ::.

Powered by: FUDforum 3.0.2.
Copyright ©2001-2010 FUDforum Bulletin Board Software