[LL FIR] simplify FileStructureElement invalidation
We can avoid complex reanalyze-base logic and just directly drop outdated data from FileStructureCache ^KT-60611
This commit is contained in:
committed by
Space Team
parent
89c186c496
commit
8832865e9a
+5
-47
@@ -6,9 +6,7 @@
|
||||
package org.jetbrains.kotlin.analysis.low.level.api.fir.file.structure
|
||||
|
||||
import com.intellij.psi.PsiElement
|
||||
import org.jetbrains.annotations.TestOnly
|
||||
import org.jetbrains.kotlin.KtFakeSourceElementKind
|
||||
import org.jetbrains.kotlin.analysis.low.level.api.fir.LLFirInternals
|
||||
import org.jetbrains.kotlin.analysis.low.level.api.fir.LLFirModuleResolveComponents
|
||||
import org.jetbrains.kotlin.analysis.low.level.api.fir.api.collectDesignationWithFile
|
||||
import org.jetbrains.kotlin.analysis.low.level.api.fir.api.targets.LLFirClassWithSpecificMembersResolveTarget
|
||||
@@ -22,48 +20,16 @@ import org.jetbrains.kotlin.psi.psiUtil.isContractDescriptionCallPsiCheck
|
||||
internal object FileElementFactory {
|
||||
fun createFileStructureElement(
|
||||
firDeclaration: FirDeclaration,
|
||||
ktDeclaration: KtDeclaration,
|
||||
firFile: FirFile,
|
||||
moduleComponents: LLFirModuleResolveComponents,
|
||||
): FileStructureElement = when {
|
||||
ktDeclaration is KtNamedFunction && ktDeclaration.isReanalyzableContainer() -> ReanalyzableFunctionStructureElement(
|
||||
firFile,
|
||||
ktDeclaration,
|
||||
(firDeclaration as FirSimpleFunction).symbol,
|
||||
ktDeclaration.modificationStamp,
|
||||
moduleComponents,
|
||||
)
|
||||
|
||||
ktDeclaration is KtProperty &&
|
||||
(ktDeclaration.isReanalyzableContainer() || ktDeclaration.accessors.any { it.isReanalyzableContainer() })
|
||||
-> ReanalyzablePropertyStructureElement(
|
||||
firFile,
|
||||
ktDeclaration,
|
||||
(firDeclaration as FirProperty).symbol,
|
||||
ktDeclaration.modificationStamp,
|
||||
moduleComponents,
|
||||
)
|
||||
|
||||
ktDeclaration is KtClassOrObject && ktDeclaration !is KtEnumEntry -> {
|
||||
lazyResolveClassWithGeneratedMembers(firDeclaration as FirRegularClass, moduleComponents)
|
||||
NonReanalyzableClassDeclarationStructureElement(
|
||||
firFile,
|
||||
firDeclaration,
|
||||
ktDeclaration,
|
||||
moduleComponents,
|
||||
)
|
||||
firDeclaration is FirRegularClass -> {
|
||||
lazyResolveClassWithGeneratedMembers(firDeclaration, moduleComponents)
|
||||
ClassDeclarationStructureElement(firFile, firDeclaration, moduleComponents)
|
||||
}
|
||||
|
||||
ktDeclaration is KtScript -> RootScriptStructureElement(firFile, firDeclaration as FirScript, ktDeclaration, moduleComponents)
|
||||
|
||||
else -> {
|
||||
NonReanalyzableNonClassDeclarationStructureElement(
|
||||
firFile,
|
||||
firDeclaration,
|
||||
ktDeclaration,
|
||||
moduleComponents,
|
||||
)
|
||||
}
|
||||
firDeclaration is FirScript -> RootScriptStructureElement(firFile, firDeclaration, moduleComponents)
|
||||
else -> DeclarationStructureElement(firFile, firDeclaration, moduleComponents)
|
||||
}
|
||||
|
||||
private fun lazyResolveClassWithGeneratedMembers(firClass: FirRegularClass, moduleComponents: LLFirModuleResolveComponents) {
|
||||
@@ -149,14 +115,6 @@ private fun isInsideContract(body: KtExpression, child: PsiElement): Boolean {
|
||||
return firstStatement.isAncestor(child)
|
||||
}
|
||||
|
||||
@TestOnly
|
||||
internal fun KtDeclaration.isReanalyzableContainer(): Boolean = when (this) {
|
||||
is KtNamedFunction -> isReanalyzableContainer()
|
||||
is KtPropertyAccessor -> isReanalyzableContainer()
|
||||
is KtProperty -> isReanalyzableContainer()
|
||||
else -> error("Unknown declaration type: ${this::class.simpleName}")
|
||||
}
|
||||
|
||||
private fun KtNamedFunction.isReanalyzableContainer(): Boolean = hasBlockBody() || typeReference != null
|
||||
|
||||
private fun KtPropertyAccessor.isReanalyzableContainer(): Boolean = isSetter || hasBlockBody() || property.typeReference != null
|
||||
|
||||
+28
-39
@@ -10,25 +10,25 @@ import com.intellij.psi.PsiErrorElement
|
||||
import com.intellij.psi.util.PsiTreeUtil
|
||||
import org.jetbrains.kotlin.analysis.low.level.api.fir.LLFirModuleResolveComponents
|
||||
import org.jetbrains.kotlin.analysis.low.level.api.fir.api.DiagnosticCheckerFilter
|
||||
import org.jetbrains.kotlin.analysis.low.level.api.fir.element.builder.canBePartOfParentDeclaration
|
||||
import org.jetbrains.kotlin.analysis.low.level.api.fir.element.builder.getNonLocalContainingOrThisDeclaration
|
||||
import org.jetbrains.kotlin.analysis.low.level.api.fir.util.codeFragment
|
||||
import org.jetbrains.kotlin.analysis.low.level.api.fir.util.errorWithFirSpecificEntries
|
||||
import org.jetbrains.kotlin.analysis.low.level.api.fir.util.findSourceByTraversingWholeTree
|
||||
import org.jetbrains.kotlin.analysis.low.level.api.fir.util.findSourceNonLocalFirDeclaration
|
||||
import org.jetbrains.kotlin.diagnostics.KtPsiDiagnostic
|
||||
import org.jetbrains.kotlin.fir.correspondingProperty
|
||||
import org.jetbrains.kotlin.fir.declarations.FirDanglingModifierList
|
||||
import org.jetbrains.kotlin.fir.declarations.FirFile
|
||||
import org.jetbrains.kotlin.fir.declarations.FirResolvePhase
|
||||
import org.jetbrains.kotlin.fir.declarations.impl.FirPrimaryConstructor
|
||||
import org.jetbrains.kotlin.fir.resolve.providers.firProvider
|
||||
import org.jetbrains.kotlin.fir.symbols.lazyResolveToPhase
|
||||
import org.jetbrains.kotlin.psi.*
|
||||
import org.jetbrains.kotlin.psi.psiUtil.isAncestor
|
||||
import java.util.concurrent.ConcurrentHashMap
|
||||
import org.jetbrains.kotlin.analysis.low.level.api.fir.element.builder.canBePartOfParentDeclaration
|
||||
import org.jetbrains.kotlin.analysis.low.level.api.fir.util.codeFragment
|
||||
import org.jetbrains.kotlin.fir.correspondingProperty
|
||||
import org.jetbrains.kotlin.fir.declarations.impl.FirPrimaryConstructor
|
||||
import org.jetbrains.kotlin.utils.exceptions.errorWithAttachment
|
||||
import org.jetbrains.kotlin.utils.exceptions.withPsiEntry
|
||||
import java.util.concurrent.ConcurrentHashMap
|
||||
|
||||
internal class FileStructure private constructor(
|
||||
private val ktFile: KtFile,
|
||||
@@ -49,7 +49,24 @@ internal class FileStructure private constructor(
|
||||
|
||||
private val structureElements = ConcurrentHashMap<KtElement, FileStructureElement>()
|
||||
|
||||
/**
|
||||
* Must be called only under write-lock.
|
||||
*
|
||||
* This method is responsible for "invalidation" of re-analyzable declarations.
|
||||
*
|
||||
* @see LLFirDeclarationModificationService
|
||||
*/
|
||||
fun invalidateElement(element: KtElement) {
|
||||
val container = getContainerKtElement(element)
|
||||
structureElements.remove(container)
|
||||
}
|
||||
|
||||
fun getStructureElementFor(element: KtElement): FileStructureElement {
|
||||
val container = getContainerKtElement(element)
|
||||
return structureElements.getOrPut(container) { createStructureElement(container) }
|
||||
}
|
||||
|
||||
private fun getContainerKtElement(element: KtElement): KtElement {
|
||||
val declaration = getStructureKtElement(element)
|
||||
val container: KtElement
|
||||
if (declaration != null) {
|
||||
@@ -63,7 +80,7 @@ internal class FileStructure private constructor(
|
||||
}
|
||||
}
|
||||
|
||||
return getStructureElementForDeclaration(container)
|
||||
return container
|
||||
}
|
||||
|
||||
private fun getStructureKtElement(element: KtElement): KtDeclaration? {
|
||||
@@ -89,31 +106,6 @@ internal class FileStructure private constructor(
|
||||
return false
|
||||
}
|
||||
|
||||
private fun getStructureElementForDeclaration(declaration: KtElement): FileStructureElement {
|
||||
val elementFromCache = structureElements[declaration]
|
||||
if (elementFromCache == null) {
|
||||
val newElement = createStructureElement(declaration)
|
||||
return structureElements.putIfAbsent(declaration, newElement) ?: newElement
|
||||
}
|
||||
|
||||
if (elementFromCache !is ReanalyzableStructureElement<*, *> || elementFromCache.isUpToDate()) {
|
||||
return elementFromCache
|
||||
}
|
||||
|
||||
val reanalyzedElement = elementFromCache.reanalyze()
|
||||
return structureElements.merge(declaration, reanalyzedElement) { _, oldElement ->
|
||||
if (oldElement === elementFromCache) {
|
||||
reanalyzedElement
|
||||
} else {
|
||||
// Another thread already reanalyzed the declaration
|
||||
oldElement
|
||||
}
|
||||
} ?: errorWithFirSpecificEntries(
|
||||
"${reanalyzedElement::class.simpleName} for ${declaration::class.simpleName} is gone",
|
||||
psi = declaration,
|
||||
)
|
||||
}
|
||||
|
||||
fun getAllDiagnosticsForFile(diagnosticCheckerFilter: DiagnosticCheckerFilter): Collection<KtPsiDiagnostic> {
|
||||
// TODO, KT-60799: Add a new FileStructure for file diagnostics
|
||||
firFile.lazyResolveToPhase(FirResolvePhase.BODY_RESOLVE)
|
||||
@@ -144,9 +136,7 @@ internal class FileStructure private constructor(
|
||||
override fun visitDeclaration(dcl: KtDeclaration) {
|
||||
val structureElement = getStructureElementFor(dcl)
|
||||
structureElements += structureElement
|
||||
if (structureElement !is ReanalyzableStructureElement<*, *>) {
|
||||
dcl.acceptChildren(this)
|
||||
}
|
||||
dcl.acceptChildren(this)
|
||||
}
|
||||
|
||||
override fun visitModifierList(list: KtModifierList) {
|
||||
@@ -175,20 +165,19 @@ internal class FileStructure private constructor(
|
||||
|
||||
return FileElementFactory.createFileStructureElement(
|
||||
firDeclaration = firDeclaration,
|
||||
ktDeclaration = declaration,
|
||||
firFile = firFile,
|
||||
moduleComponents = moduleComponents
|
||||
)
|
||||
}
|
||||
|
||||
private fun createDanglingModifierListStructure(container: KtElement): FileStructureElement {
|
||||
private fun createDanglingModifierListStructure(container: KtModifierList): FileStructureElement {
|
||||
val firDanglingModifierList = container.findSourceByTraversingWholeTree(
|
||||
moduleComponents.firFileBuilder,
|
||||
firFile,
|
||||
) as? FirDanglingModifierList ?: errorWithFirSpecificEntries("No dangling modifier found", psi = container)
|
||||
|
||||
firDanglingModifierList.lazyResolveToPhase(FirResolvePhase.BODY_RESOLVE)
|
||||
return DanglingTopLevelModifierListStructureElement(firFile, firDanglingModifierList, moduleComponents, container.containingKtFile)
|
||||
return DeclarationStructureElement(firFile, firDanglingModifierList, moduleComponents)
|
||||
}
|
||||
|
||||
private fun createStructureElement(container: KtElement): FileStructureElement = when {
|
||||
@@ -196,7 +185,7 @@ internal class FileStructure private constructor(
|
||||
val firCodeFragment = firFile.codeFragment
|
||||
firCodeFragment.lazyResolveToPhase(FirResolvePhase.BODY_RESOLVE)
|
||||
|
||||
ReanalyzableCodeFragmentStructureElement(firFile, container, firCodeFragment.symbol, moduleComponents)
|
||||
DeclarationStructureElement(firFile, firCodeFragment, moduleComponents)
|
||||
}
|
||||
container is KtFile -> {
|
||||
val firFile = moduleComponents.firFileBuilder.buildRawFirFileWithCaching(ktFile)
|
||||
@@ -210,7 +199,7 @@ internal class FileStructure private constructor(
|
||||
)
|
||||
}
|
||||
|
||||
RootStructureElement(firFile, container, moduleComponents)
|
||||
RootStructureElement(firFile, moduleComponents)
|
||||
}
|
||||
container is KtDeclaration -> createDeclarationStructure(container)
|
||||
container is KtModifierList && container.nextSibling is PsiErrorElement -> createDanglingModifierListStructure(container)
|
||||
|
||||
+2
@@ -18,4 +18,6 @@ internal class FileStructureCache(private val moduleResolveComponents: LLFirModu
|
||||
fun getFileStructure(ktFile: KtFile): FileStructure = cache.computeIfAbsent(ktFile) {
|
||||
FileStructure.build(ktFile, moduleResolveComponents)
|
||||
}
|
||||
|
||||
fun getCachedFileStructure(ktFile: KtFile): FileStructure? = cache[ktFile]
|
||||
}
|
||||
+26
-131
@@ -19,16 +19,10 @@ import org.jetbrains.kotlin.fir.FirElement
|
||||
import org.jetbrains.kotlin.fir.correspondingProperty
|
||||
import org.jetbrains.kotlin.fir.declarations.*
|
||||
import org.jetbrains.kotlin.fir.declarations.impl.FirPrimaryConstructor
|
||||
import org.jetbrains.kotlin.fir.symbols.FirBasedSymbol
|
||||
import org.jetbrains.kotlin.fir.symbols.impl.FirCodeFragmentSymbol
|
||||
import org.jetbrains.kotlin.fir.symbols.impl.FirFunctionSymbol
|
||||
import org.jetbrains.kotlin.fir.symbols.impl.FirPropertySymbol
|
||||
import org.jetbrains.kotlin.fir.symbols.lazyResolveToPhase
|
||||
import org.jetbrains.kotlin.fir.visitors.FirVisitor
|
||||
import org.jetbrains.kotlin.psi.*
|
||||
|
||||
internal sealed class FileStructureElement(val firFile: FirFile, protected val moduleComponents: LLFirModuleResolveComponents) {
|
||||
abstract val psi: KtAnnotated
|
||||
internal sealed class FileStructureElement {
|
||||
abstract val mappings: KtToFirMapping
|
||||
abstract val diagnostics: FileStructureElementDiagnostics
|
||||
|
||||
@@ -38,8 +32,8 @@ internal sealed class FileStructureElement(val firFile: FirFile, protected val m
|
||||
fun recorderFor(fir: FirElement): FirElementsRecorder = when (fir) {
|
||||
is FirFile -> RootStructureElement.Recorder
|
||||
is FirScript -> RootScriptStructureElement.Recorder
|
||||
is FirRegularClass -> NonReanalyzableClassDeclarationStructureElement.Recorder(fir)
|
||||
else -> NonReanalyzableNonClassDeclarationStructureElement.Recorder
|
||||
is FirRegularClass -> ClassDeclarationStructureElement.Recorder(fir)
|
||||
else -> DeclarationStructureElement.Recorder
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -120,101 +114,18 @@ internal class KtToFirMapping(firElement: FirElement) {
|
||||
}
|
||||
}
|
||||
|
||||
internal sealed class ReanalyzableStructureElement<KT : KtAnnotated, S : FirBasedSymbol<*>>(
|
||||
firFile: FirFile,
|
||||
val firSymbol: S,
|
||||
moduleComponents: LLFirModuleResolveComponents,
|
||||
) : FileStructureElement(firFile, moduleComponents) {
|
||||
abstract override val psi: KtAnnotated
|
||||
abstract val timestamp: Long
|
||||
|
||||
override val mappings = KtToFirMapping(firSymbol.fir)
|
||||
|
||||
/**
|
||||
* Recreate [mappings] and [diagnostics]
|
||||
*/
|
||||
abstract fun reanalyze(): ReanalyzableStructureElement<KT, S>
|
||||
|
||||
fun isUpToDate(): Boolean = psi.getModificationStamp() == timestamp
|
||||
|
||||
override val diagnostics = FileStructureElementDiagnostics(
|
||||
firFile,
|
||||
SingleNonLocalDeclarationDiagnosticRetriever(firSymbol.fir),
|
||||
moduleComponents,
|
||||
)
|
||||
}
|
||||
|
||||
internal class ReanalyzableCodeFragmentStructureElement(
|
||||
firFile: FirFile,
|
||||
override val psi: KtCodeFragment,
|
||||
firSymbol: FirCodeFragmentSymbol,
|
||||
moduleComponents: LLFirModuleResolveComponents,
|
||||
) : ReanalyzableStructureElement<KtCodeFragment, FirCodeFragmentSymbol>(firFile, firSymbol, moduleComponents) {
|
||||
override val timestamp = psi.modificationStamp
|
||||
|
||||
override fun reanalyze(): ReanalyzableStructureElement<KtCodeFragment, FirCodeFragmentSymbol> {
|
||||
firSymbol.lazyResolveToPhase(FirResolvePhase.BODY_RESOLVE)
|
||||
return ReanalyzableCodeFragmentStructureElement(firFile, psi, firSymbol, moduleComponents)
|
||||
}
|
||||
}
|
||||
|
||||
internal class ReanalyzableFunctionStructureElement(
|
||||
firFile: FirFile,
|
||||
override val psi: KtNamedFunction,
|
||||
firSymbol: FirFunctionSymbol<*>,
|
||||
override val timestamp: Long,
|
||||
moduleComponents: LLFirModuleResolveComponents,
|
||||
) : ReanalyzableStructureElement<KtNamedFunction, FirFunctionSymbol<*>>(firFile, firSymbol, moduleComponents) {
|
||||
override fun reanalyze(): ReanalyzableFunctionStructureElement {
|
||||
firSymbol.lazyResolveToPhase(FirResolvePhase.BODY_RESOLVE)
|
||||
|
||||
return ReanalyzableFunctionStructureElement(
|
||||
firFile,
|
||||
psi,
|
||||
firSymbol,
|
||||
psi.modificationStamp,
|
||||
moduleComponents,
|
||||
)
|
||||
}
|
||||
}
|
||||
|
||||
internal class ReanalyzablePropertyStructureElement(
|
||||
firFile: FirFile,
|
||||
override val psi: KtProperty,
|
||||
firSymbol: FirPropertySymbol,
|
||||
override val timestamp: Long,
|
||||
moduleComponents: LLFirModuleResolveComponents,
|
||||
) : ReanalyzableStructureElement<KtProperty, FirPropertySymbol>(firFile, firSymbol, moduleComponents) {
|
||||
override fun reanalyze(): ReanalyzablePropertyStructureElement {
|
||||
firSymbol.lazyResolveToPhase(FirResolvePhase.BODY_RESOLVE)
|
||||
|
||||
return ReanalyzablePropertyStructureElement(
|
||||
firFile,
|
||||
psi,
|
||||
firSymbol,
|
||||
psi.modificationStamp,
|
||||
moduleComponents,
|
||||
)
|
||||
}
|
||||
}
|
||||
|
||||
internal sealed class NonReanalyzableDeclarationStructureElement<T : FirDeclaration>(
|
||||
val firDeclaration: T,
|
||||
firFile: FirFile,
|
||||
moduleComponents: LLFirModuleResolveComponents,
|
||||
) : FileStructureElement(firFile, moduleComponents) {
|
||||
override val mappings: KtToFirMapping = KtToFirMapping(firDeclaration)
|
||||
internal sealed class DeclarationBaseStructureElement<F : FirDeclaration>(val declaration: F) : FileStructureElement() {
|
||||
override val mappings: KtToFirMapping = KtToFirMapping(declaration)
|
||||
}
|
||||
|
||||
internal class RootScriptStructureElement(
|
||||
firFile: FirFile,
|
||||
file: FirFile,
|
||||
script: FirScript,
|
||||
override val psi: KtScript,
|
||||
moduleComponents: LLFirModuleResolveComponents,
|
||||
) : NonReanalyzableDeclarationStructureElement<FirScript>(script, firFile, moduleComponents) {
|
||||
) : DeclarationBaseStructureElement<FirScript>(script) {
|
||||
override val diagnostics: FileStructureElementDiagnostics = FileStructureElementDiagnostics(
|
||||
firFile,
|
||||
ScriptDiagnosticRetriever(firDeclaration),
|
||||
file,
|
||||
ScriptDiagnosticRetriever(declaration),
|
||||
moduleComponents,
|
||||
)
|
||||
|
||||
@@ -236,15 +147,14 @@ internal fun <T, R> visitScriptDependentElements(script: FirScript, visitor: Fir
|
||||
}
|
||||
}
|
||||
|
||||
internal class NonReanalyzableClassDeclarationStructureElement(
|
||||
firFile: FirFile,
|
||||
fir: FirRegularClass,
|
||||
override val psi: KtClassOrObject,
|
||||
internal class ClassDeclarationStructureElement(
|
||||
file: FirFile,
|
||||
clazz: FirRegularClass,
|
||||
moduleComponents: LLFirModuleResolveComponents,
|
||||
) : NonReanalyzableDeclarationStructureElement<FirRegularClass>(fir, firFile, moduleComponents) {
|
||||
) : DeclarationBaseStructureElement<FirRegularClass>(clazz) {
|
||||
override val diagnostics = FileStructureElementDiagnostics(
|
||||
firFile,
|
||||
ClassDiagnosticRetriever(firDeclaration),
|
||||
file,
|
||||
ClassDiagnosticRetriever(declaration),
|
||||
moduleComponents,
|
||||
)
|
||||
|
||||
@@ -263,7 +173,7 @@ internal class NonReanalyzableClassDeclarationStructureElement(
|
||||
(constructor is FirPrimaryConstructor || constructor is FirErrorPrimaryConstructor) &&
|
||||
constructor.source?.kind == KtFakeSourceElementKind.ImplicitConstructor
|
||||
) {
|
||||
NonReanalyzableNonClassDeclarationStructureElement.Recorder.visitConstructor(constructor, data)
|
||||
DeclarationStructureElement.Recorder.visitConstructor(constructor, data)
|
||||
}
|
||||
}
|
||||
|
||||
@@ -283,15 +193,14 @@ internal class NonReanalyzableClassDeclarationStructureElement(
|
||||
}
|
||||
}
|
||||
|
||||
internal class NonReanalyzableNonClassDeclarationStructureElement(
|
||||
firFile: FirFile,
|
||||
fir: FirDeclaration,
|
||||
override val psi: KtDeclaration,
|
||||
internal class DeclarationStructureElement(
|
||||
file: FirFile,
|
||||
declaration: FirDeclaration,
|
||||
moduleComponents: LLFirModuleResolveComponents,
|
||||
) : NonReanalyzableDeclarationStructureElement<FirDeclaration>(fir, firFile, moduleComponents) {
|
||||
) : DeclarationBaseStructureElement<FirDeclaration>(declaration) {
|
||||
override val diagnostics = FileStructureElementDiagnostics(
|
||||
firFile,
|
||||
SingleNonLocalDeclarationDiagnosticRetriever(firDeclaration),
|
||||
file,
|
||||
SingleNonLocalDeclarationDiagnosticRetriever(declaration),
|
||||
moduleComponents,
|
||||
)
|
||||
|
||||
@@ -310,26 +219,12 @@ internal class NonReanalyzableNonClassDeclarationStructureElement(
|
||||
}
|
||||
}
|
||||
|
||||
internal class DanglingTopLevelModifierListStructureElement(
|
||||
firFile: FirFile,
|
||||
fir: FirDanglingModifierList,
|
||||
moduleComponents: LLFirModuleResolveComponents,
|
||||
override val psi: KtAnnotated,
|
||||
) : NonReanalyzableDeclarationStructureElement<FirDanglingModifierList>(fir, firFile, moduleComponents) {
|
||||
override val diagnostics = FileStructureElementDiagnostics(
|
||||
firFile,
|
||||
SingleNonLocalDeclarationDiagnosticRetriever(firDeclaration),
|
||||
moduleComponents,
|
||||
)
|
||||
}
|
||||
|
||||
internal class RootStructureElement(
|
||||
firFile: FirFile,
|
||||
override val psi: KtFile,
|
||||
val file: FirFile,
|
||||
moduleComponents: LLFirModuleResolveComponents,
|
||||
) : FileStructureElement(firFile, moduleComponents) {
|
||||
override val mappings = KtToFirMapping(firFile)
|
||||
override val diagnostics = FileStructureElementDiagnostics(firFile, FileDiagnosticRetriever, moduleComponents)
|
||||
) : FileStructureElement() {
|
||||
override val mappings = KtToFirMapping(file)
|
||||
override val diagnostics = FileStructureElementDiagnostics(file, FileDiagnosticRetriever, moduleComponents)
|
||||
|
||||
object Recorder : FirElementsRecorder() {
|
||||
override fun visitElement(element: FirElement, data: MutableMap<KtElement, FirElement>) {
|
||||
|
||||
+19
-1
@@ -15,6 +15,8 @@ import org.jetbrains.kotlin.analysis.low.level.api.fir.api.getFirResolveSession
|
||||
import org.jetbrains.kotlin.analysis.low.level.api.fir.api.getOrBuildFirFile
|
||||
import org.jetbrains.kotlin.analysis.low.level.api.fir.api.resolveToFirSymbol
|
||||
import org.jetbrains.kotlin.analysis.low.level.api.fir.file.structure.LLFirDeclarationModificationService.ModificationType
|
||||
import org.jetbrains.kotlin.analysis.low.level.api.fir.sessions.LLFirResolvableModuleSession
|
||||
import org.jetbrains.kotlin.analysis.low.level.api.fir.sessions.llFirResolvableSession
|
||||
import org.jetbrains.kotlin.analysis.low.level.api.fir.util.codeFragment
|
||||
import org.jetbrains.kotlin.analysis.low.level.api.fir.util.errorWithFirSpecificEntries
|
||||
import org.jetbrains.kotlin.analysis.project.structure.ProjectStructureProvider
|
||||
@@ -24,6 +26,7 @@ import org.jetbrains.kotlin.idea.KotlinLanguage
|
||||
import org.jetbrains.kotlin.psi.KtAnnotated
|
||||
import org.jetbrains.kotlin.psi.KtCodeFragment
|
||||
import org.jetbrains.kotlin.psi.KtDeclaration
|
||||
import org.jetbrains.kotlin.psi.KtElement
|
||||
|
||||
/**
|
||||
* This service is responsible for processing incoming [PsiElement] changes to reflect them on FIR tree.
|
||||
@@ -67,7 +70,7 @@ class LLFirDeclarationModificationService(val project: Project) {
|
||||
}
|
||||
}
|
||||
|
||||
private fun inBlockModification(declaration: PsiElement) {
|
||||
private fun inBlockModification(declaration: KtElement) {
|
||||
val ktModule = ProjectStructureProvider.getModule(project, declaration, contextualModule = null)
|
||||
val resolveSession = ktModule.getFirResolveSession(project)
|
||||
val firDeclaration = when (declaration) {
|
||||
@@ -80,6 +83,21 @@ class LLFirDeclarationModificationService(val project: Project) {
|
||||
}
|
||||
|
||||
invalidateAfterInBlockModification(firDeclaration)
|
||||
|
||||
val moduleSession = firDeclaration.llFirResolvableSession ?: errorWithFirSpecificEntries(
|
||||
"${LLFirResolvableModuleSession::class.simpleName} is not found",
|
||||
fir = firDeclaration,
|
||||
psi = declaration,
|
||||
) {
|
||||
withEntry("session", resolveSession) { it.toString() }
|
||||
}
|
||||
|
||||
val fileStructure = moduleSession.moduleComponents
|
||||
.fileStructureCache
|
||||
.getCachedFileStructure(declaration.containingKtFile)
|
||||
?: return // we do not have a cache for this file
|
||||
|
||||
fileStructure.invalidateElement(declaration)
|
||||
}
|
||||
|
||||
private fun outOfBlockModification(element: PsiElement) {
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
fun x() {/* ReanalyzableFunctionStructureElement */
|
||||
fun x() {/* DeclarationStructureElement */
|
||||
val x = object: Any() {
|
||||
fun foo(){}
|
||||
}
|
||||
|
||||
+4
-4
@@ -1,7 +1,7 @@
|
||||
open class B(x: () -> Unit)/* NonReanalyzableNonClassDeclarationStructureElement *//* NonReanalyzableClassDeclarationStructureElement */
|
||||
open class B(x: () -> Unit)/* DeclarationStructureElement *//* ClassDeclarationStructureElement */
|
||||
|
||||
class A()/* NonReanalyzableNonClassDeclarationStructureElement */ : B(1, {
|
||||
class A()/* DeclarationStructureElement */ : B(1, {
|
||||
foo()
|
||||
})/* NonReanalyzableClassDeclarationStructureElement */
|
||||
})/* ClassDeclarationStructureElement */
|
||||
|
||||
fun foo() {/* ReanalyzableFunctionStructureElement */}
|
||||
fun foo() {/* DeclarationStructureElement */}
|
||||
|
||||
+3
-3
@@ -1,7 +1,7 @@
|
||||
open class B(x: () -> Unit)/* NonReanalyzableNonClassDeclarationStructureElement *//* NonReanalyzableClassDeclarationStructureElement */
|
||||
open class B(x: () -> Unit)/* DeclarationStructureElement *//* ClassDeclarationStructureElement */
|
||||
|
||||
class A : B(1, {
|
||||
foo()
|
||||
})/* NonReanalyzableClassDeclarationStructureElement */
|
||||
})/* ClassDeclarationStructureElement */
|
||||
|
||||
fun foo() {/* ReanalyzableFunctionStructureElement */}
|
||||
fun foo() {/* DeclarationStructureElement */}
|
||||
|
||||
+5
-5
@@ -1,17 +1,17 @@
|
||||
open class A(x: () -> Unit)/* NonReanalyzableNonClassDeclarationStructureElement *//* NonReanalyzableClassDeclarationStructureElement */
|
||||
open class A(x: () -> Unit)/* DeclarationStructureElement *//* ClassDeclarationStructureElement */
|
||||
|
||||
class B : A {/* NonReanalyzableClassDeclarationStructureElement */
|
||||
class B : A {/* ClassDeclarationStructureElement */
|
||||
constructor(i: Int) : super(
|
||||
{
|
||||
foo(i)
|
||||
}
|
||||
)/* NonReanalyzableNonClassDeclarationStructureElement */
|
||||
)/* DeclarationStructureElement */
|
||||
|
||||
constructor(l: Long) : super(
|
||||
{
|
||||
foo(l)
|
||||
}
|
||||
)/* NonReanalyzableNonClassDeclarationStructureElement */
|
||||
)/* DeclarationStructureElement */
|
||||
}
|
||||
|
||||
fun foo(any: Any) {/* ReanalyzableFunctionStructureElement */}
|
||||
fun foo(any: Any) {/* DeclarationStructureElement */}
|
||||
|
||||
+4
-4
@@ -1,11 +1,11 @@
|
||||
open class A(x: () -> Unit)/* NonReanalyzableNonClassDeclarationStructureElement *//* NonReanalyzableClassDeclarationStructureElement */
|
||||
open class A(x: () -> Unit)/* DeclarationStructureElement *//* ClassDeclarationStructureElement */
|
||||
|
||||
class B : A {/* NonReanalyzableClassDeclarationStructureElement */
|
||||
class B : A {/* ClassDeclarationStructureElement */
|
||||
constructor(i: Int) : super(
|
||||
{
|
||||
foo(i)
|
||||
}
|
||||
)/* NonReanalyzableNonClassDeclarationStructureElement */
|
||||
)/* DeclarationStructureElement */
|
||||
}
|
||||
|
||||
fun foo(any: Any) {/* ReanalyzableFunctionStructureElement */}
|
||||
fun foo(any: Any) {/* DeclarationStructureElement */}
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
class A {/* NonReanalyzableClassDeclarationStructureElement */
|
||||
fun x() {/* ReanalyzableFunctionStructureElement */
|
||||
class A {/* ClassDeclarationStructureElement */
|
||||
fun x() {/* DeclarationStructureElement */
|
||||
|
||||
}
|
||||
fun y(): Int = 10/* ReanalyzableFunctionStructureElement */
|
||||
fun y(): Int = 10/* DeclarationStructureElement */
|
||||
}
|
||||
|
||||
@@ -1,8 +1,8 @@
|
||||
class B {/* NonReanalyzableClassDeclarationStructureElement */
|
||||
fun q(): C {/* ReanalyzableFunctionStructureElement */}
|
||||
private val y = q()/* NonReanalyzableNonClassDeclarationStructureElement */
|
||||
class B {/* ClassDeclarationStructureElement */
|
||||
fun q(): C {/* DeclarationStructureElement */}
|
||||
private val y = q()/* DeclarationStructureElement */
|
||||
|
||||
fun foo(a: A) = with(a) {
|
||||
bar("a", y)
|
||||
}/* NonReanalyzableNonClassDeclarationStructureElement */
|
||||
}/* DeclarationStructureElement */
|
||||
}
|
||||
|
||||
@@ -1,11 +1,11 @@
|
||||
class X {/* NonReanalyzableClassDeclarationStructureElement */
|
||||
var x: Int/* ReanalyzablePropertyStructureElement */
|
||||
class X {/* ClassDeclarationStructureElement */
|
||||
var x: Int/* DeclarationStructureElement */
|
||||
get() = field
|
||||
set(value) {
|
||||
field = value
|
||||
}
|
||||
|
||||
val y = 42/* NonReanalyzableNonClassDeclarationStructureElement */
|
||||
val y = 42/* DeclarationStructureElement */
|
||||
|
||||
var z: Int = 15/* NonReanalyzableNonClassDeclarationStructureElement */
|
||||
var z: Int = 15/* DeclarationStructureElement */
|
||||
}
|
||||
|
||||
+4
-4
@@ -1,11 +1,11 @@
|
||||
/* RootScriptStructureElement */class X {/* NonReanalyzableClassDeclarationStructureElement */
|
||||
var x: Int/* ReanalyzablePropertyStructureElement */
|
||||
/* RootScriptStructureElement */class X {/* ClassDeclarationStructureElement */
|
||||
var x: Int/* DeclarationStructureElement */
|
||||
get() = field
|
||||
set(value) {
|
||||
field = value
|
||||
}
|
||||
|
||||
val y = 42/* NonReanalyzableNonClassDeclarationStructureElement */
|
||||
val y = 42/* DeclarationStructureElement */
|
||||
|
||||
var z: Int = 15/* NonReanalyzableNonClassDeclarationStructureElement */
|
||||
var z: Int = 15/* DeclarationStructureElement */
|
||||
}
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
/* RootScriptStructureElement */class A {/* NonReanalyzableClassDeclarationStructureElement */
|
||||
fun x() {/* ReanalyzableFunctionStructureElement */
|
||||
/* RootScriptStructureElement */class A {/* ClassDeclarationStructureElement */
|
||||
fun x() {/* DeclarationStructureElement */
|
||||
|
||||
}
|
||||
fun y(): Int = 10/* ReanalyzableFunctionStructureElement */
|
||||
fun y(): Int = 10/* DeclarationStructureElement */
|
||||
}
|
||||
|
||||
@@ -1 +1 @@
|
||||
class A(var x: Int)/* NonReanalyzableNonClassDeclarationStructureElement *//* NonReanalyzableClassDeclarationStructureElement */
|
||||
class A(var x: Int)/* DeclarationStructureElement *//* ClassDeclarationStructureElement */
|
||||
|
||||
@@ -1 +1 @@
|
||||
class A(val x: String)/* NonReanalyzableNonClassDeclarationStructureElement *//* NonReanalyzableClassDeclarationStructureElement */
|
||||
class A(val x: String)/* DeclarationStructureElement *//* ClassDeclarationStructureElement */
|
||||
|
||||
+2
-2
@@ -5,6 +5,6 @@ class A(
|
||||
@field:Ann
|
||||
@property:Ann
|
||||
var x: Int
|
||||
)/* NonReanalyzableNonClassDeclarationStructureElement *//* NonReanalyzableClassDeclarationStructureElement */
|
||||
)/* DeclarationStructureElement *//* ClassDeclarationStructureElement */
|
||||
|
||||
annotation class Ann/* NonReanalyzableClassDeclarationStructureElement */
|
||||
annotation class Ann/* ClassDeclarationStructureElement */
|
||||
|
||||
@@ -1,9 +1,9 @@
|
||||
class A
|
||||
|
||||
(val a: Int)/* NonReanalyzableNonClassDeclarationStructureElement */
|
||||
(val a: Int)/* DeclarationStructureElement */
|
||||
|
||||
{/* NonReanalyzableClassDeclarationStructureElement */
|
||||
constructor() : this(1) {/* NonReanalyzableNonClassDeclarationStructureElement */
|
||||
{/* ClassDeclarationStructureElement */
|
||||
constructor() : this(1) {/* DeclarationStructureElement */
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,9 +1,9 @@
|
||||
/* RootScriptStructureElement */class A
|
||||
|
||||
(val a: Int)/* NonReanalyzableNonClassDeclarationStructureElement */
|
||||
(val a: Int)/* DeclarationStructureElement */
|
||||
|
||||
{/* NonReanalyzableClassDeclarationStructureElement */
|
||||
constructor() : this(1) {/* NonReanalyzableNonClassDeclarationStructureElement */
|
||||
{/* ClassDeclarationStructureElement */
|
||||
constructor() : this(1) {/* DeclarationStructureElement */
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
+5
-5
@@ -1,14 +1,14 @@
|
||||
class Foo {/* NonReanalyzableClassDeclarationStructureElement */
|
||||
class Foo {/* ClassDeclarationStructureElement */
|
||||
@Suppress("") @MustBeDocumented
|
||||
}
|
||||
class Bar {/* NonReanalyzableClassDeclarationStructureElement */
|
||||
class Bar {/* ClassDeclarationStructureElement */
|
||||
@Suppress("") @MustBeDocumented
|
||||
}
|
||||
class Outer {/* NonReanalyzableClassDeclarationStructureElement */
|
||||
class Inner {/* NonReanalyzableClassDeclarationStructureElement */
|
||||
class Outer {/* ClassDeclarationStructureElement */
|
||||
class Inner {/* ClassDeclarationStructureElement */
|
||||
@Suppress("") @MustBeDocumented
|
||||
}
|
||||
fun foo() {/* ReanalyzableFunctionStructureElement */
|
||||
fun foo() {/* DeclarationStructureElement */
|
||||
class Local {
|
||||
@Suppress("") @MustBeDocumented
|
||||
}
|
||||
|
||||
+5
-5
@@ -1,14 +1,14 @@
|
||||
/* RootScriptStructureElement */class Foo {/* NonReanalyzableClassDeclarationStructureElement */
|
||||
/* RootScriptStructureElement */class Foo {/* ClassDeclarationStructureElement */
|
||||
@Suppress("") @MustBeDocumented
|
||||
}
|
||||
class Bar {/* NonReanalyzableClassDeclarationStructureElement */
|
||||
class Bar {/* ClassDeclarationStructureElement */
|
||||
@Suppress("") @MustBeDocumented
|
||||
}
|
||||
class Outer {/* NonReanalyzableClassDeclarationStructureElement */
|
||||
class Inner {/* NonReanalyzableClassDeclarationStructureElement */
|
||||
class Outer {/* ClassDeclarationStructureElement */
|
||||
class Inner {/* ClassDeclarationStructureElement */
|
||||
@Suppress("") @MustBeDocumented
|
||||
}
|
||||
fun foo() {/* ReanalyzableFunctionStructureElement */
|
||||
fun foo() {/* DeclarationStructureElement */
|
||||
class Local {
|
||||
@Suppress("") @MustBeDocumented
|
||||
}
|
||||
|
||||
+1
-1
@@ -1 +1 @@
|
||||
@Suppress("") @MustBeDocumented/* DanglingTopLevelModifierListStructureElement */
|
||||
@Suppress("") @MustBeDocumented/* DeclarationStructureElement */
|
||||
|
||||
+3
-3
@@ -1,11 +1,11 @@
|
||||
class A {/* NonReanalyzableClassDeclarationStructureElement */
|
||||
class A {/* ClassDeclarationStructureElement */
|
||||
val a = myRun {
|
||||
class X()
|
||||
|
||||
val y = 10
|
||||
}/* NonReanalyzableNonClassDeclarationStructureElement */
|
||||
}/* DeclarationStructureElement */
|
||||
}
|
||||
|
||||
inline fun <R> myRun(block: () -> R): R {/* ReanalyzableFunctionStructureElement */
|
||||
inline fun <R> myRun(block: () -> R): R {/* DeclarationStructureElement */
|
||||
return block()
|
||||
}
|
||||
|
||||
+3
-3
@@ -1,11 +1,11 @@
|
||||
/* RootScriptStructureElement */class A {/* NonReanalyzableClassDeclarationStructureElement */
|
||||
/* RootScriptStructureElement */class A {/* ClassDeclarationStructureElement */
|
||||
val a = run {
|
||||
class X()
|
||||
|
||||
val y = 10
|
||||
}/* NonReanalyzableNonClassDeclarationStructureElement */
|
||||
}/* DeclarationStructureElement */
|
||||
}
|
||||
|
||||
inline fun <R> run(block: () -> R): R {/* ReanalyzableFunctionStructureElement */
|
||||
inline fun <R> run(block: () -> R): R {/* DeclarationStructureElement */
|
||||
return block()
|
||||
}
|
||||
|
||||
@@ -1,3 +1,3 @@
|
||||
enum class Enum(val x: Int)/* NonReanalyzableNonClassDeclarationStructureElement */ {/* NonReanalyzableClassDeclarationStructureElement */
|
||||
A(1),/* NonReanalyzableNonClassDeclarationStructureElement */
|
||||
enum class Enum(val x: Int)/* DeclarationStructureElement */ {/* ClassDeclarationStructureElement */
|
||||
A(1),/* DeclarationStructureElement */
|
||||
}
|
||||
|
||||
@@ -1,13 +1,13 @@
|
||||
enum class A {/* NonReanalyzableClassDeclarationStructureElement */
|
||||
X,/* NonReanalyzableNonClassDeclarationStructureElement */
|
||||
Y,/* NonReanalyzableNonClassDeclarationStructureElement */
|
||||
enum class A {/* ClassDeclarationStructureElement */
|
||||
X,/* DeclarationStructureElement */
|
||||
Y,/* DeclarationStructureElement */
|
||||
Z
|
||||
|
||||
;/* NonReanalyzableNonClassDeclarationStructureElement */
|
||||
;/* DeclarationStructureElement */
|
||||
|
||||
fun foo(){/* ReanalyzableFunctionStructureElement */}
|
||||
fun foo(){/* DeclarationStructureElement */}
|
||||
|
||||
val x = 10/* NonReanalyzableNonClassDeclarationStructureElement */
|
||||
val x = 10/* DeclarationStructureElement */
|
||||
|
||||
fun bar() = 10/* NonReanalyzableNonClassDeclarationStructureElement */
|
||||
fun bar() = 10/* DeclarationStructureElement */
|
||||
}
|
||||
|
||||
@@ -1,13 +1,13 @@
|
||||
/* RootScriptStructureElement */enum class A {/* NonReanalyzableClassDeclarationStructureElement */
|
||||
X,/* NonReanalyzableNonClassDeclarationStructureElement */
|
||||
Y,/* NonReanalyzableNonClassDeclarationStructureElement */
|
||||
/* RootScriptStructureElement */enum class A {/* ClassDeclarationStructureElement */
|
||||
X,/* DeclarationStructureElement */
|
||||
Y,/* DeclarationStructureElement */
|
||||
Z
|
||||
|
||||
;/* NonReanalyzableNonClassDeclarationStructureElement */
|
||||
;/* DeclarationStructureElement */
|
||||
|
||||
fun foo(){/* ReanalyzableFunctionStructureElement */}
|
||||
fun foo(){/* DeclarationStructureElement */}
|
||||
|
||||
val x = 10/* NonReanalyzableNonClassDeclarationStructureElement */
|
||||
val x = 10/* DeclarationStructureElement */
|
||||
|
||||
fun bar() = 10/* NonReanalyzableNonClassDeclarationStructureElement */
|
||||
fun bar() = 10/* DeclarationStructureElement */
|
||||
}
|
||||
|
||||
@@ -1,13 +1,13 @@
|
||||
enum class A {/* NonReanalyzableClassDeclarationStructureElement */
|
||||
X {/* NonReanalyzableNonClassDeclarationStructureElement */
|
||||
enum class A {/* ClassDeclarationStructureElement */
|
||||
X {/* DeclarationStructureElement */
|
||||
fun localInX() = 1
|
||||
},
|
||||
Y {/* NonReanalyzableNonClassDeclarationStructureElement */
|
||||
Y {/* DeclarationStructureElement */
|
||||
override fun foo() {}
|
||||
},
|
||||
Z,
|
||||
|
||||
;/* NonReanalyzableNonClassDeclarationStructureElement */
|
||||
;/* DeclarationStructureElement */
|
||||
|
||||
open fun foo() {/* ReanalyzableFunctionStructureElement */}
|
||||
open fun foo() {/* DeclarationStructureElement */}
|
||||
}
|
||||
|
||||
+5
-5
@@ -1,13 +1,13 @@
|
||||
/* RootScriptStructureElement */enum class A {/* NonReanalyzableClassDeclarationStructureElement */
|
||||
X {/* NonReanalyzableNonClassDeclarationStructureElement */
|
||||
/* RootScriptStructureElement */enum class A {/* ClassDeclarationStructureElement */
|
||||
X {/* DeclarationStructureElement */
|
||||
fun localInX() = 1
|
||||
},
|
||||
Y {/* NonReanalyzableNonClassDeclarationStructureElement */
|
||||
Y {/* DeclarationStructureElement */
|
||||
override fun foo() {}
|
||||
},
|
||||
Z,
|
||||
|
||||
;/* NonReanalyzableNonClassDeclarationStructureElement */
|
||||
;/* DeclarationStructureElement */
|
||||
|
||||
open fun foo() {/* ReanalyzableFunctionStructureElement */}
|
||||
open fun foo() {/* DeclarationStructureElement */}
|
||||
}
|
||||
|
||||
@@ -1,3 +1,3 @@
|
||||
fun main() {/* ReanalyzableFunctionStructureElement */
|
||||
fun main() {/* DeclarationStructureElement */
|
||||
|
||||
}
|
||||
|
||||
+3
-3
@@ -1,9 +1,9 @@
|
||||
fun bar(a: Int, b: (Boolean) -> Unit) {/* ReanalyzableFunctionStructureElement */
|
||||
fun bar(a: Int, b: (Boolean) -> Unit) {/* DeclarationStructureElement */
|
||||
|
||||
}
|
||||
|
||||
class A {/* NonReanalyzableClassDeclarationStructureElement */
|
||||
fun foo(x: String, y: () -> String) {/* ReanalyzableFunctionStructureElement */
|
||||
class A {/* ClassDeclarationStructureElement */
|
||||
fun foo(x: String, y: () -> String) {/* DeclarationStructureElement */
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
+2
-2
@@ -1,5 +1,5 @@
|
||||
import java.util.Collections
|
||||
|
||||
fun <T> checkSubtype(t: T) = t/* NonReanalyzableNonClassDeclarationStructureElement */
|
||||
fun <T> checkSubtype(t: T) = t/* DeclarationStructureElement */
|
||||
|
||||
val ab = checkSubtype<List<Int>?>(Collections.emptyList<Int>())/* NonReanalyzableNonClassDeclarationStructureElement */
|
||||
val ab = checkSubtype<List<Int>?>(Collections.emptyList<Int>())/* DeclarationStructureElement */
|
||||
|
||||
@@ -1,3 +1,3 @@
|
||||
class A(val x: Int = 10, val b: String)/* NonReanalyzableNonClassDeclarationStructureElement */ {/* NonReanalyzableClassDeclarationStructureElement */
|
||||
class A(val x: Int = 10, val b: String)/* DeclarationStructureElement */ {/* ClassDeclarationStructureElement */
|
||||
|
||||
}
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
class A {/* NonReanalyzableClassDeclarationStructureElement */
|
||||
init {/* NonReanalyzableNonClassDeclarationStructureElement */
|
||||
class A {/* ClassDeclarationStructureElement */
|
||||
init {/* DeclarationStructureElement */
|
||||
val x = 10
|
||||
class B
|
||||
}
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/* RootScriptStructureElement */class A {/* NonReanalyzableClassDeclarationStructureElement */
|
||||
init {/* NonReanalyzableNonClassDeclarationStructureElement */
|
||||
/* RootScriptStructureElement */class A {/* ClassDeclarationStructureElement */
|
||||
init {/* DeclarationStructureElement */
|
||||
val x = 10
|
||||
class B
|
||||
}
|
||||
|
||||
@@ -2,12 +2,12 @@ val x = myRun {
|
||||
val inLambda = 10
|
||||
println(inLambda)
|
||||
inLambda
|
||||
}/* NonReanalyzableNonClassDeclarationStructureElement */
|
||||
}/* DeclarationStructureElement */
|
||||
|
||||
fun println(any: Any) {/* ReanalyzableFunctionStructureElement */
|
||||
fun println(any: Any) {/* DeclarationStructureElement */
|
||||
|
||||
}
|
||||
|
||||
inline fun <R> myRun(block: () -> R): R {/* ReanalyzableFunctionStructureElement */
|
||||
inline fun <R> myRun(block: () -> R): R {/* DeclarationStructureElement */
|
||||
return block()
|
||||
}
|
||||
|
||||
+4
-4
@@ -1,13 +1,13 @@
|
||||
inline fun <T, R> with(receiver: T, block: T.() -> R): R {/* ReanalyzableFunctionStructureElement */
|
||||
inline fun <T, R> with(receiver: T, block: T.() -> R): R {/* DeclarationStructureElement */
|
||||
return receiver.block()
|
||||
}
|
||||
|
||||
inline fun <T, R> T.let(block: (T) -> R): R {/* ReanalyzableFunctionStructureElement */
|
||||
inline fun <T, R> T.let(block: (T) -> R): R {/* DeclarationStructureElement */
|
||||
return block(this)
|
||||
}
|
||||
|
||||
class B {/* NonReanalyzableClassDeclarationStructureElement */
|
||||
class B {/* ClassDeclarationStructureElement */
|
||||
fun foo(a: Int) = with(a) {
|
||||
toString().let { it }
|
||||
}/* NonReanalyzableNonClassDeclarationStructureElement */
|
||||
}/* DeclarationStructureElement */
|
||||
}
|
||||
|
||||
+5
-5
@@ -1,14 +1,14 @@
|
||||
inline fun <T, R> with(receiver: T, block: T.() -> R): R {/* ReanalyzableFunctionStructureElement */
|
||||
inline fun <T, R> with(receiver: T, block: T.() -> R): R {/* DeclarationStructureElement */
|
||||
return receiver.block()
|
||||
}
|
||||
|
||||
inline fun <T, R> T.let(block: (T) -> R): R {/* ReanalyzableFunctionStructureElement */
|
||||
inline fun <T, R> T.let(block: (T) -> R): R {/* DeclarationStructureElement */
|
||||
return block(this)
|
||||
}
|
||||
|
||||
class B {/* NonReanalyzableClassDeclarationStructureElement */
|
||||
val a: Int = 10/* NonReanalyzableNonClassDeclarationStructureElement */
|
||||
class B {/* ClassDeclarationStructureElement */
|
||||
val a: Int = 10/* DeclarationStructureElement */
|
||||
val x = with(a) {
|
||||
toString().let { it }
|
||||
}/* NonReanalyzableNonClassDeclarationStructureElement */
|
||||
}/* DeclarationStructureElement */
|
||||
}
|
||||
|
||||
+4
-4
@@ -1,13 +1,13 @@
|
||||
inline fun <T, R> with(receiver: T, block: T.() -> R): R {/* ReanalyzableFunctionStructureElement */
|
||||
inline fun <T, R> with(receiver: T, block: T.() -> R): R {/* DeclarationStructureElement */
|
||||
return receiver.block()
|
||||
}
|
||||
|
||||
inline fun <T, R> T.let(block: (T) -> R): R {/* ReanalyzableFunctionStructureElement */
|
||||
inline fun <T, R> T.let(block: (T) -> R): R {/* DeclarationStructureElement */
|
||||
return block(this)
|
||||
}
|
||||
|
||||
class A {/* NonReanalyzableClassDeclarationStructureElement */
|
||||
fun foo() {/* ReanalyzableFunctionStructureElement */
|
||||
class A {/* ClassDeclarationStructureElement */
|
||||
fun foo() {/* DeclarationStructureElement */
|
||||
val a = with(1) {
|
||||
this.let { it }
|
||||
}.let { 2 }
|
||||
|
||||
@@ -1,9 +1,9 @@
|
||||
fun a() {/* ReanalyzableFunctionStructureElement */
|
||||
fun a() {/* DeclarationStructureElement */
|
||||
class X
|
||||
}
|
||||
|
||||
class Y {/* NonReanalyzableClassDeclarationStructureElement */
|
||||
fun b() {/* ReanalyzableFunctionStructureElement */
|
||||
class Y {/* ClassDeclarationStructureElement */
|
||||
fun b() {/* DeclarationStructureElement */
|
||||
class Z
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
fun x() {/* ReanalyzableFunctionStructureElement */
|
||||
fun x() {/* DeclarationStructureElement */
|
||||
class Local {
|
||||
fun foo(){}
|
||||
}
|
||||
|
||||
@@ -1,9 +1,9 @@
|
||||
/* RootScriptStructureElement */fun a() {/* ReanalyzableFunctionStructureElement */
|
||||
/* RootScriptStructureElement */fun a() {/* DeclarationStructureElement */
|
||||
class X
|
||||
}
|
||||
|
||||
class Y {/* NonReanalyzableClassDeclarationStructureElement */
|
||||
fun b() {/* ReanalyzableFunctionStructureElement */
|
||||
class Y {/* ClassDeclarationStructureElement */
|
||||
fun b() {/* DeclarationStructureElement */
|
||||
class Z
|
||||
}
|
||||
}
|
||||
|
||||
+3
-3
@@ -1,5 +1,5 @@
|
||||
class Outer {/* NonReanalyzableClassDeclarationStructureElement */
|
||||
val i: Int = 1/* ReanalyzablePropertyStructureElement */
|
||||
class Outer {/* ClassDeclarationStructureElement */
|
||||
val i: Int = 1/* DeclarationStructureElement */
|
||||
get() {
|
||||
class Inner {
|
||||
var i: Int = 2
|
||||
@@ -20,7 +20,7 @@ class Outer {/* NonReanalyzableClassDeclarationStructureElement */
|
||||
return field
|
||||
}
|
||||
|
||||
val j: Int = 4/* ReanalyzablePropertyStructureElement */
|
||||
val j: Int = 4/* DeclarationStructureElement */
|
||||
get() {
|
||||
fun local() {
|
||||
field++
|
||||
|
||||
@@ -1,11 +1,11 @@
|
||||
fun x() {/* ReanalyzableFunctionStructureElement */
|
||||
fun x() {/* DeclarationStructureElement */
|
||||
fun y() {
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
class A {/* NonReanalyzableClassDeclarationStructureElement */
|
||||
fun z() {/* ReanalyzableFunctionStructureElement */
|
||||
class A {/* ClassDeclarationStructureElement */
|
||||
fun z() {/* DeclarationStructureElement */
|
||||
fun q() {
|
||||
|
||||
}
|
||||
|
||||
@@ -1,11 +1,11 @@
|
||||
/* RootScriptStructureElement */fun x() {/* ReanalyzableFunctionStructureElement */
|
||||
/* RootScriptStructureElement */fun x() {/* DeclarationStructureElement */
|
||||
fun y() {
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
class A {/* NonReanalyzableClassDeclarationStructureElement */
|
||||
fun z() {/* ReanalyzableFunctionStructureElement */
|
||||
class A {/* ClassDeclarationStructureElement */
|
||||
fun z() {/* DeclarationStructureElement */
|
||||
fun q() {
|
||||
|
||||
}
|
||||
|
||||
+1
-1
@@ -1,3 +1,3 @@
|
||||
fun foo() {/* ReanalyzableFunctionStructureElement */
|
||||
fun foo() {/* DeclarationStructureElement */
|
||||
fun local() = 0
|
||||
}
|
||||
|
||||
@@ -1,14 +1,14 @@
|
||||
fun foo() {/* ReanalyzableFunctionStructureElement */
|
||||
fun foo() {/* DeclarationStructureElement */
|
||||
var x: Int
|
||||
}
|
||||
class A {/* NonReanalyzableClassDeclarationStructureElement */
|
||||
fun q() {/* ReanalyzableFunctionStructureElement */
|
||||
class A {/* ClassDeclarationStructureElement */
|
||||
fun q() {/* DeclarationStructureElement */
|
||||
val y = 42
|
||||
}
|
||||
}
|
||||
class B {/* NonReanalyzableClassDeclarationStructureElement */
|
||||
class C {/* NonReanalyzableClassDeclarationStructureElement */
|
||||
fun u() {/* ReanalyzableFunctionStructureElement */
|
||||
class B {/* ClassDeclarationStructureElement */
|
||||
class C {/* ClassDeclarationStructureElement */
|
||||
fun u() {/* DeclarationStructureElement */
|
||||
var z: Int = 15
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,14 +1,14 @@
|
||||
/* RootScriptStructureElement */fun foo() {/* ReanalyzableFunctionStructureElement */
|
||||
/* RootScriptStructureElement */fun foo() {/* DeclarationStructureElement */
|
||||
var x: Int
|
||||
}
|
||||
class A {/* NonReanalyzableClassDeclarationStructureElement */
|
||||
fun q() {/* ReanalyzableFunctionStructureElement */
|
||||
class A {/* ClassDeclarationStructureElement */
|
||||
fun q() {/* DeclarationStructureElement */
|
||||
val y = 42
|
||||
}
|
||||
}
|
||||
class B {/* NonReanalyzableClassDeclarationStructureElement */
|
||||
class C {/* NonReanalyzableClassDeclarationStructureElement */
|
||||
fun u() {/* ReanalyzableFunctionStructureElement */
|
||||
class B {/* ClassDeclarationStructureElement */
|
||||
class C {/* ClassDeclarationStructureElement */
|
||||
fun u() {/* DeclarationStructureElement */
|
||||
var z: Int = 15
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
fun foo() {/* ReanalyzableFunctionStructureElement */
|
||||
fun foo() {/* DeclarationStructureElement */
|
||||
fun local() {
|
||||
println("local")
|
||||
}
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
class A {/* NonReanalyzableClassDeclarationStructureElement */
|
||||
fun foo1() = 10/* NonReanalyzableNonClassDeclarationStructureElement */
|
||||
class A {/* ClassDeclarationStructureElement */
|
||||
fun foo1() = 10/* DeclarationStructureElement */
|
||||
|
||||
fun foo2() {/* ReanalyzableFunctionStructureElement */
|
||||
fun foo2() {/* DeclarationStructureElement */
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
class A {/* NonReanalyzableClassDeclarationStructureElement */
|
||||
fun foo1() = 10/* NonReanalyzableNonClassDeclarationStructureElement */
|
||||
class A {/* ClassDeclarationStructureElement */
|
||||
fun foo1() = 10/* DeclarationStructureElement */
|
||||
|
||||
fun foo2() {/* ReanalyzableFunctionStructureElement */
|
||||
fun foo2() {/* DeclarationStructureElement */
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,3 +1,3 @@
|
||||
class A {/* NonReanalyzableClassDeclarationStructureElement */
|
||||
typealias X = Int/* NonReanalyzableNonClassDeclarationStructureElement */
|
||||
class A {/* ClassDeclarationStructureElement */
|
||||
typealias X = Int/* DeclarationStructureElement */
|
||||
}
|
||||
|
||||
+2
-2
@@ -1,3 +1,3 @@
|
||||
/* RootScriptStructureElement */class A {/* NonReanalyzableClassDeclarationStructureElement */
|
||||
typealias X = Int/* NonReanalyzableNonClassDeclarationStructureElement */
|
||||
/* RootScriptStructureElement */class A {/* ClassDeclarationStructureElement */
|
||||
typealias X = Int/* DeclarationStructureElement */
|
||||
}
|
||||
|
||||
+4
-4
@@ -1,15 +1,15 @@
|
||||
class A {/* NonReanalyzableClassDeclarationStructureElement */
|
||||
class A {/* ClassDeclarationStructureElement */
|
||||
|
||||
}
|
||||
|
||||
class B {/* NonReanalyzableClassDeclarationStructureElement */
|
||||
class B {/* ClassDeclarationStructureElement */
|
||||
|
||||
}
|
||||
|
||||
class C {/* NonReanalyzableClassDeclarationStructureElement */
|
||||
class C {/* ClassDeclarationStructureElement */
|
||||
|
||||
}
|
||||
|
||||
class D {/* NonReanalyzableClassDeclarationStructureElement */
|
||||
class D {/* ClassDeclarationStructureElement */
|
||||
|
||||
}
|
||||
|
||||
Vendored
+4
-4
@@ -1,7 +1,7 @@
|
||||
fun foo1() = 1/* NonReanalyzableNonClassDeclarationStructureElement */
|
||||
fun foo1() = 1/* DeclarationStructureElement */
|
||||
|
||||
fun foo2() = 2/* NonReanalyzableNonClassDeclarationStructureElement */
|
||||
fun foo2() = 2/* DeclarationStructureElement */
|
||||
|
||||
fun foo3() = 3/* NonReanalyzableNonClassDeclarationStructureElement */
|
||||
fun foo3() = 3/* DeclarationStructureElement */
|
||||
|
||||
fun foo4() = 4/* NonReanalyzableNonClassDeclarationStructureElement */
|
||||
fun foo4() = 4/* DeclarationStructureElement */
|
||||
|
||||
+4
-4
@@ -1,15 +1,15 @@
|
||||
fun foo1() {/* ReanalyzableFunctionStructureElement */
|
||||
fun foo1() {/* DeclarationStructureElement */
|
||||
println("foo1")
|
||||
}
|
||||
|
||||
fun foo2() {/* ReanalyzableFunctionStructureElement */
|
||||
fun foo2() {/* DeclarationStructureElement */
|
||||
println("foo2")
|
||||
}
|
||||
|
||||
fun foo3() {/* ReanalyzableFunctionStructureElement */
|
||||
fun foo3() {/* DeclarationStructureElement */
|
||||
println("foo3")
|
||||
}
|
||||
|
||||
fun foo4() {/* ReanalyzableFunctionStructureElement */
|
||||
fun foo4() {/* DeclarationStructureElement */
|
||||
println("foo4")
|
||||
}
|
||||
|
||||
@@ -1,10 +1,10 @@
|
||||
class A {/* NonReanalyzableClassDeclarationStructureElement */
|
||||
class B {/* NonReanalyzableClassDeclarationStructureElement */
|
||||
class A {/* ClassDeclarationStructureElement */
|
||||
class B {/* ClassDeclarationStructureElement */
|
||||
|
||||
}
|
||||
|
||||
object C {/* NonReanalyzableClassDeclarationStructureElement */
|
||||
class D {/* NonReanalyzableClassDeclarationStructureElement */
|
||||
object C {/* ClassDeclarationStructureElement */
|
||||
class D {/* ClassDeclarationStructureElement */
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
class A {/* NonReanalyzableClassDeclarationStructureElement */
|
||||
fun y() {/* ReanalyzableFunctionStructureElement */}
|
||||
class A {/* ClassDeclarationStructureElement */
|
||||
fun y() {/* DeclarationStructureElement */}
|
||||
|
||||
class B {/* NonReanalyzableClassDeclarationStructureElement */
|
||||
fun x() {/* ReanalyzableFunctionStructureElement */}
|
||||
class B {/* ClassDeclarationStructureElement */
|
||||
fun x() {/* DeclarationStructureElement */}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,16 +1,16 @@
|
||||
class A {/* NonReanalyzableClassDeclarationStructureElement */
|
||||
class B {/* NonReanalyzableClassDeclarationStructureElement */
|
||||
fun x() {/* ReanalyzableFunctionStructureElement */
|
||||
class A {/* ClassDeclarationStructureElement */
|
||||
class B {/* ClassDeclarationStructureElement */
|
||||
fun x() {/* DeclarationStructureElement */
|
||||
}
|
||||
|
||||
class C {/* NonReanalyzableClassDeclarationStructureElement */
|
||||
class C {/* ClassDeclarationStructureElement */
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
class E {/* NonReanalyzableClassDeclarationStructureElement */
|
||||
class E {/* ClassDeclarationStructureElement */
|
||||
|
||||
}
|
||||
|
||||
fun y(): Int = 10/* ReanalyzableFunctionStructureElement */
|
||||
fun y(): Int = 10/* DeclarationStructureElement */
|
||||
}
|
||||
|
||||
@@ -1,16 +1,16 @@
|
||||
/* RootScriptStructureElement */class A {/* NonReanalyzableClassDeclarationStructureElement */
|
||||
class B {/* NonReanalyzableClassDeclarationStructureElement */
|
||||
fun x() {/* ReanalyzableFunctionStructureElement */
|
||||
/* RootScriptStructureElement */class A {/* ClassDeclarationStructureElement */
|
||||
class B {/* ClassDeclarationStructureElement */
|
||||
fun x() {/* DeclarationStructureElement */
|
||||
}
|
||||
|
||||
class C {/* NonReanalyzableClassDeclarationStructureElement */
|
||||
class C {/* ClassDeclarationStructureElement */
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
class E {/* NonReanalyzableClassDeclarationStructureElement */
|
||||
class E {/* ClassDeclarationStructureElement */
|
||||
|
||||
}
|
||||
|
||||
fun y(): Int = 10/* ReanalyzableFunctionStructureElement */
|
||||
fun y(): Int = 10/* DeclarationStructureElement */
|
||||
}
|
||||
|
||||
@@ -1,11 +1,11 @@
|
||||
var x: Int = 10/* ReanalyzablePropertyStructureElement */
|
||||
var x: Int = 10/* DeclarationStructureElement */
|
||||
get() = field
|
||||
set(value) {
|
||||
field = value
|
||||
}
|
||||
|
||||
class X {/* NonReanalyzableClassDeclarationStructureElement */
|
||||
var y: Int = 10/* ReanalyzablePropertyStructureElement */
|
||||
class X {/* ClassDeclarationStructureElement */
|
||||
var y: Int = 10/* DeclarationStructureElement */
|
||||
get() = field
|
||||
set(value) {
|
||||
field = value
|
||||
|
||||
+3
-3
@@ -1,11 +1,11 @@
|
||||
/* RootScriptStructureElement */var x: Int = 10/* ReanalyzablePropertyStructureElement */
|
||||
/* RootScriptStructureElement */var x: Int = 10/* DeclarationStructureElement */
|
||||
get() = field
|
||||
set(value) {
|
||||
field = value
|
||||
}
|
||||
|
||||
class X {/* NonReanalyzableClassDeclarationStructureElement */
|
||||
var y: Int = 10/* ReanalyzablePropertyStructureElement */
|
||||
class X {/* ClassDeclarationStructureElement */
|
||||
var y: Int = 10/* DeclarationStructureElement */
|
||||
get() = field
|
||||
set(value) {
|
||||
field = value
|
||||
|
||||
+1
-1
@@ -1,4 +1,4 @@
|
||||
var withGetterAndSetter: Int = 42/* ReanalyzablePropertyStructureElement */
|
||||
var withGetterAndSetter: Int = 42/* DeclarationStructureElement */
|
||||
get() = field
|
||||
set(value) {
|
||||
field = value
|
||||
|
||||
@@ -1,14 +1,14 @@
|
||||
abstract class Foo {/* NonReanalyzableClassDeclarationStructureElement */
|
||||
abstract var id: Int/* ReanalyzablePropertyStructureElement */
|
||||
abstract class Foo {/* ClassDeclarationStructureElement */
|
||||
abstract var id: Int/* DeclarationStructureElement */
|
||||
protected set
|
||||
}
|
||||
|
||||
class Bar : Foo() {/* NonReanalyzableClassDeclarationStructureElement */
|
||||
override var id: Int = 1/* ReanalyzablePropertyStructureElement */
|
||||
class Bar : Foo() {/* ClassDeclarationStructureElement */
|
||||
override var id: Int = 1/* DeclarationStructureElement */
|
||||
public set
|
||||
}
|
||||
|
||||
fun test() {/* ReanalyzableFunctionStructureElement */
|
||||
fun test() {/* DeclarationStructureElement */
|
||||
val bar = Bar()
|
||||
bar.id = 1
|
||||
}
|
||||
|
||||
+13
-13
@@ -1,51 +1,51 @@
|
||||
open class A(init: A.() -> Unit)/* NonReanalyzableNonClassDeclarationStructureElement */ {/* NonReanalyzableClassDeclarationStructureElement */
|
||||
val prop: String = ""/* NonReanalyzableNonClassDeclarationStructureElement */
|
||||
open class A(init: A.() -> Unit)/* DeclarationStructureElement */ {/* ClassDeclarationStructureElement */
|
||||
val prop: String = ""/* DeclarationStructureElement */
|
||||
}
|
||||
|
||||
object B : A({})/* NonReanalyzableClassDeclarationStructureElement */
|
||||
object B : A({})/* ClassDeclarationStructureElement */
|
||||
|
||||
object C : A(
|
||||
{
|
||||
fun foo() = B.prop.toString()
|
||||
}
|
||||
)/* NonReanalyzableClassDeclarationStructureElement */
|
||||
)/* ClassDeclarationStructureElement */
|
||||
|
||||
class D : A(
|
||||
{
|
||||
fun foo() = B.prop.toString()
|
||||
}
|
||||
)/* NonReanalyzableClassDeclarationStructureElement */
|
||||
)/* ClassDeclarationStructureElement */
|
||||
|
||||
class E()/* NonReanalyzableNonClassDeclarationStructureElement */ : A(
|
||||
class E()/* DeclarationStructureElement */ : A(
|
||||
{
|
||||
fun foo() = B.prop.toString()
|
||||
}
|
||||
)/* NonReanalyzableClassDeclarationStructureElement */
|
||||
)/* ClassDeclarationStructureElement */
|
||||
|
||||
class F : A(
|
||||
{
|
||||
fun foo() = B.prop.toString()
|
||||
}
|
||||
) {/* NonReanalyzableClassDeclarationStructureElement */
|
||||
constructor()/* NonReanalyzableNonClassDeclarationStructureElement */
|
||||
) {/* ClassDeclarationStructureElement */
|
||||
constructor()/* DeclarationStructureElement */
|
||||
}
|
||||
|
||||
class G : A(
|
||||
{
|
||||
fun foo() = B.prop.toString()
|
||||
}
|
||||
) {/* NonReanalyzableClassDeclarationStructureElement */
|
||||
) {/* ClassDeclarationStructureElement */
|
||||
constructor() : super(
|
||||
{
|
||||
fun foo() = B.prop.toString()
|
||||
}
|
||||
)/* NonReanalyzableNonClassDeclarationStructureElement */
|
||||
)/* DeclarationStructureElement */
|
||||
}
|
||||
|
||||
class H : A {/* NonReanalyzableClassDeclarationStructureElement */
|
||||
class H : A {/* ClassDeclarationStructureElement */
|
||||
constructor() : super(
|
||||
{
|
||||
fun foo() = B.prop.toString()
|
||||
}
|
||||
)/* NonReanalyzableNonClassDeclarationStructureElement */
|
||||
)/* DeclarationStructureElement */
|
||||
}
|
||||
|
||||
@@ -1,13 +1,13 @@
|
||||
/* RootScriptStructureElement */class Builder {/* NonReanalyzableClassDeclarationStructureElement */
|
||||
var version: String = ""/* NonReanalyzableNonClassDeclarationStructureElement */
|
||||
/* RootScriptStructureElement */class Builder {/* ClassDeclarationStructureElement */
|
||||
var version: String = ""/* DeclarationStructureElement */
|
||||
|
||||
fun execute() {/* ReanalyzableFunctionStructureElement */
|
||||
fun execute() {/* DeclarationStructureElement */
|
||||
println(version)
|
||||
}
|
||||
}
|
||||
|
||||
fun build(action: Builder.() -> Unit) = Builder().apply(action)/* NonReanalyzableNonClassDeclarationStructureElement */
|
||||
fun build2(action: Builder.() -> Unit): Builder = Builder().apply(action)/* ReanalyzableFunctionStructureElement */
|
||||
fun build(action: Builder.() -> Unit) = Builder().apply(action)/* DeclarationStructureElement */
|
||||
fun build2(action: Builder.() -> Unit): Builder = Builder().apply(action)/* DeclarationStructureElement */
|
||||
|
||||
build {
|
||||
version = "123"
|
||||
@@ -22,6 +22,6 @@ build {
|
||||
|
||||
val builder = build {
|
||||
version = "321"
|
||||
}/* NonReanalyzableNonClassDeclarationStructureElement */
|
||||
}/* DeclarationStructureElement */
|
||||
|
||||
builder.execute()
|
||||
|
||||
@@ -1,3 +1,3 @@
|
||||
class A(val x: Int = 10, val b: String)/* NonReanalyzableNonClassDeclarationStructureElement */ {/* NonReanalyzableClassDeclarationStructureElement */
|
||||
constructor(i: Int) : this(x = 1, b = i.toString())/* NonReanalyzableNonClassDeclarationStructureElement */
|
||||
class A(val x: Int = 10, val b: String)/* DeclarationStructureElement */ {/* ClassDeclarationStructureElement */
|
||||
constructor(i: Int) : this(x = 1, b = i.toString())/* DeclarationStructureElement */
|
||||
}
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
@Target(AnnotationTarget.TYPE)
|
||||
annotation class Anno/* NonReanalyzableClassDeclarationStructureElement */
|
||||
annotation class Anno/* ClassDeclarationStructureElement */
|
||||
|
||||
open class A/* NonReanalyzableClassDeclarationStructureElement */
|
||||
open class A/* ClassDeclarationStructureElement */
|
||||
|
||||
class B : @Anno A()/* NonReanalyzableClassDeclarationStructureElement */
|
||||
class B : @Anno A()/* ClassDeclarationStructureElement */
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
@Target(AnnotationTarget.TYPE)
|
||||
annotation class Anno/* NonReanalyzableClassDeclarationStructureElement */
|
||||
annotation class Anno/* ClassDeclarationStructureElement */
|
||||
|
||||
interface A/* NonReanalyzableClassDeclarationStructureElement */
|
||||
interface A/* ClassDeclarationStructureElement */
|
||||
|
||||
class B : @Anno A/* NonReanalyzableClassDeclarationStructureElement */
|
||||
class B : @Anno A/* ClassDeclarationStructureElement */
|
||||
|
||||
@@ -1,16 +1,16 @@
|
||||
open class A
|
||||
(init: A.() -> Unit)/* NonReanalyzableNonClassDeclarationStructureElement */
|
||||
{/* NonReanalyzableClassDeclarationStructureElement */
|
||||
val prop: String = ""/* NonReanalyzableNonClassDeclarationStructureElement */
|
||||
(init: A.() -> Unit)/* DeclarationStructureElement */
|
||||
{/* ClassDeclarationStructureElement */
|
||||
val prop: String = ""/* DeclarationStructureElement */
|
||||
}
|
||||
|
||||
class B()/* NonReanalyzableNonClassDeclarationStructureElement */ : A()/* NonReanalyzableClassDeclarationStructureElement */
|
||||
class B()/* DeclarationStructureElement */ : A()/* ClassDeclarationStructureElement */
|
||||
|
||||
object C : A(
|
||||
{
|
||||
fun foo() = B.prop.toString()
|
||||
}
|
||||
) {/* NonReanalyzableClassDeclarationStructureElement */
|
||||
) {/* ClassDeclarationStructureElement */
|
||||
|
||||
}
|
||||
|
||||
@@ -20,16 +20,16 @@ val f = object : A(
|
||||
}
|
||||
) {
|
||||
|
||||
}/* NonReanalyzableNonClassDeclarationStructureElement */
|
||||
}/* DeclarationStructureElement */
|
||||
|
||||
class D : A(
|
||||
{
|
||||
fun foo() = B.prop.toString()
|
||||
}
|
||||
) {/* NonReanalyzableClassDeclarationStructureElement */
|
||||
) {/* ClassDeclarationStructureElement */
|
||||
constructor(): super(
|
||||
{
|
||||
fun boo() = prop.toString()
|
||||
}
|
||||
)/* NonReanalyzableNonClassDeclarationStructureElement */
|
||||
)/* DeclarationStructureElement */
|
||||
}
|
||||
|
||||
@@ -1,16 +1,16 @@
|
||||
/* RootScriptStructureElement */open class A
|
||||
(init: A.() -> Unit)/* NonReanalyzableNonClassDeclarationStructureElement */
|
||||
{/* NonReanalyzableClassDeclarationStructureElement */
|
||||
val prop: String = ""/* NonReanalyzableNonClassDeclarationStructureElement */
|
||||
(init: A.() -> Unit)/* DeclarationStructureElement */
|
||||
{/* ClassDeclarationStructureElement */
|
||||
val prop: String = ""/* DeclarationStructureElement */
|
||||
}
|
||||
|
||||
class B()/* NonReanalyzableNonClassDeclarationStructureElement */ : A()/* NonReanalyzableClassDeclarationStructureElement */
|
||||
class B()/* DeclarationStructureElement */ : A()/* ClassDeclarationStructureElement */
|
||||
|
||||
object C : A(
|
||||
{
|
||||
fun foo() = B.prop.toString()
|
||||
}
|
||||
) {/* NonReanalyzableClassDeclarationStructureElement */
|
||||
) {/* ClassDeclarationStructureElement */
|
||||
|
||||
}
|
||||
|
||||
@@ -20,16 +20,16 @@ val f = object : A(
|
||||
}
|
||||
) {
|
||||
|
||||
}/* NonReanalyzableNonClassDeclarationStructureElement */
|
||||
}/* DeclarationStructureElement */
|
||||
|
||||
class D : A(
|
||||
{
|
||||
fun foo() = B.prop.toString()
|
||||
}
|
||||
) {/* NonReanalyzableClassDeclarationStructureElement */
|
||||
) {/* ClassDeclarationStructureElement */
|
||||
constructor(): super(
|
||||
{
|
||||
fun boo() = prop.toString()
|
||||
}
|
||||
)/* NonReanalyzableNonClassDeclarationStructureElement */
|
||||
)/* DeclarationStructureElement */
|
||||
}
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
interface A<T>/* NonReanalyzableClassDeclarationStructureElement */
|
||||
interface A<T>/* ClassDeclarationStructureElement */
|
||||
|
||||
typealias AS = A<String>/* NonReanalyzableNonClassDeclarationStructureElement */
|
||||
typealias AS = A<String>/* DeclarationStructureElement */
|
||||
|
||||
class C : AS {/* NonReanalyzableClassDeclarationStructureElement */
|
||||
constructor()/* NonReanalyzableNonClassDeclarationStructureElement */
|
||||
class C : AS {/* ClassDeclarationStructureElement */
|
||||
constructor()/* DeclarationStructureElement */
|
||||
}
|
||||
|
||||
+1
-1
@@ -1 +1 @@
|
||||
fun foo(): Int = 42/* ReanalyzableFunctionStructureElement */
|
||||
fun foo(): Int = 42/* DeclarationStructureElement */
|
||||
Vendored
+1
-1
@@ -1 +1 @@
|
||||
/* RootScriptStructureElement */fun foo(): Int = 42/* ReanalyzableFunctionStructureElement */
|
||||
/* RootScriptStructureElement */fun foo(): Int = 42/* DeclarationStructureElement */
|
||||
|
||||
+1
-1
@@ -1 +1 @@
|
||||
fun foo() = 42/* NonReanalyzableNonClassDeclarationStructureElement */
|
||||
fun foo() = 42/* DeclarationStructureElement */
|
||||
|
||||
Vendored
+1
-1
@@ -1 +1 @@
|
||||
/* RootScriptStructureElement */fun foo() = 42/* NonReanalyzableNonClassDeclarationStructureElement */
|
||||
/* RootScriptStructureElement */fun foo() = 42/* DeclarationStructureElement */
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
fun foo(): Int {/* ReanalyzableFunctionStructureElement */
|
||||
fun foo(): Int {/* DeclarationStructureElement */
|
||||
println("")
|
||||
return 10
|
||||
}
|
||||
|
||||
+1
-1
@@ -1,4 +1,4 @@
|
||||
/* RootScriptStructureElement */fun foo(): Int {/* ReanalyzableFunctionStructureElement */
|
||||
/* RootScriptStructureElement */fun foo(): Int {/* DeclarationStructureElement */
|
||||
println("")
|
||||
return 10
|
||||
}
|
||||
|
||||
@@ -1,9 +1,9 @@
|
||||
var x: Int/* ReanalyzablePropertyStructureElement */
|
||||
var x: Int/* DeclarationStructureElement */
|
||||
get() = field
|
||||
set(value) {
|
||||
field = value
|
||||
}
|
||||
|
||||
val y = 42/* NonReanalyzableNonClassDeclarationStructureElement */
|
||||
val y = 42/* DeclarationStructureElement */
|
||||
|
||||
var z: Int = 15/* NonReanalyzableNonClassDeclarationStructureElement */
|
||||
var z: Int = 15/* DeclarationStructureElement */
|
||||
|
||||
+3
-3
@@ -1,9 +1,9 @@
|
||||
/* RootScriptStructureElement */var x: Int/* ReanalyzablePropertyStructureElement */
|
||||
/* RootScriptStructureElement */var x: Int/* DeclarationStructureElement */
|
||||
get() = field
|
||||
set(value) {
|
||||
field = value
|
||||
}
|
||||
|
||||
val y = 42/* NonReanalyzableNonClassDeclarationStructureElement */
|
||||
val y = 42/* DeclarationStructureElement */
|
||||
|
||||
var z: Int = 15/* NonReanalyzableNonClassDeclarationStructureElement */
|
||||
var z: Int = 15/* DeclarationStructureElement */
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
fun foo() {/* ReanalyzableFunctionStructureElement */
|
||||
fun foo() {/* DeclarationStructureElement */
|
||||
println("")
|
||||
}
|
||||
|
||||
|
||||
+1
-1
@@ -1,3 +1,3 @@
|
||||
/* RootScriptStructureElement */fun foo() {/* ReanalyzableFunctionStructureElement */
|
||||
/* RootScriptStructureElement */fun foo() {/* DeclarationStructureElement */
|
||||
println("")
|
||||
}
|
||||
|
||||
@@ -1 +1 @@
|
||||
typealias A = 10/* NonReanalyzableNonClassDeclarationStructureElement */
|
||||
typealias A = 10/* DeclarationStructureElement */
|
||||
|
||||
@@ -1,27 +1,27 @@
|
||||
fun (a: Int = 1): String = "str"/* ReanalyzableFunctionStructureElement */
|
||||
fun (a: Int = 1): String = "str"/* DeclarationStructureElement */
|
||||
|
||||
fun () {/* ReanalyzableFunctionStructureElement */
|
||||
fun () {/* DeclarationStructureElement */
|
||||
|
||||
}
|
||||
|
||||
val : Int = 4/* NonReanalyzableNonClassDeclarationStructureElement */
|
||||
val : Int = 4/* DeclarationStructureElement */
|
||||
|
||||
var : Int/* ReanalyzablePropertyStructureElement */
|
||||
var : Int/* DeclarationStructureElement */
|
||||
get() = 4
|
||||
set(value) {
|
||||
|
||||
}
|
||||
|
||||
class A {/* NonReanalyzableClassDeclarationStructureElement */
|
||||
fun (a: Int = 1): String = "str"/* ReanalyzableFunctionStructureElement */
|
||||
class A {/* ClassDeclarationStructureElement */
|
||||
fun (a: Int = 1): String = "str"/* DeclarationStructureElement */
|
||||
|
||||
fun () {/* ReanalyzableFunctionStructureElement */
|
||||
fun () {/* DeclarationStructureElement */
|
||||
|
||||
}
|
||||
|
||||
val : Int = 4/* NonReanalyzableNonClassDeclarationStructureElement */
|
||||
val : Int = 4/* DeclarationStructureElement */
|
||||
|
||||
var : Boolean/* ReanalyzablePropertyStructureElement */
|
||||
var : Boolean/* DeclarationStructureElement */
|
||||
get() = true
|
||||
set(value) {
|
||||
|
||||
|
||||
@@ -1,27 +1,27 @@
|
||||
/* RootScriptStructureElement */fun (a: Int = 1): String = "str"/* ReanalyzableFunctionStructureElement */
|
||||
/* RootScriptStructureElement */fun (a: Int = 1): String = "str"/* DeclarationStructureElement */
|
||||
|
||||
fun () {/* ReanalyzableFunctionStructureElement */
|
||||
fun () {/* DeclarationStructureElement */
|
||||
|
||||
}
|
||||
|
||||
val : Int = 4/* NonReanalyzableNonClassDeclarationStructureElement */
|
||||
val : Int = 4/* DeclarationStructureElement */
|
||||
|
||||
var : Int/* ReanalyzablePropertyStructureElement */
|
||||
var : Int/* DeclarationStructureElement */
|
||||
get() = 4
|
||||
set(value) {
|
||||
|
||||
}
|
||||
|
||||
class A {/* NonReanalyzableClassDeclarationStructureElement */
|
||||
fun (a: Int = 1): String = "str"/* ReanalyzableFunctionStructureElement */
|
||||
class A {/* ClassDeclarationStructureElement */
|
||||
fun (a: Int = 1): String = "str"/* DeclarationStructureElement */
|
||||
|
||||
fun () {/* ReanalyzableFunctionStructureElement */
|
||||
fun () {/* DeclarationStructureElement */
|
||||
|
||||
}
|
||||
|
||||
val : Int = 4/* NonReanalyzableNonClassDeclarationStructureElement */
|
||||
val : Int = 4/* DeclarationStructureElement */
|
||||
|
||||
var : Boolean/* ReanalyzablePropertyStructureElement */
|
||||
var : Boolean/* DeclarationStructureElement */
|
||||
get() = true
|
||||
set(value) {
|
||||
|
||||
|
||||
+1
-7
@@ -55,19 +55,13 @@ abstract class AbstractFirContextCollectionTest : AbstractLowLevelApiSingleFileT
|
||||
val fileStructure = fileStructureCache.getFileStructure(ktFile)
|
||||
val allStructureElements = fileStructure.getAllStructureElements()
|
||||
|
||||
handler.elementsToCheckContext = allStructureElements.map { it.getFirDeclaration() }
|
||||
handler.elementsToCheckContext = allStructureElements.map(FileStructureElement::firDeclaration)
|
||||
handler.firFile = ktFile.getOrBuildFirFile(firResolveSession)
|
||||
|
||||
ktFile.getDiagnostics(firResolveSession, DiagnosticCheckerFilter.ONLY_COMMON_CHECKERS)
|
||||
}
|
||||
}
|
||||
|
||||
private fun FileStructureElement.getFirDeclaration(): FirDeclaration = when (this) {
|
||||
is RootStructureElement -> firFile
|
||||
is ReanalyzableStructureElement<*, *> -> firSymbol.fir
|
||||
is NonReanalyzableDeclarationStructureElement<*> -> firDeclaration
|
||||
}
|
||||
|
||||
private class BeforeElementLLFirSessionConfigurator(private val testServices: TestServices) : LLFirSessionConfigurator {
|
||||
@OptIn(SessionConfiguration::class)
|
||||
override fun configure(session: LLFirSession) {
|
||||
|
||||
+10
-3
@@ -19,6 +19,8 @@ import org.jetbrains.kotlin.analysis.low.level.api.fir.test.configurators.Analys
|
||||
import org.jetbrains.kotlin.analysis.low.level.api.fir.test.configurators.AnalysisApiFirScriptTestConfigurator
|
||||
import org.jetbrains.kotlin.analysis.low.level.api.fir.test.configurators.AnalysisApiFirSourceTestConfigurator
|
||||
import org.jetbrains.kotlin.analysis.project.structure.ProjectStructureProvider
|
||||
import org.jetbrains.kotlin.fir.declarations.FirDeclaration
|
||||
import org.jetbrains.kotlin.fir.psi
|
||||
import org.jetbrains.kotlin.psi.*
|
||||
import org.jetbrains.kotlin.psi.psiUtil.forEachDescendantOfType
|
||||
import org.jetbrains.kotlin.test.KotlinTestUtils
|
||||
@@ -29,8 +31,7 @@ abstract class AbstractFileStructureTest : AbstractLowLevelApiSingleFileTest() {
|
||||
override fun doTestByFileStructure(ktFile: KtFile, moduleStructure: TestModuleStructure, testServices: TestServices) {
|
||||
val fileStructure = ktFile.getFileStructure()
|
||||
val allStructureElements = fileStructure.getAllStructureElements(ktFile)
|
||||
val declarationToStructureElement = allStructureElements.associateBy { it.psi }
|
||||
|
||||
val declarationToStructureElement = allStructureElements.associateBy { it.firDeclaration.psi }
|
||||
val elementToComment = mutableMapOf<PsiElement, String>()
|
||||
ktFile.forEachDescendantOfType<KtDeclaration> { ktDeclaration ->
|
||||
val structureElement = declarationToStructureElement[ktDeclaration] ?: return@forEachDescendantOfType
|
||||
@@ -76,7 +77,7 @@ abstract class AbstractFileStructureTest : AbstractLowLevelApiSingleFileTest() {
|
||||
|
||||
PsiTreeUtil.getChildrenOfTypeAsList(ktFile, KtModifierList::class.java).forEach {
|
||||
if (it.nextSibling is PsiErrorElement) {
|
||||
val structureElement = declarationToStructureElement[ktFile] ?: return@forEach
|
||||
val structureElement = declarationToStructureElement[it] ?: return@forEach
|
||||
val comment = structureElement.createComment()
|
||||
elementToComment[it] = comment
|
||||
}
|
||||
@@ -120,6 +121,12 @@ abstract class AbstractFileStructureTest : AbstractLowLevelApiSingleFileTest() {
|
||||
}
|
||||
}
|
||||
|
||||
internal val FileStructureElement.firDeclaration: FirDeclaration
|
||||
get() = when (this) {
|
||||
is RootStructureElement -> file
|
||||
is DeclarationBaseStructureElement<*> -> declaration
|
||||
}
|
||||
|
||||
abstract class AbstractSourceFileStructureTest : AbstractFileStructureTest() {
|
||||
override val configurator = AnalysisApiFirSourceTestConfigurator(analyseInDependentSession = false)
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user