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

Javascript: fix some cyclic dependencies #2772

Merged
merged 1 commit into from
Apr 17, 2020
Merged

Conversation

carocad
Copy link
Contributor

@carocad carocad commented Mar 8, 2020

This PR is a follow up on #2749 specifically this comment

This PR removes 2 of the 3 cyclic dependencies from before:

$ madge --circular src/antlr4/index.js 
Processed 47 files (1.1s) 

✖ Found 3 circular dependencies!

1) LL1Analyzer.js > PredictionContext.js > RuleContext.js > atn/ATN.js
2) RuleContext.js > tree/Trees.js > ParserRuleContext.js
3) RuleContext.js > tree/Trees.js

Number 2 and 3 are eliminated.

The solution for this specific case is to check for RuleNode interface since both RuleContext and ParserRuleContext implement it (RuleNode -> RuleContext -> ParserRuleContext) and since RuleContext is the only implementation of RuleNode the checks are equivalent.

NOTE: On Javascript the RuleNode didnt declare the getRuleContext as in Java so I added it to make it consistent and to make it work as described above.

@carocad carocad changed the title fix: cyclic dependency between RuleContext.js, Trees.js and ParserRul… Javascript - fix: some cyclic dependencies Mar 8, 2020
@carocad carocad changed the title Javascript - fix: some cyclic dependencies Javascript: fix some cyclic dependencies Mar 8, 2020
@carocad
Copy link
Contributor Author

carocad commented Mar 10, 2020

@ericvergnaud unfortunately I cannot add a reviewer to github anymore ... dont know why. So I am not sure if you have already checked this :) ?

@ericvergnaud
Copy link
Contributor

@parrt blessed

@parrt
Copy link
Member

parrt commented Mar 26, 2020

Hi guys, we have conflicts after merging previous...

@carocad
Copy link
Contributor Author

carocad commented Mar 26, 2020

Hi guys, we have conflicts after merging previous...

Let me take a look.

EDIT: fixed :)

…eContext.js

check for RuleNode instead of RuleContext since that it the only implementation (RuleNode -> RuleContext -> ParserRuleContext)
@carocad
Copy link
Contributor Author

carocad commented Apr 17, 2020

hello ? anyone there ?

@ericvergnaud
Copy link
Contributor

ericvergnaud commented Apr 17, 2020

@parrt blessed, sorry for the delay

@parrt parrt merged commit 8c50731 into antlr:master Apr 17, 2020
@carocad carocad deleted the cyclic-import branch April 18, 2020 10:53
@parrt parrt added this to the 4.9 milestone Nov 24, 2020
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.

3 participants