use of meghanada.session.Session 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.session.Session in project meghanada-server by mopemope.
the class ParseEventSubscriber method on.
@Subscribe
public synchronized void on(final SessionEventBus.ParseRequest request) {
final Session session = super.sessionEventBus.getSession();
final File file = request.getFile();
if (!FileUtils.isJavaFile(file)) {
return;
}
try {
ParseEventSubscriber.parseFile(session, file);
} catch (Exception e) {
log.warn("parse error {}", e.getMessage());
}
}
use of meghanada.session.Session in project meghanada-server by mopemope.
the class EmacsServer method acceptConnection.
private Future<?> acceptConnection(final Socket conn) {
return this.executorService.submit(() -> {
try (final BufferedReader reader = new BufferedReader(new InputStreamReader(conn.getInputStream(), UTF_8));
final BufferedWriter writer = new BufferedWriter(new OutputStreamWriter(conn.getOutputStream(), UTF_8))) {
final CommandHandler handler = new CommandHandler(session, writer, getOutputFormatter());
boolean start = true;
final SExprParser parser = new SExprParser();
while (start) {
final String line = reader.readLine();
if (isNull(line) || line.isEmpty()) {
log.info("close from client ...");
break;
}
final SExprParser.SExpr expr = parser.parse(line);
final List<SExprParser.SExpr> lst = expr.value();
final List<String> args = lst.stream().map(sExpr -> sExpr.value().toString()).collect(Collectors.toList());
log.debug("receive command line:{} expr:{} args:{}", line, expr, args);
start = dispatch(args, handler);
if (!start) {
log.info("stop client ... args:{}", args);
}
if (this.outputEOT) {
writer.write(EmacsServer.EOT);
writer.newLine();
}
writer.flush();
}
log.info("close client ...");
} catch (Throwable e) {
log.catching(e);
} finally {
try {
conn.close();
} catch (IOException e) {
log.catching(e);
}
log.info("client disconnect");
}
});
}
use of meghanada.session.Session in project meghanada-server by mopemope.
the class ParseEventSubscriber method on.
@Subscribe
public synchronized void on(SessionEventBus.ParseFilesRequest request) {
final Session session = super.sessionEventBus.getSession();
final List<File> files = request.getFiles();
for (final File file : files) {
if (!FileUtils.isJavaFile(file)) {
continue;
}
try {
ParseEventSubscriber.parseFile(session, file);
} catch (Exception e) {
log.warn("parse error {}", e.getMessage());
}
}
}
Aggregations