@Override
public void apply(ICompletionReporter reporter) throws BadLocationException {
EntityCompletionContext context = (EntityCompletionContext) getContext();
SymfonyModelAccess model = SymfonyModelAccess.getDefault();
IScriptProject project = context.getSourceModule().getScriptProject();
SourceRange range = getReplacementRange(context);
IDLTKSearchScope projectScope = SearchEngine.createSearchScope(context.getSourceModule().getScriptProject());
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);