Process exclusively java files during recompilation

Hi! I have custom language plugin with language which based on Java language. I implemented custom ModuleLevelBuilder for the run custom compiler like java and eclipse compilers. All works fine except one situation with partial recompiling with constants. Due to this piece of code from com.intellij.compiler.server.DefaultMessageHandler#processIdentifiers:

SearchScope javaScope = searchScope instanceof GlobalSearchScope
? GlobalSearchScope.getScopeRestrictedByFileTypes((GlobalSearchScope)searchScope, JavaFileType.INSTANCE)
: searchScope;

Why you handle only JavaFileTypes and not all files with language java like? Can you change implementation?
Thanks for any answers!
Comment actions Permalink

Hi Alexandr, 

The part of build subsystem handling constants is very java-specific. I'd say even javac-specific, as eclipse compiler does not inline constants. So when the bytecode is generated by javac, the constant reference information is missing from the bytecode and our dependencies analyser has to use sources in order to discover constant-induced file dependencies. This type of analysis is far more time-consuming than bytecode-based analysis and we had hard time to make it working as fast as possible. This search scope restriction is one of those optimizations. The analysis is very java-specific, is done by the IDE and is based on java PSI. It cannot be applied to a different language anyway, as there will be a different PSI structure built for this language. Because of that it is logical to restrict the search scope to java files: the files for which we 100% are getting the expected PSI structure. Scanning other files would have been just a waste of time, as our analysis cannot provide any guaranteed results for them.

A couple of things are not clear from your question:

1. IDEA's constant search functionality might be useful for you only if compiler for your language inlines constants exactly like javac does. Is it really the case?

2.Moreover, the IDE language plugin for your language should provide 100% java-compatible PSI tree. This second condition doesn't seem to be the case, because otherwise your language would have been equal to java language.

Comment actions Permalink

Thanks, for the detailed explanation.

1. Yes, our custom compiler has behaviour in this case like javac. Our language classes can use java classes and their constants too. Full compatibility.

2. That's right, our custom language is the superset of Java language. I reused java Psi tree with additional tree nodes.


Please sign in to leave a comment.