Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Syntax highlighting for Crucible #13200

Open
marcinz opened this issue Jun 6, 2019 · 10 comments
Open

Syntax highlighting for Crucible #13200

marcinz opened this issue Jun 6, 2019 · 10 comments

Comments

@marcinz
Copy link

marcinz commented Jun 6, 2019

Summary of Problem

We are using Atlassian Crucible for code review. They seem to use their own format for syntax highlighting:

https://confluence.atlassian.com/fishkb/defining-your-own-syntax-highlighting-in-crucible-or-fisheye-225120620.html

It would be nice to have an additional highlighter for Crucible.

@bradcray
Copy link
Member

bradcray commented Jun 6, 2019

If there's not much more to it than their example shows (which I read as being a list of keywords sorted by first letter), then it should be fairly easy to take a list like this one and adapt it to that purpose:

morekeywords={
align, as, atomic,
begin, bool, borrowed, break, by,
catch, class, cobegin, coforall, complex, config, const, continue,
defer, delete, dmapped, do, domain,
else, enum, except, export, extern,
false, for, forall, forwarding,
if, imag, in, index, inline, inout, int, iter,
label, lambda, let, lifetime, local, locale,
module,
new, nil, noinit,
on, only, opaque, otherwise, out, override, owned,
param, pragma, primitive, private, proc, prototype, public,
range, real, record, reduce, ref, require, return,
scan, select, serial, shared, single, sparse, string, subdomain, sync,
then, this, throw, throws, true, try, type,
uint, union, unmanaged, use,
var,
when, where, while, with,
yield,
zip
},

@bradcray
Copy link
Member

bradcray commented Jun 6, 2019

(but I don't have or know how to use crucible to try it out for myself... maybe a side activity for CHIUW 2019's coding day?)

@marcinz
Copy link
Author

marcinz commented Jun 6, 2019

Sure, we can take a look then. I also thought after I filed the issue here that I should file an issue at Atlassian:

https://jira.atlassian.com/browse/CRUC-8404

@bradcray
Copy link
Member

bradcray commented Jun 6, 2019

When the instructions say:

Copy one of the existing definitions into your FISHEYE_INST/syntax directory.

Do you know where that directory is, and can you say what other languages it contains? Do they all look as short and sweet as the example in the link you pointed to in the original issue text?

@marcinz
Copy link
Author

marcinz commented Jun 20, 2019

I'll have to have @tjstavenger-pnnl help me out with this. But before we do that, somebody on Atlassion's JIRA thinks that "the Chapel language is not very popular one.". :) Somebody should show them.

@tjstavenger-pnnl
Copy link
Contributor

I've attached the cpp.def that Crucible uses for C++ files and the filename.map file that maps file names/extensions to the language definition file. To add Chapel support to Crucible we'd need to create a chapel.def and then map *.chpl files to it.

I renamed the files *.txt because GitHub didn't know what to do with a .def and .map file

cpp.def.txt
filename.map.txt

@bradcray
Copy link
Member

Oops, I forgot that we were going to look at this at CHIUW yesterday.

I would guess that cloning cpp.def into chpl.def and putting the list of keywords from the chapel_listing.tex file I pointed to above into the respective section would get you 90% of the way to a working solution. I'm reluctant to take that step myself since I wouldn't have any way to verify whether it was working and iterate on a solution.

@tjstavenger-pnnl
Copy link
Contributor

I've made a custom Chapel syntax definition for our Crucible server. I added our current configuration to the Jira ticket @marcinz made. See my comment here: https://jira.atlassian.com/browse/CRUC-8404?focusedCommentId=2025188

@bradcray
Copy link
Member

Cool, thanks for that update, Tim! If Crucible isn't interested in taking your file such that any users would have access to it, you could PR it into the Chapel repository into a crucible-appropriate subdirectory of $CHPL_HOME/highlight/ such that other Chapel Crucible users would have access to it.

@mppf
Copy link
Member

mppf commented Oct 11, 2021

I've pasted the comment from https://jira.atlassian.com/browse/CRUC-8404?focusedCommentId=2025188 in the details section below to keep the key details here in one place.

I'd attach this as a file, but I don't seem to have permissions to do that (or attachments are disabled?). I started with the C++ definition and changed the keywords to match Chapel. Then I added the new definition to our filename.map.

syntaxdef chpl {

# whitespace
/\s+/m : ;

# keywords
/(align|as|atomic|\
begin|bool|borrowed|break|by|\
catch|class|clone|cobegin|coforall|complex|config|const|continue|\
defer|delete|destroy|dmapped|domain|do|\
else|enum|except|export|extern|\
false|forall|forwarding|for|\
if|imag|index|init|inline|inout|integral|int|in|iter|\
label|lambda|let|lifetime|locale|local|\
module|\
new|nil|noinit|\
only|on|opaque|otherwise|out|override|owned|\
param|pragma|primitive|private|proc|prototype|public|\
range|real|record|reduce|ref|require|return|\
scan|select|serial|shared|single|sparse|string|subdomain|sync|\
then|this|throws|throw|true|try|type|\
uint|union|unmanaged|use|\
var|\
when|where|while|with|\
yield|\
zip)\b/ : {
       region {
         type=keyword;
         index=word;
       }
    }

# preprocessor line
/^#.*$/m : {
       region {
         type=keyword; # obviously not a keyword. this will change when we shake out a cannonical list of types
       }
    }

# char literal
/L?'(\\.|\\[0-7]{3}|\\x[0-9a-fA-F]{2}|.)'/ : {
       region {
          type=char_literal;
       }    
}

# string literal
/L?"/ : {
    context {
        /\\"/: ;
        /\\./: ;
        /$/m : exit;
        "\"" : exit;
    }
    region ${ALL} {
           type=string;
    }
}

#numeric literal
/(0x[0-9a-f]+(lu|ul|[ul])?)|((([0-9]+\.?)|([0-9]*\.[0-9]+))(e(\+|-)?[0-9]+)?(fl|lf|[lf])?)/i : {
       region {
          type=numeric;
       }
   }# identifier
/[a-zA-Z_][a-zA-Z_0-9]*/ : {
      region {
         type=identifier;
         index=word;
      }
   }

# comment
/\/\*.*?\*\//s : {
      region {
         type=comment;
         index=prose;
         findlinks=true;
      }
    }

# inline comment
/\/\/.*$/m : {
      region {
         type=comment;
         index=prose;
         findlinks=true;
      }
   }
}

The next step is for somebody who can try this out with Atlassian Crucible to prepare a PR that creates a subdirectory in the highlight directory with README instructions on how to use it as well as the above file.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

4 participants