Java Syntax highlighting not handling a return type that is a generic?

32 views
Skip to first unread message

Duncan Mackenzie

unread,
Oct 26, 2016, 8:41:17 PM10/26/16
to highlight.js
Hey folks, I'm seeing an issue where the first code snippet below is *not* being highlighted correctly, while the 2nd is.

      <pre>
        <code class="lang-java java">
          public ServiceResponseWithHeaders&lt;PagedList&lt;NodeAgentSku&gt;, AccountListNodeAgentSkusHeaders&gt; listNodeAgentSkus(final AccountListNodeAgentSkusOptions accountListNodeAgentSkusOptions)
        </code>
      </pre>
      <pre>
        <code class="lang-java java">
          public Foo listNodeAgentSkus(final AccountListNodeAgentSkusOptions accountListNodeAgentSkusOptions)
        </code>
      </pre>

I believe I need to modify the definition of a function in https://github.com/isagalaev/highlight.js/blob/master/src/languages/java.js to handle this, but I'm reading the code and I'm not sure what change would be required

{
className: 'function',
begin: '(' + GENERIC_IDENT_RE + '\\s+)+' + hljs.UNDERSCORE_IDENT_RE + '\\s*\\(', returnBegin: true, end: /[{;=]/,
excludeEnd: true,
keywords: KEYWORDS,
contains: [
{
begin: hljs.UNDERSCORE_IDENT_RE + '\\s*\\(', returnBegin: true,
relevance: 0,
contains: [hljs.UNDERSCORE_TITLE_MODE]
},
{
className: 'params',
begin: /\(/, end: /\)/,
keywords: KEYWORDS,
relevance: 0,
contains: [
hljs.APOS_STRING_MODE,
hljs.QUOTE_STRING_MODE,
hljs.C_NUMBER_MODE,
hljs.C_BLOCK_COMMENT_MODE
]
},
hljs.C_LINE_COMMENT_MODE,
hljs.C_BLOCK_COMMENT_MODE
]
},

Reply all
Reply to author
Forward
0 new messages