1
0
Fork 0
mirror of https://github.com/eclipse-cdt/cdt synced 2025-06-06 17:26:01 +02:00

Patch for John Camelon:

CORE
	Removed all the old Code Model Builder source that was no longer being used (NewModelBuilder.java, etc.). 
	Moved all the files in parser.util directory to the dom.  
	Organized imports. 
	Fixed bug36250 Parser ignores functions with default parameters that have no name.
	Fixed bug36240 Parser incorrectly parses operator= 
	Fixed bug36254 Parser doesn't recognize unsigned as a type by itself.


TESTS
	Organized imports. 
	Added DOMTests::testTemplateDeclarationOfMethod().
	Added DOMTests::testBug36250().  
	Added DOMTests::testBug36240(). 
	Added DOMTests::testBug36254().
This commit is contained in:
Doug Schaefer 2003-04-09 21:12:09 +00:00
parent 663cef492f
commit 7e62df880f
43 changed files with 600 additions and 2275 deletions

View file

@ -10,7 +10,7 @@
* Contributors: * Contributors:
* Rational Software - Initial API and implementation * Rational Software - Initial API and implementation
***********************************************************************/ ***********************************************************************/
package org.eclipse.cdt.internal.core.parser.util; package org.eclipse.cdt.internal.core.dom;
/** /**
* @author jcamelon * @author jcamelon

View file

@ -1,8 +1,5 @@
package org.eclipse.cdt.internal.core.dom; package org.eclipse.cdt.internal.core.dom;
import org.eclipse.cdt.internal.core.parser.util.AccessSpecifier;
import org.eclipse.cdt.internal.core.parser.util.ClassKey;
import org.eclipse.cdt.internal.core.parser.util.Name;
/** /**
* @author dschaefe * @author dschaefe

View file

@ -10,7 +10,7 @@
* Contributors: * Contributors:
* Rational Software - Initial API and implementation * Rational Software - Initial API and implementation
***********************************************************************/ ***********************************************************************/
package org.eclipse.cdt.internal.core.parser.util; package org.eclipse.cdt.internal.core.dom;
/** /**
* @author jcamelon * @author jcamelon

View file

@ -5,9 +5,6 @@ import java.util.LinkedList;
import java.util.List; import java.util.List;
import org.eclipse.cdt.internal.core.parser.Token; 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.ClassKey;
import org.eclipse.cdt.internal.core.parser.util.Name;
public class ClassSpecifier extends TypeSpecifier implements IScope, IOffsetable { public class ClassSpecifier extends TypeSpecifier implements IScope, IOffsetable {

View file

@ -16,7 +16,6 @@ import java.util.ArrayList;
import java.util.Collections; import java.util.Collections;
import java.util.List; import java.util.List;
import org.eclipse.cdt.internal.core.parser.util.Name;
/** /**
* @author jcamelon * @author jcamelon

View file

@ -3,10 +3,6 @@ package org.eclipse.cdt.internal.core.dom;
import org.eclipse.cdt.internal.core.parser.IParserCallback; import org.eclipse.cdt.internal.core.parser.IParserCallback;
import org.eclipse.cdt.internal.core.parser.Token; 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.ClassKey;
import org.eclipse.cdt.internal.core.parser.util.DeclSpecifier;
import org.eclipse.cdt.internal.core.parser.util.Name;
/** /**
* This is the parser callback that creates objects in the DOM. * This is the parser callback that creates objects in the DOM.

View file

@ -0,0 +1,343 @@
package org.eclipse.cdt.internal.core.dom;
import java.util.List;
import org.eclipse.cdt.internal.core.parser.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) {
int masked = (declSpecifierSeq & mask);
return (masked != 0);
}
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(DeclSpecifier.t_char);
break;
case Token.t_wchar_t :
setType(DeclSpecifier.t_wchar_t);
break;
case Token.t_bool :
setType(DeclSpecifier.t_bool);
break;
case Token.t_short :
setShort(true);
break;
case Token.t_int :
setType(DeclSpecifier.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(DeclSpecifier.t_float);
break;
case Token.t_double :
setType(DeclSpecifier.t_double);
break;
case Token.t_void :
setType(DeclSpecifier.t_void);
break;
case Token.tIDENTIFIER :
setType(DeclSpecifier.t_type);
break;
}
}
public void setType(int t) {
declSpecifierSeq = declSpecifierSeq & ~typeMask | t;
}
public int getType() {
return declSpecifierSeq & typeMask;
}
public interface Container {
public DeclSpecifier getDeclSpecifier();
public void setDeclSpecifier(DeclSpecifier in);
public void addDeclarator(Object declarator);
public void removeDeclarator(Object declarator);
public List getDeclarators();
};
Name name = null;
/**
* 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;
}
/**
* Returns the type as a String
* @return String
*/
public String getTypeName() {
StringBuffer type = new StringBuffer();
switch (getType()) {
case t_char :
if (isUnsigned())
type.append("unsigned ");
type.append("char");
break;
case t_wchar_t :
if (isUnsigned())
type.append("unsigned ");
type.append("wchar_t");
break;
case t_bool :
type.append("bool");
break;
case t_int :
if (isUnsigned())
type.append("unsigned ");
if (isShort())
type.append("short ");
if (isLong())
type.append("long ");
type.append("int");
break;
case t_float :
type.append("float");
break;
case t_double :
if (isLong())
type.append("long ");
type.append("double");
break;
case t_void :
type.append("void");
break;
case t_type :
if (getName() != null)
type.append(getName().toString());
else {
if (isUnsigned())
type.append("unsigned");
if (isShort())
type.append("short");
if (isLong())
type.append("long");
}
break;
default :
return "";
}
return type.toString();
}
}

View file

@ -4,8 +4,6 @@ import java.util.ArrayList;
import java.util.Collections; import java.util.Collections;
import java.util.List; import java.util.List;
import org.eclipse.cdt.internal.core.parser.util.DeclSpecifier;
import org.eclipse.cdt.internal.core.parser.util.Name;
public class Declarator implements IExpressionOwner { public class Declarator implements IExpressionOwner {

View file

@ -1,7 +1,5 @@
package org.eclipse.cdt.internal.core.dom; package org.eclipse.cdt.internal.core.dom;
import org.eclipse.cdt.internal.core.parser.util.ClassKey;
import org.eclipse.cdt.internal.core.parser.util.Name;
/** /**
* @author jcamelon * @author jcamelon

View file

@ -17,7 +17,6 @@ import java.util.Collections;
import java.util.List; import java.util.List;
import org.eclipse.cdt.internal.core.parser.Token; import org.eclipse.cdt.internal.core.parser.Token;
import org.eclipse.cdt.internal.core.parser.util.Name;
/** /**
* @author jcamelon * @author jcamelon

View file

@ -12,7 +12,6 @@
***********************************************************************/ ***********************************************************************/
package org.eclipse.cdt.internal.core.dom; package org.eclipse.cdt.internal.core.dom;
import org.eclipse.cdt.internal.core.parser.util.Name;
/** /**
* @author jcamelon * @author jcamelon

View file

@ -16,7 +16,6 @@ import java.util.Collections;
import java.util.LinkedList; import java.util.LinkedList;
import java.util.List; import java.util.List;
import org.eclipse.cdt.internal.core.parser.util.Name;
/** /**
* @author jcamelon * @author jcamelon

View file

@ -1,4 +1,4 @@
package org.eclipse.cdt.internal.core.parser.util; package org.eclipse.cdt.internal.core.dom;
import org.eclipse.cdt.internal.core.parser.Token; import org.eclipse.cdt.internal.core.parser.Token;

View file

@ -17,7 +17,6 @@ import java.util.LinkedList;
import java.util.List; import java.util.List;
import org.eclipse.cdt.internal.core.parser.Token; import org.eclipse.cdt.internal.core.parser.Token;
import org.eclipse.cdt.internal.core.parser.util.Name;
/** /**
* @author jcamelon * @author jcamelon

View file

@ -4,7 +4,6 @@ import java.util.Collections;
import java.util.LinkedList; import java.util.LinkedList;
import java.util.List; import java.util.List;
import org.eclipse.cdt.internal.core.parser.util.DeclSpecifier;
/** /**

View file

@ -4,8 +4,6 @@ import java.util.Collections;
import java.util.LinkedList; import java.util.LinkedList;
import java.util.List; import java.util.List;
import org.eclipse.cdt.internal.core.parser.util.AccessSpecifier;
import org.eclipse.cdt.internal.core.parser.util.DeclSpecifier;
public class SimpleDeclaration extends Declaration implements DeclSpecifier.Container, IOffsetable, TypeSpecifier.IOwner { public class SimpleDeclaration extends Declaration implements DeclSpecifier.Container, IOffsetable, TypeSpecifier.IOwner {

View file

@ -12,7 +12,6 @@
***********************************************************************/ ***********************************************************************/
package org.eclipse.cdt.internal.core.dom; package org.eclipse.cdt.internal.core.dom;
import org.eclipse.cdt.internal.core.parser.util.Name;
/** /**
* @author jcamelon * @author jcamelon

View file

@ -12,7 +12,6 @@
***********************************************************************/ ***********************************************************************/
package org.eclipse.cdt.internal.core.dom; package org.eclipse.cdt.internal.core.dom;
import org.eclipse.cdt.internal.core.parser.util.Name;
/** /**
* @author jcamelon * @author jcamelon

View file

@ -12,7 +12,6 @@
***********************************************************************/ ***********************************************************************/
package org.eclipse.cdt.internal.core.dom; package org.eclipse.cdt.internal.core.dom;
import org.eclipse.cdt.internal.core.parser.util.Name;
/** /**
* @author jcamelon * @author jcamelon

View file

@ -1,3 +1,11 @@
2003-04-09 John Camelon
Removed all the old Code Model Builder source that was no longer being used (NewModelBuilder.java, etc.).
Moved all the files in parser.util directory to the dom.
Organized imports.
Fixed bug36250 Parser ignores functions with default parameters that have no name.
Fixed bug36240 Parser incorrectly parses operator=
Fixed bug36254 Parser doesn't recognize unsigned as a type by itself.
2003-04-09 John Camelon 2003-04-09 John Camelon
Added timing printout for CModelTests. Added timing printout for CModelTests.
Provided partial fix for bug36255 to get past infinite loop, will leave defect open. Provided partial fix for bug36255 to get past infinite loop, will leave defect open.

View file

@ -20,8 +20,10 @@ import org.eclipse.cdt.core.model.INamespace;
import org.eclipse.cdt.core.model.IParent; 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.dom.ClassKey;
import org.eclipse.cdt.internal.core.dom.ClassSpecifier; import org.eclipse.cdt.internal.core.dom.ClassSpecifier;
import org.eclipse.cdt.internal.core.dom.DOMBuilder; import org.eclipse.cdt.internal.core.dom.DOMBuilder;
import org.eclipse.cdt.internal.core.dom.DeclSpecifier;
import org.eclipse.cdt.internal.core.dom.Declaration; import org.eclipse.cdt.internal.core.dom.Declaration;
import org.eclipse.cdt.internal.core.dom.Declarator; import org.eclipse.cdt.internal.core.dom.Declarator;
import org.eclipse.cdt.internal.core.dom.ElaboratedTypeSpecifier; import org.eclipse.cdt.internal.core.dom.ElaboratedTypeSpecifier;
@ -39,8 +41,6 @@ import org.eclipse.cdt.internal.core.dom.TranslationUnit;
import org.eclipse.cdt.internal.core.dom.TypeSpecifier; import org.eclipse.cdt.internal.core.dom.TypeSpecifier;
import org.eclipse.cdt.internal.core.parser.Parser; import org.eclipse.cdt.internal.core.parser.Parser;
import org.eclipse.cdt.internal.core.parser.ParserException; import org.eclipse.cdt.internal.core.parser.ParserException;
import org.eclipse.cdt.internal.core.parser.util.ClassKey;
import org.eclipse.cdt.internal.core.parser.util.DeclSpecifier;
public class CModelBuilder { public class CModelBuilder {

View file

@ -1,99 +0,0 @@
package org.eclipse.cdt.internal.core.model;
import java.util.ArrayList;
import java.util.List;
import org.eclipse.cdt.internal.core.parser.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;
private boolean isConst = false;
private boolean isVolatile = false;
/**
* 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;
}
private List pointerOperators = new ArrayList();
/**
* @return List
*/
public List getPointerOperators() {
return pointerOperators;
}
public void addPointerOperator( PointerOperator po )
{
pointerOperators.add( po );
}
/**
* @return boolean
*/
public boolean isConst() {
return isConst;
}
/**
* Sets the isConst.
* @param isConst The isConst to set
*/
public void setConst(boolean isConst) {
this.isConst = isConst;
}
/**
* @return boolean
*/
public boolean isVolatile() {
return isVolatile;
}
/**
* Sets the isVolatile.
* @param isVolatile The isVolatile to set
*/
public void setVolatile(boolean isVolatile) {
this.isVolatile = isVolatile;
}
}

View file

@ -1,82 +0,0 @@
/**********************************************************************
* 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

@ -1,69 +0,0 @@
/**********************************************************************
* 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.Token;
import org.eclipse.cdt.internal.core.parser.util.Name;
/**
* @author jcamelon
*
*/
public class EnumeratorWrapper {
private final EnumerationWrapper parent;
private Name name;
private Token lastToken = null;
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;
}
/**
* @return
*/
public Token getLastToken() {
return lastToken;
}
/**
* @param token
*/
public void setLastToken(Token token) {
lastToken = token;
}
}

View file

@ -1,19 +0,0 @@
package org.eclipse.cdt.internal.core.model;
import org.eclipse.cdt.core.model.ICElement;
import org.eclipse.cdt.core.model.IParent;
/**
* @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 ICElement getElement();
public void setElement (ICElement item);
public IParent getParent();
}

View file

@ -1,78 +0,0 @@
package org.eclipse.cdt.internal.core.model;
import org.eclipse.cdt.core.model.ICElement;
import org.eclipse.cdt.core.model.IParent;
import org.eclipse.cdt.internal.core.parser.Token;
import org.eclipse.cdt.internal.core.parser.util.Name;
/**********************************************************************
* 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
***********************************************************************/
public class NamespaceWrapper implements ICElementWrapper{
private Name name;
private final IParent parent;
private ICElement element;
private Token firstToken;
public NamespaceWrapper( IParent incoming, Token namespace)
{
this.parent= incoming;
firstToken = namespace;
}
/**
* Returns the name.
* @return Name
*/
public Name getName() {
return name;
}
/**
* Returns the parent.
* @return IParent
*/
public IParent getParent() {
return parent;
}
/**
* Sets the name.
* @param name The name to set
*/
public void setName(Name name) {
this.name = name;
}
/**
* @see org.eclipse.cdt.internal.core.model.ICElementWrapper#getElement()
*/
public ICElement getElement() {
return element;
}
/**
* @see org.eclipse.cdt.internal.core.model.ICElementWrapper#setElement(org.eclipse.cdt.core.model.IParent)
*/
public void setElement(ICElement item) {
element = item;
}
/**
* @return
*/
public Token getFirstToken() {
return firstToken;
}
}

View file

@ -1,979 +0,0 @@
/*******************************************************************************
* Copyright (c) 2001 Rational Software Corp. 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 implementation
******************************************************************************/
package org.eclipse.cdt.internal.core.model;
import java.util.Iterator;
import java.util.LinkedList;
import java.util.List;
import org.eclipse.cdt.core.model.ICElement;
import org.eclipse.cdt.core.model.IParent;
import org.eclipse.cdt.internal.core.parser.IParserCallback;
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;
public class NewModelBuilder implements IParserCallback {
private TranslationUnitWrapper translationUnit = new TranslationUnitWrapper();
public NewModelBuilder(TranslationUnit tu) {
translationUnit.setElement( tu );
}
/**
* @see org.eclipse.cdt.internal.core.newparser.IParserCallback#beginTranslationUnit()
*/
public Object translationUnitBegin() {
return translationUnit;
}
/**
* @see org.eclipse.cdt.core.newparser.IParserCallback#beginClass(String, String)
*/
public Object classSpecifierBegin(Object container, Token classKey) {
if( container instanceof SimpleDeclarationWrapper )
{
SimpleDeclarationWrapper c = (SimpleDeclarationWrapper)container;
SimpleDeclarationWrapper wrapper = new SimpleDeclarationWrapper();
wrapper.setClassKind( classKey );
switch( classKey.getType() )
{
case Token.t_class:
wrapper.setCurrentVisibility( AccessSpecifier.v_private );
break;
case Token.t_struct:
case Token.t_union:
wrapper.setCurrentVisibility( AccessSpecifier.v_public );
break;
}
wrapper.setParent( c.getParent() );
return wrapper;
}
else
return null;
}
/**
* @see org.eclipse.cdt.internal.core.newparser.IParserCallback#classSpecifierName()
*/
public Object classSpecifierName(Object classSpecifier)
{
if( classSpecifier instanceof SimpleDeclarationWrapper )
{
SimpleDeclarationWrapper wrapper = (SimpleDeclarationWrapper)classSpecifier;
wrapper.setName( currName );
}
return classSpecifier;
}
/**
* @see org.eclipse.cdt.core.newparser.IParserCallback#endClass()
*/
public void classSpecifierEnd(Object classSpecifier, Token closingBrace) {
SimpleDeclarationWrapper wrapper = (SimpleDeclarationWrapper)classSpecifier;
Structure s = (Structure)wrapper.getElement();
s.setPos( wrapper.getClassKind().getOffset(),
wrapper.getClassKind().getDelta( closingBrace ));
}
/**
* @see org.eclipse.cdt.core.newparser.IParserCallback#beginDeclarator()
*/
public Object declaratorBegin(Object container) {
DeclSpecifier.Container declSpec = (DeclSpecifier.Container)container;
List declarators = declSpec.getDeclarators();
Declarator declarator =new Declarator();
declarators.add( declarator );
return declarator;
}
private int startIdPos;
private int idLength;
private CElement elem;
/**
* @see org.eclipse.cdt.core.newparser.IParserCallback#endDeclarator()
*/
public void declaratorEnd( Object declarator) {
}
/**
* @see org.eclipse.cdt.internal.core.newparser.IParserCallback#beginFunctionBody()
*/
public Object functionBodyBegin(Object declaration) {
SimpleDeclarationWrapper wrapper = (SimpleDeclarationWrapper)declaration;
wrapper.setFunctionDefinition(true);
return null;
}
/**
* @see org.eclipse.cdt.core.newparser.IParserCallback#macro(String)
*/
public void macro(String macroName, int offset, int macroBeginOffset, int macroEndOffset) {
Macro elem = new Macro((TranslationUnit)translationUnit.getElement(), macroName);
elem.setIdPos(offset, macroName.length());
elem.setPos(macroBeginOffset, macroEndOffset - macroBeginOffset);
((TranslationUnit)translationUnit.getElement()).addChild(elem);
}
private int startPos;
/**
* @see
org.eclipse.cdt.internal.core.newparser.IParserCallback#beginSimpleDeclaration(Token)
*/
public Object simpleDeclarationBegin(Object container, Token firstToken) {
ICElementWrapper wrapper = (ICElementWrapper)container;
// Assuming that the parent is the container's element
IParent parent = (IParent)wrapper.getElement();
SimpleDeclarationWrapper result = new SimpleDeclarationWrapper();
result.setParent( parent );
result.setFirst( firstToken );
// A special case to transfere the visibility
if( wrapper instanceof SimpleDeclarationWrapper ){
result.setCurrentVisibility(((SimpleDeclarationWrapper)wrapper).getCurrentVisibility());
}
return result;
}
/**
* @see org.eclipse.cdt.internal.core.newmparser.IParserCallback#beginInclusion(String)
*/
public void inclusionBegin(String includeFile, int offset, int inclusionBeginOffset) {
Include elem = new Include(((TranslationUnit)translationUnit.getElement()), includeFile);
((TranslationUnit)translationUnit.getElement()).addChild(elem);
elem.setIdPos(offset, includeFile.length());
elem.setPos(inclusionBeginOffset, inclusionBeginOffset - offset + includeFile.length() + 1 );
}
/**
* @see org.eclipse.cdt.internal.core.newparser.IParserCallback#endInclusion()
*/
public void inclusionEnd() {
}
private Name currName;
/**
* @see org.eclipse.cdt.internal.core.newparser.IParserCallback#nameBegin(org.eclipse.cdt.internal.core.newparser.Token)
*/
public void nameBegin(Token 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) {
currName.setEnd(lastToken);
}
/**
* @see org.eclipse.cdt.internal.core.newparser.IParserCallback#simpleDeclarationEnd(java.lang.Object)
*/
public void simpleDeclarationEnd(Object declaration, Token lastToken) {
SimpleDeclarationWrapper wrapper = (SimpleDeclarationWrapper)declaration;
wrapper.setLast( lastToken );
wrapper.createElements();
}
/**
* @see org.eclipse.cdt.internal.core.newparser.IParserCallback#simpleDeclSpecifier(java.lang.Object, org.eclipse.cdt.internal.core.newparser.Token)
*/
public Object simpleDeclSpecifier(Object declSpec, Token specifier) {
DeclSpecifier declSpecifier = (DeclSpecifier)declSpec;
declSpecifier.setType( specifier );
return declSpecifier;
}
/**
* @see org.eclipse.cdt.internal.core.newparser.IParserCallback#declaratorId(java.lang.Object)
*/
public Object declaratorId(Object declarator) {
Declarator decl = (Declarator)declarator;
decl.setName( currName );
return decl;
}
/**
* @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 Object baseSpecifierName(Object baseSpecifier) {
return baseSpecifier;
}
/**
* @see org.eclipse.cdt.internal.core.newparser.IParserCallback#baseSpecifierVirtual(java.lang.Object, boolean)
*/
public Object baseSpecifierVirtual(Object baseSpecifier, boolean virtual) {
return baseSpecifier;
}
/**
* @see org.eclipse.cdt.internal.core.newparser.IParserCallback#baseSpecifierVisibility(java.lang.Object, org.eclipse.cdt.internal.core.newparser.Token)
*/
public Object baseSpecifierVisibility( Object baseSpecifier, Token visibility)
{
return null;
}
/**
* @see org.eclipse.cdt.internal.core.newparser.IParserCallback#expressionOperator(org.eclipse.cdt.internal.core.newparser.Token)
*/
public void expressionOperator(Object expression, Token operator) {
}
/**
* @see org.eclipse.cdt.internal.core.newparser.IParserCallback#expressionTerminal(org.eclipse.cdt.internal.core.newparser.Token)
*/
public void expressionTerminal(Object expression, Token terminal) {
}
/**
* @see org.eclipse.cdt.internal.core.newparser.IParserCallback#functionBodyEnd()
*/
public void functionBodyEnd(Object functionBody ) {
}
/**
* @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) {
}
/**
* @see org.eclipse.cdt.internal.core.newparser.IParserCallback#declaratorAbort(java.lang.Object, java.lang.Object)
*/
public void declaratorAbort(Object container, Object declarator) {
DeclSpecifier.Container declSpec = (DeclSpecifier.Container)container;
Declarator toBeRemoved =(Declarator)declarator;
declSpec.removeDeclarator( toBeRemoved );
toBeRemoved = null;
currName = null;
}
/**
* @see org.eclipse.cdt.internal.core.parser.IParserCallback#expressionBegin(java.lang.Object)
*/
public Object expressionBegin(Object container) {
return null;
}
/**
* @see org.eclipse.cdt.internal.core.parser.IParserCallback#expressionEnd(java.lang.Object)
*/
public void expressionEnd(Object expression) {
}
/**
* @see org.eclipse.cdt.internal.core.parser.IParserCallback#classSpecifierAbort(java.lang.Object)
*/
public void classSpecifierAbort(Object classSpecifier) {
classSpecifier = null;
}
/**
* @see org.eclipse.cdt.internal.core.parser.IParserCallback#classSpecifierSafe(java.lang.Object)
*/
public Object classSpecifierSafe(Object classSpecifier) {
SimpleDeclarationWrapper wrapper = (SimpleDeclarationWrapper)classSpecifier;
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 );
((Parent)wrapper.getParent()).addChild(elem);
String elementName = ( wrapper.getName() == null ) ? "" : wrapper.getName().toString();
elem.setElementName( elementName );
if( wrapper.getName() != null )
{
elem.setTypeName( wrapper.getClassKind().getImage() );
elem.setIdPos(wrapper.getName().getStartOffset(), elementName.length());
}
else
{
elem.setTypeName( wrapper.getClassKind().getImage() );
elem.setIdPos(wrapper.getClassKind().getOffset(), wrapper.getClassKind().getLength());
}
return wrapper;
}
/**
* @see org.eclipse.cdt.internal.core.parser.IParserCallback#elaboratedTypeSpecifierBegin(java.lang.Object)
*/
public Object elaboratedTypeSpecifierBegin(Object container, Token classKey) {
if( container instanceof SimpleDeclarationWrapper )
{
SimpleDeclarationWrapper c = (SimpleDeclarationWrapper)container;
SimpleDeclarationWrapper wrapper = new SimpleDeclarationWrapper();
wrapper.setClassKind( classKey );
wrapper.setParent( c.getParent() );
return wrapper;
}
else
return null;
}
/**
* @see org.eclipse.cdt.internal.core.parser.IParserCallback#elaboratedTypeSpecifierEnd(java.lang.Object)
*/
public void elaboratedTypeSpecifierEnd(Object elab) {
SimpleDeclarationWrapper wrapper = (SimpleDeclarationWrapper)elab;
}
/**
* @see org.eclipse.cdt.internal.core.parser.IParserCallback#elaboratedTypeSpecifierName(java.lang.Object)
*/
public Object elaboratedTypeSpecifierName(Object elab) {
if( elab instanceof SimpleDeclarationWrapper )
{
SimpleDeclarationWrapper wrapper = (SimpleDeclarationWrapper)elab;
wrapper.setName( currName );
}
return elab;
}
/**
* @see org.eclipse.cdt.internal.core.parser.IParserCallback#simpleDeclSpecifierName(java.lang.Object)
*/
public Object simpleDeclSpecifierName(Object declaration) {
DeclSpecifier declSpecifier = (DeclSpecifier)declaration;
declSpecifier.setName( currName );
return declSpecifier;
}
/* (non-Javadoc)
* @see org.eclipse.cdt.internal.core.parser.IParserCallback#expressionAbort(java.lang.Object)
*/
public void expressionAbort(Object expression) {
// TODO Auto-generated method stub
}
/* (non-Javadoc)
* @see org.eclipse.cdt.internal.core.parser.IParserCallback#classMemberVisibility(java.lang.Object, org.eclipse.cdt.internal.core.parser.Token)
*/
public Object classMemberVisibility(Object classSpecifier, Token visibility) {
SimpleDeclarationWrapper spec = (SimpleDeclarationWrapper)classSpecifier;
switch( visibility.getType() )
{
case Token.t_public:
spec.setCurrentVisibility( AccessSpecifier.v_public );
break;
case Token.t_protected:
spec.setCurrentVisibility( AccessSpecifier.v_protected );
break;
case Token.t_private:
spec.setCurrentVisibility( AccessSpecifier.v_private );
break;
}
return spec;
}
/* (non-Javadoc)
* @see org.eclipse.cdt.internal.core.parser.IParserCallback#pointerOperatorBegin(java.lang.Object, org.eclipse.cdt.internal.core.parser.Token)
*/
public Object pointerOperatorBegin(Object container) {
Declarator d = (Declarator)container;
PointerOperator po = new PointerOperator(d);
return po;
}
/* (non-Javadoc)
* @see org.eclipse.cdt.internal.core.parser.IParserCallback#pointerOperatorEnd(java.lang.Object)
*/
public void pointerOperatorEnd(Object ptrOperator) {
PointerOperator po = (PointerOperator)ptrOperator;
po.getOwnerDeclarator().addPointerOperator( po );
}
/* (non-Javadoc)
* @see org.eclipse.cdt.internal.core.parser.IParserCallback#pointerOperatorName(java.lang.Object)
*/
public Object pointerOperatorName(Object ptrOperator) {
// TODO Auto-generated method stub
return null;
}
/* (non-Javadoc)
* @see org.eclipse.cdt.internal.core.parser.IParserCallback#pointerOperatorType(java.lang.Object, org.eclipse.cdt.internal.core.parser.Token)
*/
public Object pointerOperatorType(Object ptrOperator, Token type) {
PointerOperator po=(PointerOperator)ptrOperator;
switch( type.getType() )
{
case Token.tSTAR:
po.setKind( PointerOperator.k_pointer );
break;
case Token.tAMPER:
po.setKind( PointerOperator.k_reference );
break;
default:
}
return po;
}
/* (non-Javadoc)
* @see org.eclipse.cdt.internal.core.parser.IParserCallback#pointerOperatorCVModifier(java.lang.Object, org.eclipse.cdt.internal.core.parser.Token)
*/
public Object pointerOperatorCVModifier(Object ptrOperator, Token modifier) {
PointerOperator po=(PointerOperator)ptrOperator;
switch( modifier.getType() )
{
case Token.t_const:
po.setConst( true );
break;
case Token.t_volatile:
po.setVolatile( true );
break;
default:
}
return po;
}
/* (non-Javadoc)
* @see org.eclipse.cdt.internal.core.parser.IParserCallback#declaratorCVModifier(java.lang.Object, org.eclipse.cdt.internal.core.parser.Token)
*/
public Object declaratorCVModifier(Object declarator, Token modifier) {
Declarator d = (Declarator)declarator;
switch( modifier.getType() )
{
case Token.t_const:
d.setConst( true );
break;
case Token.t_volatile:
d.setVolatile(true);
break;
default:
break;
}
return d;
}
/* (non-Javadoc)
* @see org.eclipse.cdt.internal.core.parser.IParserCallback#arrayBegin(java.lang.Object)
*/
public Object arrayDeclaratorBegin(Object declarator) {
// TODO Auto-generated method stub
return null;
}
/* (non-Javadoc)
* @see org.eclipse.cdt.internal.core.parser.IParserCallback#arrayEnd(java.lang.Object)
*/
public void arrayDeclaratorEnd(Object arrayQualifier ) {
// TODO Auto-generated method stub
}
/* (non-Javadoc)
* @see org.eclipse.cdt.internal.core.parser.IParserCallback#exceptionSpecificationTypename(java.lang.Object)
*/
public Object declaratorThrowExceptionName(Object declarator) {
// TODO Auto-generated method stub
return declarator;
}
/* (non-Javadoc)
* @see org.eclipse.cdt.internal.core.parser.IParserCallback#declaratorThrowsException(java.lang.Object)
*/
public Object declaratorThrowsException(Object declarator) {
// TODO Auto-generated method stub
return declarator;
}
/* (non-Javadoc)
* @see org.eclipse.cdt.internal.core.parser.IParserCallback#namespaceDeclarationBegin(java.lang.Object)
*/
public Object namespaceDefinitionBegin(Object container, Token namespace) {
ICElementWrapper c = (ICElementWrapper)container;
NamespaceWrapper wrapper = new NamespaceWrapper((IParent)c.getElement(), namespace);
return wrapper;
}
/* (non-Javadoc)
* @see org.eclipse.cdt.internal.core.parser.IParserCallback#namespaceDeclarationId(java.lang.Object)
*/
public Object namespaceDefinitionId(Object namespace) {
// set wrapper name to current name
NamespaceWrapper wrapper = (NamespaceWrapper)namespace;
wrapper.setName( currName );
// create the new element
String namespaceName = wrapper.getName().toString();
Parent realParent = (Parent)wrapper.getParent();
Namespace newNameSpace = new Namespace( (ICElement)realParent, namespaceName );
wrapper.setElement(newNameSpace);
realParent.addChild( newNameSpace );
// set the ID position
newNameSpace.setIdPos(wrapper.getName().getStartOffset(), namespaceName.length());
return wrapper;
}
/* (non-Javadoc)
* @see org.eclipse.cdt.internal.core.parser.IParserCallback#namespaceDeclarationAbort(java.lang.Object)
*/
public void namespaceDefinitionAbort(Object namespace) {
namespace = null;
}
/* (non-Javadoc)
* @see org.eclipse.cdt.internal.core.parser.IParserCallback#namespaceDeclarationEnd(java.lang.Object)
*/
public void namespaceDefinitionEnd(Object namespace, Token closingBrace) {
NamespaceWrapper wrapper = (NamespaceWrapper)namespace;
Namespace celement = (Namespace)wrapper.getElement();
celement.setPos( wrapper.getFirstToken().getOffset(), wrapper.getFirstToken().getDelta(closingBrace));
}
/* (non-Javadoc)
* @see org.eclipse.cdt.internal.core.parser.IParserCallback#linkageSpecificationBegin(java.lang.Object, java.lang.String)
*/
public Object linkageSpecificationBegin(Object container, String literal) {
// until linkageSpecs are part of the code model (do they need to be?) just return the container object
return container;
}
/* (non-Javadoc)
* @see org.eclipse.cdt.internal.core.parser.IParserCallback#linkageSpecificationEnd(java.lang.Object)
*/
public void linkageSpecificationEnd(Object linkageSpec) {
// do not implement anything unless linkageSpecificationBegin does more than just return its container
}
/* (non-Javadoc)
* @see org.eclipse.cdt.internal.core.parser.IParserCallback#usingDirectiveBegin(java.lang.Object)
*/
public Object usingDirectiveBegin(Object container) {
// TODO Auto-generated method stub
return null;
}
/* (non-Javadoc)
* @see org.eclipse.cdt.internal.core.parser.IParserCallback#usingDirectiveNamespaceId(java.lang.Object)
*/
public Object usingDirectiveNamespaceId(Object container) {
// TODO Auto-generated method stub
return container;
}
/* (non-Javadoc)
* @see org.eclipse.cdt.internal.core.parser.IParserCallback#usingDirectiveEnd(java.lang.Object)
*/
public void usingDirectiveEnd(Object directive) {
// TODO Auto-generated method stub
}
/* (non-Javadoc)
* @see org.eclipse.cdt.internal.core.parser.IParserCallback#usingDeclarationBegin(java.lang.Object)
*/
public Object usingDeclarationBegin(Object container) {
// TODO Auto-generated method stub
return null;
}
/* (non-Javadoc)
* @see org.eclipse.cdt.internal.core.parser.IParserCallback#usingDeclarationMapping(java.lang.Object)
*/
public Object usingDeclarationMapping(Object container, boolean isTypename) {
// TODO Auto-generated method stub
return container;
}
/* (non-Javadoc)
* @see org.eclipse.cdt.internal.core.parser.IParserCallback#usingDeclarationEnd(java.lang.Object)
*/
public void usingDeclarationEnd(Object directive) {
// TODO Auto-generated method stub
}
/* (non-Javadoc)
* @see org.eclipse.cdt.internal.core.parser.IParserCallback#usingDirectiveAbort(java.lang.Object)
*/
public void usingDirectiveAbort(Object directive) {
// TODO Auto-generated method stub
}
/* (non-Javadoc)
* @see org.eclipse.cdt.internal.core.parser.IParserCallback#usingDeclarationAbort(java.lang.Object)
*/
public void usingDeclarationAbort(Object declaration) {
// TODO Auto-generated method stub
}
/* (non-Javadoc)
* @see org.eclipse.cdt.internal.core.parser.IParserCallback#enumSpecifierBegin(java.lang.Object)
*/
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 Object enumSpecifierId(Object enumSpec) {
((EnumerationWrapper)enumSpec).setName( currName );
return enumSpec;
}
/* (non-Javadoc)
* @see org.eclipse.cdt.internal.core.parser.IParserCallback#enumSpecifierAbort(java.lang.Object)
*/
public void enumSpecifierAbort(Object enumSpec) {
enumSpec = null;
}
/* (non-Javadoc)
* @see org.eclipse.cdt.internal.core.parser.IParserCallback#enumSpecifierEnd(java.lang.Object)
*/
public void enumSpecifierEnd(Object enumSpec, Token closingBrace) {
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 );
enumeration.setTypeName( "enum" );
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() );
String enumeratorName = subwrapper.getName().toString();
enumerator.setIdPos(subwrapper.getName().getStartOffset(), enumeratorName.length());
enumerator.setPos(subwrapper.getName().getStartOffset(),
subwrapper.getName().getNameStart().getDelta( subwrapper.getLastToken()));
enumeration.addChild( enumerator );
}
// do the offsets
if( wrapper.getName() != null )
{
enumeration.setIdPos(wrapper.getName().getStartOffset(), enumName.length());
}
else
{
enumeration.setIdPos(wrapper.getClassKind().getOffset(), wrapper.getClassKind().getLength());
}
enumeration.setPos(wrapper.getClassKind().getOffset(), wrapper.getClassKind().getDelta( closingBrace ));
}
/* (non-Javadoc)
* @see org.eclipse.cdt.internal.core.parser.IParserCallback#enumDefinitionBegin(java.lang.Object)
*/
public Object enumeratorBegin(Object enumSpec) {
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 Object enumeratorId(Object enumDefn) {
EnumeratorWrapper wrapper = (EnumeratorWrapper)enumDefn;
wrapper.setName( currName );
return wrapper;
}
/* (non-Javadoc)
* @see org.eclipse.cdt.internal.core.parser.IParserCallback#enumDefinitionEnd(java.lang.Object)
*/
public void enumeratorEnd(Object enumDefn, Token lastToken) {
EnumeratorWrapper wrapper = (EnumeratorWrapper)enumDefn;
wrapper.setLastToken( lastToken );
wrapper.getParent().addEnumerator( wrapper );
}
/* (non-Javadoc)
* @see org.eclipse.cdt.internal.core.parser.IParserCallback#asmDefinition(java.lang.String)
*/
public void asmDefinition(Object container, String assemblyCode) {
// TODO Auto-generated method stub
}
/* (non-Javadoc)
* @see org.eclipse.cdt.internal.core.parser.IParserCallback#constructorChainBegin(java.lang.Object)
*/
public Object constructorChainBegin(Object declarator) {
// TODO Auto-generated method stub
return null;
}
/* (non-Javadoc)
* @see org.eclipse.cdt.internal.core.parser.IParserCallback#constructorChainAbort(java.lang.Object)
*/
public void constructorChainAbort(Object ctor) {
// TODO Auto-generated method stub
}
/* (non-Javadoc)
* @see org.eclipse.cdt.internal.core.parser.IParserCallback#constructorChainEnd(java.lang.Object)
*/
public void constructorChainEnd(Object ctor) {
// TODO Auto-generated method stub
}
/* (non-Javadoc)
* @see org.eclipse.cdt.internal.core.parser.IParserCallback#constructorChainElementBegin(java.lang.Object)
*/
public Object constructorChainElementBegin(Object ctor) {
// TODO Auto-generated method stub
return null;
}
/* (non-Javadoc)
* @see org.eclipse.cdt.internal.core.parser.IParserCallback#constructorChainElementEnd(java.lang.Object)
*/
public void constructorChainElementEnd(Object element) {
// TODO Auto-generated method stub
}
/* (non-Javadoc)
* @see org.eclipse.cdt.internal.core.parser.IParserCallback#constructorChainId(java.lang.Object)
*/
public Object constructorChainElementId(Object ctor) {
// TODO Auto-generated method stub
return ctor;
}
/* (non-Javadoc)
* @see org.eclipse.cdt.internal.core.parser.IParserCallback#constructorChainElementExpressionListElementBegin(java.lang.Object)
*/
public Object constructorChainElementExpressionListElementBegin(Object element) {
// TODO Auto-generated method stub
return null;
}
/* (non-Javadoc)
* @see org.eclipse.cdt.internal.core.parser.IParserCallback#constructorChainElementExpressionListElementEnd(java.lang.Object)
*/
public void constructorChainElementExpressionListElementEnd(Object expression) {
// TODO Auto-generated method stub
}
/* (non-Javadoc)
* @see org.eclipse.cdt.internal.core.parser.IParserCallback#explicitInstantiationBegin(java.lang.Object)
*/
public Object explicitInstantiationBegin(Object container) {
// until explicit-instantiations are part of the code model just return the container object
return container;
}
/* (non-Javadoc)
* @see org.eclipse.cdt.internal.core.parser.IParserCallback#explicitInstantiationEnd(java.lang.Object)
*/
public void explicitInstantiationEnd(Object instantiation) {
}
/* (non-Javadoc)
* @see org.eclipse.cdt.internal.core.parser.IParserCallback#explicitSpecializationBegin(java.lang.Object)
*/
public Object explicitSpecializationBegin(Object container) {
// until explicit-specializations are part of the code model just return the container object
return container;
}
/* (non-Javadoc)
* @see org.eclipse.cdt.internal.core.parser.IParserCallback#explicitSpecializationEnd(java.lang.Object)
*/
public void explicitSpecializationEnd(Object instantiation) {
}
/* (non-Javadoc)
* @see org.eclipse.cdt.internal.core.parser.IParserCallback#declaratorPureVirtual(java.lang.Object)
*/
public Object declaratorPureVirtual(Object declarator) {
// TODO Auto-generated method stub
return declarator;
}
/* (non-Javadoc)
* @see org.eclipse.cdt.internal.core.parser.IParserCallback#templateDeclarationBegin(java.lang.Object, boolean)
*/
public Object templateDeclarationBegin(Object container, boolean exported) {
// until linkageSpecs are part of the code model just return the container object
return container;
}
/* (non-Javadoc)
* @see org.eclipse.cdt.internal.core.parser.IParserCallback#templateDeclarationAbort(java.lang.Object)
*/
public void templateDeclarationAbort(Object templateDecl) {
// TODO Auto-generated method stub
}
/* (non-Javadoc)
* @see org.eclipse.cdt.internal.core.parser.IParserCallback#templateDeclarationEnd(java.lang.Object)
*/
public void templateDeclarationEnd(Object templateDecl) {
// TODO Auto-generated method stub
}
/* (non-Javadoc)
* @see org.eclipse.cdt.internal.core.parser.IParserCallback#templateTypeParameterBegin(java.lang.Object, org.eclipse.cdt.internal.core.parser.Token)
*/
public Object templateTypeParameterBegin(Object templDecl, Token kind) {
// TODO Auto-generated method stub
return null;
}
/* (non-Javadoc)
* @see org.eclipse.cdt.internal.core.parser.IParserCallback#templateTypeParameterName(java.lang.Object)
*/
public Object templateTypeParameterName(Object typeParm) {
// TODO Auto-generated method stub
return typeParm;
}
/* (non-Javadoc)
* @see org.eclipse.cdt.internal.core.parser.IParserCallback#templateTypeInitialTypeId(java.lang.Object)
*/
public Object templateTypeParameterInitialTypeId(Object typeParm) {
// TODO Auto-generated method stub
return typeParm;
}
/* (non-Javadoc)
* @see org.eclipse.cdt.internal.core.parser.IParserCallback#templateTypeParameterEnd(java.lang.Object)
*/
public void templateTypeParameterEnd(Object typeParm) {
// TODO Auto-generated method stub
}
/* (non-Javadoc)
* @see org.eclipse.cdt.internal.core.parser.IParserCallback#templateTypeParameterAbort(java.lang.Object)
*/
public void templateTypeParameterAbort(Object typeParm) {
// TODO Auto-generated method stub
}
/* (non-Javadoc)
* @see org.eclipse.cdt.internal.core.parser.IParserCallback#pointerOperatorAbort(java.lang.Object)
*/
public void pointerOperatorAbort(Object ptrOperator) {
ptrOperator = null;
}
/* (non-Javadoc)
* @see org.eclipse.cdt.internal.core.parser.IParserCallback#templateParameterListBegin(java.lang.Object)
*/
public Object templateParameterListBegin(Object declaration) {
// TODO Auto-generated method stub
return null;
}
/* (non-Javadoc)
* @see org.eclipse.cdt.internal.core.parser.IParserCallback#templateParameterListEnd(java.lang.Object)
*/
public void templateParameterListEnd(Object parameterList) {
// TODO Auto-generated method stub
}
}

View file

@ -1,52 +0,0 @@
package org.eclipse.cdt.internal.core.model;
import java.util.LinkedList;
import java.util.List;
import org.eclipse.cdt.internal.core.parser.util.DeclSpecifier;
/**
* @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 DeclSpecifier.Container
{
DeclSpecifier declSpec = null;
/**
* @see org.eclipse.cdt.internal.core.dom.DeclarationSpecifier.CElementWrapper#getDeclSpecifier()
*/
public DeclSpecifier getDeclSpecifier() {
if( declSpec == null )
declSpec = new DeclSpecifier();
return declSpec;
}
/**
* @see org.eclipse.cdt.internal.core.dom.DeclarationSpecifier.CElementWrapper#setDeclSpecifier(org.eclipse.cdt.internal.core.dom.DeclarationSpecifier)
*/
public void setDeclSpecifier(DeclSpecifier in) {
declSpec = in;
}
private List declarators = new LinkedList();
public void addDeclarator(Object declarator) {
declarators.add(declarator);
}
public List getDeclarators() {
return declarators;
}
/**
* @see org.eclipse.cdt.internal.core.newparser.util.DeclarationSpecifier.Container#removeDeclarator(java.lang.Object)
*/
public void removeDeclarator(Object declarator) {
declarators.remove( declarator );
}
}

View file

@ -1,86 +0,0 @@
/**********************************************************************
* Created on Mar 31, 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;
/**
* @author jcamelon
*
*/
public class PointerOperator {
private final Declarator ownerDeclarator;
public PointerOperator( Declarator decl )
{
ownerDeclarator = decl;
}
/**
* @return Declarator
*/
public Declarator getOwnerDeclarator() {
return ownerDeclarator;
}
public static final int k_pointer = 1;
public static final int k_reference = 2;
private boolean isConst = false;
private boolean isVolatile = false;
private int kind;
/**
* @return boolean
*/
public boolean isConst() {
return isConst;
}
/**
* @return boolean
*/
public boolean isVolatile() {
return isVolatile;
}
/**
* @return int
*/
public int getKind() {
return kind;
}
/**
* Sets the isConst.
* @param isConst The isConst to set
*/
public void setConst(boolean isConst) {
this.isConst = isConst;
}
/**
* Sets the isVolatile.
* @param isVolatile The isVolatile to set
*/
public void setVolatile(boolean isVolatile) {
this.isVolatile = isVolatile;
}
/**
* Sets the kind.
* @param kind The kind to set
*/
public void setKind(int kind) {
this.kind = kind;
}
}

View file

@ -1,447 +0,0 @@
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.core.model.INamespace;
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;
/**
* @author jcamelon
*
*/
public class SimpleDeclarationWrapper extends DeclSpecifier implements DeclSpecifier.Container, ICElementWrapper {
private ICElement element = null;
private IParent parent = null;
Token first = null, last = null;
private Name name = null;
private boolean functionDefinition = false;
public SimpleDeclarationWrapper( IParent item )
{
this.parent = item;
}
public SimpleDeclarationWrapper()
{
}
/**
* Returns the item.
* @return CElement
*/
public ICElement getElement() {
return element;
}
/**
* Sets the item.
* @param item The item to set
*/
public void setElement (ICElement item) {
this.element = item;
}
/**
* Returns the parent.
* @return CElement
*/
public IParent getParent() {
return parent;
}
/**
* Sets the parent.
* @param parent The parent to set
*/
public void setParent(IParent 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 = (CElement)getParent();
for( int i = 0; i < declarators.length; ++i )
{
Declarator currentDeclarator = declarators[i];
CElement declaration = null;
// 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
if (currentDeclarator.getName() == null)
return;
// this is an attribute or a varaible
if( parentElement instanceof IStructure )
{
declaration = createField( parentElement, declaratorName );
}
else if(( parentElement instanceof ITranslationUnit )
|| ( parentElement instanceof INamespace ))
{
if(isExtern())
{
declaration = createVariableDeclaration( parentElement, declaratorName );
}
else
{
declaration = createVariable( parentElement, declaratorName );
}
}
}
else if( isTypedef() )
{
declaration = createTypedef( parentElement, declaratorName );
}
else
{
Parameter [] parameters = (Parameter []) clause.toArray( new Parameter[ clause.size() ]);
// this is a function or a method
if( parentElement instanceof IStructure )
{
if (isFunctionDefinition())
{
declaration = createMethod( parentElement, declaratorName, parameters );
}
else
{
declaration = createMethodDeclaration( parentElement, declaratorName, parameters );
}
}
else if(( parentElement instanceof ITranslationUnit )
|| ( parentElement instanceof INamespace ))
{
if (isFunctionDefinition())
{
// 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, declaratorName, parameters );
}
else
{
declaration = createFunctionDeclaration( parentElement, declaratorName, parameters );
}
}
}
if( currentDeclarator.getName() != null )
{
// hook up the offsets
declaration.setIdPos( currentDeclarator.getName().getStartOffset(), currentDeclarator.getName().length() );
}
else
{
declaration.setIdPos( classKind.getOffset(), classKind.getImage().toString().length());
}
declaration.setPos( getFirst().getOffset(), getFirst().getDelta( getLast() ));
// add to parent
parentElement.addChild( declaration );
}
}
List declarators = new LinkedList();
String [] myString;
public void addDeclarator( Object in )
{
declarators.add( in );
}
public List getDeclarators()
{
return declarators;
}
DeclSpecifier declSpec = null;
/**
* @see org.eclipse.cdt.internal.core.dom.DeclarationSpecifier.CElementWrapper#getDeclSpecifier()
*/
public DeclSpecifier getDeclSpecifier() {
if( declSpec == null )
declSpec = new DeclSpecifier();
return declSpec;
}
/**
* @see org.eclipse.cdt.internal.core.dom.DeclarationSpecifier.CElementWrapper#setDeclSpecifier(org.eclipse.cdt.internal.core.dom.DeclarationSpecifier)
*/
public void setDeclSpecifier(DeclSpecifier in) {
declSpec = in;
}
/**
* @see org.eclipse.cdt.internal.core.newparser.util.DeclarationSpecifier.Container#removeDeclarator(java.lang.Object)
*/
public void removeDeclarator(Object declarator) {
declarators.remove( declarator );
}
/**
* 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 Token classKind;
/**
* Returns the functionDefinition.
* @return boolean
*/
public boolean isFunctionDefinition() {
return functionDefinition;
}
/**
* Sets the functionDefinition.
* @param functionDefinition The functionDefinition to set
*/
public void setFunctionDefinition(boolean functionDefinition) {
this.functionDefinition = functionDefinition;
}
private AccessSpecifier currentVisibility = new AccessSpecifier( AccessSpecifier.v_unknown );
/**
* @return int
*/
public int getCurrentVisibility() {
return currentVisibility.getAccess();
}
/**
* Sets the currentVisibility.
* @param currentVisibility The currentVisibility to set
*/
public void setCurrentVisibility(int currentVisibility) {
this.currentVisibility.setAccess( currentVisibility );
}
/**
* Creates a Field and fills its info
* @param parent
* @param name
* @return CElement
*/
private CElement createField(CElement parent, String name){
Field newElement = new Field( parent, name );
newElement.setTypeName ( getTypeName() );
newElement.setMutable(isMutable());
newElement.setVisibility(this.getCurrentVisibility());
newElement.setConst(isConst());
newElement.setVolatile(isVolatile());
newElement.setStatic(isStatic());
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
* @param name
* @return CElement
*/
private CElement createVariable(CElement parent, String name){
Variable newElement = new Variable( parent, name );
newElement.setTypeName ( getTypeName() );
newElement.setConst(isConst());
newElement.setVolatile(isVolatile());
newElement.setStatic(isStatic());
return newElement;
}
/**
* Creates a VariableDeclaration and fills its info
* @param parent
* @param name
* @return CElement
*/
private CElement createVariableDeclaration(CElement parent, String name){
VariableDeclaration newElement = new VariableDeclaration( parent, name );
newElement.setTypeName ( getTypeName() );
newElement.setConst(isConst());
newElement.setVolatile(isVolatile());
newElement.setStatic(isStatic());
return newElement;
}
/**
* Creates a MethodDeclaration and fills its info
* @param parent
* @param name
* @param parameters
* @return CElement
*/
private CElement createMethodDeclaration(CElement parent, String name, Parameter[] parameters){
String[] parameterTypes = new String[parameters.length];
for( int j = 0; j< parameters.length; ++j )
{
Parameter param = parameters[j];
parameterTypes[j] = new String(param.getTypeName());
}
MethodDeclaration newElement = new MethodDeclaration( parent, name );
newElement.setParameterTypes(parameterTypes);
newElement.setReturnType( getTypeName() );
newElement.setVisibility(this.getCurrentVisibility());
newElement.setVolatile(isVolatile());
newElement.setStatic(isStatic());
newElement.setConst(isConst());
return newElement;
}
/**
* Creates a Method and fills its info
* @param parent
* @param name
* @param parameters
* @return CElement
*/
private CElement createMethod(CElement parent, String name, Parameter[] parameters){
String[] parameterTypes = new String[parameters.length];
for( int j = 0; j< parameters.length; ++j )
{
Parameter param = parameters[j];
parameterTypes[j] = new String(param.getTypeName());
}
Method newElement = new Method( parent, name );
newElement.setParameterTypes(parameterTypes);
newElement.setReturnType( getTypeName() );
newElement.setVisibility(this.getCurrentVisibility());
newElement.setVolatile(isVolatile());
newElement.setStatic(isStatic());
newElement.setConst(isConst());
return newElement;
}
/**
* Creates a FunctionDeclaration and fills its info
* @param parent
* @param name
* @param parameters
* @return CElement
*/
private CElement createFunctionDeclaration(CElement parent, String name, Parameter[] parameters){
String[] parameterTypes = new String[parameters.length];
for( int j = 0; j< parameters.length; ++j )
{
Parameter param = parameters[j];
parameterTypes[j] = new String(param.getTypeName());
}
FunctionDeclaration newElement = new FunctionDeclaration( parent, name );
newElement.setParameterTypes(parameterTypes);
newElement.setReturnType( getTypeName() );
newElement.setVolatile(isVolatile());
newElement.setStatic(isStatic());
return newElement;
}
/**
* Creates a Function and fills its info
* @param parent
* @param name
* @param parameters
* @return CElement
*/
private CElement createFunction(CElement parent, String name, Parameter[] parameters){
String[] parameterTypes = new String[parameters.length];
for( int j = 0; j< parameters.length; ++j )
{
Parameter param = parameters[j];
parameterTypes[j] = new String(param.getTypeName());
}
Function newElement = new Function( parent, name );
newElement.setParameterTypes(parameterTypes);
newElement.setReturnType( getTypeName() );
newElement.setVolatile(isVolatile());
newElement.setStatic(isStatic());
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;
}
/**
* @return
*/
public Token getFirst() {
return first;
}
/**
* @return
*/
public Token getLast() {
return last;
}
/**
* @param token
*/
public void setFirst(Token token) {
first = token;
}
/**
* @param token
*/
public void setLast(Token token) {
last = token;
}
}

View file

@ -1,42 +0,0 @@
package org.eclipse.cdt.internal.core.model;
import org.eclipse.cdt.core.model.ICElement;
import org.eclipse.cdt.core.model.IParent;
/**
* @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 ICElement getElement() {
return unit;
}
/**
* @see org.eclipse.cdt.internal.core.model.IWrapper#setElement(java.lang.Object)
*/
public void setElement(ICElement item) {
unit = (TranslationUnit)item;
}
public TranslationUnitWrapper( )
{
}
/**
* @see org.eclipse.cdt.internal.core.model.ICElementWrapper#getParent()
*/
public IParent getParent() {
return null;
}
}

View file

@ -16,7 +16,6 @@ import java.util.Iterator;
import java.util.LinkedList; import java.util.LinkedList;
import java.util.Map; import java.util.Map;
import org.eclipse.cdt.internal.core.parser.util.TypeInfo;
/** /**
* @author aniefer * @author aniefer

View file

@ -677,10 +677,10 @@ c, quick);
case Token.t_friend: case Token.t_friend:
case Token.t_const: case Token.t_const:
case Token.t_volatile: case Token.t_volatile:
case Token.t_signed:
case Token.t_unsigned:
try{ decl = callback.simpleDeclSpecifier(decl, consume());} catch( Exception e ) {} try{ decl = callback.simpleDeclSpecifier(decl, consume());} catch( Exception e ) {}
break; break;
case Token.t_signed:
case Token.t_unsigned:
case Token.t_short: case Token.t_short:
case Token.t_char: case Token.t_char:
case Token.t_wchar_t: case Token.t_wchar_t:
@ -825,6 +825,7 @@ c, quick);
Token first = LA(1); Token first = LA(1);
Token last = null; Token last = null;
Token mark = mark();
try{ callback.nameBegin(first); } catch( Exception e ) {} try{ callback.nameBegin(first); } catch( Exception e ) {}
if (LT(1) == Token.tCOLONCOLON) if (LT(1) == Token.tCOLONCOLON)
@ -858,6 +859,7 @@ c, quick);
} }
break; break;
default: default:
backup( mark );
throw backtrack; throw backtrack;
} }
@ -868,6 +870,9 @@ c, quick);
consume(); consume();
switch (LT(1)) { switch (LT(1)) {
case Token.t_operator:
backup( mark );
throw backtrack;
case Token.tIDENTIFIER: case Token.tIDENTIFIER:
last = consume(); last = consume();
if( LT(1) == Token.tLT ) if( LT(1) == Token.tLT )
@ -998,6 +1003,7 @@ c, quick);
*/ */
protected Object declarator( Object container ) throws Backtrack { protected Object declarator( Object container ) throws Backtrack {
boolean anonymous = false;
do do
{ {
Object declarator = null; Object declarator = null;
@ -1037,7 +1043,7 @@ c, quick);
{ {
// operator () // operator ()
consume( Token.tLPAREN ); consume( Token.tLPAREN );
toSend = toSend = consume( Token.tRPAREN ); toSend = consume( Token.tRPAREN );
} }
else if ( LT(1) == Token.tLBRACKET && LT(2) == Token.tRBRACKET ) else if ( LT(1) == Token.tLBRACKET && LT(2) == Token.tRBRACKET )
{ {
@ -1064,14 +1070,81 @@ c, quick);
callback.nameEnd( toSend ); callback.nameEnd( toSend );
} catch( Exception e ) {} } catch( Exception e ) {}
try{ declarator = callback.declaratorId(declarator);} catch( Exception e ) {}
} }
else else
{ {
name(); try
{
name();
try{ declarator = callback.declaratorId(declarator);} catch( Exception e ) {}
}
catch( Backtrack bt )
{
if( LT(1) == Token.tCOLONCOLON || LT(1) == Token.tIDENTIFIER )
{
Token start = consume();
Token end = null;
while( LT(1) == Token.tCOLONCOLON || LT(1) == Token.tIDENTIFIER )
{
end = consume();
}
if( LT(1) == Token.t_operator )
{
if( LA(1).isOperator() || LT(1) == Token.tLPAREN || LT(1) == Token.tLBRACKET )
{
if( (LT(1) == Token.t_new || LT(1) == Token.t_delete ) &&
LT(2) == Token.tLBRACKET && LT(3) == Token.tRBRACKET )
{
consume();
consume( Token.tLBRACKET );
end = consume( Token.tRBRACKET );
// vector new and delete operators
}
else if ( LT(1) == Token.tLPAREN && LT(2) == Token.tRPAREN )
{
// operator ()
consume( Token.tLPAREN );
end = consume( Token.tRPAREN );
}
else if ( LT(1) == Token.tLBRACKET && LT(2) == Token.tRBRACKET )
{
consume( Token.tLBRACKET );
end = consume( Token.tRBRACKET );
}
else if( LA(1).isOperator() )
end = consume();
else
throw backtrack;
}
else
{
// temporary
while( LT(1) != Token.tLPAREN )
{
end = consume();
}
}
try{
callback.nameBegin( start );
callback.nameEnd( end );
} catch( Exception e ) {}
try{ declarator = callback.declaratorId(declarator);} catch( Exception e ) {}
}
}
else
{
// anonymous is good
anonymous = true;
}
}
} }
try{ declarator = callback.declaratorId(declarator);} catch( Exception e ) {}
for (;;) { for (;;) {
switch (LT(1)) { switch (LT(1)) {
case Token.tLPAREN: case Token.tLPAREN:
@ -1176,6 +1249,8 @@ c, quick);
try{ callback.arrayDeclaratorEnd( array );} catch( Exception e ) {} try{ callback.arrayDeclaratorEnd( array );} catch( Exception e ) {}
} }
continue; continue;
default:
break;
} }
break; break;
} }

View file

@ -22,7 +22,6 @@ import java.util.Map;
import java.util.Set; import java.util.Set;
import java.util.Stack; import java.util.Stack;
import org.eclipse.cdt.internal.core.parser.util.TypeInfo;
/** /**
* @author aniefer * @author aniefer

View file

@ -9,10 +9,8 @@
* Rational Software - Initial API and implementation * Rational Software - Initial API and implementation
***********************************************************************/ ***********************************************************************/
package org.eclipse.cdt.internal.core.parser.util; package org.eclipse.cdt.internal.core.parser;
import org.eclipse.cdt.internal.core.parser.Declaration;
import org.eclipse.cdt.internal.core.parser.ParserSymbolTableException;
/** /**
* @author aniefer * @author aniefer

View file

@ -1,252 +0,0 @@
package org.eclipse.cdt.internal.core.parser.util;
import java.util.List;
import org.eclipse.cdt.internal.core.parser.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) {
int masked =(declSpecifierSeq & mask);
return (masked != 0);
}
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(DeclSpecifier.t_char);
break;
case Token.t_wchar_t:
setType(DeclSpecifier.t_wchar_t);
break;
case Token.t_bool:
setType(DeclSpecifier.t_bool);
break;
case Token.t_short:
setShort(true);
break;
case Token.t_int:
setType(DeclSpecifier.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(DeclSpecifier.t_float);
break;
case Token.t_double:
setType(DeclSpecifier.t_double);
break;
case Token.t_void:
setType(DeclSpecifier.t_void);
break;
case Token.tIDENTIFIER:
setType(DeclSpecifier.t_type);
break;
}
}
public void setType(int t) {
declSpecifierSeq = declSpecifierSeq & ~typeMask | t;
}
public int getType() {
return declSpecifierSeq & typeMask;
}
public interface Container {
public DeclSpecifier getDeclSpecifier();
public void setDeclSpecifier( DeclSpecifier in );
public void addDeclarator(Object declarator);
public void removeDeclarator( Object declarator );
public List getDeclarators();
};
Name name = null;
/**
* 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;
}
/**
* Returns the type as a String
* @return String
*/
public String getTypeName(){
switch(getType()){
case t_char:
return "char";
case t_wchar_t:
return "wchar_t";
case t_bool:
return "bool";
case t_int:
return "int";
case t_float:
return "float";
case t_double:
return "double";
case t_void:
return "void";
case t_type:
if (getName() != null)
return getName().toString();
default:
return "";
}
}
}

View file

@ -1,3 +1,12 @@
2003-04-09 John Camelon
Removed all the old Code Model Builder source that was no longer being used (NewModelBuilder.java, etc.).
Moved all the files in parser.util directory to the dom.
Organized imports.
Added DOMTests::testTemplateDeclarationOfMethod().
Added DOMTests::testBug36250().
Added DOMTests::testBug36240().
Added DOMTests::testBug36254().
2003-04-09 John Camelon 2003-04-09 John Camelon
Updated ScannerTest::testBug36045(). Updated ScannerTest::testBug36045().
Added ScannerTest::testBug36287(). Added ScannerTest::testBug36287().

View file

@ -11,11 +11,20 @@ import java.io.FileNotFoundException;
import junit.framework.TestCase; import junit.framework.TestCase;
import junit.framework.TestSuite; import junit.framework.TestSuite;
import org.eclipse.cdt.testplugin.*;
import org.eclipse.cdt.testplugin.util.*; import org.eclipse.cdt.core.model.IArchive;
import org.eclipse.cdt.core.model.*; import org.eclipse.cdt.core.model.IBinary;
import org.eclipse.core.resources.*; import org.eclipse.cdt.core.model.ICElement;
import org.eclipse.core.runtime.*; import org.eclipse.cdt.core.model.ICProject;
import org.eclipse.cdt.testplugin.CProjectHelper;
import org.eclipse.cdt.testplugin.util.ExpectedStrings;
import org.eclipse.core.resources.IFile;
import org.eclipse.core.resources.IWorkspace;
import org.eclipse.core.resources.IWorkspaceRoot;
import org.eclipse.core.resources.ResourcesPlugin;
import org.eclipse.core.runtime.CoreException;
import org.eclipse.core.runtime.NullProgressMonitor;
import org.eclipse.core.runtime.Path;

View file

@ -11,11 +11,19 @@ import java.io.FileNotFoundException;
import junit.framework.TestCase; import junit.framework.TestCase;
import junit.framework.TestSuite; import junit.framework.TestSuite;
import org.eclipse.cdt.testplugin.*;
import org.eclipse.cdt.testplugin.util.*; import org.eclipse.cdt.core.model.IBinary;
import org.eclipse.cdt.core.model.*; import org.eclipse.cdt.core.model.ICElement;
import org.eclipse.core.resources.*; import org.eclipse.cdt.core.model.ICProject;
import org.eclipse.core.runtime.*; import org.eclipse.cdt.testplugin.CProjectHelper;
import org.eclipse.cdt.testplugin.util.ExpectedStrings;
import org.eclipse.core.resources.IFile;
import org.eclipse.core.resources.IWorkspace;
import org.eclipse.core.resources.IWorkspaceRoot;
import org.eclipse.core.resources.ResourcesPlugin;
import org.eclipse.core.runtime.CoreException;
import org.eclipse.core.runtime.NullProgressMonitor;
import org.eclipse.core.runtime.Path;

View file

@ -11,11 +11,20 @@ import java.io.FileNotFoundException;
import junit.framework.TestCase; import junit.framework.TestCase;
import junit.framework.TestSuite; import junit.framework.TestSuite;
import org.eclipse.cdt.testplugin.*;
import org.eclipse.cdt.core.CCProjectNature; import org.eclipse.cdt.core.CCProjectNature;
import org.eclipse.cdt.core.model.*; import org.eclipse.cdt.core.model.CoreModel;
import org.eclipse.core.resources.*; import org.eclipse.cdt.core.model.ICProject;
import org.eclipse.core.runtime.*; import org.eclipse.cdt.testplugin.CProjectHelper;
import org.eclipse.core.resources.IFile;
import org.eclipse.core.resources.IProject;
import org.eclipse.core.resources.IWorkspace;
import org.eclipse.core.resources.IWorkspaceDescription;
import org.eclipse.core.resources.IWorkspaceRoot;
import org.eclipse.core.resources.ResourcesPlugin;
import org.eclipse.core.runtime.CoreException;
import org.eclipse.core.runtime.NullProgressMonitor;
import org.eclipse.core.runtime.Path;
/** /**

View file

@ -12,11 +12,22 @@ import java.util.Stack;
import junit.framework.TestCase; import junit.framework.TestCase;
import junit.framework.TestSuite; import junit.framework.TestSuite;
import org.eclipse.cdt.testplugin.*;
import org.eclipse.cdt.testplugin.util.*; import org.eclipse.cdt.core.model.CModelException;
import org.eclipse.cdt.core.model.*; import org.eclipse.cdt.core.model.ICElement;
import org.eclipse.core.resources.*; import org.eclipse.cdt.core.model.ICProject;
import org.eclipse.core.runtime.*; import org.eclipse.cdt.core.model.IInclude;
import org.eclipse.cdt.core.model.ITranslationUnit;
import org.eclipse.cdt.testplugin.CProjectHelper;
import org.eclipse.cdt.testplugin.util.ExpectedStrings;
import org.eclipse.core.resources.IFile;
import org.eclipse.core.resources.IWorkspace;
import org.eclipse.core.resources.IWorkspaceDescription;
import org.eclipse.core.resources.IWorkspaceRoot;
import org.eclipse.core.resources.ResourcesPlugin;
import org.eclipse.core.runtime.CoreException;
import org.eclipse.core.runtime.NullProgressMonitor;
import org.eclipse.core.runtime.Path;

View file

@ -8,13 +8,16 @@ import java.util.List;
import junit.framework.TestCase; import junit.framework.TestCase;
import org.eclipse.cdt.internal.core.dom.ASMDefinition; import org.eclipse.cdt.internal.core.dom.ASMDefinition;
import org.eclipse.cdt.internal.core.dom.AccessSpecifier;
import org.eclipse.cdt.internal.core.dom.ArrayQualifier; import org.eclipse.cdt.internal.core.dom.ArrayQualifier;
import org.eclipse.cdt.internal.core.dom.BaseSpecifier; import org.eclipse.cdt.internal.core.dom.BaseSpecifier;
import org.eclipse.cdt.internal.core.dom.ClassKey;
import org.eclipse.cdt.internal.core.dom.ClassSpecifier; import org.eclipse.cdt.internal.core.dom.ClassSpecifier;
import org.eclipse.cdt.internal.core.dom.ConstructorChain; import org.eclipse.cdt.internal.core.dom.ConstructorChain;
import org.eclipse.cdt.internal.core.dom.ConstructorChainElement; import org.eclipse.cdt.internal.core.dom.ConstructorChainElement;
import org.eclipse.cdt.internal.core.dom.ConstructorChainElementExpression; import org.eclipse.cdt.internal.core.dom.ConstructorChainElementExpression;
import org.eclipse.cdt.internal.core.dom.DOMBuilder; import org.eclipse.cdt.internal.core.dom.DOMBuilder;
import org.eclipse.cdt.internal.core.dom.DeclSpecifier;
import org.eclipse.cdt.internal.core.dom.Declarator; import org.eclipse.cdt.internal.core.dom.Declarator;
import org.eclipse.cdt.internal.core.dom.ElaboratedTypeSpecifier; import org.eclipse.cdt.internal.core.dom.ElaboratedTypeSpecifier;
import org.eclipse.cdt.internal.core.dom.EnumerationSpecifier; import org.eclipse.cdt.internal.core.dom.EnumerationSpecifier;
@ -25,6 +28,7 @@ import org.eclipse.cdt.internal.core.dom.Expression;
import org.eclipse.cdt.internal.core.dom.Inclusion; import org.eclipse.cdt.internal.core.dom.Inclusion;
import org.eclipse.cdt.internal.core.dom.LinkageSpecification; import org.eclipse.cdt.internal.core.dom.LinkageSpecification;
import org.eclipse.cdt.internal.core.dom.Macro; import org.eclipse.cdt.internal.core.dom.Macro;
import org.eclipse.cdt.internal.core.dom.Name;
import org.eclipse.cdt.internal.core.dom.NamespaceDefinition; import org.eclipse.cdt.internal.core.dom.NamespaceDefinition;
import org.eclipse.cdt.internal.core.dom.ParameterDeclaration; import org.eclipse.cdt.internal.core.dom.ParameterDeclaration;
import org.eclipse.cdt.internal.core.dom.ParameterDeclarationClause; import org.eclipse.cdt.internal.core.dom.ParameterDeclarationClause;
@ -38,14 +42,7 @@ import org.eclipse.cdt.internal.core.dom.UsingDirective;
import org.eclipse.cdt.internal.core.parser.Parser; import org.eclipse.cdt.internal.core.parser.Parser;
import org.eclipse.cdt.internal.core.parser.ParserException; import org.eclipse.cdt.internal.core.parser.ParserException;
import org.eclipse.cdt.internal.core.parser.Token; 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.ClassKey;
import org.eclipse.cdt.internal.core.parser.util.DeclSpecifier;
import org.eclipse.cdt.internal.core.parser.util.Name;
/**
* Tests the construction of DOMs for snippets of code
*/
public class DOMTests extends TestCase { public class DOMTests extends TestCase {
public DOMTests( String arg ) public DOMTests( String arg )
@ -986,7 +983,35 @@ public class DOMTests extends TestCase {
} }
} }
public void testTemplateDeclaration() throws Exception { public void testTemplateDeclarationOfMethod() throws Exception
{
TranslationUnit tu = parse( "template<class A, typename B=C> A aTemplatedFunction( B bInstance );");
assertEquals( tu.getDeclarations().size(), 1 );
TemplateDeclaration templateDeclaration = (TemplateDeclaration)tu.getDeclarations().get(0);
assertEquals( templateDeclaration.getTemplateParms().getDeclarations().size(), 2 );
TemplateParameter templateParameter = (TemplateParameter)templateDeclaration.getTemplateParms().getDeclarations().get(0);
assertEquals( templateParameter.getKind(), TemplateParameter.k_class );
assertEquals( templateParameter.getName().toString(), "A");
templateParameter = (TemplateParameter)templateDeclaration.getTemplateParms().getDeclarations().get(1);
assertEquals( templateParameter.getKind(), TemplateParameter.k_typename );
assertEquals( templateParameter.getName().toString(), "B");
assertEquals( templateParameter.getTypeId().toString(), "C");
assertEquals( templateDeclaration.getDeclarations().size(), 1 );
SimpleDeclaration methodDeclaration = (SimpleDeclaration) templateDeclaration.getDeclarations().get(0);
assertEquals( methodDeclaration.getDeclSpecifier().getType(), DeclSpecifier.t_type );
assertEquals( methodDeclaration.getDeclSpecifier().getTypeName(), "A");
assertEquals( methodDeclaration.getDeclarators().size(), 1 );
Declarator declarator = (Declarator)methodDeclaration.getDeclarators().get(0);
assertEquals( declarator.getName().toString(), "aTemplatedFunction" );
assertEquals( declarator.getParms().getDeclarations().size(), 1 );
ParameterDeclaration parameterDeclaration = (ParameterDeclaration)declarator.getParms().getDeclarations().get(0);
assertEquals( parameterDeclaration.getDeclSpecifier().getType(), DeclSpecifier.t_type );
assertEquals( parameterDeclaration.getDeclSpecifier().getTypeName(), "B" );
assertEquals( parameterDeclaration.getDeclarators().size(), 1 );
assertEquals( ((Declarator)parameterDeclaration.getDeclarators().get(0)).getName().toString(), "bInstance");
}
public void testTemplateDeclarationOfClass() throws Exception {
TranslationUnit tu = parse( "template<class T, typename Tibor = junk, class, typename, int x, float y,template <class Y> class, template<class A> class AClass> class myarray { /* ... */ };"); TranslationUnit tu = parse( "template<class T, typename Tibor = junk, class, typename, int x, float y,template <class Y> class, template<class A> class AClass> class myarray { /* ... */ };");
assertEquals( tu.getDeclarations().size(), 1 ); assertEquals( tu.getDeclarations().size(), 1 );
TemplateDeclaration declaration = (TemplateDeclaration)tu.getDeclarations().get(0); TemplateDeclaration declaration = (TemplateDeclaration)tu.getDeclarations().get(0);
@ -1137,6 +1162,68 @@ public class DOMTests extends TestCase {
} }
} }
public void testBug36250() throws Exception
{
TranslationUnit tu = parse( "int f( int = 0 );");
assertEquals( tu.getDeclarations().size(), 1 );
SimpleDeclaration functionDeclaration = (SimpleDeclaration)tu.getDeclarations().get(0);
assertEquals( functionDeclaration.getDeclSpecifier().getType(), DeclSpecifier.t_int );
assertEquals( functionDeclaration.getDeclarators().size(), 1 );
Declarator functionDeclarator = (Declarator)functionDeclaration.getDeclarators().get(0);
assertEquals( functionDeclarator.getName().toString(), "f" );
assertEquals( functionDeclarator.getParms().getDeclarations().size(), 1 );
ParameterDeclaration parameterDeclaration = (ParameterDeclaration)functionDeclarator.getParms().getDeclarations().get(0);
assertEquals( parameterDeclaration .getDeclSpecifier().getType(), DeclSpecifier.t_int );
assertEquals( parameterDeclaration .getDeclarators().size(), 1 );
Declarator parameterDeclarator = (Declarator)parameterDeclaration.getDeclarators().get(0);
assertNull( parameterDeclarator.getName() );
assertNotNull( parameterDeclarator.getExpression());
}
public void testBug36240() throws Exception
{
TranslationUnit tu = parse( "A & A::operator=( A ){}");
assertEquals( tu.getDeclarations().size(), 1 );
SimpleDeclaration functionDeclaration = (SimpleDeclaration)tu.getDeclarations().get(0);
assertEquals( functionDeclaration.getDeclSpecifier().getType(), DeclSpecifier.t_type );
assertEquals( functionDeclaration.getDeclSpecifier().getTypeName(), "A" );
assertEquals( functionDeclaration.getDeclarators().size(), 1 );
Declarator functionDeclarator = (Declarator)functionDeclaration.getDeclarators().get(0);
assertEquals( functionDeclarator.getPointerOperators().size(), 1 );
PointerOperator po = (PointerOperator)functionDeclarator.getPointerOperators().get(0);
assertEquals( po.getType(), PointerOperator.t_reference );
assertFalse( po.isConst() || po.isVolatile() );
assertEquals( functionDeclarator.getName().toString(), "A::operator=");
assertEquals( functionDeclarator.getParms().getDeclarations().size(), 1 );
ParameterDeclaration parameterDeclaration = (ParameterDeclaration)functionDeclarator.getParms().getDeclarations().get(0);
assertEquals( parameterDeclaration.getDeclSpecifier().getType(), DeclSpecifier.t_type );
assertEquals( parameterDeclaration.getDeclSpecifier().getTypeName(), "A");
assertEquals( parameterDeclaration .getDeclarators().size(), 1 );
Declarator parameterDeclarator = (Declarator)parameterDeclaration.getDeclarators().get(0);
assertNull( parameterDeclarator.getName() );
}
public void testBug36254() throws Exception
{
TranslationUnit tu = parse( "unsigned i;\nvoid f( unsigned p1 = 0 );");
assertEquals( tu.getDeclarations().size(), 2 );
SimpleDeclaration declaration = (SimpleDeclaration)tu.getDeclarations().get(0);
assertTrue( declaration.getDeclSpecifier().isUnsigned());
assertEquals( 1, declaration.getDeclarators().size() );
assertEquals( "i", ((Declarator)declaration.getDeclarators().get(0)).getName().toString() );
declaration = (SimpleDeclaration)tu.getDeclarations().get(1);
assertEquals( declaration.getDeclSpecifier().getType(), DeclSpecifier.t_void );
assertEquals( 1, declaration.getDeclarators().size() );
Declarator declarator = (Declarator)declaration.getDeclarators().get(0);
assertEquals( declarator.getName().toString(), "f" );
assertEquals( declarator.getParms().getDeclarations().size(), 1 );
ParameterDeclaration parmDecl = (ParameterDeclaration)declarator.getParms().getDeclarations().get(0);
assertTrue( parmDecl.getDeclSpecifier().isUnsigned());
assertEquals( parmDecl.getDeclarators().size(), 1 );
Declarator parmDeclarator = (Declarator) parmDecl.getDeclarators().get(0);
assertEquals( parmDeclarator.getName().toString(), "p1");
assertNotNull( parmDeclarator.getExpression());
}
} }

View file

@ -20,7 +20,7 @@ import junit.framework.TestCase;
import org.eclipse.cdt.internal.core.parser.Declaration; import org.eclipse.cdt.internal.core.parser.Declaration;
import org.eclipse.cdt.internal.core.parser.ParserSymbolTable; import org.eclipse.cdt.internal.core.parser.ParserSymbolTable;
import org.eclipse.cdt.internal.core.parser.ParserSymbolTableException; import org.eclipse.cdt.internal.core.parser.ParserSymbolTableException;
import org.eclipse.cdt.internal.core.parser.util.TypeInfo; import org.eclipse.cdt.internal.core.parser.TypeInfo;
/** /**
* @author aniefer * @author aniefer