Search in sources :

Example 51 with Navigatable

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;
}
Also used : Language(com.intellij.lang.Language) PsiFile(com.intellij.psi.PsiFile) TemplateLanguageFileViewProvider(com.intellij.psi.templateLanguages.TemplateLanguageFileViewProvider) PsiElement(com.intellij.psi.PsiElement) Navigatable(com.intellij.pom.Navigatable) Nullable(org.jetbrains.annotations.Nullable)

Example 52 with Navigatable

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);
}
Also used : Side(com.intellij.diff.util.Side) LineCol(com.intellij.diff.util.LineCol) Navigatable(com.intellij.pom.Navigatable) Nullable(org.jetbrains.annotations.Nullable)

Example 53 with Navigatable

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);
}
Also used : Project(com.intellij.openapi.project.Project) DiffElement(com.intellij.ide.diff.DiffElement) ArrayList(java.util.ArrayList) Navigatable(com.intellij.pom.Navigatable) Nullable(org.jetbrains.annotations.Nullable)

Example 54 with Navigatable

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);
}
Also used : Project(com.intellij.openapi.project.Project) Navigatable(com.intellij.pom.Navigatable)

Example 55 with Navigatable

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);
}
Also used : Project(com.intellij.openapi.project.Project) MouseEvent(java.awt.event.MouseEvent) Editor(com.intellij.openapi.editor.Editor) Navigatable(com.intellij.pom.Navigatable)

Aggregations

Navigatable (com.intellij.pom.Navigatable)70 VirtualFile (com.intellij.openapi.vfs.VirtualFile)22 OpenFileDescriptor (com.intellij.openapi.fileEditor.OpenFileDescriptor)19 Project (com.intellij.openapi.project.Project)14 Nullable (org.jetbrains.annotations.Nullable)14 PsiElement (com.intellij.psi.PsiElement)11 ArrayList (java.util.ArrayList)9 PsiFile (com.intellij.psi.PsiFile)7 DefaultMutableTreeNode (javax.swing.tree.DefaultMutableTreeNode)7 TreePath (javax.swing.tree.TreePath)7 NotNull (org.jetbrains.annotations.NotNull)6 Editor (com.intellij.openapi.editor.Editor)4 List (java.util.List)4 TextRange (com.intellij.openapi.util.TextRange)3 XmlTag (com.intellij.psi.xml.XmlTag)3 BlazeConsoleView (com.google.idea.blaze.base.console.BlazeConsoleView)2 IssueOutput (com.google.idea.blaze.base.scope.output.IssueOutput)2 DataContext (com.intellij.openapi.actionSystem.DataContext)2 Logger (com.intellij.openapi.diagnostic.Logger)2 Document (com.intellij.openapi.editor.Document)2