@Override public Signature createSignature(Construct _construct) { if(_construct!=null && _construct.getContent()!=null) return new PythonConstructDigest(_construct.getContent(), DigestAlgorithm.SHA1); else return null; }
public ASTConstructBodySignature(Construct _construct){ super(JavaEntityType.METHOD, _construct.getId().getSimpleName()); sMethodBodyConverter = sInjector.getInstance(JavaMethodBodyConverter.class); this._construct = _construct; fCompilation = CompilationUtils.compileSource(getSourceCodeWithSnippets(_construct.getContent())); }
final String source_code = jfa.getConstruct(jid).getContent(); response.getWriter().print(source_code); response.flushBuffer();
final String source_code = jfa.getConstruct(jid).getContent(); response.getWriter().print(source_code); response.flushBuffer();
@Override public Signature createSignature(ConstructId _cid, File _file) { if(!_cid.getLang().equals(ProgrammingLanguage.PY)) throw new IllegalArgumentException("Programming language [" + _cid.getLang() + "] not supported"); Signature signature = null; // Compute signature from the entire file if(_cid.getType().equals(ConstructType.MODU)) { signature = new PythonConstructDigest(_file.toPath(), DigestAlgorithm.SHA1); } // For all others, parse the file, and compute the digest for the construct body else { try { final Python3FileAnalyzer fa = (Python3FileAnalyzer)FileAnalyzerFactory.buildFileAnalyzer(_file, new String[] { "py" }); final Construct c = fa.getConstruct(_cid); if(c==null) { throw new IllegalStateException("Construct [" + _cid +"] cannot be found in file [" + _file + "]"); } else { signature = new PythonConstructDigest(c.getContent(), DigestAlgorithm.SHA1); } } catch (IllegalArgumentException e) { log.error(e); } catch (FileAnalysisException e) { log.error(e); } } return signature; }