<NME> ElmLineMarkerProviderTestBase.kt
<BEF> ADDFILE
<MSG> Show a line marker for exposed functions/types (#127)


<DFF> @@ -0,0 +1,46 @@
+/*
+ * Use of this source code is governed by the MIT license that can be
+ * found in the LICENSE file.
+ *
+ * Originally from intellij-rust
+ */
+
+package org.elm.ide.lineMarkers
+
+import com.intellij.codeInsight.daemon.impl.DaemonCodeAnalyzerImpl
+import com.intellij.openapi.editor.Editor
+import com.intellij.openapi.project.Project
+import com.intellij.testFramework.fixtures.LightPlatformCodeInsightFixtureTestCase
+import org.elm.lang.ElmTestBase
+import org.intellij.lang.annotations.Language
+
+
+abstract class ElmLineMarkerProviderTestBase : ElmTestBase() {
+
+    protected fun doTestByText(@Language("Elm") source: String) {
+        myFixture.configureByText("Main.elm", source)
+        myFixture.doHighlighting()
+        val expected = markersFrom(source)
+        val actual = markersFrom(myFixture.editor, myFixture.project)
+        LightPlatformCodeInsightFixtureTestCase.assertEquals(expected.joinToString(COMPARE_SEPARATOR), actual.joinToString(COMPARE_SEPARATOR))
+    }
+
+    private fun markersFrom(text: String) =
+            text.split('\n')
+                    .withIndex()
+                    .filter { it.value.contains(MARKER) }
+                    .map { Pair(it.index, it.value.substring(it.value.indexOf(MARKER) + MARKER.length).trim()) }
+
+    private fun markersFrom(editor: Editor, project: Project) =
+            DaemonCodeAnalyzerImpl.getLineMarkers(editor.document, project)
+                    .map {
+                        Pair(editor.document.getLineNumber(it.element?.textRange?.startOffset as Int),
+                                it.lineMarkerTooltip)
+                    }
+                    .sortedBy { it.first }
+
+    private companion object {
+        val MARKER = "--> "
+        val COMPARE_SEPARATOR = " | "
+    }
+}

Show a line marker for exposed functions/types (#127)