Aw: [argouml-dev] Some observations on java reverse engineering

Thomas Neustupny <[email protected]> Wed, 17 Dec 2014 23:14:20 +0100
Newsgroups gmane.comp.db.axion.devel
Message-ID <trinity-27e7bc2f-baf8-4bf4-ae06-1ad19fc9a646-1418854460805@3capp-gmx-bs03>
Hi Bob,

here is a first attempt. First, a method call has to be added in the parser=
 java.g, here:

localVariableDeclaration
    :   variableModifiers t=3Dtype
    =09{
    =09=09// simple dependency algorithm: if t is found in the model,
    =09=09// then build a dependency, otherwise ignore
            if (parserMode =3D=3D MODE_IMPORT_PASS2) {
                getModeller().addClassifierDependency(t);
            }
    =09}
    =09variableDeclarators["", (short)0, null]
    ;

Then, the method in Modeller.java has to be added, here is a first working =
version:

    /**
     * Called from the parser to add a dependency to a classifier.
     *=20
     * @param name The name of the classifier candidate.
     */
    void addClassifierDependency(String name) {
        String classifierName =3D stripVarargAndGenerics(name);
        Object clientObj =3D parseState.getClassifier();
        if (clientObj =3D=3D null) {
            return;
        }
        Object supplierObj =3D null;
       =20
        // first try: lookup classifierName in same namespace
        Object ns =3D Model.getFacade().getNamespace(clientObj);
        if (ns !=3D null) {
            supplierObj =3D Model.getFacade().lookupIn(ns, classifierName);
        }

        // second try: lookup in imports
        if (supplierObj =3D=3D null) {
            String packageName =3D getPackageName(name);
            // ...
        }
       =20
        // third try: resolve fully qualified classifier (xxx.yyy.Zzz)
        String packageName =3D getPackageName(name);
        if (supplierObj =3D=3D null && packageName.length() > 0) {
            classifierName =3D this.getClassifierName(name);
            // ...
        }
       =20
        // finally build the dependency
        if (supplierObj !=3D null) {
            buildDependency(supplierObj, clientObj, null);
        }
    }

I've committed it to the Java module code, feel free to test&experiment. Yo=
ur example already works with that provided both classes are in the same pa=
ckage.

Regards,=C2=A0
Thomas=C2=A0


Gesendet:=C2=A0Montag, 15. Dezember 2014 um 21:32 Uhr
Von:=C2=A0"Thomas Neustupny" <[email protected]>
An:[email protected]
Betreff:=C2=A0Aw: [argouml-dev] Some observations on java reverse engineeri=
ng
[Sorry for accidently sending in hmtl format, I'm resending it in plain tex=
t format]
=C2=A0

Hi Bob,

this is no malfunction, just a missing feature. The method bodies are compl=
etely parsed, but the information in there is not used yet. I want this fea=
ture, too, and can assist. I&#39;ve just set up my dev environment (eclipse=
 Luna, Java 1.8, it works well so far).

The component is not generated for each class, but for each compilation uni=
t (.java file), because a file can host more than one class. Also, the impo=
rts do not belong to the class, but to the component instance for obvious r=
easons. It&#39;s a great feature (not by me, I forgot who deserves the hono=
r for that!).

I suggest to identify the lines in java.g, where the type identifier for th=
e associated class/interface can be found and discuss how to process them. =
The parser has two passes, so we could search the already identified types =
from the first pass during the second phase.

Regards,
Thomas


14 um 18:07 Uhr<br/>
<b>Von:</b>&nbsp;&quot;Bob Tarling&quot; &lt;[email protected]&gt;<br/>
<b>An:</b>&nbsp;[email protected]<br/>
<b>Betreff:</b>&nbsp;[argouml-dev] Some observations on java reverse engine=
ering</div>

<div name=3D"quoted-content">
<div>
<div>I&#39;m trying to generate some diagrams from an existing code base at=
 work and I see some issues with the model generated.<br/>
&nbsp;</div>
A simple example is this.

<div><br/>
public class UseTestUtil {<br/>
<br/>
&nbsp;&nbsp;&nbsp; private void test() {<br/>
&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; TestUtil tu =3D new TestUtil();<br/>
&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; tu.test();<br/>
&nbsp;&nbsp;&nbsp; }<br/>
}<br/>
&nbsp;</div>

<div>I&#39;d expect to see a dependency relationship from UseTestUtil to Te=
stUtil but nothing is generated. Is there some complication with our parser=
 not being able to manage this or is this just an outstanding enhancement.<=
br/>
&nbsp;</div>

<div>I also notice a component eing generated for every class. WHy is this?=
<br/>
&nbsp;</div>

<div>Regards<br/>
&nbsp;</div>

<div>Bob<br/>
&nbsp;</div>

<div><br/>
&nbsp;</div>
</div>
</div>
</div>
</div>
</div></div></body></html>

------------------------------------------------------
http://argouml.tigris.org/ds/viewMessage.do?dsForumId=3D450&dsMessageId=3D3=
092752

To unsubscribe from this discussion, e-mail: [[email protected]=
s.org].
To be allowed to post to the list contact the mailing list moderator, email=
: [[email protected]]

------------------------------------------------------
http://argouml.tigris.org/ds/viewMessage.do?dsForumId=3D450&dsMessageId=3D3=
092754[http://argouml.tigris.org/ds/viewMessage.do?dsForumId=3D450&dsMessag=
eId=3D3092754]

To unsubscribe from this discussion, e-mail: [[email protected]=
s.org].
To be allowed to post to the list contact the mailing list moderator, email=
: [[email protected]]

------------------------------------------------------
http://argouml.tigris.org/ds/viewMessage.do?dsForumId=3D450&dsMessageId=3D3=
092933

To unsubscribe from this discussion, e-mail: [[email protected]=
s.org].
To be allowed to post to the list contact the mailing list moderator, email=
: [[email protected]]