-
Notifications
You must be signed in to change notification settings - Fork 332
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
Feature/antlr language utils #1159
Conversation
@TwoOfTwelve, you need to adapt the coverage pom in order for us to see the coverage correctly: |
[JPlag Plagiarism Detector] SonarCloud Quality Gate failed. 0 Bugs 38.5% Coverage Catch issues before they fail your Quality Gate with our IDE extension SonarLint |
[JPlag Plagiarism Detector] Kudos, SonarCloud Quality Gate passed! |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks good. Maybe we can see with the typescript module how intuitive the system is (@Kr0nox just FYI) and then tweak it if required.
@TwoOfTwelve Is there a way two tokens for the same RuleContext get added in the desired order?
In this case |
Currently, that is not possible. Can you check if this patch fixes the problem? Index: language-antlr-utils/src/main/java/de/jplag/antlr/AbstractAntlrListener.java
IDEA additional info:
Subsystem: com.intellij.openapi.diff.impl.patch.CharsetEP
<+>UTF-8
===================================================================
diff --git a/language-antlr-utils/src/main/java/de/jplag/antlr/AbstractAntlrListener.java b/language-antlr-utils/src/main/java/de/jplag/antlr/AbstractAntlrListener.java
--- a/language-antlr-utils/src/main/java/de/jplag/antlr/AbstractAntlrListener.java (revision e5aeec5e7aa858e0dd1d416eaf3b30dd9b536bb4)
+++ b/language-antlr-utils/src/main/java/de/jplag/antlr/AbstractAntlrListener.java (date 1689066637596)
@@ -25,7 +25,6 @@
public class AbstractAntlrListener implements ParseTreeListener {
private final List<ContextTokenBuilder<ParserRuleContext>> startMappings;
private final List<ContextTokenBuilder<ParserRuleContext>> endMappings;
- private final List<ContextTokenBuilder<ParserRuleContext>> rangeMappings;
private final List<TerminalTokenBuilder> terminalMapping;
@@ -46,7 +45,6 @@
this.startMappings = new ArrayList<>();
this.endMappings = new ArrayList<>();
- this.rangeMappings = new ArrayList<>();
this.terminalMapping = new ArrayList<>();
@@ -78,8 +76,6 @@
@Override
public void enterEveryRule(ParserRuleContext rule) {
this.startMappings.stream().filter(mapping -> mapping.matches(rule)).forEach(mapping -> mapping.createToken(rule, variableRegistry));
-
- this.rangeMappings.stream().filter(mapping -> mapping.matches(rule)).forEach(mapping -> mapping.createToken(rule, variableRegistry));
}
@Override
@@ -166,7 +162,7 @@
protected <T extends ParserRuleContext> ContextTokenBuilder<T> createRangeMapping(Class<T> antlrType, TokenType jplagType,
Predicate<T> condition) {
ContextTokenBuilder<T> builder = initTypeBuilder(antlrType, jplagType, condition, ContextTokenBuilderType.RANGE);
- this.rangeMappings.add((ContextTokenBuilder<ParserRuleContext>) builder);
+ this.startMappings.add((ContextTokenBuilder<ParserRuleContext>) builder);
return builder;
} |
Yes that solves the issue 👍 |
Adds a new maven module, containing a common parser implementation for all antlr languages.
Part of #983