IntelliJ Java IDE
The moose likes IDEs, Version Control and other tools and the fly likes Eclipse insists on parsing my Big Moose Saloon
  Search | Java FAQ | Recent Topics
Register / Login


Win a copy of Practical Unit Testing with TestNG and Mockito this week in the Testing forum!
JavaRanch » Java Forums » Engineering » IDEs, Version Control and other tools
Reply Bookmark "Eclipse insists on parsing my "raw" code" Watch "Eclipse insists on parsing my "raw" code" New topic
Author

Eclipse insists on parsing my "raw" code

Frank Carver
Sheriff

Joined: Jan 07, 1999
Posts: 6913
Hi,
I have a project which makes some use of the Ant "filter" task to preprocess some of my Java files. In particular, I give it code such as:

and it replaces the @processor.class@ with the processor class specified in a properties file or command-line parameter.
This enables me to maintin a single code base but generate several different "builds" for different situations uner control of Ant.
All this is fine when I use a "dumb" editor, and even Eclipse will happily call the Ant build script and generate the build. It's just that Eclipse insists on complaining that the source file is invalid Java.
Does anyone have any good ideas for getting around this. Most word-processors have a way of telling them to ignore certain spelling errors, for example - does Eclipse have anything like this? I would like to keep the source files in question editable by Eclipse, as the Eclipse refactoring tools and so on are still useful for other parts of the files.
All help appreciated, thanks.


A Convergent Visionary ~ Frank's Punchbarrel Blog ~ LinkedIn profile
David Weitzman
Ranch Hand

Joined: Jul 27, 2001
Posts: 1365
For a quick fix you could do something like:

You lose compile-time type-checking, but at least Eclipse will stop pestering you.
Tim Holloway
Saloon Keeper

Joined: Jun 25, 2001
Posts: 12504

Have you tried using an extension other than ".java"? I use the same syntax in a system of mine, but the template files end with ".model".
However they're not part of the Eclipse project, so I don't know if Eclipse is attempting to parse based on deduced content or just using the filename extension.


One of the most odious afflictions that Business has inflicted on the modern English language is "pro-active". Most of the time it's simply redundantly used in place of the simple old word "active". And a good deal of the rest of the time it means "You're not overworked enough yet, so go out and find more!"
Frank Carver
Sheriff

Joined: Jan 07, 1999
Posts: 6913
Thanks for the suggestions, guys.
David: You lose compile-time type-checking, but at least Eclipse will stop pestering you.
I guess so, but that seems dangerously overcomplicated, when I know the code works the way it is.
Tim: Have you tried using an extension other than ".java"? I use the same syntax in a system of mine, but the template files end with ".model".
I tried this, but as far as I can tell you either get Eclipse's smart refactoring, syntax colouring and error checking for the whole file (typically only for "*.java" files), or you get none of the above and the file is treated as just text. This is also dangerous, as a refactoring might inadvertently miss changes needed in the renamed file.
David Weitzman
Ranch Hand

Joined: Jul 27, 2001
Posts: 1365
that seems dangerously overcomplicated, when I know the code works the way it is.
One might say that rewriting source code at build time is dangeously over-complicated. Isn't that just a sneaky way of avoiding the Open Closed Principle?
 
 
subject: Eclipse insists on parsing my "raw" code
 
Threads others viewed
Using Eclipse 3.1.0 IDE, JBOSS 4.0.0 server & ANT as build tool
Sharing filesets between Checkstyle in Ant and Eclipse Plugin?
RMI from start to finish
Buildpath problem with Eclipse
Build log for inbuilt Java builder in Eclipse
developer file tools

cast iron skillet 49er

more from paul wheaton's glorious empire of web junk: cast iron skillet diatomaceous earth rocket mass heater sepp holzer raised garden beds raising chickens lawn care CFL flea control missoula heat permaculture