<commit_before>package de.endrullis.idea.postfixtemplates.languages.scala;

import com.intellij.codeInsight.template.Template;
import com.intellij.openapi.editor.Editor;
import com.intellij.openapi.util.Condition;
import com.intellij.psi.PsiElement;
import com.intellij.util.containers.OrderedSet;
import de.endrullis.idea.postfixtemplates.templates.MyVariable;
import de.endrullis.idea.postfixtemplates.templates.NavigatablePostfixTemplate;
import de.endrullis.idea.postfixtemplates.templates.SpecialType;
import lombok.val;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
import org.jetbrains.plugins.scala.lang.completion.postfix.templates.ScalaStringBasedPostfixTemplate;
import org.jetbrains.plugins.scala.lang.completion.postfix.templates.selector.AncestorSelector;
import org.jetbrains.plugins.scala.lang.psi.ScImportsHolder;

import java.util.*;
import java.util.regex.Pattern;
import java.util.stream.Collectors;

import static de.endrullis.idea.postfixtemplates.languages.java.CustomJavaStringPostfixTemplate.withProjectClassCondition;
import static de.endrullis.idea.postfixtemplates.languages.scala.ScalaPostfixTemplatesUtils.*;
import static de.endrullis.idea.postfixtemplates.templates.CustomPostfixTemplateUtils.parseVariables;
import static de.endrullis.idea.postfixtemplates.templates.CustomPostfixTemplateUtils.removeVariableValues;
import static de.endrullis.idea.postfixtemplates.templates.SimpleStringBasedPostfixTemplate.addVariablesToTemplate;
import static de.endrullis.idea.postfixtemplates.settings.CustomPostfixTemplates.PREDEFINED_VARIABLES;

/**
 * Custom postfix template for Scala.
 *
 * @author <NAME> &lt;<EMAIL>&gt;
 */
@SuppressWarnings("WeakerAccess")
public class CustomScalaStringPostfixTemplate extends ScalaStringBasedPostfixTemplate implements NavigatablePostfixTemplate {

	static final Pattern IMPORT_PATTERN = Pattern.compile("\\[IMPORT ([^\\]]+)\\]");

	private static final Map<String, Condition<PsiElement>> type2psiCondition = new HashMap<>() {{
		put(SpecialType.ANY.name(), e -> true);
		put(SpecialType.VOID.name(), VOID);
		put(SpecialType.NON_VOID.name(), NON_VOID);
		//put(SpecialType.ARRAY.name(), IS_ARRAY);
		put(SpecialType.BOOLEAN.name(), BOOLEAN);
		//put(SpecialType.ITERABLE_OR_ARRAY.name(), IS_ITERABLE_OR_ARRAY);
		put(SpecialType.NUMBER.name(), DECIMAL_NUMBER);
		put(SpecialType.BYTE.name(), BYTE);
		put(SpecialType.SHORT.name(), SHORT);
		put(SpecialType.CHAR.name(), CHAR);
		put(SpecialType.INT.name(), INT);
		put(SpecialType.LONG.name(), LONG);
		put(SpecialType.FLOAT.name(), FLOAT);
		put(SpecialType.DOUBLE.name(), DOUBLE);
		/*
		put(SpecialType.BYTE_LITERAL.name(), isCertainNumberLiteral(PsiType.BYTE));
		put(SpecialType.SHORT_LITERAL.name(), isCertainNumberLiteral(PsiType.SHORT));
		put(SpecialType.CHAR_LITERAL.name(), isCertainNumberLiteral(PsiType.CHAR));
		put(SpecialType.INT_LITERAL.name(), isCertainNumberLiteral(PsiType.INT));
		put(SpecialType.LONG_LITERAL.name(), isCertainNumberLiteral(PsiType.LONG));
		put(SpecialType.FLOAT_LITERAL.name(), isCertainNumberLiteral(PsiType.FLOAT));<commit_msg>Changed to explicit types, due to rollback to java 8<commit_after>package de.endrullis.idea.postfixtemplates.languages.scala;

import com.intellij.codeInsight.template.Template;
import com.intellij.openapi.editor.Editor;
import com.intellij.openapi.util.Condition;
import com.intellij.psi.PsiElement;
import com.intellij.util.containers.OrderedSet;
import de.endrullis.idea.postfixtemplates.templates.MyVariable;
import de.endrullis.idea.postfixtemplates.templates.NavigatablePostfixTemplate;
import de.endrullis.idea.postfixtemplates.templates.SpecialType;
import lombok.val;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
import org.jetbrains.plugins.scala.lang.completion.postfix.templates.ScalaStringBasedPostfixTemplate;
import org.jetbrains.plugins.scala.lang.completion.postfix.templates.selector.AncestorSelector;
import org.jetbrains.plugins.scala.lang.psi.ScImportsHolder;

import java.util.*;
import java.util.regex.Pattern;
import java.util.stream.Collectors;

import static de.endrullis.idea.postfixtemplates.languages.java.CustomJavaStringPostfixTemplate.withProjectClassCondition;
import static de.endrullis.idea.postfixtemplates.languages.scala.ScalaPostfixTemplatesUtils.*;
import static de.endrullis.idea.postfixtemplates.templates.CustomPostfixTemplateUtils.parseVariables;
import static de.endrullis.idea.postfixtemplates.templates.CustomPostfixTemplateUtils.removeVariableValues;
import static de.endrullis.idea.postfixtemplates.templates.SimpleStringBasedPostfixTemplate.addVariablesToTemplate;
import static de.endrullis.idea.postfixtemplates.settings.CustomPostfixTemplates.PREDEFINED_VARIABLES;

/**
 * Custom postfix template for Scala.
 *
 * @author <NAME> &lt;<EMAIL>&gt;
 */
@SuppressWarnings("WeakerAccess")
public class CustomScalaStringPostfixTemplate extends ScalaStringBasedPostfixTemplate implements NavigatablePostfixTemplate {

	static final Pattern IMPORT_PATTERN = Pattern.compile("\\[IMPORT ([^\\]]+)\\]");

	private static final Map<String, Condition<PsiElement>> type2psiCondition = new HashMap<String, Condition<PsiElement>>() {{
		put(SpecialType.ANY.name(), e -> true);
		put(SpecialType.VOID.name(), VOID);
		put(SpecialType.NON_VOID.name(), NON_VOID);
		//put(SpecialType.ARRAY.name(), IS_ARRAY);
		put(SpecialType.BOOLEAN.name(), BOOLEAN);
		//put(SpecialType.ITERABLE_OR_ARRAY.name(), IS_ITERABLE_OR_ARRAY);
		put(SpecialType.NUMBER.name(), DECIMAL_NUMBER);
		put(SpecialType.BYTE.name(), BYTE);
		put(SpecialType.SHORT.name(), SHORT);
		put(SpecialType.CHAR.name(), CHAR);
		put(SpecialType.INT.name(), INT);
		put(SpecialType.LONG.name(), LONG);
		put(SpecialType.FLOAT.name(), FLOAT);
		put(SpecialType.DOUBLE.name(), DOUBLE);
		/*
		put(SpecialType.BYTE_LITERAL.name(), isCertainNumberLiteral(PsiType.BYTE));
		put(SpecialType.SHORT_LITERAL.name(), isCertainNumberLiteral(PsiType.SHORT));
		put(SpecialType.CHAR_LITERAL.name(), isCertainNumberLiteral(PsiType.CHAR));
		put(SpecialType.INT_LITERAL.name(), isCertainNumberLiteral(PsiType.INT));
		put(SpecialType.LONG_LITERAL.name(), isCertainNumberLiteral(PsiType.LONG));
		put(SpecialType.FLOAT_LITERAL.name(), isCertainNumberLiteral(PsiType.FLOAT));
{'fraction_non_alphanumeric': 0.12353500158378207, 'fraction_numerical': 0.0004751346214760849, 'mean_word_length': 7.499327052489906, 'pattern_counts': {'":': 0, '<': 14, '<?xml version=': 0, '>': 16, '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': '2502541', 'n_tokens_mistral': 2094, 'n_tokens_neox': 2030, 'n_words': 257}