Class CompilationUnitExtension
java.lang.Object
org.emftext.language.java.extensions.containers.CompilationUnitExtension
-
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptionstatic void
addImport
(CompilationUnit me, String nameOfClassToImport) Adds an import of the given class to this compilation unit.static void
addPackageImport
(CompilationUnit me, String packageName) Adds an import of the given package to this compilation unit.static EList<ConcreteClassifier>
static Annotation
Returns the annotation that is directly contained in the compilation unit (if exactly one exists).static Class
Returns the class that is directly contained in the compilation unit (if exactly one exists).static ConcreteClassifier
getContainedClassifier
(CompilationUnit me, String name) Returns the firstConcreteClassifier
that is contained in thisCompilationUnit
and which has the given name.static Enumeration
Returns the enumeration that is directly contained in the compilation unit (if exactly one exists).static Interface
Returns the interface that is directly contained in the compilation unit (if exactly one exists).
-
Constructor Details
-
CompilationUnitExtension
public CompilationUnitExtension()
-
-
Method Details
-
getContainedClassifier
Returns the firstConcreteClassifier
that is contained in thisCompilationUnit
and 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 theCompilationUnit
contains multiple classifiers or if the contained classifier is not aClass
,null
is 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 theCompilationUnit
contains multiple classifiers or if the contained classifier is not anInterface
,null
is 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 theCompilationUnit
contains multiple classifiers or if the contained classifier is not anAnnotation
,null
is 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 theCompilationUnit
contains multiple classifiers or if the contained classifier is not anEnumeration
,null
is 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.
-