Re: [SrcML] problems in plugin building
Status: Beta
Brought to you by:
crashchaos
From: Icaro <ic...@gm...> - 2005-11-25 20:25:41
|
Frank Raiser ha scritto: >>I am trying to create a ViewPlugin but I have found some problems. >> >> > >Any specific idea on what the plugin is supposed to do or are you just >toying around with the ViewPlugins? In the first case let us know and >maybe we can include it in the official SrcML distribution. > > I am trying to turn the code XML of SrcML into an useful format to one project of mine. (Fine-grained Configuration management). Practically I want to eliminate details for me superfluous, and to add other information. what I want is to get from this: import javax.swing.*; public class testFrame extends Frame{ public int ELEMENTO = 0; public void addbuttons(int n){ for(int i =1; i<=n; i++){ this.add( new Button(""+i)); } } } something similar to this: <?xml version="1.0" encoding="UTF-8"?> <ARTEFACT id="012345" filename="test.java"> <CONTAINER id="012345.1" name ="test" type="class" sinceFileVersion="1.0" autor="AuthorXyz" > <AIU id="012345.1.1" name="ELEMENTO" type="field" sinceFileVersion="1.0"> <value version="1.0" time="19081979 20:20" autor="AuthorKjf"> public int ELEMENTO = 0; </value> </AIU> <AIU id="012345.1.2" name="addbuttons" type="method" sinceFileVersion="1.2"> <value version="1.1" time="19081979 20:20" autor="AuthorXyz"> public void addbuttons(int n) </value> </AIU> </CONTAINER> </ARTEFACT> I think that the thing is easier if I take advantage of the XML of SrcML rather than to work on the file source native. Considering that then SrcML makes a platform available to simplify the transformation from XML in something else I have thought about trying to use it Then, in conclusion, I need at least to reconstruct the signatures of the classes, of the methods and of the global variable. >>I have created a new project (using Eclipse) inserting srcml-0.2.2.jar >>in the classpath and >>then I have copied the sources of ViewXHTML.java to have a starting point. >> >> > >Oops. That's not going to work. The ViewXHTML.java currently in CVS is >still building upon the old ViewPlatform. Leif is right now working on >porting it over to the new platform. > > Ok, I have understood. [...] >I'll have to publish a >SourceForge support request for the removal of those outdated >directories soon. > > I think that this is a good think. >For now I suggest you take a look at the current ViewJava plugin: >http://cvs.sourceforge.net/viewcvs.py/srcml/views/ViewJava/de/srcml/view/java/ViewJava.java?view=markup > > ViewJava is made with the new ViewPlatform? This is the simplest example available of the use of the platform? I had chosen ViewXHTML because it seemed closer to my purposes. (from XML to XML) [...] >But for now I'll quickly mark the documentation on the wiki as deprecated. >Thanks for pointing this out. > > of nothing >>PS: is it possible to have in the output of SrcML the line in which a >>statement was present in the original source file? (e.g. <class name = >>"StatementTest" row=28> ) >> >> > >Short answer: officially not > >Detailed answer: As SrcML is abstracting from the actual line-by-line >representation of source code there is nothing like a positional >information in terms of 'lines' contained in a SrcML document. In our >vision even something like the 'original source file' is not really >applicable, as you would save your sources directly in SrcML which >pretty much replaces the meaning of what the 'original source file' is. > > I don't intend to use SrcML as a format of the information but as medium to reach something else. my project supposes to be the most possible transparency to the user. >Hackish answer: Despite the above there is of course the technical >possibilty to get what you want. If you modify the existing parser to >include the positioning of tokens in the resulting SrcML document you >(currently [1]) break the Schema, but apart from that you get the >information you wanted. If you want to go that way I can direct you >towards the java.tree.g file in the parser-java module. It shouldn't be >too difficult to add this information as ANTLR tokens always know their >original location in the source code. It's just a lot of effort to add >this information everywhere, because the grammar file is several >thousand lines long. > > for my purposes it would be enough to have information for the classes, the methods and the global variable. but however, for now, it is not so important and I don't have the time to modify SrcML :-) >>PPS: is it still working the possibility to have an XML output with a >>specified level of detail? (I believe it was the option - g...I'have >>read something in the SrcML documentation) >> >> > >No. This was an idea we incorporated from similar projects some years >ago [2]. However I'd like to know what use you have for such a feature. The >only advantage I can come up with is that the parsing process would be >faster (of course it would still be linear in the file size). But if you >can live with a full SrcML document you get all levels of details for >free, as you can simply choose how deep you walk down the DOM tree. > > for me there are a lot of not important information in the SrcML files and therefore are useless to produce. Besides, in the case I decided not to use the ViewPlattform but to create my own parser of the XML of SrcML to have less useless things in front of me will make simplest the job. >[...] The current schema is very java centric > Yes, it seems also to me. >[2] Have you found the information about detail levels in the parser on >any of the current wiki pages? If yes could you please tell us which >one, so it can be updated accordingly. > not in the wiki, but here: http://srcml.sourceforge.net/bericht.html <cite> Src2SrcML converter version 0.1 (for Java) Usage: java2srcml <options> <sourcecode file> Supported options: -g n : granularity [1 = classes only : 4 = full markup ] -t n : number of spaces to replace \t by. (0 = don't replace) -n : add <line_break/> tags -v : print version info and exit </cite> thanks for the detailed and exhaustive answers. -- Domenico (aka ^I^caro) http://icaro.blogspot.com ~~~~ "Dove mai andiamo?"......"Sempre a casa".... ~~~~ |