Search in sources :

Example 41 with LineMarkerInfo

use of com.intellij.codeInsight.daemon.LineMarkerInfo in project intellij-community by JetBrains.

the class PyLineSeparatorUtil method addLineSeparatorIfNeeded.

@Nullable
public static LineMarkerInfo addLineSeparatorIfNeeded(final Provider provider, final PsiElement element) {
    final Ref<LineMarkerInfo> info = new Ref<LineMarkerInfo>(null);
    ApplicationManager.getApplication().runReadAction(() -> {
        if (!provider.isSeparatorAllowed(element)) {
            return;
        }
        boolean hasSeparableBefore = false;
        final PsiElement parent = element.getParent();
        if (parent == null) {
            return;
        }
        for (PsiElement child : parent.getChildren()) {
            if (child == element) {
                break;
            }
            if (provider.isSeparatorAllowed(child)) {
                hasSeparableBefore = true;
                break;
            }
        }
        if (!hasSeparableBefore) {
            return;
        }
        info.set(createLineSeparatorByElement(element));
    });
    return info.get();
}
Also used : LineMarkerInfo(com.intellij.codeInsight.daemon.LineMarkerInfo) Ref(com.intellij.openapi.util.Ref) PsiElement(com.intellij.psi.PsiElement) Nullable(org.jetbrains.annotations.Nullable)

Example 42 with LineMarkerInfo

use of com.intellij.codeInsight.daemon.LineMarkerInfo in project intellij-community by JetBrains.

the class PyRunLineMarkerTest method testRunnableMain.

public void testRunnableMain() {
    List<LineMarkerInfo> infos = getInfos("runnable.py");
    assertEquals("Wrong number of line markers", 1, infos.size());
    LineMarkerInfo lineMarkerInfo = infos.get(0);
    PsiElement elementWithInfo = lineMarkerInfo.getElement();
    assertNotNull(elementWithInfo);
    assertTrue(elementWithInfo.getText().startsWith("if __name__ == \"__main__\""));
}
Also used : LineMarkerInfo(com.intellij.codeInsight.daemon.LineMarkerInfo) PsiElement(com.intellij.psi.PsiElement)

Aggregations

LineMarkerInfo (com.intellij.codeInsight.daemon.LineMarkerInfo)42 PsiElement (com.intellij.psi.PsiElement)16 Nullable (org.jetbrains.annotations.Nullable)12 NotNull (org.jetbrains.annotations.NotNull)7 Pass (com.intellij.codeHighlighting.Pass)5 GutterIconNavigationHandler (com.intellij.codeInsight.daemon.GutterIconNavigationHandler)5 AllIcons (com.intellij.icons.AllIcons)5 Document (com.intellij.openapi.editor.Document)5 GutterIconRenderer (com.intellij.openapi.editor.markup.GutterIconRenderer)5 Collection (java.util.Collection)5 LineMarkerProvider (com.intellij.codeInsight.daemon.LineMarkerProvider)4 EditorColorsScheme (com.intellij.openapi.editor.colors.EditorColorsScheme)4 Project (com.intellij.openapi.project.Project)4 List (java.util.List)4 javax.swing (javax.swing)4 DaemonBundle (com.intellij.codeInsight.daemon.DaemonBundle)3 PsiElementListNavigator (com.intellij.codeInsight.daemon.impl.PsiElementListNavigator)3 DefaultPsiElementCellRenderer (com.intellij.ide.util.DefaultPsiElementCellRenderer)3 MarkupModelEx (com.intellij.openapi.editor.ex.MarkupModelEx)3 VirtualFile (com.intellij.openapi.vfs.VirtualFile)3