use of meghanada.analyze.CompileResult in project meghanada-server by mopemope.
the class GradleProjectTest method testCompile02.
@Ignore
@Test
public void testCompile02() throws Exception {
project.parseProject();
setupReflector(project);
Thread.sleep(1000 * 3);
final CompileResult compileResult = this.project.compileJava(true);
assertTrue(compileResult.isSuccess());
String fqcn = "meghanada.store.ProjectDatabase";
Thread.sleep(1000 * 5);
ProjectDatabaseHelper.getClassIndexLinks(fqcn, "references", entities -> {
log.info("references {}", entities.size());
});
for (int i = 0; i < 5; i++) {
this.project.compileJava(true);
Thread.sleep(1000 * 5);
ProjectDatabaseHelper.getClassIndexLinks(fqcn, "references", entities -> {
log.info("references {}", entities.size());
});
}
}
use of meghanada.analyze.CompileResult in project meghanada-server by mopemope.
the class ReferenceSearcherTest method setup.
@BeforeClass
public static void setup() throws Exception {
GradleTestBase.setupReflector(true);
CompileResult compileResult1 = project.compileJava();
CompileResult compileResult2 = project.compileTestJava();
Thread.sleep(1000 * 4);
}
use of meghanada.analyze.CompileResult in project meghanada-server by mopemope.
the class JavaSourceLoader method load.
@Override
public Source load(final File file) throws IOException {
final Config config = Config.load();
if (!file.exists()) {
return new Source(file.getPath());
}
if (!config.useSourceCache()) {
final CompileResult compileResult = project.parseFile(file);
return compileResult.getSources().get(file);
}
final String projectRootPath = this.project.getProjectRootPath();
final Map<String, String> checksumMap = ProjectDatabaseHelper.getChecksumMap(projectRootPath);
final String path = file.getCanonicalPath();
final String md5sum = FileUtils.getChecksum(file);
if (checksumMap.containsKey(path)) {
// compare checksum
final String prevSum = checksumMap.get(path);
if (md5sum.equals(prevSum)) {
// load from cache
try {
final Optional<Source> source = loadSource(file);
if (source.isPresent()) {
log.debug("hit source cache {}", file);
return source.get();
}
} catch (Exception e) {
log.catching(e);
}
}
}
log.warn("source cache miss {}", file);
final CompileResult compileResult = project.parseFile(file.getCanonicalFile());
return compileResult.getSources().get(file.getCanonicalFile());
}
use of meghanada.analyze.CompileResult in project meghanada-server by mopemope.
the class Project method compileFile.
public CompileResult compileFile(final File file, final boolean force, final boolean withRelated) throws IOException {
boolean isTest = false;
final String filepath = file.getCanonicalPath();
for (final File source : this.testSources) {
String testPath = source.getCanonicalPath();
if (filepath.startsWith(testPath)) {
isTest = true;
break;
}
}
String output;
if (isTest) {
output = this.testOutput.getCanonicalPath();
} else {
output = this.output.getCanonicalPath();
}
final Stopwatch stopwatch = Stopwatch.createStarted();
List<File> files = new ArrayList<>(8);
files.add(file);
final Set<File> sources = isTest ? this.getAllSources() : this.getSourcesAndResources();
files = force ? files : FileUtils.getModifiedSources(projectRoot, files, sources, new File(output));
if (withRelated) {
files = this.getRelatedSources(sources, files);
}
if (isTest) {
this.prepareTestCompile(files);
} else {
this.prepareCompile(files);
}
final CompiledSourceHandler handler = new CompiledSourceHandler(this);
final CompileResult compileResult = clearMemberCache(getJavaAnalyzer().analyzeAndCompile(files, this.allClasspath(), output, true, handler));
log.info("project {} compile and analyze {} files. force:{} problem:{} elapsed:{}", this.name, files.size(), force, compileResult.getDiagnostics().size(), stopwatch.stop());
return compileResult;
}
use of meghanada.analyze.CompileResult in project meghanada-server by mopemope.
the class Project method compileString.
public CompileResult compileString(final String sourceFile, final String sourceCode) throws IOException {
boolean isTest = false;
for (final File source : this.testSources) {
String testPath = source.getCanonicalPath();
if (sourceFile.startsWith(testPath)) {
isTest = true;
break;
}
}
String output;
if (isTest) {
output = this.testOutput.getCanonicalPath();
} else {
output = this.output.getCanonicalPath();
}
final Stopwatch stopwatch = Stopwatch.createStarted();
CompiledSourceHandler handler = new CompiledSourceHandler(this, true);
CompileResult compileResult = clearMemberCache(getJavaAnalyzer().runAnalyzeAndCompile(this.allClasspath(), output, sourceFile, sourceCode, true, handler));
log.info("file {} compile and analyze problem:{} elapsed:{}", sourceFile, compileResult.getDiagnostics().size(), stopwatch.stop());
return compileResult;
}
Aggregations