Rather than define `SwiftFormatInvocation::setMainExecutablePath()` and use it
in the one spot where a `SwiftFormatInvocation` is initialized, have
`SwiftFormatInvocation` take an executable path in its initializer. No
functional change, but slightly fewer lines of code.
This patch allows Parser to generate a refined token stream to satisfy tooling's need. For syntax coloring, token stream from lexer is insufficient because (1) we have contextual keywords like get and set; (2) we may allow keywords to be used as argument labels and names; and (3) we need to split tokens like "==<". In this patch, these refinements are directly fulfilled through parsing without additional heuristics. The refined token vector is optionally saved in SourceFile instance.
We would previously fail to read from stdin as we would diagnose an
error if no input files were provided. This allows us to read from
stdin once more.
Considering that formatting only affects a single compilation unit, and
that code formatting does not support line ranges yet, remove dependency
on clang::tooling::Replacement.
This fixes SR-2619.
llvm::Error's destructor has an assert in it that it was checked for success or
failure. This patch puts in a quick check for failure and emits a message to
llvm::errs() and returns failure (which in this case is indicating by returning
true).
A first class diagnostic should be added here, but given that I am preparing for
a stable merge update on a quick time schedule, I did the easy thing (with
respect to the message).
If a line range is not set, create a line range over the unsigned type,
instead of setting an arbitrary limit. We're not probably going to ever
deal with such big files, though.