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("."); throw new IllegalArgumentException("Cannot determine . in qname [" + _cid.getQname() + "]"); else 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) throw new IllegalArgumentException("Cannot determine . in qname [" + _cid.getQname() + "]"); else ccid = new ConstructId(_cid.getLang(), ConstructType.CLAS, _cid.getQname().substring(0, idx));
/** * 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; }
@Override public int hashCode(){ return this.constructId.hashCode()+this.repoPath.hashCode(); }
public com.sap.psr.vulas.shared.json.model.ConstructId toSharedType() { final com.sap.psr.vulas.shared.json.model.ConstructId shared_type = new com.sap.psr.vulas.shared.json.model.ConstructId(); shared_type.setLang(this.getLang()); shared_type.setType(this.getType()); shared_type.setQname(this.getQname()); return shared_type; } }
/** * 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() + "]"); } }
if(cpa.getConstruct().equals(c.getConstructId().getQname()) && c.getRepoPath().contains(cpa.getPath()) && c.getConstructChangeType().toString().equals(cpa.getType())){ JsonObject thisCc = new JsonObject(); 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()); cc.add("constructId", constructId);
/** * 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()) ); }
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()); break; 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()); break;
private com.sap.psr.vulas.shared.json.model.ConstructId getClass(Classfile _classfile) { com.sap.psr.vulas.shared.json.model.ConstructId c = new com.sap.psr.vulas.shared.json.model.ConstructId(); c.setLang(ProgrammingLanguage.JAVA); c.setQname(_classfile.getClassName()); c.addRelates("annotation", new ConstructId(ProgrammingLanguage.JAVA, ConstructType.INTF, "java.lang.Deprecated")); c.addAttribute("final", _classfile.isFinal()); c.addAttribute("synthetic", _classfile.isSynthetic()); c.addAttribute("super", _classfile.isSuper()); c.addAttribute("visibility", "public"); else if(_classfile.isPackage()) c.addAttribute("visibility", "package"); c.setType(ConstructType.INTF); Iterator<? extends Class_info> i = _classfile.getAllInterfaces().iterator(); while (i.hasNext()) { c.addRelates("extends", new ConstructId(ProgrammingLanguage.JAVA, ConstructType.INTF, i.next().toString())); c.setType(ConstructType.CLAS); c.addRelates("extends", new ConstructId(ProgrammingLanguage.JAVA, ConstructType.CLAS, _classfile.getSuperclassName())); c.addAttribute("abstract", _classfile.isAbstract()); Iterator<? extends Class_info> i = _classfile.getAllInterfaces().iterator(); while (i.hasNext()) { c.addRelates("implements", new ConstructId(ProgrammingLanguage.JAVA, ConstructType.INTF,i.next().toString()));
if(ProgrammingLanguage.JAVA.equals(cid.getLang())) { _constructs_qname.add(cid.getQname()); this.filteredEP.add(cid); method = (IMethod) m_iter.next(); if (!method.isClinit()) { method_qname = getCid(method).getQname(); if (!method.isAbstract() && (_constructs_qname.contains(method_qname))) { ep.add(new ArgumentTypeEntrypoint(method, cha));
/** * 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)); }
com.sap.psr.vulas.shared.json.model.ConstructId pid = new com.sap.psr.vulas.shared.json.model.ConstructId(ProgrammingLanguage.PY,PythonId.toSharedType(PythonId.typeFromString(type)), qname); if(PythonId.toSharedType(c).equals(pid)){ SignatureFactory sf = CoreConfiguration.getSignatureFactory(pid); sign = (PythonConstructDigest)sf.createSignature(fa.getConstructs().get(c));
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; } }
if(json_cid.getLang().equals(ProgrammingLanguage.JAVA) && !cc.getConstructChangeType().equals(ConstructChangeType.ADD)) { changes_set.add(json_cid);
public void addAttribute(String _key, boolean _value) { this.addAttribute(_key, Boolean.toString(_value)); } public boolean hasAttribute(String _key) {
/** * 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(); }
if(cc.getConstructId().getLang()==ProgrammingLanguage.JAVA) hasJava = true; if ( !isBelowTestDir(cc.getConstructId().getQname()) && !isInTestClass(cc.getConstructId()) && (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)){