This commit is contained in:
Alexey Kudravtsev
2013-04-18 13:10:56 +04:00
parent fb3b8387d9
commit eb3aa615c5
17 changed files with 53 additions and 34 deletions
@@ -24,9 +24,10 @@ public abstract class PyStubElementType<StubT extends StubElement, PsiT extends
public abstract PsiElement createElement(@NotNull final ASTNode node);
public void indexStub(final StubT stub, final IndexSink sink) {
public void indexStub(@NotNull final StubT stub, @NotNull final IndexSink sink) {
}
@NotNull
public String getExternalId() {
return "py." + super.toString();
}
@@ -2,6 +2,7 @@ package com.jetbrains.python.documentation.doctest;
import com.intellij.lang.Language;
import com.jetbrains.python.psi.PyFileElementType;
import org.jetbrains.annotations.NotNull;
/**
* User : ktisha
@@ -11,6 +12,7 @@ public class PyDocstringFileElementType extends PyFileElementType {
super(language);
}
@NotNull
@Override
public String getExternalId() {
return "PyDocstring.FILE";
@@ -128,20 +128,22 @@ public class PyFileElementType extends IStubFileElementType<PyFileStub> {
return ((PyFile)file).getLanguageLevel();
}
@NotNull
@Override
public String getExternalId() {
return "python.FILE";
}
@Override
public void serialize(PyFileStub stub, StubOutputStream dataStream) throws IOException {
public void serialize(@NotNull PyFileStub stub, @NotNull StubOutputStream dataStream) throws IOException {
writeNullableList(dataStream, stub.getDunderAll());
writeBitSet(dataStream, stub.getFutureFeatures());
dataStream.writeName(stub.getDeprecationMessage());
}
@NotNull
@Override
public PyFileStub deserialize(StubInputStream dataStream, StubElement parentStub) throws IOException {
public PyFileStub deserialize(@NotNull StubInputStream dataStream, StubElement parentStub) throws IOException {
List<String> all = readNullableList(dataStream);
BitSet future_features = readBitSet(dataStream);
StringRef deprecationMessage = dataStream.readName();
@@ -38,11 +38,12 @@ public class PyAnnotationElementType extends PyStubElementType<PyAnnotationStub,
return new PyAnnotationImpl(node);
}
public void serialize(final PyAnnotationStub stub, final StubOutputStream dataStream)
public void serialize(@NotNull final PyAnnotationStub stub, @NotNull final StubOutputStream dataStream)
throws IOException {
}
public PyAnnotationStub deserialize(final StubInputStream dataStream, final StubElement parentStub)
@NotNull
public PyAnnotationStub deserialize(@NotNull final StubInputStream dataStream, final StubElement parentStub)
throws IOException {
return new PyAnnotationStubImpl(parentStub, PyElementTypes.ANNOTATION);
}
@@ -54,7 +54,7 @@ public class PyClassElementType extends PyStubElementType<PyClassStub, PyClass>
getStubElementType());
}
public void serialize(final PyClassStub pyClassStub, final StubOutputStream dataStream) throws IOException {
public void serialize(@NotNull final PyClassStub pyClassStub, @NotNull final StubOutputStream dataStream) throws IOException {
dataStream.writeName(pyClassStub.getName());
final PyQualifiedName[] classes = pyClassStub.getSuperClasses();
dataStream.writeByte(classes.length);
@@ -66,7 +66,8 @@ public class PyClassElementType extends PyStubElementType<PyClassStub, PyClass>
dataStream.writeUTFFast(docString != null ? docString : "");
}
public PyClassStub deserialize(final StubInputStream dataStream, final StubElement parentStub) throws IOException {
@NotNull
public PyClassStub deserialize(@NotNull final StubInputStream dataStream, final StubElement parentStub) throws IOException {
String name = StringRef.toString(dataStream.readName());
int superClassCount = dataStream.readByte();
PyQualifiedName[] superClasses = new PyQualifiedName[superClassCount];
@@ -78,7 +79,7 @@ public class PyClassElementType extends PyStubElementType<PyClassStub, PyClass>
return new PyClassStubImpl(name, parentStub, superClasses, slots, docString.length() > 0 ? docString : null, getStubElementType());
}
public void indexStub(final PyClassStub stub, final IndexSink sink) {
public void indexStub(@NotNull final PyClassStub stub, @NotNull final IndexSink sink) {
final String name = stub.getName();
if (name != null) {
sink.occurrence(PyClassNameIndex.KEY, name);
@@ -36,11 +36,12 @@ public class PyDecoratorCallElementType extends PyStubElementType<PyDecoratorStu
return new PyDecoratorStubImpl(psi.getQualifiedName(), parentStub);
}
public void serialize(PyDecoratorStub stub, StubOutputStream dataStream) throws IOException {
public void serialize(@NotNull PyDecoratorStub stub, @NotNull StubOutputStream dataStream) throws IOException {
PyQualifiedName.serialize(stub.getQualifiedName(), dataStream);
}
public PyDecoratorStub deserialize(StubInputStream dataStream, StubElement parentStub) throws IOException {
@NotNull
public PyDecoratorStub deserialize(@NotNull StubInputStream dataStream, StubElement parentStub) throws IOException {
PyQualifiedName q_name = PyQualifiedName.deserialize(dataStream);
return new PyDecoratorStubImpl(q_name, parentStub);
}
@@ -36,11 +36,12 @@ public class PyDecoratorListElementType extends PyStubElementType<PyDecoratorLis
return new PyDecoratorListStubImpl(parentStub);
}
public void serialize(final PyDecoratorListStub stub, final StubOutputStream dataStream) throws IOException {
public void serialize(@NotNull final PyDecoratorListStub stub, @NotNull final StubOutputStream dataStream) throws IOException {
// nothing
}
public PyDecoratorListStub deserialize(final StubInputStream dataStream, final StubElement parentStub) throws IOException {
@NotNull
public PyDecoratorListStub deserialize(@NotNull final StubInputStream dataStream, final StubElement parentStub) throws IOException {
return new PyDecoratorListStubImpl(parentStub);
}
}
@@ -37,11 +37,12 @@ public class PyExceptPartElementType extends PyStubElementType<PyExceptPartStub,
}
@Override
public void serialize(PyExceptPartStub stub, StubOutputStream dataStream) throws IOException {
public void serialize(@NotNull PyExceptPartStub stub, @NotNull StubOutputStream dataStream) throws IOException {
}
@NotNull
@Override
public PyExceptPartStub deserialize(StubInputStream dataStream, StubElement parentStub) throws IOException {
public PyExceptPartStub deserialize(@NotNull StubInputStream dataStream, StubElement parentStub) throws IOException {
return new PyExceptPartStubImpl(parentStub);
}
}
@@ -44,14 +44,15 @@ public class PyFromImportStatementElementType extends PyStubElementType<PyFromIm
getStubElementType());
}
public void serialize(PyFromImportStatementStub stub, StubOutputStream dataStream) throws IOException {
public void serialize(@NotNull PyFromImportStatementStub stub, @NotNull StubOutputStream dataStream) throws IOException {
final PyQualifiedName qName = stub.getImportSourceQName();
PyQualifiedName.serialize(qName, dataStream);
dataStream.writeBoolean(stub.isStarImport());
dataStream.writeVarInt(stub.getRelativeLevel());
}
public PyFromImportStatementStub deserialize(StubInputStream dataStream, StubElement parentStub) throws IOException {
@NotNull
public PyFromImportStatementStub deserialize(@NotNull StubInputStream dataStream, StubElement parentStub) throws IOException {
PyQualifiedName qName = PyQualifiedName.deserialize(dataStream);
boolean isStarImport = dataStream.readBoolean();
int relativeLevel = dataStream.readVarInt();
@@ -44,21 +44,22 @@ public class PyFunctionElementType extends PyStubElementType<PyFunctionStub, PyF
message == null ? null : StringRef.fromString(message), parentStub, getStubElementType());
}
public void serialize(final PyFunctionStub stub, final StubOutputStream dataStream)
public void serialize(@NotNull final PyFunctionStub stub, @NotNull final StubOutputStream dataStream)
throws IOException {
dataStream.writeName(stub.getName());
dataStream.writeUTFFast(stub.getDocString() != null ? stub.getDocString() : "");
dataStream.writeName(stub.getDeprecationMessage());
}
public PyFunctionStub deserialize(final StubInputStream dataStream, final StubElement parentStub) throws IOException {
@NotNull
public PyFunctionStub deserialize(@NotNull final StubInputStream dataStream, final StubElement parentStub) throws IOException {
String name = StringRef.toString(dataStream.readName());
String docString = dataStream.readUTFFast();
StringRef deprecationMessage = dataStream.readName();
return new PyFunctionStubImpl(name, docString.length() > 0 ? docString : null, deprecationMessage, parentStub, getStubElementType());
}
public void indexStub(final PyFunctionStub stub, final IndexSink sink) {
public void indexStub(@NotNull final PyFunctionStub stub, @NotNull final IndexSink sink) {
final String name = stub.getName();
if (name != null) {
sink.occurrence(PyFunctionNameIndex.KEY, name);
@@ -46,12 +46,13 @@ public class PyImportElementElementType extends PyStubElementType<PyImportElemen
return new PyImportElementStubImpl(psi.getImportedQName(), asName != null ? asName.getName() : "", parentStub, getStubElementType());
}
public void serialize(PyImportElementStub stub, StubOutputStream dataStream) throws IOException {
public void serialize(@NotNull PyImportElementStub stub, @NotNull StubOutputStream dataStream) throws IOException {
PyQualifiedName.serialize(stub.getImportedQName(), dataStream);
dataStream.writeName(stub.getAsName());
}
public PyImportElementStub deserialize(StubInputStream dataStream, StubElement parentStub) throws IOException {
@NotNull
public PyImportElementStub deserialize(@NotNull StubInputStream dataStream, StubElement parentStub) throws IOException {
PyQualifiedName qName = PyQualifiedName.deserialize(dataStream);
StringRef asName = dataStream.readName();
return new PyImportElementStubImpl(qName, asName.getString(), parentStub, getStubElementType());
@@ -42,10 +42,11 @@ public class PyImportStatementElementType extends PyStubElementType<PyImportStat
return new PyImportStatementStubImpl(parentStub, getStubElementType());
}
public void serialize(PyImportStatementStub stub, StubOutputStream dataStream) throws IOException {
public void serialize(@NotNull PyImportStatementStub stub, @NotNull StubOutputStream dataStream) throws IOException {
}
public PyImportStatementStub deserialize(StubInputStream dataStream, StubElement parentStub) throws IOException {
@NotNull
public PyImportStatementStub deserialize(@NotNull StubInputStream dataStream, StubElement parentStub) throws IOException {
return new PyImportStatementStubImpl(parentStub, getStubElementType());
}
@@ -45,7 +45,7 @@ public class PyNamedParameterElementType extends PyStubElementType<PyNamedParame
return new PyNamedParameterImpl(node);
}
public void serialize(final PyNamedParameterStub stub, final StubOutputStream dataStream)
public void serialize(@NotNull final PyNamedParameterStub stub, @NotNull final StubOutputStream dataStream)
throws IOException {
dataStream.writeName(stub.getName());
@@ -56,7 +56,8 @@ public class PyNamedParameterElementType extends PyStubElementType<PyNamedParame
dataStream.writeByte(flags);
}
public PyNamedParameterStub deserialize(final StubInputStream dataStream, final StubElement parentStub) throws IOException {
@NotNull
public PyNamedParameterStub deserialize(@NotNull final StubInputStream dataStream, final StubElement parentStub) throws IOException {
String name = StringRef.toString(dataStream.readName());
byte flags = dataStream.readByte();
return new PyNamedParameterStubImpl(name,
@@ -39,11 +39,12 @@ public class PyParameterListElementType extends PyStubElementType<PyParameterLis
return new PyParameterListImpl(node);
}
public void serialize(final PyParameterListStub stub, final StubOutputStream dataStream)
public void serialize(@NotNull final PyParameterListStub stub, @NotNull final StubOutputStream dataStream)
throws IOException {
}
public PyParameterListStub deserialize(final StubInputStream dataStream, final StubElement parentStub)
@NotNull
public PyParameterListStub deserialize(@NotNull final StubInputStream dataStream, final StubElement parentStub)
throws IOException {
return new PyParameterListStubImpl(parentStub, getStubElementType());
}
@@ -36,10 +36,11 @@ public class PySingleStarParameterElementType extends PyStubElementType<PySingle
return new PySingleStarParameterStubImpl(parentStub);
}
public void serialize(PySingleStarParameterStub stub, StubOutputStream dataStream) throws IOException {
public void serialize(@NotNull PySingleStarParameterStub stub, @NotNull StubOutputStream dataStream) throws IOException {
}
public PySingleStarParameterStub deserialize(StubInputStream dataStream, StubElement parentStub) throws IOException {
@NotNull
public PySingleStarParameterStub deserialize(@NotNull StubInputStream dataStream, StubElement parentStub) throws IOException {
return new PySingleStarParameterStubImpl(parentStub);
}
}
@@ -70,7 +70,7 @@ public class PyTargetExpressionElementType extends PyStubElementType<PyTargetExp
return new PyTargetExpressionStubImpl(name, initializerType, initializer, psi.getQualifier() != null, parentStub);
}
public void serialize(final PyTargetExpressionStub stub, final StubOutputStream stream)
public void serialize(@NotNull final PyTargetExpressionStub stub, @NotNull final StubOutputStream stream)
throws IOException {
stream.writeName(stub.getName());
stream.writeVarInt(stub.getInitializerType().getIndex());
@@ -85,7 +85,8 @@ public class PyTargetExpressionElementType extends PyStubElementType<PyTargetExp
}
}
public PyTargetExpressionStub deserialize(final StubInputStream stream, final StubElement parentStub)
@NotNull
public PyTargetExpressionStub deserialize(@NotNull final StubInputStream stream, final StubElement parentStub)
throws IOException {
String name = StringRef.toString(stream.readName());
PyTargetExpressionStub.InitializerType initializerType = PyTargetExpressionStub.InitializerType.fromIndex(stream.readVarInt());
@@ -126,7 +127,7 @@ public class PyTargetExpressionElementType extends PyStubElementType<PyTargetExp
}
@Override
public void indexStub(PyTargetExpressionStub stub, IndexSink sink) {
public void indexStub(@NotNull PyTargetExpressionStub stub, @NotNull IndexSink sink) {
String name = stub.getName();
if (name != null && PyUtil.getInitialUnderscores(name) == 0) {
if (stub.getParentStub() instanceof PyFileStub) {
@@ -34,12 +34,13 @@ public class PyTupleParameterElementType extends PyStubElementType<PyTupleParame
return new PyTupleParameterStubImpl(psi.hasDefaultValue(), parentStub);
}
public PyTupleParameterStub deserialize(StubInputStream dataStream, StubElement parentStub) throws IOException {
@NotNull
public PyTupleParameterStub deserialize(@NotNull StubInputStream dataStream, StubElement parentStub) throws IOException {
boolean hasDefaultValue = dataStream.readBoolean();
return new PyTupleParameterStubImpl(hasDefaultValue, parentStub);
}
public void serialize(PyTupleParameterStub stub, StubOutputStream dataStream) throws IOException {
public void serialize(@NotNull PyTupleParameterStub stub, @NotNull StubOutputStream dataStream) throws IOException {
dataStream.writeBoolean(stub.hasDefaultValue());
}
}