mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-09-27 10:03:11 +07:00
Remove default value flag from parameter stub and use text instead.
This commit is contained in:
@@ -26,7 +26,6 @@ import org.jetbrains.annotations.Nullable;
|
||||
public interface PyNamedParameterStub extends NamedStub<PyNamedParameter>, PyAnnotationOwnerStub, PyTypeCommentOwnerStub {
|
||||
boolean isPositionalContainer();
|
||||
boolean isKeywordContainer();
|
||||
boolean hasDefaultValue();
|
||||
@Nullable
|
||||
String getDefaultValueText();
|
||||
}
|
||||
@@ -23,7 +23,6 @@ import org.jetbrains.annotations.Nullable;
|
||||
* Tuple parameter stub, collects nested parameters from stubs.
|
||||
*/
|
||||
public interface PyTupleParameterStub extends StubElement<PyTupleParameter> {
|
||||
boolean hasDefaultValue();
|
||||
@Nullable
|
||||
String getDefaultValueText();
|
||||
}
|
||||
|
||||
@@ -62,7 +62,7 @@ public class PyFileElementType extends IStubFileElementType<PyFileStub> {
|
||||
@Override
|
||||
public int getStubVersion() {
|
||||
// Don't forget to update versions of indexes that use the updated stub-based elements
|
||||
return 63;
|
||||
return 64;
|
||||
}
|
||||
|
||||
@Nullable
|
||||
|
||||
@@ -155,10 +155,10 @@ public class PyNamedParameterImpl extends PyBaseElementImpl<PyNamedParameterStub
|
||||
@Nullable
|
||||
public PyExpression getDefaultValue() {
|
||||
final PyNamedParameterStub stub = getStub();
|
||||
if (stub != null && !stub.hasDefaultValue()) {
|
||||
if (stub != null && stub.getDefaultValueText() == null) {
|
||||
return null;
|
||||
}
|
||||
ASTNode[] nodes = getNode().getChildren(PythonDialectsTokenSetProvider.INSTANCE.getExpressionTokens());
|
||||
final ASTNode[] nodes = getNode().getChildren(PythonDialectsTokenSetProvider.INSTANCE.getExpressionTokens());
|
||||
if (nodes.length > 0) {
|
||||
return (PyExpression)nodes[0].getPsi();
|
||||
}
|
||||
@@ -169,7 +169,7 @@ public class PyNamedParameterImpl extends PyBaseElementImpl<PyNamedParameterStub
|
||||
public boolean hasDefaultValue() {
|
||||
final PyNamedParameterStub stub = getStub();
|
||||
if (stub != null) {
|
||||
return stub.hasDefaultValue();
|
||||
return stub.getDefaultValueText() != null;
|
||||
}
|
||||
return getDefaultValue() != null;
|
||||
}
|
||||
|
||||
@@ -63,7 +63,7 @@ public class PyTupleParameterImpl extends PyBaseElementImpl<PyTupleParameterStub
|
||||
public boolean hasDefaultValue() {
|
||||
final PyTupleParameterStub stub = getStub();
|
||||
if (stub != null) {
|
||||
return stub.hasDefaultValue();
|
||||
return stub.getDefaultValueText() != null;
|
||||
}
|
||||
return getDefaultValue() != null;
|
||||
}
|
||||
|
||||
@@ -39,7 +39,6 @@ import java.io.IOException;
|
||||
public class PyNamedParameterElementType extends PyStubElementType<PyNamedParameterStub, PyNamedParameter> {
|
||||
private static final int POSITIONAL_CONTAINER = 1;
|
||||
private static final int KEYWORD_CONTAINER = 2;
|
||||
private static final int HAS_DEFAULT_VALUE = 4;
|
||||
|
||||
public PyNamedParameterElementType() {
|
||||
this("NAMED_PARAMETER");
|
||||
@@ -58,9 +57,8 @@ public class PyNamedParameterElementType extends PyStubElementType<PyNamedParame
|
||||
@Override
|
||||
@NotNull
|
||||
public PyNamedParameterStub createStub(@NotNull final PyNamedParameter psi, final StubElement parentStub) {
|
||||
return new PyNamedParameterStubImpl(psi.getName(), psi.isPositionalContainer(), psi.isKeywordContainer(), psi.hasDefaultValue(),
|
||||
psi.getDefaultValueText(), psi.getTypeCommentAnnotation(), psi.getAnnotationValue() , parentStub,
|
||||
getStubElementType());
|
||||
return new PyNamedParameterStubImpl(psi.getName(), psi.isPositionalContainer(), psi.isKeywordContainer(), psi.getDefaultValueText(),
|
||||
psi.getTypeCommentAnnotation(), psi.getAnnotationValue(), parentStub, getStubElementType());
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -77,7 +75,6 @@ public class PyNamedParameterElementType extends PyStubElementType<PyNamedParame
|
||||
byte flags = 0;
|
||||
if (stub.isPositionalContainer()) flags |= POSITIONAL_CONTAINER;
|
||||
if (stub.isKeywordContainer()) flags |= KEYWORD_CONTAINER;
|
||||
if (stub.hasDefaultValue()) flags |= HAS_DEFAULT_VALUE;
|
||||
dataStream.writeByte(flags);
|
||||
dataStream.writeName(stub.getDefaultValueText());
|
||||
dataStream.writeName(stub.getTypeComment());
|
||||
@@ -95,7 +92,6 @@ public class PyNamedParameterElementType extends PyStubElementType<PyNamedParame
|
||||
return new PyNamedParameterStubImpl(name,
|
||||
(flags & POSITIONAL_CONTAINER) != 0,
|
||||
(flags & KEYWORD_CONTAINER) != 0,
|
||||
(flags & HAS_DEFAULT_VALUE) != 0,
|
||||
defaultValueText == null ? null : defaultValueText.getString(),
|
||||
typeComment == null ? null : typeComment.getString(),
|
||||
annotation == null ? null : annotation.getString(),
|
||||
|
||||
@@ -30,7 +30,6 @@ public class PyNamedParameterStubImpl extends StubBase<PyNamedParameter> impleme
|
||||
private final String myName;
|
||||
private final boolean myPositionalContainer;
|
||||
private final boolean myKeywordContainer;
|
||||
private final boolean myHasDefaultValue;
|
||||
private final String myTypeCommentAnnotation;
|
||||
private final String myAnnotation;
|
||||
@Nullable
|
||||
@@ -39,7 +38,6 @@ public class PyNamedParameterStubImpl extends StubBase<PyNamedParameter> impleme
|
||||
public PyNamedParameterStubImpl(String name,
|
||||
boolean isPositionalContainer,
|
||||
boolean isKeywordContainer,
|
||||
boolean hasDefaultValue,
|
||||
@Nullable String defaultValueText,
|
||||
@Nullable String typeCommentAnnotation,
|
||||
@Nullable String annotation,
|
||||
@@ -49,7 +47,6 @@ public class PyNamedParameterStubImpl extends StubBase<PyNamedParameter> impleme
|
||||
myName = name;
|
||||
myPositionalContainer = isPositionalContainer;
|
||||
myKeywordContainer = isKeywordContainer;
|
||||
myHasDefaultValue = hasDefaultValue;
|
||||
myTypeCommentAnnotation = typeCommentAnnotation;
|
||||
myAnnotation = annotation;
|
||||
myDefaultValueText = defaultValueText;
|
||||
@@ -65,11 +62,6 @@ public class PyNamedParameterStubImpl extends StubBase<PyNamedParameter> impleme
|
||||
return myKeywordContainer;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean hasDefaultValue() {
|
||||
return myHasDefaultValue;
|
||||
}
|
||||
|
||||
@Nullable
|
||||
@Override
|
||||
public String getDefaultValueText() {
|
||||
|
||||
@@ -52,20 +52,18 @@ public class PyTupleParameterElementType extends PyStubElementType<PyTupleParame
|
||||
@Override
|
||||
@NotNull
|
||||
public PyTupleParameterStub createStub(@NotNull PyTupleParameter psi, StubElement parentStub) {
|
||||
return new PyTupleParameterStubImpl(psi.hasDefaultValue(), psi.getDefaultValueText(), parentStub);
|
||||
return new PyTupleParameterStubImpl(psi.getDefaultValueText(), parentStub);
|
||||
}
|
||||
|
||||
@Override
|
||||
@NotNull
|
||||
public PyTupleParameterStub deserialize(@NotNull StubInputStream dataStream, StubElement parentStub) throws IOException {
|
||||
final boolean hasDefaultValue = dataStream.readBoolean();
|
||||
final StringRef defaultValueText = dataStream.readName();
|
||||
return new PyTupleParameterStubImpl(hasDefaultValue, defaultValueText == null ? null : defaultValueText.getString(), parentStub);
|
||||
return new PyTupleParameterStubImpl(defaultValueText == null ? null : defaultValueText.getString(), parentStub);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void serialize(@NotNull PyTupleParameterStub stub, @NotNull StubOutputStream dataStream) throws IOException {
|
||||
dataStream.writeBoolean(stub.hasDefaultValue());
|
||||
dataStream.writeName(stub.getDefaultValueText());
|
||||
}
|
||||
}
|
||||
|
||||
@@ -28,21 +28,14 @@ import org.jetbrains.annotations.Nullable;
|
||||
* Date: Jul 6, 2009 1:33:08 AM
|
||||
*/
|
||||
public class PyTupleParameterStubImpl extends StubBase<PyTupleParameter> implements PyTupleParameterStub {
|
||||
private final boolean myHasDefaultValue;
|
||||
@Nullable
|
||||
private final String myDefaultValueText;
|
||||
|
||||
protected PyTupleParameterStubImpl(boolean hasDefaultValue, @Nullable String defaultValueText, StubElement parent) {
|
||||
protected PyTupleParameterStubImpl(@Nullable String defaultValueText, StubElement parent) {
|
||||
super(parent, PyElementTypes.TUPLE_PARAMETER);
|
||||
myHasDefaultValue = hasDefaultValue;
|
||||
myDefaultValueText = defaultValueText;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean hasDefaultValue() {
|
||||
return myHasDefaultValue;
|
||||
}
|
||||
|
||||
@Nullable
|
||||
@Override
|
||||
public String getDefaultValueText() {
|
||||
|
||||
Reference in New Issue
Block a user