示例#1
0
def parse(program):
    parser = ASTParser.newParser(AST.JLS3)
    parser.setSource(String(program).toCharArray())
    parser.setKind(ASTParser.K_COMPILATION_UNIT)

    cu = parser.createAST(None)
    print cu
示例#2
0
文件: main.py 项目: goingkilo/astex
def parse( program):
    parser = ASTParser.newParser(AST.JLS3);
    parser.setSource( String(program).toCharArray());
    parser.setKind(ASTParser.K_COMPILATION_UNIT);
    
    cu = parser.createAST(None);
    print cu
示例#3
0
    def getASTParser(self, sourceCode, parserType):
        parser = ASTParser.newParser(AST.JLS3);
        # print "RESOLVE", self.resolve

        parser.setSource(String(sourceCode).toCharArray())
        parser.setResolveBindings(self.resolve);
        parser.setStatementsRecovery(self.resolve);
        parser.setBindingsRecovery(self.resolve);
        parser.setKind(parserType)
        return parser
示例#4
0
文件: __init__.py 项目: rfw/navigr8
def source(project_name, path):
    workspace = ResourcesPlugin.getWorkspace()
    projects = get_projects(workspace)

    if project_name not in projects:
        abort(404)

    project = projects[project_name]
    resource = project.project.findMember(Path(path))

    if resource is None:
        abort(404)

    if resource.type == IResource.FILE:
        code = open(resource.contents).read().decode('utf-8', errors='replace').replace("\r", "")

        parser = ASTParser.newParser(AST.JLS3)
        parser.kind = ASTParser.K_COMPILATION_UNIT
        parser.setSource(String(code).toCharArray())
        parser.resolveBindings = True

        comp_unit = parser.createAST(None)

        return render_template('file.html',
            workspace=workspace,
            projects=projects,
            comp_unit=comp_unit,
            project=project,
            code=code
        )
    else:
        return render_template('folder.html',
            workspace=workspace,
            projects=projects,
            project=project,
            folder=resource
        )