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);
}
}
}
} else if (identifierElementType.isDefinition()) {
if (identifierElementType.isAlias()) {
String[] aliasNames = buildAliasDefinitionNames(element);
for (String aliasName : aliasNames) {
AliasLookupItemFactory lookupItemFactory = new AliasLookupItemFactory(aliasName, true);
lookupItemFactory.createLookupItem(aliasName, consumer);
}
}
}
}
}