Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Modeling » MoDisco » Accessing source line number from Java Model
Accessing source line number from Java Model [message #1326573] Thu, 01 May 2014 20:35 Go to next message
Dániel Stein is currently offline Dániel SteinFriend
Messages: 2
Registered: May 2014
Junior Member
Hello,

I'd like to create a model from my java code, update it incrementally, find elements in the model and get the relating line number in the source code.

After I've discovered a Java Project into a Java and Inventory Model, I'm able to find the source file, the source class (and method for some elments), but not the exact line number.

If I use the KDM, I could find the SourceRegion, but the attributes (startLine, startPosition, ...) do not contain any information, only the file reference is set.


So my question is: is it possible to create a model (preferably) incrementally, that has the exact number to the source line? Or is it possible to find the particular line in the file, based on the information in the model?

Thank you.
Re: Accessing source line number from Java Model [message #1327988 is a reply to message #1326573] Fri, 02 May 2014 12:51 Go to previous messageGo to next message
Hugo Bruneliere is currently offline Hugo BruneliereFriend
Messages: 667
Registered: July 2009
Senior Member
Hello,

You should take a look to the models stored in the java2kdmFragments folder that is created when running "Discover Java and Inventory model...".
They contain JavaNodeSourceRegion elements that provide information on the various elements locations in the code.

Best regards,


------------------------------------------
Hugo Bruneliere - R&D Engineer
AtlanMod research team (Inria, EMN & LINA)
Ecole des Mines de Nantes
Nantes - France
------------------------------------------
Re: Accessing source line number from Java Model [message #1328257 is a reply to message #1327988] Fri, 02 May 2014 15:51 Go to previous messageGo to next message
Dániel Stein is currently offline Dániel SteinFriend
Messages: 2
Registered: May 2014
Junior Member
Thank you!

Is it possible to generate and access these "fragment" models from code without serializing? (Even if in the code I set the discoverer to serialize, and run it, just one xmi is produced.)

Could you please show me an example?
Re: Accessing source line number from Java Model [message #1334155 is a reply to message #1328257] Mon, 05 May 2014 12:24 Go to previous message
Fabien Giquel is currently offline Fabien GiquelFriend
Messages: 139
Registered: July 2009
Senior Member
Hi Daniel,

these "fragments" can be accessed from code. From the "JavaApplication" top level element, you must follow "java2DirectoryChildren" and "java2FileChildren" links -> "Java2File" elements own the SourceRegion.

You may have a look at source for "org.eclipse.modisco.java.composition.javaapplication.queries.GetASTNodeSourceRegion" .It defines the code to retrieve the SourceRegion from a ASTNode java element.

Regards,
Fabien.



----------------------------------------------------
Fabien GIQUEL
R&D Engineer
Mia-Software
4, rue du Château de l'Eraudiere
44324 NANTES CEDEX 03
----------------------------------------------------
Previous Topic:Full long paper on MoDisco published in Information and Software Technology (Elsevier)
Next Topic:Problems with modify plugins
Goto Forum:
  


Current Time: Tue Jul 17 22:40:49 GMT 2018

Powered by FUDForum. Page generated in 0.02142 seconds
.:: Contact :: Home ::.

Powered by: FUDforum 3.0.2.
Copyright ©2001-2010 FUDforum Bulletin Board Software

Back to the top