use of meghanada.project.Project in project meghanada-server by mopemope.
the class GradleTestBase method setupProject.
@SuppressWarnings("CheckReturnValue")
public static void setupProject(boolean useCache) throws Exception {
if (useCache) {
System.setProperty("meghanada.source.cache", "true");
} else {
System.setProperty("meghanada.source.cache", "false");
}
if (project == null) {
// replace tmp
Project newProject = new GradleProject(new File("./").getCanonicalFile());
final File tempDir = Files.createTempDir();
tempDir.deleteOnExit();
final String path = tempDir.getCanonicalPath();
System.setProperty(TEMP_PROJECT_SETTING_DIR, path);
log.info("create database {}", path);
project = newProject.parseProject().mergeFromProjectConfig();
}
Config config = Config.load();
if (useCache) {
config.update("source-cache", true);
} else {
config.update("source-cache", false);
}
log.info("finish setupProject");
}
use of meghanada.project.Project in project meghanada-server by mopemope.
the class AnnoTest2 method init.
@BeforeSuite
public static void init() throws Exception {
final Project project = new GradleProject(new File("./").getCanonicalFile());
project.parseProject();
project.compileJava(false);
project.compileTestJava(false);
List<String> list = new ArrayList<>();
final JCDiagnostic.DiagnosticPosition pos = null;
}
use of meghanada.project.Project in project meghanada-server by mopemope.
the class LocationSearcher method getFieldLocationFromProject.
private Optional<Location> getFieldLocationFromProject(final String fqcn, final String fieldName, final File file) {
try {
final Source declaringClassSrc = getSource(project, file);
final String path = declaringClassSrc.getFile().getPath();
return declaringClassSrc.getClassScopes().stream().map(cs -> getMatchField(cs, fqcn, fieldName)).filter(Optional::isPresent).map(optional -> {
final Variable variable = optional.get();
return new Location(path, variable.range.begin.line, variable.range.begin.column);
}).findFirst();
} catch (Exception e) {
throw new UncheckedExecutionException(e);
}
}
Aggregations