/** * Merges the constructs of the map into a single set. Returns a TreeSet if _ordered is equal to true, a HashSet otherwise. * @param _map * @return a single set containing all the constructs passed in _map */ public static final Set<ConstructId> merge(Map<String, Set<com.sap.psr.vulas.shared.json.model.ConstructId>> _map, boolean _ordered) { final Set<ConstructId> set = ( _ordered ? new TreeSet<ConstructId>() : new HashSet<ConstructId>() ); for(Object key: _map.keySet()) { for(com.sap.psr.vulas.shared.json.model.ConstructId cid: _map.get(key)) { set.add(JavaId.toCoreType(cid)); } } return set; } }
/** * Returns true if the construct is part of the archive, false otherwise. * @return */ private boolean isConstructInArchive() { return this.ja.getConstructIds().contains(JavaId.toCoreType(this.constructId)); }
private boolean isTestConstruct(ConstructId _cid) { com.sap.psr.vulas.ConstructId c = JavaId.toCoreType(_cid); return c instanceof JavaMethodId && ((JavaMethodId)c).isTestMethod(); }
private synchronized URL collectArchiveInformation(com.sap.psr.vulas.shared.json.model.ConstructId tgt_node) { URL url = null; final JavaId jid = ((JavaId)JavaId.toCoreType(tgt_node)).getCompilationUnit(); // We should always have a Java ID, since packages are not part of the callgraph if(jid!=null) { // Not in cache -> put in cache if(!this.cachedJarUrls.containsKey(jid)) { url = jid.getJarUrl(); this.cachedJarUrls.put(jid, url); // Warn if we do not find a URL if(url==null) constructsWithoutJarUrl.add(tgt_node); } // Read from cache url = this.cachedJarUrls.get(jid); } return url; }
/** * 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()); }
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; }
private ConstructIdUtil() { try { final Set<com.sap.psr.vulas.shared.json.model.ConstructId> app_constructs = BackendConnector.getInstance().getAppConstructIds(CoreConfiguration.buildGoalContextFromGlobalConfiguration(), CoreConfiguration.getAppContext()); this.appConstructs = new HashSet<ConstructId>(); for(com.sap.psr.vulas.shared.json.model.ConstructId cid: app_constructs) { this.appConstructs.add(JavaId.toCoreType(cid)); } } catch (ConfigurationException e) { ConstructIdUtil.getLog().error(e.getMessage(), e); } catch (BackendConnectionException e) { ConstructIdUtil.getLog().error(e.getMessage(), e); } }
/** * Returns true if the signature creation is supported for the given {@link ConstructId}. This depends * on whether the ID's definition context can be obtained, and whether the latter is a nested class. * @param _cid */ static final boolean isSupported(ConstructId _cid, boolean _throw_exception) throws IllegalArgumentException { boolean supported = true; // Get and check the definition context of the construct whose signature we're about to create final JavaClassId class_id = (JavaClassId)JavaId.toCoreType(_cid).getDefinitionContext(); // Cannot get the def context if(class_id==null) { supported = false; if(_throw_exception) throw new IllegalArgumentException("No definition context for construct [" + _cid.getQname() + "]"); } // Nested class else if(class_id.isNestedClass()) { supported = false; JavaSignatureFactory.log.error("Nested classes are not yet supported, cannot create signature for [" + _cid.getQname() + "]"); if(_throw_exception) throw new IllegalArgumentException("Nested classes are not yet supported, cannot create signature for [" + _cid.getQname() + "]"); } return supported; }
final Construct c = fa.getConstruct(JavaId.toCoreType(_cid)); final Construct c = fa.getConstruct(JavaId.toCoreType(_cid));
final JavaClassId class_id = (JavaClassId)(JavaId.toCoreType(_cid)).getDefinitionContext();
final JavaId jcid = (JavaId) JavaId.toCoreType(cid); if (jcid instanceof com.sap.psr.vulas.java.JavaConstructorId || jcid instanceof com.sap.psr.vulas.java.JavaMethodId) { _constructs_qname.add(cid.getQname());
String className = JavaId.toCoreType(constructId).getDefinitionContext().getName();
final JavaId target_jid = (JavaId)JavaId.toCoreType(target); final JavaId comp_unit = target_jid.getCompilationUnit(); final boolean is_nested_class = comp_unit instanceof JavaClassId && ((JavaClassId)comp_unit).isNestedClass();