Skip to content

Commit

Permalink
#16 Using File instead of IPath in Violation and FileValue
Browse files Browse the repository at this point in the history
Violation and FileValue had both a file attribute which type was IPath.
Changing it into File from java.io.File package imply a lot of little
modifications in files using theses objects.
  • Loading branch information
Omar Waldmann committed May 10, 2017
1 parent 4bc6790 commit 1301aa7
Show file tree
Hide file tree
Showing 400 changed files with 24,712 additions and 24,288 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@

package fr.cnes.analysis.tools.analyzer;

import java.io.File;
import java.util.List;
import java.util.logging.Logger;

Expand All @@ -32,7 +33,7 @@ public abstract class AbstractAnalysisJob extends Job {
/** Extension id for the analyzer to use. **/
private String extensionId;
/** List of files to analyze. **/
private List<IPath> files;
private List<File> files;

/**
* Constructor for this Job with extension id in parameter and files' path.
Expand All @@ -43,7 +44,7 @@ public abstract class AbstractAnalysisJob extends Job {
* list of path for files to analyze
*/
public AbstractAnalysisJob(final String pExtensionId,
final List<IPath> pFiles) {
final List<File> pFiles) {
super("Running analysis...");
this.extensionId = pExtensionId;
this.files = pFiles;
Expand All @@ -63,7 +64,7 @@ public String getExtensionId() {
*
* @return the files
*/
public List<IPath> getFiles() {
public List<File> getFiles() {
return this.files;
}

Expand All @@ -83,7 +84,7 @@ public void setExtensionId(final String pExtensionId) {
* @param pFiles
* the files to set
*/
public void setFiles(final List<IPath> pFiles) {
public void setFiles(final List<File> pFiles) {
this.files = pFiles;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@

package fr.cnes.analysis.tools.analyzer;

import java.io.File;
import java.io.FileNotFoundException;
import java.io.IOException;
import java.util.List;
Expand Down Expand Up @@ -36,7 +37,7 @@ public abstract class AbstractAnalyzer extends Job {
.getLogger(AbstractAnalyzer.class.getName());

/** Files to be analyzed. */
private List<IPath> files;
private List<File> files;
/** the id of rule/metric contribution **/
private String extensionId;

Expand All @@ -46,15 +47,15 @@ public abstract class AbstractAnalyzer extends Job {
*
* @param name
* the name of this Job
* @param pFiles
* @param pFilePath
* the files to analyze
* @param pExtensionId
* the id of rule/metric contribution
*/
public AbstractAnalyzer(final String name, final List<IPath> pFiles,
public AbstractAnalyzer(final String name, final List<File> pFilePath,
final String pExtensionId) {
super(name);
this.files = pFiles;
this.files = pFilePath;
this.extensionId = pExtensionId;
}

Expand All @@ -63,7 +64,7 @@ public AbstractAnalyzer(final String name, final List<IPath> pFiles,
*
* @return the files path.
*/
public List<IPath> getFiles() {
public List<File> getFiles() {
return this.files;
}

Expand All @@ -82,7 +83,7 @@ public String getExtensionId() {
* @param inputFiles
* the files path.
*/
public void setFiles(final List<IPath> inputFiles) {
public void setFiles(final List<File> inputFiles) {
this.files = inputFiles;
}

Expand Down Expand Up @@ -115,7 +116,7 @@ protected IStatus run(final IProgressMonitor monitor) {
.getConfigurationElementsFor(this.extensionId);

// Calculate total work to do
final List<IPath> pFiles = this.getFiles();
final List<File> pFiles = this.getFiles();
int totalEval = 0;
for (final IConfigurationElement contribution : evalContribs) {
if (PlatformUI.getPreferenceStore().getBoolean(
Expand Down Expand Up @@ -211,7 +212,7 @@ protected IStatus run(final IProgressMonitor monitor) {
*/
protected abstract IStatus runEvaluation(
final IConfigurationElement contribution,
final List<IPath> pFiles, final IProgressMonitor monitor)
final List<File> pFiles, final IProgressMonitor monitor)
throws CloneNotSupportedException, CoreException,
IOException, JFlexException;
}
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
*/
package fr.cnes.analysis.tools.analyzer;

import java.io.File;
import java.util.LinkedList;
import java.util.List;
import java.util.logging.Level;
Expand Down Expand Up @@ -36,7 +37,7 @@ public class MetricAnalysisJob extends AbstractAnalysisJob {
* list of path for files to analyze
*/
public MetricAnalysisJob(final String pExtensionId,
final List<IPath> pFiles) {
final List<File> pFiles) {
super(pExtensionId, pFiles);
this.values = new LinkedList<FileValue>();
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
*/
package fr.cnes.analysis.tools.analyzer;

import java.io.File;
import java.io.IOException;
import java.util.LinkedList;
import java.util.List;
Expand Down Expand Up @@ -39,14 +40,14 @@ public class MetricAnalyzer extends AbstractAnalyzer {
*
* @param name
* the name of this Job
* @param pFiles
* @param pFile
* the files to analyze
* @param pExtensionId
* the id of rule/metric contribution
*/
public MetricAnalyzer(final String name, final List<IPath> pFiles,
public MetricAnalyzer(final String name, final List<File> pFile,
final String pExtensionId) {
super(name, pFiles, pExtensionId);
super(name, pFile, pExtensionId);
this.values = new LinkedList<FileValue>();
}

Expand Down Expand Up @@ -91,7 +92,7 @@ public void setValues(final FileValue[] pValues) {
*/
@Override
protected IStatus runEvaluation(final IConfigurationElement contribution,
final List<IPath> pFiles, final IProgressMonitor monitor)
final List<File> pFiles, final IProgressMonitor monitor)
throws CloneNotSupportedException, CoreException,
IOException, JFlexException {
LOGGER.finest("Begin runEvaluation method");
Expand All @@ -100,18 +101,17 @@ protected IStatus runEvaluation(final IConfigurationElement contribution,
IStatus status = Status.OK_STATUS;

// Run analysis on all files
for (final IPath file : pFiles) {

for (final File file : pFiles) {
// Get the evaluation
final AbstractMetric metric =
(AbstractMetric) contribution
.createExecutableExtension("class");
metric.setContribution(contribution);

// Run the evaluation
LOGGER.finest("File : " + file.toFile().getName());
LOGGER.finest("File : " + file.getName());
monitor.subTask("Analyzing " + contribution.getAttribute("id")
+ " on file " + file.toFile().getName());
+ " on file " + file.getName());
this.values.add(this.runMetricOnFile(metric, file));
monitor.worked(1);

Expand Down Expand Up @@ -140,7 +140,7 @@ protected IStatus runEvaluation(final IConfigurationElement contribution,
* JFlex analysis error
*/
private FileValue runMetricOnFile(final AbstractMetric metric,
final IPath file) throws IOException,
final File file) throws IOException,
JFlexException {
LOGGER.finest("Begin runEvaluationOnFile method");

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
*/
package fr.cnes.analysis.tools.analyzer;

import java.io.File;
import java.util.LinkedList;
import java.util.List;
import java.util.logging.Level;
Expand Down Expand Up @@ -35,7 +36,7 @@ public class RuleAnalysisJob extends AbstractAnalysisJob {
* @param pFiles
* list of path for files to analyze
*/
public RuleAnalysisJob(final String pExtensionId, final List<IPath> pFiles) {
public RuleAnalysisJob(final String pExtensionId, final List<File> pFiles) {
super(pExtensionId, pFiles);
this.violations = new LinkedList<Violation>();
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
*/
package fr.cnes.analysis.tools.analyzer;

import java.io.File;
import java.io.IOException;
import java.util.LinkedList;
import java.util.List;
Expand Down Expand Up @@ -39,14 +40,14 @@ public class RuleAnalyzer extends AbstractAnalyzer {
*
* @param name
* the name of this Job
* @param pFiles
* @param list
* the files to analyze
* @param pExtensionId
* the id of rule/metric contribution
*/
public RuleAnalyzer(final String name, final List<IPath> pFiles,
public RuleAnalyzer(final String name, final List<File> list,
final String pExtensionId) {
super(name, pFiles, pExtensionId);
super(name, list, pExtensionId);
this.violations = new LinkedList<Violation>();
}

Expand Down Expand Up @@ -92,7 +93,7 @@ public void setDescriptors(final Violation[] pViolations) {
*/
@Override
protected IStatus runEvaluation(final IConfigurationElement contribution,
final List<IPath> pFiles, final IProgressMonitor monitor)
final List<File> pFiles, final IProgressMonitor monitor)
throws CloneNotSupportedException, CoreException, IOException,
JFlexException {
LOGGER.finest("Begin runEvaluation method");
Expand All @@ -101,17 +102,17 @@ protected IStatus runEvaluation(final IConfigurationElement contribution,
IStatus status = Status.OK_STATUS;

// Run analysis on all files
for (final IPath file : pFiles) {
for (final File file : pFiles) {

// Get the evaluation
final AbstractRule rule = (AbstractRule) contribution
.createExecutableExtension("class");
rule.setContribution(contribution);

// Run the evaluation
LOGGER.finest("File : " + file.toFile().getName());
LOGGER.finest("File : " + file.getName());
monitor.subTask("Analyzing " + contribution.getAttribute("id")
+ " on file " + file.toFile().getName());
+ " on file " + file.getName());
this.violations.addAll(this.runRuleOnFile(rule, file));
monitor.worked(1);

Expand Down Expand Up @@ -140,7 +141,7 @@ protected IStatus runEvaluation(final IConfigurationElement contribution,
* JFlex analysis error
*/
private List<Violation> runRuleOnFile(final AbstractRule rule,
final IPath file) throws IOException, JFlexException {
final File file) throws IOException, JFlexException {
LOGGER.finest("Begin runRuleOnFile method");

// Initializing file reader in the metric
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,10 +6,10 @@
*/
package fr.cnes.analysis.tools.analyzer.datas;

import java.io.File;
import java.io.FileNotFoundException;

import org.eclipse.core.runtime.IConfigurationElement;
import org.eclipse.core.runtime.IPath;

/**
* Abstract class implementing the generic application of a rule or metric over
Expand Down Expand Up @@ -48,5 +48,5 @@ public void setContribution(final IConfigurationElement pContribution) {
* @throws FileNotFoundException
* exception thrown when a file is not found
*/
public abstract void setInputFile(IPath file) throws FileNotFoundException;
public abstract void setInputFile(File file) throws FileNotFoundException;
}
Original file line number Diff line number Diff line change
Expand Up @@ -6,12 +6,14 @@
*/
package fr.cnes.analysis.tools.analyzer.datas;

import java.io.File;
import java.io.FileNotFoundException;
import java.io.IOException;
import java.util.LinkedList;
import java.util.List;

import org.eclipse.core.runtime.IPath;
import org.eclipse.core.runtime.Path;

import fr.cnes.analysis.tools.analyzer.exception.JFlexException;

Expand Down Expand Up @@ -108,7 +110,7 @@ protected void setError(final String pLocation, final String pMessage, final int
* (org.eclipse.core.runtime.IPath)
*/
@Override
public void setInputFile(final IPath file) throws FileNotFoundException {
public void setInputFile(final File file) throws FileNotFoundException {
this.violations = new LinkedList<Violation>();
this.violation =
new Violation(this.getContribution().getAttribute("name"),
Expand Down
Loading

0 comments on commit 1301aa7

Please sign in to comment.