use of org.sonar.java.resolve.JavaSymbol.MethodJavaSymbol in project sonar-java by SonarSource.
the class ThreadAsRunnableArgumentCheck method visitNode.
@Override
public void visitNode(Tree tree) {
if (!hasSemantic()) {
return;
}
List<ExpressionTree> arguments;
Symbol methodSymbol;
if (tree.is(Kind.NEW_CLASS)) {
NewClassTree nct = (NewClassTree) tree;
methodSymbol = nct.constructorSymbol();
arguments = nct.arguments();
} else {
MethodInvocationTree mit = (MethodInvocationTree) tree;
methodSymbol = mit.symbol();
arguments = mit.arguments();
}
if (!arguments.isEmpty() && methodSymbol.isMethodSymbol()) {
checkArgumentsTypes(arguments, (MethodJavaSymbol) methodSymbol);
}
}
use of org.sonar.java.resolve.JavaSymbol.MethodJavaSymbol in project sonar-java by SonarSource.
the class GenericsTest method test_method_resolution_with_unchecked_conversions.
@Test
public void test_method_resolution_with_unchecked_conversions() {
// JLS8 5.1.9 + JLS8 15.12.2.6
JavaType bType = (JavaType) declaredTypesFromFile("src/test/files/resolve/UncheckedConversion.java").get(0);
MethodJavaSymbol foo = getMethodSymbol(bType, "foo");
Type type = getMethodInvocationType(foo, 0);
assertThat(type.isArray()).isTrue();
assertThat(((ArrayJavaType) type).elementType.is("java.lang.Object")).isTrue();
type = getMethodInvocationType(foo, 1);
assertThat(type.isArray()).isTrue();
assertThat(((ArrayJavaType) type).elementType.is("org.foo.A")).isTrue();
type = getMethodInvocationType(foo, 2);
assertThat(type.isArray()).isTrue();
assertThat(((ArrayJavaType) type).elementType.is("org.foo.A")).isTrue();
methodHasUsagesWithSameTypeAs(bType, "bar", "objectType", "aType", "aType");
methodHasUsagesWithSameTypeAs(bType, "qix", "bRawType", "bAType", "bAType");
methodHasUsagesWithSameTypeAs(bType, "gul", "bRawType", "bBAType", "bBAType");
methodHasUsagesWithSameTypeAs(bType, "lot", "aType", "cType", "cType");
}
Aggregations