elementType.is(ElementTypeAttribute.OBJECT_DECLARATION) ? DBContentType.CODE_SPEC :
elementType.is(ElementTypeAttribute.OBJECT_SPECIFICATION) ? DBContentType.CODE_BODY : null;
if (targetContentType != null && identifierPsiElement.getFile() instanceof PSQLFile) {
PSQLFile file = (PSQLFile) identifierPsiElement.getFile();
DBSchemaObject object = (DBSchemaObject) file.getUnderlyingObject();
VirtualFile virtualFile = file.getVirtualFile();
if (object == null || virtualFile.isInLocalFileSystem()) {
ElementTypeAttribute targetAttribute =
elementType.is(ElementTypeAttribute.OBJECT_DECLARATION) ? ElementTypeAttribute.OBJECT_SPECIFICATION :
elementType.is(ElementTypeAttribute.OBJECT_SPECIFICATION) ? ElementTypeAttribute.OBJECT_DECLARATION : null;
if (targetAttribute != null) {
BasePsiElement rootPsiElement = identifierPsiElement.lookupEnclosingPsiElement(ElementTypeAttribute.ROOT);
BasePsiElement targetElement = rootPsiElement == null ? null :
rootPsiElement.lookupPsiElementBySubject(targetAttribute,
identifierPsiElement.getChars(),
identifierPsiElement.getObjectType());
if (targetElement != null) {
NavigationAction navigationAction = targetContentType == DBContentType.CODE_BODY ?
new NavigateToDefinitionAction(null, targetElement, objectType) :
new NavigateToSpecificationAction(null, targetElement, objectType);
Annotation annotation = holder.createInfoAnnotation(basePsiElement, null);
NavigationGutterRenderer gutterIconRenderer = new NavigationGutterRenderer(navigationAction, GutterIconRenderer.Alignment.RIGHT);
annotation.setGutterIconRenderer(gutterIconRenderer);
}
NavigateToObjectAction navigateToObjectAction = new NavigateToObjectAction(identifierPsiElement.resolveUnderlyingObject(), objectType);
Annotation annotation = holder.createInfoAnnotation(basePsiElement, null);
annotation.setGutterIconRenderer(new NavigationGutterRenderer(navigateToObjectAction, GutterIconRenderer.Alignment.LEFT));
}
} else if (object.getContentType() == DBContentType.CODE_SPEC_AND_BODY) {
SourceCodeManager codeEditorManager = SourceCodeManager.getInstance(object.getProject());
BasePsiElement targetElement = codeEditorManager.getObjectNavigationElement(object, targetContentType, identifierPsiElement.getObjectType(), identifierPsiElement.getChars());
if (targetElement != null) {
NavigationAction navigationAction = targetContentType == DBContentType.CODE_BODY ?