/** * Returns the construct that is subject to change. */ public Construct getConstruct() { if(this.getType()==ConstructChangeType.DEL) return this.def; else return this.fix; }
/** * Creates instances of {@link FileAnalyzer} depending on the file. * @param _file * @return */ public final static FileAnalyzer buildFileAnalyzer(File _file) throws IllegalArgumentException { return FileAnalyzerFactory.buildFileAnalyzer(_file, null); }
public Set<FileAnalyzer> getNestedArchives() { if(this.fileAnalyzer!=null && !(this.fileAnalyzer instanceof DirAnalyzer)) { return this.fileAnalyzer.getChilds(true); } else { return null; } }
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
/** * 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()); }
/** * Returns true if construct id and revision are equal. */ @Override public boolean equals(Object obj) { if (this == obj) return true; if (obj == null) return false; if (getClass() != obj.getClass()) return false; final ConstructChange other = (ConstructChange)obj; final ConstructId tc = (this.def!=null ? com.sap.psr.vulas.ConstructId.toSharedType(this.def.getId()) : com.sap.psr.vulas.ConstructId.toSharedType(this.fix.getId())); final ConstructId oc = (other.def!=null ? com.sap.psr.vulas.ConstructId.toSharedType(other.def.getId()) : com.sap.psr.vulas.ConstructId.toSharedType(other.fix.getId())); return (tc.equals(oc) && this.commit.equals(other.commit)); }
@Override public Map<ConstructId, Construct> getConstructs() throws FileAnalysisException { if(this.constructs==null) { analyzer = PythonFileAnalyzer.createAnalyzer(this.file); analyzer.analyze(this.file); this.constructs = analyzer.getConstructs(); } return analyzer.getConstructs(); }
public ASTConstructBodySignature(Construct _construct){ super(JavaEntityType.METHOD, _construct.getId().getSimpleName()); sMethodBodyConverter = sInjector.getInstance(JavaMethodBodyConverter.class); this._construct = _construct; fCompilation = CompilationUtils.compileSource(getSourceCodeWithSnippets(_construct.getContent())); }
@Override public String toString() { return "[" + this.caller.getQualifiedName() + " --> " + this.callee.getQualifiedName() + "]"; }
@Override public final int compareTo(ConstructChange _cc) { final int id_comparison_result = this.getConstruct().getId().compareTo(_cc.getConstruct().getId()); if (id_comparison_result==0 && this.commit!=null) return this.commit.compareTo(_cc.commit); else return id_comparison_result; } }
@Override public Signature createSignature(Construct _construct) { if(_construct!=null && _construct.getContent()!=null) return new PythonConstructDigest(_construct.getContent(), DigestAlgorithm.SHA1); else return null; }
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() {
@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
@Override public boolean containsConstruct(ConstructId _id) throws FileAnalysisException { return this.getConstructs().containsKey(_id); }
/** * Compares the construct with the given construct by comparing their qualified name. * @param _c * @return */ public final int compareTo(ConstructId _c) { return this.getQualifiedName().compareTo(_c.getQualifiedName()); }
@Override public Construct getConstruct(ConstructId _id) throws FileAnalysisException { return this.getConstructs().get(_id); }
public final void addConstructIds(Collection<ConstructId> _classes) { for(ConstructId cid: _classes) { classNames.add(cid.getQualifiedName()); } }
@Override public int hashCode() { final int prime = 31; int result = 1; result = prime * result + this.getQualifiedName().hashCode(); return result; }
@Override public String toString() { final StringBuffer b = new StringBuffer(); b.append("[qname="); b.append(this.constructId.getQualifiedName()); if(this.sha1!=null) { b.append(", libsha1=").append(this.sha1); } b.append("]"); return b.toString(); } }