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;
}
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());
}
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;
}
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);
}
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);
}
}
Aggregations