Getting around LibFormat

classic Classic list List threaded Threaded
5 messages Options
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Getting around LibFormat

Richard Pennington via cfe-dev
Hi,

I'm working on trying to make changes to LibFormat to support Haiku's
coding style [1], but I'm having some trouble trying to figure out
where indentation gets calculated. I've tried various things, but
everything I've tried so far only affects some lines and not others.

For example, I'm trying to format comments with an extra indent if the
line above at what would be same indent without the extra tab for
comment is not whitespace in a function:

if (someCondition) {
    DoSomething();
        // Comments that only affect a single line are usually
        // written after it, and are indented by a single tab
    DoSomethingElse();
} else if (someOtherCondition) {
    DoSomethingElse();
    DoSomething();
}

At the moment, I'm just trying to indent comments an extra tab
unconditionally to identify what might be the right approach, but as
stated above, I've only managed to affect a partial set of what I
want. Finding the documentation just a little too sparse to see how it
all fits together. Some changes are definitely simpler than others...
some pointers would be very much appreciated :-)

Jessica

[1] https://www.haiku-os.org/development/coding-guidelines
_______________________________________________
cfe-dev mailing list
[hidden email]
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-dev
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: Getting around LibFormat

Richard Pennington via cfe-dev
+ Krasimir 

On Mon, Apr 10, 2017 at 1:42 AM Jessica Hamilton via cfe-dev <[hidden email]> wrote:
Hi,

I'm working on trying to make changes to LibFormat to support Haiku's
coding style [1], but I'm having some trouble trying to figure out
where indentation gets calculated. I've tried various things, but
everything I've tried so far only affects some lines and not others.

For example, I'm trying to format comments with an extra indent if the
line above at what would be same indent without the extra tab for
comment is not whitespace in a function:

if (someCondition) {
    DoSomething();
        // Comments that only affect a single line are usually
        // written after it, and are indented by a single tab
    DoSomethingElse();
} else if (someOtherCondition) {
    DoSomethingElse();
    DoSomething();
}

At the moment, I'm just trying to indent comments an extra tab
unconditionally to identify what might be the right approach, but as
stated above, I've only managed to affect a partial set of what I
want. Finding the documentation just a little too sparse to see how it
all fits together. Some changes are definitely simpler than others...
some pointers would be very much appreciated :-)

Jessica

[1] https://www.haiku-os.org/development/coding-guidelines
_______________________________________________
cfe-dev mailing list
[hidden email]
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-dev

_______________________________________________
cfe-dev mailing list
[hidden email]
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-dev
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: Getting around LibFormat

Richard Pennington via cfe-dev
Hi!

Unfortunately comment formatting is all over the place. For your use case, it might be worth looking at TokenAnnotator::setCommentLineLevels: it computes the Level-s of comment tokens based on the next non-comment token. So I'd say that an additional level there might work, but haven't really tried.

Best regards,
Krasimir

On Mon, Apr 10, 2017 at 11:33 AM, Eric Liu <[hidden email]> wrote:
+ Krasimir 

On Mon, Apr 10, 2017 at 1:42 AM Jessica Hamilton via cfe-dev <[hidden email]> wrote:
Hi,

I'm working on trying to make changes to LibFormat to support Haiku's
coding style [1], but I'm having some trouble trying to figure out
where indentation gets calculated. I've tried various things, but
everything I've tried so far only affects some lines and not others.

For example, I'm trying to format comments with an extra indent if the
line above at what would be same indent without the extra tab for
comment is not whitespace in a function:

if (someCondition) {
    DoSomething();
        // Comments that only affect a single line are usually
        // written after it, and are indented by a single tab
    DoSomethingElse();
} else if (someOtherCondition) {
    DoSomethingElse();
    DoSomething();
}

At the moment, I'm just trying to indent comments an extra tab
unconditionally to identify what might be the right approach, but as
stated above, I've only managed to affect a partial set of what I
want. Finding the documentation just a little too sparse to see how it
all fits together. Some changes are definitely simpler than others...
some pointers would be very much appreciated :-)

Jessica

[1] https://www.haiku-os.org/development/coding-guidelines
_______________________________________________
cfe-dev mailing list
[hidden email]
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-dev


_______________________________________________
cfe-dev mailing list
[hidden email]
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-dev
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: Getting around LibFormat

Richard Pennington via cfe-dev
That seems to have done the trick! Somehow managed to miss this with
all my grepping :-)

On 10 April 2017 at 22:12, Krasimir Georgiev <[hidden email]> wrote:

> Hi!
>
> Unfortunately comment formatting is all over the place. For your use case,
> it might be worth looking at TokenAnnotator::setCommentLineLevels: it
> computes the Level-s of comment tokens based on the next non-comment token.
> So I'd say that an additional level there might work, but haven't really
> tried.
>
> Best regards,
> Krasimir
>
> On Mon, Apr 10, 2017 at 11:33 AM, Eric Liu <[hidden email]> wrote:
>>
>> + Krasimir
>>
>> On Mon, Apr 10, 2017 at 1:42 AM Jessica Hamilton via cfe-dev
>> <[hidden email]> wrote:
>>>
>>> Hi,
>>>
>>> I'm working on trying to make changes to LibFormat to support Haiku's
>>> coding style [1], but I'm having some trouble trying to figure out
>>> where indentation gets calculated. I've tried various things, but
>>> everything I've tried so far only affects some lines and not others.
>>>
>>> For example, I'm trying to format comments with an extra indent if the
>>> line above at what would be same indent without the extra tab for
>>> comment is not whitespace in a function:
>>>
>>> if (someCondition) {
>>>     DoSomething();
>>>         // Comments that only affect a single line are usually
>>>         // written after it, and are indented by a single tab
>>>     DoSomethingElse();
>>> } else if (someOtherCondition) {
>>>     DoSomethingElse();
>>>     DoSomething();
>>> }
>>>
>>> At the moment, I'm just trying to indent comments an extra tab
>>> unconditionally to identify what might be the right approach, but as
>>> stated above, I've only managed to affect a partial set of what I
>>> want. Finding the documentation just a little too sparse to see how it
>>> all fits together. Some changes are definitely simpler than others...
>>> some pointers would be very much appreciated :-)
>>>
>>> Jessica
>>>
>>> [1] https://www.haiku-os.org/development/coding-guidelines
>>> _______________________________________________
>>> cfe-dev mailing list
>>> [hidden email]
>>> http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-dev
>
>
_______________________________________________
cfe-dev mailing list
[hidden email]
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-dev
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: Getting around LibFormat

Richard Pennington via cfe-dev
And if I want to format a particular block of code conditionally, how
would I go about that?

E.g. we have different variable alignment rules for class definitions
compared to function definitions. In a class, member variable names
are aligned, but in functions, there is no variable name alignment.


On 11 April 2017 at 14:36, Jessica Hamilton
<[hidden email]> wrote:

> That seems to have done the trick! Somehow managed to miss this with
> all my grepping :-)
>
> On 10 April 2017 at 22:12, Krasimir Georgiev <[hidden email]> wrote:
>> Hi!
>>
>> Unfortunately comment formatting is all over the place. For your use case,
>> it might be worth looking at TokenAnnotator::setCommentLineLevels: it
>> computes the Level-s of comment tokens based on the next non-comment token.
>> So I'd say that an additional level there might work, but haven't really
>> tried.
>>
>> Best regards,
>> Krasimir
>>
>> On Mon, Apr 10, 2017 at 11:33 AM, Eric Liu <[hidden email]> wrote:
>>>
>>> + Krasimir
>>>
>>> On Mon, Apr 10, 2017 at 1:42 AM Jessica Hamilton via cfe-dev
>>> <[hidden email]> wrote:
>>>>
>>>> Hi,
>>>>
>>>> I'm working on trying to make changes to LibFormat to support Haiku's
>>>> coding style [1], but I'm having some trouble trying to figure out
>>>> where indentation gets calculated. I've tried various things, but
>>>> everything I've tried so far only affects some lines and not others.
>>>>
>>>> For example, I'm trying to format comments with an extra indent if the
>>>> line above at what would be same indent without the extra tab for
>>>> comment is not whitespace in a function:
>>>>
>>>> if (someCondition) {
>>>>     DoSomething();
>>>>         // Comments that only affect a single line are usually
>>>>         // written after it, and are indented by a single tab
>>>>     DoSomethingElse();
>>>> } else if (someOtherCondition) {
>>>>     DoSomethingElse();
>>>>     DoSomething();
>>>> }
>>>>
>>>> At the moment, I'm just trying to indent comments an extra tab
>>>> unconditionally to identify what might be the right approach, but as
>>>> stated above, I've only managed to affect a partial set of what I
>>>> want. Finding the documentation just a little too sparse to see how it
>>>> all fits together. Some changes are definitely simpler than others...
>>>> some pointers would be very much appreciated :-)
>>>>
>>>> Jessica
>>>>
>>>> [1] https://www.haiku-os.org/development/coding-guidelines
>>>> _______________________________________________
>>>> cfe-dev mailing list
>>>> [hidden email]
>>>> http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-dev
>>
>>
_______________________________________________
cfe-dev mailing list
[hidden email]
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-dev
Loading...