-
Notifications
You must be signed in to change notification settings - Fork 35
Added enum types and verification #168
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
Merged
Merged
Changes from 1 commit
Commits
Show all changes
19 commits
Select commit
Hold shift + click to select a range
c70cc5a
Added enum type support with tests
cheestree e77a33b
Added EnumRefinementMessage test
cheestree a359d1f
Applied fixes and suggestions for enums
cheestree a6a4055
Fixed grammar
cheestree 0ab2098
Revert "Fixed grammar"
cheestree 44758c7
Reapply "Fixed grammar"
cheestree b610928
Separated translation into phases
cheestree cdf192e
Refactored variable translation
cheestree d7dea40
Added enum tests
cheestree e3e49d2
Added enum tests, adjusted grammar
cheestree aafde53
Moved RefinementMessage test
cheestree 7a7e074
Changed Enumerate to Enum
cheestree 96905c1
Renamed fields and getters/setters
cheestree 8a4e507
Updated variable translation with suggestions
cheestree 2e46e5c
Merge branch 'liquid-java:main' into main
cheestree 2754337
Updated tests to fit with main changes
cheestree 2c23a2e
Extracted enum logic to its own method
cheestree c85ed97
Apply suggestions from code review
cheestree 2ad2747
Renamed usage
cheestree File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Applied fixes and suggestions for enums
Created AST node and visitors for enums. Changed grammar as suggested to specific rules and positioning to avoid ambiguity. Changed format.
- Loading branch information
commit a359d1f9c5a33345c9905f11d9fecf0a71ca9e8f
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
74 changes: 74 additions & 0 deletions
74
liquidjava-verifier/src/main/java/liquidjava/rj_language/ast/Enumerate.java
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,74 @@ | ||
| package liquidjava.rj_language.ast; | ||
|
|
||
| import java.util.List; | ||
|
|
||
| import liquidjava.diagnostics.errors.LJError; | ||
| import liquidjava.rj_language.visitors.ExpressionVisitor; | ||
|
|
||
| public class Enumerate extends Expression { | ||
|
|
||
| private final String enumTypeName; | ||
| private final String enumConstantName; | ||
|
|
||
| public Enumerate(String enumTypeName, String enumConstantName) { | ||
| this.enumTypeName = enumTypeName; | ||
| this.enumConstantName = enumConstantName; | ||
| } | ||
|
|
||
| public String getEnumTypeName() { | ||
| return enumTypeName; | ||
| } | ||
|
|
||
| public String getEnumConstantName() { | ||
| return enumConstantName; | ||
| } | ||
|
|
||
| @Override | ||
| public <T> T accept(ExpressionVisitor<T> visitor) throws LJError { | ||
| return visitor.visitEnumerate(this); | ||
| } | ||
|
|
||
| @Override | ||
| public void getVariableNames(List<String> toAdd) { | ||
| // end leaf | ||
| } | ||
|
|
||
| @Override | ||
| public void getStateInvocations(List<String> toAdd, List<String> all) { | ||
| // end leaf | ||
| } | ||
|
|
||
| @Override | ||
| public boolean isBooleanTrue() { | ||
| return false; | ||
| } | ||
|
|
||
| @Override | ||
| public String toString() { | ||
| return enumTypeName + "." + enumConstantName; | ||
| } | ||
|
|
||
| @Override | ||
| public int hashCode() { | ||
| final int prime = 31; | ||
| int result = 1; | ||
| result = prime * result + ((enumTypeName == null) ? 0 : enumTypeName.hashCode()); | ||
| result = prime * result + ((enumConstantName == null) ? 0 : enumConstantName.hashCode()); | ||
| return result; | ||
| } | ||
|
|
||
| @Override | ||
| public boolean equals(Object obj) { | ||
| if (this == obj) | ||
| return true; | ||
| if (obj == null || getClass() != obj.getClass()) | ||
| return false; | ||
| Enumerate other = (Enumerate) obj; | ||
| return enumTypeName.equals(other.enumTypeName) && enumConstantName.equals(other.enumConstantName); | ||
| } | ||
|
|
||
| @Override | ||
| public Expression clone() { | ||
| return new Enumerate(enumTypeName, enumConstantName); | ||
| } | ||
| } | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.