Home » Language IDEs » C / C++ IDE (CDT) » Question about the CDT Parser : Access Visibility
Question about the CDT Parser : Access Visibility [message #144806] |
Fri, 06 May 2005 20:18 |
Eclipse User |
|
|
|
Originally posted by: fliao2.yahoo.ca
Hi, I've been plugging away with using the parser, and I've come across a
problem. I can see that the ASTAccessVisibility class stores the access
level (i.e., private, protected, public) for member variables/functions of
a class, but there's no accessor function to get the actual value
contained inside. How am I supposed to figure out the access level for a
given member?
|
|
|
Re: Question about the CDT Parser : Access Visibility [message #144990 is a reply to message #144806] |
Tue, 10 May 2005 18:03 |
Andrew Niefer Messages: 990 Registered: July 2009 |
Senior Member |
|
|
ASTAccessVisiblity defines 3 static final instances of itself. PUBLIC,
PROTECTED, PRIVATE.
When you call IASTMember.getVisibility(), you will get back one of those
instances. So just do something like boolean ispublic =
(field.getVisibility() == ASTAccessVisibility.PUBLIC);
This pattern was trying to be like an enumeration in C++.
Note that in the new DOM AST, the visibility constants are just integers,
see ICPPASTVisibilityLabel and/or ICPPMember. in the dom.ast package.
-Andrew
"Felix" <fliao2@yahoo.ca> wrote in message
news:93b3c59de834444f05259c29156434d5$1@www.eclipse.org...
> Hi, I've been plugging away with using the parser, and I've come across a
> problem. I can see that the ASTAccessVisibility class stores the access
> level (i.e., private, protected, public) for member variables/functions of
> a class, but there's no accessor function to get the actual value
> contained inside. How am I supposed to figure out the access level for a
> given member?
>
|
|
|
Re: Question about the CDT Parser : Access Visibility [message #145007 is a reply to message #144990] |
Tue, 10 May 2005 18:35 |
Eclipse User |
|
|
|
Originally posted by: fliao2.yahoo.ca
Thanks, that worked. On a related note, why isn't there an interface for
enumerations within a class (i.e., something that extends IASTMember)? I
can see that IASTMethod is the one for IASTFunction, IASTField is the one
for IASTVariable, but I can't find the one for IASTEnumerationSpecifier,
so how do I find the access level for an enumerator within a class?
Andrew Niefer wrote:
> ASTAccessVisiblity defines 3 static final instances of itself. PUBLIC,
> PROTECTED, PRIVATE.
> When you call IASTMember.getVisibility(), you will get back one of those
> instances. So just do something like boolean ispublic =
> (field.getVisibility() == ASTAccessVisibility.PUBLIC);
> This pattern was trying to be like an enumeration in C++.
> Note that in the new DOM AST, the visibility constants are just integers,
> see ICPPASTVisibilityLabel and/or ICPPMember. in the dom.ast package.
> -Andrew
> "Felix" <fliao2@yahoo.ca> wrote in message
> news:93b3c59de834444f05259c29156434d5$1@www.eclipse.org...
>> Hi, I've been plugging away with using the parser, and I've come across a
>> problem. I can see that the ASTAccessVisibility class stores the access
>> level (i.e., private, protected, public) for member variables/functions of
>> a class, but there's no accessor function to get the actual value
>> contained inside. How am I supposed to figure out the access level for a
>> given member?
>>
|
|
|
Re: Question about the CDT Parser : Access Visibility [message #145392 is a reply to message #145007] |
Fri, 13 May 2005 15:10 |
Andrew Niefer Messages: 990 Registered: July 2009 |
Senior Member |
|
|
Ah, thats something we never thought of, this also applies to nested
classes.
Using the original parser there is currently no way to get this information.
If you were to use the new DOM AST parser, that information is not yet in
the semantic IBinding interfaces either, but it would be possible to examine
the physical syntax tree and find that information by looking for the
visibility labels.
(The biggest difference between the old and the new parsers is that the old
one did syntax and semantics all in one pass, the new parser first builds a
syntax tree and the semantic resolution occurs later on demand.)
-Andrew
"Felix" <fliao2@yahoo.ca> wrote in message
news:beaa3aa37ec79853309808e67beac176$1@www.eclipse.org...
> Thanks, that worked. On a related note, why isn't there an interface for
> enumerations within a class (i.e., something that extends IASTMember)? I
> can see that IASTMethod is the one for IASTFunction, IASTField is the one
> for IASTVariable, but I can't find the one for IASTEnumerationSpecifier,
> so how do I find the access level for an enumerator within a class?
>
> Andrew Niefer wrote:
>
> > ASTAccessVisiblity defines 3 static final instances of itself. PUBLIC,
> > PROTECTED, PRIVATE.
>
> > When you call IASTMember.getVisibility(), you will get back one of those
> > instances. So just do something like boolean ispublic =
> > (field.getVisibility() == ASTAccessVisibility.PUBLIC);
>
> > This pattern was trying to be like an enumeration in C++.
>
> > Note that in the new DOM AST, the visibility constants are just
integers,
> > see ICPPASTVisibilityLabel and/or ICPPMember. in the dom.ast package.
>
> > -Andrew
>
> > "Felix" <fliao2@yahoo.ca> wrote in message
> > news:93b3c59de834444f05259c29156434d5$1@www.eclipse.org...
> >> Hi, I've been plugging away with using the parser, and I've come across
a
> >> problem. I can see that the ASTAccessVisibility class stores the access
> >> level (i.e., private, protected, public) for member variables/functions
of
> >> a class, but there's no accessor function to get the actual value
> >> contained inside. How am I supposed to figure out the access level for
a
> >> given member?
> >>
>
>
|
|
|
Goto Forum:
Current Time: Wed Jan 15 07:10:58 GMT 2025
Powered by FUDForum. Page generated in 0.03112 seconds
|