Class XsemanticsRuntimeSystem


  • public class XsemanticsRuntimeSystem
    extends java.lang.Object
    All generated systems will inherit from this class.
    Author:
    Lorenzo Bettini
    • Constructor Detail

      • XsemanticsRuntimeSystem

        public XsemanticsRuntimeSystem()
    • Method Detail

      • 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 a RuleFailedException.
        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 a RuleFailedException.
        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​(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,
                                                          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 of RuleFailedException.
        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
      • 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
      • clone

        public <T extends org.eclipse.emf.ecore.EObject> T clone​(T eObject)
      • environmentEntry

        public RuleEnvironment environmentEntry​(java.lang.Object key,
                                                java.lang.Object value)
      • 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 -