public Construct(ConstructId _id, String _content) { if(_id == null || _content==null) throw new IllegalArgumentException("Id and content must be provided"); this.id = _id; this.setContent(_content); } public String getDigest() {
public Map<ConstructId, Construct> getConstructs(InputStream m) throws FileAnalysisException, IOException, RecognitionException { final ANTLRInputStream input = new ANTLRInputStream(m); final Python3Lexer lexer = new Python3Lexer(input); final CommonTokenStream tokens = new CommonTokenStream(lexer); final Python3Parser parser = new Python3Parser(tokens); final ParseTree root = parser.file_input(); final ParseTreeWalker walker = new ParseTreeWalker(); try { walker.walk(this, root); } catch(IllegalStateException ise) { throw new FileAnalysisException(ise.getMessage(), ise); } // Update module body after the parsing of the entire file if(this.stmts!=null && this.stmts.size()>0) { final StringBuffer b = new StringBuffer(); for(String stmt: this.stmts) if(!stmt.trim().equals("")) b.append(stmt); this.constructs.get(this.module).setContent(b.toString()); } return this.constructs; }
public Map<ConstructId, Construct> getConstructs(InputStream m) throws FileAnalysisException, IOException, RecognitionException { final ANTLRInputStream input = new ANTLRInputStream(m); final Python335Lexer lexer = new Python335Lexer(input); final CommonTokenStream tokens = new CommonTokenStream(lexer); final Python335Parser parser = new Python335Parser(tokens); final ParseTree root = parser.file_input(); final ParseTreeWalker walker = new ParseTreeWalker(); try { walker.walk(this, root); } catch(IllegalStateException ise) { throw new FileAnalysisException("Parser error", ise); } // Update module body after the parsing of the entire file if(this.stmts!=null && this.stmts.size()>0) { final StringBuffer b = new StringBuffer(); for(String stmt: this.stmts) if(!stmt.trim().equals("")) b.append(stmt); this.constructs.get(this.module).setContent(b.toString()); } return this.constructs; }