2525import javax .annotation .Nonnull ;
2626import javax .annotation .Nullable ;
2727import org .sonar .plugins .python .api .LocationInFile ;
28+ import org .sonar .plugins .python .api .types .v2 .GenericInfo ;
2829
2930public class ClassDescriptor implements Descriptor {
3031
@@ -40,12 +41,13 @@ public class ClassDescriptor implements Descriptor {
4041 private final boolean hasMetaClass ;
4142 private final String metaclassFQN ;
4243 private final List <Descriptor > metaClasses ;
43- private final boolean supportsGenerics ;
44+ private final GenericInfo genericInfo ;
4445 private final boolean isSelf ;
4546
4647 private ClassDescriptor (String name , String fullyQualifiedName , Collection <String > superClasses , Set <Descriptor > members ,
4748 List <Descriptor > attributes , boolean hasDecorators , @ Nullable LocationInFile definitionLocation , boolean hasSuperClassWithoutDescriptor ,
48- boolean hasMetaClass , @ Nullable String metaclassFQN , List <Descriptor > metaClasses , boolean supportsGenerics , boolean isSelf , List <DecoratorDescriptor > decorators ) {
49+ boolean hasMetaClass , @ Nullable String metaclassFQN , List <Descriptor > metaClasses , GenericInfo genericInfo , boolean isSelf ,
50+ List <DecoratorDescriptor > decorators ) {
4951
5052 this .name = name ;
5153 this .fullyQualifiedName = fullyQualifiedName ;
@@ -59,7 +61,7 @@ private ClassDescriptor(String name, String fullyQualifiedName, Collection<Strin
5961 this .hasMetaClass = hasMetaClass ;
6062 this .metaclassFQN = metaclassFQN ;
6163 this .metaClasses = metaClasses ;
62- this .supportsGenerics = supportsGenerics ;
64+ this .genericInfo = genericInfo ;
6365 this .isSelf = isSelf ;
6466 }
6567
@@ -123,7 +125,11 @@ public List<Descriptor> metaClasses() {
123125 }
124126
125127 public boolean supportsGenerics () {
126- return supportsGenerics ;
128+ return genericInfo .isGeneric ();
129+ }
130+
131+ public GenericInfo genericInfo () {
132+ return genericInfo ;
127133 }
128134
129135 public boolean isSelf () {
@@ -144,7 +150,7 @@ public static class ClassDescriptorBuilder {
144150 private boolean hasMetaClass = false ;
145151 private String metaclassFQN = null ;
146152 private List <Descriptor > metaClasses = new ArrayList <>();
147- private boolean supportsGenerics = false ;
153+ private GenericInfo genericInfo = GenericInfo . UNKNOWN ;
148154 private boolean isSelf = false ;
149155
150156 public ClassDescriptorBuilder withName (String name ) {
@@ -207,8 +213,8 @@ public ClassDescriptorBuilder withMetaClasses(List<Descriptor> metaClasses) {
207213 return this ;
208214 }
209215
210- public ClassDescriptorBuilder withSupportsGenerics ( boolean supportsGenerics ) {
211- this .supportsGenerics = supportsGenerics ;
216+ public ClassDescriptorBuilder withGenericInfo ( GenericInfo genericInfo ) {
217+ this .genericInfo = genericInfo ;
212218 return this ;
213219 }
214220
@@ -219,7 +225,7 @@ public ClassDescriptorBuilder withIsSelf(boolean isSelf) {
219225
220226 public ClassDescriptor build () {
221227 return new ClassDescriptor (name , fullyQualifiedName , superClasses , members , attributes , hasDecorators , definitionLocation ,
222- hasSuperClassWithoutDescriptor , hasMetaClass , metaclassFQN , metaClasses , supportsGenerics , isSelf , decorators );
228+ hasSuperClassWithoutDescriptor , hasMetaClass , metaclassFQN , metaClasses , genericInfo , isSelf , decorators );
223229 }
224230 }
225231}
0 commit comments