The dependency is tighter than just the branch; you would need a different case in that if chain for every patch release of the compiler you want to support building with, and if you wanted to use a nightly build of the compiler, you would need a corresponding swift-format and swift-syntax tag for that toolchain, and possibly #if
in the code itself any time there is an API break. Quoting myself
Swift-syntax has an unstable dependency on
lib_InternalSwiftSyntaxParser
from the toolchain. Currently, you must use an identical tag of swift-syntax and the parser library. At the same time, the Swift API of swift-syntax is not API-stable. This means that if we use main branch of swift-format/swift-syntax, we cannot use it without building the whole toolchain from source. Alternatively, if we used the latest released tag version we would always be a full release behind any syntax changes to the language, and we would open ourselves up to incompatibility between what happens in a development build, and what happens when building the toolchain for swift.org.
The reason a binary dependency helps here is that during development we can use a parser library that is not part of the user's toolchain, decoupling the compiler you use to build sourcekit-lsp and the swift-syntax that you are using. At the same time, we could keep the dependency on swift-syntax/swift-format as up-to-date as possible, which avoids compatibility issues between what is being developed and what will end up in the toolchain in swift ci.