<commit_before>package org.jetbrains.plugins.groovy.lang.completion;

import com.intellij.codeInsight.lookup.CharFilter;
import com.intellij.codeInsight.lookup.Lookup;
import org.jetbrains.annotations.Nullable;
import org.jetbrains.plugins.groovy.GroovyFileType;

/**
 * @author ilyas
 */
public class GroovyReferenceCharFilter extends CharFilter {
  @Nullable
  public Result acceptChar(char c, int pefixLength, Lookup lookup) {
    if (!lookup.getPsiFile().getViewProvider().getLanguages().contains(GroovyFileType.GROOVY_LANGUAGE)) return null;

    if (Character.isJavaIdentifierPart(c) || c == '\'') {
      return Result.ADD_TO_PREFIX;
    } else if (c == '\n' || c == '\t') {
      return Result.SELECT_ITEM_AND_FINISH_LOOKUP;
    }
    switch (c) {
      case '.':
      case ',':
      case ';':
      case '=':
      case ' ':
      case ':':
      case '(':
        return Result.SELECT_ITEM_AND_FINISH_LOOKUP;

      default:
        return Result.HIDE_LOOKUP;
    }
  }

}<commit_msg>IDEADEV-22181 Type completion in JSP can loose all suggestions if package is completed<commit_after>package org.jetbrains.plugins.groovy.lang.completion;

import com.intellij.codeInsight.lookup.CharFilter;
import com.intellij.codeInsight.lookup.Lookup;
import org.jetbrains.annotations.Nullable;
import org.jetbrains.plugins.groovy.GroovyFileType;

/**
 * @author ilyas
 */
public class GroovyReferenceCharFilter extends CharFilter {
  @Nullable
  public Result acceptChar(char c, int pefixLength, Lookup lookup) {
    if (!lookup.getPsiFile().getViewProvider().getLanguages().contains(GroovyFileType.GROOVY_LANGUAGE)) return null;

    if (Character.isJavaIdentifierPart(c) || c == '\'') {
      return Result.ADD_TO_PREFIX;
    }
    if (c == '\n' || c == '\t') {
      return Result.SELECT_ITEM_AND_FINISH_LOOKUP;
    }

    return null;
  }

}
{'fraction_non_alphanumeric': 0.12479652740097667, 'fraction_numerical': 0.0027129679869777536, 'mean_word_length': 3.752577319587629, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, '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': '4745215', 'n_tokens_mistral': 631, 'n_tokens_neox': 595, 'n_words': 113}