Class CompilationUnitExtension
java.lang.Object
org.emftext.language.java.extensions.containers.CompilationUnitExtension
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionstatic 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>static AnnotationReturns the annotation that is directly contained in the compilation unit (if exactly one exists).static ClassReturns 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 EnumerationReturns the enumeration that is directly contained in the compilation unit (if exactly one exists).static InterfaceReturns the interface that is directly contained in the compilation unit (if exactly one exists).
-
Constructor Details
-
CompilationUnitExtension
public CompilationUnitExtension()
-
-
Method Details
-
getContainedClassifier
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
- Parameters:
me- the context.- Returns:
- all classes in the same package imports
-
getContainedClass
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
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
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
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
Adds an import of the given class to this compilation unit.- Parameters:
me- the compilation unit.nameOfClassToImport- name of the class to import.
-
addPackageImport
Adds an import of the given package to this compilation unit.- Parameters:
me- the compilation unit.packageName- name of the package to import.
-