@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(); }
/** * Returns the union of constructs of all {@link FileAnalyzer}s created when searching recursivly in the directory. */ @Override public Map<ConstructId, Construct> getConstructs() throws FileAnalysisException { if(this.constructs==null) { this.constructs = new TreeMap<ConstructId, Construct>(); for(FileAnalyzer fa: this.analyzers) { try { this.constructs.putAll(fa.getConstructs()); } catch(RuntimeException e) { DirAnalyzer.log.error("Error getting constructs from [" + fa + "]: " + e, e); } } DirAnalyzer.log.info("Constructs found: [" + this.constructs.size() + "]"); } return this.constructs; }
/** * Potential refactoring: Delete constructor (or make private), see proposal of prev. constructor. * @param _def * @param _fix * @param _rev * @param _repo_path * @throws IOException */ public FileComparator(File _def, File _fix, String _rev, String _repo, String _repo_path, String _time_stamp) throws IOException, FileAnalysisException { if(_def==null && _fix==null) throw new IllegalArgumentException("The comparator requires at least one file as input, either the defective file, the fixed file or both"); this.revision = _rev; this.repo = _repo; this.repoPath = _repo_path; this.timeStamp = _time_stamp; if(_def!=null) { this.def = _def; this.defAnalyzer = FileAnalyzerFactory.buildFileAnalyzer(_def); this.defAnalyzer.getConstructs(); } if(_fix!=null) { this.fix = _fix; this.fixAnalyzer = FileAnalyzerFactory.buildFileAnalyzer(_fix); this.fixAnalyzer.getConstructs(); } }
/** * Identifies all programming constructs of a given revision number. * @param _revision * @return * @throws Exception */ public Map<ConstructId,Construct> identifySourceConstructs(String _rev) throws Exception { if(!(this.sourceRev.equals(_rev)) || this.sourceConstructs==null) { // The revision for which the sources are analyzed this.sourceRev = _rev; // Check out the entire SVN final Path p = this.vcs.checkout(_rev); // Instantiate SrcAnalyzer (using the dir to which the checkout happened) to crawl all files this.sourceConstructs = FileAnalyzerFactory.buildFileAnalyzer(p.toFile()); } return this.sourceConstructs.getConstructs(); }
this.fileAnalyzer = FileAnalyzerFactory.buildFileAnalyzer(this.downloadPath.toFile()); if(this.fileAnalyzer!=null) { this.constructs = this.fileAnalyzer.getConstructs(); log.info("Got [" + this.constructs.size() + "] constructs from downloaded file [" + this.downloadPath + "]"); if(this.eggFile!=null) { this.fileAnalyzer = FileAnalyzerFactory.buildFileAnalyzer(this.eggFile.toFile()); this.constructs = this.fileAnalyzer.getConstructs(); log.info("Got [" + this.constructs.size() + "] constructs from egg [" + this.eggFile + "]"); this.constructs = this.fileAnalyzer.getConstructs(); log.info("Got [" + this.constructs.size() + "] constructs from file [" + this.pyFile + "]"); this.constructs = this.fileAnalyzer.getConstructs(); log.info("Got [" + this.constructs.size() + "] constructs from directory [" + this.pyDir + "]");
final Set<com.sap.psr.vulas.ConstructId> constructs_in = fa.getConstructs().keySet(); final Set<com.sap.psr.vulas.shared.json.model.ConstructId> constructs_out = new TreeSet<ConstructId>(); for(com.sap.psr.vulas.ConstructId c: constructs_in) {
final Set<com.sap.psr.vulas.ConstructId> constructs_in = fa.getConstructs().keySet(); for (com.sap.psr.vulas.ConstructId c : constructs_in){ String aaa = c.getQualifiedName(); sign = (PythonConstructDigest)sf.createSignature(fa.getConstructs().get(c)); break;
log.info("Searching for Python constructs in search path [" + p + "] with filter [" + StringUtil.join(EXT_FILTER, ", ") + "]"); final FileAnalyzer da = FileAnalyzerFactory.buildFileAnalyzer(p.toFile(), EXT_FILTER); app_constructs.addAll(da.getConstructs().keySet());
@Override public FileAnalyzer fetch(Artifact _key) throws CacheException { // The artifact whose JAR is to be downloaded _key.setClassifier(null); RepositoryDispatcher r = new RepositoryDispatcher(); Path file = null; try { file = r.downloadArtifact(_key); } catch (IllegalArgumentException ie) { throw new CacheException("Artifact [" + _key + "] not ready for download",ie); } catch (Exception e) { throw new CacheException("Cannot download ["+ _key + "]",e); } FileAnalyzer fa = new JarAnalyzer(); try{ if (fa.canAnalyze(file.toFile())) { fa.analyze(file.toFile()); } else { fa = new PythonArchiveAnalyzer(); fa.analyze(file.toFile()); fa.getConstructs(); } }catch (FileAnalysisException fe){ throw new CacheException("Cannot Analyze file ["+ file.toString() + "]",fe); } return fa; }
for (ConstructId key : this.defAnalyzer.getConstructs().keySet()) { if(this.fixAnalyzer!=null && this.fixAnalyzer.containsConstruct(key)) { if(!this.defAnalyzer.getConstruct(key).equals(this.fixAnalyzer.getConstruct(key))) { for (ConstructId key : this.fixAnalyzer.getConstructs().keySet()) { if(this.defAnalyzer!=null && this.defAnalyzer.containsConstruct(key)) { if(!this.fixAnalyzer.getConstruct(key).equals(this.defAnalyzer.getConstruct(key))) {
final Set<ConstructId> constructs = JavaId.filter(fa2.getConstructs().keySet(), this.appPrefixes); if(constructs.size()==fa2.getConstructs().size()) { log.info(StringUtil.padLeft(++count, 4) + " [" + StringUtil.padLeft(ja.getFileName(), 30) + "]: All [" + fa2.getConstructs().size() + "] constructs matched prefix(es): Constructs added to application, file NOT added as dependency"); log.info(StringUtil.padLeft(++count, 4) + " [" + StringUtil.padLeft(ja.getFileName(), 30) + "]: [" + constructs.size() + "/" + fa2.getConstructs().size() + "] constructs matched prefix(es): Constructs added to application, file added as dependency"); dep_files.put(ja.getPath(), ja); log.info(StringUtil.padLeft(++count, 4) + " [" + StringUtil.padLeft(ja.getFileName(), 30) + "]: None of the [" + fa2.getConstructs().size() + "] constructs matched prefix(es): No constructs added to application, file added as dependency"); dep_files.put(ja.getPath(), ja); log.info(StringUtil.padLeft(++count, 4) + " [" + StringUtil.padLeft(ja.getFileName(), 30) + "]: Filename matches pattern(s), all of its [" + fa2.getConstructs().size() + "] constructs added to application"); app_constructs.addAll(fa2.getConstructs().keySet()); app_constructs.addAll(fa2.getConstructs().keySet()); app_constructs.addAll(fa.getConstructs().keySet()); } catch (FileAnalysisException e) { log.error(e.getMessage(), e);