[FIR] Make check for dangling modifier lists use stubs
Seventh step for ^KT-52615 Merge-request: KT-MR-8651 Merged-by: Egor Kulikov <Egor.Kulikov@jetbrains.com>
This commit is contained in:
@@ -1066,7 +1066,7 @@ open class RawFirBuilder(
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
for (danglingModifierList in PsiTreeUtil.getChildrenOfTypeAsList(file, KtModifierList::class.java)) {
|
for (danglingModifierList in file.danglingModifierLists) {
|
||||||
declarations += buildErrorTopLevelDeclarationForDanglingModifierList(danglingModifierList)
|
declarations += buildErrorTopLevelDeclarationForDanglingModifierList(danglingModifierList)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -1284,7 +1284,7 @@ open class RawFirBuilder(
|
|||||||
)
|
)
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
for (danglingModifier in PsiTreeUtil.getChildrenOfTypeAsList(classOrObject.body, KtModifierList::class.java)) {
|
for (danglingModifier in classOrObject.body?.danglingModifierLists ?: emptyList()) {
|
||||||
addDeclaration(
|
addDeclaration(
|
||||||
buildErrorTopLevelDeclarationForDanglingModifierList(danglingModifier).apply {
|
buildErrorTopLevelDeclarationForDanglingModifierList(danglingModifier).apply {
|
||||||
containingClassAttr = currentDispatchReceiverType()?.lookupTag
|
containingClassAttr = currentDispatchReceiverType()?.lookupTag
|
||||||
@@ -1383,7 +1383,7 @@ open class RawFirBuilder(
|
|||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
for (danglingModifier in PsiTreeUtil.getChildrenOfTypeAsList(objectDeclaration.body, KtModifierList::class.java)) {
|
for (danglingModifier in objectDeclaration.body?.danglingModifierLists ?: emptyList()) {
|
||||||
declarations += buildErrorTopLevelDeclarationForDanglingModifierList(danglingModifier).apply {
|
declarations += buildErrorTopLevelDeclarationForDanglingModifierList(danglingModifier).apply {
|
||||||
containingClassAttr = currentDispatchReceiverType()?.lookupTag
|
containingClassAttr = currentDispatchReceiverType()?.lookupTag
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -69,5 +69,11 @@ class KtClassBody : KtElementImplStub<KotlinPlaceHolderStub<KtClassBody>>, KtDec
|
|||||||
* @return annotations that do not belong to any declaration due to incomplete code or syntax errors
|
* @return annotations that do not belong to any declaration due to incomplete code or syntax errors
|
||||||
*/
|
*/
|
||||||
val danglingAnnotations: List<KtAnnotationEntry>
|
val danglingAnnotations: List<KtAnnotationEntry>
|
||||||
get() = getStubOrPsiChildrenAsList(MODIFIER_LIST).flatMap { it.annotationEntries }
|
get() = danglingModifierLists.flatMap { it.annotationEntries }
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @return modifier lists that do not belong to any declaration due to incomplete code or syntax errors
|
||||||
|
*/
|
||||||
|
val danglingModifierLists: List<KtModifierList>
|
||||||
|
get() = getStubOrPsiChildrenAsList(MODIFIER_LIST)
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -128,18 +128,23 @@ open class KtFile(viewProvider: FileViewProvider, val isCompiled: Boolean) :
|
|||||||
get() = script != null
|
get() = script != null
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @return annotations that do not belong to any declaration due to incomplete code or syntax errors
|
* @return modifier lists that do not belong to any declaration due to incomplete code or syntax errors
|
||||||
*/
|
*/
|
||||||
val danglingAnnotations: List<KtAnnotationEntry>
|
val danglingModifierLists: Array<out KtModifierList>
|
||||||
get() {
|
get() {
|
||||||
val stub = stub
|
val stub = stub
|
||||||
val danglingModifierLists = stub?.getChildrenByType(
|
return stub?.getChildrenByType(
|
||||||
KtStubElementTypes.MODIFIER_LIST,
|
KtStubElementTypes.MODIFIER_LIST,
|
||||||
KtStubElementTypes.MODIFIER_LIST.arrayFactory
|
KtStubElementTypes.MODIFIER_LIST.arrayFactory
|
||||||
) ?: findChildrenByClass(KtModifierList::class.java)
|
) ?: findChildrenByClass(KtModifierList::class.java)
|
||||||
return danglingModifierLists.flatMap { obj: KtModifierList -> obj.annotationEntries }
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @return annotations that do not belong to any declaration due to incomplete code or syntax errors
|
||||||
|
*/
|
||||||
|
val danglingAnnotations: List<KtAnnotationEntry>
|
||||||
|
get() = danglingModifierLists.flatMap { obj: KtModifierList -> obj.annotationEntries }
|
||||||
|
|
||||||
override fun getFileType(): FileType = KotlinFileType.INSTANCE
|
override fun getFileType(): FileType = KotlinFileType.INSTANCE
|
||||||
|
|
||||||
override fun toString(): String = "KtFile: $name"
|
override fun toString(): String = "KtFile: $name"
|
||||||
|
|||||||
Reference in New Issue
Block a user