Skip to content
This repository was archived by the owner on Mar 8, 2020. It is now read-only.
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions driver/normalizer/annotation.go
Original file line number Diff line number Diff line change
Expand Up @@ -149,6 +149,8 @@ var AnnotationRules = On(Any).Self(
),
),

On(jdt.AssertStatement).Roles(Assert, Statement),

// Others
On(jdt.Block).Roles(BlockScope, Block),
On(jdt.ExpressionStatement).Roles(Statement),
Expand Down
6 changes: 6 additions & 0 deletions native/src/main/java/bblfsh/EclipseParser.java
Original file line number Diff line number Diff line change
@@ -1,11 +1,14 @@
package bblfsh;

import org.eclipse.jdt.core.JavaCore;
import org.eclipse.jdt.core.dom.AST;
import org.eclipse.jdt.core.dom.ASTParser;
import org.eclipse.jdt.core.dom.CompilationUnit;

import java.io.IOException;

import java.util.Map;

/**
* Java AST parser based on Eclipse JDT.
* <p>
Expand Down Expand Up @@ -33,6 +36,9 @@ public EclipseParser() {
*/
public CompilationUnit parse(final String source) throws IOException {
parser.setSource(source.toCharArray());
Map options = JavaCore.getOptions();
JavaCore.setComplianceOptions(JavaCore.VERSION_1_8, options);
parser.setCompilerOptions(options);
return (CompilationUnit) parser.createAST(null);
}
}
72 changes: 72 additions & 0 deletions tests/assert.native
Original file line number Diff line number Diff line change
@@ -0,0 +1,72 @@
{
"status": "ok",
"errors": [],
"ast": {
"CompilationUnit": {
"internalClass": "CompilationUnit",
"types": [
{
"bodyDeclarations": [
{
"body": {
"internalClass": "Block",
"statements": [
{
"expression": {
"booleanValue": "true",
"internalClass": "BooleanLiteral",
"line": 3,
"startPosition": 40
},
"internalClass": "AssertStatement"
},
{
"expression": {
"booleanValue": "true",
"internalClass": "BooleanLiteral",
"line": 4,
"startPosition": 57
},
"internalClass": "AssertStatement",
"message": {
"booleanValue": "false",
"internalClass": "BooleanLiteral",
"line": 4,
"startPosition": 64
}
}
]
},
"constructor": "false",
"internalClass": "MethodDeclaration",
"line": 2,
"name": {
"identifier": "code",
"internalClass": "SimpleName",
"line": 2,
"startPosition": 20
},
"returnType2": {
"internalClass": "PrimitiveType",
"line": 2,
"primitiveTypeCode": "void",
"startPosition": 15
},
"startPosition": 15
}
],
"interface": "false",
"internalClass": "TypeDeclaration",
"line": 1,
"name": {
"identifier": "Code",
"internalClass": "SimpleName",
"line": 1,
"startPosition": 6
},
"startPosition": 0
}
]
}
}
}
6 changes: 6 additions & 0 deletions tests/assert.source
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
class Code {
void code() {
assert true;
assert true : false;
}
}
132 changes: 132 additions & 0 deletions tests/assert.uast
Original file line number Diff line number Diff line change
@@ -0,0 +1,132 @@
Status: ok
Errors:
UAST:
CompilationUnit {
. Roles: File
. Children: {
. . 0: TypeDeclaration {
. . . Roles: VisibleFromPackage,TypeDeclaration
. . . StartPosition: {
. . . . Offset: 0
. . . . Line: 1
. . . . Col: 0
. . . }
. . . Properties: {
. . . . interface: false
. . . . internalRole: types
. . . }
. . . Children: {
. . . . 0: SimpleName {
. . . . . Roles: SimpleIdentifier
. . . . . TOKEN "Code"
. . . . . StartPosition: {
. . . . . . Offset: 6
. . . . . . Line: 1
. . . . . . Col: 0
. . . . . }
. . . . . Properties: {
. . . . . . internalRole: name
. . . . . }
. . . . }
. . . . 1: MethodDeclaration {
. . . . . Roles: VisibleFromPackage,FunctionDeclaration
. . . . . StartPosition: {
. . . . . . Offset: 15
. . . . . . Line: 2
. . . . . . Col: 0
. . . . . }
. . . . . Properties: {
. . . . . . constructor: false
. . . . . . internalRole: bodyDeclarations
. . . . . }
. . . . . Children: {
. . . . . . 0: PrimitiveType {
. . . . . . . TOKEN "void"
. . . . . . . StartPosition: {
. . . . . . . . Offset: 15
. . . . . . . . Line: 2
. . . . . . . . Col: 0
. . . . . . . }
. . . . . . . Properties: {
. . . . . . . . internalRole: returnType2
. . . . . . . }
. . . . . . }
. . . . . . 1: SimpleName {
. . . . . . . Roles: SimpleIdentifier,FunctionDeclarationName
. . . . . . . TOKEN "code"
. . . . . . . StartPosition: {
. . . . . . . . Offset: 20
. . . . . . . . Line: 2
. . . . . . . . Col: 0
. . . . . . . }
. . . . . . . Properties: {
. . . . . . . . internalRole: name
. . . . . . . }
. . . . . . }
. . . . . . 2: Block {
. . . . . . . Roles: FunctionDeclarationBody,BlockScope,Block
. . . . . . . Properties: {
. . . . . . . . internalRole: body
. . . . . . . }
. . . . . . . Children: {
. . . . . . . . 0: AssertStatement {
. . . . . . . . . Roles: Assert,Statement
. . . . . . . . . Properties: {
. . . . . . . . . . internalRole: statements
. . . . . . . . . }
. . . . . . . . . Children: {
. . . . . . . . . . 0: BooleanLiteral {
. . . . . . . . . . . Roles: BooleanLiteral
. . . . . . . . . . . StartPosition: {
. . . . . . . . . . . . Offset: 40
. . . . . . . . . . . . Line: 3
. . . . . . . . . . . . Col: 0
. . . . . . . . . . . }
. . . . . . . . . . . Properties: {
. . . . . . . . . . . . booleanValue: true
. . . . . . . . . . . . internalRole: expression
. . . . . . . . . . . }
. . . . . . . . . . }
. . . . . . . . . }
. . . . . . . . }
. . . . . . . . 1: AssertStatement {
. . . . . . . . . Roles: Assert,Statement
. . . . . . . . . Properties: {
. . . . . . . . . . internalRole: statements
. . . . . . . . . }
. . . . . . . . . Children: {
. . . . . . . . . . 0: BooleanLiteral {
. . . . . . . . . . . Roles: BooleanLiteral
. . . . . . . . . . . StartPosition: {
. . . . . . . . . . . . Offset: 57
. . . . . . . . . . . . Line: 4
. . . . . . . . . . . . Col: 0
. . . . . . . . . . . }
. . . . . . . . . . . Properties: {
. . . . . . . . . . . . booleanValue: true
. . . . . . . . . . . . internalRole: expression
. . . . . . . . . . . }
. . . . . . . . . . }
. . . . . . . . . . 1: BooleanLiteral {
. . . . . . . . . . . Roles: BooleanLiteral
. . . . . . . . . . . StartPosition: {
. . . . . . . . . . . . Offset: 64
. . . . . . . . . . . . Line: 4
. . . . . . . . . . . . Col: 0
. . . . . . . . . . . }
. . . . . . . . . . . Properties: {
. . . . . . . . . . . . booleanValue: false
. . . . . . . . . . . . internalRole: message
. . . . . . . . . . . }
. . . . . . . . . . }
. . . . . . . . . }
. . . . . . . . }
. . . . . . . }
. . . . . . }
. . . . . }
. . . . }
. . . }
. . }
. }
}