KtFile.getPackageFqNameByTree() never tries to access stub (EA-82168)
This commit is contained in:
@@ -126,6 +126,11 @@ public class KtFile extends PsiFileBase implements KtDeclarationContainer, KtAnn
|
|||||||
StubElement<KtPackageDirective> packageDirectiveStub = stub.findChildStubByType(KtStubElementTypes.PACKAGE_DIRECTIVE);
|
StubElement<KtPackageDirective> packageDirectiveStub = stub.findChildStubByType(KtStubElementTypes.PACKAGE_DIRECTIVE);
|
||||||
return packageDirectiveStub != null ? packageDirectiveStub.getPsi() : null;
|
return packageDirectiveStub != null ? packageDirectiveStub.getPsi() : null;
|
||||||
}
|
}
|
||||||
|
return getPackageDirectiveByTree();
|
||||||
|
}
|
||||||
|
|
||||||
|
@Nullable
|
||||||
|
private KtPackageDirective getPackageDirectiveByTree() {
|
||||||
ASTNode ast = getNode().findChildByType(KtNodeTypes.PACKAGE_DIRECTIVE);
|
ASTNode ast = getNode().findChildByType(KtNodeTypes.PACKAGE_DIRECTIVE);
|
||||||
return ast != null ? (KtPackageDirective) ast.getPsi() : null;
|
return ast != null ? (KtPackageDirective) ast.getPsi() : null;
|
||||||
}
|
}
|
||||||
@@ -148,7 +153,7 @@ public class KtFile extends PsiFileBase implements KtDeclarationContainer, KtAnn
|
|||||||
|
|
||||||
@NotNull
|
@NotNull
|
||||||
public FqName getPackageFqNameByTree() {
|
public FqName getPackageFqNameByTree() {
|
||||||
KtPackageDirective packageDirective = getPackageDirective();
|
KtPackageDirective packageDirective = getPackageDirectiveByTree();
|
||||||
if (packageDirective == null) {
|
if (packageDirective == null) {
|
||||||
return FqName.ROOT;
|
return FqName.ROOT;
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user