Class CompilationUnitExtension
- java.lang.Object
-
- org.emftext.language.java.extensions.containers.CompilationUnitExtension
-
public class CompilationUnitExtension extends Object
-
-
Constructor Summary
Constructors Constructor Description CompilationUnitExtension()
-
Method Summary
All Methods Static Methods Concrete Methods Modifier and Type Method Description static voidaddImport(CompilationUnit me, String nameOfClassToImport)Adds an import of the given class to this compilation unit.static voidaddPackageImport(CompilationUnit me, String packageName)Adds an import of the given package to this compilation unit.static EList<ConcreteClassifier>getClassifiersInSamePackage(CompilationUnit me)static AnnotationgetContainedAnnotation(CompilationUnit me)Returns the annotation that is directly contained in the compilation unit (if exactly one exists).static ClassgetContainedClass(CompilationUnit me)Returns the class that is directly contained in the compilation unit (if exactly one exists).static ConcreteClassifiergetContainedClassifier(CompilationUnit me, String name)Returns the firstConcreteClassifierthat is contained in thisCompilationUnitand which has the given name.static EnumerationgetContainedEnumeration(CompilationUnit me)Returns the enumeration that is directly contained in the compilation unit (if exactly one exists).static InterfacegetContainedInterface(CompilationUnit me)Returns the interface that is directly contained in the compilation unit (if exactly one exists).
-
-
-
Method Detail
-
getContainedClassifier
public static ConcreteClassifier getContainedClassifier(CompilationUnit me, String name)
Returns the firstConcreteClassifierthat is contained in thisCompilationUnitand which has the given name.- Parameters:
me- the context.name- the name of the classifier to search for- Returns:
- the classifier if one is found, otherwise
null
-
getClassifiersInSamePackage
public static EList<ConcreteClassifier> getClassifiersInSamePackage(CompilationUnit me)
- Parameters:
me- the context.- Returns:
- all classes in the same package imports
-
getContainedClass
public static Class getContainedClass(CompilationUnit me)
Returns the class that is directly contained in the compilation unit (if exactly one exists). If theCompilationUnitcontains multiple classifiers or if the contained classifier is not aClass,nullis returned.- Parameters:
me- the compilation unit.- Returns:
- the class directly contained in the compilation unit (if there is
exactly one contained classifier that is of type
Class)
-
getContainedInterface
public static Interface getContainedInterface(CompilationUnit me)
Returns the interface that is directly contained in the compilation unit (if exactly one exists). If theCompilationUnitcontains multiple classifiers or if the contained classifier is not anInterface,nullis returned.- Parameters:
me- the compilation unit.- Returns:
- the interface directly contained in the compilation unit (if
there is exactly one contained classifier that is of type
Interface)
-
getContainedAnnotation
public static Annotation getContainedAnnotation(CompilationUnit me)
Returns the annotation that is directly contained in the compilation unit (if exactly one exists). If theCompilationUnitcontains multiple classifiers or if the contained classifier is not anAnnotation,nullis returned.- Parameters:
me- the compilation unit.- Returns:
- the annotation directly contained in the compilation unit (if
there is exactly one contained classifier that is of type
Annotation)
-
getContainedEnumeration
public static Enumeration getContainedEnumeration(CompilationUnit me)
Returns the enumeration that is directly contained in the compilation unit (if exactly one exists). If theCompilationUnitcontains multiple classifiers or if the contained classifier is not anEnumeration,nullis returned.- Parameters:
me- the compilation unit.- Returns:
- the enumeration directly contained in the compilation unit (if
there is exactly one contained classifier that is of type
Enumeration)
-
addImport
public static void addImport(CompilationUnit me, String nameOfClassToImport)
Adds an import of the given class to this compilation unit.- Parameters:
me- the compilation unit.nameOfClassToImport- name of the class to import.
-
addPackageImport
public static void addPackageImport(CompilationUnit me, String packageName)
Adds an import of the given package to this compilation unit.- Parameters:
me- the compilation unit.packageName- name of the package to import.
-
-