1
0
Fork 0
mirror of https://github.com/eclipse-cdt/cdt synced 2025-04-29 19:45:01 +02:00

Patch for John Camelon:

CORE
- Updated callbacks and parser to add offset information to template
declarations, thus making TemplateDeclaration implement IOffsetable.
This commit is contained in:
Doug Schaefer 2003-04-10 17:25:06 +00:00
parent 006348900f
commit 938a074dd8
7 changed files with 85 additions and 18 deletions

View file

@ -813,7 +813,7 @@ public class DOMBuilder implements IParserCallback
/* (non-Javadoc)
* @see org.eclipse.cdt.internal.core.parser.IParserCallback#templateDeclarationBegin(java.lang.Object, boolean)
*/
public Object templateDeclarationBegin(Object container, boolean exported) {
public Object templateDeclarationBegin(Object container, Token exported) {
return new TemplateDeclaration( (IScope)container, exported );
}
@ -827,8 +827,9 @@ public class DOMBuilder implements IParserCallback
/* (non-Javadoc)
* @see org.eclipse.cdt.internal.core.parser.IParserCallback#templateDeclarationEnd(java.lang.Object)
*/
public void templateDeclarationEnd(Object templateDecl) {
public void templateDeclarationEnd(Object templateDecl, Token lastToken) {
TemplateDeclaration decl = (TemplateDeclaration)templateDecl;
decl.setLastToken(lastToken);
decl.getOwnerScope().addDeclaration(decl);
}

View file

@ -16,21 +16,25 @@ import java.util.ArrayList;
import java.util.Collections;
import java.util.List;
import org.eclipse.cdt.internal.core.parser.Token;
/**
* @author jcamelon
*
*/
public class TemplateDeclaration extends Declaration implements IScope, ITemplateParameterListOwner {
public class TemplateDeclaration extends Declaration implements IScope, ITemplateParameterListOwner, IOffsetable {
private final boolean exported;
private final boolean exported;
private Token firstToken, lastToken;
private IScope ownerScope;
private List declarations = new ArrayList();
private TemplateParameterList templateParms = null;
public TemplateDeclaration( IScope ownerScope, boolean exported )
public TemplateDeclaration( IScope ownerScope, Token exported )
{
this.ownerScope = ownerScope;
this.exported = exported;
this.firstToken = exported;
this.exported = exported.getType() == Token.t_export ? true : false;
}
/* (non-Javadoc)
@ -75,4 +79,60 @@ public class TemplateDeclaration extends Declaration implements IScope, ITemplat
templateParms = list;
}
/**
* @return
*/
public Token getFirstToken() {
return firstToken;
}
/**
* @return
*/
public Token getLastToken() {
return lastToken;
}
/**
* @param token
*/
public void setFirstToken(Token token) {
firstToken = token;
}
/**
* @param token
*/
public void setLastToken(Token token) {
lastToken = token;
}
/* (non-Javadoc)
* @see org.eclipse.cdt.internal.core.dom.IOffsetable#getStartingOffset()
*/
public int getStartingOffset() {
return getFirstToken().getOffset();
}
/* (non-Javadoc)
* @see org.eclipse.cdt.internal.core.dom.IOffsetable#getTotalLength()
*/
public int getTotalLength() {
return getLastToken().getOffset() + getLastToken().getLength() - getStartingOffset();
}
/* (non-Javadoc)
* @see org.eclipse.cdt.internal.core.dom.IOffsetable#setStartingOffset(int)
*/
public void setStartingOffset(int i) {
throw new Error( "Sorry, not implemented bucko!");
}
/* (non-Javadoc)
* @see org.eclipse.cdt.internal.core.dom.IOffsetable#setTotalLength(int)
*/
public void setTotalLength(int i) {
throw new Error( "Sorry, not implemented bucko!");
}
}

View file

@ -1,3 +1,7 @@
2003-04-10 John Camelon
Updated callbacks and parser to add offset information to template declarations,
thus making TemplateDeclaration implement IOffsetable.
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.

View file

@ -680,7 +680,7 @@ public class ExpressionEvaluator implements IParserCallback {
/* (non-Javadoc)
* @see org.eclipse.cdt.internal.core.parser.IParserCallback#templateDeclarationBegin(java.lang.Object, boolean)
*/
public Object templateDeclarationBegin(Object container, boolean exported) {
public Object templateDeclarationBegin(Object container, Token exported) {
return null;
}
@ -693,7 +693,7 @@ public class ExpressionEvaluator implements IParserCallback {
/* (non-Javadoc)
* @see org.eclipse.cdt.internal.core.parser.IParserCallback#templateDeclarationEnd(java.lang.Object)
*/
public void templateDeclarationEnd(Object templateDecl) {
public void templateDeclarationEnd(Object templateDecl, Token lastToken) {
}
/* (non-Javadoc)

View file

@ -124,9 +124,9 @@ public interface IParserCallback {
public Object explicitSpecializationBegin( Object container );
public void explicitSpecializationEnd( Object instantiation );
public Object templateDeclarationBegin( Object container, boolean exported );
public Object templateDeclarationBegin( Object container, Token firstToken );
public void templateDeclarationAbort( Object templateDecl );
public void templateDeclarationEnd( Object templateDecl );
public void templateDeclarationEnd( Object templateDecl, Token lastToken );
public Object templateParameterListBegin( Object declaration );
public void templateParameterListEnd( Object parameterList );

View file

@ -569,7 +569,7 @@ public class NullParserCallback implements IParserCallback {
/* (non-Javadoc)
* @see org.eclipse.cdt.internal.core.parser.IParserCallback#templateDeclarationBegin(java.lang.Object, boolean)
*/
public Object templateDeclarationBegin(Object container, boolean exported) {
public Object templateDeclarationBegin(Object container, Token exported) {
return null;
}
@ -582,7 +582,7 @@ public class NullParserCallback implements IParserCallback {
/* (non-Javadoc)
* @see org.eclipse.cdt.internal.core.parser.IParserCallback#templateDeclarationEnd(java.lang.Object)
*/
public void templateDeclarationEnd(Object templateDecl) {
public void templateDeclarationEnd(Object templateDecl, Token lastToken) {
}
/* (non-Javadoc)

View file

@ -283,14 +283,16 @@ c, quick);
*/
protected void templateDeclaration( Object container ) throws Backtrack
{
boolean export = false;
Token firstToken = null;
if( LT(1) == Token.t_export )
{
consume( Token.t_export );
export = true;
firstToken = consume( Token.t_export );
consume( Token.t_template );
}
else
firstToken = consume( Token.t_template );
consume( Token.t_template );
if( LT(1) != Token.tLT )
{
// explicit-instantiation
@ -318,11 +320,11 @@ c, quick);
Object templateDeclaration = null;
try
{
try{ templateDeclaration = callback.templateDeclarationBegin( container, export ); } catch ( Exception e ) {}
try{ templateDeclaration = callback.templateDeclarationBegin( container, firstToken ); } catch ( Exception e ) {}
templateParameterList( templateDeclaration );
consume( Token.tGT );
declaration( templateDeclaration );
try{ callback.templateDeclarationEnd( templateDeclaration ); } catch( Exception e ) {}
try{ callback.templateDeclarationEnd( templateDeclaration, lastToken ); } catch( Exception e ) {}
} catch( Backtrack bt )
{