<commit_before>package org.rust.ide.annotator

import com.intellij.codeHighlighting.Pass
import com.intellij.codeInsight.daemon.LineMarkerInfo
import com.intellij.codeInsight.daemon.LineMarkerProvider
import com.intellij.openapi.editor.markup.GutterIconRenderer
import com.intellij.psi.PsiDocumentManager
import com.intellij.psi.PsiElement
import com.intellij.util.FunctionUtil
import org.rust.ide.icons.RustIcons
import org.rust.lang.core.psi.RustCallExprElement
import org.rust.lang.core.psi.RustFunctionElement
import org.rust.lang.core.psi.RustMethodCallExprElement
import org.rust.lang.core.psi.RustPathExprElement
import org.rust.lang.core.psi.util.parentOfType
import java.util.*

/**
 * Line marker provider that annotates recursive funciton and method calls with
 * an icon on the gutter.
 */
class RustRecursiveCallLineMarkerProvider : LineMarkerProvider {

    override fun getLineMarkerInfo(element: PsiElement) = null

    override fun collectSlowLineMarkers(elements: List<PsiElement>,
                                        result: MutableCollection<LineMarkerInfo<PsiElement>>) {
        val lines = HashSet<Int>()  // To prevent several markers on one line

        for (el in elements.filter { it.isRecursive }) {
            val doc = PsiDocumentManager.getInstance(el.project).getDocument(el.containingFile) ?: continue
            val lineNumber = doc.getLineNumber(el.textOffset)
            if (lineNumber !in lines) {
                lines.add(lineNumber)
                result.add(LineMarkerInfo(
                    el,
                    el.textRange,
                    RustIcons.RECURSIVE_CALL,
                    // BACKCOMPAT: 2016.2
                    Pass.UPDATE_OVERRIDDEN_MARKERS,<commit_msg>Revert "Remove recursion marker hack"<commit_after>package org.rust.ide.annotator

import com.intellij.codeInsight.daemon.LineMarkerInfo
import com.intellij.codeInsight.daemon.LineMarkerProvider
import com.intellij.openapi.editor.markup.GutterIconRenderer
import com.intellij.psi.PsiDocumentManager
import com.intellij.psi.PsiElement
import com.intellij.util.FunctionUtil
import org.rust.ide.icons.RustIcons
import org.rust.lang.core.psi.RustCallExprElement
import org.rust.lang.core.psi.RustFunctionElement
import org.rust.lang.core.psi.RustMethodCallExprElement
import org.rust.lang.core.psi.RustPathExprElement
import org.rust.lang.core.psi.util.parentOfType
import java.util.*

/**
 * Line marker provider that annotates recursive funciton and method calls with
 * an icon on the gutter.
 */
class RustRecursiveCallLineMarkerProvider : LineMarkerProvider {

    override fun getLineMarkerInfo(element: PsiElement) = null

    override fun collectSlowLineMarkers(elements: List<PsiElement>,
                                        result: MutableCollection<LineMarkerInfo<PsiElement>>) {
        val lines = HashSet<Int>()  // To prevent several markers on one line

        for (el in elements.filter { it.isRecursive }) {
            val doc = PsiDocumentManager.getInstance(el.project).getDocument(el.containingFile) ?: continue
            val lineNumber = doc.getLineNumber(el.textOffset)
            if (lineNumber !in lines) {
                lines.add(lineNumber)
                result.add(LineMarkerInfo(
                    el,
                    el.textRange,
                    RustIcons.RECURSIVE_CALL,
                    // BACKCOMPAT: 2016.1
                    // Pass.UPDATE_OVERRIDEN_MARKERS in IDEA 2016.1
                    // Pass.UPDATE_OVERRIDDEN_MARKERS in IDEA 2016.2
                    // TODO: change to Pass.LINE_MARKERS, when it
                    // does not create duplicate icons.
                    6, // :(
{'fraction_non_alphanumeric': 0.08143322475570032, 'fraction_numerical': 0.005700325732899023, 'mean_word_length': 2.737322515212982, 'pattern_counts': {'":': 0, '<': 11, '<?xml version=': 0, '>': 11, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 2, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '3023455', 'n_tokens_mistral': 1086, 'n_tokens_neox': 1020, 'n_words': 208}