On Wed, Feb 6, 2013 at 12:55 PM, Dmitri Gribenko <[email protected]>wrote:
> On Wed, Feb 6, 2013 at 11:42 AM, Manuel Klimek <[email protected]> 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 <[email protected]>*/ >
_______________________________________________ cfe-commits mailing list [email protected] http://lists.cs.uiuc.edu/mailman/listinfo/cfe-commits
