use of meghanada.project.Project in project meghanada-server by mopemope.
the class Session method compileProject.
public synchronized CompileResult compileProject(final String path, final boolean force) throws IOException {
final Project project = currentProject;
final CompileResult result = project.compileJava(force);
if (result.hasDiagnostics()) {
log.warn("project {} compile report:{}", project.getName(), result.getDiagnosticsSummary());
}
final CompileResult testResult = project.compileTestJava(force);
if (testResult.hasDiagnostics()) {
for (final Diagnostic<? extends JavaFileObject> diagnostic : testResult.getDiagnostics()) {
result.getDiagnostics().add(diagnostic);
}
log.warn("peoject {} test compile report:{}", project.getName(), testResult.getDiagnosticsSummary());
}
return result;
}
use of meghanada.project.Project in project meghanada-server by mopemope.
the class Session method switchTest.
public Optional<String> switchTest(final String path) throws IOException {
boolean b = this.changeProject(path);
Project project = currentProject;
String root = null;
Set<File> roots;
boolean isTest;
if (path.endsWith("Test.java")) {
// test -> src
roots = project.getTestSources();
isTest = true;
} else {
// src -> test
roots = project.getSources();
isTest = false;
}
for (final File file : roots) {
final String rootPath = file.getCanonicalPath();
if (path.startsWith(rootPath)) {
root = rootPath;
break;
}
}
if (isNull(root)) {
return Optional.empty();
}
String switchPath = path.substring(root.length());
if (isTest) {
switchPath = SWITCH_TEST_RE.matcher(switchPath).replaceAll(Matcher.quoteReplacement(".java"));
// to src
for (File srcRoot : project.getSources()) {
final File srcFile = new File(srcRoot, switchPath);
if (srcFile.exists()) {
return Optional.of(srcFile.getCanonicalPath());
}
}
} else {
switchPath = SWITCH_JAVA_RE.matcher(switchPath).replaceAll(Matcher.quoteReplacement("Test.java"));
// to test
for (File srcRoot : project.getTestSources()) {
final File testFile = new File(srcRoot, switchPath);
if (testFile.exists()) {
return Optional.of(testFile.getCanonicalPath());
}
}
}
return Optional.empty();
}
use of meghanada.project.Project in project meghanada-server by mopemope.
the class Session method reloadProject.
public void reloadProject() throws IOException {
final Project currentProject = this.currentProject;
final File projectRoot = currentProject.getProjectRoot();
this.projects.clear();
if (currentProject instanceof GradleProject) {
loadProject(projectRoot, Project.GRADLE_PROJECT_FILE).ifPresent(project -> {
boolean ret = setProject(projectRoot, project);
});
} else if (currentProject instanceof MavenProject) {
loadProject(projectRoot, Project.MVN_PROJECT_FILE).ifPresent(project -> {
boolean ret = setProject(projectRoot, project);
});
} else {
loadProject(projectRoot, Config.MEGHANADA_CONF_FILE).ifPresent(project -> {
boolean ret = setProject(projectRoot, project);
});
}
final Set<File> temp = new HashSet<>(this.currentProject.getSources());
temp.addAll(this.currentProject.getTestSources());
this.sessionEventBus.requestWatchFiles(new ArrayList<>(temp));
final CachedASMReflector reflector = CachedASMReflector.getInstance();
reflector.addClasspath(Session.getSystemJars());
this.sessionEventBus.requestCreateCache();
this.projects.values().forEach(project -> this.sessionEventBus.requestWatchFile(project.getProjectRoot()));
}
use of meghanada.project.Project in project meghanada-server by mopemope.
the class GradleProjectTest method testLoadProject01.
@Ignore
@Test
public void testLoadProject01() throws Exception {
Project parsed = project.parseProject();
String classpath1 = parsed.classpath();
timeIt(parsed::saveProject);
Thread.sleep(1000);
Project load = timeIt(() -> Project.loadProject(this.projectRootPath));
String classpath2 = load.classpath();
assertEquals(classpath1, classpath2);
timeIt(load::saveProject);
}
use of meghanada.project.Project in project meghanada-server by mopemope.
the class GradleProjectTest method testParse02.
@Test
public void testParse02() throws Exception {
final Project project = timeIt(() -> this.project.parseProject());
final String classpath = project.classpath();
assertNotNull(classpath);
// for (final String cp : StringUtils.split(classpath, File.pathSeparatorChar)) {
// System.out.println(cp);
// }
final String all = project.classpath();
assertNotNull(all);
}
Aggregations