Class ConstructorExtension


  • public class ConstructorExtension
    extends Object
    Extension providing utility methods for the the Constructor meta model class.
    • Constructor Detail

      • ConstructorExtension

        public ConstructorExtension()
    • Method Detail

      • isBetterConstructorForCall

        public static boolean isBetterConstructorForCall​(Constructor co,
                                                         Constructor other,
                                                         Instantiation call)
        Returns true if the given Constructor co is a better match for the given constructor call than Constructor other. Possible Result:
        1. other is perfect match: co can not be better
        2. other is weak match: true only if co is perfect match
        3. other does not match: True only if co is at least weak match
        Parameters:
        co - The constructor to check if it is better.
        other - The existing constructor to compare with.
        call - The call to check for.
        Returns:
        True only if the new Constructor co is better than the other one.
      • isConstructorForCall

        public static boolean isConstructorForCall​(Constructor co,
                                                   Instantiation call,
                                                   boolean needsPerfectMatch)
        Check if a constructor element is valid for a constructor call. Note, this method has been originally copied from the MethodExtension class as the behavior is nearly the same, but Constructor and Method have no common super type. The only difference in the implementation is the check of the return type. Constructors must return the exact type of the classifier they are member of. General methods can have an arbitrary return type. The latter is checked by the MethodExtension class as part of the "weak match" check in the isBetterMethodForCall check. For the constructor, the return type is a hard criteria and thus checked as part of the general #isConstructorForCall(Constructor, NewConstructorCall, boolean).
        Parameters:
        co - The constructor to check.
        call - The call to check for.
        needsPerfectMatch - Flag how to handle parameters with variable argument (array) length
        Returns:
        True if the constructor is valid for the call.
      • getStatements

        @Deprecated
        public static EList<Statement> getStatements​(Constructor me)
        Deprecated.
        Use getBlock().getStatements().
        Returns a list of all statements within the block of a constructor. This is a legacy method to provide a stable and backwards-compatible API.
        Parameters:
        me - the constructor for which the statements are obtained.
        Returns:
        the list of all statements.