use of meghanada.cache.GlobalCache in project meghanada-server by mopemope.
the class FileWatchEventSubscriber method on.
@Subscribe
public void on(final FileSystemWatcher.DeleteEvent event) {
final File file = event.getFile();
try {
String filePath = file.getCanonicalPath();
GlobalCache globalCache = GlobalCache.getInstance();
Project project = sessionEventBus.getSession().getCurrentProject();
globalCache.invalidateSource(project, file);
ProjectDatabaseHelper.deleteSource(filePath);
FileUtils.getClassFile(filePath, project.getSources(), project.getOutput()).ifPresent(File::delete);
FileUtils.getClassFile(filePath, project.getTestSources(), project.getTestOutput()).ifPresent(File::delete);
} catch (Throwable e) {
log.catching(e);
}
}
use of meghanada.cache.GlobalCache in project meghanada-server by mopemope.
the class JavaCompletion method completionPackage.
private Collection<? extends CandidateUnit> completionPackage() {
final GlobalCache globalCache = GlobalCache.getInstance();
final LoadingCache<File, Source> sourceCache = globalCache.getSourceCache(project);
return sourceCache.asMap().values().stream().map(source -> ClassIndex.createPackage(source.getPackageName())).collect(Collectors.toSet());
}
use of meghanada.cache.GlobalCache in project meghanada-server by mopemope.
the class Session method parseFile.
public synchronized boolean parseFile(final String path) throws ExecutionException {
// java file only
final File file = normalize(path);
if (!FileUtils.isJavaFile(file)) {
return false;
}
boolean b = this.changeProject(path);
final GlobalCache globalCache = GlobalCache.getInstance();
globalCache.invalidateSource(currentProject, file);
Optional<Source> source = this.parseJavaSource(file);
return source.isPresent();
}
use of meghanada.cache.GlobalCache in project meghanada-server by mopemope.
the class CachedASMReflector method reflect.
public List<MemberDescriptor> reflect(final String className) {
final ClassName cn = new ClassName(className);
// check type parameter
final String classWithoutTP = cn.getName();
final GlobalCache globalCache = GlobalCache.getInstance();
try {
final List<MemberDescriptor> members = new ArrayList<>(16);
List<MemberDescriptor> list = globalCache.getMemberDescriptors(classWithoutTP);
for (final MemberDescriptor md : list) {
members.add(md.clone());
}
if (cn.hasTypeParameter()) {
return this.replaceMembers(classWithoutTP, className, members);
}
return members;
} catch (ExecutionException e) {
throw new UncheckedExecutionException(e);
}
}
use of meghanada.cache.GlobalCache in project meghanada-server by mopemope.
the class Source method invalidateCache.
private void invalidateCache(final List<ClassScope> classScopes) {
final GlobalCache globalCache = GlobalCache.getInstance();
for (final ClassScope classScope : classScopes) {
globalCache.invalidateMemberDescriptors(classScope.getFQCN());
this.invalidateCache(classScope.classScopes);
}
}
Aggregations