[forge-users] support for nested classes.

Lincoln Baxter, III lincolnbaxter at gmail.com
Thu Feb 2 12:30:14 EST 2012


Sure, let's talk about that.

I think the quick fix is good enough for now. We can come up with a
strategy to handle the nesting properly later. Is there a JIRA for this?

BTW. The Forge Java Parser uses the Eclipse parser under the covers, and if
you really need to, you can use the method:

parserObject.getInternal();
>

Which should return the related Eclipse parser object.

Does that help? Let's discuss further on the forge-dev list.

~Lincoln

On Thu, Feb 2, 2012 at 3:43 AM, Rudy De Busscher <rdebusscher at gmail.com>wrote:

> Lincoln,
>
> @deltaspike plugin, I have been making some kind of prototype that creates
> the correct files.  Now I need to make the checks and update files.  But
> your input is welcome.
>
> @fix There are 2 options:
> - Quick fix that just handles the main class and ignores nested classes
> - Correct handling, but that needs a lot of refactoring to handle multiple
> classes per file.
>
> For deltaspike, I was writing something based on the eclipse parser to
> have full access to everyhting.
>
> Thus depends what forge project wants and I could try to help but have
> limited time.  We can discuss this maybe outside of this thread.
>
> regards
> Rudy
>
> On 1 February 2012 21:24, Lincoln Baxter, III <lincolnbaxter at gmail.com>wrote:
>
>> Thanks. You are correct about this behavior. Now to find time to fix it!
>> Is this something you might be able to help with?
>>
>> I've been meaning to take a look at the deltaspike plugin. A test case
>> would make this much easier to debug!
>>
>> Thanks so much for finding this!
>> ~Lincoln
>>
>>
>> On Wed, Feb 1, 2012 at 7:02 AM, Rudy De Busscher <rdebusscher at gmail.com>wrote:
>>
>>> Hi Lincoln,
>>>
>>> see  https://issues.jboss.org/browse/FORGE-471 with a rather extended
>>> explanation.
>>>
>>> Regards
>>> Rudy
>>>
>>>
>>> On 31 January 2012 18:50, Lincoln Baxter, III <lincolnbaxter at gmail.com>wrote:
>>>
>>>> Hi Rudy,
>>>>
>>>> You're right: We don't yet have nested class support, and the top-level
>>>> class is what should be returned, so I'm a bit surprised that this is what
>>>> is happening. Do you know if this problem is caused by the JavaParser API
>>>> or by the forge Resources API?
>>>>
>>>> Care to file an issue? Thanks!
>>>>
>>>> https://issues.jboss.org/browse/FORGE
>>>>
>>>> ~Lincoln
>>>>
>>>> On Tue, Jan 31, 2012 at 10:06 AM, Rudy De Busscher <
>>>> rdebusscher at gmail.com> wrote:
>>>>
>>>>> Hi All,
>>>>>
>>>>> Seems that nested classes aren't handled correctly by forge.
>>>>>
>>>>> If you have a java source file like this
>>>>>
>>>>> public class CustomProjectStageHolder implements ProjectStageHolder
>>>>> {
>>>>>     public static final class CustomProjectStage extends ProjectStage
>>>>>     {
>>>>>         private static final long serialVersionUID = 1029094387976167179L;
>>>>>     }
>>>>>
>>>>>     public static final CustomProjectStage CustomProjectStage = new CustomProjectStage();
>>>>> }
>>>>>
>>>>>
>>>>> And consider then following statements:
>>>>>
>>>>> JavaResource javaResource = factory.getResourceFrom(new File("/path/to/file/RudyHolder.java")).reify(JavaResource.class);
>>>>>
>>>>> javaResource.getJavaSource().getQualifiedName();
>>>>>
>>>>>
>>>>> The javaResource is indeed pointing to the file, you can verify with javaResource.getFullyQualifiedName()
>>>>>
>>>>> But if you ask for the javaSource, as in the second statement, you get the nested class, CustomProjectStage in our example.
>>>>>
>>>>>
>>>>> Relation between JavaResource and JavaSource indicates that multiple classes per java file wasn't considered.  And isn't common for entity classes etc that have to be handled by Forge.
>>>>>
>>>>> So when there are no plans in supporting this in Forge, isn't it logic to return the main class, instead of the nested class?
>>>>>
>>>>>
>>>>>
>>>>>
>>>>>
>>>>> Thx for the clarification.
>>>>>
>>>>>
>>>>> Regards
>>>>>
>>>>> Rudy
>>>>>
>>>>>
>>>>>
>>>>>
>>>>>
>>>>>
>>>>> --
>>>>>
>>>>> Rudy De Busscher
>>>>> http://www.c4j.be
>>>>>
>>>>>
>>>>> _______________________________________________
>>>>> forge-users mailing list
>>>>> forge-users at lists.jboss.org
>>>>> https://lists.jboss.org/mailman/listinfo/forge-users
>>>>>
>>>>>
>>>>
>>>>
>>>> --
>>>> Lincoln Baxter, III
>>>> http://ocpsoft.com
>>>> http://scrumshark.com
>>>> "Keep it Simple"
>>>>
>>>> _______________________________________________
>>>> forge-users mailing list
>>>> forge-users at lists.jboss.org
>>>> https://lists.jboss.org/mailman/listinfo/forge-users
>>>>
>>>>
>>>
>>>
>>> --
>>> Rudy De Busscher
>>> http://www.c4j.be
>>>
>>>
>>> _______________________________________________
>>> forge-users mailing list
>>> forge-users at lists.jboss.org
>>> https://lists.jboss.org/mailman/listinfo/forge-users
>>>
>>>
>>
>>
>> --
>> Lincoln Baxter, III
>> http://ocpsoft.com
>> http://scrumshark.com
>> "Keep it Simple"
>>
>> _______________________________________________
>> forge-users mailing list
>> forge-users at lists.jboss.org
>> https://lists.jboss.org/mailman/listinfo/forge-users
>>
>>
>
>
> --
> Rudy De Busscher
> http://www.c4j.be
>
>
> _______________________________________________
> forge-users mailing list
> forge-users at lists.jboss.org
> https://lists.jboss.org/mailman/listinfo/forge-users
>
>


-- 
Lincoln Baxter, III
http://ocpsoft.com
http://scrumshark.com
"Keep it Simple"
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.jboss.org/pipermail/forge-users/attachments/20120202/45c9e80f/attachment.html 


More information about the forge-users mailing list