I want to link elements in a markdown file to java string literals so the string literal appears as the declaration and the markdown element as a reference.
The issue is that the java string literals can override literals by the same name from a super class so sometimes the literal will refer to a literal in another class.
Markdown elements in multiple files can refer to string literal in the same java file and elements from one markdown file can refer to string literal in several java class files.
I figured that the only way to accomplish this is via a
FakePsiElement which is used as a fake declaration with both the Java string literal and Markdown referring to the fake element in their references.
I had it working without the fake psi element except without having string literal override ones in a base class. I put it into an overview diagram with all relevant points:
Q1: The question I have is how to have all elements be refactored together when they reference the same
Q2: Do I need to provide a
SearchReferences extension point and when the
elementToSearch is a
FakePsiLiteralExpression then provide references from markdown elements that use it?
Q3: How do I make sure that a
FakePsiLiteralExpression element is treated identically to another instance which refers to the same underlying
Q4: Is having
hashCode() return the same value for these
FakePsiLiteralExpression instances enough or do I need to have a manager to ensure that for every
PsiLiteralExpression the same instance of
FakePsiLiteralExpression is always used?