C/C++ member HTML causes issue in Theming (vs csharp)


#1

I am trying to generate a theme and came across this issue.

For a c++ class defined below

 class Team: public SportingEntity {
     public:
        Person Manager;
        Vector<Player> has;
 };

Here is the generated html for the two members

<span class="syntax--meta syntax--class-struct-block syntax--cpp">
    <span class="leading-whitespace">    </span>
    Person Manager;
</span>

and

<span class="syntax--meta syntax--class-struct-block syntax--cpp">
    <span class="leading-whitespace">    </span>
    Vector
    <span class="syntax--keyword syntax--operator syntax--comparison syntax--c">&lt;</span>
    Player
    <span class="syntax--keyword syntax--operator syntax--comparison syntax--c">&gt;</span>
     has;
</span>

Whereas when I tested a similar csharp class shown below generated from the same model

public class Team {
    HashSet<Player> has;
    Person Manager;
}

I got the following

<span class="syntax--source syntax--cs">
    <span class="syntax--meta syntax--field syntax--declaration syntax--cs">
        <span class="leading-whitespace">    </span>
        <span class="syntax--entity syntax--name syntax--class syntax--cs">Person</span>
         
        <span class="syntax--entity syntax--name syntax--variable syntax--cs">Manager</span>
    </span>
    ;
</span>

and

<span class="syntax--meta syntax--field syntax--declaration syntax--cs">
    <span class="leading-whitespace">    </span>
    <span class="syntax--entity syntax--name syntax--generic syntax--class syntax--cs">HashSet</span>
    &lt;
    <span class="syntax--meta syntax--generic syntax--type syntax--specifier syntax--cs">
        <span class="syntax--entity syntax--name syntax--class syntax--cs">Player</span>
    </span>
    &gt; 
    <span class="syntax--entity syntax--name syntax--variable syntax--cs">has</span>
</span>

In case of csharp Person was correctly identified as a type name and was emitted under a separate css class along with the name of the person type memeber (called “Manager”) followed by a semicolon. However in case of cpp this was not the case. It was generated as a single string “Person Manager;”

This causes issue when trying to theme code since there is no clear separation between type name and property name. Moreover, since CSS does not allow capturing the first word out of a string, this becomes something unachievable.

As shown by the second property, Recognition of templated properties is made even more difficult because of a lack of distinction. In this case this is true in both cases (cpp and cs). Enclosing the less than and greater than signs in a scope will provide ease of theming.

Recommendation: Separate the type name and property names by enclosing them in classes unique to their scope.

I tried to look at language-c and language-csharp packages for any obvious setting that would make this difference but couldn’t find one.

Also, is there a document that specifies the different types of CSS classes emitted depending on various code elements ? If yes, could someone please point me to that ?

Thanks


#2

In each language package, there’s a CSON file (or more than one) that contains instructions for the language grammar so that Atom knows how to highlight the language. The language-c package has two, for C and C++. You can compare its behavior with that of language-csharp by looking for the regular expression that matches the text you’re interested in.


#3

Thanks. Will look into these next as soon as I find some time.