use of org.sonar.java.bytecode.loader.SquidClassLoader in project sonar-java by SonarSource.
the class VariableReadExtractorTest method buildMethodTree.
private static MethodTree buildMethodTree(String methodCode) {
CompilationUnitTree cut = (CompilationUnitTree) PARSER.parse("class A { int field1; int field2; " + methodCode + " }");
SemanticModel.createFor(cut, new SquidClassLoader(Collections.emptyList()));
return (MethodTree) ((ClassTree) cut.types().get(0)).members().get(2);
}
use of org.sonar.java.bytecode.loader.SquidClassLoader in project sonar-java by SonarSource.
the class MethodTreeImplTest method createTree.
private CompilationUnitTree createTree(String code) {
CompilationUnitTree compilationUnitTree = (CompilationUnitTree) p.parse(code);
SemanticModel.createFor(compilationUnitTree, new SquidClassLoader(Collections.emptyList()));
return compilationUnitTree;
}
use of org.sonar.java.bytecode.loader.SquidClassLoader in project sonar-java by SonarSource.
the class OpensDirectiveTreeImplTest method createTree.
private CompilationUnitTree createTree(String... lines) {
CompilationUnitTree compilationUnitTree = (CompilationUnitTree) p.parse(Arrays.stream(lines).collect(Collectors.joining("\n")));
SemanticModel.createFor(compilationUnitTree, new SquidClassLoader(Collections.emptyList()));
return compilationUnitTree;
}
use of org.sonar.java.bytecode.loader.SquidClassLoader in project sonar-java by SonarSource.
the class ReassignmentFinderTest method classTree.
private ClassTree classTree(String classBody) {
CompilationUnitTree compilationUnitTree = (CompilationUnitTree) p.parse(classBody);
SemanticModel.createFor(compilationUnitTree, new SquidClassLoader(Collections.emptyList()));
return (ClassTree) compilationUnitTree.types().get(0);
}
use of org.sonar.java.bytecode.loader.SquidClassLoader in project sonar-java by SonarSource.
the class ValueBasedUtilsTest method testIsValueBased.
@Test
public void testIsValueBased() throws Exception {
File file = new File("src/test/files/checks/helpers/ValueBasedUtilsTest.java");
CompilationUnitTree tree = (CompilationUnitTree) JavaParser.createParser().parse(file);
SemanticModel.createFor(tree, new SquidClassLoader(Collections.emptyList()));
List<Tree> members = ((ClassTree) tree.types().get(0)).members();
members.stream().forEach(member -> checkMember((VariableTree) member));
}
Aggregations