prakashjegan / javaparser

Automatically exported from code.google.com/p/javaparser
0 stars 0 forks source link

parsing "default scope" #28

Closed GoogleCodeExporter closed 8 years ago

GoogleCodeExporter commented 8 years ago
for the declaration

static class myclass {  /**/}
the modifiers can't detect if the class is private or public (this apply 
also for any other TypeDeclaration)

so, the following statements always returns false:

ModifierSet.isPrivate(classNode.getModifiers())

been classNode the node representing the class definition above.
it also returns false for any other test (isPublic, isProtected, etc.)
Regards

Original issue reported on code.google.com by rodrigo....@gmail.com on 23 Nov 2009 at 3:58

GoogleCodeExporter commented 8 years ago
This is because the class above is declared "package-private". "package-private"
means neither "private", nor "public", nor "protected" modifier is used. 
ModifierSet
can only check if a modifier was actually used in the parsed code.

Original comment by michaelkoch6@googlemail.com on 15 Jan 2010 at 10:06

GoogleCodeExporter commented 8 years ago
Thanks michaelkoch6.
It seems rodrigo had a little mistake. Am I right?
I will close this issue until this mistake be demystified.

Original comment by jges...@gmail.com on 15 Jan 2010 at 3:14

GoogleCodeExporter commented 8 years ago
Hi,
i think it should be useful to have that "package private" modifier in the 
parser.
i'm making a diff. tool and out of the box i can't know if the modifier has 
changed 
from package private to just private (or other).
To solve the issue i had to implement a exhaustive if (if it's not private, not 
public, etc. then it should be package private). It's not a very clean 
solution, it 
would be nicer if the parser could answer "ModifierSet.isPackagePrivate(...)".
Just my opinion ;)

Original comment by rodrigo....@gmail.com on 15 Jan 2010 at 3:22

GoogleCodeExporter commented 8 years ago
package private means the lack of modifiers. This is why there is no flag for 
this.
If the method "ModifierSet.isPackagePrivate(...)" existed, it's implementation 
should
be composed by the same ifs you've done in your code. 

I agree with you that in some situations it could be useful. But it shouldn't be
implemented in the class "ModifierSet". Maybe in a helper class.

Original comment by jges...@gmail.com on 15 Jan 2010 at 3:31

GoogleCodeExporter commented 8 years ago
Well, maybe a method "hasModifiers()" or something like that make more sence, i 
see 
the point for not having a package private modifier (as modifiers do that, 
explicitly change the default package private behavior). 

Original comment by rodrigo....@gmail.com on 15 Jan 2010 at 3:43