Hey Rudy,
This looks really good!
Would you like to push the SourceVisitor API into Forge JavaSourceFacet?
This way you could use it directly from the plugin API and it would be
supported ongoing.
~Lincoln
On Thu, Feb 2, 2012 at 9:39 AM, Rudy De Busscher <rdebusscher(a)gmail.com>wrote:
Hi Lincoln,
created today some kind of prototype for getting all class information,
like class name, super type and interfaces of the java source files in the
project.
It handles nested classes correctly
See this commit
https://github.com/rdebusscher/forge-plugin-deltaspike/commit/ffa511c8ba8...
With this, I can find all classes that implement ProjectStage of
DeltaSpike what we need to have proper value/token completion.
regards
Rudy
On 2 February 2012 10:09, Rudy De Busscher <rdebusscher(a)gmail.com> wrote:
> Lincoln,
>
> I created yesterday something simple
>
> public void visitSources(JavaSourceFacet facet, ClassVisitor visitor)
> {
> visitSources(facet.getSourceFolder(), visitor);
> }
>
> public void visitSources(Resource<?> searchFolder, final
> JavaResourceVisitor visitor ) {
> if (searchFolder instanceof DirectoryResource) {
>
> searchFolder.listResources(new ResourceFilter() {
> @Override
> public boolean accept(Resource<?> resource) {
> if (resource instanceof DirectoryResource) {
> visitSources(resource, visitor);
> }
> if (resource instanceof JavaResource) {
> visitor.visit((JavaResource) resource);
> }
>
> return false;
> }
> });
> }
> }
>
> public interface JavaResourceVisitor {
>
> void visit(JavaResource javaResource);
> }
>
>
> Regards
> Rudy
>
> On 1 February 2012 21:35, Lincoln Baxter, III <lincolnbaxter(a)gmail.com>wrote:
>
>> Perhaps also a recursive flag.
>>
>>
>> On Wed, Feb 1, 2012 at 3:35 PM, Lincoln Baxter, III <
>> lincolnbaxter(a)gmail.com> wrote:
>>
>>> (Switching to Dev List)
>>>
>>> Hey Rudy,
>>>
>>> Awesome! I figure adding a new set of methods in the JavaSourceFacet
>>> would do the trick... something like this:
>>>
>>> JavaSourceFacet java = project.getFacet(JavaSourceFacet.class);
>>>>
>>>> java.visitSources("com.base.package", new JavaSourceVisitor()
{...});
>>>> java.visitTestSourceTree("com.base.package", new
JavaSourceVisitor()
>>>> {...});
>>>>
>>>> java.visitSources(new JavaSourceVisitor() {
>>>> public void visit(VisitContext context, JavaSource source) {
>>>>
>>>> // to end the visit after this method returns, call this method
>>>>
>>> context.visitComplete();
>>>>
>>>> }
>>>> } );
>>>>
>>>> java.visitTestSources(new JavaSourceVisitor() {
>>>> public void visit(VisitContext context, JavaSource source) {
>>>> context.visitComplete();
>>>> }
>>>> } );
>>>>
>>>
>>> Thoughts?
>>> ~Lincoln
>>>
>>>
>>>
>>>
>>> On Wed, Feb 1, 2012 at 7:21 AM, Rudy De Busscher <rdebusscher(a)gmail.com
>>> > wrote:
>>>
>>>> I'll have try
>>>>
>>>> Rudy
>>>>
>>>>
>>>> On 31 January 2012 19:01, Lincoln Baxter, III
<lincolnbaxter(a)gmail.com
>>>> > wrote:
>>>>
>>>>> Hi Rudy,
>>>>>
>>>>> Source scanning is on the list of things to implement in the
>>>>> JavaSourceFacet, but unfortunately we don't have it yet.
Actually, we could
>>>>> use some help with this feature. Is that something you'd be
interested in
>>>>> creating, since you know what you need?
>>>>>
>>>>>
https://issues.jboss.org/browse/FORGE-469
>>>>>
>>>>> There are methods called: javaClass.getSuperType() and
>>>>> getInterfaces() that you can use, though, but there just isn't
any way to
>>>>> walk over all source files yet. Wouldn't be hard to implement!
>>>>>
>>>>> ~Lincoln
>>>>>
>>>>> On Tue, Jan 31, 2012 at 9:23 AM, Rudy De Busscher <
>>>>> rdebusscher(a)gmail.com> wrote:
>>>>>
>>>>>> Hi all,
>>>>>>
>>>>>> For a plugin, I could use some functionality that scans the
source
>>>>>> directories and report me all the java classes that extend a
certain class.
>>>>>>
>>>>>> But I couldn't find anything for that in Forge.
>>>>>>
>>>>>> Is there some way of getting the parent class ? (or do I have
the
>>>>>> 'parse' the source myself (find extend clause and see
what come next))
>>>>>>
>>>>>> Thx
>>>>>>
>>>>>> Best regards
>>>>>>
>>>>>> --
>>>>>> Rudy De Busscher
>>>>>>
http://www.c4j.be
>>>>>>
>>>>>>
>>>>>> _______________________________________________
>>>>>> forge-users mailing list
>>>>>> forge-users(a)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(a)lists.jboss.org
>>>>>
https://lists.jboss.org/mailman/listinfo/forge-users
>>>>>
>>>>>
>>>>
>>>>
>>>> --
>>>> Rudy De Busscher
>>>>
http://www.c4j.be
>>>>
>>>>
>>>> _______________________________________________
>>>> forge-users mailing list
>>>> forge-users(a)lists.jboss.org
>>>>
https://lists.jboss.org/mailman/listinfo/forge-users
>>>>
>>>>
>>>
>>>
>>> --
>>> Lincoln Baxter, III
>>>
http://ocpsoft.com
>>>
http://scrumshark.com
>>> "Keep it Simple"
>>>
>>
>>
>>
>> --
>> Lincoln Baxter, III
>>
http://ocpsoft.com
>>
http://scrumshark.com
>> "Keep it Simple"
>>
>
>
>
> --
> Rudy De Busscher
>
http://www.c4j.be
>
>
--
Rudy De Busscher
http://www.c4j.be