Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorAlain Magloire2003-04-01 18:52:37 +0000
committerAlain Magloire2003-04-01 18:52:37 +0000
commitaacea7223cbaa112b8e930fd2f33739b1da73851 (patch)
treefc8582b58c680353895c9ba0a06614340c60cf1b
parent1c8649d6fdcab50e4458633db6e3945a6c846c5f (diff)
downloadorg.eclipse.cdt-aacea7223cbaa112b8e930fd2f33739b1da73851.tar.gz
org.eclipse.cdt-aacea7223cbaa112b8e930fd2f33739b1da73851.tar.xz
org.eclipse.cdt-aacea7223cbaa112b8e930fd2f33739b1da73851.zip
Fixed unsigned short Simpledeclartions not showing up in the
outline view
-rw-r--r--core/org.eclipse.cdt.core/dom/org/eclipse/cdt/internal/core/dom/DOMBuilder.java2
-rw-r--r--core/org.eclipse.cdt.core/parser/ChangeLog7
-rw-r--r--core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/model/EnumerationWrapper.java82
-rw-r--r--core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/model/EnumeratorWrapper.java53
-rw-r--r--core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/model/ICElementWrapper.java6
-rw-r--r--core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/model/NewModelBuilder.java116
-rw-r--r--core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/model/SimpleDeclarationWrapper.java91
-rw-r--r--core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/model/TranslationUnitWrapper.java6
-rw-r--r--core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/parser/ExpressionEvaluator.java2
-rw-r--r--core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/parser/IParserCallback.java2
-rw-r--r--core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/parser/NullParserCallback.java2
-rw-r--r--core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/parser/Parser.java6
-rw-r--r--core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/parser/Scanner.java10
-rw-r--r--core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/parser/Token.java4
14 files changed, 305 insertions, 84 deletions
diff --git a/core/org.eclipse.cdt.core/dom/org/eclipse/cdt/internal/core/dom/DOMBuilder.java b/core/org.eclipse.cdt.core/dom/org/eclipse/cdt/internal/core/dom/DOMBuilder.java
index efe51de205c..e2583ad60ac 100644
--- a/core/org.eclipse.cdt.core/dom/org/eclipse/cdt/internal/core/dom/DOMBuilder.java
+++ b/core/org.eclipse.cdt.core/dom/org/eclipse/cdt/internal/core/dom/DOMBuilder.java
@@ -600,7 +600,7 @@ public class DOMBuilder implements IParserCallback
/* (non-Javadoc)
* @see org.eclipse.cdt.internal.core.parser.IParserCallback#enumSpecifierBegin(java.lang.Object)
*/
- public Object enumSpecifierBegin(Object container) {
+ public Object enumSpecifierBegin(Object container, Token enumKey) {
SimpleDeclaration decl = (SimpleDeclaration)container;
EnumerationSpecifier es = new EnumerationSpecifier( decl );
decl.setTypeSpecifier(es);
diff --git a/core/org.eclipse.cdt.core/parser/ChangeLog b/core/org.eclipse.cdt.core/parser/ChangeLog
index bb3a17b7e57..d5fff579785 100644
--- a/core/org.eclipse.cdt.core/parser/ChangeLog
+++ b/core/org.eclipse.cdt.core/parser/ChangeLog
@@ -1,3 +1,10 @@
+2003-03-31 John Camelon
+ Fixed unsigned short SimpleDeclarations not showing up in the outline view.
+ Fixed default visibilities for structs in outline view.
+ Fixed bug35892.
+ Added icon-less typedefs and enums to the outline view.
+ Fixed NPEs relating to anonymous structs, unions, enums in outline view.
+
2003-03-31 Andrew Niefer
Parser Symbol Table, better support for function resolution with pointers and
references as parameters. Also support for typedefs as function parameters
diff --git a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/model/EnumerationWrapper.java b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/model/EnumerationWrapper.java
new file mode 100644
index 00000000000..d34fefba607
--- /dev/null
+++ b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/model/EnumerationWrapper.java
@@ -0,0 +1,82 @@
+/**********************************************************************
+ * Created on Apr 1, 2003
+ *
+ * Copyright (c) 2002,2003 Rational Software Corporation and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Common Public License v0.5
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/cpl-v05.html
+ *
+ * Contributors:
+ * Rational Software - Initial API and implementation
+***********************************************************************/
+package org.eclipse.cdt.internal.core.model;
+
+import java.util.ArrayList;
+import java.util.List;
+
+import org.eclipse.cdt.core.model.IParent;
+import org.eclipse.cdt.internal.core.parser.Token;
+import org.eclipse.cdt.internal.core.parser.util.Name;
+
+/**
+ * @author jcamelon
+ *
+ */
+public class EnumerationWrapper {
+
+ private Name name;
+ private List enumerators = new ArrayList();
+ private final IParent parent;
+ private final Token key;
+
+ public EnumerationWrapper( IParent incoming, Token enumKey )
+ {
+ this.parent= incoming;
+ key = enumKey;
+ }
+
+ /**
+ * @return Name
+ */
+ public Name getName() {
+ return name;
+ }
+
+ /**
+ * Sets the name.
+ * @param name The name to set
+ */
+ public void setName(Name name) {
+ this.name = name;
+ }
+
+
+
+ /**
+ * @return List
+ */
+ public List getEnumerators() {
+ return enumerators;
+ }
+
+ public void addEnumerator( EnumeratorWrapper in )
+ {
+ enumerators.add( in );
+ }
+
+ /**
+ * @return ICElementWrapper
+ */
+ public IParent getParent() {
+ return parent;
+ }
+
+ /**
+ * @return Token
+ */
+ public Token getClassKind() {
+ return key;
+ }
+
+}
diff --git a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/model/EnumeratorWrapper.java b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/model/EnumeratorWrapper.java
new file mode 100644
index 00000000000..bc21c5764e9
--- /dev/null
+++ b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/model/EnumeratorWrapper.java
@@ -0,0 +1,53 @@
+/**********************************************************************
+ * Created on Apr 1, 2003
+ *
+ * Copyright (c) 2002,2003 Rational Software Corporation and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Common Public License v0.5
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/cpl-v05.html
+ *
+ * Contributors:
+ * Rational Software - Initial API and implementation
+***********************************************************************/
+package org.eclipse.cdt.internal.core.model;
+
+import org.eclipse.cdt.internal.core.parser.util.Name;
+
+/**
+ * @author jcamelon
+ *
+ */
+public class EnumeratorWrapper {
+
+ private final EnumerationWrapper parent;
+ private Name name;
+
+ EnumeratorWrapper( EnumerationWrapper myParent )
+ {
+ this.parent = myParent;
+ }
+
+ /**
+ * @return Name
+ */
+ public Name getName() {
+ return name;
+ }
+
+ /**
+ * @return EnumerationWrapper
+ */
+ public EnumerationWrapper getParent() {
+ return parent;
+ }
+
+ /**
+ * Sets the name.
+ * @param name The name to set
+ */
+ public void setName(Name name) {
+ this.name = name;
+ }
+
+}
diff --git a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/model/ICElementWrapper.java b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/model/ICElementWrapper.java
index 5f3db2b35d1..d82c5d1a8b9 100644
--- a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/model/ICElementWrapper.java
+++ b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/model/ICElementWrapper.java
@@ -1,5 +1,7 @@
package org.eclipse.cdt.internal.core.model;
+import org.eclipse.cdt.core.model.IParent;
+
/**
* @author jcamelon
*
@@ -10,6 +12,6 @@ package org.eclipse.cdt.internal.core.model;
*/
public interface ICElementWrapper {
- public CElement getElement();
- public void setElement (CElement item);
+ public IParent getElement();
+ public void setElement (IParent item);
}
diff --git a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/model/NewModelBuilder.java b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/model/NewModelBuilder.java
index 5f1869ebdd7..bd47677a974 100644
--- a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/model/NewModelBuilder.java
+++ b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/model/NewModelBuilder.java
@@ -10,6 +10,7 @@
******************************************************************************/
package org.eclipse.cdt.internal.core.model;
+import java.util.Iterator;
import java.util.LinkedList;
import java.util.List;
@@ -44,20 +45,20 @@ public class NewModelBuilder implements IParserCallback {
{
SimpleDeclarationWrapper c = (SimpleDeclarationWrapper)container;
- int kind;
- switch (classKey.getType()) {
+ SimpleDeclarationWrapper wrapper = new SimpleDeclarationWrapper();
+ wrapper.setClassKind( classKey );
+ switch( classKey.getType() )
+ {
case Token.t_class:
- kind = ICElement.C_CLASS;
+ wrapper.setCurrentVisibility( AccessSpecifier.v_private );
break;
case Token.t_struct:
- kind = ICElement.C_STRUCT;
+ case Token.t_union:
+ wrapper.setCurrentVisibility( AccessSpecifier.v_public );
break;
- default:
- kind = ICElement.C_UNION;
}
- SimpleDeclarationWrapper wrapper = new SimpleDeclarationWrapper();
- wrapper.setKind( kind );
+
wrapper.setParent( c.getParent() );
return wrapper;
@@ -138,7 +139,7 @@ org.eclipse.cdt.internal.core.newparser.IParserCallback#beginSimpleDeclaration(T
Object parent = wrapper.getElement();
SimpleDeclarationWrapper result = new SimpleDeclarationWrapper();
if( wrapper instanceof SimpleDeclarationWrapper ){
- result.setParent( (CElement)wrapper.getElement() );
+ result.setParent( wrapper.getElement() );
result.setCurrentVisibility(((SimpleDeclarationWrapper)wrapper).getCurrentVisibility());
} else if ( wrapper instanceof TranslationUnitWrapper )
result.setParent( (TranslationUnit)wrapper.getElement());
@@ -331,13 +332,36 @@ org.eclipse.cdt.internal.core.newparser.IParserCallback#beginSimpleDeclaration(T
*/
public void classSpecifierSafe(Object classSpecifier) {
SimpleDeclarationWrapper wrapper = (SimpleDeclarationWrapper)classSpecifier;
- Structure elem = new Structure( wrapper.getParent(), wrapper.getKind(), null );
+ int kind;
+
+ switch( wrapper.getClassKind().getType() )
+ {
+ case Token.t_class:
+ kind = ICElement.C_CLASS;
+ break;
+ case Token.t_struct:
+ kind = ICElement.C_STRUCT;
+ break;
+ default:
+ kind = ICElement.C_UNION;
+ break;
+ }
+ Structure elem = new Structure( (CElement)wrapper.getParent(), kind, null );
wrapper.setElement( elem );
- wrapper.getParent().addChild(elem);
- String name = wrapper.getName().toString();
- elem.setElementName( name );
- elem.setIdPos(wrapper.getName().getStartOffset(), name.length());
- elem.setPos(wrapper.getName().getStartOffset(), name.length());
+ ((Parent)wrapper.getParent()).addChild(elem);
+
+ String elementName = ( wrapper.getName() == null ) ? "" : wrapper.getName().toString();
+ elem.setElementName( elementName );
+ if( wrapper.getName() != null )
+ {
+ elem.setIdPos(wrapper.getName().getStartOffset(), elementName.length());
+ elem.setPos(wrapper.getName().getStartOffset(), elementName.length());
+ }
+ else
+ {
+ elem.setIdPos(wrapper.getClassKind().getOffset(), wrapper.getClassKind().getLength());
+ elem.setPos(wrapper.getClassKind().getOffset(), wrapper.getClassKind().getLength());
+ }
}
/**
* @see org.eclipse.cdt.internal.core.parser.IParserCallback#elaboratedTypeSpecifierBegin(java.lang.Object)
@@ -346,21 +370,9 @@ org.eclipse.cdt.internal.core.newparser.IParserCallback#beginSimpleDeclaration(T
if( container instanceof SimpleDeclarationWrapper )
{
SimpleDeclarationWrapper c = (SimpleDeclarationWrapper)container;
-
- int kind;
- switch (classKey.getType()) {
- case Token.t_class:
- kind = ICElement.C_CLASS;
- break;
- case Token.t_struct:
- kind = ICElement.C_STRUCT;
- break;
- default:
- kind = ICElement.C_UNION;
- }
-
+
SimpleDeclarationWrapper wrapper = new SimpleDeclarationWrapper();
- wrapper.setKind( kind );
+ wrapper.setClassKind( classKey );
wrapper.setParent( c.getParent() );
return wrapper;
@@ -373,6 +385,7 @@ org.eclipse.cdt.internal.core.newparser.IParserCallback#beginSimpleDeclaration(T
* @see org.eclipse.cdt.internal.core.parser.IParserCallback#elaboratedTypeSpecifierEnd(java.lang.Object)
*/
public void elaboratedTypeSpecifierEnd(Object elab) {
+ SimpleDeclarationWrapper wrapper = (SimpleDeclarationWrapper)elab;
}
/**
@@ -640,14 +653,17 @@ org.eclipse.cdt.internal.core.newparser.IParserCallback#beginSimpleDeclaration(T
/* (non-Javadoc)
* @see org.eclipse.cdt.internal.core.parser.IParserCallback#enumSpecifierBegin(java.lang.Object)
*/
- public Object enumSpecifierBegin(Object container) {
- return null;
+ public Object enumSpecifierBegin(Object container, Token enumKey) {
+ SimpleDeclarationWrapper c = (SimpleDeclarationWrapper)container;
+ EnumerationWrapper wrapper = new EnumerationWrapper(c.getParent(), enumKey );
+ return wrapper;
}
/* (non-Javadoc)
* @see org.eclipse.cdt.internal.core.parser.IParserCallback#enumSpecifierId(java.lang.Object)
*/
public void enumSpecifierId(Object enumSpec) {
+ ((EnumerationWrapper)enumSpec).setName( currName );
}
/* (non-Javadoc)
@@ -661,25 +677,60 @@ org.eclipse.cdt.internal.core.newparser.IParserCallback#beginSimpleDeclaration(T
* @see org.eclipse.cdt.internal.core.parser.IParserCallback#enumSpecifierEnd(java.lang.Object)
*/
public void enumSpecifierEnd(Object enumSpec) {
+ EnumerationWrapper wrapper = (EnumerationWrapper)enumSpec;
+
+ List enumerators = wrapper.getEnumerators();
+
+ Parent realParent = (Parent)wrapper.getParent();
+ String enumName = ( wrapper.getName() == null ) ? "" : wrapper.getName().toString();
+ Enumeration enumeration = new Enumeration( (ICElement)realParent, enumName );
+ realParent.addChild( enumeration );
+
+ // create the list
+ Iterator i = enumerators.iterator();
+ while( i.hasNext())
+ {
+ EnumeratorWrapper subwrapper = (EnumeratorWrapper)i.next();
+ Enumerator enumerator = new Enumerator( enumeration, subwrapper.getName().toString() );
+ enumeration.addChild( enumerator );
+ }
+
+ // do the offsets
+ if( wrapper.getName() != null )
+ {
+ elem.setIdPos(wrapper.getName().getStartOffset(), enumName.length());
+ elem.setPos(wrapper.getName().getStartOffset(), enumName.length());
+ }
+ else
+ {
+ elem.setIdPos(wrapper.getClassKind().getOffset(), wrapper.getClassKind().getLength());
+ elem.setPos(wrapper.getClassKind().getOffset(), wrapper.getClassKind().getLength());
+ }
}
/* (non-Javadoc)
* @see org.eclipse.cdt.internal.core.parser.IParserCallback#enumDefinitionBegin(java.lang.Object)
*/
public Object enumDefinitionBegin(Object enumSpec) {
- return null;
+ EnumerationWrapper wrapper = (EnumerationWrapper)enumSpec;
+ EnumeratorWrapper result = new EnumeratorWrapper(wrapper);
+ return result;
}
/* (non-Javadoc)
* @see org.eclipse.cdt.internal.core.parser.IParserCallback#enumDefinitionId(java.lang.Object)
*/
public void enumDefinitionId(Object enumDefn) {
+ EnumeratorWrapper wrapper = (EnumeratorWrapper)enumDefn;
+ wrapper.setName( currName );
}
/* (non-Javadoc)
* @see org.eclipse.cdt.internal.core.parser.IParserCallback#enumDefinitionEnd(java.lang.Object)
*/
public void enumDefinitionEnd(Object enumDefn) {
+ EnumeratorWrapper wrapper = (EnumeratorWrapper)enumDefn;
+ wrapper.getParent().addEnumerator( wrapper );
}
/* (non-Javadoc)
@@ -687,7 +738,6 @@ org.eclipse.cdt.internal.core.newparser.IParserCallback#beginSimpleDeclaration(T
*/
public void asmDefinition(Object container, String assemblyCode) {
// TODO Auto-generated method stub
-
}
/* (non-Javadoc)
diff --git a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/model/SimpleDeclarationWrapper.java b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/model/SimpleDeclarationWrapper.java
index f8963f66622..e8ecefcc464 100644
--- a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/model/SimpleDeclarationWrapper.java
+++ b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/model/SimpleDeclarationWrapper.java
@@ -3,8 +3,10 @@ package org.eclipse.cdt.internal.core.model;
import java.util.LinkedList;
import java.util.List;
+import org.eclipse.cdt.core.model.IParent;
import org.eclipse.cdt.core.model.IStructure;
import org.eclipse.cdt.core.model.ITranslationUnit;
+import org.eclipse.cdt.internal.core.parser.Token;
import org.eclipse.cdt.internal.core.parser.util.AccessSpecifier;
import org.eclipse.cdt.internal.core.parser.util.DeclSpecifier;
import org.eclipse.cdt.internal.core.parser.util.Name;
@@ -19,13 +21,13 @@ import org.eclipse.cdt.internal.core.parser.util.Name;
*/
public class SimpleDeclarationWrapper extends DeclSpecifier implements DeclSpecifier.Container, ICElementWrapper {
- private CElement element = null;
- private CElement parent = null;
- int kind;
+ private IParent element = null;
+ private IParent parent = null;
+
private Name name = null;
private boolean functionDefinition = false;
- public SimpleDeclarationWrapper( CElement item )
+ public SimpleDeclarationWrapper( IParent item )
{
this.element = item;
}
@@ -38,7 +40,7 @@ public class SimpleDeclarationWrapper extends DeclSpecifier implements DeclSpeci
* Returns the item.
* @return CElement
*/
- public CElement getElement() {
+ public IParent getElement() {
return element;
}
@@ -46,15 +48,15 @@ public class SimpleDeclarationWrapper extends DeclSpecifier implements DeclSpeci
* Sets the item.
* @param item The item to set
*/
- public void setElement (CElement item) {
- this.element = (CElement)item;
+ public void setElement (IParent item) {
+ this.element = (IParent)item;
}
/**
* Returns the parent.
* @return CElement
*/
- public CElement getParent() {
+ public IParent getParent() {
return parent;
}
@@ -62,7 +64,7 @@ public class SimpleDeclarationWrapper extends DeclSpecifier implements DeclSpeci
* Sets the parent.
* @param parent The parent to set
*/
- public void setParent(CElement parent) {
+ public void setParent(IParent parent) {
this.parent = parent;
}
@@ -71,7 +73,7 @@ public class SimpleDeclarationWrapper extends DeclSpecifier implements DeclSpeci
// creates the appropriate C Elements
List declaratorList = getDeclarators();
Declarator [] declarators = (Declarator []) declaratorList.toArray( new Declarator[ declaratorList.size() ] );
- CElement parentElement = getParent();
+ CElement parentElement = (CElement)getParent();
for( int i = 0; i < declarators.length; ++i )
{
@@ -80,6 +82,7 @@ public class SimpleDeclarationWrapper extends DeclSpecifier implements DeclSpeci
// instantiate the right element
List clause =currentDeclarator.getParameterDeclarationClause();
+ String declaratorName = ( currentDeclarator.getName() == null ) ? "" : currentDeclarator.getName().toString();
if( clause == null && !isTypedef())
{
// TODO - this was to get rid of the NULL pointer we've been seeing
@@ -89,24 +92,23 @@ public class SimpleDeclarationWrapper extends DeclSpecifier implements DeclSpeci
// this is an attribute or a varaible
if( parentElement instanceof IStructure )
{
- declaration = createField( parentElement, currentDeclarator.getName().toString() );
+ declaration = createField( parentElement, declaratorName );
}
else if( parentElement instanceof ITranslationUnit )
{
if(isExtern())
{
- declaration = createVariableDeclaration( parentElement, currentDeclarator.getName().toString() );
+ declaration = createVariableDeclaration( parentElement, declaratorName );
}
else
{
- declaration = createVariable( parentElement, currentDeclarator.getName().toString() );
+ declaration = createVariable( parentElement, declaratorName );
}
}
}
else if( isTypedef() )
{
- // do nothing just yet
- //TODO : update this -- typedefs do not have a parameterdeclarationclause
+ declaration = createTypedef( parentElement, declaratorName );
}
else
{
@@ -114,7 +116,7 @@ public class SimpleDeclarationWrapper extends DeclSpecifier implements DeclSpeci
// this is a function or a method
if( parentElement instanceof IStructure )
{
- declaration = createMethodDeclaration( parentElement, currentDeclarator.getName().toString(), parameters );
+ declaration = createMethodDeclaration( parentElement, declaratorName, parameters );
}
else if( parentElement instanceof ITranslationUnit )
@@ -124,18 +126,27 @@ public class SimpleDeclarationWrapper extends DeclSpecifier implements DeclSpeci
// if it belongs to a class, then create a method
// else create a function
// this will not be known until we have cross reference information
- declaration = createFunction( parentElement, currentDeclarator.getName().toString(), parameters );
+ declaration = createFunction( parentElement, declaratorName, parameters );
}
else
{
- declaration = createFunctionDeclaration( parentElement, currentDeclarator.getName().toString(), parameters );
+ declaration = createFunctionDeclaration( parentElement, declaratorName, parameters );
}
}
}
- // hook up the offsets
- declaration.setIdPos( currentDeclarator.getName().getStartOffset(), currentDeclarator.getName().toString().length());
- declaration.setPos( currentDeclarator.getName().getStartOffset(), currentDeclarator.getName().toString().length() );
+
+ if( currentDeclarator.getName() != null )
+ {
+ // hook up the offsets
+ declaration.setIdPos( currentDeclarator.getName().getStartOffset(), declaratorName.length());
+ declaration.setPos( currentDeclarator.getName().getStartOffset(), declaratorName.length() );
+ }
+ else
+ {
+ declaration.setIdPos( classKind.getOffset(), classKind.getImage().toString().length());
+ declaration.setPos( classKind.getOffset(), classKind.getImage().toString().length());
+ }
// add to parent
parentElement.addChild( declaration );
@@ -144,6 +155,7 @@ public class SimpleDeclarationWrapper extends DeclSpecifier implements DeclSpeci
}
List declarators = new LinkedList();
+ String [] myString;
public void addDeclarator( Object in )
{
@@ -197,21 +209,7 @@ public class SimpleDeclarationWrapper extends DeclSpecifier implements DeclSpeci
this.name = name;
}
- /**
- * Returns the kind.
- * @return int
- */
- public int getKind() {
- return kind;
- }
-
- /**
- * Sets the kind.
- * @param kind The kind to set
- */
- public void setKind(int kind) {
- this.kind = kind;
- }
+ private Token classKind;
/**
* Returns the functionDefinition.
@@ -262,6 +260,12 @@ public class SimpleDeclarationWrapper extends DeclSpecifier implements DeclSpeci
return newElement;
}
+ private CElement createTypedef(CElement parent, String name){
+ CElement typedef = new TypeDef( parent, name );
+ return typedef;
+ }
+
+
/**
* Creates a Variable and fills its info
* @param parent
@@ -387,4 +391,19 @@ public class SimpleDeclarationWrapper extends DeclSpecifier implements DeclSpeci
return newElement;
}
+ /**
+ * @return Token
+ */
+ public Token getClassKind() {
+ return classKind;
+ }
+
+ /**
+ * Sets the classKind.
+ * @param classKind The classKind to set
+ */
+ public void setClassKind(Token classKind) {
+ this.classKind = classKind;
+ }
+
}
diff --git a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/model/TranslationUnitWrapper.java b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/model/TranslationUnitWrapper.java
index 7284d695401..dce4f9b733c 100644
--- a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/model/TranslationUnitWrapper.java
+++ b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/model/TranslationUnitWrapper.java
@@ -1,5 +1,7 @@
package org.eclipse.cdt.internal.core.model;
+import org.eclipse.cdt.core.model.IParent;
+
/**
* @author jcamelon
*
@@ -15,13 +17,13 @@ public class TranslationUnitWrapper implements ICElementWrapper {
/**
* @see org.eclipse.cdt.internal.core.model.IWrapper#getElement()
*/
- public CElement getElement() {
+ public IParent getElement() {
return unit;
}
/**
* @see org.eclipse.cdt.internal.core.model.IWrapper#setElement(java.lang.Object)
*/
- public void setElement(CElement item) {
+ public void setElement(IParent item) {
unit = (TranslationUnit)item;
}
diff --git a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/parser/ExpressionEvaluator.java b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/parser/ExpressionEvaluator.java
index e35a7ca8cac..51dd6b8ab88 100644
--- a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/parser/ExpressionEvaluator.java
+++ b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/parser/ExpressionEvaluator.java
@@ -513,7 +513,7 @@ public class ExpressionEvaluator implements IParserCallback {
/* (non-Javadoc)
* @see org.eclipse.cdt.internal.core.parser.IParserCallback#enumSpecifierBegin(java.lang.Object)
*/
- public Object enumSpecifierBegin(Object container) {
+ public Object enumSpecifierBegin(Object container, Token enumKey) {
return null;
}
diff --git a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/parser/IParserCallback.java b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/parser/IParserCallback.java
index ab1c9d247b3..145b0f29725 100644
--- a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/parser/IParserCallback.java
+++ b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/parser/IParserCallback.java
@@ -96,7 +96,7 @@ public interface IParserCallback {
public void usingDeclarationAbort( Object declaration );
public void usingDeclarationEnd( Object declaration );
- public Object enumSpecifierBegin( Object container );
+ public Object enumSpecifierBegin( Object container, Token enumKey );
public void enumSpecifierId( Object enumSpec );
public void enumSpecifierAbort( Object enumSpec );
public void enumSpecifierEnd( Object enumSpec );
diff --git a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/parser/NullParserCallback.java b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/parser/NullParserCallback.java
index 015a748a0ea..a0533689fbd 100644
--- a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/parser/NullParserCallback.java
+++ b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/parser/NullParserCallback.java
@@ -413,7 +413,7 @@ public class NullParserCallback implements IParserCallback {
/* (non-Javadoc)
* @see org.eclipse.cdt.internal.core.parser.IParserCallback#enumSpecifierBegin(java.lang.Object)
*/
- public Object enumSpecifierBegin(Object container) {
+ public Object enumSpecifierBegin(Object container, Token enumKey) {
// TODO Auto-generated method stub
return null;
}
diff --git a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/parser/Parser.java b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/parser/Parser.java
index e5414830d5c..0fa839d3928 100644
--- a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/parser/Parser.java
+++ b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/parser/Parser.java
@@ -670,9 +670,9 @@ c, quick);
case Token.t_volatile:
case Token.t_signed:
case Token.t_unsigned:
- case Token.t_short:
try{ callback.simpleDeclSpecifier(decl, consume());} catch( Exception e ) {}
break;
+ case Token.t_short:
case Token.t_char:
case Token.t_wchar_t:
case Token.t_bool:
@@ -1157,10 +1157,8 @@ c, quick);
*/
protected void enumSpecifier( Object owner ) throws Backtrack
{
- consume( Token.t_enum );
-
Object enumSpecifier = null;
- try{ enumSpecifier = callback.enumSpecifierBegin( owner );} catch( Exception e ) {}
+ try{ enumSpecifier = callback.enumSpecifierBegin( owner, consume( Token.t_enum ) );} catch( Exception e ) {}
if( LT(1) == Token.tIDENTIFIER )
{
diff --git a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/parser/Scanner.java b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/parser/Scanner.java
index 5f101db1a04..191b75fb8e2 100644
--- a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/parser/Scanner.java
+++ b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/parser/Scanner.java
@@ -871,6 +871,14 @@ public class Scanner implements IScanner {
}
} else {
switch (c) {
+ case '\'' :
+ c = getChar();
+ int next = getChar();
+ if( next == '\'' )
+ return newToken( Token.tCHAR, new Character( (char)c ).toString(), currentContext );
+ else
+ if( throwExceptionOnBadCharacterRead )
+ throw new ScannerException( "Invalid character '" + (char)c + "' read @ offset " + currentContext.getOffset() + " of file " + currentContext.getFilename() );
case ':' :
c = getChar();
switch (c) {
@@ -1185,7 +1193,7 @@ public class Scanner implements IScanner {
default :
// Bad character
if( throwExceptionOnBadCharacterRead )
- throw new ScannerException( "Invalid character read @ offset " + currentContext.getOffset() + " of file " + currentContext.getFilename() );
+ throw new ScannerException( "Invalid character '" + (char)c + "' read @ offset " + currentContext.getOffset() + " of file " + currentContext.getFilename() );
break;
}
diff --git a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/parser/Token.java b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/parser/Token.java
index df0a95c7d15..8924a50f639 100644
--- a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/parser/Token.java
+++ b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/parser/Token.java
@@ -175,6 +175,6 @@ public class Token {
static public final int tSTRING = 129;
static public final int tFLOATINGPT = 130;
static public final int tLSTRING = 131;
-
- static public final int tLAST = tLSTRING;
+ static public final int tCHAR = 132;
+ static public final int tLAST = tCHAR;
}

Back to the top