Maybe something like:<div><br></div><div>private boolean fieldNeedsFQN(String typeName)</div><div>    String simpleName = Types.toSimpleName(typeName);</div><div>    // This works both with simple as well as with qualified names</div>
<div>    Import import = getOrigin().getImport(simpleName);</div><div>    if (import != null &amp;&amp; !import.getQualifiedName().equals(typeName)) {</div><div>        return true;</div><div>    }</div><div>    return false;</div>
<div>}<br><br><div class="gmail_quote">On Tue, Jul 24, 2012 at 1:14 AM, George Gastaldi <span dir="ltr">&lt;<a href="mailto:gegastaldi@gmail.com" target="_blank">gegastaldi@gmail.com</a>&gt;</span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
Hi Ivan,<br>
<br>
Yeah, I have to agree with you, this is something that should be<br>
improved. I also don&#39;t like having FQN in field declarations.<br>
But, figuring it out how to avoid name clashes may be harder to<br>
implement than using this strategy.<br>
<div class="HOEnZb"><div class="h5"><br>
Regards,<br>
<br>
George Gastaldi<br>
<br>
2012/7/23 Ivan St. Ivanov &lt;<a href="mailto:ivan.st.ivanov@gmail.com">ivan.st.ivanov@gmail.com</a>&gt;:<br>
&gt; Hi George,<br>
&gt;<br>
&gt; Yes, I realized that. So it&#39;s up to us to decide which option we take:<br>
&gt;<br>
&gt; 1) It is safe to have the fully qualified name in the field declarations,<br>
&gt; but it is kinda ugly<br>
&gt; 2) Declaring the fields with non fully qualified names looks natural (all of<br>
&gt; us use this style), but it may produce class name clashes in one out of 1000<br>
&gt; or more cases. E.g. adding java.util.Date and java.sql.Date to a class.<br>
&gt;<br>
&gt; I don&#39;t mind to keep it in the current way. But when I show the generated<br>
&gt; classes to the people, they might get the feeling that something does not<br>
&gt; look like in their IDEs.<br>
&gt;<br>
&gt; Regards,<br>
&gt; Ivan<br>
&gt;<br>
&gt;<br>
&gt; On Tue, Jul 24, 2012 at 12:46 AM, George Gastaldi &lt;<a href="mailto:gegastaldi@gmail.com">gegastaldi@gmail.com</a>&gt;<br>
&gt; wrote:<br>
&gt;&gt;<br>
&gt;&gt; Hi Ivan,<br>
&gt;&gt;<br>
&gt;&gt; Using the fully qualified name avoids class name conflicts, so it is<br>
&gt;&gt; much safer to use than to rely on imports only.<br>
&gt;&gt;<br>
&gt;&gt; Regards,<br>
&gt;&gt;<br>
&gt;&gt; George Gastaldi<br>
&gt;&gt;<br>
&gt;&gt; 2012/7/23 Ivan St. Ivanov &lt;<a href="mailto:ivan.st.ivanov@gmail.com">ivan.st.ivanov@gmail.com</a>&gt;:<br>
&gt;&gt; &gt; Hi Lincoln,<br>
&gt;&gt; &gt;<br>
&gt;&gt; &gt; I&#39;m hacking now a solution. Something like:<br>
&gt;&gt; &gt;<br>
&gt;&gt; &gt; if (Types.isArray(simpleName))<br>
&gt;&gt; &gt; {<br>
&gt;&gt; &gt;     Name name = ast.newSimpleName(Types.stripArray(simpleName));<br>
&gt;&gt; &gt;     Type typeOfArray = ast.newSimpleType(name);<br>
&gt;&gt; &gt;     type = ast.newArrayType(typeNoArray);<br>
&gt;&gt; &gt; }<br>
&gt;&gt; &gt;<br>
&gt;&gt; &gt; I&#39;m just trying to find the most suitable place of the above snippet in<br>
&gt;&gt; &gt; the<br>
&gt;&gt; &gt; setType method. Maybe I&#39;ll do some refactoring of the existing code.<br>
&gt;&gt; &gt;<br>
&gt;&gt; &gt;  I noticed also that the code inside:<br>
&gt;&gt; &gt;<br>
&gt;&gt; &gt;       if (!Strings.areEqual(typeName, simpleName) &amp;&amp; requiresImport)<br>
&gt;&gt; &gt;<br>
&gt;&gt; &gt; ...should also be touched to support arrays.<br>
&gt;&gt; &gt;<br>
&gt;&gt; &gt; BTW, we have the same issue with generic types as well. So I&#39;m looking<br>
&gt;&gt; &gt; into<br>
&gt;&gt; &gt; them too.<br>
&gt;&gt; &gt;<br>
&gt;&gt; &gt; Cheers,<br>
&gt;&gt; &gt; Ivan<br>
&gt;&gt; &gt;<br>
&gt;&gt; &gt; P.S. Don&#39;t you think that we should have the simple name (e.g. File) in<br>
&gt;&gt; &gt; the<br>
&gt;&gt; &gt; field declaration instead of the whole type:<br>
&gt;&gt; &gt;<br>
&gt;&gt; &gt; right now it is:<br>
&gt;&gt; &gt;<br>
&gt;&gt; &gt; import java.io.File;<br>
&gt;&gt; &gt;<br>
&gt;&gt; &gt; public class Test {<br>
&gt;&gt; &gt;<br>
&gt;&gt; &gt;    private java.io.File file;<br>
&gt;&gt; &gt;<br>
&gt;&gt; &gt; }<br>
&gt;&gt; &gt;<br>
&gt;&gt; &gt; On Mon, Jul 23, 2012 at 5:53 PM, Lincoln Baxter, III<br>
&gt;&gt; &gt; &lt;<a href="mailto:lincolnbaxter@gmail.com">lincolnbaxter@gmail.com</a>&gt; wrote:<br>
&gt;&gt; &gt;&gt;<br>
&gt;&gt; &gt;&gt; Hey Ivan!<br>
&gt;&gt; &gt;&gt;<br>
&gt;&gt; &gt;&gt; You&#39;re correct, the JDT probably doesn&#39;t have a convenient method for<br>
&gt;&gt; &gt;&gt; this<br>
&gt;&gt; &gt;&gt; (it doesn&#39;t have much that is convenient,) but what are your proposed<br>
&gt;&gt; &gt;&gt; changes?<br>
&gt;&gt; &gt;&gt;<br>
&gt;&gt; &gt;&gt; ~Lincoln<br>
&gt;&gt; &gt;&gt;<br>
&gt;&gt; &gt;&gt; On Sat, Jul 21, 2012 at 4:04 PM, Ivan St. Ivanov<br>
&gt;&gt; &gt;&gt; &lt;<a href="mailto:ivan.st.ivanov@gmail.com">ivan.st.ivanov@gmail.com</a>&gt; wrote:<br>
&gt;&gt; &gt;&gt;&gt;<br>
&gt;&gt; &gt;&gt;&gt; Hi folks,<br>
&gt;&gt; &gt;&gt;&gt;<br>
&gt;&gt; &gt;&gt;&gt; I wonder is it possible to add a field to a JavaClass and to set an<br>
&gt;&gt; &gt;&gt;&gt; array<br>
&gt;&gt; &gt;&gt;&gt; as its type. The setType(String) method does not support arrays yet<br>
&gt;&gt; &gt;&gt;&gt; and I<br>
&gt;&gt; &gt;&gt;&gt; don&#39;t want to use the other two variants of this method (taking Class<br>
&gt;&gt; &gt;&gt;&gt; and<br>
&gt;&gt; &gt;&gt;&gt; JavaResource parameters).<br>
&gt;&gt; &gt;&gt;&gt;<br>
&gt;&gt; &gt;&gt;&gt; I looked at the mentioned method (setType(String)). And found a<br>
&gt;&gt; &gt;&gt;&gt; suitable<br>
&gt;&gt; &gt;&gt;&gt; place where I could add the support for arrays. However, I&#39;m afraid<br>
&gt;&gt; &gt;&gt;&gt; that<br>
&gt;&gt; &gt;&gt;&gt; JDT&#39;s AST class does not have a convenient newArray....() method.<br>
&gt;&gt; &gt;&gt;&gt;<br>
&gt;&gt; &gt;&gt;&gt; Or maybe I&#39;m missing something?<br>
&gt;&gt; &gt;&gt;&gt;<br>
&gt;&gt; &gt;&gt;&gt; Cheers,<br>
&gt;&gt; &gt;&gt;&gt; Ivan<br>
&gt;&gt; &gt;&gt;&gt;<br>
&gt;&gt; &gt;&gt;&gt; _______________________________________________<br>
&gt;&gt; &gt;&gt;&gt; forge-dev mailing list<br>
&gt;&gt; &gt;&gt;&gt; <a href="mailto:forge-dev@lists.jboss.org">forge-dev@lists.jboss.org</a><br>
&gt;&gt; &gt;&gt;&gt; <a href="https://lists.jboss.org/mailman/listinfo/forge-dev" target="_blank">https://lists.jboss.org/mailman/listinfo/forge-dev</a><br>
&gt;&gt; &gt;&gt;&gt;<br>
&gt;&gt; &gt;&gt;<br>
&gt;&gt; &gt;&gt;<br>
&gt;&gt; &gt;&gt;<br>
&gt;&gt; &gt;&gt; --<br>
&gt;&gt; &gt;&gt; Lincoln Baxter, III<br>
&gt;&gt; &gt;&gt; <a href="http://ocpsoft.org" target="_blank">http://ocpsoft.org</a><br>
&gt;&gt; &gt;&gt; &quot;Simpler is better.&quot;<br>
&gt;&gt; &gt;&gt;<br>
&gt;&gt; &gt;&gt; _______________________________________________<br>
&gt;&gt; &gt;&gt; forge-dev mailing list<br>
&gt;&gt; &gt;&gt; <a href="mailto:forge-dev@lists.jboss.org">forge-dev@lists.jboss.org</a><br>
&gt;&gt; &gt;&gt; <a href="https://lists.jboss.org/mailman/listinfo/forge-dev" target="_blank">https://lists.jboss.org/mailman/listinfo/forge-dev</a><br>
&gt;&gt; &gt;&gt;<br>
&gt;&gt; &gt;<br>
&gt;&gt; &gt;<br>
&gt;&gt; &gt; _______________________________________________<br>
&gt;&gt; &gt; forge-dev mailing list<br>
&gt;&gt; &gt; <a href="mailto:forge-dev@lists.jboss.org">forge-dev@lists.jboss.org</a><br>
&gt;&gt; &gt; <a href="https://lists.jboss.org/mailman/listinfo/forge-dev" target="_blank">https://lists.jboss.org/mailman/listinfo/forge-dev</a><br>
&gt;&gt; &gt;<br>
&gt;&gt; _______________________________________________<br>
&gt;&gt; forge-dev mailing list<br>
&gt;&gt; <a href="mailto:forge-dev@lists.jboss.org">forge-dev@lists.jboss.org</a><br>
&gt;&gt; <a href="https://lists.jboss.org/mailman/listinfo/forge-dev" target="_blank">https://lists.jboss.org/mailman/listinfo/forge-dev</a><br>
&gt;<br>
&gt;<br>
&gt;<br>
&gt; _______________________________________________<br>
&gt; forge-dev mailing list<br>
&gt; <a href="mailto:forge-dev@lists.jboss.org">forge-dev@lists.jboss.org</a><br>
&gt; <a href="https://lists.jboss.org/mailman/listinfo/forge-dev" target="_blank">https://lists.jboss.org/mailman/listinfo/forge-dev</a><br>
&gt;<br>
_______________________________________________<br>
forge-dev mailing list<br>
<a href="mailto:forge-dev@lists.jboss.org">forge-dev@lists.jboss.org</a><br>
<a href="https://lists.jboss.org/mailman/listinfo/forge-dev" target="_blank">https://lists.jboss.org/mailman/listinfo/forge-dev</a><br>
</div></div></blockquote></div><br></div>