getting color and syntax formatting to work with non-source files?


I find it useful to rewrite and refactor java source files in order to come to really understand them. Of course, I don't want those source files to be a part of my project's source.But it seems like unless they're marked as source in the project structure dialog, they don't get any kind of formatting except the default formatting applied to them in the editor. I've looked in the configuration dialogs for formatting options , like a checkbox that says  "apply formatting to all project files" or something but I don't see anything. Am I missing something? So far I have tried marking them as "resources" and "test" .


What's wrong with the colors? Basic syntax highlighting should work, but inspections will not run.

If you want to edit and reformat these files, configure them in a separate module with its own content and source roots or even in a separate project.


OK yeah the color and formatting is not there. I should maybe file a bug report then, because it should be applied to files specified as "resources" or "test". Just looking to confirm before wasting anyone's time with a false bug report.

What I do is copy the whole java source (src) directory over into a local folder then add it as a resource to the project I am working on (because problems and questions that arise there are what initiates the desire to look closely at say a JavaFX class) . But you're saying create a separate module and then mark them as sources for that module then just never bother building that module... is that about it? Is the module a part of my project- i.e. is IJ going to want to build it if I say build project?






Thank you much Serge you save me so much time and frustration.


How about this Serge: I have a module which is composed soley of JDK / JavaFX source, copied then relocated Elsewhere. Those java files are designated the source of my project and I refactor them at will. 

The directory structure is as it is in the JDK (as far as the module knows).

If I use "go to class definition" or "go to method" (ctrl right click) what I "go to" is not the JDK/ JavaFX source I am refactoring- (those classes which constitute the source of my project)  but rather the equivalent source files in the "real" JDK itself, ie. the ones located in the JDK as I installed the JDK using Oracle's installer. They live here: c:/ProgramFiles/Java etc etc and not Elsewhere.


So the "goto X" of Intellij is hard coded to refer to the JDK defined for the project if it meets a JDK class? I don't see how that would actually work and anyway it makes zero sense. A module which just happens to use a copy of the source of the JDK , (and which has been re-located Elsewhere ) as it's own source ought to also "go to" Elsewhere . See what I mean? Why is this not going to the project's own source?


Check module dependencies order. JDK comes before the sources.


Please sign in to leave a comment.