[FIR] Strip comments in Fir2IrAnnotationsFromPluginRegistrar

Fir2IrAnnotationsFromPluginRegistrar stores elements using start and end
  offsets from IR elements, which strip comments from the start offset.
  So it's also needed to strip it from FIR source to keep the consistency

^KT-61872 Fixed
This commit is contained in:
Dmitriy Novozhilov
2023-09-12 12:39:33 +03:00
committed by Space Team
parent 1f49266c4b
commit 6d00dcf972
2 changed files with 3 additions and 3 deletions
@@ -80,7 +80,7 @@ class Fir2IrAnnotationsFromPluginRegistrar(private val components: Fir2IrCompone
val fileFqName = firFile.packageFqName.child(Name.identifier(firFile.name)).asString()
val source = declaration.source ?: return emptyList()
val fileStorage = generatedIrDeclarationsByFileByOffset[fileFqName] ?: return emptyList()
return fileStorage[source.startOffset to source.endOffset] ?: emptyList()
return fileStorage[(source.startOffsetSkippingComments() ?: source.startOffset) to source.endOffset] ?: emptyList()
}
private fun FirDeclaration.containingFile(): FirFile? {
@@ -6,8 +6,8 @@
@R|org/jetbrains/kotlin/fir/plugin/AnnotationToAdd|(booleanValue = Boolean(true), byteValue = Byte(1), charValue = Char(c), doubleValue = Double(4.2), floatValue = Float(2.4), intValue = Int(42), longValue = Long(24), shortValue = Short(7), stringValue = String(OK)) public constructor(@R|org/jetbrains/kotlin/fir/plugin/AnnotationToAdd|(booleanValue = Boolean(true), byteValue = Byte(1), charValue = Char(c), doubleValue = Double(4.2), floatValue = Float(2.4), intValue = Int(42), longValue = Long(24), shortValue = Short(7), stringValue = String(OK)) @R|org/jetbrains/kotlin/fir/plugin/AnnotationToAdd|(booleanValue = Boolean(true), byteValue = Byte(1), charValue = Char(c), doubleValue = Double(4.2), floatValue = Float(2.4), intValue = Int(42), longValue = Long(24), shortValue = Short(7), stringValue = String(OK)) @R|org/jetbrains/kotlin/fir/plugin/AnnotationToAdd|(booleanValue = Boolean(true), byteValue = Byte(1), charValue = Char(c), doubleValue = Double(4.2), floatValue = Float(2.4), intValue = Int(42), longValue = Long(24), shortValue = Short(7), stringValue = String(OK)) @R|org/jetbrains/kotlin/fir/plugin/AnnotationToAdd|(booleanValue = Boolean(true), byteValue = Byte(1), charValue = Char(c), doubleValue = Double(4.2), floatValue = Float(2.4), intValue = Int(42), longValue = Long(24), shortValue = Short(7), stringValue = String(OK)) @R|org/jetbrains/kotlin/fir/plugin/AnnotationToAdd|(booleanValue = Boolean(true), byteValue = Byte(1), charValue = Char(c), doubleValue = Double(4.2), floatValue = Float(2.4), intValue = Int(42), longValue = Long(24), shortValue = Short(7), stringValue = String(OK)) x: R|kotlin/Int|): R|test/Some|
public final class Derived : R|kotlin/Any| {
public constructor(): R|test/Some.Derived|
@R|org/jetbrains/kotlin/fir/plugin/AnnotationToAdd|(booleanValue = Boolean(true), byteValue = Byte(1), charValue = Char(c), doubleValue = Double(4.2), floatValue = Float(2.4), intValue = Int(42), longValue = Long(24), shortValue = Short(7), stringValue = String(OK)) @R|org/jetbrains/kotlin/fir/plugin/AnnotationToAdd|(booleanValue = Boolean(true), byteValue = Byte(1), charValue = Char(c), doubleValue = Double(4.2), floatValue = Float(2.4), intValue = Int(42), longValue = Long(24), shortValue = Short(7), stringValue = String(OK)) @R|org/jetbrains/kotlin/fir/plugin/AnnotationToAdd|(booleanValue = Boolean(true), byteValue = Byte(1), charValue = Char(c), doubleValue = Double(4.2), floatValue = Float(2.4), intValue = Int(42), longValue = Long(24), shortValue = Short(7), stringValue = String(OK)) public final class Derived : R|kotlin/Any| {
@R|org/jetbrains/kotlin/fir/plugin/AnnotationToAdd|(booleanValue = Boolean(true), byteValue = Byte(1), charValue = Char(c), doubleValue = Double(4.2), floatValue = Float(2.4), intValue = Int(42), longValue = Long(24), shortValue = Short(7), stringValue = String(OK)) @R|org/jetbrains/kotlin/fir/plugin/AnnotationToAdd|(booleanValue = Boolean(true), byteValue = Byte(1), charValue = Char(c), doubleValue = Double(4.2), floatValue = Float(2.4), intValue = Int(42), longValue = Long(24), shortValue = Short(7), stringValue = String(OK)) @R|org/jetbrains/kotlin/fir/plugin/AnnotationToAdd|(booleanValue = Boolean(true), byteValue = Byte(1), charValue = Char(c), doubleValue = Double(4.2), floatValue = Float(2.4), intValue = Int(42), longValue = Long(24), shortValue = Short(7), stringValue = String(OK)) public constructor(): R|test/Some.Derived|
}