mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-09-27 10:03:11 +07:00
PY-45206 IJ-CR-3996 More null safety
GitOrigin-RevId: 98a84a10f2b50e76ae416140fecff8d05d42bbe2
This commit is contained in:
committed by
intellij-monorepo-bot
parent
6951cf0f2d
commit
1c353a809a
@@ -220,6 +220,7 @@ public interface PyClass extends PsiNameIdentifierOwner, PyStatement, PyDocStrin
|
||||
* <p/>
|
||||
* This method does not access AST if underlying PSI is stub based.
|
||||
*/
|
||||
@NotNull
|
||||
List<PyTargetExpression> getInstanceAttributes();
|
||||
|
||||
@Nullable
|
||||
|
||||
@@ -64,8 +64,8 @@ public class PyClassImpl extends PyBaseElementImpl<PyClassStub> implements PyCla
|
||||
|
||||
public static final PyClass[] EMPTY_ARRAY = new PyClassImpl[0];
|
||||
|
||||
private volatile List<PyTargetExpression> myInstanceAttributes;
|
||||
private volatile List<PyTargetExpression> myFallbackInstanceAttributes;
|
||||
@Nullable private volatile List<PyTargetExpression> myInstanceAttributes;
|
||||
@Nullable private volatile List<PyTargetExpression> myFallbackInstanceAttributes;
|
||||
|
||||
private volatile Map<String, Property> myLocalPropertyCache;
|
||||
|
||||
@@ -1066,12 +1066,16 @@ public class PyClassImpl extends PyBaseElementImpl<PyClassStub> implements PyCla
|
||||
return processor.getResult();
|
||||
}
|
||||
|
||||
@NotNull
|
||||
@Override
|
||||
public List<PyTargetExpression> getInstanceAttributes() {
|
||||
if (myInstanceAttributes == null) {
|
||||
myInstanceAttributes = collectInstanceAttributes(Collections.emptyMap());
|
||||
List<PyTargetExpression> attributes = myInstanceAttributes;
|
||||
if (attributes != null) {
|
||||
return attributes;
|
||||
}
|
||||
return myInstanceAttributes;
|
||||
attributes = collectInstanceAttributes(Collections.emptyMap());
|
||||
myInstanceAttributes = attributes;
|
||||
return attributes;
|
||||
}
|
||||
|
||||
@Nullable
|
||||
@@ -1094,17 +1098,22 @@ public class PyClassImpl extends PyBaseElementImpl<PyClassStub> implements PyCla
|
||||
return null;
|
||||
}
|
||||
|
||||
@NotNull
|
||||
private List<PyTargetExpression> getFallbackInstanceAttributes() {
|
||||
if (myFallbackInstanceAttributes == null) {
|
||||
Map<String, ScopeOwner> scopesToSkip = StreamEx.of(getInstanceAttributes())
|
||||
.filter(e -> e.getName() != null)
|
||||
.mapToEntry(e -> e.getName(), e -> ScopeUtil.getScopeOwner(e))
|
||||
.toMap();
|
||||
myFallbackInstanceAttributes = collectInstanceAttributes(scopesToSkip);
|
||||
List<PyTargetExpression> attributes = myFallbackInstanceAttributes;
|
||||
if (attributes != null) {
|
||||
return attributes;
|
||||
}
|
||||
return myFallbackInstanceAttributes;
|
||||
Map<String, ScopeOwner> scopesToSkip = StreamEx.of(getInstanceAttributes())
|
||||
.filter(e -> e.getName() != null)
|
||||
.mapToEntry(e -> e.getName(), e -> ScopeUtil.getScopeOwner(e))
|
||||
.toMap();
|
||||
attributes = collectInstanceAttributes(scopesToSkip);
|
||||
myFallbackInstanceAttributes = attributes;
|
||||
return attributes;
|
||||
}
|
||||
|
||||
@NotNull
|
||||
private List<PyTargetExpression> collectInstanceAttributes(Map<String, ScopeOwner> scopesToSkip) {
|
||||
Map<String, PyTargetExpression> result = new HashMap<>();
|
||||
collectAttributesInConstructors(result, scopesToSkip);
|
||||
|
||||
Reference in New Issue
Block a user