Generate IR for synthetic nested classes directly in class generator

This commit is contained in:
Leonid Startsev
2018-07-09 17:07:43 +03:00
parent c3f66cda65
commit ba9b7547b0
9 changed files with 87 additions and 50 deletions
@@ -67,7 +67,7 @@ abstract class KtClassOrObject :
fun getAnonymousInitializers(): List<KtAnonymousInitializer> = getBody()?.anonymousInitializers.orEmpty()
fun getBody(): KtClassBody? = getStubOrPsiChild(KtStubElementTypes.CLASS_BODY)
override fun getBody(): KtClassBody? = getStubOrPsiChild(KtStubElementTypes.CLASS_BODY)
inline fun <reified T : KtDeclaration> addDeclaration(declaration: T): T {
val body = getOrCreateBody()
@@ -57,5 +57,8 @@ public interface KtPureClassOrObject extends KtPureElement, KtDeclarationContain
@NotNull
@ReadOnly
List<KtSecondaryConstructor> getSecondaryConstructors();
@Nullable
KtClassBody getBody();
}
@@ -26,10 +26,7 @@ import com.intellij.psi.search.SearchScope
import com.intellij.psi.util.PsiTreeUtil
import org.jetbrains.kotlin.diagnostics.PsiDiagnosticUtils
import org.jetbrains.kotlin.lexer.KtTokens
import org.jetbrains.kotlin.psi.KtFile
import org.jetbrains.kotlin.psi.KtFileAnnotationList
import org.jetbrains.kotlin.psi.KtModifierList
import org.jetbrains.kotlin.psi.KtModifierListOwner
import org.jetbrains.kotlin.psi.*
import java.util.*
// NOTE: in this file we collect only LANGUAGE INDEPENDENT methods working with PSI and not modifying it
@@ -294,6 +291,13 @@ val PsiElement.startOffset: Int
val PsiElement.endOffset: Int
get() = textRange.endOffset
val KtPureElement.pureStartOffset: Int
get() = psiOrParent.textRange.startOffset
val KtPureElement.pureEndOffset: Int
get() = psiOrParent.textRange.endOffset
fun PsiElement.getStartOffsetIn(ancestor: PsiElement): Int {
var offset = 0
var parent = this