use of com.kyj.fx.voeditor.visual.framework.pmd.GargoylePMDParameters in project Gargoyle by callakrsos.
the class PMDCheckComposite method simpleFilePmd.
private void simpleFilePmd(File file) {
try {
String sourceCode = Files.toString(this.sourceFile, Charset.forName("UTF-8"));
javaTextArea.setContent(sourceCode);
GargoylePMDParameters params = new GargoylePMDParameters();
params.setSourceFileName(file.getAbsolutePath());
params.setSourceText(sourceCode);
// transformParametersIntoConfiguration(params);
long start = System.nanoTime();
int violations = doPMD.doPMD(transformParametersIntoConfiguration(params));
long end = System.nanoTime();
Benchmarker.mark(Benchmark.TotalPMD, end - start, 0);
TextReport report = new TextReport();
try (ByteArrayOutputStream out = new ByteArrayOutputStream()) {
report.generate(Benchmarker.values(), new PrintStream(out));
out.flush();
LOGGER.debug(out.toString("UTF-8"));
}
Platform.runLater(() -> {
xmlEditor.setContent(doPMD.getResultString());
violationLabel.setText(String.format(VIOLATION_TEXT_FORMAT, violations));
});
} catch (IOException e) {
LOGGER.error(ValueUtil.toString(e));
}
}
use of com.kyj.fx.voeditor.visual.framework.pmd.GargoylePMDParameters in project Gargoyle by callakrsos.
the class PMDCheckComposite method dirFilePmd.
private void dirFilePmd(File file) {
try {
// String sourceCode = Files.toString(this.sourceFile, Charset.forName("UTF-8"));
// javaTextArea.setContent(sourceCode);
GargoylePMDParameters params = new GargoylePMDParameters();
try {
Field declaredField = GargoylePMDParameters.class.getDeclaredField("sourceDir");
if (declaredField != null) {
declaredField.setAccessible(true);
declaredField.set(params, file.getAbsolutePath());
}
} catch (Exception e) {
e.printStackTrace();
}
// transformParametersIntoConfiguration(params);
long start = System.nanoTime();
int violations = doPMD.doPMD(transformParametersIntoConfiguration(params));
long end = System.nanoTime();
Benchmarker.mark(Benchmark.TotalPMD, end - start, 0);
TextReport report = new TextReport();
try (ByteArrayOutputStream out = new ByteArrayOutputStream()) {
report.generate(Benchmarker.values(), new PrintStream(out));
out.flush();
LOGGER.debug(out.toString("UTF-8"));
}
Platform.runLater(() -> {
xmlEditor.setContent(doPMD.getResultString());
violationLabel.setText(String.format(VIOLATION_TEXT_FORMAT, violations));
});
} catch (IOException e) {
LOGGER.error(ValueUtil.toString(e));
}
}
use of com.kyj.fx.voeditor.visual.framework.pmd.GargoylePMDParameters in project Gargoyle by callakrsos.
the class PMDCheckedListComposite method dirFilePmd.
protected void dirFilePmd(File file) {
try {
GargoylePMDParameters params = new GargoylePMDParameters();
try {
Field declaredField = GargoylePMDParameters.class.getDeclaredField("sourceDir");
if (declaredField != null) {
declaredField.setAccessible(true);
declaredField.set(params, file.getAbsolutePath());
}
} catch (Exception e) {
LOGGER.error(ValueUtil.toString(e));
}
long start = System.nanoTime();
List<ReportListener> listeners = new ArrayList<>();
listeners.addAll(chartComposite.getAvalilableReportListenerList());
listeners.add(reportListenerProperty.get());
listeners.add(violationCountingListener.get());
doPMD.doPMD(transformParametersIntoConfiguration(params), listeners);
long end = System.nanoTime();
Benchmarker.mark(Benchmark.TotalPMD, end - start, 0);
TextReport report = new TextReport();
try (ByteArrayOutputStream out = new ByteArrayOutputStream()) {
report.generate(Benchmarker.values(), new PrintStream(out));
out.flush();
LOGGER.debug(out.toString("UTF-8"));
}
Platform.runLater(() -> {
updateViolationLabel();
chartComposite.build();
});
} catch (IOException e) {
LOGGER.error(ValueUtil.toString(e));
}
}
use of com.kyj.fx.voeditor.visual.framework.pmd.GargoylePMDParameters in project Gargoyle by callakrsos.
the class JavaCodeAreaHelper method doPmd.
/**
* PMD 처리
* @작성자 : KYJ
* @작성일 : 2016. 10. 12.
*/
private void doPmd() {
PMDCheckedListComposite pmdCheckedListComposite = new PMDCheckedListComposite(null) {
@Override
public void run() {
simpleFilePmd(null);
}
@Override
protected void simpleFilePmd(File file) {
try {
GargoylePMDParameters params = new GargoylePMDParameters();
String sourceCode = codeArea.getText();
params.setSourceFileName("Java");
params.setSourceText(sourceCode);
// if (!FileUtil.isJavaFile(file)) {
// String fileExtension = FileUtil.getFileExtension(file);
// try {
// Field declaredField = PMDParameters.class.getDeclaredField("language");
// if (declaredField != null) {
// declaredField.setAccessible(true);
// declaredField.set(params, fileExtension);
// }
// } catch (Exception e) {
// e.printStackTrace();
// }
// }
// transformParametersIntoConfiguration(params);
long start = System.nanoTime();
doPMD.doPMD(transformParametersIntoConfiguration(params), reportListenerPropertyProperty().get(), violationCountingListenerProperty().get());
long end = System.nanoTime();
Benchmarker.mark(Benchmark.TotalPMD, end - start, 0);
TextReport report = new TextReport();
try (ByteArrayOutputStream out = new ByteArrayOutputStream()) {
report.generate(Benchmarker.values(), new PrintStream(out));
out.flush();
LOGGER.debug(out.toString("UTF-8"));
}
updateStatus(sourceCode);
} catch (IOException e) {
LOGGER.error(ValueUtil.toString(e));
}
}
};
pmdCheckedListComposite.run();
CloseableParent<BorderPane> closa = pmdCheckedListComposite;
Consumer<Stage> option = stage -> {
stage.setTitle("PMD Check.");
stage.initOwner(SharedMemory.getPrimaryStage());
stage.setWidth(1200d);
stage.setHeight(800d);
};
FxUtil.createStageAndShow(closa, option);
}
use of com.kyj.fx.voeditor.visual.framework.pmd.GargoylePMDParameters in project Gargoyle by callakrsos.
the class PMDCheckedListComposite method simpleFilePmd.
/**
* 파일 1개를 대상으로 PMD 체크하기 위한 처리.
*
* @작성자 : KYJ
* @작성일 : 2016. 10. 13.
* @param file
*/
protected void simpleFilePmd(File file) {
try {
String sourceCode = Files.toString(this.sourceFile, Charset.forName("UTF-8"));
GargoylePMDParameters params = new GargoylePMDParameters();
params.setSourceFileName(file.getAbsolutePath());
params.setSourceText(sourceCode);
if (!FileUtil.isJavaFile(file)) {
String fileExtension = FileUtil.getFileExtension(file);
try {
Field declaredField = GargoylePMDParameters.class.getDeclaredField("language");
if (declaredField != null) {
declaredField.setAccessible(true);
declaredField.set(params, fileExtension);
}
} catch (Exception e) {
e.printStackTrace();
}
}
// transformParametersIntoConfiguration(params);
long start = System.nanoTime();
doPMD.doPMD(transformParametersIntoConfiguration(params), reportListenerProperty.get(), violationCountingListener.get());
long end = System.nanoTime();
Benchmarker.mark(Benchmark.TotalPMD, end - start, 0);
TextReport report = new TextReport();
try (ByteArrayOutputStream out = new ByteArrayOutputStream()) {
report.generate(Benchmarker.values(), new PrintStream(out));
out.flush();
LOGGER.debug(out.toString("UTF-8"));
}
updateStatus(sourceCode);
} catch (IOException e) {
LOGGER.error(ValueUtil.toString(e));
}
}
Aggregations