We're developing a plugin for the Gosu programming language. Gosu's type system extends existing types with new methods and properties and also adds new types. We'd like to provide some or all of these features to Java source files inside IntelliJ. For instance, Gosu extends String with several useful methods and properties. Is there some way to extend the Java Psi parser to provide our own Psi so that the following will parse in a Java file?
String Hi = "hi".capitalize();
Gosu provides the capitalize() method and our plugin is capable of producing Psi for the method call. I would even be satisfied if we could get a crack at simply stubbing out the psi for the expression to avoid the parse error.
Gosu also provides whole types that are not known to Java. The type system is pluggable where a new metatype can be defined on equal footing with any other type in the system via a custom type loader. For example, a type loader for XML schemas can resolve type names corresponding with elements defined in XSD files. Gosu's parser doesn't care where a type comes from; it's view of a type is unified through abstract type information; all types loaded in Gosu implement a set of standard interfaces to provide type information about types, methods, properties, etc. Our Psi parser for Gosu resolves references to new types and new features to existing types. So, for example, the following reference to an XML schema type is legal in Gosu in the presence of the Gosu XML schema type loader:
var address : xsd.location.Address
I'd like to extend these new types to Java as well. So I'd like to somehow plug in to the Java Psi parser to make the following declaration legal in a Java file:
Fwiw, we have the compiler side of things taken care of; we've tricked javac into compiling Java source with references to Gosu type information. Now the hard part seems to be tricking the IDE's parser to do the same.