2929import org .sonar .plugins .java .api .IssuableSubscriptionVisitor ;
3030import org .sonar .plugins .java .api .JavaFileScanner ;
3131import org .sonar .plugins .java .api .JavaFileScannerContext ;
32- import org .sonar .plugins .java .api .tree .ClassTree ;
3332import org .sonar .plugins .java .api .tree .CompilationUnitTree ;
34- import org .sonar .plugins .java .api .tree .MethodTree ;
3533import org .sonar .plugins .java .api .tree .Tree ;
3634import org .sonar .plugins .java .api .tree .Tree .Kind ;
3735import org .sonar .squidbridge .api .SourceProject ;
3836
3937import javax .annotation .Nullable ;
40-
4138import java .io .File ;
4239import java .util .Collections ;
4340import java .util .List ;
@@ -63,35 +60,6 @@ public void scanFile(JavaFileScannerContext context) {
6360 checkFile (contstructFileName ("home" , "user" , "oracleSdk" , "java" , "lang" , "someFile.java" ), "package java.lang; class A {}" , visitorsBridgeWithoutSemantic );
6461 checkFile (contstructFileName ("java" , "io" , "Serializable.java" ), "package java.io; class A {}" , visitorsBridgeWithoutSemantic );
6562 checkFile (contstructFileName ("java" , "lang" , "annotation" , "Annotation.java" ), "package java.lang.annotation; class Annotation {}" , visitorsBridgeWithoutSemantic );
66- InternalVisitorsBridge visitorsBridgeWithSemantic = new InternalVisitorsBridge (Collections .singletonList (new IssuableSubscriptionVisitor () {
67- public ClassTree enclosingClass ;
68-
69- @ Override
70- public List <Tree .Kind > nodesToVisit () {
71- return ImmutableList .of (Tree .Kind .CLASS , Tree .Kind .METHOD );
72- }
73-
74- @ Override
75- public void scanFile (JavaFileScannerContext context ) {
76- assertThat (context .getSemanticModel ()).isNotNull ();
77- assertThat (context .fileParsed ()).isTrue ();
78- super .scanFile (context );
79- }
80-
81- @ Override
82- public void visitNode (Tree tree ) {
83- if (tree .is (Tree .Kind .CLASS )) {
84- enclosingClass = (ClassTree ) tree ;
85- assertThat (context .getComplexityNodes (enclosingClass ).size ()).isEqualTo (context .getComplexity (enclosingClass ));
86- } else {
87- assertThat (context .getMethodComplexityNodes (enclosingClass , ((MethodTree ) tree )).size ()).isEqualTo (context .getMethodComplexity (enclosingClass , ((MethodTree ) tree )));
88- }
89- }
90- }), Lists .<File >newArrayList (), null );
91- visitorsBridgeWithSemantic .setContext (context );
92- checkFile (contstructFileName ("java" , "lang" , "annotation" , "Foo.java" ), "package java.lang.annotation; class Annotation {}" , visitorsBridgeWithSemantic );
93- checkFile (contstructFileName ("java" , "io" , "File.java" ), "package java.io; class A {}" , visitorsBridgeWithSemantic );
94- checkFile (contstructFileName ("src" , "foo" , "bar" , "java" , "lang" , "someFile.java" ), "package foo.bar.java.lang; class A { void method() { ; } }" , visitorsBridgeWithSemantic );
9563
9664 InternalVisitorsBridge visitorsBridgeWithParsingIssue = new InternalVisitorsBridge (Collections .singletonList (new IssuableSubscriptionVisitor () {
9765 @ Override
0 commit comments