Class ConstructorExtension
- java.lang.Object
-
- org.emftext.language.java.extensions.members.ConstructorExtension
-
public class ConstructorExtension extends Object
Extension providing utility methods for the the Constructor meta model class.
-
-
Constructor Summary
Constructors Constructor Description ConstructorExtension()
-
Method Summary
All Methods Static Methods Concrete Methods Deprecated Methods Modifier and Type Method Description static EList<Statement>
getStatements(Constructor me)
Deprecated.Use getBlock().getStatements().static boolean
isBetterConstructorForCall(Constructor co, Constructor other, Instantiation call)
Returnstrue
if the givenConstructor
co
is a better match for the given constructor call thanConstructor
other
.static boolean
isConstructorForCall(Constructor co, Instantiation call, boolean needsPerfectMatch)
Check if a constructor element is valid for a constructor call.
-
-
-
Method Detail
-
isBetterConstructorForCall
public static boolean isBetterConstructorForCall(Constructor co, Constructor other, Instantiation call)
Returnstrue
if the givenConstructor
co
is a better match for the given constructor call thanConstructor
other
. Possible Result:other
is perfect match:co
can not be betterother
is weak match: true only ifco
is perfect matchother
does not match: True only ifco
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.
-
-