Skip to main content

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [List Home]
Re: [cdt-dev] LLVM Project Blog: A path forward for an LLVM toolchain on Windows



On Sat, Nov 9, 2013 at 12:52 AM, scalpel4k <scalpel4k@xxxxxxxxx> wrote:
Hallo Sergey,

I just sat down and wanted to create a plugin for clang-format. It seems
pretty easy indeed. However, I can't get clang-format to write to stdout. Can
you give me a hint on how you solved it?

I'm running clang-format with -output-replacements-xml command line flag.
 
What are you doing about the -style option? Are you translating the generic
options into a config file for clang-format, or are you just ignoring it?

It's lame, but I use a preference page separate from C/C++ > Code Style Formatter that allows user to specify the style. Another option would be to define a separate formatter extension for each of the styles. This way a user wiuld select not just clang-format, but something like clang-format -style=LLVM or clang-format -style=Chromium.

Please keep in mind that clang-format operates in terms of utf-8 byte offsets, not in terms of characters like Eclipse. To avoid bad results on files containing non-ascii characters you have to convert from character offsets to byte offsets and back.

thx Michi

-sergey 

On Monday 16 Sep 2013 11:35:10 Sergey Prigogin wrote:
> On Mon, Sep 16, 2013 at 11:22 AM, Nathan Ridge
<zeratul976@xxxxxxxxxxx>wrote:
> > > I have a tiny plugin (sorry not open source) that
> >
> > implements org.eclipse.cdt.core.CodeFormatter extension point and calls
> > clang-format with -output-replacements-xml flag. The XML produced by
> > clang-format is parsed, converted into an array of TextEdits, and returned
> > from the format method.
> >
> > That sounds quite useful! Do you think you (or your Google overlords :) )
> > would consider open-sourcing that at some point?
>
> It's not easily open-sourceable due to dependency on couple proprietary
> classes. The code is less that 200 lines, so anybody should be able to
> write such a plugin in a day.
>
> > Regards,
> > Nate
>
> -sergey
>
> > _______________________________________________
> > cdt-dev mailing list
> > cdt-dev@xxxxxxxxxxx
> > https://dev.eclipse.org/mailman/listinfo/cdt-dev


Back to the top