Search in sources :

Example 6 with IpnbCodePanel

use of org.jetbrains.plugins.ipnb.editor.panels.code.IpnbCodePanel in project intellij-community by JetBrains.

the class IpnbPyReference method multiResolve.

@NotNull
@Override
public ResolveResult[] multiResolve(boolean incompleteCode) {
    ResolveResult[] results = super.multiResolve(incompleteCode);
    if (results.length == 0) {
        PsiFile file = myElement.getContainingFile();
        if (file instanceof IpnbPyFragment) {
            final IpnbFilePanel panel = ((IpnbPyFragment) file).getFilePanel();
            final List<IpnbEditablePanel> panels = panel.getIpnbPanels();
            final String referencedName = myElement.getReferencedName();
            if (referencedName == null)
                return ResolveResult.EMPTY_ARRAY;
            for (IpnbEditablePanel editablePanel : panels) {
                if (!(editablePanel instanceof IpnbCodePanel))
                    continue;
                final Editor editor = ((IpnbCodePanel) editablePanel).getEditor();
                final IpnbPyFragment psiFile = (IpnbPyFragment) PsiDocumentManager.getInstance(myElement.getProject()).getPsiFile(editor.getDocument());
                if (psiFile == null)
                    continue;
                final PyResolveProcessor processor = new PyResolveProcessor(referencedName);
                PyResolveUtil.scopeCrawlUp(processor, psiFile, referencedName, psiFile);
                final List<RatedResolveResult> resultList = getResultsFromProcessor(referencedName, processor, psiFile, psiFile);
                if (resultList.size() > 0) {
                    List<RatedResolveResult> ret = RatedResolveResult.sorted(resultList);
                    return ret.toArray(new RatedResolveResult[ret.size()]);
                }
            }
        }
    }
    return results;
}
Also used : IpnbEditablePanel(org.jetbrains.plugins.ipnb.editor.panels.IpnbEditablePanel) IpnbFilePanel(org.jetbrains.plugins.ipnb.editor.panels.IpnbFilePanel) PsiFile(com.intellij.psi.PsiFile) IpnbCodePanel(org.jetbrains.plugins.ipnb.editor.panels.code.IpnbCodePanel) Editor(com.intellij.openapi.editor.Editor) ResolveResult(com.intellij.psi.ResolveResult) NotNull(org.jetbrains.annotations.NotNull)

Example 7 with IpnbCodePanel

use of org.jetbrains.plugins.ipnb.editor.panels.code.IpnbCodePanel in project intellij-community by JetBrains.

the class IpnbPyTargetExpression method navigate.

@Override
public void navigate(boolean requestFocus) {
    final IpnbCodeSourcePanel sourcePanel = ((IpnbPyFragment) getContainingFile()).getCodeSourcePanel();
    final Editor editor = sourcePanel.getEditor();
    final IpnbCodePanel codePanel = sourcePanel.getIpnbCodePanel();
    final IpnbFileEditor fileEditor = codePanel.getFileEditor();
    final IpnbFilePanel filePanel = fileEditor.getIpnbFilePanel();
    codePanel.setEditing(true);
    filePanel.setSelectedCellPanel(codePanel);
    super.navigate(false);
    UIUtil.requestFocus(editor.getContentComponent());
}
Also used : IpnbFilePanel(org.jetbrains.plugins.ipnb.editor.panels.IpnbFilePanel) IpnbCodeSourcePanel(org.jetbrains.plugins.ipnb.editor.panels.code.IpnbCodeSourcePanel) IpnbFileEditor(org.jetbrains.plugins.ipnb.editor.IpnbFileEditor) Editor(com.intellij.openapi.editor.Editor) IpnbFileEditor(org.jetbrains.plugins.ipnb.editor.IpnbFileEditor) IpnbCodePanel(org.jetbrains.plugins.ipnb.editor.panels.code.IpnbCodePanel)

Example 8 with IpnbCodePanel

use of org.jetbrains.plugins.ipnb.editor.panels.code.IpnbCodePanel in project intellij-community by JetBrains.

the class IpnbUnresolvedReferenceSkipper method unusedImportShouldBeSkipped.

@Override
public boolean unusedImportShouldBeSkipped(@NotNull final PyImportedNameDefiner importNameDefiner) {
    final PsiFile file = importNameDefiner.getContainingFile();
    if (file instanceof IpnbPyFragment) {
        final IpnbFilePanel panel = ((IpnbPyFragment) file).getFilePanel();
        final List<IpnbEditablePanel> panels = panel.getIpnbPanels();
        for (IpnbEditablePanel editablePanel : panels) {
            if (!(editablePanel instanceof IpnbCodePanel))
                continue;
            final Editor editor = ((IpnbCodePanel) editablePanel).getEditor();
            final IpnbPyFragment psiFile = (IpnbPyFragment) PsiDocumentManager.getInstance(importNameDefiner.getProject()).getPsiFile(editor.getDocument());
            if (psiFile == null)
                continue;
            final MyVisitor visitor = new MyVisitor(importNameDefiner);
            psiFile.accept(visitor);
            if (visitor.used)
                return true;
        }
    }
    return false;
}
Also used : IpnbFilePanel(org.jetbrains.plugins.ipnb.editor.panels.IpnbFilePanel) IpnbCodePanel(org.jetbrains.plugins.ipnb.editor.panels.code.IpnbCodePanel) Editor(com.intellij.openapi.editor.Editor) IpnbEditablePanel(org.jetbrains.plugins.ipnb.editor.panels.IpnbEditablePanel)

Example 9 with IpnbCodePanel

use of org.jetbrains.plugins.ipnb.editor.panels.code.IpnbCodePanel in project intellij-community by JetBrains.

the class IpnbFilePanel method createAndAddCell.

public void createAndAddCell(final boolean below, IpnbCodeCell cell) {
    final IpnbCodePanel codePanel = new IpnbCodePanel(myProject, myParent, cell);
    addCell(codePanel, below);
}
Also used : IpnbCodePanel(org.jetbrains.plugins.ipnb.editor.panels.code.IpnbCodePanel)

Example 10 with IpnbCodePanel

use of org.jetbrains.plugins.ipnb.editor.panels.code.IpnbCodePanel in project intellij-community by JetBrains.

the class IpnbFileEditor method updateCellTypeCombo.

private void updateCellTypeCombo(@NotNull final IpnbPanel ipnbPanel) {
    if (ipnbPanel instanceof IpnbHeadingPanel) {
        final IpnbHeadingCell cell = ((IpnbHeadingPanel) ipnbPanel).getCell();
        final int level = cell.getLevel();
        myCellTypeCombo.setSelectedItem(headingCellType + level);
    } else if (ipnbPanel instanceof IpnbMarkdownPanel) {
        myCellTypeCombo.setSelectedItem(markdownCellType);
    } else if (ipnbPanel instanceof IpnbCodePanel) {
        myCellTypeCombo.setSelectedItem(codeCellType);
    }
}
Also used : IpnbHeadingCell(org.jetbrains.plugins.ipnb.format.cells.IpnbHeadingCell) IpnbCodePanel(org.jetbrains.plugins.ipnb.editor.panels.code.IpnbCodePanel)

Aggregations

IpnbCodePanel (org.jetbrains.plugins.ipnb.editor.panels.code.IpnbCodePanel)10 Editor (com.intellij.openapi.editor.Editor)5 IpnbFilePanel (org.jetbrains.plugins.ipnb.editor.panels.IpnbFilePanel)5 NotNull (org.jetbrains.annotations.NotNull)3 IpnbEditablePanel (org.jetbrains.plugins.ipnb.editor.panels.IpnbEditablePanel)3 PsiFile (com.intellij.psi.PsiFile)2 IpnbFileEditor (org.jetbrains.plugins.ipnb.editor.IpnbFileEditor)2 IpnbCodeSourcePanel (org.jetbrains.plugins.ipnb.editor.panels.code.IpnbCodeSourcePanel)2 IpnbHeadingCell (org.jetbrains.plugins.ipnb.format.cells.IpnbHeadingCell)2 ResolveResult (com.intellij.psi.ResolveResult)1 List (java.util.List)1 Nullable (org.jetbrains.annotations.Nullable)1 IpnbCell (org.jetbrains.plugins.ipnb.format.cells.IpnbCell)1 IpnbCodeCell (org.jetbrains.plugins.ipnb.format.cells.IpnbCodeCell)1 IpnbMarkdownCell (org.jetbrains.plugins.ipnb.format.cells.IpnbMarkdownCell)1 IpnbConnection (org.jetbrains.plugins.ipnb.protocol.IpnbConnection)1 IpnbConnectionListenerBase (org.jetbrains.plugins.ipnb.protocol.IpnbConnectionListenerBase)1