Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -178,6 +178,14 @@ private void formatMethodSignature(MethodSignature methodSignature) {
+ " "
+ symInfo.getDisplayName())
.collect(Collectors.joining(", ", "(", ")")));

if (!methodSignature.getThrowsList().isEmpty()) {
printKeyword(" throws");
s.append(
methodSignature.getThrowsList().stream()
.map(this::formatType)
.collect(Collectors.joining(", ")));
}
}

private void formatValueSignature(ValueSignature valueSignature) {
Expand Down
1 change: 1 addition & 0 deletions semanticdb-java/src/main/protobuf/semanticdb.proto
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,7 @@ message MethodSignature {
Scope type_parameters = 1;
repeated Scope parameter_lists = 2;
Type return_type = 3;
repeated Type throws = 4;
}

message TypeSignature {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
import javax.lang.model.element.Element;
import javax.lang.model.type.*;
import java.util.List;
import java.util.stream.Collectors;

import static com.sourcegraph.semanticdb_javac.SemanticdbTypeVisitor.UNRESOLVED_TYPE_REF;

Expand Down Expand Up @@ -73,6 +74,10 @@ private Signature generateMethodSignature(Symbol.MethodSymbol sym) {
builder.setReturnType(returnType);
}

List<Semanticdb.Type> thrownTypes =
sym.getThrownTypes().stream().map(this::generateType).collect(Collectors.toList());
builder.addAllThrows(thrownTypes);

return Signature.newBuilder().setMethodSignature(builder).build();
}

Expand Down
2 changes: 1 addition & 1 deletion tests/minimized/src/main/java/minimized/Methods.java
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ private static String staticOverload(String value) {
return value + "1";
}

public static String app(int n, String m) {
public static String app(int n, String m) throws RuntimeException, IndexOutOfBoundsException {
Methods methods = new Methods();
int a = staticOverload(n);
String b = staticOverload(m);
Expand Down
6 changes: 4 additions & 2 deletions tests/snapshots/src/main/generated/minimized/Methods.java
Original file line number Diff line number Diff line change
Expand Up @@ -35,12 +35,14 @@ private static String staticOverload(String value) {
// ^^^^^ reference local3
}

public static String app(int n, String m) {
public static String app(int n, String m) throws RuntimeException, IndexOutOfBoundsException {
// ^^^^^^ reference java/lang/String#
// ^^^ definition minimized/Methods#app(). public static String app(int n, String m)
// ^^^ definition minimized/Methods#app(). public static String app(int n, String m) throws RuntimeException, IndexOutOfBoundsException
// ^ definition local4 int n
// ^^^^^^ reference java/lang/String#
// ^ definition local5 String m
// ^^^^^^^^^^^^^^^^ reference java/lang/RuntimeException#
// ^^^^^^^^^^^^^^^^^^^^^^^^^ reference java/lang/IndexOutOfBoundsException#
Methods methods = new Methods();
// ^^^^^^^ reference minimized/Methods#
// ^^^^^^^ definition local6 Methods methods
Expand Down