in old/dekaf-core/src/main/java/org/jetbrains/dekaf/sql/SqlScriptBuilder.java [67:110]
static String extractEssentialWords(@NotNull final TextWalker walker, int limitWords) {
TextWalker w = walker.clone();
StringBuilder b = new StringBuilder(40);
int wordsCnt = 0;
boolean inWord = false;
boolean inSingleLineComment = false;
boolean inMultiLineComment = false;
while (!w.isEOT()) {
char c = w.getChar();
char c2 = w.getNextChar();
final boolean isWordChar = Character.isJavaIdentifierPart(c);
if (inSingleLineComment) {
if (c == '\n') inSingleLineComment = false;
}
else if (inMultiLineComment) {
if (c == '*' && c2 == '/') {
w.next(); // additional w.next() - because 2 chars
inMultiLineComment = false;
}
}
else if (inWord && !isWordChar) {
wordsCnt++;
if (wordsCnt >= limitWords) break;
b.append(' ');
inWord = false;
}
else if (isWordChar) {
b.append(Character.toLowerCase(c));
inWord = true;
}
else if (!isWordChar) {
if (c == '-' && c2 == '-') {
inSingleLineComment = true;
w.next();
}
if (c == '/' && c2 == '*') {
inMultiLineComment = true;
w.next();
}
}
w.next();
}
return b.toString().trim();
}