1
0
Fork 0
mirror of https://github.com/eclipse-cdt/cdt synced 2025-08-17 13:15:44 +02:00

Fixed unsigned short Simpledeclartions not showing up in the

outline view
This commit is contained in:
Alain Magloire 2003-04-01 18:52:37 +00:00
parent 1c8649d6fd
commit aacea7223c
14 changed files with 305 additions and 84 deletions

View file

@ -600,7 +600,7 @@ public class DOMBuilder implements IParserCallback
/* (non-Javadoc) /* (non-Javadoc)
* @see org.eclipse.cdt.internal.core.parser.IParserCallback#enumSpecifierBegin(java.lang.Object) * @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; SimpleDeclaration decl = (SimpleDeclaration)container;
EnumerationSpecifier es = new EnumerationSpecifier( decl ); EnumerationSpecifier es = new EnumerationSpecifier( decl );
decl.setTypeSpecifier(es); decl.setTypeSpecifier(es);

View file

@ -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 2003-03-31 Andrew Niefer
Parser Symbol Table, better support for function resolution with pointers and Parser Symbol Table, better support for function resolution with pointers and
references as parameters. Also support for typedefs as function parameters references as parameters. Also support for typedefs as function parameters

View file

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

View file

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

View file

@ -1,5 +1,7 @@
package org.eclipse.cdt.internal.core.model; package org.eclipse.cdt.internal.core.model;
import org.eclipse.cdt.core.model.IParent;
/** /**
* @author jcamelon * @author jcamelon
* *
@ -10,6 +12,6 @@ package org.eclipse.cdt.internal.core.model;
*/ */
public interface ICElementWrapper { public interface ICElementWrapper {
public CElement getElement(); public IParent getElement();
public void setElement (CElement item); public void setElement (IParent item);
} }

View file

@ -10,6 +10,7 @@
******************************************************************************/ ******************************************************************************/
package org.eclipse.cdt.internal.core.model; package org.eclipse.cdt.internal.core.model;
import java.util.Iterator;
import java.util.LinkedList; import java.util.LinkedList;
import java.util.List; import java.util.List;
@ -44,20 +45,20 @@ public class NewModelBuilder implements IParserCallback {
{ {
SimpleDeclarationWrapper c = (SimpleDeclarationWrapper)container; SimpleDeclarationWrapper c = (SimpleDeclarationWrapper)container;
int kind; SimpleDeclarationWrapper wrapper = new SimpleDeclarationWrapper();
switch (classKey.getType()) { wrapper.setClassKind( classKey );
switch( classKey.getType() )
{
case Token.t_class: case Token.t_class:
kind = ICElement.C_CLASS; wrapper.setCurrentVisibility( AccessSpecifier.v_private );
break; break;
case Token.t_struct: case Token.t_struct:
kind = ICElement.C_STRUCT; case Token.t_union:
wrapper.setCurrentVisibility( AccessSpecifier.v_public );
break; break;
default:
kind = ICElement.C_UNION;
} }
SimpleDeclarationWrapper wrapper = new SimpleDeclarationWrapper();
wrapper.setKind( kind );
wrapper.setParent( c.getParent() ); wrapper.setParent( c.getParent() );
return wrapper; return wrapper;
@ -138,7 +139,7 @@ org.eclipse.cdt.internal.core.newparser.IParserCallback#beginSimpleDeclaration(T
Object parent = wrapper.getElement(); Object parent = wrapper.getElement();
SimpleDeclarationWrapper result = new SimpleDeclarationWrapper(); SimpleDeclarationWrapper result = new SimpleDeclarationWrapper();
if( wrapper instanceof SimpleDeclarationWrapper ){ if( wrapper instanceof SimpleDeclarationWrapper ){
result.setParent( (CElement)wrapper.getElement() ); result.setParent( wrapper.getElement() );
result.setCurrentVisibility(((SimpleDeclarationWrapper)wrapper).getCurrentVisibility()); result.setCurrentVisibility(((SimpleDeclarationWrapper)wrapper).getCurrentVisibility());
} else if ( wrapper instanceof TranslationUnitWrapper ) } else if ( wrapper instanceof TranslationUnitWrapper )
result.setParent( (TranslationUnit)wrapper.getElement()); result.setParent( (TranslationUnit)wrapper.getElement());
@ -331,13 +332,36 @@ org.eclipse.cdt.internal.core.newparser.IParserCallback#beginSimpleDeclaration(T
*/ */
public void classSpecifierSafe(Object classSpecifier) { public void classSpecifierSafe(Object classSpecifier) {
SimpleDeclarationWrapper wrapper = (SimpleDeclarationWrapper)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.setElement( elem );
wrapper.getParent().addChild(elem); ((Parent)wrapper.getParent()).addChild(elem);
String name = wrapper.getName().toString();
elem.setElementName( name ); String elementName = ( wrapper.getName() == null ) ? "" : wrapper.getName().toString();
elem.setIdPos(wrapper.getName().getStartOffset(), name.length()); elem.setElementName( elementName );
elem.setPos(wrapper.getName().getStartOffset(), name.length()); 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) * @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 ) if( container instanceof SimpleDeclarationWrapper )
{ {
SimpleDeclarationWrapper c = (SimpleDeclarationWrapper)container; 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(); SimpleDeclarationWrapper wrapper = new SimpleDeclarationWrapper();
wrapper.setKind( kind ); wrapper.setClassKind( classKey );
wrapper.setParent( c.getParent() ); wrapper.setParent( c.getParent() );
return wrapper; 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) * @see org.eclipse.cdt.internal.core.parser.IParserCallback#elaboratedTypeSpecifierEnd(java.lang.Object)
*/ */
public void elaboratedTypeSpecifierEnd(Object elab) { public void elaboratedTypeSpecifierEnd(Object elab) {
SimpleDeclarationWrapper wrapper = (SimpleDeclarationWrapper)elab;
} }
/** /**
@ -640,14 +653,17 @@ org.eclipse.cdt.internal.core.newparser.IParserCallback#beginSimpleDeclaration(T
/* (non-Javadoc) /* (non-Javadoc)
* @see org.eclipse.cdt.internal.core.parser.IParserCallback#enumSpecifierBegin(java.lang.Object) * @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; SimpleDeclarationWrapper c = (SimpleDeclarationWrapper)container;
EnumerationWrapper wrapper = new EnumerationWrapper(c.getParent(), enumKey );
return wrapper;
} }
/* (non-Javadoc) /* (non-Javadoc)
* @see org.eclipse.cdt.internal.core.parser.IParserCallback#enumSpecifierId(java.lang.Object) * @see org.eclipse.cdt.internal.core.parser.IParserCallback#enumSpecifierId(java.lang.Object)
*/ */
public void enumSpecifierId(Object enumSpec) { public void enumSpecifierId(Object enumSpec) {
((EnumerationWrapper)enumSpec).setName( currName );
} }
/* (non-Javadoc) /* (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) * @see org.eclipse.cdt.internal.core.parser.IParserCallback#enumSpecifierEnd(java.lang.Object)
*/ */
public void enumSpecifierEnd(Object enumSpec) { 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) /* (non-Javadoc)
* @see org.eclipse.cdt.internal.core.parser.IParserCallback#enumDefinitionBegin(java.lang.Object) * @see org.eclipse.cdt.internal.core.parser.IParserCallback#enumDefinitionBegin(java.lang.Object)
*/ */
public Object enumDefinitionBegin(Object enumSpec) { public Object enumDefinitionBegin(Object enumSpec) {
return null; EnumerationWrapper wrapper = (EnumerationWrapper)enumSpec;
EnumeratorWrapper result = new EnumeratorWrapper(wrapper);
return result;
} }
/* (non-Javadoc) /* (non-Javadoc)
* @see org.eclipse.cdt.internal.core.parser.IParserCallback#enumDefinitionId(java.lang.Object) * @see org.eclipse.cdt.internal.core.parser.IParserCallback#enumDefinitionId(java.lang.Object)
*/ */
public void enumDefinitionId(Object enumDefn) { public void enumDefinitionId(Object enumDefn) {
EnumeratorWrapper wrapper = (EnumeratorWrapper)enumDefn;
wrapper.setName( currName );
} }
/* (non-Javadoc) /* (non-Javadoc)
* @see org.eclipse.cdt.internal.core.parser.IParserCallback#enumDefinitionEnd(java.lang.Object) * @see org.eclipse.cdt.internal.core.parser.IParserCallback#enumDefinitionEnd(java.lang.Object)
*/ */
public void enumDefinitionEnd(Object enumDefn) { public void enumDefinitionEnd(Object enumDefn) {
EnumeratorWrapper wrapper = (EnumeratorWrapper)enumDefn;
wrapper.getParent().addEnumerator( wrapper );
} }
/* (non-Javadoc) /* (non-Javadoc)
@ -687,7 +738,6 @@ org.eclipse.cdt.internal.core.newparser.IParserCallback#beginSimpleDeclaration(T
*/ */
public void asmDefinition(Object container, String assemblyCode) { public void asmDefinition(Object container, String assemblyCode) {
// TODO Auto-generated method stub // TODO Auto-generated method stub
} }
/* (non-Javadoc) /* (non-Javadoc)

View file

@ -3,8 +3,10 @@ package org.eclipse.cdt.internal.core.model;
import java.util.LinkedList; import java.util.LinkedList;
import java.util.List; import java.util.List;
import org.eclipse.cdt.core.model.IParent;
import org.eclipse.cdt.core.model.IStructure; import org.eclipse.cdt.core.model.IStructure;
import org.eclipse.cdt.core.model.ITranslationUnit; 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.AccessSpecifier;
import org.eclipse.cdt.internal.core.parser.util.DeclSpecifier; import org.eclipse.cdt.internal.core.parser.util.DeclSpecifier;
import org.eclipse.cdt.internal.core.parser.util.Name; 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 { public class SimpleDeclarationWrapper extends DeclSpecifier implements DeclSpecifier.Container, ICElementWrapper {
private CElement element = null; private IParent element = null;
private CElement parent = null; private IParent parent = null;
int kind;
private Name name = null; private Name name = null;
private boolean functionDefinition = false; private boolean functionDefinition = false;
public SimpleDeclarationWrapper( CElement item ) public SimpleDeclarationWrapper( IParent item )
{ {
this.element = item; this.element = item;
} }
@ -38,7 +40,7 @@ public class SimpleDeclarationWrapper extends DeclSpecifier implements DeclSpeci
* Returns the item. * Returns the item.
* @return CElement * @return CElement
*/ */
public CElement getElement() { public IParent getElement() {
return element; return element;
} }
@ -46,15 +48,15 @@ public class SimpleDeclarationWrapper extends DeclSpecifier implements DeclSpeci
* Sets the item. * Sets the item.
* @param item The item to set * @param item The item to set
*/ */
public void setElement (CElement item) { public void setElement (IParent item) {
this.element = (CElement)item; this.element = (IParent)item;
} }
/** /**
* Returns the parent. * Returns the parent.
* @return CElement * @return CElement
*/ */
public CElement getParent() { public IParent getParent() {
return parent; return parent;
} }
@ -62,7 +64,7 @@ public class SimpleDeclarationWrapper extends DeclSpecifier implements DeclSpeci
* Sets the parent. * Sets the parent.
* @param parent The parent to set * @param parent The parent to set
*/ */
public void setParent(CElement parent) { public void setParent(IParent parent) {
this.parent = parent; this.parent = parent;
} }
@ -71,7 +73,7 @@ public class SimpleDeclarationWrapper extends DeclSpecifier implements DeclSpeci
// creates the appropriate C Elements // creates the appropriate C Elements
List declaratorList = getDeclarators(); List declaratorList = getDeclarators();
Declarator [] declarators = (Declarator []) declaratorList.toArray( new Declarator[ declaratorList.size() ] ); Declarator [] declarators = (Declarator []) declaratorList.toArray( new Declarator[ declaratorList.size() ] );
CElement parentElement = getParent(); CElement parentElement = (CElement)getParent();
for( int i = 0; i < declarators.length; ++i ) for( int i = 0; i < declarators.length; ++i )
{ {
@ -80,6 +82,7 @@ public class SimpleDeclarationWrapper extends DeclSpecifier implements DeclSpeci
// instantiate the right element // instantiate the right element
List clause =currentDeclarator.getParameterDeclarationClause(); List clause =currentDeclarator.getParameterDeclarationClause();
String declaratorName = ( currentDeclarator.getName() == null ) ? "" : currentDeclarator.getName().toString();
if( clause == null && !isTypedef()) if( clause == null && !isTypedef())
{ {
// TODO - this was to get rid of the NULL pointer we've been seeing // 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 // this is an attribute or a varaible
if( parentElement instanceof IStructure ) if( parentElement instanceof IStructure )
{ {
declaration = createField( parentElement, currentDeclarator.getName().toString() ); declaration = createField( parentElement, declaratorName );
} }
else if( parentElement instanceof ITranslationUnit ) else if( parentElement instanceof ITranslationUnit )
{ {
if(isExtern()) if(isExtern())
{ {
declaration = createVariableDeclaration( parentElement, currentDeclarator.getName().toString() ); declaration = createVariableDeclaration( parentElement, declaratorName );
} }
else else
{ {
declaration = createVariable( parentElement, currentDeclarator.getName().toString() ); declaration = createVariable( parentElement, declaratorName );
} }
} }
} }
else if( isTypedef() ) else if( isTypedef() )
{ {
// do nothing just yet declaration = createTypedef( parentElement, declaratorName );
//TODO : update this -- typedefs do not have a parameterdeclarationclause
} }
else else
{ {
@ -114,7 +116,7 @@ public class SimpleDeclarationWrapper extends DeclSpecifier implements DeclSpeci
// this is a function or a method // this is a function or a method
if( parentElement instanceof IStructure ) if( parentElement instanceof IStructure )
{ {
declaration = createMethodDeclaration( parentElement, currentDeclarator.getName().toString(), parameters ); declaration = createMethodDeclaration( parentElement, declaratorName, parameters );
} }
else if( parentElement instanceof ITranslationUnit ) 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 // if it belongs to a class, then create a method
// else create a function // else create a function
// this will not be known until we have cross reference information // this will not be known until we have cross reference information
declaration = createFunction( parentElement, currentDeclarator.getName().toString(), parameters ); declaration = createFunction( parentElement, declaratorName, parameters );
} }
else 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()); if( currentDeclarator.getName() != null )
declaration.setPos( currentDeclarator.getName().getStartOffset(), currentDeclarator.getName().toString().length() ); {
// 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 // add to parent
parentElement.addChild( declaration ); parentElement.addChild( declaration );
@ -144,6 +155,7 @@ public class SimpleDeclarationWrapper extends DeclSpecifier implements DeclSpeci
} }
List declarators = new LinkedList(); List declarators = new LinkedList();
String [] myString;
public void addDeclarator( Object in ) public void addDeclarator( Object in )
{ {
@ -197,21 +209,7 @@ public class SimpleDeclarationWrapper extends DeclSpecifier implements DeclSpeci
this.name = name; this.name = name;
} }
/** private Token classKind;
* 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;
}
/** /**
* Returns the functionDefinition. * Returns the functionDefinition.
@ -262,6 +260,12 @@ public class SimpleDeclarationWrapper extends DeclSpecifier implements DeclSpeci
return newElement; return newElement;
} }
private CElement createTypedef(CElement parent, String name){
CElement typedef = new TypeDef( parent, name );
return typedef;
}
/** /**
* Creates a Variable and fills its info * Creates a Variable and fills its info
* @param parent * @param parent
@ -387,4 +391,19 @@ public class SimpleDeclarationWrapper extends DeclSpecifier implements DeclSpeci
return newElement; 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;
}
} }

View file

@ -1,5 +1,7 @@
package org.eclipse.cdt.internal.core.model; package org.eclipse.cdt.internal.core.model;
import org.eclipse.cdt.core.model.IParent;
/** /**
* @author jcamelon * @author jcamelon
* *
@ -15,13 +17,13 @@ public class TranslationUnitWrapper implements ICElementWrapper {
/** /**
* @see org.eclipse.cdt.internal.core.model.IWrapper#getElement() * @see org.eclipse.cdt.internal.core.model.IWrapper#getElement()
*/ */
public CElement getElement() { public IParent getElement() {
return unit; return unit;
} }
/** /**
* @see org.eclipse.cdt.internal.core.model.IWrapper#setElement(java.lang.Object) * @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; unit = (TranslationUnit)item;
} }

View file

@ -513,7 +513,7 @@ public class ExpressionEvaluator implements IParserCallback {
/* (non-Javadoc) /* (non-Javadoc)
* @see org.eclipse.cdt.internal.core.parser.IParserCallback#enumSpecifierBegin(java.lang.Object) * @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; return null;
} }

View file

@ -96,7 +96,7 @@ public interface IParserCallback {
public void usingDeclarationAbort( Object declaration ); public void usingDeclarationAbort( Object declaration );
public void usingDeclarationEnd( 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 enumSpecifierId( Object enumSpec );
public void enumSpecifierAbort( Object enumSpec ); public void enumSpecifierAbort( Object enumSpec );
public void enumSpecifierEnd( Object enumSpec ); public void enumSpecifierEnd( Object enumSpec );

View file

@ -413,7 +413,7 @@ public class NullParserCallback implements IParserCallback {
/* (non-Javadoc) /* (non-Javadoc)
* @see org.eclipse.cdt.internal.core.parser.IParserCallback#enumSpecifierBegin(java.lang.Object) * @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 // TODO Auto-generated method stub
return null; return null;
} }

View file

@ -670,9 +670,9 @@ c, quick);
case Token.t_volatile: case Token.t_volatile:
case Token.t_signed: case Token.t_signed:
case Token.t_unsigned: case Token.t_unsigned:
case Token.t_short:
try{ callback.simpleDeclSpecifier(decl, consume());} catch( Exception e ) {} try{ callback.simpleDeclSpecifier(decl, consume());} catch( Exception e ) {}
break; break;
case Token.t_short:
case Token.t_char: case Token.t_char:
case Token.t_wchar_t: case Token.t_wchar_t:
case Token.t_bool: case Token.t_bool:
@ -1157,10 +1157,8 @@ c, quick);
*/ */
protected void enumSpecifier( Object owner ) throws Backtrack protected void enumSpecifier( Object owner ) throws Backtrack
{ {
consume( Token.t_enum );
Object enumSpecifier = null; 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 ) if( LT(1) == Token.tIDENTIFIER )
{ {

View file

@ -871,6 +871,14 @@ public class Scanner implements IScanner {
} }
} else { } else {
switch (c) { 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 ':' : case ':' :
c = getChar(); c = getChar();
switch (c) { switch (c) {
@ -1185,7 +1193,7 @@ public class Scanner implements IScanner {
default : default :
// Bad character // Bad character
if( throwExceptionOnBadCharacterRead ) 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; break;
} }

View file

@ -175,6 +175,6 @@ public class Token {
static public final int tSTRING = 129; static public final int tSTRING = 129;
static public final int tFLOATINGPT = 130; static public final int tFLOATINGPT = 130;
static public final int tLSTRING = 131; static public final int tLSTRING = 131;
static public final int tCHAR = 132;
static public final int tLAST = tLSTRING; static public final int tLAST = tCHAR;
} }