else if (nextPossibleLeaf instanceof IdentifierElementType) {
IdentifierElementType identifierElementType = (IdentifierElementType) nextPossibleLeaf;
if (identifierElementType.isReference()) {
DBObjectType objectType = identifierElementType.getObjectType();
if (identifierElementType.isObject()) {
PsiLookupAdapter lookupAdapter = new ObjectDefinitionLookupAdapter(null, objectType, null);
Set<BasePsiElement> objectDefinitions = lookupAdapter.collectInParentScopeOf(element);
if (objectDefinitions != null) {
for (BasePsiElement psiElement : objectDefinitions) {
if (psiElement instanceof IdentifierPsiElement) {
IdentifierPsiElement identifierPsiElement = (IdentifierPsiElement) psiElement;
PsiElement referencedPsiElement = identifierPsiElement.resolve();
if (referencedPsiElement instanceof DBObject) {
DBObject object = (DBObject) referencedPsiElement;
LookupItemFactory lookupItemFactory = object.getLookupItemFactory(identifierElementType.getLanguage());
lookupItemFactory.createLookupItem(object, consumer);
}
}
}
}
if (connectionHandler != null && !connectionHandler.isVirtual()) {
if (parentObject == null) {
BasePsiElement scope = element.getEnclosingScopePsiElement();
collectObjectMatchingScope(consumer, identifierElementType, filterSettings, scope, context);
} else {
for (DBObject object : parentObject.getChildObjects(identifierElementType.getObjectType())) {
consumer.check();
consumer.consume(object);
}
}
}
} else if (identifierElementType.isAlias()) {
PsiLookupAdapter lookupAdapter = new AliasDefinitionLookupAdapter(null, objectType, null);
Set<BasePsiElement> aliasDefinitions = lookupAdapter.collectInParentScopeOf(element);
if (aliasDefinitions != null) {
for (PsiElement psiElement : aliasDefinitions) {
IdentifierPsiElement identifierPsiElement = (IdentifierPsiElement) psiElement;
AliasLookupItemFactory lookupItemFactory = new AliasLookupItemFactory(identifierPsiElement.getChars(), true);
lookupItemFactory.createLookupItem(identifierPsiElement, consumer);
}
}
} else if (identifierElementType.isVariable()) {
PsiLookupAdapter lookupAdapter = new VariableDefinitionLookupAdapter(null, objectType, null);
Set<BasePsiElement> aliasDefinitions = lookupAdapter.collectInParentScopeOf(element);
if (aliasDefinitions != null) {
for (BasePsiElement psiElement : aliasDefinitions) {
IdentifierPsiElement identifierPsiElement = (IdentifierPsiElement) psiElement;
VariableLookupItemFactory lookupItemFactory = new VariableLookupItemFactory(identifierPsiElement.getChars(), true);
lookupItemFactory.createLookupItem(identifierPsiElement, consumer);