I’m using Eclipse 3.4.2 Ganymede…
with the Web and Java EE Environment add-on installed.
I have a Dynamic Web Project with a number of scripts and html pages in it.
In my HTML file, I’ve added a few scripts.
<script type="text/javascript" src="scripts/dojo/dojo.js"></script>
<script type="text/javascript" src="scripts/getpoints.js"></script>
Since the getpoints.js file does not directly reference dojo.js, Eclipse’s error/warning highlightings in getpoints.js are useless.
How can I get Eclipse to detect this relationship correctly and display the correct errors/warnings?
Edit: for reference, these are the predominant errors
dojo cannot be resolved
XMLHttpRequest cannot be resolved or is not a field
ActiveXObject cannot be resolved or is not a field
as well as a few more related to specifics of the project.
Solutions:
- I found out that if I add a number of my js files to my sources and browser globals, I solved some of my errors.
Project -> Properties -> Javascript -> Javascript Libraries -> Source -> Add File from Project`
Project -> Properties -> Javascript -> Javascript Libraries -> Global Supertypes -> Select & Reorder Libraries
-
My ajax related errors came from accidentally declaring
var http. -
Dojo’s error was minimized by the solution given below.
If getpoints.js is your own script, you could put a line at the top like:
That should silence the warnings.
I think Eclipse is behaving correctly, though, because it can’t know that getpoints.js will always have dojo included in the HTML file. It’s just checking the syntax/semantics of getpoints.js and, technically, the script won’t stand on its own. Adding the above line will ‘fix’ the problem by making sure that dojo is always defined.