public final String toString() { final StringBuilder builder = new StringBuilder(); builder.append("[").append(this.getId()).append(":").append(this.getLang()).append("|").append(this.getType()).append("|").append(this.getQname()).append("]"); return builder.toString(); }
@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; }
throw new IllegalArgumentException("Cannot determine . in qname [" + _cid.getQname() + "]"); else ccid = new ConstructId(_cid.getLang(), ConstructType.CLAS, _cid.getQname().substring(0, idx)); throw new IllegalArgumentException("Cannot determine . in qname [" + _cid.getQname() + "]"); else ccid = new ConstructId(_cid.getLang(), ConstructType.CLAS, _cid.getQname().substring(0, idx));
/** * Returns true if the given {@link ConstructId} is of type Java method or Java constructor. */ @Override public boolean isSupportedConstructId(ConstructId _id) { return _id!=null && ProgrammingLanguage.JAVA.equals(_id.getLang()) && ( ConstructType.METH.equals(_id.getType()) || ConstructType.CONS.equals(_id.getType())); }
if(json_cid.getLang().equals(ProgrammingLanguage.JAVA) && !cc.getConstructChangeType().equals(ConstructChangeType.ADD)) { changes_set.add(json_cid);
if(ProgrammingLanguage.JAVA.equals(cid.getLang())) {
cc.addProperty("repoPath", c.getRepoPath()); JsonObject constructId = new JsonObject(); constructId.addProperty("lang", c.getConstructId().getLang().toString()); constructId.addProperty("type", c.getConstructId().getType().toString()); constructId.addProperty("qname", c.getConstructId().getQname());
if(cc.getConstructId().getLang()==ProgrammingLanguage.JAVA) hasJava = true;
if(!pack_cids.contains(new ConstructId(c.getLang(),c.getType(),c.getQname()))){ equal = false; LibraryController.log.info("["+lid.toString()+"] contains a pack not included in the requested jar: " + c.toString()); if(!cids.contains(new ConstructId(c.getLang(),c.getType(),c.getQname()))){ equal = false; LibraryController.log.info("["+lid.toString()+"] contains a construct not included in the requested jar: " + c.toString());
/** * Returns a {@link ConstructId} of type {@link ConstructType#PACK} in which the given construct ID has been declared. * @param _cid * @return */ public static ConstructId getPackageOf(ConstructId _cid) { ConstructId ccid = null; if(_cid.getType()==ConstructType.PACK) ccid = _cid; else if(_cid.getType()==ConstructType.CLAS) { int idx = _cid.getQname().lastIndexOf("."); //final String ctx = _cid.getQname().substring(0, idx); if(idx==-1) ccid = null; //throw new IllegalArgumentException("Cannot determine . in qname [" + _cid.getQname() + "]"); else ccid = new ConstructId(_cid.getLang(), ConstructType.PACK, _cid.getQname().substring(0, idx)); } else if(_cid.getType()==ConstructType.INIT || _cid.getType()==ConstructType.METH) ccid = JarDiffResult.getPackageOf(JarDiffResult.getClassOf(_cid)); else if(_cid.getType()==ConstructType.CONS) ccid = JarDiffResult.getPackageOf(JarDiffResult.getClassOf(_cid)); return ccid; }
/** * Returns true if the given {@link ConstructId} is of type Java method or Java constructor. */ @Override public boolean isSupportedConstructId(ConstructId _id) { return _id!=null && ProgrammingLanguage.PY.equals(_id.getLang()) && ( ConstructType.FUNC.equals(_id.getType()) || ConstructType.MODU.equals(_id.getType()) || ConstructType.METH.equals(_id.getType()) || ConstructType.CONS.equals(_id.getType()) ); }