Re: [groovy-dev] DeclarationExpression.getVariableExpression should be deprecated?
Back to the discussion of DeclarationExpression...
This object has the following API:
class DeclarationExpression
- DeclarationExpression(Expression, Token, Expression) - For this constructor the left expression
_must_ be of type VariableExpression or a TupleExpression with one or more elements.
- getVariableExpression() : VariableExpression - as we discussed, this can throw a ClassCastException
- isMultipleAssignmentDeclaration() - returns true if the left hand side is a ArgumentListExpression
So...
I added deprecated to getVariableExpression() and we found two bugs in Groovy. Both have JIRAs. However,
the isMultipleAssignmentDeclaration() method does exist, and there is a safe way to work with this
object.
I think we should remove the deprecation and write better javadoc for the object. Since the API allows safe
usage there is no need for a deprecation. I did this already but have not checked in. What do you think?
Second issue: It is possible to create a DeclarationExpression with a TupleExpression that is _not_ an
ArgumentListExpression. In this case isMultipleAssignmentDeclaration() returns false but
getVariableExpression() still throws an exception. I believe we should change the implementation of
this method from:
public boolean isMultipleAssignmentDeclaration() {
return getLeftExpression() instanceof ArgumentListExpression;
}
to:
public boolean isMultipleAssignmentDeclaration() {
return getLeftExpression() instanceof TupleExpression;
}
Is that correct?
Thanks,
--
Hamlet D'Arcy
hamlet.darcy@...
----- Original Message -----
> >> am fixing the Category AST warning now - which unsurfaced a bug.
> >>
>
> Yes, we need to analyze each usage and see if that usage breaks when a
> multiple assignment is encountered. Should we create a JIRA
> placeholder for this and I can do the analysis over the next couple
> days?
>
>
> >> Created http://jira.codehaus.org/browse/GROOVY-4547 for the some
> >> issues that I noticed in the new AST Browser UI.
>
> Thanks Roshan. It is assigned to you but feel free to assign it to me.
>
> --
> Hamlet D'Arcy
> hamlet.darcy@...
>
> ----- Original Message -----
>
>
>
> I am fixing the Category AST warning now - which unsurfaced a bug.
>
> Paul.
>
> On 1/12/2010 2:09 PM, Paul King wrote:
> > On 1/12/2010 6:20 AM, Hamlet DArcy wrote:
> >> Let's just deprecate the method and leave it at that.
> >
> > There seems to be a bunch of warnings now that weren't cleaned up
> > when the method was deprecated.
> >
> > Cheers, Paul.
> >
> > ---------------------------------------------------------------------
> > To unsubscribe from this list, please visit:
> >
> > http://xircles.codehaus.org/manage_email
> >
> >
> >
>
>
> ---------------------------------------------------------------------
> To unsubscribe from this list, please visit:
>
> http://xircles.codehaus.org/manage_email
>
>
>
>
> ---------------------------------------------------------------------
> To unsubscribe from this list, please visit:
>
> http://xircles.codehaus.org/manage_email
---------------------------------------------------------------------
To unsubscribe from this list, please visit:
http://xircles.codehaus.org/manage_email