Kick JSON output for XML output.
Apparently the owners of the tools we want to integrate with (eclipse in this case) don't have JSON parsers. The output now is: <replacements> <replacement offset='2' length='3'> </replacement> ... </replacements> Kicking JSON for now - it's easy enough to get back in when we need it. FIXME: once we find this useful enough, we might want to add it as free-standing functions to tooling. llvm-svn: 174497
This commit is contained in:
parent
a80c4c1a08
commit
1882ad9905
|
@ -38,8 +38,8 @@ static cl::opt<std::string> Style(
|
||||||
static cl::opt<bool> Inplace("i",
|
static cl::opt<bool> Inplace("i",
|
||||||
cl::desc("Inplace edit <file>, if specified."));
|
cl::desc("Inplace edit <file>, if specified."));
|
||||||
|
|
||||||
static cl::opt<bool> OutputReplacements(
|
static cl::opt<bool> OutputXML(
|
||||||
"output-replacements", cl::desc("Output replacements as JSON."));
|
"output-replacements-xml", cl::desc("Output replacements as XML."));
|
||||||
|
|
||||||
// FIXME: Remove this when styles are configurable through files.
|
// FIXME: Remove this when styles are configurable through files.
|
||||||
static cl::opt<bool> InvertPointerBinding(
|
static cl::opt<bool> InvertPointerBinding(
|
||||||
|
@ -107,22 +107,17 @@ static void format() {
|
||||||
Ranges.push_back(CharSourceRange::getCharRange(Start, End));
|
Ranges.push_back(CharSourceRange::getCharRange(Start, End));
|
||||||
}
|
}
|
||||||
tooling::Replacements Replaces = reformat(getStyle(), Lex, Sources, Ranges);
|
tooling::Replacements Replaces = reformat(getStyle(), Lex, Sources, Ranges);
|
||||||
if (OutputReplacements) {
|
if (OutputXML) {
|
||||||
llvm::outs() << "[\n";
|
llvm::outs() << "<?xml version='1.0'?>\n<replacements>\n";
|
||||||
for (tooling::Replacements::const_iterator I = Replaces.begin(),
|
for (tooling::Replacements::const_iterator I = Replaces.begin(),
|
||||||
E = Replaces.end();
|
E = Replaces.end();
|
||||||
I != E; ++I) {
|
I != E; ++I) {
|
||||||
if (I != Replaces.begin()) {
|
llvm::outs() << "<replacement "
|
||||||
llvm::outs() << ",\n";
|
<< "offset='" << I->getOffset() << "' "
|
||||||
}
|
<< "length='" << I->getLength() << "'>"
|
||||||
llvm::outs() << " {\n"
|
<< I->getReplacementText() << "</replacement>\n";
|
||||||
<< " \"offset\": " << I->getOffset() << ",\n"
|
|
||||||
<< " \"length\": " << I->getLength() << ",\n"
|
|
||||||
<< " \"replacement_text\": \"" << I->getReplacementText()
|
|
||||||
<< "\"\n"
|
|
||||||
<< " }";
|
|
||||||
}
|
}
|
||||||
llvm::outs() << "\n]\n";
|
llvm::outs() << "</replacements>\n";
|
||||||
} else {
|
} else {
|
||||||
Rewriter Rewrite(Sources, LangOptions());
|
Rewriter Rewrite(Sources, LangOptions());
|
||||||
tooling::applyAllReplacements(Replaces, Rewrite);
|
tooling::applyAllReplacements(Replaces, Rewrite);
|
||||||
|
|
Loading…
Reference in New Issue