Skip to main content

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [List Home]
Re: [jdt-core-dev] Q about relationships between various java language element models in jdt.core


I'm not a JDT core expert, but I'll take a stab at answering:

There are essentially two interesting JDT "models".  The main java model is represented by the jdt.core.* types such as IField.  This a source-based model that is the main interface for searching and traversing the java model. It allows basic manipulation of type structure (such as add or delete members), but no real support for viewing or modifying the bodies of methods.  It also supports adding element change listeners to be notified when the model changes.

The other interesting "model" is the abstract syntax tree, which can be built for individual complication units in order to query or manipulate within method bodies.  You typically build one of these when you need it, and then it gets thrown away.  This is represented by methods in the "dom" package, for example FieldDeclaration in your list.  The compiler implementation uses a more powerful version of the AST (internal.compiler.ast.*), that supports things like code generation, but this is for internal use only.

I believe the JDOM model has been largely replaced by AST, but it remains for backwards compatibility.  It was used as a model for more complex source manipulation (for example refactoring used to use this). Again, you should probably just use AST instead of this.

For another language writer, I would suggest something similar.  A "fast" source based model that is always up to date and is mainly used for browsing and making major source changes (such adding/deleting files), and a "slow", lazily built parsed and resolved representation for richer manipulations such as refactoring.
--




Christopher J Daly <cjdaly@xxxxxxxxxx>
Sent by: jdt-core-dev-admin@xxxxxxxxxxx

10/24/2003 06:46 PM

Please respond to
jdt-core-dev

To
jdt-core-dev@xxxxxxxxxxx
cc
Subject
[jdt-core-dev] Q about relationships between various java language element models in jdt.core










I'm looking into the possibility of an eclipse plugin to support C#, so I'm
trying to understand how JDT does all the stuff it does.  One thing that's
confusing me is the number of different (but similar) object models for
representing Java language elements.  For instance if you take Java fields,
there is:

 org.eclipse.jdt.core.IField

which is implemented by
 org.eclipse.jdt.internal.core.BinaryField   and
 org.eclipse.jdt.internal.core.SourceField

then you have

 org.eclipse.jdt.internal.compiler.ast.FieldDeclaration

as well as

 org.eclipse.jdt.core.dom.FieldDeclaration

finally there is

 org.eclipse.jdt.core.jdom.IDOMField

which is implemented by
org.eclipse.jdt.internal.core.jdom.DOMField


Can anyone help me answer these questions:

1) are all 4 of these object models considered necessary and good?   If you
were starting from scratch on support for a new language would you have all
4?

2) What are the key relationships between the object models?  Are there
places where you walk a tree of one type to build a tree of another?  I see
that when the parser runs it creates nodes of the classes in
org.eclipse.jdt.internal.compiler.ast, so when do trees of the other types
get created?

3) Are the org.eclipse.jdt.internal.compiler.ast classes meant to be more a
model of the syntactic structure of the file, while the other models are
meant to represent the semantic information?  In other words was it deemed
useful (or necessary) to have a more syntactic / file-oriented model as
well as a more semantic model to do refactoring type stuff, or could they
be combined into one?  Or are the key distinctions between these object
models something else besides syntax vs. semantics?

4) Are there any newsgroups, mailing-lists, or documents that are
specifically for people trying to produce org.eclipse.Xdt - for languages X
that haven't been hosted on eclipse yet?


thanks in advance,

Chris

_______________________________________________
jdt-core-dev mailing list
jdt-core-dev@xxxxxxxxxxx
http://dev.eclipse.org/mailman/listinfo/jdt-core-dev


Back to the top