PositiveTechnologies/PT.PM

Java array initialization support

Closed this issue · 1 comments

Parsing each of the following lines of java code

char[] a = new char[] {'a', 'b'};
char[] a = new char[1][2];

gives

"Right": {
 "NodeType": "ObjectCreateExpression",
 "Type": {
   "NodeType": "TypeToken",
   "TypeText": "char"
  },
  "Arguments": {
  "NodeType": "ArgsNode",
  "Collection": []
  }
}

Parsing should give the following results:

  1. char[] a = new char[] {'a', 'b'};
"Right": {
  "NodeType": "ArrayCreationExpression",
  "Type": {
    "NodeType": "TypeToken",
    "TypeText": "char"
  },
  "Sizes": [
    {
      "NodeType": "IntLiteral",
      "Value": 0
    }
  ],
  "Initializers": [
    {
      "NodeType": "StringLiteral",
      "Text": "a"
    },
    {
      "NodeType": "StringLiteral",
      "Text": "b"
    }
  ]
}
  1. char[] a = new char[1][2];
"Right": {
  "NodeType": "ArrayCreationExpression",
  "Type": {
    "NodeType": "TypeToken",
    "TypeText": "char"
  },
  "Sizes": [
    {
      "NodeType": "IntLiteral",
      "Value": 1
    },
    {
      "NodeType": "IntLiteral",
      "Value": 2
    }
  ]
}

fixed via #74