<commit_before>package org.intellij.plugins.hcl.psi.impl

import com.intellij.icons.AllIcons
import com.intellij.navigation.ItemPresentation
import com.intellij.openapi.util.Key
import com.intellij.openapi.util.Pair
import com.intellij.openapi.util.TextRange
import com.intellij.openapi.util.text.StringUtil
import com.intellij.psi.PsiElement
import com.intellij.psi.util.PsiTreeUtil
import com.intellij.util.ArrayUtil
import com.intellij.util.PlatformIcons
import com.intellij.util.SmartList
import org.intellij.plugins.hcl.HCLParserDefinition
import org.intellij.plugins.hcl.psi.*

import javax.swing.*
import java.util.ArrayList
import java.util.Collections

public object HCLPsiImplUtils {
  public fun getName(property: HCLProperty): String {
    return StringUtil.unescapeStringCharacters(HCLPsiUtil.stripQuotes(property.getNameElement().getText()))
  }

  public fun getName(block: HCLBlock): String {
    val elements = block.getNameElements()
    val sb = StringBuilder()
    for (element in elements) {
      sb.append(StringUtil.unescapeStringCharacters(HCLPsiUtil.stripQuotes(element.getText()))).append(' ')
    }
    return sb.toString().trim()
  }

  /**
   * Actually only JSON string literal should be accepted as valid name of property according to standard,
   * but for compatibility with JavaScript integration any JSON literals as well as identifiers (unquoted words)
   * are possible and highlighted as error later.

   * @see HCLStandardComplianceInspection
   */
  public fun getNameElement(property: HCLProperty): HCLValue {
    val firstChild = property.getFirstChild()
    assert(firstChild is HCLLiteral || firstChild is HCLIdentifier)
    return firstChild as HCLValue
  }

  public fun getNameElements(block: HCLBlock): Array<HCLElement> {
    var result: MutableList<HCLElement>? = null
    var child: PsiElement? = block.getFirstChild()
    while (child != null) {
      if ((child is HCLIdentifier || child is HCLLiteral)) {
        if (result == null) result = SmartList<HCLElement>()
        //noinspection unchecked
        result.add(child as HCLElement)
      }
      child = child.getNextSibling()
    }
    return if (result == null) arrayOfNulls<HCLElement>(0) else ArrayUtil.toObjectArray<HCLElement>(result, javaClass<HCLElement>())
  }
<commit_msg>Fix compilation<commit_after>package org.intellij.plugins.hcl.psi.impl

import com.intellij.icons.AllIcons
import com.intellij.navigation.ItemPresentation
import com.intellij.openapi.util.Key
import com.intellij.openapi.util.Pair
import com.intellij.openapi.util.TextRange
import com.intellij.openapi.util.text.StringUtil
import com.intellij.psi.PsiElement
import com.intellij.psi.util.PsiTreeUtil
import com.intellij.util.ArrayUtil
import com.intellij.util.PlatformIcons
import com.intellij.util.SmartList
import org.intellij.plugins.hcl.HCLParserDefinition
import org.intellij.plugins.hcl.psi.*

import javax.swing.*
import java.util.ArrayList
import java.util.Collections

public object HCLPsiImplUtils {
  public fun getName(property: HCLProperty): String {
    return StringUtil.unescapeStringCharacters(HCLPsiUtil.stripQuotes(property.getNameElement().getText()))
  }

  public fun getName(block: HCLBlock): String {
    val elements = block.getNameElements()
    val sb = StringBuilder()
    for (element in elements) {
      sb.append(StringUtil.unescapeStringCharacters(HCLPsiUtil.stripQuotes(element.getText()))).append(' ')
    }
    return sb.toString().trim()
  }

  /**
   * Actually only JSON string literal should be accepted as valid name of property according to standard,
   * but for compatibility with JavaScript integration any JSON literals as well as identifiers (unquoted words)
   * are possible and highlighted as error later.

   * @see HCLStandardComplianceInspection
   */
  public fun getNameElement(property: HCLProperty): HCLValue {
    val firstChild = property.getFirstChild()
    assert(firstChild is HCLLiteral || firstChild is HCLIdentifier)
    return firstChild as HCLValue
  }

  public fun getNameElements(block: HCLBlock): Array<HCLElement> {
    var result: MutableList<HCLElement>? = null
    var child: PsiElement? = block.getFirstChild()
    while (child != null) {
      if ((child is HCLIdentifier || child is HCLLiteral)) {
        if (result == null) result = SmartList<HCLElement>()
        //noinspection unchecked
        result.add(child as HCLElement)
      }
      child = child.getNextSibling()
    }
    return if (result == null) emptyArray<HCLElement>() else ArrayUtil.toObjectArray<HCLElement>(result, javaClass<HCLElement>())
  }

{'fraction_non_alphanumeric': 0.09592326139088729, 'fraction_numerical': 0.00021800741225201656, 'mean_word_length': 4.423167848699763, 'pattern_counts': {'":': 0, '<': 15, '<?xml version=': 0, '>': 15, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '11310', 'n_tokens_mistral': 1376, 'n_tokens_neox': 1373, 'n_words': 327}