Hi Markus,
as i understood you, JaMoPP is completely sufficient for you.

Prerequisite is that you installed JaMoPP. You can then load your Java
files like this:

IFile javaFile; // = just get a Java file from your workspace
ResourceSet rs = new ResourceSetImpl();
URI uri = URI.createPlatformResourceURI(file.getFullPath().toString(),
true);
JavaResource resource = (JavaResource) rs.getResource(uri, true);
CompilationUnit cu = (CompilationUnit) resource.getContents().get(0);

Now you can do what you want with the model. There are nice access
method to better get some stuff in the model, such as e.g.:

ConcreteClassifier classifier =
cu.getConcreteClassifier(SomeClassInThisUnit.class.getName());

or to get a method:

List<Member> members = classifier.getMembersByName("someMethod");

So you don't need to iterate through the model by your own.

best regards,
Jan



Markus wrote:
> Hi,
> 
> at first thank you for your response and sorry for asking somewhat 
> confusing ^^.
> 
> So maybe I should start from scratch. What I want to achieve is to parse 
> Java-SourceCode to an ECore based JavaMetamodel and then process this model.
> 
> As far as I understand there are two ways to achieve this:
> 
> 1)  use the emftext plugin and generate the ecore + genmodel files as in
>   http://www.emftext.org/index.php/EMFText_Concrete_Syntax_Zoo_Java_5
>   then the java.cs file and afterwards let emftext generate the text 
> resources. Which should be the   plugins, and in the base package of 
> those plugin-set, I have those problems with the "cannot be resolved to 
> a type"
> 
> 2) then there is the possibility to use jamopp, where the ecore based 
> javametamodel is built in, but what my understanding of this plugin was, 
> is that you somehow, click somewhere in the gui, find a menu jamopp and 
> there is the option "generate model" and afterwards shows me a nice 
> image of the code but as model. Which I don't need because I need to 
> process it further. But you seem to be saying that is not the point. So 
> what my question regarding jamopp is: How do I use it then? Is there any 
> extension point I have to attach to and get the current open documents?
> 
> Regards Markus
> 
> On 10/09/2012 11:45 AM, Mirko Seifert wrote:
>> Hi Markus,
>>
>> 08.10.2012 17:03, Markus:
>>> Hi,
>>>
>>> I'm relatively new to emftext so I hope this question wasn't asked
>>> before (I searched but I didn't find anything though).
>>>
>>> Here is my situation:
>>> I need to convert java-source-code into emf so I basically just follow
>>> the steps on the screencast. Where I generate the ecore, then the
>>> generator model an afterwards the java.cs. Thereafter I let emftext
>>> generate the Text Resources. This goes well enough, but after it is
>>> finished (where code should be working) I have in my Base Package the
>>> following problem:
>>
>> I'm not sure which screencast you're referring to, but I'll try to 
>> answer anyway.
>>
>>> Eclipse always tells me "org.emftext cannot be resolved to a type".
>>>
>>> So basically what is my failure?
>>
>> The missing import might be caused if you do not have the 
>> org.emftext.commons.layout Plug-ins in your workspace. You can find 
>> these at https://github.com/DevBoost/EMFText/tree/master/Core/Commons
>>
>>> On a side note: can this all be avoided using jamopp? My understanding
>>> is, that jamopp needs a user interaction to generate the emf from the
>>> source code, but I need to get it per source code. Are there the same
>>> rules as for the normal emftext generated, that I just append myself to
>>> an extension point to get the emf?
>>
>> I understood that you're using JaMoPP, now I'm confused. Anyhow, 
>> JaMoPP does not need user interaction.
>>
>> Please describe more detailed what you're trying to do. EMF is a 
>> framework, thus you can't convert "Java code to EMF". You can convert 
>> Java code to a model. This can be either a model conforming to the 
>> Ecore metamodel or one conforming to the Java metamodel that is 
>> included in JaMoPP. These two are different use cases.
>>
>> I hope this helps nonetheless,
>>
>> Mirko
>>
>>
> 
> _______________________________________________
> emftext-users mailing list
> [email protected]
> http://mail-st.inf.tu-dresden.de/cgi-bin/mailman/listinfo/emftext-users
> 


-- 
Dipl.-Inf. Jan Reimann
Research Assistant

Technische Universität Dresden
Department of Computer Science
Software Technology Group
01062 Dresden

Phone +49 (351) 463-42073
Email [email protected]

Refactory - Refactorings for DSLs. http://modelrefactoring.org
_______________________________________________
emftext-users mailing list
[email protected]
http://mail-st.inf.tu-dresden.de/cgi-bin/mailman/listinfo/emftext-users

Reply via email to