NotNull annotation for IStubElementType.createStub and its inheritors

This commit is contained in:
Semyon Proshev
2016-07-20 21:16:55 +03:00
parent 3fd146f13a
commit cabe8bb04c
29 changed files with 30 additions and 0 deletions
@@ -67,6 +67,7 @@ public abstract class JavaStubElementType<StubT extends StubElement, PsiT extend
@SuppressWarnings("MethodOverloadsMethodOfSuperclass")
public abstract PsiT createPsi(@NotNull ASTNode node);
@NotNull
@Override
public final StubT createStub(@NotNull final PsiT psi, final StubElement parentStub) {
final String message = "Should not be called. Element=" + psi + "; class" + psi.getClass() + "; file=" + (psi.isValid() ? psi.getContainingFile() : "-");
@@ -34,6 +34,7 @@ public abstract class IStubElementType<StubT extends StubElement, PsiT extends P
public abstract PsiT createPsi(@NotNull StubT stub);
@NotNull
public abstract StubT createStub(@NotNull PsiT psi, final StubElement parentStub);
public boolean shouldCreateStub(ASTNode node) {
@@ -285,6 +285,7 @@ public interface GroovyElementTypes {
return new GrTypeParameterImpl(stub);
}
@NotNull
@Override
public GrTypeParameterStub createStub(@NotNull GrTypeParameter psi, StubElement parentStub) {
return new GrTypeParameterStub(parentStub, StringRef.fromString(psi.getName()));
@@ -341,6 +342,7 @@ public interface GroovyElementTypes {
return new GrParameterImpl(stub);
}
@NotNull
@Override
public GrParameterStub createStub(@NotNull GrParameter psi, StubElement parentStub) {
return new GrParameterStub(parentStub, StringRef.fromString(psi.getName()), GrStubUtils.getAnnotationNames(psi), GrStubUtils.getTypeText(
@@ -38,6 +38,7 @@ public class GrAnnotationElementType extends GrStubElementType<GrAnnotationStub,
return new GrAnnotationImpl(stub);
}
@NotNull
@Override
public GrAnnotationStub createStub(@NotNull GrAnnotation psi, StubElement parentStub) {
return new GrAnnotationStub(parentStub, psi);
@@ -44,6 +44,7 @@ public class GrEnumConstantElementType extends GrStubElementType<GrFieldStub, Gr
return new GrEnumConstantImpl(stub);
}
@NotNull
@Override
public GrFieldStub createStub(@NotNull GrEnumConstant psi, StubElement parentStub) {
String[] annNames = GrStubUtils.getAnnotationNames(psi);
@@ -48,6 +48,7 @@ public class GrFieldElementType extends GrStubElementType<GrFieldStub, GrField>
return new GrFieldImpl(stub);
}
@NotNull
@Override
public GrFieldStub createStub(@NotNull GrField psi, StubElement parentStub) {
String[] annNames = GrStubUtils.getAnnotationNames(psi);
@@ -41,6 +41,7 @@ public class GrImportStatementElementType extends GrStubElementType<GrImportStat
return new GrImportStatementImpl(stub, this);
}
@NotNull
@Override
public GrImportStatementStub createStub(@NotNull GrImportStatement psi, StubElement parentStub) {
GrCodeReferenceElement ref = psi.getImportReference();
@@ -41,6 +41,7 @@ public abstract class GrMethodElementType extends GrStubElementType<GrMethodStub
super(debugName);
}
@NotNull
@Override
public GrMethodStub createStub(@NotNull GrMethod psi, StubElement parentStub) {
@@ -39,6 +39,7 @@ public class GrModifierListElementType extends GrStubElementType<GrModifierListS
return new GrModifierListImpl(stub);
}
@NotNull
@Override
public GrModifierListStub createStub(@NotNull GrModifierList psi, StubElement parentStub) {
return new GrModifierListStub(parentStub, GroovyElementTypes.MODIFIERS, GrModifierListStub.buildFlags(psi));
@@ -38,6 +38,7 @@ public class GrPackageDefinitionElementType extends GrStubElementType<GrPackageD
return new GrPackageDefinitionImpl(stub);
}
@NotNull
@Override
public GrPackageDefinitionStub createStub(@NotNull GrPackageDefinition psi, StubElement parentStub) {
return new GrPackageDefinitionStub(parentStub, GroovyElementTypes.PACKAGE_DEFINITION, StringRef.fromString(psi.getPackageName()));
@@ -42,6 +42,7 @@ public abstract class GrReferenceListElementType<T extends GrReferenceList> exte
super(debugName);
}
@NotNull
@Override
public GrReferenceListStub createStub(@NotNull T psi, StubElement parentStub) {
List<String> refNames = new ArrayList<String>();
@@ -42,6 +42,7 @@ public abstract class GrTypeDefinitionElementType<TypeDef extends GrTypeDefiniti
super(debugName);
}
@NotNull
@Override
public GrTypeDefinitionStub createStub(@NotNull TypeDef psi, StubElement parentStub) {
final byte flags = GrTypeDefinitionStub.buildFlags(psi);
@@ -39,6 +39,7 @@ public class PropertyListStubElementType extends ILightStubElementType<Propertie
return new PropertiesListImpl(stub);
}
@NotNull
public PropertiesListStub createStub(@NotNull final PropertiesList psi, final StubElement parentStub) {
return new PropertiesListStubImpl(parentStub);
}
@@ -44,6 +44,7 @@ public class PropertyStubElementType extends ILightStubElementType<PropertyStub,
return new PropertyImpl(stub, this);
}
@NotNull
public PropertyStub createStub(@NotNull final Property psi, final StubElement parentStub) {
return new PropertyStubImpl(parentStub, psi.getKey());
}
@@ -46,6 +46,7 @@ public class PyAnnotationElementType extends PyStubElementType<PyAnnotationStub,
return new PyAnnotationImpl(stub);
}
@NotNull
public PyAnnotationStub createStub(@NotNull final PyAnnotation psi, final StubElement parentStub) {
return new PyAnnotationStubImpl(parentStub, PyElementTypes.ANNOTATION);
}
@@ -55,6 +55,7 @@ public class PyClassElementType extends PyStubElementType<PyClassStub, PyClass>
return new PyClassImpl(stub);
}
@NotNull
public PyClassStub createStub(@NotNull final PyClass psi, final StubElement parentStub) {
final Map<QualifiedName, QualifiedName> superClasses = getSuperClassQNames(psi);
final PyStringLiteralExpression docStringExpression = psi.getDocStringExpression();
@@ -50,6 +50,7 @@ public class PyDecoratorCallElementType extends PyStubElementType<PyDecoratorStu
return new PyDecoratorImpl(stub);
}
@NotNull
public PyDecoratorStub createStub(@NotNull PyDecorator psi, StubElement parentStub) {
return new PyDecoratorStubImpl(psi.getQualifiedName(), parentStub);
}
@@ -48,6 +48,7 @@ public class PyDecoratorListElementType extends PyStubElementType<PyDecoratorLis
return new PyDecoratorListImpl(stub);
}
@NotNull
public PyDecoratorListStub createStub(@NotNull final PyDecoratorList psi, final StubElement parentStub) {
return new PyDecoratorListStubImpl(parentStub);
}
@@ -47,6 +47,7 @@ public class PyExceptPartElementType extends PyStubElementType<PyExceptPartStub,
return new PyExceptPartImpl(stub);
}
@NotNull
@Override
public PyExceptPartStub createStub(@NotNull PyExceptPart psi, StubElement parentStub) {
return new PyExceptPartStubImpl(parentStub);
@@ -54,6 +54,7 @@ public class PyFromImportStatementElementType extends PyStubElementType<PyFromIm
return new PyFromImportStatementImpl(stub);
}
@NotNull
@Override
public PyFromImportStatementStub createStub(@NotNull PyFromImportStatement psi, StubElement parentStub) {
return new PyFromImportStatementStubImpl(psi.getImportSourceQName(), psi.isStarImport(), psi.getRelativeLevel(), parentStub,
@@ -53,6 +53,7 @@ public class PyFunctionElementType extends PyStubElementType<PyFunctionStub, PyF
return new PyFunctionImpl(stub);
}
@NotNull
public PyFunctionStub createStub(@NotNull final PyFunction psi, final StubElement parentStub) {
PyFunctionImpl function = (PyFunctionImpl)psi;
String message = function.extractDeprecationMessage();
@@ -56,6 +56,7 @@ public class PyImportElementElementType extends PyStubElementType<PyImportElemen
return new PyImportElementImpl(stub);
}
@NotNull
@Override
public PyImportElementStub createStub(@NotNull PyImportElement psi, StubElement parentStub) {
final PyTargetExpression asName = psi.getAsNameElement();
@@ -53,6 +53,7 @@ public class PyImportStatementElementType extends PyStubElementType<PyImportStat
return new PyImportStatementImpl(stub);
}
@NotNull
@Override
public PyImportStatementStub createStub(@NotNull PyImportStatement psi, StubElement parentStub) {
return new PyImportStatementStubImpl(parentStub, getStubElementType());
@@ -52,6 +52,7 @@ public class PyNamedParameterElementType extends PyStubElementType<PyNamedParame
return new PyNamedParameterImpl(stub);
}
@NotNull
public PyNamedParameterStub createStub(@NotNull final PyNamedParameter psi, final StubElement parentStub) {
return new PyNamedParameterStubImpl(psi.getName(), psi.isPositionalContainer(), psi.isKeywordContainer(), psi.hasDefaultValue(),
psi.getTypeCommentAnnotation(), parentStub, getStubElementType());
@@ -47,6 +47,7 @@ public class PyParameterListElementType extends PyStubElementType<PyParameterLis
return new PyParameterListImpl(stub);
}
@NotNull
public PyParameterListStub createStub(@NotNull final PyParameterList psi, final StubElement parentStub) {
return new PyParameterListStubImpl(parentStub, getStubElementType());
}
@@ -47,6 +47,7 @@ public class PySingleStarParameterElementType extends PyStubElementType<PySingle
return new PySingleStarParameterImpl(stub);
}
@NotNull
@Override
public PySingleStarParameterStub createStub(@NotNull PySingleStarParameter psi, StubElement parentStub) {
return new PySingleStarParameterStubImpl(parentStub);
@@ -45,6 +45,7 @@ public class PyStarImportElementElementType extends PyStubElementType<PyStarImpo
return new PyStarImportElementImpl(stub);
}
@NotNull
public PyStarImportElementStub createStub(@NotNull final PyStarImportElement psi, final StubElement parentStub) {
return new PyStarImportElementStubImpl(parentStub);
}
@@ -67,6 +67,7 @@ public class PyTargetExpressionElementType extends PyStubElementType<PyTargetExp
return new PyTargetExpressionImpl(stub);
}
@NotNull
public PyTargetExpressionStub createStub(@NotNull final PyTargetExpression psi, final StubElement parentStub) {
final String name = psi.getName();
final PyExpression assignedValue = psi.findAssignedValue();
@@ -46,6 +46,7 @@ public class PyTupleParameterElementType extends PyStubElementType<PyTupleParame
return new PyTupleParameterImpl(stub);
}
@NotNull
public PyTupleParameterStub createStub(@NotNull PyTupleParameter psi, StubElement parentStub) {
return new PyTupleParameterStubImpl(psi.hasDefaultValue(), parentStub);
}