override fun getSuggestion()

in src/main/kotlin/org/jetbrains/plugins/feature/suggester/suggesters/LineCommentingSuggester.kt [36:61]


    override fun getSuggestion(action: Action): Suggestion {
        if (action is EditorTextInsertedAction) {
            if (isCommentSymbolAdded(action, '/')) {
                firstSlashAddedAction = action
            } else if (firstSlashAddedAction != null && isSecondSlashAdded(action, firstSlashAddedAction!!) ||
                isCommentSymbolAdded(action, '#')
            ) {
                val document = action.document
                val commentData = CommentData(
                    lineNumber = document.getLineNumber(action.caretOffset),
                    documentRef = WeakReference(document),
                    timeMillis = action.timeMillis
                )
                commentsHistory.add(commentData)
                firstSlashAddedAction = null

                if (commentsHistory.size == numberOfCommentsToGetSuggestion &&
                    commentsHistory.isLinesCommentedInARow()
                ) {
                    commentsHistory.clear()
                    return createSuggestion()
                }
            }
        }
        return NoSuggestion
    }