use of com.intellij.pom.Navigatable in project intellij-community by JetBrains.
the class StructureViewElementWrapper method getNavigatableInTemplateLanguageFile.
@Nullable
private Navigatable getNavigatableInTemplateLanguageFile() {
PsiElement element = (PsiElement) myTreeElement.getValue();
if (element == null)
return null;
int offset = element.getTextRange().getStartOffset();
final Language dataLanguage = ((TemplateLanguageFileViewProvider) myMainFile.getViewProvider()).getTemplateDataLanguage();
final PsiFile dataFile = myMainFile.getViewProvider().getPsi(dataLanguage);
if (dataFile == null)
return null;
PsiElement tlElement = dataFile.findElementAt(offset);
while (true) {
if (tlElement == null || tlElement.getTextRange().getStartOffset() != offset)
break;
if (tlElement instanceof Navigatable) {
return (Navigatable) tlElement;
}
tlElement = tlElement.getParent();
}
return null;
}
use of com.intellij.pom.Navigatable in project intellij-community by JetBrains.
the class TwosideTextDiffViewer method getNavigatable.
//
// Misc
//
@Nullable
@Override
protected Navigatable getNavigatable() {
Side side = getCurrentSide();
LineCol position = LineCol.fromCaret(getEditor(side));
Navigatable navigatable = getContent(side).getNavigatable(position);
if (navigatable != null)
return navigatable;
LineCol otherPosition = transferPosition(side, position);
return getContent(side.other()).getNavigatable(otherPosition);
}
use of com.intellij.pom.Navigatable in project intellij-community by JetBrains.
the class DirDiffPanel method getNavigatableArray.
@Nullable
private Navigatable[] getNavigatableArray() {
Project project = myModel.getProject();
List<DirDiffElementImpl> elements = myModel.getSelectedElements();
List<Navigatable> navigatables = new ArrayList<>();
for (DirDiffElementImpl element : elements) {
DiffElement source = element.getSource();
DiffElement target = element.getTarget();
Navigatable navigatable1 = source != null ? source.getNavigatable(project) : null;
Navigatable navigatable2 = target != null ? target.getNavigatable(project) : null;
if (navigatable1 != null)
navigatables.add(navigatable1);
if (navigatable2 != null)
navigatables.add(navigatable2);
}
return toObjectArray(navigatables, Navigatable.class);
}
use of com.intellij.pom.Navigatable in project intellij-community by JetBrains.
the class OpenInEditorAction method actionPerformed.
@Override
public void actionPerformed(@NotNull AnActionEvent e) {
Project project = e.getProject();
if (project == null)
return;
Navigatable[] navigatables = e.getData(DiffDataKeys.NAVIGATABLE_ARRAY);
if (navigatables == null)
return;
openEditor(project, navigatables);
}
use of com.intellij.pom.Navigatable in project intellij-community by JetBrains.
the class OpenInEditorWithMouseAction method actionPerformed.
@Override
public void actionPerformed(@NotNull AnActionEvent e) {
UsageTrigger.trigger("diff.OpenInEditor.Mouse");
MouseEvent inputEvent = (MouseEvent) e.getInputEvent();
OpenInEditorAction openInEditorAction = e.getRequiredData(OpenInEditorAction.KEY);
Project project = e.getRequiredData(CommonDataKeys.PROJECT);
Component component = inputEvent.getComponent();
Point point = inputEvent.getPoint();
Component componentAt = SwingUtilities.getDeepestComponentAt(component, point.x, point.y);
MouseEvent convertedEvent = SwingUtilities.convertMouseEvent(inputEvent.getComponent(), inputEvent, componentAt);
Editor editor = getEditor(componentAt);
assert editor != null;
int line = editor.xyToLogicalPosition(convertedEvent.getPoint()).line;
Navigatable navigatable = getNavigatable(editor, line);
if (navigatable == null)
return;
openInEditorAction.openEditor(project, navigatable);
}
Aggregations