<!DOCTYPE html><html><head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
</head>
<body>
<p>Ok, now onto an improvements that might help us classify the
results more easily. Remember, our ultimate goal would be to see
in which context these variables are introduced. E.g. is it a for
loop, is it a method declaration, or an else block?</p>
<p>I was thinking of doing this in Attr using Env<AttrContext>
but on second though, that seems to complex.</p>
<p>Instead, it would be better if you just created a new visitor in
Flow whose only responsibility is that of populating the
DummyVariable map you already have.</p>
<p>This new visitor might keep track of the innermost "interesting"
enclosing context, and when you create the dummy variable, you
note that context down.</p>
<p>Possible interesting contexts are:<br>
</p>
<p>* if/then/else<br>
* loop bodies (of all kinds)<br>
* try/catch blocks<br>
* switch<br>
* method/constructor body<br>
* static/instance initializer<br>
* lambda expression</p>
<p>I probably forgot a few - but hopefully it's enough to get the
message across :-)</p>
<p>The note/warning will then include the context in which the dummy
variable was found (e.g. something like FOR, WHILE, TRY, CATCH.
Just use the name of the tree tag, which is an enum, so should
render nicely).<br>
</p>
<p>Thanks<br>
Maurizio<br>
</p>
<div class="moz-cite-prefix">On 16/10/2024 22:03, Archie Cobbs
wrote:<br>
</div>
<blockquote type="cite" cite="mid:CANSoFxs4jou_0b2vv60fTwcLES3TDDpDYA16NCFU8evS6hVpVg@mail.gmail.com">
<div dir="ltr">
<div dir="ltr">On Wed, Oct 16, 2024 at 3:56 PM Maurizio
Cimadamore <<a href="mailto:maurizio.cimadamore@oracle.com" moz-do-not-send="true" class="moz-txt-link-freetext">maurizio.cimadamore@oracle.com</a>>
wrote:</div>
<div class="gmail_quote">
<blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex">
<div>
<div>
<p style="margin:0px 0px 1.2em"> think we have to check
whether the symbol under tree.init is that of a local
variable.</p>
</div>
</div>
</blockquote>
<div>Oops, thanks. Should be fixed now.</div>
<div><br>
</div>
<div>FWIW when I build the JDK itself with this change it
outputs 113 notes.</div>
<div><br>
</div>
<div>-Archie<br>
</div>
</div>
<br>
<span class="gmail_signature_prefix">-- </span><br>
<div dir="ltr" class="gmail_signature">Archie L. Cobbs<br>
</div>
</div>
</blockquote>
</body>
</html>