Classes and Namespaces imported by a Java class

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
6 messages Options
Reply | Threaded
Open this post in threaded view
|

Classes and Namespaces imported by a Java class

Alberto Bacchelli
Hi,

 Given a FAMIXClass, generated from a Java project parsed with Verveine-J,
is it possible to know the classes that it imports? I am referring to this
kind of information:

import org.argouml.application.events.ArgoDiagramAppearanceEvent;
import org.argouml.application.events.ArgoEventPump;

It should be easy to write a parser that gets these "imports" from the
completeText of the FAMIXFileAnchor, but I don't want to write it if I can
have this information more easily.

Thanks again.

Cheers,
 Alberto

--
View this message in context: http://moose-dev.97923.n3.nabble.com/Classes-and-Namespaces-imported-by-a-Java-class-tp3494319p3494319.html
Sent from the moose-dev mailing list archive at Nabble.com.
_______________________________________________
Moose-dev mailing list
[hidden email]
https://www.iam.unibe.ch/mailman/listinfo/moose-dev
Reply | Threaded
Open this post in threaded view
|

Re: Classes and Namespaces imported by a Java class

Nicolas Anquetil
Hi Alberto,

For the moment, verveineJ does not export this information.
The main reason being that the meta-model does not represent "import" as an association.

And it would not be that easy to add, because imports are made from a file (actually, a CompilationUnit) which may contain more than one class.
After that, another difficulty from verveine point of view this time is that you can import all the classes from a package (import java.io.*) or import a single method (import static org.junit.Assert.assertEquals).

What you could do, is look at the classes that one class depends on, and then look at their packages, and if their packages is different from the initial class' package, you may assume they are imported, ...

nicolas

----- Mail original -----

> De: "Alberto Bacchelli" <[hidden email]>
> À: [hidden email]
> Envoyé: Mercredi 9 Novembre 2011 18:53:40
> Objet: [Moose-dev] Classes and Namespaces imported by a Java class
> Hi,
>
> Given a FAMIXClass, generated from a Java project parsed with
> Verveine-J,
> is it possible to know the classes that it imports? I am referring to
> this
> kind of information:
>
> import org.argouml.application.events.ArgoDiagramAppearanceEvent;
> import org.argouml.application.events.ArgoEventPump;
>
> It should be easy to write a parser that gets these "imports" from the
> completeText of the FAMIXFileAnchor, but I don't want to write it if I
> can
> have this information more easily.
>
> Thanks again.
>
> Cheers,
> Alberto
>
> --
> View this message in context:
> http://moose-dev.97923.n3.nabble.com/Classes-and-Namespaces-imported-by-a-Java-class-tp3494319p3494319.html
> Sent from the moose-dev mailing list archive at Nabble.com.
> _______________________________________________
> Moose-dev mailing list
> [hidden email]
> https://www.iam.unibe.ch/mailman/listinfo/moose-dev

_______________________________________________
Moose-dev mailing list
[hidden email]
https://www.iam.unibe.ch/mailman/listinfo/moose-dev
Reply | Threaded
Open this post in threaded view
|

Re: Classes and Namespaces imported by a Java class

Alberto Bacchelli

Nicolas Anquetil-2 wrote:

>
> Hi Alberto,
>
> For the moment, verveineJ does not export this information.
> The main reason being that the meta-model does not represent "import" as
> an association.
>
> And it would not be that easy to add, because imports are made from a file
> (actually, a CompilationUnit) which may contain more than one class.
> After that, another difficulty from verveine point of view this time is
> that you can import all the classes from a package (import java.io.*) or
> import a single method (import static org.junit.Assert.assertEquals).
>

Yep, your point is absolutely clear.


Nicolas Anquetil-2 wrote:
>
> What you could do, is look at the classes that one class depends on, and
> then look at their packages, and if their packages is different from the
> initial class' package, you may assume they are imported, ...
>

That's a good idea. Fortunately I just need the text of the imports, so I
will parse it.

Thank you,
 Alberto

--
View this message in context: http://moose-dev.97923.n3.nabble.com/Classes-and-Namespaces-imported-by-a-Java-class-tp3494319p3494829.html
Sent from the moose-dev mailing list archive at Nabble.com.
_______________________________________________
Moose-dev mailing list
[hidden email]
https://www.iam.unibe.ch/mailman/listinfo/moose-dev
Reply | Threaded
Open this post in threaded view
|

Re: Classes and Namespaces imported by a Java class

Stéphane Ducasse
In reply to this post by Alberto Bacchelli
why would it be at the class level?
imports are not at the package level?

Stef
On Nov 9, 2011, at 6:53 PM, Alberto Bacchelli wrote:

> Hi,
>
> Given a FAMIXClass, generated from a Java project parsed with Verveine-J,
> is it possible to know the classes that it imports? I am referring to this
> kind of information:
>
> import org.argouml.application.events.ArgoDiagramAppearanceEvent;
> import org.argouml.application.events.ArgoEventPump;
>
> It should be easy to write a parser that gets these "imports" from the
> completeText of the FAMIXFileAnchor, but I don't want to write it if I can
> have this information more easily.
>
> Thanks again.
>
> Cheers,
> Alberto
>
> --
> View this message in context: http://moose-dev.97923.n3.nabble.com/Classes-and-Namespaces-imported-by-a-Java-class-tp3494319p3494319.html
> Sent from the moose-dev mailing list archive at Nabble.com.
> _______________________________________________
> Moose-dev mailing list
> [hidden email]
> https://www.iam.unibe.ch/mailman/listinfo/moose-dev


_______________________________________________
Moose-dev mailing list
[hidden email]
https://www.iam.unibe.ch/mailman/listinfo/moose-dev
Reply | Threaded
Open this post in threaded view
|

Re: Classes and Namespaces imported by a Java class

Tudor Girba-2
In Java, they are at the CompilationUnit level. Which should probably translate to some subclass of a ContainerEntity.

Doru


On 13 Nov 2011, at 16:17, Stéphane Ducasse wrote:

> why would it be at the class level?
> imports are not at the package level?
>
> Stef
> On Nov 9, 2011, at 6:53 PM, Alberto Bacchelli wrote:
>
>> Hi,
>>
>> Given a FAMIXClass, generated from a Java project parsed with Verveine-J,
>> is it possible to know the classes that it imports? I am referring to this
>> kind of information:
>>
>> import org.argouml.application.events.ArgoDiagramAppearanceEvent;
>> import org.argouml.application.events.ArgoEventPump;
>>
>> It should be easy to write a parser that gets these "imports" from the
>> completeText of the FAMIXFileAnchor, but I don't want to write it if I can
>> have this information more easily.
>>
>> Thanks again.
>>
>> Cheers,
>> Alberto
>>
>> --
>> View this message in context: http://moose-dev.97923.n3.nabble.com/Classes-and-Namespaces-imported-by-a-Java-class-tp3494319p3494319.html
>> Sent from the moose-dev mailing list archive at Nabble.com.
>> _______________________________________________
>> Moose-dev mailing list
>> [hidden email]
>> https://www.iam.unibe.ch/mailman/listinfo/moose-dev
>
>
> _______________________________________________
> Moose-dev mailing list
> [hidden email]
> https://www.iam.unibe.ch/mailman/listinfo/moose-dev

--
www.tudorgirba.com

"Every thing has its own flow."





_______________________________________________
Moose-dev mailing list
[hidden email]
https://www.iam.unibe.ch/mailman/listinfo/moose-dev
Reply | Threaded
Open this post in threaded view
|

Re: Classes and Namespaces imported by a Java class

abergel
In reply to this post by Stéphane Ducasse
They are at the level of file.

Alexandre


On 13 Nov 2011, at 12:17, Stéphane Ducasse wrote:

> why would it be at the class level?
> imports are not at the package level?
>
> Stef
> On Nov 9, 2011, at 6:53 PM, Alberto Bacchelli wrote:
>
>> Hi,
>>
>> Given a FAMIXClass, generated from a Java project parsed with Verveine-J,
>> is it possible to know the classes that it imports? I am referring to this
>> kind of information:
>>
>> import org.argouml.application.events.ArgoDiagramAppearanceEvent;
>> import org.argouml.application.events.ArgoEventPump;
>>
>> It should be easy to write a parser that gets these "imports" from the
>> completeText of the FAMIXFileAnchor, but I don't want to write it if I can
>> have this information more easily.
>>
>> Thanks again.
>>
>> Cheers,
>> Alberto
>>
>> --
>> View this message in context: http://moose-dev.97923.n3.nabble.com/Classes-and-Namespaces-imported-by-a-Java-class-tp3494319p3494319.html
>> Sent from the moose-dev mailing list archive at Nabble.com.
>> _______________________________________________
>> Moose-dev mailing list
>> [hidden email]
>> https://www.iam.unibe.ch/mailman/listinfo/moose-dev
>
>
> _______________________________________________
> Moose-dev mailing list
> [hidden email]
> https://www.iam.unibe.ch/mailman/listinfo/moose-dev

--
_,.;:~^~:;._,.;:~^~:;._,.;:~^~:;._,.;:~^~:;._,.;:
Alexandre Bergel  http://www.bergel.eu
^~:;._,.;:~^~:;._,.;:~^~:;._,.;:~^~:;._,.;:~^~:;.






_______________________________________________
Moose-dev mailing list
[hidden email]
https://www.iam.unibe.ch/mailman/listinfo/moose-dev