Java Model in JDT

来源:互联网 发布:宇石网络绍兴 编辑:程序博客网 时间:2024/05/07 19:11
Each Java project is internally represented in Eclipse as a Java model. The Eclipse Java model is a light-weight and fault tolerant representation of the Java project.

It does not contain as many information as the Abstract Syntax Tree (AST) but is fast to create. For example the Outline view is using the Java model for its representation; this way the information in the Outline view can quickly get updated.

The Java model is defined in the org.eclipse.jdt.core plug-in. JDT Core (org.eclipse.jdt.core) is the plug-in that defines the core Java elements and API. You should always list this plug-in as a prerequisite when you are developing Java specific features.

JDT Core packages give you access to the Java model objects and headless Java IDE infrastructure.  The JDT Core packages include:

org.eclipse.jdt.core - defines the classes that describe the Java model.
org.eclipse.jdt.core.compiler - defines an API for the compiler infrastructure.
org.eclipse.jdt.core.dom - supports Abstract Syntax Trees (AST) that can be used for examining the structure of a compilation unit down to the statement level.
org.eclipse.jdt.core.dom.rewrite - supports rewriting of Abstract Syntax Trees (AST) that can be used for manipulating the structure of a compilation unit down to the statement level.
org.eclipse.jdt.core.eval - supports the evaluation of code snippets in a scrapbook or inside the debugger.
org.eclipse.jdt.core.formatter - supports the formatting of compilation units, types, statements, expressions, etc.
org.eclipse.jdt.core.jdom - supports a Java Document Object Model (DOM) that can be used for walking the structure of a Java compilation unit.
org.eclipse.jdt.core.search - supports searching the workspace's Java model for Java elements that match a particular description.  

org.eclipse.jdt.core.util - provides utility classes for manipulating .class files and Java model elements.                                                                                                                                            

Project ElementJava Model elementDescriptionJava projectIJavaProjectThe Java project which contains all other objects.src folder / bin folder / or external libraryIPackageFragmentRootHold source or binary files, can be a folder or a library (zip / jar file)Each packageIPackageFragmentEach package is below the IPackageFragmentRoot, sub-packages are not leaves of the package, they are listed directed under IPackageFragmentRootJava Source FileICompilationUnitThe Source file is always below the package nodeTypes / Fields / MethodsIType / IField / IMethodTypes, fields and methods