mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-09-27 10:03:11 +07:00
[java-parser] IDEA-332589 Support when as identifier in patterns
- fix global check for unused types directly GitOrigin-RevId: c6efa64aa9f8c98ee8b7a3cfca18a886dbe8fdc3
This commit is contained in:
committed by
intellij-monorepo-bot
parent
dced7d86d0
commit
2f980484c8
@@ -5,6 +5,7 @@ import com.intellij.lang.java.lexer.BasicJavaLexer;
|
||||
import com.intellij.lang.java.parser.BasicJavaParser;
|
||||
import com.intellij.openapi.application.ex.PathManagerEx;
|
||||
import com.intellij.openapi.util.io.FileUtil;
|
||||
import com.intellij.openapi.util.text.StringUtil;
|
||||
import com.intellij.openapi.util.text.Strings;
|
||||
import com.intellij.psi.impl.source.AbstractBasicJavaDocElementTypeFactory;
|
||||
import com.intellij.psi.impl.source.AbstractBasicJavaElementTypeFactory;
|
||||
@@ -70,16 +71,24 @@ public class FrontBackElementTypeTest extends AbstractBasicJavaParsingTestCase {
|
||||
|
||||
private static void checkContains(String pathToCheck, String target) throws IOException {
|
||||
List<Path> paths = Files.walk(Paths.get(pathToCheck).normalize())
|
||||
.filter( Files::isRegularFile)
|
||||
.filter(Files::isRegularFile)
|
||||
.toList();
|
||||
for (Path path : paths) {
|
||||
//exclude, because element types can be used there
|
||||
if (path.toString().endsWith("ThinJavaParserUtil.java")) {
|
||||
if (path.toString().endsWith("BasicJavaParserUtil.java")) {
|
||||
continue;
|
||||
}
|
||||
String content = FileUtil.loadFile(path.toFile());
|
||||
if (content.contains(target)) {
|
||||
Assert.fail("Probably, file: " + path + " contains reference to " + target);
|
||||
int start = 0;
|
||||
int find = content.indexOf(target, start);
|
||||
while (find != -1) {
|
||||
if (find == 0) {
|
||||
Assert.fail("Probably, file: " + path + " contains reference to " + target);
|
||||
}
|
||||
if (!StringUtil.isLatinAlphanumeric(String.valueOf(content.charAt(find - 1)))) {
|
||||
Assert.fail("Probably, file: " + path + " contains reference to " + target);
|
||||
}
|
||||
find = content.indexOf(target, find + 1);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user