use of org.eclipse.titanium.markers.handler.Marker in project titan.EclipsePlug-ins by eclipse.
the class SingleCsvProblemExporter method exportMarkers.
/**
* @param monitor : The monitor that we use for feedback
* @param path : The path of the file to be saved
* @param date : The time stamp (not used currently)
*
* @see BaseProblemExporter#exportMarkers(IProgressMonitor, String, Date)
*/
@Override
public void exportMarkers(final IProgressMonitor monitor, final String path, final Date date) {
final SubMonitor progress = SubMonitor.convert(monitor, 100);
BufferedWriter summaryFile = null;
try {
summaryFile = new BufferedWriter(new OutputStreamWriter(new FileOutputStream(new File(path)), "UTF-8"));
final MarkerHandler mh = AnalyzerCache.withAll().analyzeProject(progress.newChild(30), project);
for (final Map.Entry<IResource, List<Marker>> entry : mh.getMarkersByResource().entrySet()) {
final IResource resource = entry.getKey();
for (final Marker marker : entry.getValue()) {
summaryFile.write(resource.getProjectRelativePath().toString());
summaryFile.write(SEPARATOR);
summaryFile.write(String.valueOf(marker.getLine()));
summaryFile.write(SEPARATOR);
summaryFile.write(marker.getProblemType().name());
summaryFile.write(SEPARATOR);
summaryFile.write(SEPARATOR);
summaryFile.write(SEPARATOR);
summaryFile.newLine();
}
}
} catch (IOException e) {
ErrorReporter.logExceptionStackTrace("Error while exporting to CSV file: " + path, e);
} finally {
if (summaryFile != null) {
try {
summaryFile.close();
} catch (IOException e) {
ErrorReporter.logExceptionStackTrace("Error while closing the file: " + path, e);
}
}
}
}
use of org.eclipse.titanium.markers.handler.Marker in project titan.EclipsePlug-ins by eclipse.
the class XlsProblemExporter method createCodeSmellSheet.
/**
* Create a page for a code smell.
*
* @param workbook the workbook to work in.
* @param mh the markerhandler object knowing the occurences of the given code smell
* @param t the codesmell type to export
* @param fullPath the resource names should use full path or project relative
*/
private void createCodeSmellSheet(final HSSFWorkbook workbook, final MarkerHandler mh, final CodeSmellType t, final boolean fullPath) {
if (mh.get(t).isEmpty()) {
return;
}
final String sheetName = t.name();
final HSSFSheet sheet = workbook.createSheet(sheetName);
Row row = sheet.createRow(0);
row.createCell(0).setCellValue("Description");
row.createCell(1).setCellValue("Resource");
row.createCell(2).setCellValue("Location");
int currentRow = 1;
Cell label;
for (final Marker m : mh.get(t)) {
if (m.getLine() == -1 || m.getResource() == null) {
// TODO this might need a second thought
continue;
}
try {
row = sheet.createRow(currentRow);
label = row.createCell(0);
label.setCellValue(m.getMessage());
label = row.createCell(1);
if (fullPath) {
label.setCellValue(m.getResource().getFullPath().toString());
} else {
label.setCellValue(m.getResource().getName());
}
label = row.createCell(2);
label.setCellValue(m.getLine());
++currentRow;
} catch (Exception e) {
ErrorReporter.logWarning("Only " + currentRow + " rows were written: the limit has been reached.");
break;
}
}
sheet.autoSizeColumn(0);
sheet.autoSizeColumn(1);
sheet.autoSizeColumn(2);
}
Aggregations