From d127ac94ad4ad04ce2b356da1f67e0eaf045085b Mon Sep 17 00:00:00 2001 From: Benjamin Attal Date: Mon, 5 May 2014 17:01:25 -0400 Subject: [PATCH] 1) All unavailable line numbers and column numbers become -1. 2) Add correct dependency in pom.xml --- bitshift/parser/python.py | 4 ++-- parsers/java/pom.xml | 9 ++++----- .../main/java/com/bitshift/parsing/parsers/JavaParser.java | 12 ++++++------ .../main/java/com/bitshift/parsing/symbols/JavaSymbols.java | 10 +++++++++- 4 files changed, 21 insertions(+), 14 deletions(-) diff --git a/bitshift/parser/python.py b/bitshift/parser/python.py index 7e9b109..d0cd7d3 100644 --- a/bitshift/parser/python.py +++ b/bitshift/parser/python.py @@ -55,7 +55,7 @@ class _CachedWalker(ast.NodeVisitor): """ line, col = node.lineno, node.col_offset - pos = (line, col, line, col) + pos = (line, col, -1, -1) self.cache.append({'nodes': []}) self.generic_visit(node) @@ -104,7 +104,7 @@ class _CachedWalker(ast.NodeVisitor): """ line, col = node.lineno, node.col_offset - pos = (line, col, line, col) + pos = (line, col, -1, -1) if isinstance(node.func, ast.Name): name = node.func.id diff --git a/parsers/java/pom.xml b/parsers/java/pom.xml index cfecc30..c2191b0 100644 --- a/parsers/java/pom.xml +++ b/parsers/java/pom.xml @@ -13,13 +13,12 @@ junit junit - 3.8.1 - test + 4.11 - + org.eclipse.jdt - core - 3.3.0-v_771 + org.eclipse.jdt.core + 3.7.1 diff --git a/parsers/java/src/main/java/com/bitshift/parsing/parsers/JavaParser.java b/parsers/java/src/main/java/com/bitshift/parsing/parsers/JavaParser.java index 0150af4..4ba3623 100644 --- a/parsers/java/src/main/java/com/bitshift/parsing/parsers/JavaParser.java +++ b/parsers/java/src/main/java/com/bitshift/parsing/parsers/JavaParser.java @@ -76,7 +76,7 @@ public class JavaParser extends Parser { int sl = this.root.getLineNumber(node.getStartPosition()); int sc = this.root.getColumnNumber(node.getStartPosition()); - data.put("coord", Symbols.createCoord(sl, sc, null, null)); + data.put("coord", Symbols.createCoord(sl, sc, -1, -1)); this._cache.push(data); return true; } @@ -97,8 +97,8 @@ public class JavaParser extends Parser { int sl = this.root.getLineNumber(node.getStartPosition()); int sc = this.root.getColumnNumber(node.getStartPosition()); - Integer el = null; - Integer ec = null; + Integer el = -1; + Integer ec = -1; if (statements.size() > 0) { Statement last = statements.get(statements.size() - 1); @@ -127,7 +127,7 @@ public class JavaParser extends Parser { int sl = this.root.getLineNumber(node.getStartPosition()); int sc = this.root.getColumnNumber(node.getStartPosition()); - data.put("coord", Symbols.createCoord(sl, sc, null, null)); + data.put("coord", Symbols.createCoord(sl, sc, -1, -1)); data.put("name", name); this._cache.push(data); return true; @@ -157,7 +157,7 @@ public class JavaParser extends Parser { int sl = this.root.getLineNumber(node.getStartPosition()); int sc = this.root.getColumnNumber(node.getStartPosition()); - data.put("coord", Symbols.createCoord(sl, sc, null, null)); + data.put("coord", Symbols.createCoord(sl, sc, -1, -1)); this._cache.push(data); return true; } @@ -178,7 +178,7 @@ public class JavaParser extends Parser { int sl = this.root.getLineNumber(node.getStartPosition()); int sc = this.root.getColumnNumber(node.getStartPosition()); - data.put("coord", Symbols.createCoord(sl, sc, null, null)); + data.put("coord", Symbols.createCoord(sl, sc, -1, -1)); this._cache.push(data); return true; } diff --git a/parsers/java/src/main/java/com/bitshift/parsing/symbols/JavaSymbols.java b/parsers/java/src/main/java/com/bitshift/parsing/symbols/JavaSymbols.java index dd15468..5419d5a 100644 --- a/parsers/java/src/main/java/com/bitshift/parsing/symbols/JavaSymbols.java +++ b/parsers/java/src/main/java/com/bitshift/parsing/symbols/JavaSymbols.java @@ -29,7 +29,15 @@ public class JavaSymbols extends Symbols { } public boolean insertClassDeclaration(String name, HashMap data) { - this._classes.put(name, data); + ArrayList assignments = new ArrayList(10); + ArrayList uses = new ArrayList(10); + HashMap klass = new HashMap(); + + assignments.add(data.get("coord")); + klass.put("assignments", assignments); + klass.put("uses", uses); + + this._classes.put(name, klass); return true; }