Search in sources :

Example 6 with TypeJavaSymbol

use of org.sonar.java.resolve.JavaSymbol.TypeJavaSymbol in project sonar-java by SonarSource.

the class TypeSubstitutionSolver method applySiteSubstitutionToFormalParameters.

@VisibleForTesting
List<JavaType> applySiteSubstitutionToFormalParameters(List<JavaType> formals, JavaType site, Set<Type> visited) {
    TypeSubstitution typeSubstitution = new TypeSubstitution();
    if (site.isParameterized()) {
        typeSubstitution = ((ParametrizedTypeJavaType) site).typeSubstitution;
    }
    TypeJavaSymbol siteSymbol = site.getSymbol();
    List<JavaType> newFormals = formals;
    Type superClass = siteSymbol.superClass();
    if (superClass != null) {
        JavaType newSuperClass = applySubstitution((JavaType) superClass, typeSubstitution);
        if (visited.add(newSuperClass)) {
            newFormals = applySiteSubstitutionToFormalParameters(newFormals, newSuperClass, visited);
        }
    }
    for (Type interfaceType : siteSymbol.interfaces()) {
        JavaType newInterfaceType = applySubstitution((JavaType) interfaceType, typeSubstitution);
        if (visited.add(newInterfaceType)) {
            newFormals = applySiteSubstitutionToFormalParameters(newFormals, newInterfaceType, visited);
        }
    }
    return applySubstitutionToFormalParameters(newFormals, typeSubstitution);
}
Also used : TypeJavaSymbol(org.sonar.java.resolve.JavaSymbol.TypeJavaSymbol) Type(org.sonar.plugins.java.api.semantic.Type) VisibleForTesting(com.google.common.annotations.VisibleForTesting)

Example 7 with TypeJavaSymbol

use of org.sonar.java.resolve.JavaSymbol.TypeJavaSymbol in project sonar-java by SonarSource.

the class BytecodeCompleterTest method bridge_method_not_synthetic_should_not_be_created_as_symbol_nor_fail_analysis.

@Test
public void bridge_method_not_synthetic_should_not_be_created_as_symbol_nor_fail_analysis() throws Exception {
    TypeJavaSymbol prezModel42 = bytecodeCompleter.getClassSymbol("model42.PresentationModel42");
    prezModel42.complete();
    assertThat(prezModel42.members().lookup("setSliderMinValue")).isEmpty();
    assertThat(logTester.logs(LoggerLevel.WARN)).contains("bridge method setSliderMinValue not marked as synthetic in class model42/PresentationModel42");
}
Also used : TypeJavaSymbol(org.sonar.java.resolve.JavaSymbol.TypeJavaSymbol) Test(org.junit.Test)

Aggregations

TypeJavaSymbol (org.sonar.java.resolve.JavaSymbol.TypeJavaSymbol)7 Test (org.junit.Test)4 File (java.io.File)2 SquidClassLoader (org.sonar.java.bytecode.loader.SquidClassLoader)2 Type (org.sonar.plugins.java.api.semantic.Type)2 VisibleForTesting (com.google.common.annotations.VisibleForTesting)1