use of jetbrains.exodus.entitystore.Entity in project meghanada-server by mopemope.
the class ProjectDatabaseHelper method saveMemberDescriptors.
public static boolean saveMemberDescriptors(final String fqcn, final List<MemberDescriptor> members) {
ProjectDatabase database = ProjectDatabase.getInstance();
return database.execute(txn -> {
EntityIterable it = txn.find(ClassIndex.ENTITY_TYPE, ProjectDatabase.ID, fqcn);
Entity entity = it.getFirst();
if (isNull(entity)) {
return false;
}
try {
ProjectDatabase.setSerializeBlobData(entity, BLOB_PROP_MEMBERS, members);
} catch (IOException e) {
log.catching(e);
txn.abort();
return false;
}
// txn.saveEntity(entity);
return true;
});
}
use of jetbrains.exodus.entitystore.Entity in project meghanada-server by mopemope.
the class Source method deleteLinks.
private static void deleteLinks(StoreTransaction txn, Entity mainEntity) {
Set<String> names = new HashSet<>(3);
names.add(LINK_VARIABLE);
names.add(LINK_FIELD_ACCESS);
names.add(LINK_METHOD_CALL);
for (Entity entity : mainEntity.getLinks(names)) {
entity.delete();
}
for (String name : names) {
mainEntity.deleteLinks(name);
}
// mainEntity.deleteLinks(LINK_REV_CLASS_REFERENCES);
}
use of jetbrains.exodus.entitystore.Entity in project meghanada-server by mopemope.
the class CompileResult method store.
@Override
public void store(StoreTransaction txn, Entity entity) {
long now = Instant.now().getEpochSecond();
entity.setProperty("createdAt", now);
entity.setProperty("result", this.success);
entity.setProperty("problems", this.diagnostics.size());
for (Diagnostic<? extends JavaFileObject> diagnostic : this.diagnostics) {
String kind = diagnostic.getKind().toString();
long line = diagnostic.getLineNumber();
long column = diagnostic.getColumnNumber();
String message = diagnostic.getMessage(null);
if (isNull(message)) {
message = "";
}
JavaFileObject fileObject = diagnostic.getSource();
String path = null;
if (fileObject != null) {
final URI uri = fileObject.toUri();
final File file = new File(uri);
try {
path = file.getCanonicalPath();
} catch (IOException e) {
throw new UncheckedIOException(e);
}
}
String code = diagnostic.getCode();
Entity subEntity = txn.newEntity(CompileResult.DIAGNOSTIC_ENTITY_TYPE);
subEntity.setProperty("kind", kind);
subEntity.setProperty("line", line);
subEntity.setProperty("column", column);
subEntity.setProperty("message", message);
if (nonNull(path)) {
subEntity.setProperty("path", path);
}
if (nonNull(code)) {
subEntity.setProperty("code", code);
}
entity.addLink("diagnostic", entity);
}
}
use of jetbrains.exodus.entitystore.Entity in project meghanada-server by mopemope.
the class ProjectDatabaseHelper method deleteMemberDescriptors.
public static boolean deleteMemberDescriptors(String fqcn) {
ProjectDatabase database = ProjectDatabase.getInstance();
return database.execute(txn -> {
EntityIterable it = txn.find(ClassIndex.ENTITY_TYPE, ProjectDatabase.ID, fqcn);
Entity entity = it.getFirst();
if (isNull(entity)) {
return false;
}
boolean result = entity.deleteBlob(BLOB_PROP_MEMBERS);
// txn.saveEntity(entity);
return result;
});
}
use of jetbrains.exodus.entitystore.Entity in project meghanada-server by mopemope.
the class ProjectDatabaseHelper method getClassIndexLinks.
public static void getClassIndexLinks(String fqcn, String linkName, Consumer<EntityIterable> fn) throws Exception {
Map<String, ClassIndex> globalClassIndex = CachedASMReflector.getInstance().getGlobalClassIndex();
if (!globalClassIndex.containsKey(fqcn)) {
return;
}
ClassIndex index = globalClassIndex.get(fqcn);
EntityId entityId = index.getEntityId();
ProjectDatabase database = ProjectDatabase.getInstance();
boolean result = database.execute(txn -> {
Entity classEntity = txn.getEntity(entityId);
EntityIterable iterable = classEntity.getLinks(linkName);
fn.accept(iterable);
return true;
});
}
Aggregations