/** * 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); }
/** * 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(); this.fileAnalyzer = FileAnalyzerFactory.buildFileAnalyzer(this.eggFile.toFile()); this.constructs = this.fileAnalyzer.getConstructs(); log.info("Got [" + this.constructs.size() + "] constructs from egg [" + this.eggFile + "]"); this.fileAnalyzer = FileAnalyzerFactory.buildFileAnalyzer(this.pyFile.toFile()); this.constructs = this.fileAnalyzer.getConstructs(); log.info("Got [" + this.constructs.size() + "] constructs from file [" + this.pyFile + "]"); this.fileAnalyzer = FileAnalyzerFactory.buildFileAnalyzer(this.pyDir.toFile()); this.constructs = this.fileAnalyzer.getConstructs(); log.info("Got [" + this.constructs.size() + "] constructs from directory [" + this.pyDir + "]");
if(file.exists()) { log.info("Exists already: Entry [" + _entry + "] corresponds to [" + file.toPath().toAbsolutePath() + "]"); fa = FileAnalyzerFactory.buildFileAnalyzer(file); } else { fos.flush(); log.info("Extracted entry [" + _entry + "] to [" + file.toPath().toAbsolutePath() + "]"); fa = FileAnalyzerFactory.buildFileAnalyzer(file);
count_ext.put(ext, Integer.valueOf(curr+1)); fa = FileAnalyzerFactory.buildFileAnalyzer(file.toFile()); if(fa!=null) this.analyzers.add(fa);
FileAnalyzer jfa = FileAnalyzerFactory.buildFileAnalyzer(file.toFile()); if(jfa.containsConstruct(jid)) {
final FileAnalyzer fa = FileAnalyzerFactory.buildFileAnalyzer(_java_file); final FileAnalyzer fa = FileAnalyzerFactory.buildFileAnalyzer(java_source_file);
FileAnalyzer jfa = FileAnalyzerFactory.buildFileAnalyzer(file.toFile()); if(jfa.containsConstruct(jid)) {
@Override public Signature createSignature(ConstructId _cid, File _file) { if(!_cid.getLang().equals(ProgrammingLanguage.PY)) throw new IllegalArgumentException("Programming language [" + _cid.getLang() + "] not supported"); Signature signature = null; // Compute signature from the entire file if(_cid.getType().equals(ConstructType.MODU)) { signature = new PythonConstructDigest(_file.toPath(), DigestAlgorithm.SHA1); } // For all others, parse the file, and compute the digest for the construct body else { try { final Python3FileAnalyzer fa = (Python3FileAnalyzer)FileAnalyzerFactory.buildFileAnalyzer(_file, new String[] { "py" }); final Construct c = fa.getConstruct(_cid); if(c==null) { throw new IllegalStateException("Construct [" + _cid +"] cannot be found in file [" + _file + "]"); } else { signature = new PythonConstructDigest(c.getContent(), DigestAlgorithm.SHA1); } } catch (IllegalArgumentException e) { log.error(e); } catch (FileAnalysisException e) { log.error(e); } } return signature; }
final FileAnalyzer da = FileAnalyzerFactory.buildFileAnalyzer(p.toFile(), EXT_FILTER); app_constructs.addAll(da.getConstructs().keySet());
for(Path p: this.getSearchPath()) { log.info("Searching for Java constructs in search path [" + p + "] with filter [" + StringUtil.join(EXT_FILTER, ", ") + "] ..."); final FileAnalyzer fa = FileAnalyzerFactory.buildFileAnalyzer(p.toFile(), EXT_FILTER);