Search in sources :

Example 1 with ModuleDeclaration

use of com.github.javaparser.ast.modules.ModuleDeclaration in project drools by kiegroup.

the class DrlxVisitor method visit.

public void visit(CompilationUnit u, Void arg) {
    PackageDeclaration packageDeclaration = u.getPackageDeclaration().orElseThrow(() -> new ParseException("Expected package declaration.", -1));
    String pkgName = packageDeclaration.getNameAsString();
    builder.name(pkgName);
    for (ImportDeclaration i : u.getImports()) {
        this.visit(i, null);
    }
    ModuleDeclaration moduleDeclaration = u.getModule().orElseThrow(() -> new ParseException("Expected unit declaration.", -1));
    builder.newUnit().target(String.format("%s.%s", pkgName, moduleDeclaration.getNameAsString()));
    for (TypeDeclaration<?> typeDeclaration : u.getTypes()) {
        RuleDeclaration rd = (RuleDeclaration) typeDeclaration;
        this.visit(rd, null);
    }
}
Also used : ImportDeclaration(com.github.javaparser.ast.ImportDeclaration) ModuleDeclaration(com.github.javaparser.ast.modules.ModuleDeclaration) ParseException(org.drools.drl.parser.lang.ParseException) PackageDeclaration(com.github.javaparser.ast.PackageDeclaration)

Example 2 with ModuleDeclaration

use of com.github.javaparser.ast.modules.ModuleDeclaration in project checker-framework by typetools.

the class JointJavacJavaParserVisitor method visitModule.

@Override
public Void visitModule(ModuleTree javacTree, Node javaParserNode) {
    ModuleDeclaration node = castNode(ModuleDeclaration.class, javaParserNode, javacTree);
    processModule(javacTree, node);
    javacTree.getName().accept(this, node.getName());
    return null;
}
Also used : ModuleDeclaration(com.github.javaparser.ast.modules.ModuleDeclaration)

Example 3 with ModuleDeclaration

use of com.github.javaparser.ast.modules.ModuleDeclaration in project checker-framework by typetools.

the class DoubleJavaParserVisitor method visit.

@Override
public void visit(final ModuleDeclaration node1, final Node other) {
    ModuleDeclaration node2 = (ModuleDeclaration) other;
    defaultAction(node1, node2);
    visitLists(node1.getDirectives(), node2.getDirectives());
    node1.getName().accept(this, node2.getName());
}
Also used : ModuleDeclaration(com.github.javaparser.ast.modules.ModuleDeclaration)

Aggregations

ModuleDeclaration (com.github.javaparser.ast.modules.ModuleDeclaration)3 ImportDeclaration (com.github.javaparser.ast.ImportDeclaration)1 PackageDeclaration (com.github.javaparser.ast.PackageDeclaration)1 ParseException (org.drools.drl.parser.lang.ParseException)1