1
0
Fork 0
mirror of https://github.com/eclipse-cdt/cdt synced 2025-07-24 01:15:29 +02:00

Hooked up the DOM to the Core Model (kind of). Put in a little more docs.

This commit is contained in:
Doug Schaefer 2004-11-22 03:45:18 +00:00
parent 3fab76a13d
commit 21342769d7
3 changed files with 35 additions and 1 deletions

View file

@ -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();
}

View file

@ -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;
}
}

View file

@ -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.<br>
</p>
<p>The top node of the Syntactic View is <a
href="../../reference/api/org/eclipse/cdt/core/dom/ast/IASTTranslationUnit.html">IASTTranslationUnit</a>.
The translation unit object can be accessed from the C Model's <a
href="../../reference/api/org/eclipse/cdt/core/model/ITranslationUnit.html">ITranslationUnit</a>
object.<br>
</p>
<h2>Semantic View</h2>
<p>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.<br>
</p>
<p>The most common way to get from the Syntactic View is to navigate
from an <a
href="../../reference/api/org/eclipse/cdt/core/dom/ast/IASTName.html">IASTName</a>
view to the <a
href="../../reference/api/org/eclipse/cdt/core/dom/ast/IBinding.html">IBinding</a>
that represents the Semantic object for that
given name.<br>
</p>
<h2>Workspace-Wide View</h2>
<p>Once you have a binding, it is possible to find all translation
units that declare or refer to that binding.</p>
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.<br>
</p>
<h2>Rewriting</h2>
<p>From the Syntactic view, you can ask the AST Rewriter to calculate
the TextEdits required to accomplish changes to the AST.<br>