@@ -201,7 +201,7 @@ public boolean visit(ArrayCreation node) {
201201}else {
202202List dim =node .dimensions ();
203203ITypeBinding elementType =node .getType ().getElementType ().resolveBinding ();
204- if (elementType !=null ){
204+ if (elementType !=null ){
205205if (elementType .isPrimitive ()) {
206206String typeCode =elementType .getName ();
207207if ("int" .equals (typeCode )
@@ -258,10 +258,58 @@ public boolean visit(ArrayInitializer node) {
258258/*
259259 * TODO: should be tested
260260 */
261- buffer .append ("[" );
262- List list =node .expressions ();
263- visitList (list ,", " );
264- buffer .append ("]" );
261+ List expressions =node .expressions ();
262+ ITypeBinding arrType =node .resolveTypeBinding ();
263+ ITypeBinding elementType =null ;
264+ if (arrType !=null ) {
265+ elementType =arrType .getComponentType ();
266+ }
267+ if (elementType ==null ) {
268+ buffer .append ("[" );
269+ visitList (expressions ,", " );
270+ buffer .append ("]" );
271+ return false ;
272+ }
273+ if (elementType .isPrimitive ()) {
274+ String typeCode =elementType .getName ();
275+ if ("int" .equals (typeCode )
276+ ||"float" .equals (typeCode )
277+ ||"double" .equals (typeCode )
278+ ||"byte" .equals (typeCode )
279+ ||"long" .equals (typeCode )
280+ ||"short" .equals (typeCode )) {
281+ //buffer.append(" Clazz.newArray (");
282+ buffer .append (" Clazz.new" );
283+ buffer .append (typeCode .substring (0 ,1 ).toUpperCase ());
284+ buffer .append (typeCode .substring (1 ));
285+ buffer .append ("Array (-1, " );
286+ buffer .append ("[" );
287+ visitList (expressions ,", " );
288+ buffer .append ("])" );
289+ }else if ("char" .equals (typeCode )) {
290+ //buffer.append(" Clazz.newArray (");
291+ buffer .append (" Clazz.newCharArray (-1, " );
292+ buffer .append ("[" );
293+ visitList (expressions ,", " );
294+ buffer .append ("])" );
295+ }else if ("boolean" .equals (typeCode )) {
296+ //buffer.append(" Clazz.newArray (");
297+ buffer .append (" Clazz.newBooleanArray (-1, " );
298+ buffer .append ("[" );
299+ visitList (expressions ,", " );
300+ buffer .append ("])" );
301+ }else {
302+ buffer .append (" Clazz.newArray (-1, " );
303+ buffer .append ("[" );
304+ visitList (expressions ,", " );
305+ buffer .append ("])" );
306+ }
307+ }else {
308+ buffer .append (" Clazz.newArray (-1, " );
309+ buffer .append ("[" );
310+ visitList (expressions ,", " );
311+ buffer .append ("])" );
312+ }
265313return false ;
266314}
267315
@@ -1340,11 +1388,30 @@ public boolean visit(ReturnStatement node) {
13401388Expression expression =node .getExpression ();
13411389if (expression !=null ) {
13421390buffer .append (' ' );
1343- ITypeBinding tBinding =expression .resolveTypeBinding ();
1344- if (tBinding !=null && !("char" .equals (tBinding .getName ()))) {
1345- buffer .append ("String.fromCharCode (" );
1346- expression .accept (this );
1347- buffer .append (")" );
1391+ boolean needCharWrapping =false ;
1392+ ASTNode parent =node .getParent ();
1393+ while (parent !=null && !(parent instanceof MethodDeclaration )) {
1394+ parent =parent .getParent ();
1395+ }
1396+ if (parent !=null ) {
1397+ MethodDeclaration m = (MethodDeclaration )parent ;
1398+ IMethodBinding binding =m .resolveBinding ();
1399+ if (binding !=null ) {
1400+ ITypeBinding returnType =binding .getReturnType ();
1401+ if (returnType !=null &&"char" .equals (returnType .getName ())) {
1402+ needCharWrapping =true ;
1403+ }
1404+ }
1405+ }
1406+ if (needCharWrapping ) {
1407+ ITypeBinding tBinding =expression .resolveTypeBinding ();
1408+ if (tBinding !=null && !("char" .equals (tBinding .getName ()))) {
1409+ buffer .append ("String.fromCharCode (" );
1410+ expression .accept (this );
1411+ buffer .append (")" );
1412+ }else {
1413+ expression .accept (this );
1414+ }
13481415}else {
13491416expression .accept (this );
13501417}