Skip to content

Commit

Permalink
Basic implementation of ClassType and FunctionType toString
Browse files Browse the repository at this point in the history
  • Loading branch information
guillaume-dequenne-sonarsource committed May 13, 2024
1 parent 14289c7 commit 245a7f4
Show file tree
Hide file tree
Showing 4 changed files with 13 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -184,4 +184,9 @@ public boolean equals(Object o) {
public int hashCode() {
return Objects.hash(name, members, attributes, superClasses);
}

@Override
public String toString() {
return "ClassType[%s]".formatted(name);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -70,4 +70,10 @@ public Optional<LocationInFile> definitionLocation() {
public int hashCode() {
return Objects.hash(name, attributes, parameters, returnType, isAsynchronous, hasDecorators, isInstanceMethod, hasVariadicParameter);
}


@Override
public String toString() {
return "FunctionType[%s]".formatted(name);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,7 @@ void no_parents() {
assertThat(classType.hasUnresolvedHierarchy()).isFalse();
// TODO: not correct
assertThat(classType.key()).isEqualTo("C[]");
assertThat(classType).hasToString("ClassType[C]");

assertThat(classType.hasMember("__call__")).isEqualTo(TriBool.TRUE);
assertThat(classType.hasMember("unknown")).isEqualTo(TriBool.UNKNOWN);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,7 @@ void arity() {
assertThat(functionType.isAsynchronous()).isFalse();
assertThat(functionType.parameters()).isEmpty();
assertThat(functionType.displayName()).contains("Callable");
assertThat(functionType).hasToString("FunctionType[fn]");
assertThat(functionType.unwrappedType()).isEqualTo(functionType);
assertThat(functionType.instanceDisplayName()).isEmpty();
String fileId = SymbolUtils.pathOf(pythonFile).toString();
Expand Down

0 comments on commit 245a7f4

Please sign in to comment.