1

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.

1

2 Answers 2

2

If getpoints.js is your own script, you could put a line at the top like:

var dojo = dojo || {};

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.

Sign up to request clarification or add additional context in comments.

2 Comments

So there's really no way for eclipse to highlight errors with respect to the entire project rather than the file?
No, but you could retry it with something more current. Ganymede is old.
0

In eclipse var dojo = dojo || {}; throws:

The operator || is undefined for the argument type(s) any, ___anonymous708_709

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.