<p class="MsoNormal">Hi, David!<br>
<span style="">&nbsp;</span>I need investigate method's content and
find service name. Service name every time will be in one of place and find it
not difficult:<br>
<span style="color: rgb(51, 102, 255);">this.service =
ServiceLocator.getInstance().getService(&quot;<b><u>CallMeService</u></b>&quot;);</span><br>
I did next:<br>
1) I add:<br>
- uk.co.badgersinfoil.metaas.dom.ASMethod<br>
&nbsp;&nbsp;&nbsp; <b>public ASTStatementList getStmt();</b><br>
- uk.co.badgersinfoil.metaas.impl.ASTASMethod (Implementation);<br>
&nbsp;&nbsp;&nbsp; <b>public ASTStatementList getStmt()<br>
&nbsp;&nbsp;&nbsp; {<br>
&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; return this.stmtList;<br>
&nbsp;&nbsp;&nbsp; }</b><br>
And implement in my code information reader from <b>ASTStatementList</b>.<br>
2) In my business method invoke new one:<br>
&nbsp;&nbsp;&nbsp; <i><span style="color: rgb(51, 102, 255);">// Find Service name<br>
</span></i>&nbsp;&nbsp;&nbsp; <i><span style="color: rgb(51, 102, 255);">// TODO: Use
Implement read method statement from MetAS in Future<br>
</span></i>&nbsp;&nbsp;&nbsp; <i><span style="color: rgb(51, 102, 255);">ASTStatementList
stmts = method.getStmt(); // My hack method for take method content<br>
</span></i>&nbsp;&nbsp;&nbsp; <i><span style="color: rgb(51, 102, 255);">serviceName = <b><u>findServiceName</u></b>(stmts);</span><span style="color: rgb(102, 51, 255);"><br>
</span></i><br>
3) This is information reader method:<br>
&nbsp;&nbsp;&nbsp; <span style="color: rgb(51, 102, 255);">private String
findServiceName(ASTStatementList stmts)<br>
&nbsp;&nbsp;&nbsp; {<br>
&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; String result = null;<br>
&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; LinkedListTree linkedListTree =
stmts.getAST();<br>
&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; LinkedListToken currentListToken =
linkedListTree.getStartToken();<br>
&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; LinkedListToken stopListToken =
linkedListTree.getStopToken();<br>
&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; List lines = new ArrayList();<br>
&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; StringBuffer sb = new StringBuffer();<br>
&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; String tonk = currentListToken.getText();<br>
&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; while ( (currentListToken =
currentListToken.getNext()) != null)<br>
&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; {<br>
&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; if
(currentListToken.equals(stopListToken))<br>
&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; {<br>
&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; if
( (sb.toString().length() &gt; 0) &amp;&amp;
(!sb.toString().equals(&quot;;&quot;)) )<br>
&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp;
&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; lines.add(sb.toString());<br>
&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp;
break;<br>
&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; }<br>
&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp;
System.out.print(tonk);<br>
&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; sb.append(tonk);<br>
&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; tonk =
currentListToken.getText();<br>
&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; if
(tonk.equals(&quot;;&quot;))<br>
&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; {<br>
&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp;
lines.add(sb.toString());<br>
&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; sb
= new StringBuffer();<br>
&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; }<br>
&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; };<br>
&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; System.out.println();<br>
&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; for (int j = 0; j &lt; lines.size(); j++)<br>
&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; {<br>
&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; String str =
lines.get(j).toString();<br>
&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp;
System.out.println(str);<br>
&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; int offs = str.indexOf(&quot;getService(\&quot;&quot;);<br>
&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; if (offs != -1)<br>
&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; {<br>
&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp;
offs += &quot;getService(\&quot;&quot;.length();<br>
&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; //
Found<br>
&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; int
offe = str.indexOf(&quot;\&quot;&quot;, offs);<br>
&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; if
(offe != -1)<br>
&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; {<br>
&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp;
&nbsp;&nbsp;&nbsp; result = str.substring(offs, offe);<br>
&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; }<br>
&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; }<br>
&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; }<br>
&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; return result;<br>
&nbsp;&nbsp;&nbsp; }</span><br>
<br>
It is working, but in the future I rewrite this code, after you finish.<br>
Is this implementation right or not?<br>
<br>
Sergey.</p>On 24/01/07, <b class="gmail_sendername">David Holroyd</b> &lt;<a href="mailto:dave@badgers-in-foil.co.uk">dave@badgers-in-foil.co.uk</a>&gt; wrote:<div><span class="gmail_quote"></span><blockquote class="gmail_quote" style="border-left: 1px solid rgb(204, 204, 204); margin: 0pt 0pt 0pt 0.8ex; padding-left: 1ex;">
On Wed, Jan 24, 2007 at 08:01:09AM +0200, Sergey Akopkokhyants wrote:<br>&gt; Is it possible take statements from method, because I need investigate<br>&gt; content of it? I can open the same file in another thread, but I it bad
<br>&gt; idea.<br><br>metaas doesn&#39;t provide read-access to statements in a method/block etc.<br>yet, just write-access for code generation.<br><br>The plan is for this to be included at some point, but it is quite a<br>
lot of work.<br><br>What information specifically are you trying to get from the code?<br><br><br><br>dave<br></blockquote></div><br>