Class GrammarConstraintProvider.Constraint
- java.lang.Object
-
- org.eclipse.xtext.serializer.analysis.GrammarConstraintProvider.Constraint
-
- All Implemented Interfaces:
java.lang.Comparable<IGrammarConstraintProvider.IConstraint>,IGrammarConstraintProvider.IConstraint
- Enclosing class:
- GrammarConstraintProvider
protected static class GrammarConstraintProvider.Constraint extends java.lang.Object implements IGrammarConstraintProvider.IConstraint
-
-
Constructor Summary
Constructors Constructor Description Constraint(Grammar grammar, org.eclipse.emf.ecore.EClass type, org.eclipse.xtext.util.formallang.Nfa<ISemanticSequencerNfaProvider.ISemState> nfa)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description intcompareTo(IGrammarConstraintProvider.IConstraint o)protected int[]computeLowerBounds()protected int[]computeUpperBounds()Computing the upper bounds is equivalent to the longest path problem.booleanequals(java.lang.Object obj)IGrammarConstraintProvider.IConstraintElementgetBody()java.util.List<ISerializationContext>getContexts()IGrammarConstraintProvider.IFeatureInfo[]getFeatures()protected java.lang.StringgetIdentity()java.lang.StringgetName()org.eclipse.xtext.util.formallang.Nfa<ISemanticSequencerNfaProvider.ISemState>getNfa()java.lang.StringgetSimpleName()org.eclipse.emf.ecore.EClassgetType()inthashCode()protected voidsetName(java.lang.String name)java.lang.StringtoString()
-
-
-
Constructor Detail
-
Constraint
public Constraint(Grammar grammar, org.eclipse.emf.ecore.EClass type, org.eclipse.xtext.util.formallang.Nfa<ISemanticSequencerNfaProvider.ISemState> nfa)
-
-
Method Detail
-
computeLowerBounds
protected int[] computeLowerBounds()
-
computeUpperBounds
protected int[] computeUpperBounds()
Computing the upper bounds is equivalent to the longest path problem. While this is NP-hard if constrained to simple paths, it becomes easily solvable in our case since we include infinite paths. All features that are assigned inside a cycle have infinity as upper bound. For the remaining features we can handle each cycle as if it was a single node because it is not relevant where we enter the cycle and where we exit it (traversing the cycle has zero weight). The resulting simplified graph is acyclic, and in such graphs the longest path can be computed in linear time with a simple recursive algorithm.
-
compareTo
public int compareTo(IGrammarConstraintProvider.IConstraint o)
- Specified by:
compareToin interfacejava.lang.Comparable<IGrammarConstraintProvider.IConstraint>
-
equals
public boolean equals(java.lang.Object obj)
- Overrides:
equalsin classjava.lang.Object
-
getBody
public IGrammarConstraintProvider.IConstraintElement getBody()
- Specified by:
getBodyin interfaceIGrammarConstraintProvider.IConstraint- Returns:
- the root of the tree of
IGrammarConstraintProvider.IConstraintElementthat defines this constraint.
-
getContexts
public java.util.List<ISerializationContext> getContexts()
- Specified by:
getContextsin interfaceIGrammarConstraintProvider.IConstraint
-
getFeatures
public IGrammarConstraintProvider.IFeatureInfo[] getFeatures()
- Specified by:
getFeaturesin interfaceIGrammarConstraintProvider.IConstraint- Returns:
- a list of
IGrammarConstraintProvider.IFeatureInfofor allEStructuralFeatures from theEClassreturned byIGrammarConstraintProvider.IConstraint.getType()that have an assignment if this constraint. If there is no assignment for anEStructuralFeaturein this constraint, the array's item is null.
-
getIdentity
protected java.lang.String getIdentity()
-
getName
public java.lang.String getName()
- Specified by:
getNamein interfaceIGrammarConstraintProvider.IConstraint- Returns:
- a name that is unique for a grammar and that aims to be human-readable.
-
getNfa
public org.eclipse.xtext.util.formallang.Nfa<ISemanticSequencerNfaProvider.ISemState> getNfa()
- Specified by:
getNfain interfaceIGrammarConstraintProvider.IConstraint
-
getSimpleName
public java.lang.String getSimpleName()
- Specified by:
getSimpleNamein interfaceIGrammarConstraintProvider.IConstraint
-
getType
public org.eclipse.emf.ecore.EClass getType()
- Specified by:
getTypein interfaceIGrammarConstraintProvider.IConstraint- Returns:
- This constraint only applies to EObjects of this type.
-
hashCode
public int hashCode()
- Overrides:
hashCodein classjava.lang.Object
-
setName
protected void setName(java.lang.String name)
-
toString
public java.lang.String toString()
- Overrides:
toStringin classjava.lang.Object
-
-