/** * Returns true if the given {@link ConstructId} is deleted. */ @JsonIgnore public boolean isDeleted(@NotNull ConstructId _cid) { return (_cid.getType()==ConstructType.CONS && this.removedConstructors!=null && this.removedConstructors.contains(_cid)) || (_cid.getType()==ConstructType.METH && this.removedMethods!=null && this.removedMethods.contains(_cid)); }
public ConstructIdFilter(Collection<ConstructId> _constructs_ids) { SortedSet<ConstructId> cids = null; if(_constructs_ids!=null) { for(ConstructId cid: _constructs_ids) { cids = this.constructIds.get(cid.getType()); if(cids==null) { cids = new TreeSet<ConstructId>(); this.constructIds.put(cid.getType(), cids); } cids.add(cid); } } }
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(); }
/** * vulas-cia:/constructs()/{sha1}/{type}/{qname}/ast * @return */ public static final String constructSignature(@NotNull String _sha1, @NotNull com.sap.psr.vulas.shared.json.model.ConstructId _cid) { final StringBuilder b = new StringBuilder(); b.append(constructs()); b.append("/").append(_sha1); b.append("/").append(_cid.getType().toString()); b.append("/").append(_cid.getQname()); b.append("/ast"); return b.toString(); }
/** * 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()) ); }
/** * vulas-cia:/constructs()/{group}/{artifact}/{version}/{type}/{qname}/ast * @return */ public static final String constructSignature(@NotNull Application _lib, @NotNull com.sap.psr.vulas.shared.json.model.ConstructId _cid) { final StringBuilder b = new StringBuilder(); b.append(constructs()); b.append("/").append(_lib.getMvnGroup()); b.append("/").append(_lib.getArtifact()); b.append("/").append(_lib.getVersion()); b.append("/").append(_cid.getType().toString()); b.append("/").append(_cid.getQname()); b.append("/ast"); return b.toString(); }
/** * 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())); }
private void setChangeList(){ Collection<ConstructChange> constructChanges = bugChangeList.getConstructChanges(); this.methsConsCC = new ArrayList<>(); for (ConstructChange cc : constructChanges) { if (cc.getConstructId().getType().equals(ConstructType.METH) || cc.getConstructId().getType().equals(ConstructType.CONS)) this.methsConsCC.add(cc); } }
/** * 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; }
ConstructId ccid = null; if(_cid.getType()==ConstructType.PACK) throw new IllegalArgumentException("Cannot determine class of a package"); else if(_cid.getType()==ConstructType.CLAS) ccid = _cid; else if(_cid.getType()==ConstructType.INIT || _cid.getType()==ConstructType.METH) { int idx = _cid.getQname().lastIndexOf("."); ccid = new ConstructId(_cid.getLang(), ConstructType.CLAS, _cid.getQname().substring(0, idx)); else if(_cid.getType()==ConstructType.CONS) { final int idx = _cid.getQname().lastIndexOf("("); if(idx==-1)
/** * Returns true if the given {@link ConstructId} is modified. */ @JsonIgnore public boolean isBodyChanged(@NotNull ConstructId _cid) { boolean mod = false; if(_cid.getType()==ConstructType.CONS && this.modifiedConstructors!=null) { for(ClassModification m: this.modifiedConstructors) { if(m.getNewConstruct().getQname().equals(_cid.getQname()) && m.isBodyChanged()) { mod = true; break; } } } else if(_cid.getType()==ConstructType.METH && this.modifiedMethods!=null) { for(ClassModification m: this.modifiedMethods) { if(m.getNewConstruct().getQname().equals(_cid.getQname()) && m.isBodyChanged()) { mod = true; break; } } } return mod; } }
else cshared = PythonId.toSharedType(c); if(type==null || type.equals("") || cshared.getType().toString().equals(type.toString())) constructs_out.add(cshared);
for(ConstructChange c:methsConsCC){ if(c.getConstructId().getQname().equals(splitLine[0])) type=c.getConstructId().getType();
@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; }
JsonObject constructId = new JsonObject(); constructId.addProperty("lang", c.getConstructId().getLang().toString()); constructId.addProperty("type", c.getConstructId().getType().toString()); constructId.addProperty("qname", c.getConstructId().getQname()); cc.add("constructId", constructId);
/** * Transforms an object with a given shared type (defined in vulas-share) into * an object having the corresponding core type (defined in vulas-core). * @param _cid * @return */ public static com.sap.psr.vulas.ConstructId toCoreType(com.sap.psr.vulas.shared.json.model.ConstructId _cid) { switch(_cid.getType()) { case METH: return JavaId.parseMethodQName(_cid.getQname()); case CONS: return JavaId.parseConstructorQName(_cid.getQname()); case PACK: return new JavaPackageId(_cid.getQname()); case INIT: return JavaId.parseClassInitQName(_cid.getQname()); case ENUM: return JavaId.parseEnumQName(_cid.getQname()); case CLAS: return JavaId.parseClassQName(_cid.getQname()); default: throw new IllegalArgumentException("Unknown type [" + _cid.getType() + "]"); } }
(cc.getConstructId().getType().equals(ConstructType.METH) || cc.getConstructId().getType().equals(ConstructType.CONS) || cc.getConstructId().getType().equals(ConstructType.FUNC) || cc.getConstructId().getType().equals(ConstructType.MODU) ) ){ OrderedCCperConstructPath2 a = new OrderedCCperConstructPath2(cc.getConstructId(),cc.getRepoPath()); if(orderedQnamePerCC.contains(a)){
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());
if((c.getConstructId().getType().equals(ConstructType.CONS)||c.getConstructId().getType().equals(ConstructType.METH))&&c.getConstructChangeType().equals(ConstructChangeType.MOD)){ mod_exists=true; BugLibManager.log.info("At least one MOD constructor/method for bug ["+b.getBugId()+"] exists, continue patchEval");
if(BackendConnector.getInstance().getSourcesForQnameInLib(qString+"/"+mcCC.getConstructId().getType().toString()+"/"+mcCC.getConstructId().getQname())!=null) sourcesQnameLib = true; ast_lid = BackendConnector.getInstance().getAstForQnameInLib(qString+"/"+mcCC.getConstructId().getType().toString()+"/"+mcCC.getConstructId().getQname(),true,ProgrammingLanguage.JAVA); Gson gson = GsonHelper.getCustomGsonBuilder().create(); log.error("Got null for ast "+qString+"/"+mcCC.getConstructId().getType().toString()+"/"+mcCC.getConstructId().getQname()+ " for library [" + l + "] where sourcesQnameLib is " + sourcesQnameLib + "qnameinjar and sources " + qnameInBin + " " + sourcesAvailable ); throw new Exception("AST_LID not available"); // happens when 500