[cfe-commits] [PATCH] Interface proposal for clang formatting tools
dgregor at apple.com
Wed Jun 6 08:04:08 PDT 2012
On Jun 6, 2012, at 3:23 AM, Chandler Carruth wrote:
> On Wed, Jun 6, 2012 at 3:08 AM, Manuel Klimek <klimek at google.com> wrote:
> On Wed, Jun 6, 2012 at 12:04 PM, Chandler Carruth <chandlerc at google.com> wrote:
> On Wed, Jun 6, 2012 at 2:57 AM, Manuel Klimek <klimek at google.com> wrote:
> Daniel & me have worked on a first proposal to provide an interface for clang formatting as part of the Tooling library.
> Please re-send the patch as an attachment? Email plays havoc w/ 80-columns.
> I think it would help a lot to have a bit more code & context when evaluating this, even as a very early step.
> My concrete suggestion would be this: implement a bozo-formatter. A completely trivial to implement, BS set of rules that only requires lexing. Then we can see the interface, a trivial implementation, and some test cases that use it. I think that'll make this much easier to review and really analyze. It also makes it much closer to something that could get checked in as a stepping stone
Yes, please! In fact, I don't think we should even try to design the AnalyzableSource interface now, because we're not likely to know what we need until we have at least some basic formatting.
Personally, I think we can get fairly far with lexer-based formatting, and I think we should start there. From that, I hope that we can build a semantic interface that allows partial information to be useful, e.g., "is this identifier 'foo' at line 5, column before a '<' referring to a template name or not?". We can definitely answer with a parse, but we can also guess if we have a little knowledge of the names of templates in our system.
Allowing the use of partial information is important because we'll probably want to use this code formatting tool even in places where getting an AST is either too expensive or not generally possible, e.g., within an editor.
> - please point out anything that might make this interface not viable for your own use cases
> - are we missing the point somewhere?
> - is Tooling/ the right place for this?
> I think Tooling is the right place because I think essentially every tool anyone writes will want to have *some* formatting applied to it. Leveraging this from an existing tool and composing cleanly w/ it will almost certainly be important.
It seems more general than tooling. In particular, I'd like to expose this through libclang, which doesn't need any of the other tooling infrastructure. How about the Edit lib?
-------------- next part --------------
An HTML attachment was scrubbed...
More information about the cfe-commits