<commit_before>package org.jetbrains.plugins.scala.lang.folding

import _root_.scala.collection.mutable._

import java.util.ArrayList;
import com.intellij.lang.ASTNode;
import com.intellij.lang.folding.FoldingBuilder;
import com.intellij.lang.folding.FoldingDescriptor;
import com.intellij.openapi.editor.Document;
import com.intellij.psi.tree.IElementType;
import org.jetbrains.plugins.scala.lang.lexer.ScalaTokenTypes;
import org.jetbrains.plugins.scala.lang.parser.ScalaElementTypes;

/*
*
@author <NAME>
*
*/

class ScalaFoldingBuilder extends FoldingBuilder {


  private def appendDescriptors(node: ASTNode,
          document: Document,
          descriptors: ListBuffer[FoldingDescriptor]): Unit = {

    node.getElementType match {
      case ScalaElementTypes.BLOCK_EXPR |
      ScalaElementTypes.INFIX_EXPR |
      ScalaElementTypes.AN_FUN |
      ScalaElementTypes.PREFIX_EXPR |
      ScalaElementTypes.POSTFIX_EXPR |
      ScalaElementTypes.SIMPLE_EXPR |
      ScalaElementTypes.IF_STMT |
      ScalaElementTypes.FOR_STMT |
      ScalaElementTypes.WHILE_STMT |
      ScalaElementTypes.DO_STMT |
      ScalaElementTypes.TRY_STMT |
      ScalaElementTypes.RETURN_STMT |
      ScalaElementTypes.METHOD_CLOSURE |
      ScalaElementTypes.THROW_STMT |
      ScalaElementTypes.ASSIGN_STMT |
      ScalaElementTypes.MATCH_STMT |
      ScalaElementTypes.TYPED_EXPR_STMT if
        (ScalaElementTypes.FUNCTION_DEFINITION.equals(node.getTreeParent().getElementType)) => {
        descriptors += (new FoldingDescriptor(node, node.getTextRange()))
      }
      case ScalaTokenTypes.tCOMMENT_CONTENT => {
        descriptors += (new FoldingDescriptor(node, node.getTextRange()))
      }
      case _ => {}
    }

    var child = node.getFirstChildNode()
    while (child != null) {
      appendDescriptors(child, document, descriptors)
      child = child.getTreeNext()
    }
  }

  def buildFoldRegions(astNode: ASTNode, document: Document): Array[FoldingDescriptor] = {
    var descriptors = new ListBuffer[FoldingDescriptor]
    appendDescriptors(astNode, document, descriptors);
    descriptors.toList.toArray
  }

  def getPlaceholderText(node: ASTNode): String = {
    node.getElementType match {
      case ScalaElementTypes.BLOCK_EXPR |
      ScalaElementTypes.INFIX_EXPR |
      ScalaElementTypes.AN_FUN |
      ScalaElementTypes.PREFIX_EXPR |
      ScalaElementTypes.POSTFIX_EXPR |
      ScalaElementTypes.SIMPLE_EXPR |
      ScalaElementTypes.IF_STMT |
      ScalaElementTypes.FOR_STMT |
      ScalaElementTypes.WHILE_STMT |<commit_msg>Failed commit: Default (31)<commit_after>package org.jetbrains.plugins.scala.lang.folding

import _root_.scala.collection.mutable._

import java.util.ArrayList;
import com.intellij.lang.ASTNode;
import com.intellij.lang.folding.FoldingBuilder;
import com.intellij.lang.folding.FoldingDescriptor;
import com.intellij.openapi.editor.Document;
import com.intellij.psi.tree.IElementType;
import org.jetbrains.plugins.scala.lang.lexer.ScalaTokenTypes;
import org.jetbrains.plugins.scala.lang.parser.ScalaElementTypes;

/*
*
@author <NAME>
*
*/

class ScalaFoldingBuilder extends FoldingBuilder {


  private def appendDescriptors(node: ASTNode,
          document: Document,
          descriptors: ListBuffer[FoldingDescriptor]): Unit = {

    node.getElementType match {
      case ScalaElementTypes.BLOCK_EXPR |
      ScalaElementTypes.INFIX_EXPR |
      ScalaElementTypes.AN_FUN |
      ScalaElementTypes.PREFIX_EXPR |
      ScalaElementTypes.POSTFIX_EXPR |
      ScalaElementTypes.SIMPLE_EXPR |
      ScalaElementTypes.IF_STMT |
      ScalaElementTypes.FOR_STMT |
      ScalaElementTypes.WHILE_STMT |
      ScalaElementTypes.DO_STMT |
      ScalaElementTypes.TRY_STMT |
      ScalaElementTypes.RETURN_STMT |
      ScalaElementTypes.METHOD_CLOSURE |
      ScalaElementTypes.THROW_STMT |
      ScalaElementTypes.ASSIGN_STMT |
      ScalaElementTypes.MATCH_STMT |
      ScalaElementTypes.TYPED_EXPR_STMT if
        (ScalaElementTypes.FUNCTION_DEFINITION.equals(node.getTreeParent().getElementType)) => {
        descriptors += (new FoldingDescriptor(node, node.getTextRange()))
      }
      case ScalaTokenTypes.tCOMMENT_CONTENT if {
        node.getText.substring(0, 3).equals("/**") &&
        (node.getText.contains('\n') || node.getText.contains('\r'))
      } => {
        descriptors += (new FoldingDescriptor(node, node.getTextRange()))
      }
      case _ => {}
    }

    var child = node.getFirstChildNode()
    while (child != null) {
      appendDescriptors(child, document, descriptors)
      child = child.getTreeNext()
    }
  }

  def buildFoldRegions(astNode: ASTNode, document: Document): Array[FoldingDescriptor] = {
    var descriptors = new ListBuffer[FoldingDescriptor]
    appendDescriptors(astNode, document, descriptors);
    descriptors.toList.toArray
  }

  def getPlaceholderText(node: ASTNode): String = {
    node.getElementType match {
      case ScalaElementTypes.BLOCK_EXPR |
      ScalaElementTypes.INFIX_EXPR |
      ScalaElementTypes.AN_FUN |
      ScalaElementTypes.PREFIX_EXPR |
      ScalaElementTypes.POSTFIX_EXPR |
      ScalaElementTypes.SIMPLE_EXPR |
      ScalaElementTypes.IF_STMT |
      ScalaElementTypes.FOR_STMT |
      ScalaElementTypes.WHILE_STMT |
{'fraction_non_alphanumeric': 0.09115179252479023, 'fraction_numerical': 0.0007627765064836003, 'mean_word_length': 3.6539485359361135, 'pattern_counts': {'":': 0, '<': 5, '<?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': 1, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '830639', 'n_tokens_mistral': 1681, 'n_tokens_neox': 1649, 'n_words': 226}