Search in sources :

Example 21 with LineMarkerInfo

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

the class AbstractLineMarkersTest method doTest.

public void doTest(String path) {
    try {
        String fileText = FileUtil.loadFile(new File(path));
        ConfigLibraryUtil.configureLibrariesByDirective(myFixture.getModule(), PlatformTestUtil.getCommunityPath(), fileText);
        myFixture.configureByFile(path);
        Project project = myFixture.getProject();
        Document document = myFixture.getEditor().getDocument();
        ExpectedHighlightingData data = new ExpectedHighlightingData(document, false, false, false, myFixture.getFile());
        data.init();
        PsiDocumentManager.getInstance(project).commitAllDocuments();
        myFixture.doHighlighting();
        List<LineMarkerInfo> markers = DaemonCodeAnalyzerImpl.getLineMarkers(document, project);
        try {
            data.checkLineMarkers(markers, document.getText());
            // the latter doesn't throw assertion error when some line markers are expected, but none are present.
            if (FileUtil.loadFile(new File(path)).contains("<lineMarker") && markers.isEmpty()) {
                throw new AssertionError("Some line markers are expected, but nothing is present at all");
            }
        } catch (AssertionError error) {
            try {
                String actualTextWithTestData = TagsTestDataUtil.insertInfoTags(markers, true, myFixture.getFile().getText());
                KotlinTestUtils.assertEqualsToFile(new File(path), actualTextWithTestData);
            } catch (FileComparisonFailure failure) {
                throw new FileComparisonFailure(error.getMessage() + "\n" + failure.getMessage(), failure.getExpected(), failure.getActual(), failure.getFilePath());
            }
        }
        assertNavigationElements(markers);
    } catch (Exception exc) {
        throw new RuntimeException(exc);
    }
}
Also used : Project(com.intellij.openapi.project.Project) LineMarkerInfo(com.intellij.codeInsight.daemon.LineMarkerInfo) ExpectedHighlightingData(com.intellij.testFramework.ExpectedHighlightingData) Document(com.intellij.openapi.editor.Document) KtFile(org.jetbrains.kotlin.psi.KtFile) File(java.io.File) FileComparisonFailure(com.intellij.rt.execution.junit.FileComparisonFailure)

Example 22 with LineMarkerInfo

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

the class JstdAssertionFrameworkLineMarkerProvider method getLineMarkerInfo.

@Override
public LineMarkerInfo getLineMarkerInfo(@NotNull PsiElement element) {
    Project project = element.getProject();
    JSFile jsFile = ObjectUtils.tryCast(element.getContainingFile(), JSFile.class);
    if (jsFile == null) {
        return null;
    }
    if (!JstdSettingsUtil.areJstdConfigFilesInProjectCached(project)) {
        return null;
    }
    LineMarkerInfo lineMarkerInfo = getJstdLineMarkerInfo(project, jsFile, element);
    if (lineMarkerInfo == null) {
        lineMarkerInfo = getQUnitLineMarkerInfo(jsFile, element);
    }
    return lineMarkerInfo;
}
Also used : Project(com.intellij.openapi.project.Project) LineMarkerInfo(com.intellij.codeInsight.daemon.LineMarkerInfo) JSFile(com.intellij.lang.javascript.psi.JSFile)

Example 23 with LineMarkerInfo

use of com.intellij.codeInsight.daemon.LineMarkerInfo in project intellij-elixir by KronicDeth.

the class CallDefinition method callDefinitionSeparator.

/*
     * Private Instance Methods
     */
@NotNull
private LineMarkerInfo callDefinitionSeparator(@NotNull Call call) {
    LineMarkerInfo lineMarkerInfo;
    lineMarkerInfo = new LineMarkerInfo<Call>(call, call.getTextRange(), null, Pass.UPDATE_ALL, null, null, GutterIconRenderer.Alignment.RIGHT);
    EditorColorsScheme editorColorsScheme = editorColorsManager.getGlobalScheme();
    lineMarkerInfo.separatorColor = editorColorsScheme.getColor(CodeInsightColors.METHOD_SEPARATORS_COLOR);
    lineMarkerInfo.separatorPlacement = SeparatorPlacement.TOP;
    return lineMarkerInfo;
}
Also used : LineMarkerInfo(com.intellij.codeInsight.daemon.LineMarkerInfo) Call(org.elixir_lang.psi.call.Call) AtUnqualifiedNoParenthesesCall(org.elixir_lang.psi.AtUnqualifiedNoParenthesesCall) EditorColorsScheme(com.intellij.openapi.editor.colors.EditorColorsScheme) NotNull(org.jetbrains.annotations.NotNull)

Example 24 with LineMarkerInfo

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

the class AnnotatorTestUtils method checkGutterTargets.

/**
   * Verifies the navigation targets' names of the gutter icon match.
   *
   * @param renderer            Gutter icon.
   * @param resultValueFunction Function to transform target to expected name.
   * @param expectedValues      Expected names.
   */
static void checkGutterTargets(@NotNull final GutterMark renderer, @NotNull final Function<PsiElement, String> resultValueFunction, final String... expectedValues) {
    final LineMarkerInfo lineMarkerInfo = ((LineMarkerInfo.LineMarkerGutterIconRenderer) renderer).getLineMarkerInfo();
    final NavigationGutterIconRenderer navigationHandler = (NavigationGutterIconRenderer) lineMarkerInfo.getNavigationHandler();
    assertNotNull(navigationHandler);
    final List<PsiElement> targetElements = navigationHandler.getTargetElements();
    final Set<String> foundValues = new HashSet<>();
    for (final PsiElement psiElement : targetElements) {
        foundValues.add(resultValueFunction.fun(psiElement));
    }
    assertSameElements(foundValues, expectedValues);
}
Also used : LineMarkerInfo(com.intellij.codeInsight.daemon.LineMarkerInfo) NavigationGutterIconRenderer(com.intellij.codeInsight.navigation.NavigationGutterIconRenderer) PsiElement(com.intellij.psi.PsiElement) HashSet(java.util.HashSet)

Example 25 with LineMarkerInfo

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

the class DartServerImplementationsMarkerProvider method createMarkerMember.

@NotNull
private static LineMarkerInfo createMarkerMember(@NotNull final DartComponentName name) {
    final VirtualFile file = name.getContainingFile().getVirtualFile();
    final int nameOffset = name.getTextRange().getStartOffset();
    return new LineMarkerInfo<>(name, name.getTextRange(), AllIcons.Gutter.OverridenMethod, Pass.LINE_MARKERS, element -> DaemonBundle.message("method.is.overridden.too.many"), (GutterIconNavigationHandler<PsiElement>) (e, elt) -> {
        final List<TypeHierarchyItem> items = DartAnalysisServerService.getInstance(name.getProject()).search_getTypeHierarchy(file, nameOffset, false);
        if (items.isEmpty()) {
            return;
        }
        final List<DartComponent> components = DartInheritorsSearcher.getSubMembers(name.getProject(), GlobalSearchScope.allScope(name.getProject()), items);
        PsiElementListNavigator.openTargets(e, DartResolveUtil.getComponentNameArray(components), DaemonBundle.message("navigation.title.overrider.method", name.getName(), components.size()), "Overriding methods of " + name.getName(), new DefaultPsiElementCellRenderer());
    }, GutterIconRenderer.Alignment.RIGHT);
}
Also used : VirtualFile(com.intellij.openapi.vfs.VirtualFile) DartResolveUtil(com.jetbrains.lang.dart.util.DartResolveUtil) AllIcons(com.intellij.icons.AllIcons) GutterIconRenderer(com.intellij.openapi.editor.markup.GutterIconRenderer) TypeHierarchyItem(org.dartlang.analysis.server.protocol.TypeHierarchyItem) DartInheritorsSearcher(com.jetbrains.lang.dart.ide.actions.DartInheritorsSearcher) VirtualFile(com.intellij.openapi.vfs.VirtualFile) DartAnalysisServerService(com.jetbrains.lang.dart.analyzer.DartAnalysisServerService) DartServerData(com.jetbrains.lang.dart.analyzer.DartServerData) PsiElementListNavigator(com.intellij.codeInsight.daemon.impl.PsiElementListNavigator) Collection(java.util.Collection) GlobalSearchScope(com.intellij.psi.search.GlobalSearchScope) DartComponentName(com.jetbrains.lang.dart.psi.DartComponentName) DartComponent(com.jetbrains.lang.dart.psi.DartComponent) Pass(com.intellij.codeHighlighting.Pass) DefaultPsiElementCellRenderer(com.intellij.ide.util.DefaultPsiElementCellRenderer) Nullable(org.jetbrains.annotations.Nullable) DaemonBundle(com.intellij.codeInsight.daemon.DaemonBundle) List(java.util.List) GutterIconNavigationHandler(com.intellij.codeInsight.daemon.GutterIconNavigationHandler) PsiElement(com.intellij.psi.PsiElement) LineMarkerProvider(com.intellij.codeInsight.daemon.LineMarkerProvider) NotNull(org.jetbrains.annotations.NotNull) LineMarkerInfo(com.intellij.codeInsight.daemon.LineMarkerInfo) LineMarkerInfo(com.intellij.codeInsight.daemon.LineMarkerInfo) DefaultPsiElementCellRenderer(com.intellij.ide.util.DefaultPsiElementCellRenderer) List(java.util.List) PsiElement(com.intellij.psi.PsiElement) NotNull(org.jetbrains.annotations.NotNull)

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