How to Provide PSI Resolution from Logical Class to Generated Versioned Class?

My company has developed a framework that stores Java source code in a database.

When editing, the code looks exactly like regular Java code. However, under the hood, the framework appends a version number to each class name and replaces all class references before compilation. For example, ClassA becomes ClassAv1.

I am developing a plugin to support editing this kind of code in IntelliJ IDEA.

When editing, the code looks like this:

package d.e.f;
class BeCalledDynamicClass {
    public static void callSomeStaticMethod() {

    }
}
package a.b.c;

// Use @DynamicClassImport to declare dynamic classes used in this class.
@DynamicClassImport("d.e.f.BeCalledDynamicClass")
class DynamicClassA {
    public void someMethod() {
        BeCalledDynamicClass.callSomeStaticMethod();
    }
}

At runtime, the actual compiled code looks like this:

package d.e.f;

// Version number appended to the class name
class BeCalledDynamicClassv1 {
    public static void callSomeStaticMethod() {

    }
}
package a.b.c;

@DynamicClassImport("d.e.f.BeCalledDynamicClass")

// Version number appended to the class name
class DynamicClassAv1 {
    public void someMethod() {

        // The following line:
        // BeCalledDynamicClass.callSomeStaticMethod();
        // is replaced with:

       DynamicCaller.of("d.e.f.BeCalledDynamicClass").call("callSomeStaticMethod");
    }
}

I have downloaded the runtime-generated source code into the IDEA workspace.

My question is:

How can I let IntelliJ IDEA understand that BeCalledDynamicClass should resolve to d.e.f.BeCalledDynamicClassv1, so that it can provide full code completion, navigation, and code inspection support?

0

Please sign in to leave a comment.