void (@NotNull PsiExpression expression) { Object patternObject = ExpressionUtils.computeConstantExpression(expression); if (!(patternObject instanceof String pattern)) return; record Token(char character, int pos, int length) {} List<Token> tokens = new ArrayList<>(); int optionalDepth = 0; char[] array = pattern.toCharArray(); boolean inQuote = false; int lastQuoteIndex = 0; int length = 0; for (int pos = 0; pos < array.length; pos++) { char c = array[pos]; //process tokens if (!inQuote && isLetter(c)) { length++; if (pos != array.length - 1 && c == array[pos + 1]) { continue; } else { tokens.add(new Token(c, pos - length + 1, length)); checkPadding(expression, array, pos - length + 1, pos + 1); } } length = 0; //check if it starts quote region or one quote //case with one quote ('') is processed as quote region if (c == '\'') { inQuote = !inQuote; lastQuoteIndex = pos; continue; } //skip whole region in quote if (inQuote) { continue; } checkUnsupportedSymbolsProblem(expression, pos, c); if (c == '[') { optionalDepth++; } if (c == ']') { optionalDepth--; checkOptionalDepthProblem(expression, optionalDepth, pos); if (optionalDepth < 0) { //reset after problem optionalDepth = 0; } } } checkInQuoteProblem(expression, inQuote, lastQuoteIndex); for (Token token : tokens) { checkAvailableCount(expression, token.character, token.pos, token.length); } }