-
Notifications
You must be signed in to change notification settings - Fork 328
Description
When inside a function, closure, or loop, I regularly find myself wondering which control flow constructs can terminate it. To assist me with that, SourceKit-LSP should return control flow keywords that exit from the same construct in the textDocument/documentHighlight request. For example in the following, the document highlight for throw or one of the return statements should return the other two keywords that leave the function scope.
func foo(x: Int) throws -> String {
if x < 0 {
throw ValueNegativeError()
}
if x == 0 {
return "none"
} else {
return "many"
}
}The same can also apply to loops (break + continue).
To implement this, we’d likely need to implement a query in swift-syntax’s SwiftLexicalLookup library that returns the control flow construct (function, closure, loop) to which one of these statements belongs and then use that in SourceKit-LSP to compute the related control flow statements.