Workaround copied kotlin element happened to be outside the KtFile
Can be reproduced after revert with IdeLightClassTestGenerated$Local.testDollarsInNameLocal test.
This commit is contained in:
committed by
Nikolay Krasko
parent
5614afed14
commit
83e422fc3b
+6
-3
@@ -35,9 +35,12 @@ open class KtLightClassForLocalDeclaration(
|
|||||||
KotlinClassInnerStuffCache(
|
KotlinClassInnerStuffCache(
|
||||||
this,
|
this,
|
||||||
with(KotlinModificationTrackerService.getInstance(classOrObject.project)) {
|
with(KotlinModificationTrackerService.getInstance(classOrObject.project)) {
|
||||||
listOf(
|
val file = classOrObject.containingFile
|
||||||
outOfBlockModificationTracker, fileModificationTracker(classOrObject.containingKtFile)
|
if (file is KtFile) {
|
||||||
)
|
listOf(outOfBlockModificationTracker, fileModificationTracker(file))
|
||||||
|
} else {
|
||||||
|
listOf(outOfBlockModificationTracker)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|||||||
@@ -67,7 +67,8 @@ public class KtElementImplStub<T extends StubElement<?>> extends StubBasedPsiEle
|
|||||||
@Override
|
@Override
|
||||||
public KtFile getContainingKtFile() {
|
public KtFile getContainingKtFile() {
|
||||||
PsiFile file = getContainingFile();
|
PsiFile file = getContainingFile();
|
||||||
if(!(file instanceof KtFile)) {
|
if (!(file instanceof KtFile)) {
|
||||||
|
// KtElementImpl.copy() might be the reason for this exception
|
||||||
String fileString = file.isValid() ? file.getText() : "";
|
String fileString = file.isValid() ? file.getText() : "";
|
||||||
throw new IllegalStateException("KtElement not inside KtFile: " + file + fileString +
|
throw new IllegalStateException("KtElement not inside KtFile: " + file + fileString +
|
||||||
"for element " + this + " of type " + this.getClass() + " node = " + getNode());
|
"for element " + this + " of type " + this.getClass() + " node = " + getNode());
|
||||||
|
|||||||
Reference in New Issue
Block a user