Browse Source

1) All unavailable line numbers and column numbers become -1.

2) Add correct dependency in pom.xml
tags/v1.0^2
Benjamin Attal 10 years ago
parent
commit
d127ac94ad
4 changed files with 21 additions and 14 deletions
  1. +2
    -2
      bitshift/parser/python.py
  2. +4
    -5
      parsers/java/pom.xml
  3. +6
    -6
      parsers/java/src/main/java/com/bitshift/parsing/parsers/JavaParser.java
  4. +9
    -1
      parsers/java/src/main/java/com/bitshift/parsing/symbols/JavaSymbols.java

+ 2
- 2
bitshift/parser/python.py View File

@@ -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


+ 4
- 5
parsers/java/pom.xml View File

@@ -13,13 +13,12 @@
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<version>3.8.1</version>
<scope>test</scope>
<version>4.11</version>
</dependency>
<dependency>
<dependency>
<groupId>org.eclipse.jdt</groupId>
<artifactId>core</artifactId>
<version>3.3.0-v_771</version>
<artifactId>org.eclipse.jdt.core</artifactId>
<version>3.7.1</version>
</dependency>
</dependencies>



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

@@ -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;
}


+ 9
- 1
parsers/java/src/main/java/com/bitshift/parsing/symbols/JavaSymbols.java View File

@@ -29,7 +29,15 @@ public class JavaSymbols extends Symbols {
}

public boolean insertClassDeclaration(String name, HashMap<String, Object> data) {
this._classes.put(name, data);
ArrayList<Object> assignments = new ArrayList<Object>(10);
ArrayList<Object> uses = new ArrayList<Object>(10);
HashMap<String, Object> klass = new HashMap<String, Object>();

assignments.add(data.get("coord"));
klass.put("assignments", assignments);
klass.put("uses", uses);

this._classes.put(name, klass);
return true;
}



Loading…
Cancel
Save