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

Simplified names for map functions in AbstractAntlrListener.java #1180

Merged
merged 1 commit into from
Jul 16, 2023

Conversation

TwoOfTwelve
Copy link
Contributor

Simplified the names of the mapping functions in AbstractAntlrListener

@brodmo
Copy link
Contributor

brodmo commented Jul 11, 2023

What's the difference between mapRange and mapStart? Is it simply the token's length? If so, I would suggest removing mapRange for clarity, as token length isn't used anywhere and should probably be removed altogether

@brodmo
Copy link
Contributor

brodmo commented Jul 11, 2023

And what about mapTerminal? I don't really get it. In my mind, there's really only two types of mappings: "simple" mappings (e.g. a variable declarations), where a token is generated when some node is encountered, and scope mappings (e.g. classes), where a begin token is generated when some node is entered and an end token is generated when that same node is exited. I guess these would correspond to mapEnter and mapEnterExit right now.

@TwoOfTwelve
Copy link
Contributor Author

mapRange indeed only changes the token length. I will check with the maintainers later today, if there is any reason to keep it.

Map terminal is used to map terminal nodes (The nodes created for the tokens defined in the lexer file) of antlr. Sadly the only way to identify them is using integer constants defined by antlr. Writing the listener manually, you can handle them in the visitTerminal method.

For example the kotlin language modules used that to extract tokens like "BREAK". Using the mapTerminal method, that can be done using the new framework:

this.mapTerminal(KotlinParser.BREAK, BREAK);

@sonarcloud
Copy link

sonarcloud bot commented Jul 11, 2023

[JPlag Plagiarism Detector] Kudos, SonarCloud Quality Gate passed!    Quality Gate passed

Bug A 0 Bugs
Vulnerability A 0 Vulnerabilities
Security Hotspot A 0 Security Hotspots
Code Smell A 0 Code Smells

99.3% 99.3% Coverage
0.0% 0.0% Duplication

@Kr0nox
Copy link
Member

Kr0nox commented Jul 13, 2023

Looks good. Only thing missing is what we discussed in #1159

@tsaglam
Copy link
Member

tsaglam commented Jul 13, 2023

@TwoOfTwelve should we merge this PR now and address the changes discussed above in another PR? Or do we want to include it here?

@tsaglam tsaglam added enhancement Issue/PR that involves features, improvements and other changes minor Minor issue/feature/contribution/change language PR / Issue deals (partly) with new and/or existing languages for JPlag labels Jul 13, 2023
@brodmo
Copy link
Contributor

brodmo commented Jul 16, 2023

@tsaglam please merge this, I'm starting work on the C++ semantic tokens based on it

Copy link
Member

@tsaglam tsaglam left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@TwoOfTwelve Lets move the other issues discussed here into another PR!

@tsaglam tsaglam merged commit 289ce30 into develop Jul 16, 2023
24 checks passed
@tsaglam tsaglam deleted the feature/antlr-utils-simpler-names branch July 16, 2023 16:06
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement Issue/PR that involves features, improvements and other changes language PR / Issue deals (partly) with new and/or existing languages for JPlag minor Minor issue/feature/contribution/change
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants