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