Haskell: Add all language pragmas as keywords.
ClosedPublic

Authored by arrowd on Jun 4 2017, 8:36 AM.

Details

Summary

Haskell has a bunch of language extensions, which can be enabled with LANGUAGE pragma. I often forget how a pragma is spelled, so I thought adding these as keywords is a good idea.

Test Plan

This patch has a flaw and I wasn't able to figure out where the problem lies. If I place the cursor onto emtpy line and then type "{-# Over", the keyword completion doesn't pop out. But if I then press "Ctrl+Backspace" to delete "Over" and start typing it again, the completion does show.

Diff Detail

Repository
R216 Syntax Highlighting
Branch
master
Lint
No Linters Available
Unit
No Unit Test Coverage
arrowd created this revision.Jun 4 2017, 8:36 AM
Restricted Application added a project: Frameworks. · View Herald TranscriptJun 4 2017, 8:36 AM
Restricted Application added a subscriber: Frameworks. · View Herald Transcript
arrowd edited the summary of this revision. (Show Details)Jun 4 2017, 8:40 AM
arrowd edited the test plan for this revision. (Show Details)
arrowd added a comment.Jun 7 2017, 7:27 AM

I just found that the same problem exists for import_keywords too - when I type import qual, the completion doesn't show up, and deleteting qual and typing it again causes it to show.

So, it seems to be a coding bug.

dhaumann accepted this revision.Jun 17 2017, 2:31 PM
dhaumann added a subscriber: dhaumann.

I will change the patch slightly and commit: Instead of StringDetect, we better use WordDetect. Also, we need to increase the version="" number. Besides that, the patch looks good.

This revision is now accepted and ready to land.Jun 17 2017, 2:31 PM

@arrowdodger Isn't there a line missing:

+ <context attribute="Pragma" lineEndContext="#pop" name="pragma">
+ <keyword attribute="Pragma" context="#stay" String="language_pragmas" />
+ <StringDetect attribute="Pragma" context="#pop" String="#-}"/> <------------------ This line ?
+ </context>

Also, is the lineEndContext #pop or should it rather be #stay?

Please clarify/confirm.

Also: could you provide us with a small demo code so that we can extend our unit test?

arrowd updated this revision to Diff 15772.Jun 23 2017, 8:35 AM
  • Use WordDetect instead of StringDetect for omport keyword.
  • Pop Pragma context on #-} string, not newline.

Also: could you provide us with a small demo code so that we can extend our unit test?

The demo for added highlighting rule, or the problem with autocompletion?

Demo for the highlighting rule - I don't think I can say anything to the auto completion issue. I am pretty sure it is unrelated to your xml file.

Demo for the highlighting rule - I don't think I can say anything to the auto completion issue. I am pretty sure it is unrelated to your xml file.

Sure. Pragmas have following form:

{-# blabla #-}

Specifically, pragmas that enable language extensions looks like

{-# LANGUAGE OverlappingInstances, BangPatterns #-}

As I've found today, pragmas can span onto multiple lines:

{-# LANGUAGE OverlappingInstances, 
             BangPatterns
#-}

So, can I push this?

I would say yes.
If you have some more time, you could add an auto-test for it.

arrowd updated this revision to Diff 15981.Jun 29 2017, 9:02 AM

Added autotests. Not sure if .ref file should be updated, as the tests pass as they are now.

Hmm, interesting, I would assume you need to update the ref given the input did change.

arrowd updated this revision to Diff 15982.Jun 29 2017, 9:08 AM

Updated reference file for autotest as well.

cullmann accepted this revision.Jun 29 2017, 9:09 AM

Feel free to push ;=)
Thanks for additions!

This revision was automatically updated to reflect the committed changes.