[clang-tools-extra] r174497 - Kick JSON output for XML output.
Manuel Klimek
klimek at google.com
Wed Feb 6 04:40:58 PST 2013
On Wed, Feb 6, 2013 at 12:55 PM, Dmitri Gribenko <gribozavr at gmail.com>wrote:
> On Wed, Feb 6, 2013 at 11:42 AM, Manuel Klimek <klimek at google.com> wrote:
> > Author: klimek
> > Date: Wed Feb 6 03:42:05 2013
> > New Revision: 174497
> >
> > URL: http://llvm.org/viewvc/llvm-project?rev=174497&view=rev
> > Log:
> > 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.
> >
> > Modified:
> > clang-tools-extra/trunk/clang-format/ClangFormat.cpp
> >
> > Modified: clang-tools-extra/trunk/clang-format/ClangFormat.cpp
> > URL:
> http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/clang-format/ClangFormat.cpp?rev=174497&r1=174496&r2=174497&view=diff
> >
> ==============================================================================
> > --- clang-tools-extra/trunk/clang-format/ClangFormat.cpp (original)
> > +++ clang-tools-extra/trunk/clang-format/ClangFormat.cpp Wed Feb 6
> 03:42:05 2013
> > @@ -38,8 +38,8 @@ static cl::opt<std::string> Style(
> > static cl::opt<bool> Inplace("i",
> > cl::desc("Inplace edit <file>, if
> specified."));
> >
> > -static cl::opt<bool> OutputReplacements(
> > - "output-replacements", cl::desc("Output replacements as JSON."));
> > +static cl::opt<bool> OutputXML(
> > + "output-replacements-xml", cl::desc("Output replacements as XML."));
> >
> > // FIXME: Remove this when styles are configurable through files.
> > static cl::opt<bool> InvertPointerBinding(
> > @@ -107,22 +107,17 @@ static void format() {
> > Ranges.push_back(CharSourceRange::getCharRange(Start, End));
> > }
> > tooling::Replacements Replaces = reformat(getStyle(), Lex, Sources,
> Ranges);
> > - if (OutputReplacements) {
> > - llvm::outs() << "[\n";
> > + if (OutputXML) {
> > + llvm::outs() << "<?xml version='1.0'?>\n<replacements>\n";
> > for (tooling::Replacements::const_iterator I = Replaces.begin(),
> > E = Replaces.end();
> > I != E; ++I) {
> > - if (I != Replaces.begin()) {
> > - llvm::outs() << ",\n";
> > - }
> > - llvm::outs() << " {\n"
> > - << " \"offset\": " << I->getOffset() << ",\n"
> > - << " \"length\": " << I->getLength() << ",\n"
> > - << " \"replacement_text\": \"" <<
> I->getReplacementText()
> > - << "\"\n"
> > - << " }";
> > + llvm::outs() << "<replacement "
> > + << "offset='" << I->getOffset() << "' "
> > + << "length='" << I->getLength() << "'>"
> > + << I->getReplacementText() << "</replacement>\n";
>
> You need xml:space="preserve" or the whitespace may be collapsed by
> xml processing tools.
>
Thanks! From STFW'ing I understand that I only need to set it on the
toplevel element (replacements), right?
If so, fixed in r174502.
Cheers,
/Manuel
>
> Dmitri
>
> --
> main(i,j){for(i=2;;i++){for(j=2;j<i;j++){if(!(i%j)){j=0;break;}}if
> (j){printf("%d\n",i);}}} /*Dmitri Gribenko <gribozavr at gmail.com>*/
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20130206/c4e5fbef/attachment.html>
More information about the cfe-commits
mailing list