Browse Source

Fix array out of bounds exception coming from JavaParser.java

tags/v1.0^2
Benjamin Attal 10 years ago
parent
commit
2d7c1f4768
2 changed files with 9 additions and 4 deletions
  1. +9
    -4
      parsers/java/src/main/java/com/bitshift/parsing/parsers/JavaParser.java
  2. +0
    -0
      test/parser_test.py

+ 9
- 4
parsers/java/src/main/java/com/bitshift/parsing/parsers/JavaParser.java View File

@@ -94,14 +94,19 @@ public class JavaParser extends Parser {
((QualifiedName) nameObj).getFullyQualifiedName() :
((SimpleName) nameObj).getIdentifier();
List<Statement> statements = node.getBody().statements();
Statement last = statements.get(statements.size() - 1);

int sl = this.root.getLineNumber(node.getStartPosition());
int sc = this.root.getColumnNumber(node.getStartPosition());
int el = this.root.getLineNumber(last.getStartPosition());
int ec = this.root.getColumnNumber(last.getStartPosition());
Integer el = null;
Integer ec = null;

data.put("coord", Symbols.createCoord(sl, sc, null, null));
if (statements.size() > 0) {
Statement last = statements.get(statements.size() - 1);
el = this.root.getLineNumber(last.getStartPosition());
ec = this.root.getColumnNumber(last.getStartPosition());
}

data.put("coord", Symbols.createCoord(sl, sc, el, ec));
data.put("name", name);
this._cache.push(data);
return true;


test/java_parser_test.py → test/parser_test.py View File


Loading…
Cancel
Save