Skip to main content

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [List Home]
Re: [hibachi-dev] SourceRange for an AdaVariable

Todd,

If I understand correctly, the situation you're mentioning only occurs when there are multiple variables declared with a single type, as in O1 and O2 in your example below.

IAdaVariable object refers to the name and type, so the range must include both. We could have the range for the O2 variable be "O2 : out Integer", but I don't like the idea splitting up a declaration like that.


FWIW, I checked the JDT model, and for field declarations like this:

public int i1, i2;

Both the source range for both i1 and i2 is "public int i1, i2;", just like Hibachi is doing.

Does anyone else have an opinion on this?

Adam

----- Original Message ----- From: "Todd Wallentine" <tcw@xxxxxxx>
To: "Hibachi Dev list" <hibachi-dev@xxxxxxxxxxx>
Sent: Friday, July 11, 2008 4:51 PM
Subject: [hibachi-dev] SourceRange for an AdaVariable


Hibachi Devs,

While working with Hibachi's underlying object model I noticed something that might be a bug. I wanted to run it by the devs list to see if it was indeed a bug before I reported it as such.

What I am seeing is that the SourceRange instance is re-used for all IAdaVariables that are declared in a list. For example, if I have the following Ada code:

procedure P1 (I : in Integer; O1, O2 : out Integer)

the SourceRange would be the same for O1 and O2 (not only are the values the same but the instance is the same).

I did find what is likely the cause of this. In the AdaASTParser class (package: org.eclipse.hibachi.model.internal) the method parseVariableDeclaration has the following snippets:

// Use the same source range for all variable declarations from
// the same list
ISourceRange range = ParserHelper.getElementRange(m_lineTracker, sourceAst);

and then later does this:

IAdaVariable[] ret = new IAdaVariable[identifiers.size()];
for (int i = 0; i < identifiers.size(); ++i)
{
ret[i] = new AdaVariable(parentMember.getCompilationUnit(), parentName, (String)identifiers.get(i), false, flags, range, typeReference);
}
return ret;

So it would appear that this was done on purpose. But this doesn't seem to be correct - or at least I would prefer that the source ranges are different. So is this a bug or just me not understanding what the SourceRange should be?

thanks,
todd
_______________________________________________
hibachi-dev mailing list
hibachi-dev@xxxxxxxxxxx
https://dev.eclipse.org/mailman/listinfo/hibachi-dev



Back to the top