@Override public String toString() { return "[" + this.caller.getQualifiedName() + " --> " + this.callee.getQualifiedName() + "]"; }
/** * Transforms an object with a given core type (defined in vulas-core) into * an object having the corresponding shared type (defined in vulas-share). * @param _core_type * @return */ public static com.sap.psr.vulas.shared.json.model.ConstructId toSharedType(com.sap.psr.vulas.ConstructId _core_type) { return new com.sap.psr.vulas.shared.json.model.ConstructId(_core_type.getLanguage(), _core_type.getSharedType(), _core_type.getQualifiedName()); }
@Override public boolean equals(Object obj) { if (this == obj) return true; if (obj == null) return false; if (getClass() != obj.getClass()) return false; Construct other = (Construct) obj; if (contentDigest == null) { if (other.contentDigest != null) return false; } else if (!contentDigest.equals(other.contentDigest)) return false; if (id == null) { if (other.id != null) return false; } else if (!id.equals(other.id)) return false; return true; } public String toString() {
public List<com.sap.psr.vulas.shared.json.model.ConstructId> getSharedConstructs() throws FileAnalysisException { List<com.sap.psr.vulas.shared.json.model.ConstructId> l= new ArrayList<com.sap.psr.vulas.shared.json.model.ConstructId>(); for(ConstructId c: this.getConstructs().keySet()) { l.add(new com.sap.psr.vulas.shared.json.model.ConstructId(ProgrammingLanguage.PY, c.getSharedType(),c.getQualifiedName())); } return l; } }
public JsonElement serialize(ConstructId src, Type typeOfSrc, JsonSerializationContext context) { final JsonObject c = new JsonObject(); c.addProperty("lang", src.getLanguage().toString()); c.addProperty("type", JavaId.typeToString(((JavaId)src).getType())); c.addProperty("qname", src.getQualifiedName()); final Set<String> annotations = ((JavaId)src).getAnnotations(); if(!annotations.isEmpty()) { final JsonArray anno = new JsonArray(); for(String a: annotations) { anno.add(new JsonPrimitive(a)); } c.add("a", anno); } return c; }
ConstructId tocheck = c.getConstruct().getId(); boolean toDelete = true; if(tocheck.getSharedType()==ConstructType.CLAS) { for(ConstructChange in : ch_array) { if(tocheck.equals(in.getConstruct().getId().getDefinitionContext())) { toDelete = false; break;
/** * This method look into the custom ClassPool and return a string with the * physical path of the JAR if is present in the resources loaded into the * ClassPool. If is not found it returns null * PS: We can add to the ClassPool all the resources that we want using * the method {@ClassPoolUpdater#appendToClasspath} * @param _cid the ConstructId that we want to search in the ClassPool * @return the JAR path or null if is not found */ public URL getJarResourcePath(ConstructId _cid) { URL url = null; if(_cid instanceof JavaId) { final JavaId jid = (JavaId)_cid; if(jid.getType()==JavaId.Type.METHOD || jid.getType()==JavaId.Type.CONSTRUCTOR || jid.getType()==JavaId.Type.CLASSINIT) { url = this.customClassPool.find(_cid.getDefinitionContext().getQualifiedName()); } else if(jid.getType()==JavaId.Type.CLASS || jid.getType()==JavaId.Type.INTERFACE || jid.getType()==JavaId.Type.ENUM || jid.getType()==JavaId.Type.NESTED_CLASS) { url = this.customClassPool.find(_cid.getQualifiedName()); } } return url; }
a.addConstructs(ConstructId.getSharedType(app_constructs));
public static Collection<com.sap.psr.vulas.shared.json.model.ConstructId> getSharedType(Collection<com.sap.psr.vulas.ConstructId> _c) { final Collection<com.sap.psr.vulas.shared.json.model.ConstructId> c = new HashSet<com.sap.psr.vulas.shared.json.model.ConstructId>(); for(ConstructId cid: _c) c.add(ConstructId.toSharedType(cid)); return c; } }
if(change_lists.get(b).contains(ConstructId.toSharedType(cle))) { if(!paths_per_bug.containsKey(b)) paths_per_bug.put(b, new ArrayList<List<PathNode>>()); if ( (m++)>0 ) json.append(","); json.append("{"); json.append("\"constructId\":").append(cid.getConstructId().toJSON());
/** * Returns true if the class of the construct is part of the archive, false otherwise. * @return */ private boolean isConstructClassInArchive() { return this.ja.getConstructIds().contains(JavaId.toCoreType(this.constructId).getDefinitionContext()); }
@Override public int hashCode() { final int prime = 31; int result = 1; result = prime * result + ((contentDigest == null) ? 0 : contentDigest.hashCode()); result = prime * result + ((id == null) ? 0 : id.hashCode()); return result; } @Override
public String toJSON() { final StringBuilder b = new StringBuilder(); // Key information b.append("{"); b.append(" \"repo\" : \"").append(this.repo).append("\","); if(this.repoPath!=null) b.append(" \"repoPath\" : \"").append(this.repoPath).append("\","); b.append(" \"constructId\" : ").append(this.getConstruct().getId().toJSON()).append(","); if(this.commit!=null) b.append(" \"commit\" : \"").append(this.commit).append("\","); // Other information b.append(" \"constructChangeType\":\"").append(this.getType().toString()).append("\","); if(this.committedAt!=null) b.append(" \"committedAt\" : \"").append(StringUtil.formatDate(Long.parseLong(this.getCommittedAt()))).append("\""); // Buggy method body, fixed one and applied changes if(this.getType() == ConstructChangeType.MOD ){ if(this.fixSignature != null) //b.append(" \"description\" : ").append(JsonBuilder.escape(this.bugDescription)).append(", "); b.append(",\"fixedBody\":").append(JsonBuilder.escape(this.fixSignature.toJson().toString())); //b.append(getFixConstructASTSignature().toJson().toString()).append(" ,"); if(this.defSignature != null) b.append(",\"buggyBody\":").append(JsonBuilder.escape(this.defSignature.toJson().toString())); //b.append(getDefConstructASTSignature().toJson().toString()).append(" ,"); if(signatureChange != null) //b.append(" \"signatureChange\" : ").append(astDiff.toJSON().toString()).append(" ,"); //b.append("\"sigchg \" :[").append(JsonBuilder.escape(astDiff.toJSON().toString())).append("]").append(" ,"); b.append(",\"bodyChange\":").append(JsonBuilder.escape(signatureChange.toJSON().toString())); //b.append(astDiff.toJSON().toString()).append(" ,"); } b.append("}"); return b.toString(); }
String className = JavaId.toCoreType(constructId).getDefinitionContext().getName();
public List<com.sap.psr.vulas.shared.json.model.ConstructId> getSharedConstructs() throws FileAnalysisException { List<com.sap.psr.vulas.shared.json.model.ConstructId> l= new ArrayList<com.sap.psr.vulas.shared.json.model.ConstructId>(); for(ConstructId c: this.getConstructIds()) { l.add(new com.sap.psr.vulas.shared.json.model.ConstructId(ProgrammingLanguage.JAVA, c.getSharedType(),c.getQualifiedName())); } return l; }
/** * Returns a {@link Library} representing the analyzed archive. * @return * @throws FileAnalysisException */ public Library getLibrary() throws FileAnalysisException { Library lib = null; if(this.fileAnalyzer!=null && this.fileAnalyzer instanceof PythonArchiveAnalyzer) { lib = ((PythonArchiveAnalyzer)this.fileAnalyzer).getLibrary(); lib.setLibraryId(new LibraryId(this.getName(), this.getName(), this.getVersion())); } else { lib = new Library(); lib.setDigest(this.getDigest()); lib.setDigestAlgorithm(DigestAlgorithm.MD5); lib.setLibraryId(new LibraryId(this.getName(), this.getName(), this.getVersion())); if(this.getConstructs()!=null) lib.setConstructs(ConstructId.getSharedType(this.getConstructs().keySet())); } final Set<Property> p = new HashSet<Property>(); for(String key: this.getProperties().keySet()) { p.add(new Property(PropertySource.PIP, key, this.getProperties().get(key))); } lib.setProperties(p); return lib; }
/** * Maybe promote this method, which uses the shared type as argument, to the interface. * Alternatively, make all core-internal interfaces work with core types, not with shared * types. Example to be changed: SignatureFactory. */ public Construct getConstruct(com.sap.psr.vulas.shared.json.model.ConstructId _id) throws FileAnalysisException { for(ConstructId cid: this.constructs.keySet()) if(ConstructId.toSharedType(cid).equals(_id)) return this.constructs.get(cid); return null; }
private boolean isNestedClassConstruct() { final com.sap.psr.vulas.ConstructId c = JavaId.toCoreType(this.constructId).getDefinitionContext(); if(c instanceof JavaClassId) return ((JavaClassId)c).isNestedClass(); else return false; }
@Override public int hashCode() { final int prime = 31; int result = 1; result = prime * result + ((appContext == null) ? 0 : appContext.hashCode()); result = prime * result + ((c == null) ? 0 : c.hashCode()); result = prime * result + ((resourceURL == null) ? 0 : resourceURL.hashCode()); return result; } @Override
public String toJSON() { final JsonBuilder jb = new JsonBuilder(); jb.startObject(); jb.appendObjectProperty("id", this.id.toJSON(), false); jb.appendObjectProperty("cd", this.contentDigest); jb.endObject(); return jb.getJson(); } @Override