Hi Lincoln,

I'm hacking now a solution. Something like:

if (Types.isArray(simpleName))
{
    Name name = ast.newSimpleName(Types.stripArray(simpleName));
    Type typeOfArray = ast.newSimpleType(name);
    type = ast.newArrayType(typeNoArray);
}

I'm just trying to find the most suitable place of the above snippet in the setType method. Maybe I'll do some refactoring of the existing code.

 I noticed also that the code inside:

      if (!Strings.areEqual(typeName, simpleName) && requiresImport)

...should also be touched to support arrays.

BTW, we have the same issue with generic types as well. So I'm looking into them too.

Cheers,
Ivan

P.S. Don't you think that we should have the simple name (e.g. File) in the field declaration instead of the whole type:

right now it is:

import java.io.File;

public class Test {

   private java.io.File file;

}

On Mon, Jul 23, 2012 at 5:53 PM, Lincoln Baxter, III <lincolnbaxter@gmail.com> wrote:
Hey Ivan!

You're correct, the JDT probably doesn't have a convenient method for this (it doesn't have much that is convenient,) but what are your proposed changes?

~Lincoln

On Sat, Jul 21, 2012 at 4:04 PM, Ivan St. Ivanov <ivan.st.ivanov@gmail.com> wrote:
Hi folks,

I wonder is it possible to add a field to a JavaClass and to set an array as its type. The setType(String) method does not support arrays yet and I don't want to use the other two variants of this method (taking Class and JavaResource parameters).

I looked at the mentioned method (setType(String)). And found a suitable place where I could add the support for arrays. However, I'm afraid that JDT's AST class does not have a convenient newArray....() method.

Or maybe I'm missing something?

Cheers,
Ivan

_______________________________________________
forge-dev mailing list
forge-dev@lists.jboss.org
https://lists.jboss.org/mailman/listinfo/forge-dev




--
Lincoln Baxter, III
http://ocpsoft.org
"Simpler is better."

_______________________________________________
forge-dev mailing list
forge-dev@lists.jboss.org
https://lists.jboss.org/mailman/listinfo/forge-dev