DoctrineModelAccess doctrineModel = DoctrineModelAccess.getDefault();
IModelAccessCache cache = null;
if (context instanceof IModelCacheContext) {
cache = ((IModelCacheContext) context).getCache();
}
EntityAlias alias = context.getAlias();
String prefix = context.getPrefix();
if (alias.hasBundle() == false) {
List<Bundle> bundles = model.findBundles(project);
for (Bundle b : bundles) {
IType[] bundleTypes = EMPTY_TYPES;
if (cache != null) {
Collection<IType> types = cache.getTypes(context.getSourceModule(), b.getElementName(), null, null);
if (types != null) {
bundleTypes = types.toArray(new IType[types.size()]);
}
} else {
bundleTypes = PhpModelAccess.getDefault().findTypes(b.getElementName(), MatchRule.EXACT, 0, 0, projectScope, null);
}
if (bundleTypes.length == 1) {
ModelElement bType = (ModelElement) bundleTypes[0];
if (CodeAssistUtils.startsWithIgnoreCase(bType.getElementName(), prefix)) {
Bundle bundleType = new Bundle(bType, b.getElementName());
reporter.reportType(bundleType, ":", range);
}
}
}
} else {
List<Entity> entities = doctrineModel.getEntities(project);
//TODO: cache the entities
for (Entity entity : entities) {
EntityAlias newAliase = new EntityAlias(alias.getBundleAlias(), entity.getElementName());
IType type = model.findEntity(newAliase, project);
if (type != null) {
reporter.reportType(new Entity((ModelElement) type, type.getElementName()), "", range);
}