Skip to main content

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [List Home]
Applied: [cdt-patch] Parser patch - Adding offsets to TemplateDeclarat ions for outline view



CORE
Updated callbacks and parser to add offset information to template

declarations,
thus making TemplateDeclaration implement IOffsetable.


JohnC aka Dude

> -----Original Message-----
> From: Schaefer, Doug [mailto:dschaefer@xxxxxxxxxxxx]
> Sent: Thursday, April 10, 2003 12:59 PM
> To: 'cdt-patch@xxxxxxxxxxx'
> Subject: RE: [cdt-patch] Parser patch - Adding offsets to
> TemplateDeclarat ions for outline view
>
>
> Dude, Outlook is messing up your patch.  Please attach the patch file.
>
> Doug Schaefer
> Rational Software - IBM Software Group
> Ottawa (Kanata), Ontario, Canada
>
>
> -----Original Message-----
> From: Camelon, John [mailto:jcamelon@xxxxxxxxxxxx]
> Sent: Thursday, April 10, 2003 12:00 PM
> To: Cdt-Patch (E-mail)
> Subject: [cdt-patch] Parser patch - Adding offsets to
> TemplateDeclarations
> for outline view
>
>
> Index: dom/org/eclipse/cdt/internal/core/dom/DOMBuilder.java
> ===================================================================
> RCS file:
> /home/tools/org.eclipse.cdt.core/dom/org/eclipse/cdt/internal/
> core/dom/DOMBu
> ilder.java,v
> retrieving revision 1.18
> diff -u -r1.18 DOMBuilder.java
> --- dom/org/eclipse/cdt/internal/core/dom/DOMBuilder.java
> 9 Apr 2003
> 21:11:59 -0000        1.18
> +++ dom/org/eclipse/cdt/internal/core/dom/DOMBuilder.java
> 10 Apr 2003
> 16:02:07 -0000
> @@ -813,7 +813,7 @@
>          /* (non-Javadoc)
>           * @see
> org.eclipse.cdt.internal.core.parser.IParserCallback#templateD
> eclarationBegi
> n(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 @@
>          /* (non-Javadoc)
>           * @see
> org.eclipse.cdt.internal.core.parser.IParserCallback#templateD
> eclarationEnd(
> 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);
>          }
>
> Index: dom/org/eclipse/cdt/internal/core/dom/TemplateDeclaration.java
> ===================================================================
> RCS file:
> /home/tools/org.eclipse.cdt.core/dom/org/eclipse/cdt/internal/
> core/dom/Templ
> ateDeclaration.java,v
> retrieving revision 1.2
> diff -u -r1.2 TemplateDeclaration.java
> ---
> dom/org/eclipse/cdt/internal/core/dom/TemplateDeclarati
> on.java        4
> Apr 2003 14:05:18 -0000        1.2
> +++
> dom/org/eclipse/cdt/internal/core/dom/TemplateDeclarati
> on.java        10
> Apr 2003 16:02:09 -0000
> @@ -16,21 +16,25 @@
>  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)
> @@ -73,6 +77,62 @@
>           */
>          public void setTemplateParms(TemplateParameterList list) {
>                  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!");
>          }
>
>  }
> Index:
> parser/org/eclipse/cdt/internal/core/parser/ExpressionEvaluator.java
> ===================================================================
> RCS file:
> /home/tools/org.eclipse.cdt.core/parser/org/eclipse/cdt/intern
> al/core/parser
> /ExpressionEvaluator.java,v
> retrieving revision 1.16
> diff -u -r1.16 ExpressionEvaluator.java
> ---
> parser/org/eclipse/cdt/internal/core/parser/ExpressionEvaluator.java
> 6 Apr 2003 03:06:16 -0000        1.16
> +++
> parser/org/eclipse/cdt/internal/core/parser/ExpressionEvaluator.java
> 10 Apr 2003 16:02:23 -0000
> @@ -680,7 +680,7 @@
>          /* (non-Javadoc)
>           * @see
> org.eclipse.cdt.internal.core.parser.IParserCallback#templateD
> eclarationBegi
> n(java.lang.Object, boolean)
>           */
> -        public Object templateDeclarationBegin(Object container, boolean
> exported) {
> +        public Object templateDeclarationBegin(Object container, Token
> exported) {
>                  return null;
>          }
>
> @@ -693,7 +693,7 @@
>          /* (non-Javadoc)
>           * @see
> org.eclipse.cdt.internal.core.parser.IParserCallback#templateD
> eclarationEnd(
> java.lang.Object)
>           */
> -        public void templateDeclarationEnd(Object templateDecl) {
> +        public void templateDeclarationEnd(Object templateDecl, Token
> lastToken) {
>          }
>
>          /* (non-Javadoc)
> Index:
> parser/org/eclipse/cdt/internal/core/parser/IParserCallback.java
> ===================================================================
> RCS file:
> /home/tools/org.eclipse.cdt.core/parser/org/eclipse/cdt/intern
> al/core/parser
> /IParserCallback.java,v
> retrieving revision 1.15
> diff -u -r1.15 IParserCallback.java
> ---
> parser/org/eclipse/cdt/internal/core/parser/IParserCallba
> ck.java        6
> Apr 2003 03:06:16 -0000        1.15
> +++
> parser/org/eclipse/cdt/internal/core/parser/IParserCallba
> ck.java        10
> Apr 2003 16:02:25 -0000
> @@ -124,9 +124,9 @@
>          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 );
> Index:
> parser/org/eclipse/cdt/internal/core/parser/NullParserCallback.java
> ===================================================================
> RCS file:
> /home/tools/org.eclipse.cdt.core/parser/org/eclipse/cdt/intern
> al/core/parser
> /NullParserCallback.java,v
> retrieving revision 1.15
> diff -u -r1.15 NullParserCallback.java
> ---
> parser/org/eclipse/cdt/internal/core/parser/NullParserCallba
> ck.java        6
> Apr 2003 03:06:16 -0000        1.15
> +++
> parser/org/eclipse/cdt/internal/core/parser/NullParserCallba
> ck.java        10
> Apr 2003 16:02:28 -0000
> @@ -569,7 +569,7 @@
>          /* (non-Javadoc)
>           * @see
> org.eclipse.cdt.internal.core.parser.IParserCallback#templateD
> eclarationBegi
> n(java.lang.Object, boolean)
>           */
> -        public Object templateDeclarationBegin(Object container, boolean
> exported) {
> +        public Object templateDeclarationBegin(Object container, Token
> exported) {
>                  return null;
>          }
>
> @@ -582,7 +582,7 @@
>          /* (non-Javadoc)
>           * @see
> org.eclipse.cdt.internal.core.parser.IParserCallback#templateD
> eclarationEnd(
> java.lang.Object)
>           */
> -        public void templateDeclarationEnd(Object templateDecl) {
> +        public void templateDeclarationEnd(Object templateDecl, Token
> lastToken) {
>          }
>
>          /* (non-Javadoc)
> Index: parser/org/eclipse/cdt/internal/core/parser/Parser.java
> ===================================================================
> RCS file:
> /home/tools/org.eclipse.cdt.core/parser/org/eclipse/cdt/intern
> al/core/parser
> /Parser.java,v
> retrieving revision 1.25
> diff -u -r1.25 Parser.java
> --- parser/org/eclipse/cdt/internal/core/parser/Parser.java
> 9 Apr 2003
> 21:11:59 -0000        1.25
> +++ parser/org/eclipse/cdt/internal/core/parser/Parser.java
> 10 Apr 2003
> 16:02:35 -0000
> @@ -283,14 +283,16 @@
>           */
>          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 @@
>                  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 )
>                  {
> _______________________________________________
> cdt-patch mailing list
> cdt-patch@xxxxxxxxxxx
> http://dev.eclipse.org/mailman/listinfo/cdt-patch
> _______________________________________________
> cdt-patch mailing list
> cdt-patch@xxxxxxxxxxx
> http://dev.eclipse.org/mailman/listinfo/cdt-patch
>





#### cdt-core-patch.txt has been removed from this note on April 10, 2003 by Douglas Schaefer

Back to the top