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 Mon, Nov 11, 2013 at 12:17 PM, scalpel4k <scalpel4k@xxxxxxxxx> wrote:

On Monday 11 Nov 2013 11:17:26 Sergey Prigogin wrote:
> 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.
I did too, but I get stuck when I try to read on the InputStream. I haven't
tested whether clang-format sees any data when I flush the output stream, yet.
Can you share your code to the point where you read from the inputstream? Are
you using the ProcessBuilder or is the Process class just doing it for you?

You have to make sure that you are reading both stdout and stderr and that clang-format is not blocked reading its stdin. I'm using ProcessBuilder.

>
> > 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.
I didn't find any extension point, so I thought to simply add that to the LLVM
category. Not perfect, but it should work.

I'm not sure I understand what you mean.
 
>
> 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
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
_______________________________________________
cdt-dev mailing list
cdt-dev@xxxxxxxxxxx
https://dev.eclipse.org/mailman/listinfo/cdt-dev


Back to the top