use of org.sonar.plugins.java.api.semantic.Type in project sonar-java by SonarSource.
the class CastArithmeticOperandCheck method checkMethodInvocationArgument.
private void checkMethodInvocationArgument(MethodInvocationTree mit) {
Symbol symbol = mit.symbol();
if (symbol.isMethodSymbol()) {
List<Type> parametersTypes = ((Symbol.MethodSymbol) symbol).parameterTypes();
if (mit.arguments().size() == parametersTypes.size()) {
int i = 0;
for (Type argType : parametersTypes) {
checkExpression(argType, mit.arguments().get(i));
i++;
}
}
}
}
use of org.sonar.plugins.java.api.semantic.Type in project sonar-java by SonarSource.
the class CastArithmeticOperandCheck method visitAssignmentExpression.
@Override
public void visitAssignmentExpression(AssignmentExpressionTree aet) {
if (aet.is(Tree.Kind.ASSIGNMENT)) {
Type varType = aet.symbolType();
ExpressionTree expr = aet.expression();
checkExpression(varType, expr);
}
super.visitAssignmentExpression(aet);
}
use of org.sonar.plugins.java.api.semantic.Type in project sonar-java by SonarSource.
the class BytecodeCompleterTest method class_not_found_should_have_unknown_super_type_and_no_interfaces.
@Test
public void class_not_found_should_have_unknown_super_type_and_no_interfaces() {
Symbol.TypeSymbol clazz = bytecodeCompleter.getClassSymbol("org.sonar.java.resolve.targets.UnknownClass");
assertThat(clazz.type()).isNotNull();
Type superClass = clazz.superClass();
assertThat(superClass).isNotNull();
assertThat(superClass).isSameAs(Symbols.unknownType);
List<Type> interfaces = clazz.interfaces();
assertThat(interfaces).isNotNull();
assertThat(interfaces).isEmpty();
assertThat(bytecodeCompleter.classesNotFound()).containsOnly("org.sonar.java.resolve.targets.UnknownClass");
}
use of org.sonar.plugins.java.api.semantic.Type in project sonar-java by SonarSource.
the class LeastUpperBoundTest method declaredTypes.
private static List<Type> declaredTypes(String... lines) {
CompilationUnitTree tree = treeOf(lines);
List<Type> results = Lists.newLinkedList();
for (Tree classTree : tree.types()) {
Type type = ((ClassTree) classTree).symbol().type();
results.add(type);
}
return results;
}
use of org.sonar.plugins.java.api.semantic.Type in project sonar-java by SonarSource.
the class LeastUpperBoundTest method lub_with_shared_supertypes3.
@Test
public void lub_with_shared_supertypes3() {
List<Type> typesFromInput = declaredTypes("class A extends Exception {}", "class B {}");
Type a = typesFromInput.get(0);
Type b = typesFromInput.get(1);
Type lub = leastUpperBound(a, b);
assertThat(lub.is("java.lang.Object")).isTrue();
}
Aggregations