@ SuppressWarnings ( { "checkstyle:cyclomaticcomplexity" , "checkstyle:npathcomplexity" , "checkstyle:nestedifdepth" } ) protected void checkSuperConstructor ( XtendTypeDeclaration container , EStructuralFeature feature , Collection < ActionParameterTypes > defaultSignatures ) { final JvmDeclaredType jvmElement = this . associations . getInferredType ( container ) ; if ( jvmElement != null ) { final Map < ActionParameterTypes , JvmConstructor > superConstructors = CollectionLiterals . newTreeMap ( ( Comparator < ActionParameterTypes > ) null ) ; final JvmTypeReference typeRef = jvmElement . getExtendedClass ( ) ; final JvmType supertype = ( typeRef == null ) ? null : typeRef . getType ( ) ; if ( supertype instanceof JvmGenericType ) { final JvmGenericType jvmSuperElement = ( JvmGenericType ) supertype ; for ( final JvmConstructor superConstructor : jvmSuperElement . getDeclaredConstructors ( ) ) { final ActionParameterTypes sig = this . sarlActionSignatures . createParameterTypesFromJvmModel ( superConstructor . isVarArgs ( ) , superConstructor . getParameters ( ) ) ; superConstructors . put ( sig , superConstructor ) ; } } final ActionParameterTypes voidKey = this . sarlActionSignatures . createParameterTypesForVoid ( ) ; //boolean hasDeclaredConstructor = false; for ( final XtendMember member : container . getMembers ( ) ) { if ( member instanceof SarlConstructor ) { final SarlConstructor constructor = ( SarlConstructor ) member ; //hasDeclaredConstructor = true; boolean invokeDefaultConstructor = true ; final XExpression body = constructor . getExpression ( ) ; if ( body instanceof XBlockExpression ) { final XBlockExpression block = ( XBlockExpression ) body ; if ( ! block . getExpressions ( ) . isEmpty ( ) ) { final XExpression firstStatement = block . getExpressions ( ) . get ( 0 ) ; if ( firstStatement instanceof XConstructorCall || isDelegateConstructorCall ( firstStatement ) ) { invokeDefaultConstructor = false ; } } } else if ( body instanceof XConstructorCall || isDelegateConstructorCall ( body ) ) { invokeDefaultConstructor = false ; } if ( invokeDefaultConstructor && ! superConstructors . containsKey ( voidKey ) ) { final List < String > issueData = new ArrayList <> ( ) ; for ( final ActionParameterTypes defaultSignature : defaultSignatures ) { issueData . add ( defaultSignature . toString ( ) ) ; } error ( Messages . SARLValidator_33 , member , null , ValidationMessageAcceptor . INSIGNIFICANT_INDEX , MUST_INVOKE_SUPER_CONSTRUCTOR , toArray ( issueData , String . class ) ) ; } } } // The following code is no more needed because of the constructor inheritance mechanism which // is implemented into the JVM model inferrer. /*if (!hasDeclaredConstructor) { for (final ActionParameterTypes defaultSignature : defaultSignatures) { if (!superConstructors.containsKey(defaultSignature)) { final List<String> issueData = new ArrayList<>(); for (final JvmConstructor superConstructor : superConstructors.values()) { issueData.add(EcoreUtil.getURI(superConstructor).toString()); issueData.add(doGetReadableSignature(container.getName(), superConstructor.getParameters())); } error(Messages.SARLValidator_33, container, feature, MISSING_CONSTRUCTOR, toArray(issueData, String.class)); } } }*/ } }
Check the super constructors .