-
Notifications
You must be signed in to change notification settings - Fork 8
2. Extractor
The Java Project Extractor is accessed through the class JavaProjectExtractor
in the package eme.extractor
. Its use is pretty straight forward. It offers a method buildIntermediateModel()
which takes an IJavaProject
as parameter (An IJavaProject
can be created from an IProject
with the JDT API method call JavaCore.create()
). The method buildIntermediateModel()
extracts all information from the Java code in the project the IJavaProject
belongs to and build the intermediate model, which is then returned.
The package eme.extractor
contains five classes. All tasks related to the extracting of types will be delegated from the JavaProjectExtractor
to the JavaTypeExtractor
. The JavaTypeExtractor
delegates all tasks related to the extracting of methods to the class JavaMethodExtractor
. For every data type the class DataTypeExtractor
is used to create the related model component (attributes, parameters, return types, throws declarations). The extracting process makes heavy use of the JDT API to analyze the Java code. Therefore, the JDTUtil
class simplifies JDT functionality that is only accessable through complex interfaces or makes the code unreadable when used. The class offers simple static methods to encapsulate the problematic JDT functionality.
The extracting of the Java code and the creating of the intermediate model is executed internally in the following order:
- Extracting of all source packages
- Unifying all packages under one root package.
- For every package unit, for every compilation unit:
- Extracting of all types, which can be a:
- Class (Extracting methods, attributes, generic type parameters & super type references)
- Interface (Extracting methods, attributes, generic type parameters & super type references)
- Enumeration (Extracting enumerals, methods, attributes, generic type parameters & super type references)
- For every method: Extract parameters, return type, access level modifier, throws declarations & static/final keywords.
- For every attribute: Extract name, data type, access level modifier, static/final keywords and generic arguments.
- P
extractarsing of all external types (All resolvable types that are not types in the intermediate model from the set of data type names of the class
DataTypeExtractor`).
The progress of the extracting is logged for every extracted package with its name, its number and the total number of packages. The last step is also logged.
To extract data types, the class DataTypeExtractor
offers six methods:
-
extractField()
is used to extract anIField
field of anIType
. Fields can be attributes and references and are modeled internally asExtractedAttribute
. -
extractParameter()
is used to extract anILocalVariable
parameter of anIMethod
. Parameters are modeled internally as *ExtractedParameter
. -
extractReturnType()
is used to extract a return type of anIMethod
. return types are modeled internally asExtractedDataType
. You cannot use the methodextractDataType()
for return types, because return types can be void. -
extractTypeParameters()
is used to extract all type parameters of anIType
and add them to anExtractedType
. type parameters are modeled internally asExtractedTypeParameter
. -
extractDataType()
is called by the other extracting methods and should only be called if other extracting methods of the class do not work for a data type. It is also used for the extracting of simple data types like throws declarations. These simple data types are signature strings and are modeled internally asExtractedDataType
. -
getDataTypes
returns a set of the names of all extacted data types. This is used to identify the external types.