Package org.eclipse.xsemantics.runtime
Class XsemanticsRuntimeSystem
- java.lang.Object
-
- org.eclipse.xsemantics.runtime.XsemanticsRuntimeSystem
-
public class XsemanticsRuntimeSystem extends java.lang.ObjectAll generated systems will inherit from this class.- Author:
- Lorenzo Bettini
-
-
Field Summary
Fields Modifier and Type Field Description protected static intINDEX_OF_AUX_PARAMETERSprotected static intINDEX_OF_RULE_PARAMETERSprotected StringRepresentationstringRepresentation
-
Constructor Summary
Constructors Constructor Description XsemanticsRuntimeSystem()
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description voidaddAsSubtrace(RuleApplicationTrace ruleApplicationTrace, RuleApplicationTrace subTrace)<T> voidaddToList(java.util.List<T> list, java.lang.Object o, java.lang.Class<? extends T> clazz)Adds the object (or if the object is a list itself, all its elements, recursively) to the list, if the object can be assigned to the passed clazz.voidaddToTrace(RuleApplicationTrace ruleApplicationTrace, com.google.inject.Provider<? extends java.lang.Object> traceElementProvider)If the passed ruleApplicationTrace is not null, then uses the traceElementProvider to create an element to add to the trace.protected java.lang.StringauxFunName(java.lang.String ruleName)protected <T> org.eclipse.xtext.util.PolymorphicDispatcher<T>buildPolymorphicDispatcher(java.lang.String methodName, int numOfArgs)protected <T> org.eclipse.xtext.util.PolymorphicDispatcher<Result<T>>buildPolymorphicDispatcher1(java.lang.String methodName, int numOfArgs, java.lang.String judgmentSymbol, java.lang.String... relationSymbols)protected <F,S>
org.eclipse.xtext.util.PolymorphicDispatcher<Result2<F,S>>buildPolymorphicDispatcher2(java.lang.String methodName, int numOfArgs, java.lang.String judgmentSymbol, java.lang.String... relationSymbols)protected <F,S,T>
org.eclipse.xtext.util.PolymorphicDispatcher<Result3<F,S,T>>buildPolymorphicDispatcher3(java.lang.String methodName, int numOfArgs, java.lang.String judgmentSymbol, java.lang.String... relationSymbols)voidcheckAssignableTo(java.lang.Object result, java.lang.Class<?> destinationClass)Checks whether the result is assignable to the specified destinationClass; if not it throws aRuleFailedException.voidcheckNotNull(java.lang.Object object)Checks that the passed object is not null; if it is null it throws aRuleFailedException.voidcheckParamsNotNull(java.lang.Object... objects)<T extends org.eclipse.emf.ecore.EObject>
Tclone(T eObject)protected RuleFailedExceptioncreateRuleFailedException(java.lang.String message, java.lang.String issue, java.lang.Throwable t)This factory method can be overridden if one needs to provide a custom implementation ofRuleFailedException.RuleEnvironmentemptyEnvironment()<T> Tenv(RuleEnvironment environment, java.lang.Object key, java.lang.Class<? extends T> clazz)This method replaces the previous keyword 'env' in Xsemantics grammar (before version 1.5.0).<T> TenvironmentAccess(RuleEnvironment environment, java.lang.Object key, java.lang.Class<? extends T> clazz)RuleEnvironmentenvironmentComposition(RuleEnvironment environment, RuleEnvironment environment2)RuleEnvironmentenvironmentEntry(java.lang.Object key, java.lang.Object value)RuleFailedExceptionextractRuleFailedException(java.lang.Exception e)protected java.lang.Stringfailed(java.lang.String message)<T> java.util.List<T>getAll(org.eclipse.emf.ecore.EObject eObject, org.eclipse.emf.ecore.EStructuralFeature mainFeature, org.eclipse.emf.ecore.EStructuralFeature extendFeature, java.lang.Class<? extends T> clazz)java.util.List<org.eclipse.emf.ecore.EObject>getAllNodesInRelation(org.eclipse.emf.ecore.EObject eObject, org.eclipse.emf.ecore.EStructuralFeature extendFeature)protected voidgetAllNodesInRelation(org.eclipse.emf.ecore.EObject eObject, org.eclipse.emf.ecore.EStructuralFeature extendFeature, java.util.List<org.eclipse.emf.ecore.EObject> nodes, java.util.Set<org.eclipse.emf.ecore.EObject> seen)XsemanticsCachegetCache()org.eclipse.emf.ecore.EObjectgetEObject(java.lang.Object object)protected <T> TgetFromCache(java.lang.String methodName, RuleEnvironment environment, RuleApplicationTrace trace, XsemanticsProvider<T> provider, java.lang.Object... elements)java.util.List<java.lang.Object>getList(java.lang.Object object)If the object is a list returns the list itself, otherwise returns a list with only the passed object as element.protected com.google.common.base.Predicate<java.lang.reflect.Method>getPredicate(java.lang.String methodName, int numOfArgs)booleanisResultAssignableTo(java.lang.Object result, java.lang.Class<?> destinationClass)RuleFailedExceptionnewRuleFailedException()RuleFailedExceptionnewRuleFailedException(java.lang.String message)RuleFailedExceptionnewRuleFailedException(java.lang.String message, java.lang.String issue, java.lang.Throwable t, ErrorInformation... errorInformations)RuleFailedExceptionnewRuleFailedException(java.lang.String message, java.lang.String issue, ErrorInformation... errorInformations)RuleFailedExceptionnewRuleFailedException(java.lang.Throwable t)RuleApplicationTracenewTrace(RuleApplicationTrace ruleApplicationTrace)protected RuleFailedExceptionnoSuchMethodException(java.lang.String judgmentSymbol, java.lang.Iterable<java.lang.String> relationSymbols, java.lang.Object... params)protected RuleFailedExceptionnoSuchMethodException(java.lang.String name, java.lang.Object... params)protected <T> Result<T>resultForFailure(java.lang.Exception e)protected <F,S>
Result2<F,S>resultForFailure2(java.lang.Exception e)protected <F,S,T>
Result3<F,S,T>resultForFailure3(java.lang.Exception e)protected java.lang.StringruleName(java.lang.String ruleName)voidsneakyThrowRuleFailedException(java.lang.Exception e)voidsneakyThrowRuleFailedException(java.lang.String message)java.lang.StringstringRep(java.lang.Object object)protected java.lang.StringstringRepForEnv(RuleEnvironment ruleEnvironment)protected java.lang.StringstringRepForParams(java.lang.Object[] params)protected java.lang.StringstringRepForParams(java.lang.Object[] params, java.lang.Iterable<java.lang.String> relationSymbols)voidthrowForExplicitFail()voidthrowForExplicitFail(java.lang.String message, ErrorInformation errorInformation)voidthrowRuleFailedException(java.lang.String message, java.lang.String issue, java.lang.Throwable t, ErrorInformation... errorInformations)protected java.lang.StringtrimIfNotNull(java.lang.String message)
-
-
-
Field Detail
-
INDEX_OF_RULE_PARAMETERS
protected static final int INDEX_OF_RULE_PARAMETERS
- See Also:
- Constant Field Values
-
INDEX_OF_AUX_PARAMETERS
protected static final int INDEX_OF_AUX_PARAMETERS
- See Also:
- Constant Field Values
-
stringRepresentation
@Inject protected StringRepresentation stringRepresentation
-
-
Method Detail
-
getCache
public XsemanticsCache getCache()
- Since:
- 1.6
-
getFromCache
protected <T> T getFromCache(java.lang.String methodName, RuleEnvironment environment, RuleApplicationTrace trace, XsemanticsProvider<T> provider, java.lang.Object... elements)- Since:
- 1.6
-
getPredicate
protected com.google.common.base.Predicate<java.lang.reflect.Method> getPredicate(java.lang.String methodName, int numOfArgs)
-
buildPolymorphicDispatcher
protected <T> org.eclipse.xtext.util.PolymorphicDispatcher<T> buildPolymorphicDispatcher(java.lang.String methodName, int numOfArgs)
-
buildPolymorphicDispatcher1
protected <T> org.eclipse.xtext.util.PolymorphicDispatcher<Result<T>> buildPolymorphicDispatcher1(java.lang.String methodName, int numOfArgs, java.lang.String judgmentSymbol, java.lang.String... relationSymbols)
-
buildPolymorphicDispatcher2
protected <F,S> org.eclipse.xtext.util.PolymorphicDispatcher<Result2<F,S>> buildPolymorphicDispatcher2(java.lang.String methodName, int numOfArgs, java.lang.String judgmentSymbol, java.lang.String... relationSymbols)
-
buildPolymorphicDispatcher3
protected <F,S,T> org.eclipse.xtext.util.PolymorphicDispatcher<Result3<F,S,T>> buildPolymorphicDispatcher3(java.lang.String methodName, int numOfArgs, java.lang.String judgmentSymbol, java.lang.String... relationSymbols)
-
isResultAssignableTo
public boolean isResultAssignableTo(java.lang.Object result, java.lang.Class<?> destinationClass)
-
checkAssignableTo
public void checkAssignableTo(java.lang.Object result, java.lang.Class<?> destinationClass)Checks whether the result is assignable to the specified destinationClass; if not it throws aRuleFailedException.- Parameters:
result-destinationClass-
-
checkParamsNotNull
public void checkParamsNotNull(java.lang.Object... objects)
-
checkNotNull
public void checkNotNull(java.lang.Object object)
Checks that the passed object is not null; if it is null it throws aRuleFailedException.- Parameters:
object-
-
stringRep
public java.lang.String stringRep(java.lang.Object object)
-
stringRepForEnv
protected java.lang.String stringRepForEnv(RuleEnvironment ruleEnvironment)
-
stringRepForParams
protected java.lang.String stringRepForParams(java.lang.Object[] params, java.lang.Iterable<java.lang.String> relationSymbols)
-
stringRepForParams
protected java.lang.String stringRepForParams(java.lang.Object[] params)
-
noSuchMethodException
protected RuleFailedException noSuchMethodException(java.lang.String judgmentSymbol, java.lang.Iterable<java.lang.String> relationSymbols, java.lang.Object... params)
-
noSuchMethodException
protected RuleFailedException noSuchMethodException(java.lang.String name, java.lang.Object... params)
-
sneakyThrowRuleFailedException
public void sneakyThrowRuleFailedException(java.lang.Exception e)
-
sneakyThrowRuleFailedException
public void sneakyThrowRuleFailedException(java.lang.String message)
-
throwForExplicitFail
public void throwForExplicitFail()
-
throwForExplicitFail
public void throwForExplicitFail(java.lang.String message, ErrorInformation errorInformation)
-
throwRuleFailedException
public void throwRuleFailedException(java.lang.String message, java.lang.String issue, java.lang.Throwable t, ErrorInformation... errorInformations)
-
newRuleFailedException
public RuleFailedException newRuleFailedException()
- Since:
- 1.5
-
newRuleFailedException
public RuleFailedException newRuleFailedException(java.lang.Throwable t)
- Since:
- 1.5
-
newRuleFailedException
public RuleFailedException newRuleFailedException(java.lang.String message)
- Since:
- 1.5
-
newRuleFailedException
public RuleFailedException newRuleFailedException(java.lang.String message, java.lang.String issue, ErrorInformation... errorInformations)
-
newRuleFailedException
public RuleFailedException newRuleFailedException(java.lang.String message, java.lang.String issue, java.lang.Throwable t, ErrorInformation... errorInformations)
-
createRuleFailedException
protected RuleFailedException createRuleFailedException(java.lang.String message, java.lang.String issue, java.lang.Throwable t)
This factory method can be overridden if one needs to provide a custom implementation ofRuleFailedException.- Parameters:
message-issue-t-- Returns:
- Since:
- 1.5
-
extractRuleFailedException
public RuleFailedException extractRuleFailedException(java.lang.Exception e)
-
resultForFailure
protected <T> Result<T> resultForFailure(java.lang.Exception e)
-
resultForFailure2
protected <F,S> Result2<F,S> resultForFailure2(java.lang.Exception e)
-
resultForFailure3
protected <F,S,T> Result3<F,S,T> resultForFailure3(java.lang.Exception e)
-
failed
protected java.lang.String failed(java.lang.String message)
-
trimIfNotNull
protected java.lang.String trimIfNotNull(java.lang.String message)
-
ruleName
protected java.lang.String ruleName(java.lang.String ruleName)
-
auxFunName
protected java.lang.String auxFunName(java.lang.String ruleName)
-
addToTrace
public void addToTrace(RuleApplicationTrace ruleApplicationTrace, com.google.inject.Provider<? extends java.lang.Object> traceElementProvider)
If the passed ruleApplicationTrace is not null, then uses the traceElementProvider to create an element to add to the trace. Using a provider instead of the actual element avoids the creation of such element in case the ruleApplicationTrace is null, heavily reducing overhead and increasing performance. See also https ://github.com/LorenzoBettini/xsemantics/pull/27- Parameters:
ruleApplicationTrace-traceElementProvider-- Since:
- 1.6
-
newTrace
public RuleApplicationTrace newTrace(RuleApplicationTrace ruleApplicationTrace)
-
addAsSubtrace
public void addAsSubtrace(RuleApplicationTrace ruleApplicationTrace, RuleApplicationTrace subTrace)
-
env
public <T> T env(RuleEnvironment environment, java.lang.Object key, java.lang.Class<? extends T> clazz) throws RuleFailedException
This method replaces the previous keyword 'env' in Xsemantics grammar (before version 1.5.0). It is useless to have such element in the grammar, since it has exactly the same syntax of this Java method invocation.- Parameters:
environment-key-clazz-- Returns:
- Throws:
RuleFailedException- Since:
- 1.5
-
environmentAccess
public <T> T environmentAccess(RuleEnvironment environment, java.lang.Object key, java.lang.Class<? extends T> clazz) throws RuleFailedException
- Throws:
RuleFailedException
-
clone
public <T extends org.eclipse.emf.ecore.EObject> T clone(T eObject)
-
emptyEnvironment
public RuleEnvironment emptyEnvironment()
-
environmentEntry
public RuleEnvironment environmentEntry(java.lang.Object key, java.lang.Object value)
-
environmentComposition
public RuleEnvironment environmentComposition(RuleEnvironment environment, RuleEnvironment environment2)
-
getAll
public <T> java.util.List<T> getAll(org.eclipse.emf.ecore.EObject eObject, org.eclipse.emf.ecore.EStructuralFeature mainFeature, org.eclipse.emf.ecore.EStructuralFeature extendFeature, java.lang.Class<? extends T> clazz)
-
getAllNodesInRelation
public java.util.List<org.eclipse.emf.ecore.EObject> getAllNodesInRelation(org.eclipse.emf.ecore.EObject eObject, org.eclipse.emf.ecore.EStructuralFeature extendFeature)
-
getAllNodesInRelation
protected void getAllNodesInRelation(org.eclipse.emf.ecore.EObject eObject, org.eclipse.emf.ecore.EStructuralFeature extendFeature, java.util.List<org.eclipse.emf.ecore.EObject> nodes, java.util.Set<org.eclipse.emf.ecore.EObject> seen)
-
getList
public java.util.List<java.lang.Object> getList(java.lang.Object object)
If the object is a list returns the list itself, otherwise returns a list with only the passed object as element.- Parameters:
object-- Returns:
-
getEObject
public org.eclipse.emf.ecore.EObject getEObject(java.lang.Object object)
-
addToList
public <T> void addToList(java.util.List<T> list, java.lang.Object o, java.lang.Class<? extends T> clazz)Adds the object (or if the object is a list itself, all its elements, recursively) to the list, if the object can be assigned to the passed clazz.- Parameters:
list-o-clazz-
-
-