jcberquist / commandbox-cfformat

A CommandBox module for formatting CFML component files.
MIT License
22 stars 10 forks source link

Add support for safe navigation operator #57

Closed elpete closed 4 years ago

elpete commented 4 years ago

It looks like the safe navigation operator (?.) is being interpreted as a ternary operator. This causes some code breakage.

Config: default

Source:

component {

    function functionCallWithSafeNavigationOperator() {
        return getFoo()?.getBar();
    }

    function structWithSafeNavigationOperator() {
        return variables?.foo?.bar;
    }

}

Current Output:

component {

    function functionCallWithSafeNavigationOperator() {
        return getFoo() ? .getBar();
    }

    function structWithSafeNavigationOperator() {
        return variables ? .foo ? .bar;
    }

}
elpete commented 4 years ago

Actually, it looks like Lucee still parses this correctly. I'm surprised. However, I don't think that's the aesthetic we want since it looks like a ternary this way.

jcberquist commented 4 years ago

Thanks! I didn't have any syntax highlighting support for the safe navigation operator in place.