LSP-390 EquationsExternalizer: make a singleton to prevent externalizer hashcode mismatch errors in LSP

LSP creates "a new copy of the world" for each request, and this caused EquationsExternalizer to be recreated too.

GitOrigin-RevId: 3f56d2a933d3d96533f5afd4c206fcecde04a716
This commit is contained in:
Bartek Pacia
2026-01-13 18:51:52 +00:00
committed by intellij-monorepo-bot
parent fa34bb71df
commit 427a1cb8f3
3 changed files with 4 additions and 2 deletions
@@ -24,7 +24,7 @@ public final class BytecodeAnalysisGist {
gist = GistManager.getInstance().newVirtualFileGist(
"BytecodeAnalysisIndex",
ClassDataIndexer.FINAL_VERSION,
new BytecodeAnalysisIndex.EquationsExternalizer(),
BytecodeAnalysisIndex.EquationsExternalizer.INSTANCE,
new ClassDataIndexer()
);
}
@@ -138,6 +138,8 @@ public final class BytecodeAnalysisIndex extends ScalarIndexExtension<HMember> {
* Externalizer for compressed equations.
*/
public static class EquationsExternalizer implements DataExternalizer<Map<HMember, Equations>> {
public static final EquationsExternalizer INSTANCE = new EquationsExternalizer();
@Override
public void save(@NotNull DataOutput out, Map<HMember, Equations> value) throws IOException {
DataInputOutputUtilRt.writeSeq(out, value.entrySet(), entry -> {
@@ -284,7 +284,7 @@ public final class ClassDataIndexer implements VirtualFileGist.GistCalculator<Ma
public void accept(Map<HMember, Equations> map) {
try {
UnsyncByteArrayOutputStream stream = new UnsyncByteArrayOutputStream();
new BytecodeAnalysisIndex.EquationsExternalizer().save(new DataOutputStream(stream), map);
BytecodeAnalysisIndex.EquationsExternalizer.INSTANCE.save(new DataOutputStream(stream), map);
ourTotalSize.addAndGet(stream.size());
ourTotalCount.incrementAndGet();
}