My plugin transforms source code at compilation time, but only slightly in most cases. When the resulting code won't compile, it's always because the original source code was incorrect. Compilation errors show up as errors in the transformed file, which causes the editor to open the transformed file. This is not so useful to the user, who would like to simply edit the file to fix the error, instead of figuring out where that position is in the original file.
I'd like a way, perhaps an extra interface that my compiler would implement, which would provide a means of translating line/column numbers in the transformed file, into line/column numbers in the original file (if applicable). I think an API like this would be useful:
public @Nullable TransformedFile transform(CompileContext ctx, VirtualFile file, VirtualFile output);
interface TransformedFile {
@Nullable Position getPositionInOriginalFile(Position p);
}
class Position { .. getLine, getColumn .. }
If getPositionInOriginalFile returns null, there is no corresponding position in the original file, and the error should be shown in the transformed file (like it is now).