use of meghanada.analyze.CompileResult in project meghanada-server by mopemope.
the class GradleProjectTest method testCompile01.
@Test
public void testCompile01() throws Exception {
final CompileResult compileResult = timeIt(() -> {
project.parseProject();
return this.project.compileJava();
});
log.info("compile message {}", compileResult.getDiagnosticsSummary());
assertTrue(compileResult.isSuccess());
Thread.sleep(3000);
}
use of meghanada.analyze.CompileResult in project meghanada-server by mopemope.
the class CacheEventSubscriber method analyze.
private void analyze() {
final Stopwatch stopwatch = Stopwatch.createStarted();
final Session session = super.sessionEventBus.getSession();
final Project project = session.getCurrentProject();
final CachedASMReflector reflector = CachedASMReflector.getInstance();
reflector.addClasspath(project.getOutput());
reflector.addClasspath(project.getTestOutput());
project.getDependencies().stream().filter(pd -> pd.getType().equals(ProjectDependency.Type.PROJECT)).forEach(pd -> {
final File df = new File(pd.getDependencyFilePath());
if (df.exists() && df.isDirectory()) {
reflector.addClasspath(df);
}
});
final Collection<File> dependentJars = session.getDependentJars();
final int size = dependentJars.size();
timeItF("create class index ... read " + size + " jars. elapsed:{}", () -> {
reflector.addClasspath(dependentJars);
reflector.createClassIndexes();
});
if (cleanUnusedSource(project)) {
project.resetCallerMap();
}
log.info("start analyze sources ...");
timeItF("analyzed and compiled. elapsed:{}", () -> {
try {
final CompileResult compileResult = project.compileJava();
if (compileResult.isSuccess()) {
if (compileResult.hasDiagnostics()) {
log.warn("compile message: {}", compileResult.getDiagnosticsSummary());
}
final CompileResult testCompileResult = project.compileTestJava();
if (testCompileResult.isSuccess()) {
if (testCompileResult.hasDiagnostics()) {
log.warn("compile(test) message: {}", testCompileResult.getDiagnosticsSummary());
}
} else {
log.warn("compile(test) error: {}", testCompileResult.getDiagnosticsSummary());
}
} else {
log.warn("compile message {}", compileResult.getDiagnosticsSummary());
}
} catch (Exception e) {
log.catching(e);
}
});
final Runtime runtime = Runtime.getRuntime();
final float maxMemory = runtime.maxMemory() / 1024 / 1024;
final float totalMemory = runtime.totalMemory() / 1024 / 1024;
final float usedMemory = (runtime.totalMemory() - runtime.freeMemory()) / 1024 / 1024;
log.info("class index size:{} total elapsed:{}", reflector.getGlobalClassIndex().size(), stopwatch.stop());
Config.showMemory();
log.info("Ready");
}
use of meghanada.analyze.CompileResult in project meghanada-server by mopemope.
the class CommandHandler method compile.
public void compile(final long id, final String path) {
try {
final String canonicalPath = new File(path).getCanonicalPath();
final CompileResult compileResult = session.compileFile(canonicalPath);
final String out = outputFormatter.compile(id, compileResult, canonicalPath);
writer.write(out);
writer.newLine();
} catch (Throwable t) {
writeError(id, t);
}
}
use of meghanada.analyze.CompileResult in project meghanada-server by mopemope.
the class CommandHandler method compileProject.
public void compileProject(final long id, String path) {
try {
final CompileResult compileResult = session.compileProject(path, true);
final String out = outputFormatter.compileProject(id, compileResult);
writer.write(out);
writer.newLine();
} catch (Throwable t) {
writeError(id, t);
}
}
use of meghanada.analyze.CompileResult in project meghanada-server by mopemope.
the class CommandHandler method diagnostics.
public void diagnostics(final long id, final String sourceFile, final String sourceCodeFile) {
File f = new File(sourceCodeFile);
f.deleteOnExit();
try {
String contents = org.apache.commons.io.FileUtils.readFileToString(new File(sourceCodeFile));
final CompileResult compileResult = session.diagnosticString(sourceFile, contents);
final String out = outputFormatter.diagnostics(id, compileResult, sourceFile);
writer.write(out);
writer.newLine();
} catch (Throwable t) {
writeError(id, t);
} finally {
if (f.exists()) {
f.delete();
}
}
}
Aggregations