Difference between revisions of "MoDisco/Components/J2SE5/Documentation/0.7"
m (MoDisco/J2SE5/Documentation moved to MoDisco/Components/J2SE5/Documentation: New Template Implementation)
|Line 1:||Line 1:|
== Main metaclasses ==
== Main metaclasses ==
Revision as of 10:24, 6 September 2010
|Mailing List • Forums|
|Browse Source • Project Set File|
- 1 Main metaclasses
- 2 Requirements
- 3 Install
- 4 Associated Discoverers
Every metaclass (apart from the Model metaclass) inherits from ASTNode. As its name indicates, ASTNode represents a graph node. ASTNode has a reference to the Comment metaclass because almost every java element could be associated to a comment (block or line comment and Javadoc). More details in "Comment" section.
Model, Package, AbstractTypeDeclaration
The root element of each J2SE5 model is an instance of the "Model" metaclass. It is a translation of java application concept, so it contains package declarations (instances of the PackageDeclaration metaclass). And package declarations contain type declarations (instances compatible with AbstractTypeDeclaration metaclass), and so on ...
NamedElement & notion of Proxy
A lot of java elements are "named", and this name could be considered as an identifier : methods, packages, types, variables, fields, ... So all the corresponding metaclasses inherit from the NamedElement metaclass. It will be useful to resolve references in binding, see the NamedElementRef metaclass.
Another goal of this metaclass is to indicate whether an element is part of the current Java application or not (element from an external library of from the JDK). Then external elements are tagged as proxy through a dedicated attribute and can be easily filtered. For example, instruction "System.out.println" has been decomposed into three named elements (one class, one variable and one method) the definitions of which are not part of the current Java application. So attribute "proxy" of these elements has been initialized as true.
To represent links between Java elements, as java AST defines only string references, metaclass NamedElementRef initially contained only this information. But an important addition was to resolve bindings between elements, so is is actually possible to navigate directly in the elements graph. It has been represented as a relationship from a NamedElementRef to a NamedElement (proxy or not).
A type declaration has different kinds of contents : fields, methods, static block, initialization block or other type declarations. All of these elements are of type BodyDeclaration metaclass.
Like in many languages, the concept of expression exists in Java : it is a portion of code, without declarations, and its evaluation returns a value, numerical or boolean or other ...For example,
All types of expressions shall inherit from Expression metaclass.
An "instruction" in Java is represented by the Statement metaclass. A block of code (Block metaclass) contains a collection of statements, an a block of code may be contained by a method.Some examples of statements in java :
if, while, for, do, ...
All of their definitions use the concept of expression to separate the value from the instruction keyword.
Zoom on comments
There are three kinds of comments : line comments (//), block comments (/* */) and javadoc comments (/** */). Every comment contains text fragments, but we can have more information on javadoc comments (Javadoc metaclass): they can also contain javadoc tags that are identified and collected through instances of the TagElement metaclass.
Zoom on annotations
Official usage of annotations has been introduced in version 5 of the JDK. To handle them, annotation declarations are managed as type declarations (AnnotationTypeDeclaration metaclass) with specific attributes (AnnotationTypeMemberDeclaration metaclass). And annotation usages are translated into instances of the Annotation metaclass, which reference corresponding annotation declarations. And parameters are translated into instances of the MemberValuePair metaclass.
Zoom on generics
Version 5 of the JDK also introduces the concept of "generics". Generic types of method declarations are translated into instances of TypeDeclaration of MethodDeclaration metaclass with arguments as instances of the TypeParameter metaclass. Uses of these generics are translated into instances of the ParameterizedType metaclass which reference concrete elements (type and types arguments).
A specific case of type argument is the "wildcard" (for example <? extends X>. There is a specific metaclass to handle it : WildCardType.
To use the plug-in you need:
- JDK 1.5 or above
- a version of Eclipse 3.3 or above with the following set of plug-ins installed
- EMF 2.3.0 or higher
You will find a version of this plug-in in SVN repository.
Here are installation instructions :
- Import project in your workspace using a SVN client.
- Use "export" menu to export this project as a plug-in (Deployable plug-ins and fragments) in your Eclipse installation. Don't forget to choose "Package plug-ins as individual jar archives" option.
- Re-start your Eclipse to take this plug-in into account.
Connection parameters to SVN repository: MoDisco/SVN.
The main discoverer available for this metamodel : JavaDiscoverer