[AA, LL] use stubs to build deserialized Fir elements in IDE

^KTIJ-24638

Notice on `DebugSymbolRenderer`:
stub based deserializer sets source directly,
but it's available in IDE mode only.
Thus, standalone and IDE tests have different results.
In order to avoid this, sources for compiled code are explicitly ignored

Notice on distinct callables:
for a file which belong to multiple libraries, decompiled code would be build per library.
In order to avoid ambiguity errors for members in that file,
we need to distinct provided elements by origins
failed test from IJ repo:
 FirReferenceResolveWithCrossLibTestGenerated#testSetWithTypeParameters
This commit is contained in:
Anna Kozlova
2023-02-15 14:22:59 +01:00
committed by teamcity
parent 96c15f6c71
commit d59d66e876
41 changed files with 1957 additions and 90 deletions
@@ -41,12 +41,15 @@ public class KtNameReferenceExpressionElementType extends KtStubElementType<Kotl
@Override
public void serialize(@NotNull KotlinNameReferenceExpressionStub stub, @NotNull StubOutputStream dataStream) throws IOException {
dataStream.writeName(stub.getReferencedName());
dataStream.writeBoolean(
stub instanceof KotlinNameReferenceExpressionStubImpl && ((KotlinNameReferenceExpressionStubImpl) stub).isClassRef());
}
@NotNull
@Override
public KotlinNameReferenceExpressionStub deserialize(@NotNull StubInputStream dataStream, StubElement parentStub) throws IOException {
StringRef referencedName = dataStream.readName();
return new KotlinNameReferenceExpressionStubImpl(parentStub, referencedName);
boolean isClassRef = dataStream.readBoolean();
return new KotlinNameReferenceExpressionStubImpl(parentStub, referencedName, isClassRef);
}
}
@@ -16,9 +16,11 @@
package org.jetbrains.kotlin.psi.stubs.impl;
import com.intellij.psi.stubs.IStubElementType;
import com.intellij.psi.stubs.StubElement;
import com.intellij.util.io.StringRef;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
import org.jetbrains.kotlin.psi.KtNameReferenceExpression;
import org.jetbrains.kotlin.psi.stubs.KotlinNameReferenceExpressionStub;
import org.jetbrains.kotlin.psi.stubs.elements.KtStubElementTypes;
@@ -27,10 +29,26 @@ public class KotlinNameReferenceExpressionStubImpl extends KotlinStubBaseImpl<Kt
KotlinNameReferenceExpressionStub {
@NotNull
private final StringRef referencedName;
private final boolean myClassRef;
public KotlinNameReferenceExpressionStubImpl(StubElement parent, @NotNull StringRef referencedName) {
super(parent, KtStubElementTypes.REFERENCE_EXPRESSION);
this.referencedName = referencedName;
myClassRef = false;
}
public KotlinNameReferenceExpressionStubImpl(
@Nullable StubElement<?> parent,
@NotNull StringRef referencedName,
boolean myClassRef
) {
super(parent, KtStubElementTypes.REFERENCE_EXPRESSION);
this.referencedName = referencedName;
this.myClassRef = myClassRef;
}
public boolean isClassRef() {
return myClassRef;
}
@NotNull