mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-09-27 10:03:11 +07:00
[python] cache PyImportElement#getImportReferenceExpression
GitOrigin-RevId: eccbb9acfc6d154c6e21b39128302c40e66107a3
This commit is contained in:
committed by
intellij-monorepo-bot
parent
5849b9860b
commit
e681ef4d52
@@ -3,6 +3,7 @@ package com.jetbrains.python.psi.impl;
|
||||
|
||||
import com.intellij.lang.ASTNode;
|
||||
import com.intellij.navigation.ItemPresentation;
|
||||
import com.intellij.openapi.util.Ref;
|
||||
import com.intellij.openapi.util.text.StringUtil;
|
||||
import com.intellij.psi.PsiElement;
|
||||
import com.intellij.psi.PsiFile;
|
||||
@@ -26,6 +27,8 @@ import java.util.Objects;
|
||||
* The "import foo" or "import foo as bar" parts.
|
||||
*/
|
||||
public class PyImportElementImpl extends PyBaseElementImpl<PyImportElementStub> implements PyImportElement {
|
||||
private volatile @Nullable Ref<PyReferenceExpression> myImportReferenceExpression;
|
||||
|
||||
public PyImportElementImpl(ASTNode astNode) {
|
||||
super(astNode);
|
||||
}
|
||||
@@ -38,6 +41,17 @@ public class PyImportElementImpl extends PyBaseElementImpl<PyImportElementStub>
|
||||
super(stub, nodeType);
|
||||
}
|
||||
|
||||
|
||||
@SuppressWarnings("DataFlowIssue")
|
||||
@Override
|
||||
public @Nullable PyReferenceExpression getImportReferenceExpression() {
|
||||
PyReferenceExpression importReferenceExpression = myImportReferenceExpression == null ? null : myImportReferenceExpression.get();
|
||||
if (myImportReferenceExpression == null || importReferenceExpression != null && !importReferenceExpression.isValid()) {
|
||||
myImportReferenceExpression = new Ref<>(PyImportElement.super.getImportReferenceExpression());
|
||||
}
|
||||
return myImportReferenceExpression.get();
|
||||
}
|
||||
|
||||
@Override
|
||||
public QualifiedName getImportedQName() {
|
||||
final PyImportElementStub stub = getStub();
|
||||
|
||||
Reference in New Issue
Block a user