/
ProductionAttributes.java
69 lines (59 loc) · 2.96 KB
/
ProductionAttributes.java
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
package org.spoofax.jsglr2.parsetable;
import java.util.Objects;
import org.metaborg.parsetable.ProductionType;
import org.spoofax.interpreter.terms.IStrategoNamed;
import org.spoofax.interpreter.terms.IStrategoTerm;
public class ProductionAttributes {
public final ProductionType type;
public final IStrategoTerm constructorTerm;
public final String constructor;
public final boolean isRecover;
public final boolean isBracket;
public final boolean isCompletion;
public final boolean isPlaceholderInsertion;
public final boolean isLiteralCompletion;
public final boolean isIgnoreLayout;
public final boolean isNewlineEnforced;
public final boolean isLongestMatch;
public final boolean isCaseInsensitive;
public final boolean isIndentPaddingLexical;
public final boolean isFlatten;
ProductionAttributes(ProductionType type, IStrategoTerm constructorTerm, boolean isRecover, boolean isBracket,
boolean isCompletion, boolean isPlaceholderInsertion, boolean isLiteralCompletion, boolean isIgnoreIndent,
boolean isNewlineEnforced, boolean isLongestMatch, boolean isCaseInsensitive, boolean isIndentPaddingLexical,
boolean isFlatten) {
this.type = type;
this.constructorTerm = constructorTerm;
this.constructor = constructorTerm == null ? null : ((IStrategoNamed) constructorTerm).getName();
this.isRecover = isRecover;
this.isBracket = isBracket;
this.isCompletion = isCompletion;
this.isPlaceholderInsertion = isPlaceholderInsertion;
this.isLiteralCompletion = isLiteralCompletion;
this.isIgnoreLayout = isIgnoreIndent;
this.isNewlineEnforced = isNewlineEnforced;
this.isLongestMatch = isLongestMatch;
this.isCaseInsensitive = isCaseInsensitive;
this.isIndentPaddingLexical = isIndentPaddingLexical;
this.isFlatten = isFlatten;
}
public boolean isCompletionOrRecovery() {
return isCompletion || isLiteralCompletion || isPlaceholderInsertion || isRecover;
}
@Override public boolean equals(Object o) {
if(this == o) {
return true;
}
if(o == null || getClass() != o.getClass()) {
return false;
}
ProductionAttributes that = (ProductionAttributes) o;
return type.equals(that.type) && Objects.equals(constructorTerm, that.constructorTerm)
&& Objects.equals(constructor, that.constructor) && isRecover == that.isRecover
&& isBracket == that.isBracket && isCompletion == that.isCompletion
&& isPlaceholderInsertion == that.isPlaceholderInsertion && isLiteralCompletion == that.isLiteralCompletion
&& isIgnoreLayout == that.isIgnoreLayout && isNewlineEnforced == that.isNewlineEnforced
&& isLongestMatch == that.isLongestMatch && isCaseInsensitive == that.isCaseInsensitive
&& isIndentPaddingLexical == that.isIndentPaddingLexical && isFlatten == that.isFlatten;
}
}