package com.intellij.ide.impl.dataRules;

import com.intellij.ide.util.EditSourceUtil;
import com.intellij.openapi.actionSystem.DataConstants;
import com.intellij.openapi.actionSystem.DataProvider;
import com.intellij.openapi.fileEditor.OpenFileDescriptor;
import com.intellij.psi.PsiElement;

public class NavigatableRule implements GetDataRule {
  public Object getData(DataProvider dataProvider) {
    final OpenFileDescriptor openFileDescriptor = (OpenFileDescriptor)dataProvider.getData(DataConstants.OPEN_FILE_DESCRIPTOR);
    if (openFileDescriptor != null && openFileDescriptor.getFile().isValid()) {
      return openFileDescriptor;
    }

    final PsiElement element = (PsiElement)dataProvider.getData(DataConstants.PSI_ELEMENT);
    if (element != null) {
      return EditSourceUtil.getDescriptor(element);
    }

    return null;
  }
}

@@ -250,16 +250,53 @@
 riptor;%0A
+import com.intellij.pom.Navigatable;%0A
 import c
@@ -853,24 +853,179 @@
 nt);%0A    %7D%0A%0A
+    final Object selection = dataProvider.getData(DataConstants.SELECTED_ITEM);%0A    if (selection instanceof Navigatable) %7B%0A      return selection;%0A    %7D%0A%0A
     return n

extend navigatable rule