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

Add support for Groovy and Lua code within PROC GROOVY and PROC LUA #2091

Merged
merged 23 commits into from
Oct 23, 2019

Conversation

cedporter
Copy link
Contributor

Like PROC SQL, PROC GROOVY and PROC LUA both contain syntax that should be treated as the language specified by the PROC, not SAS. This pull request implements that highlighting.

Edward Porter added 6 commits October 4, 2019 10:56
* Reorder comment array to fix edge case added to comment_feature.test
* Adjust datalines to allow for possible preceding spaces before closing semicolon
* Move comment in sas object for correct syntax matching precedence
* Add several more keywords
@RunDevelopment
Copy link
Member

Thank you for this PR.
A few things before the review:

  1. Please rebase this. I recently added a new test that points out all unnecessary capturing groups.
  2. Should we make the dependencies optional? Some users might not need SQL, Lua, and Groovy highlighting.
    The only problem with optional dependencies is that the languages might be present when the SAS language is created (duh, optional deps), so the rest properties will cause trouble. So the Lua and Groovy summits have to be replaced with something like this:
    {
        'groovy': {
            pattern: RegExp(/(^[ \t]*submit(?:\s+(?:load|parseonly|norun))?)(?:<str>|[^"'])+?(?=endsubmit;)/.source.replace(/<str>/g, stringPattern), 'im'),
            lookbehind: true,
            alias: 'language-groovy',
            inside: Prism.languages.groovy
        },
        'submit-statement': submitStatement,
        'global-statements': globalStatements,
        'number': number,
        'numeric-constant': numericConstant,
        'punctuation': punctuation,
        'string': string
    }
    Similarlly for Lua.
    Also, I assume that it has to be (?:<str>|[^"'])+? instead of (?:<str>|[^"'])+, isn't it?

Golmote and others added 14 commits October 17, 2019 14:56
This adds `undefined` to the list of keywords in TypeScript.
)

This adds support for optional chaining (`?.`) and nullish coalescing (`??`).
This adds support for FTL (Freemarker language).
All changed patterns are equivalent with the exception of `c-like.class-name.pattern` where the `\b` before `catch` is new.
This adds support for ANTLR4.

Languages embedded via actions are not highlighted.
This adds support for etlua (Embedded Lua templating).
This inlines a few unnecessary `rest` properties.
This adds a test that checks for unused capturing groups in patterns and another test which ensures that lookbehind groups are always the first thing being matched in a pattern.
@cedporter
Copy link
Contributor Author

I made the changes specified above and dealt with the unnecessary capturing groups. How would I make Lua and Groovy optional?

@RunDevelopment
Copy link
Member

To make them optional, you change this in components.json:

-	"require": ["groovy", "lua", "sql"],
+	"peerDependencies": ["groovy", "lua", "sql"],

I think SQL should be optional as well or is it used very often so that including it by default is justified?

@RunDevelopment
Copy link
Member

Also, with Lua and Groovy (and maybe also SQL?) being optional, you have to change your test files.

To tell Prism's testing suite to load Lua/Groovy/SQL, you create a new folder in test/languages/ and call it lua+sas. This will load first Lua and then SAS. Also, we usually call these kinds of test inclusion tests (Example of CSS in HTTP).

@cedporter
Copy link
Contributor Author

I've made all three languages optional and updated the tests to reflect it.

components.json Outdated Show resolved Hide resolved
add line spaces

Co-Authored-By: Michael Schmidt <mitchi5000.ms@googlemail.com>
@RunDevelopment RunDevelopment merged commit 3640b3f into PrismJS:master Oct 23, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

4 participants