in src/main/java/software/amazon/smithy/lsp/SmithyTextDocumentService.java [108:149]
private String findToken(String path, Position p) throws IOException {
List<String> contents;
if (Utils.isSmithyJarFile(path)) {
contents = Utils.jarFileContents(path, this.getClass().getClassLoader());
} else {
contents = readAll(new File(URI.create(path)));
}
String line = contents.get(p.getLine());
Integer col = p.getCharacter();
String before = line.substring(0, col);
String after = line.substring(col, line.length());
StringBuilder beforeAcc = new StringBuilder();
StringBuilder afterAcc = new StringBuilder();
int idx = 0;
while (idx < after.length()) {
if (Character.isLetterOrDigit(after.charAt(idx))) {
afterAcc.append(after.charAt(idx));
idx = idx + 1;
} else {
idx = after.length();
}
}
idx = before.length() - 1;
while (idx > 0) {
char c = before.charAt(idx);
if (Character.isLetterOrDigit(c)) {
beforeAcc.append(c);
idx = idx - 1;
} else {
idx = 0;
}
}
return beforeAcc.reverse().append(afterAcc).toString();
}