Skip to main content
summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorDoug Schaefer2003-03-03 10:28:09 -0500
committerDoug Schaefer2003-03-03 10:28:09 -0500
commit6ab46192aef41ee000cb9b211e84cd0fd79dd8be (patch)
tree5c6af2dea3540d6067f3cf667b265967ec676f44
parent4bfaf9664ccab31e1eec7212527bf92cbc980b12 (diff)
downloadorg.eclipse.cdt-6ab46192aef41ee000cb9b211e84cd0fd79dd8be.tar.gz
org.eclipse.cdt-6ab46192aef41ee000cb9b211e84cd0fd79dd8be.tar.xz
org.eclipse.cdt-6ab46192aef41ee000cb9b211e84cd0fd79dd8be.zip
Patch for John Camelon:
- some of the outline view going with new parser
-rw-r--r--core/org.eclipse.cdt.core/newparser/org/eclipse/cdt/internal/core/model/Declarator.java52
-rw-r--r--core/org.eclipse.cdt.core/newparser/org/eclipse/cdt/internal/core/model/ICElementWrapper.java15
-rw-r--r--core/org.eclipse.cdt.core/newparser/org/eclipse/cdt/internal/core/model/NewModelBuilder.java271
-rw-r--r--core/org.eclipse.cdt.core/newparser/org/eclipse/cdt/internal/core/model/Parameter.java46
-rw-r--r--core/org.eclipse.cdt.core/newparser/org/eclipse/cdt/internal/core/model/SimpleDeclarationWrapper.java155
-rw-r--r--core/org.eclipse.cdt.core/newparser/org/eclipse/cdt/internal/core/model/TranslationUnitWrapper.java32
-rw-r--r--core/org.eclipse.cdt.core/newparser/org/eclipse/cdt/internal/core/newparser/IParserCallback.java6
-rw-r--r--core/org.eclipse.cdt.core/newparser/org/eclipse/cdt/internal/core/newparser/NullParserCallback.java6
-rw-r--r--core/org.eclipse.cdt.core/newparser/org/eclipse/cdt/internal/core/newparser/Parser.java6
-rw-r--r--core/org.eclipse.cdt.core/newparser/org/eclipse/cdt/internal/core/newparser/util/DeclSpecifier.java188
-rw-r--r--core/org.eclipse.cdt.core/newparser/org/eclipse/cdt/internal/core/newparser/util/DeclarationSpecifier.java25
-rw-r--r--core/org.eclipse.cdt.core/newparser/org/eclipse/cdt/internal/core/newparser/util/Name.java46
12 files changed, 730 insertions, 118 deletions
diff --git a/core/org.eclipse.cdt.core/newparser/org/eclipse/cdt/internal/core/model/Declarator.java b/core/org.eclipse.cdt.core/newparser/org/eclipse/cdt/internal/core/model/Declarator.java
new file mode 100644
index 0000000000..7be89689ff
--- /dev/null
+++ b/core/org.eclipse.cdt.core/newparser/org/eclipse/cdt/internal/core/model/Declarator.java
@@ -0,0 +1,52 @@
+package org.eclipse.cdt.internal.core.model;
+
+import java.util.List;
+
+import org.eclipse.cdt.internal.core.newparser.util.Name;
+
+/**
+ * @author jcamelon
+ *
+ * To change this generated comment edit the template variable "typecomment":
+ * Window>Preferences>Java>Templates.
+ * To enable and disable the creation of type comments go to
+ * Window>Preferences>Java>Code Generation.
+ */
+public class Declarator {
+
+ private Name name;
+
+ /**
+ * Returns the name.
+ * @return Name
+ */
+ public Name getName() {
+ return name;
+ }
+
+ /**
+ * Sets the name.
+ * @param name The name to set
+ */
+ public void setName(Name name) {
+ this.name = name;
+ }
+
+ private List parameterDeclarationClause = null;
+
+ /**
+ * Returns the parameterDeclarationClause.
+ * @return List
+ */
+ public List getParameterDeclarationClause() {
+ return parameterDeclarationClause;
+ }
+
+ /**
+ * Sets the parameterDeclarationClause.
+ * @param parameterDeclarationClause The parameterDeclarationClause to set
+ */
+ public void setParameterDeclarationClause(List parameterDeclarationClause) {
+ this.parameterDeclarationClause = parameterDeclarationClause;
+ }
+}
diff --git a/core/org.eclipse.cdt.core/newparser/org/eclipse/cdt/internal/core/model/ICElementWrapper.java b/core/org.eclipse.cdt.core/newparser/org/eclipse/cdt/internal/core/model/ICElementWrapper.java
new file mode 100644
index 0000000000..5f3db2b35d
--- /dev/null
+++ b/core/org.eclipse.cdt.core/newparser/org/eclipse/cdt/internal/core/model/ICElementWrapper.java
@@ -0,0 +1,15 @@
+package org.eclipse.cdt.internal.core.model;
+
+/**
+ * @author jcamelon
+ *
+ * To change this generated comment edit the template variable "typecomment":
+ * Window>Preferences>Java>Templates.
+ * To enable and disable the creation of type comments go to
+ * Window>Preferences>Java>Code Generation.
+ */
+public interface ICElementWrapper {
+
+ public CElement getElement();
+ public void setElement (CElement item);
+}
diff --git a/core/org.eclipse.cdt.core/newparser/org/eclipse/cdt/internal/core/model/NewModelBuilder.java b/core/org.eclipse.cdt.core/newparser/org/eclipse/cdt/internal/core/model/NewModelBuilder.java
index c5ea56ced8..83c9fbd3de 100644
--- a/core/org.eclipse.cdt.core/newparser/org/eclipse/cdt/internal/core/model/NewModelBuilder.java
+++ b/core/org.eclipse.cdt.core/newparser/org/eclipse/cdt/internal/core/model/NewModelBuilder.java
@@ -10,25 +10,23 @@
******************************************************************************/
package org.eclipse.cdt.internal.core.model;
+import java.util.LinkedList;
+import java.util.List;
+
import org.eclipse.cdt.core.model.ICElement;
-import org.eclipse.cdt.internal.core.newparser.NullParserCallback;
-import org.eclipse.cdt.internal.core.newparser.Parser;
+import org.eclipse.cdt.internal.core.newparser.IParserCallback;
import org.eclipse.cdt.internal.core.newparser.Token;
+import org.eclipse.cdt.internal.core.newparser.util.DeclSpecifier;
+import org.eclipse.cdt.internal.core.newparser.util.DeclarationSpecifier;
+import org.eclipse.cdt.internal.core.newparser.util.Name;
-public class NewModelBuilder extends NullParserCallback {
+public class NewModelBuilder implements IParserCallback {
- private TranslationUnit translationUnit;
- private CElement currentElement;
- private CElement underConstruction;
- private String declSpecifier;
- private String declaratorId;
- private boolean isFunction;
- private int inclusionDepth = 0;
- private boolean inArguments = false;
+ private TranslationUnitWrapper translationUnit = new TranslationUnitWrapper();
+
public NewModelBuilder(TranslationUnit tu) {
- translationUnit = tu;
- currentElement = tu;
+ translationUnit.setElement( tu );
}
/**
@@ -37,7 +35,6 @@ public class NewModelBuilder extends NullParserCallback {
public Object translationUnitBegin() {
return translationUnit;
}
-
private Token classKey;
@@ -46,6 +43,8 @@ public class NewModelBuilder extends NullParserCallback {
*/
public Object classSpecifierBegin(Object container, Token classKey) {
+ SimpleDeclarationWrapper c = (SimpleDeclarationWrapper)container;
+
int kind;
switch (classKey.getType()) {
case Token.t_class:
@@ -59,9 +58,9 @@ public class NewModelBuilder extends NullParserCallback {
}
this.classKey = classKey;
- Structure elem = new Structure( translationUnit, kind, null );
- currentElement.addChild(elem);
- return elem;
+ Structure elem = new Structure( c.getParent(), kind, null );
+ c.getParent().addChild(elem);
+ return new SimpleDeclarationWrapper( elem );
}
/**
@@ -69,122 +68,55 @@ public class NewModelBuilder extends NullParserCallback {
*/
public void classSpecifierName(Object classSpecifier) {
- String name = nameEndToken.getImage();
- Structure elem = ((Structure)classSpecifier);
+ SimpleDeclarationWrapper container = (SimpleDeclarationWrapper)classSpecifier;
+ String name = currName.toString();
+ Structure elem = ((Structure)container.getElement());
elem.setElementName( name );
- elem.setIdPos(nameEndToken.getOffset() - 2, nameEndToken.getImage().length());
- elem.setPos(nameEndToken.getOffset(), nameEndToken.getImage().length());
- currentElement = elem;
-
+ elem.setIdPos(currName.getEndOffset() - 2, name.length());
+ elem.setPos(currName.getEndOffset(), name.length());
}
/**
* @see org.eclipse.cdt.core.newparser.IParserCallback#endClass()
*/
public void classSpecifierEnd(Object classSpecifier) {
- currentElement = (CElement)currentElement.getParent();
}
/**
* @see org.eclipse.cdt.core.newparser.IParserCallback#beginDeclarator()
*/
public Object declaratorBegin(Object container) {
- if (!inArguments) {
- declaratorId = null;
- isFunction = false;
- }
- return null;
+ DeclarationSpecifier.Container declSpec = (DeclarationSpecifier.Container)container;
+ List declarators = declSpec.getDeclarators();
+ Declarator declarator =new Declarator();
+ declarators.add( declarator );
+ return declarator;
}
- /**
- * @see org.eclipse.cdt.core.newparser.IParserCallback#declSpecifier(String)
- */
- public void declSpecifier(Token specifier) {
- declSpecifier = "";
- if (specifier != null) {
- try {
- declSpecifier = Parser.generateName(specifier);
- } catch (Exception e) {
- }
- }
- }
private int startIdPos;
private int idLength;
- /**
- * @see org.eclipse.cdt.core.newparser.IParserCallback#declaratorId(List)
- */
- public void declaratorId(Token id) {
- if (!inArguments)
- try {
- declaratorId = Parser.generateName(id);
- startIdPos = id.getOffset() - 2;
- idLength = declaratorId.length();
- } catch (Exception e) {
- // Hard to see why we would get here
- declaratorId = "";
- }
- }
-
- /**
- * @see org.eclipse.cdt.core.newparser.IParserCallback#beginArguments()
- */
- public Object argumentsBegin() {
- isFunction = true;
- inArguments = true;
- return null;
- }
-
- /**
- * @see org.eclipse.cdt.internal.core.newparser.IParserCallback#endArguments()
- */
- public void argumentsEnd() {
- inArguments = false;
- }
-
private CElement elem;
/**
* @see org.eclipse.cdt.core.newparser.IParserCallback#endDeclarator()
*/
public void declaratorEnd( Object declarator) {
- elem = null;
-
- if (isFunction) {
- elem = new FunctionDeclaration(currentElement, declaratorId);
- } else {
- if (currentElement instanceof TranslationUnit) {
- elem = new Variable(currentElement, declaratorId);
-
- } else if (currentElement instanceof Structure) {
- elem = new Field(currentElement, declaratorId);
- }
- }
-
- if (elem != null) {
- elem.setIdPos(startIdPos, idLength);
- elem.setPos(startPos, idLength);
- currentElement.addChild(elem);
- }
}
/**
* @see org.eclipse.cdt.internal.core.newparser.IParserCallback#beginFunctionBody()
*/
public void functionBodyBegin() {
- // Oops, the last function declaration was really supposed to be
- // a function definition.
- //((CElement)elem.getParent()).add
- elem = new Function(currentElement, declaratorId);
}
/**
* @see org.eclipse.cdt.core.newparser.IParserCallback#macro(String)
*/
public void macro(String macroName) {
- Macro elem = new Macro(translationUnit, macroName);
- translationUnit.addChild(elem);
+ Macro elem = new Macro((TranslationUnit)translationUnit.getElement(), macroName);
+ ((TranslationUnit)translationUnit.getElement()).addChild(elem);
}
private int startPos;
@@ -193,43 +125,164 @@ public class NewModelBuilder extends NullParserCallback {
* @see
org.eclipse.cdt.internal.core.newparser.IParserCallback#beginSimpleDeclaration(Token)
*/
- public Object simpleDeclarationBegin(Object Container, Token firstToken) {
- if (inclusionDepth == 0)
- startPos = firstToken.getOffset();
- return null;
+ public Object simpleDeclarationBegin(Object container) {
+ ICElementWrapper wrapper = (ICElementWrapper)container;
+ Object parent = wrapper.getElement();
+ SimpleDeclarationWrapper result = new SimpleDeclarationWrapper();
+ if( wrapper instanceof SimpleDeclarationWrapper )
+ result.setParent( (CElement)wrapper.getElement() );
+ else if ( wrapper instanceof TranslationUnitWrapper )
+ result.setParent( (TranslationUnit)wrapper.getElement());
+ return result;
}
+
+
/**
* @see org.eclipse.cdt.internal.core.newparser.IParserCallback#beginInclusion(String)
*/
public void inclusionBegin(String includeFile) {
- ++inclusionDepth;
- Include elem = new Include(translationUnit, includeFile);
- translationUnit.addChild(elem);
+ Include elem = new Include(((TranslationUnit)translationUnit.getElement()), includeFile);
+ ((TranslationUnit)translationUnit.getElement()).addChild(elem);
}
/**
* @see org.eclipse.cdt.internal.core.newparser.IParserCallback#endInclusion()
*/
public void inclusionEnd() {
- --inclusionDepth;
}
-
- private Token nameBeginToken;
- private Token nameEndToken;
+
+ private Name currName;
/**
* @see org.eclipse.cdt.internal.core.newparser.IParserCallback#nameBegin(org.eclipse.cdt.internal.core.newparser.Token)
*/
public void nameBegin(Token firstToken) {
- nameBeginToken = firstToken;
+ currName = new Name(firstToken);
}
/**
* @see org.eclipse.cdt.internal.core.newparser.IParserCallback#nameEnd(org.eclipse.cdt.internal.core.newparser.Token)
*/
public void nameEnd(Token lastToken) {
- nameEndToken = lastToken;
+ currName.setEnd(lastToken);
+ }
+
+
+ /**
+ * @see org.eclipse.cdt.internal.core.newparser.IParserCallback#simpleDeclarationEnd(java.lang.Object)
+ */
+ public void simpleDeclarationEnd(Object declaration) {
+ SimpleDeclarationWrapper wrapper = (SimpleDeclarationWrapper)declaration;
+ wrapper.createElements();
+ }
+
+ /**
+ * @see org.eclipse.cdt.internal.core.newparser.IParserCallback#simpleDeclSpecifier(java.lang.Object, org.eclipse.cdt.internal.core.newparser.Token)
+ */
+ public void simpleDeclSpecifier(Object declSpec, Token specifier) {
+ DeclSpecifier declSpecifier = (DeclSpecifier)declSpec;
+ declSpecifier.setType( specifier );
+ }
+
+ /**
+ * @see org.eclipse.cdt.internal.core.newparser.IParserCallback#declaratorId(java.lang.Object)
+ */
+ public void declaratorId(Object declarator) {
+ Declarator decl = (Declarator)declarator;
+ decl.setName( currName );
+ }
+
+
+ /**
+ * @see org.eclipse.cdt.internal.core.newparser.IParserCallback#argumentsBegin(java.lang.Object)
+ */
+ public Object argumentsBegin(Object declarator) {
+ Declarator decl = (Declarator)declarator;
+ List parameterDeclarationClause = new LinkedList();
+ decl.setParameterDeclarationClause( parameterDeclarationClause );
+ return parameterDeclarationClause;
+
+ }
+
+ /**
+ * @see org.eclipse.cdt.internal.core.newparser.IParserCallback#baseSpecifierBegin(java.lang.Object)
+ */
+ public Object baseSpecifierBegin(Object containingClassSpec) {
+ return null;
+ }
+
+ /**
+ * @see org.eclipse.cdt.internal.core.newparser.IParserCallback#baseSpecifierEnd(java.lang.Object)
+ */
+ public void baseSpecifierEnd(Object baseSpecifier) {
+ }
+
+ /**
+ * @see org.eclipse.cdt.internal.core.newparser.IParserCallback#baseSpecifierName(java.lang.Object)
+ */
+ public void baseSpecifierName(Object baseSpecifier) {
+ }
+
+ /**
+ * @see org.eclipse.cdt.internal.core.newparser.IParserCallback#baseSpecifierVirtual(java.lang.Object, boolean)
+ */
+ public void baseSpecifierVirtual(Object baseSpecifier, boolean virtual) {
+ }
+
+ /**
+ * @see org.eclipse.cdt.internal.core.newparser.IParserCallback#baseSpecifierVisibility(java.lang.Object, org.eclipse.cdt.internal.core.newparser.Token)
+ */
+ public void baseSpecifierVisibility(
+ Object baseSpecifier,
+ Token visibility) {
+ }
+
+ /**
+ * @see org.eclipse.cdt.internal.core.newparser.IParserCallback#expressionOperator(org.eclipse.cdt.internal.core.newparser.Token)
+ */
+ public void expressionOperator(Token operator) throws Exception {
+ }
+
+ /**
+ * @see org.eclipse.cdt.internal.core.newparser.IParserCallback#expressionTerminal(org.eclipse.cdt.internal.core.newparser.Token)
+ */
+ public void expressionTerminal(Token terminal) throws Exception {
+ }
+
+ /**
+ * @see org.eclipse.cdt.internal.core.newparser.IParserCallback#functionBodyEnd()
+ */
+ public void functionBodyEnd() {
+ }
+
+ /**
+ * @see org.eclipse.cdt.internal.core.newparser.IParserCallback#parameterDeclarationBegin(java.lang.Object, org.eclipse.cdt.internal.core.newparser.Token)
+ */
+ public Object parameterDeclarationBegin(
+ Object container ) {
+ List parameterDeclarationClause = (List)container;
+ Parameter p = new Parameter();
+ parameterDeclarationClause.add( p );
+ return p;
+
+ }
+
+ /**
+ * @see org.eclipse.cdt.internal.core.newparser.IParserCallback#parameterDeclarationEnd(java.lang.Object)
+ */
+ public void parameterDeclarationEnd(Object declaration) {
+ }
+
+ /**
+ * @see org.eclipse.cdt.internal.core.newparser.IParserCallback#translationUnitEnd(java.lang.Object)
+ */
+ public void translationUnitEnd(Object unit) {
+ }
+ /**
+ * @see org.eclipse.cdt.internal.core.newparser.IParserCallback#argumentsEnd()
+ */
+ public void argumentsEnd(Object parameterDeclarationClause) {
}
}
diff --git a/core/org.eclipse.cdt.core/newparser/org/eclipse/cdt/internal/core/model/Parameter.java b/core/org.eclipse.cdt.core/newparser/org/eclipse/cdt/internal/core/model/Parameter.java
new file mode 100644
index 0000000000..b4c24682ef
--- /dev/null
+++ b/core/org.eclipse.cdt.core/newparser/org/eclipse/cdt/internal/core/model/Parameter.java
@@ -0,0 +1,46 @@
+package org.eclipse.cdt.internal.core.model;
+
+import java.util.LinkedList;
+import java.util.List;
+
+import org.eclipse.cdt.internal.core.newparser.util.DeclSpecifier;
+import org.eclipse.cdt.internal.core.newparser.util.DeclarationSpecifier;
+
+/**
+ * @author jcamelon
+ *
+ * To change this generated comment edit the template variable "typecomment":
+ * Window>Preferences>Java>Templates.
+ * To enable and disable the creation of type comments go to
+ * Window>Preferences>Java>Code Generation.
+ */
+public class Parameter extends DeclSpecifier implements DeclarationSpecifier.Container
+{
+ DeclarationSpecifier declSpec = null;
+
+ /**
+ * @see org.eclipse.cdt.internal.core.dom.DeclarationSpecifier.CElementWrapper#getDeclSpecifier()
+ */
+ public DeclarationSpecifier getDeclSpecifier() {
+ if( declSpec == null )
+ declSpec = new DeclarationSpecifier();
+
+ return declSpec;
+ }
+
+ /**
+ * @see org.eclipse.cdt.internal.core.dom.DeclarationSpecifier.CElementWrapper#setDeclSpecifier(org.eclipse.cdt.internal.core.dom.DeclarationSpecifier)
+ */
+ public void setDeclSpecifier(DeclarationSpecifier in) {
+ declSpec = in;
+ }
+ private List declarators = new LinkedList();
+
+ public void addDeclarator(Object declarator) {
+ declarators.add(declarator);
+ }
+
+ public List getDeclarators() {
+ return declarators;
+ }
+}
diff --git a/core/org.eclipse.cdt.core/newparser/org/eclipse/cdt/internal/core/model/SimpleDeclarationWrapper.java b/core/org.eclipse.cdt.core/newparser/org/eclipse/cdt/internal/core/model/SimpleDeclarationWrapper.java
new file mode 100644
index 0000000000..eacc6630c2
--- /dev/null
+++ b/core/org.eclipse.cdt.core/newparser/org/eclipse/cdt/internal/core/model/SimpleDeclarationWrapper.java
@@ -0,0 +1,155 @@
+package org.eclipse.cdt.internal.core.model;
+
+import java.util.LinkedList;
+import java.util.List;
+
+import org.eclipse.cdt.core.model.IStructure;
+import org.eclipse.cdt.core.model.ITranslationUnit;
+import org.eclipse.cdt.internal.core.newparser.util.DeclSpecifier;
+import org.eclipse.cdt.internal.core.newparser.util.DeclarationSpecifier;
+
+/**
+ * @author jcamelon
+ *
+ * To change this generated comment edit the template variable "typecomment":
+ * Window>Preferences>Java>Templates.
+ * To enable and disable the creation of type comments go to
+ * Window>Preferences>Java>Code Generation.
+ */
+public class SimpleDeclarationWrapper extends DeclSpecifier implements DeclarationSpecifier.Container, ICElementWrapper {
+
+ private CElement element = null;
+ private CElement parent = null;
+
+ public SimpleDeclarationWrapper( CElement item )
+ {
+ this.element = item;
+ }
+
+ public SimpleDeclarationWrapper()
+ {
+ }
+
+ /**
+ * Returns the item.
+ * @return CElement
+ */
+ public CElement getElement() {
+ return element;
+ }
+
+ /**
+ * Sets the item.
+ * @param item The item to set
+ */
+ public void setElement (CElement item) {
+ this.element = (CElement)item;
+ }
+
+ /**
+ * Returns the parent.
+ * @return CElement
+ */
+ public CElement getParent() {
+ return parent;
+ }
+
+ /**
+ * Sets the parent.
+ * @param parent The parent to set
+ */
+ public void setParent(CElement parent) {
+ this.parent = parent;
+ }
+
+ public void createElements()
+ {
+ // creates the appropriate C Elements
+ List declaratorList = getDeclarators();
+ Declarator [] declarators = (Declarator []) declaratorList.toArray( new Declarator[ declaratorList.size() ] );
+ CElement parentElement = getParent();
+
+ for( int i = 0; i < declarators.length; ++i )
+ {
+ Declarator currentDeclarator = declarators[i];
+ CElement declaration = null;
+
+ // instantiate the right element
+ List clause =currentDeclarator.getParameterDeclarationClause();
+ if( clause == null )
+ {
+ // this is an attribute or a varaible
+ if( parentElement instanceof IStructure )
+ {
+ declaration = new Field( parentElement, currentDeclarator.getName().toString() );
+ }
+ else if( parentElement instanceof ITranslationUnit )
+ {
+ declaration = new Variable( parentElement, currentDeclarator.getName().toString() );
+ }
+ }
+ else
+ {
+ // this is a function or a method
+ if( parentElement instanceof IStructure )
+ {
+ declaration = new Method( parentElement, currentDeclarator.getName().toString() );
+
+ }
+ else if( parentElement instanceof ITranslationUnit )
+ {
+ declaration = new FunctionDeclaration( parentElement, currentDeclarator.getName().toString() );
+ }
+
+ Parameter [] parameters = (Parameter []) clause.toArray( new Parameter[ clause.size() ]);
+
+ for( int j = 0; j< parameters.length; ++j )
+ {
+ Parameter parm = parameters[j];
+
+ }
+
+ }
+
+ // hook up the offsets
+ declaration.setIdPos( currentDeclarator.getName().getEndOffset() - 2,currentDeclarator.getName().toString().length());
+ declaration.setPos( currentDeclarator.getName().getEndOffset(), currentDeclarator.getName().toString().length() );
+
+ // add to parent
+ parentElement.addChild( declaration );
+ }
+
+ }
+
+ List declarators = new LinkedList();
+
+ public void addDeclarator( Object in )
+ {
+ declarators.add( in );
+ }
+
+ public List getDeclarators()
+ {
+ return declarators;
+ }
+
+ DeclarationSpecifier declSpec = null;
+
+ /**
+ * @see org.eclipse.cdt.internal.core.dom.DeclarationSpecifier.CElementWrapper#getDeclSpecifier()
+ */
+ public DeclarationSpecifier getDeclSpecifier() {
+ if( declSpec == null )
+ declSpec = new DeclarationSpecifier();
+
+ return declSpec;
+ }
+
+ /**
+ * @see org.eclipse.cdt.internal.core.dom.DeclarationSpecifier.CElementWrapper#setDeclSpecifier(org.eclipse.cdt.internal.core.dom.DeclarationSpecifier)
+ */
+ public void setDeclSpecifier(DeclarationSpecifier in) {
+ declSpec = in;
+ }
+
+}
diff --git a/core/org.eclipse.cdt.core/newparser/org/eclipse/cdt/internal/core/model/TranslationUnitWrapper.java b/core/org.eclipse.cdt.core/newparser/org/eclipse/cdt/internal/core/model/TranslationUnitWrapper.java
new file mode 100644
index 0000000000..7284d69540
--- /dev/null
+++ b/core/org.eclipse.cdt.core/newparser/org/eclipse/cdt/internal/core/model/TranslationUnitWrapper.java
@@ -0,0 +1,32 @@
+package org.eclipse.cdt.internal.core.model;
+
+/**
+ * @author jcamelon
+ *
+ * To change this generated comment edit the template variable "typecomment":
+ * Window>Preferences>Java>Templates.
+ * To enable and disable the creation of type comments go to
+ * Window>Preferences>Java>Code Generation.
+ */
+public class TranslationUnitWrapper implements ICElementWrapper {
+
+ TranslationUnit unit = null;
+
+ /**
+ * @see org.eclipse.cdt.internal.core.model.IWrapper#getElement()
+ */
+ public CElement getElement() {
+ return unit;
+ }
+ /**
+ * @see org.eclipse.cdt.internal.core.model.IWrapper#setElement(java.lang.Object)
+ */
+ public void setElement(CElement item) {
+ unit = (TranslationUnit)item;
+ }
+
+ public TranslationUnitWrapper( )
+ {
+ }
+
+}
diff --git a/core/org.eclipse.cdt.core/newparser/org/eclipse/cdt/internal/core/newparser/IParserCallback.java b/core/org.eclipse.cdt.core/newparser/org/eclipse/cdt/internal/core/newparser/IParserCallback.java
index 18a0963a87..5e6b2fb378 100644
--- a/core/org.eclipse.cdt.core/newparser/org/eclipse/cdt/internal/core/newparser/IParserCallback.java
+++ b/core/org.eclipse.cdt.core/newparser/org/eclipse/cdt/internal/core/newparser/IParserCallback.java
@@ -19,10 +19,10 @@ public interface IParserCallback {
public void inclusionEnd();
public void macro(String macroName);
- public Object simpleDeclarationBegin(Object Container, Token firstToken);
+ public Object simpleDeclarationBegin(Object Container);
public void simpleDeclarationEnd(Object declaration);
- public Object parameterDeclarationBegin( Object Container, Token firstToken );
+ public Object parameterDeclarationBegin( Object Container );
public void parameterDeclarationEnd( Object declaration );
public void simpleDeclSpecifier(Object Container, Token specifier);
@@ -33,7 +33,7 @@ public interface IParserCallback {
public Object declaratorBegin(Object container);
public void declaratorId(Object declarator);
public Object argumentsBegin( Object declarator );
- public void argumentsEnd();
+ public void argumentsEnd(Object parameterDeclarationClause);
public void declaratorEnd(Object declarator);
public void functionBodyBegin();
diff --git a/core/org.eclipse.cdt.core/newparser/org/eclipse/cdt/internal/core/newparser/NullParserCallback.java b/core/org.eclipse.cdt.core/newparser/org/eclipse/cdt/internal/core/newparser/NullParserCallback.java
index e4d5af5fa3..ce46d1a7d5 100644
--- a/core/org.eclipse.cdt.core/newparser/org/eclipse/cdt/internal/core/newparser/NullParserCallback.java
+++ b/core/org.eclipse.cdt.core/newparser/org/eclipse/cdt/internal/core/newparser/NullParserCallback.java
@@ -37,7 +37,7 @@ public class NullParserCallback implements IParserCallback {
/**
* @see org.eclipse.cdt.internal.core.newparser.IParserCallback#beginSimpleDeclaration(Token)
*/
- public Object simpleDeclarationBegin(Object Container, Token firstToken) {
+ public Object simpleDeclarationBegin(Object Container) {
return null;
}
@@ -63,7 +63,7 @@ public class NullParserCallback implements IParserCallback {
/**
* @see org.eclipse.cdt.internal.core.newparser.IParserCallback#endArguments()
*/
- public void argumentsEnd() {
+ public void argumentsEnd(Object parameterDeclarationClause) {
}
/**
@@ -159,7 +159,7 @@ public class NullParserCallback implements IParserCallback {
{
}
- public Object parameterDeclarationBegin( Object container, Token firstToken )
+ public Object parameterDeclarationBegin( Object container )
{
return null;
}
diff --git a/core/org.eclipse.cdt.core/newparser/org/eclipse/cdt/internal/core/newparser/Parser.java b/core/org.eclipse.cdt.core/newparser/org/eclipse/cdt/internal/core/newparser/Parser.java
index 545850aa04..1c6b8e9e5a 100644
--- a/core/org.eclipse.cdt.core/newparser/org/eclipse/cdt/internal/core/newparser/Parser.java
+++ b/core/org.eclipse.cdt.core/newparser/org/eclipse/cdt/internal/core/newparser/Parser.java
@@ -156,7 +156,7 @@ c, quick);
* - work in ctorInitializer and functionTryBlock
*/
public void simpleDeclaration( Object container ) throws Exception {
- Object simpleDecl = callback.simpleDeclarationBegin( container, LA(1));
+ Object simpleDecl = callback.simpleDeclarationBegin( container);
declSpecifierSeq(simpleDecl);
if (LT(1) != Token.tSEMI)
@@ -215,7 +215,7 @@ c, quick);
public void parameterDeclaration( Object containerObject ) throws Exception
{
- Object parameterDecl = callback.parameterDeclarationBegin( containerObject, LA(1) );
+ Object parameterDecl = callback.parameterDeclarationBegin( containerObject );
declSpecifierSeq( parameterDecl );
if (LT(1) != Token.tSEMI)
@@ -421,7 +421,7 @@ c, quick);
parameterDeclaration( clause );
}
}
- callback.argumentsEnd();
+ callback.argumentsEnd(clause);
break;
case Token.tLBRACKET:
consume();
diff --git a/core/org.eclipse.cdt.core/newparser/org/eclipse/cdt/internal/core/newparser/util/DeclSpecifier.java b/core/org.eclipse.cdt.core/newparser/org/eclipse/cdt/internal/core/newparser/util/DeclSpecifier.java
new file mode 100644
index 0000000000..e0d41d6fc9
--- /dev/null
+++ b/core/org.eclipse.cdt.core/newparser/org/eclipse/cdt/internal/core/newparser/util/DeclSpecifier.java
@@ -0,0 +1,188 @@
+package org.eclipse.cdt.internal.core.newparser.util;
+
+import org.eclipse.cdt.internal.core.newparser.Token;
+
+/**
+ * @author jcamelon
+ *
+ * To change this generated comment edit the template variable "typecomment":
+ * Window>Preferences>Java>Templates.
+ * To enable and disable the creation of type comments go to
+ * Window>Preferences>Java>Code Generation.
+ */
+public class DeclSpecifier {
+
+ // DeclSpecifier layed out as bit array
+ // leftmost 5 bits are type
+ public static final int typeMask = 0x001f;
+ public static final int isAuto = 0x0020;
+ public static final int isRegister = 0x0040;
+ public static final int isStatic = 0x0080;
+ public static final int isExtern = 0x0100;
+ public static final int isMutable = 0x0200;
+ public static final int isInline = 0x0400;
+ public static final int isVirtual = 0x0800;
+ public static final int isExplicit = 0x1000;
+ public static final int isTypedef = 0x2000;
+ public static final int isFriend = 0x4000;
+ public static final int isConst = 0x8000;
+ public static final int isVolatile = 0x10000;
+ public static final int isUnsigned = 0x20000;
+ public static final int isShort = 0x40000;
+ public static final int isLong = 0x80000;
+
+ private int declSpecifierSeq = 0;
+ public int getDeclSpecifierSeq() { return declSpecifierSeq; }
+
+ // Convenience methods
+ private void setBit(boolean b, int mask) {
+ if (b)
+ declSpecifierSeq = declSpecifierSeq | mask;
+ else
+ declSpecifierSeq = declSpecifierSeq & ~mask;
+ }
+
+ private boolean checkBit(int mask) {
+ return (declSpecifierSeq & mask) == 1;
+ }
+
+ public void setAuto(boolean b) { setBit(b, isAuto); }
+ public boolean isAuto() { return checkBit(isAuto); }
+
+ public void setRegister(boolean b) { setBit(b, isRegister); }
+ public boolean isRegister() { return checkBit(isRegister); }
+
+ public void setStatic(boolean b) { setBit(b, isStatic); }
+ public boolean isStatic() { return checkBit(isStatic); }
+
+ public void setExtern(boolean b) { setBit(b, isExtern); }
+ public boolean isExtern() { return checkBit(isExtern); }
+
+ public void setMutable(boolean b) { setBit(b, isMutable); }
+ public boolean isMutable() { return checkBit(isMutable); }
+
+ public void setInline(boolean b) { setBit(b, isInline); }
+ public boolean isInline() { return checkBit(isInline); }
+
+ public void setVirtual(boolean b) { setBit(b, isVirtual); }
+ public boolean isVirtual() { return checkBit(isVirtual); }
+
+ public void setExplicit(boolean b) { setBit(b, isExplicit); }
+ public boolean isExplicit() { return checkBit(isExplicit); }
+
+ public void setTypedef(boolean b) { setBit(b, isTypedef); }
+ public boolean isTypedef() { return checkBit(isTypedef); }
+
+ public void setFriend(boolean b) { setBit(b, isFriend); }
+ public boolean isFriend() { return checkBit(isFriend); }
+
+ public void setConst(boolean b) { setBit(b, isConst); }
+ public boolean isConst() { return checkBit(isConst); }
+
+ public void setVolatile(boolean b) { setBit(b, isVolatile); }
+ public boolean isVolatile() { return checkBit(isVolatile); }
+
+ public void setUnsigned(boolean b) { setBit(b, isUnsigned); }
+ public boolean isUnsigned() { return checkBit(isUnsigned); }
+
+ public void setShort(boolean b) { setBit(b, isShort); }
+ public boolean isShort() { return checkBit(isShort); }
+
+ public void setLong(boolean b) { setBit(b, isLong); }
+ public boolean isLong() { return checkBit(isLong); }
+
+ // Simple Types
+ public static final int t_type = 0; // Type Specifier
+ public static final int t_char = 1;
+ public static final int t_wchar_t = 2;
+ public static final int t_bool = 3;
+ public static final int t_int = 4;
+ public static final int t_float = 5;
+ public static final int t_double = 6;
+ public static final int t_void = 7;
+
+ public void setType( Token token )
+ {
+ switch (token.getType()) {
+ case Token.t_auto:
+ setAuto(true);
+ break;
+ case Token.t_register:
+ setRegister(true);
+ break;
+ case Token.t_static:
+ setStatic(true);
+ break;
+ case Token.t_extern:
+ setExtern(true);
+ break;
+ case Token.t_mutable:
+ setMutable(true);
+ break;
+ case Token.t_inline:
+ setInline(true);
+ break;
+ case Token.t_virtual:
+ setVirtual(true);
+ break;
+ case Token.t_explicit:
+ setExplicit(true);
+ break;
+ case Token.t_typedef:
+ setTypedef(true);
+ break;
+ case Token.t_friend:
+ setFriend(true);
+ break;
+ case Token.t_const:
+ setConst(true);
+ break;
+ case Token.t_volatile:
+ setVolatile(true);
+ break;
+ case Token.t_char:
+ setType(DeclarationSpecifier.t_char);
+ break;
+ case Token.t_wchar_t:
+ setType(DeclarationSpecifier.t_wchar_t);
+ break;
+ case Token.t_bool:
+ setType(DeclarationSpecifier.t_bool);
+ break;
+ case Token.t_short:
+ setShort(true);
+ break;
+ case Token.t_int:
+ setType(DeclarationSpecifier.t_int);
+ break;
+ case Token.t_long:
+ setLong(true);
+ break;
+ case Token.t_signed:
+ setUnsigned(false);
+ break;
+ case Token.t_unsigned:
+ setUnsigned(true);
+ break;
+ case Token.t_float:
+ setType(DeclarationSpecifier.t_float);
+ break;
+ case Token.t_double:
+ setType(DeclarationSpecifier.t_double);
+ break;
+ case Token.t_void:
+ setType(DeclarationSpecifier.t_void);
+ break;
+ }
+
+ }
+
+ public void setType(int t) {
+ declSpecifierSeq = declSpecifierSeq & ~typeMask | t;
+ }
+
+ public int getType() {
+ return declSpecifierSeq & typeMask;
+ }
+
+}
diff --git a/core/org.eclipse.cdt.core/newparser/org/eclipse/cdt/internal/core/newparser/util/DeclarationSpecifier.java b/core/org.eclipse.cdt.core/newparser/org/eclipse/cdt/internal/core/newparser/util/DeclarationSpecifier.java
new file mode 100644
index 0000000000..a7188fc17f
--- /dev/null
+++ b/core/org.eclipse.cdt.core/newparser/org/eclipse/cdt/internal/core/newparser/util/DeclarationSpecifier.java
@@ -0,0 +1,25 @@
+package org.eclipse.cdt.internal.core.newparser.util;
+
+import java.util.List;
+
+/**
+ * @author jcamelon
+ *
+ * To change this generated comment edit the template variable "typecomment":
+ * Window>Preferences>Java>Templates.
+ * To enable and disable the creation of type comments go to
+ * Window>Preferences>Java>Code Generation.
+ */
+public class DeclarationSpecifier extends DeclSpecifier {
+
+ public interface Container {
+
+ public DeclarationSpecifier getDeclSpecifier();
+
+ public void setDeclSpecifier( DeclarationSpecifier in );
+
+ public void addDeclarator(Object declarator);
+ public List getDeclarators();
+
+ };
+}
diff --git a/core/org.eclipse.cdt.core/newparser/org/eclipse/cdt/internal/core/newparser/util/Name.java b/core/org.eclipse.cdt.core/newparser/org/eclipse/cdt/internal/core/newparser/util/Name.java
new file mode 100644
index 0000000000..ab2a21fecc
--- /dev/null
+++ b/core/org.eclipse.cdt.core/newparser/org/eclipse/cdt/internal/core/newparser/util/Name.java
@@ -0,0 +1,46 @@
+package org.eclipse.cdt.internal.core.newparser.util;
+
+import org.eclipse.cdt.internal.core.newparser.Token;
+
+
+/**
+ * @author dschaefe
+ *
+ * To change this generated comment edit the template variable "typecomment":
+ * Window>Preferences>Java>Templates.
+ * To enable and disable the creation of type comments go to
+ * Window>Preferences>Java>Code Generation.
+ */
+public class Name {
+
+ private Token nameStart, nameEnd;
+
+ public Name(Token nameStart) {
+ this.nameStart = nameStart;
+ }
+
+ public void setEnd(Token nameEnd) {
+ this.nameEnd = nameEnd;
+ }
+
+ public int getStartOffset()
+ {
+ return nameStart.offset;
+ }
+
+ public int getEndOffset()
+ {
+ return nameEnd.offset;
+ }
+
+ public String toString() {
+ String name = nameStart.getImage();
+
+ for (Token t = nameStart; nameStart != nameEnd;) {
+ t = nameStart.getNext();
+ name += t.getImage();
+ }
+
+ return name;
+ }
+}

Back to the top