From 21342769d7cc4ad76f4f4081fce7fd0de4943014 Mon Sep 17 00:00:00 2001 From: Doug Schaefer Date: Mon, 22 Nov 2004 03:45:18 +0000 Subject: [PATCH] Hooked up the DOM to the Core Model (kind of). Put in a little more docs. --- .../cdt/core/model/ITranslationUnit.java | 8 ++++++++ .../internal/core/model/TranslationUnit.java | 9 +++++++++ .../guide/dom/index.html | 19 ++++++++++++++++++- 3 files changed, 35 insertions(+), 1 deletion(-) diff --git a/core/org.eclipse.cdt.core/model/org/eclipse/cdt/core/model/ITranslationUnit.java b/core/org.eclipse.cdt.core/model/org/eclipse/cdt/core/model/ITranslationUnit.java index 24698fa3db7..8b5bd952f5b 100644 --- a/core/org.eclipse.cdt.core/model/org/eclipse/cdt/core/model/ITranslationUnit.java +++ b/core/org.eclipse.cdt.core/model/org/eclipse/cdt/core/model/ITranslationUnit.java @@ -6,6 +6,7 @@ package org.eclipse.cdt.core.model; */ import java.util.Map; +import org.eclipse.cdt.core.dom.ast.IASTTranslationUnit; import org.eclipse.cdt.internal.core.model.IBufferFactory; import org.eclipse.core.runtime.IProgressMonitor; /** @@ -320,4 +321,11 @@ public interface ITranslationUnit extends ICElement, IParent, IOpenable, ISource * returns a map of all new elements and their element info */ Map parse(); + + /** + * Returns the root object of a DOM Abstract syntax tree. + * + * @return + */ + IASTTranslationUnit getASTTranslationUnit(); } diff --git a/core/org.eclipse.cdt.core/model/org/eclipse/cdt/internal/core/model/TranslationUnit.java b/core/org.eclipse.cdt.core/model/org/eclipse/cdt/internal/core/model/TranslationUnit.java index 067e71b199e..04bf93703cc 100644 --- a/core/org.eclipse.cdt.core/model/org/eclipse/cdt/internal/core/model/TranslationUnit.java +++ b/core/org.eclipse.cdt.core/model/org/eclipse/cdt/internal/core/model/TranslationUnit.java @@ -10,6 +10,7 @@ import java.util.HashMap; import java.util.Map; import org.eclipse.cdt.core.CCorePlugin; +import org.eclipse.cdt.core.dom.ast.IASTTranslationUnit; import org.eclipse.cdt.core.filetype.ICFileType; import org.eclipse.cdt.core.filetype.ICFileTypeConstants; import org.eclipse.cdt.core.model.CModelException; @@ -568,4 +569,12 @@ public class TranslationUnit extends Openable implements ITranslationUnit { return super.exists(); } + /* (non-Javadoc) + * @see org.eclipse.cdt.core.model.ITranslationUnit#getASTTranslationUnit() + */ + public IASTTranslationUnit getASTTranslationUnit() { + // TODO Auto-generated method stub + return null; + } + } diff --git a/doc/org.eclipse.cdt.doc.isv/guide/dom/index.html b/doc/org.eclipse.cdt.doc.isv/guide/dom/index.html index 6e01dc4bb8b..8626ae7459d 100644 --- a/doc/org.eclipse.cdt.doc.isv/guide/dom/index.html +++ b/doc/org.eclipse.cdt.doc.isv/guide/dom/index.html @@ -24,6 +24,12 @@ up to the entry rule in the grammer. This view fulfills the role of a traditional Abstract Syntax Tree, and you'll see that the classes that make up this view have AST in their name.

+

The top node of the Syntactic View is IASTTranslationUnit. +The translation unit object can be accessed from the C Model's ITranslationUnit +object.
+

Semantic View

The semantic view (which we sometimes call the logical view) represent semantic elements in the program. These elements are @@ -31,9 +37,20 @@ generally types, variables, and functions. The JDT calls these things bindings, so we do to. However, the more general rule is that anything that links sub-branches of the AST is a binding.

+

The most common way to get from the Syntactic View is to navigate +from an IASTName +view to the IBinding +that represents the Semantic object for that +given name.
+

Workspace-Wide View

Once you have a binding, it is possible to find all translation -units that declare or refer to that binding.

+units that declare or refer to that binding. From there you can +navigate from the IASTTranslationUnit to the IASTNames that declare or +refer to that binding.
+

Rewriting

From the Syntactic view, you can ask the AST Rewriter to calculate the TextEdits required to accomplish changes to the AST.