use of de.dagere.peass.dependency.analysis.data.ChangedEntity in project peass by DaGeRe.
the class SourceWriter method readMethod.
private void readMethod(final GraphNode node, final String currentPattern) throws IOException {
ChangedEntity methodEntity = getChangedEntity(node, currentPattern);
final String key = KiekerPatternConverter.getKey(currentPattern);
final File currentSourceFile = MethodChangeReader.getMethodMainFile(methodSourceFolder, version, methodEntity);
final File oldSourceFile = MethodChangeReader.getMethodOldFile(methodSourceFolder, version, methodEntity);
if (currentSourceFile.exists() && oldSourceFile.exists()) {
node.setHasSourceChange(true);
final String sourceCurrent = FileUtils.readFileToString(currentSourceFile, Charset.defaultCharset());
nameSourceCurrent.put(key, sourceCurrent);
final String sourceOld = FileUtils.readFileToString(oldSourceFile, Charset.defaultCharset());
nameSourceOld.put(key, sourceOld);
} else {
final File diffSourceFile = MethodChangeReader.getMethodDiffFile(methodSourceFolder, version, methodEntity);
if (diffSourceFile.exists()) {
final String source = FileUtils.readFileToString(diffSourceFile, Charset.defaultCharset());
nameSourceCurrent.put(key, source);
nameSourceOld.put(key, source);
} else {
LOG.warn("Did not find file: {}", diffSourceFile);
}
}
}
use of de.dagere.peass.dependency.analysis.data.ChangedEntity in project peass by DaGeRe.
the class SourceWriter method getChangedEntity.
private ChangedEntity getChangedEntity(final GraphNode node, final String currentPattern) {
int openingParenthesis = currentPattern.lastIndexOf('(');
final String call = currentPattern.substring(currentPattern.lastIndexOf(' ') + 1, openingParenthesis);
final int dotIndex = call.lastIndexOf(".");
String method = call.substring(dotIndex + 1);
String clazz = call.substring(0, dotIndex);
ChangedEntity methodEntity = new ChangedEntity(clazz, node.getModule(), method);
final String parameterString = currentPattern.substring(openingParenthesis + 1, currentPattern.length() - 1);
methodEntity.createParameters(parameterString);
return methodEntity;
}
use of de.dagere.peass.dependency.analysis.data.ChangedEntity in project peass by DaGeRe.
the class ChangeManager method compareFiles.
private void compareFiles(final Map<ChangedEntity, ClazzChangeData> changedClassesMethods, final Iterator<ChangedEntity> clazzIterator, final ChangedEntity clazz, final ClazzChangeData changeData, final File newFile, final File oldFile) throws ParseException, IOException {
FileComparisonUtil.getChangedMethods(newFile, oldFile, changeData);
boolean isImportChange = false;
ClazzFileFinder finder = new ClazzFileFinder(config);
for (ChangedEntity entity : changeData.getImportChanges()) {
final File entityFile = finder.getSourceFile(folders.getProjectFolder(), entity);
if (entityFile != null && entityFile.exists()) {
isImportChange = true;
changeData.setChange(true);
changeData.setOnlyMethodChange(false);
changeData.addClazzChange(clazz);
}
}
if (!changeData.isChange() && !isImportChange) {
clazzIterator.remove();
LOG.debug("Dateien gleich: {}", clazz);
} else {
changedClassesMethods.put(clazz, changeData);
}
}
use of de.dagere.peass.dependency.analysis.data.ChangedEntity in project peass by DaGeRe.
the class ClazzFileFinder method getSourceFile.
public File getSourceFile(final File folder, final ChangedEntity clazz) {
final ChangedEntity sourceContainingClazz = clazz.getSourceContainingClazz();
File moduleFolder;
if (sourceContainingClazz.getModule().length() > 0) {
moduleFolder = new File(folder, sourceContainingClazz.getModule());
LOG.debug("Module: {}", sourceContainingClazz.getModule());
} else {
moduleFolder = folder;
}
return getClazzFile(moduleFolder, sourceContainingClazz);
}
use of de.dagere.peass.dependency.analysis.data.ChangedEntity in project peass by DaGeRe.
the class PropertyReadHelper method getChanges.
private Map<ChangedEntity, ClazzChangeData> getChanges(final PeassFolders folders) {
GitCommit firstCommit = new GitCommit(versionOld, null, null, null);
List<GitCommit> commits = Arrays.asList(new GitCommit[] { new GitCommit(version, null, null, null), firstCommit });
final VersionIteratorGit iterator = new VersionIteratorGit(projectFolder, commits, firstCommit);
final ChangeManager changeManager = new ChangeManager(folders, iterator, config, testExecutor);
final Map<ChangedEntity, ClazzChangeData> changes = changeManager.getChanges(versionOld, version);
return changes;
}
Aggregations