Class DispatchHelper


  • public class DispatchHelper
    extends java.lang.Object
    Helpers to deal with dispatch methods. Methods are considered to be dispatch methods, if they are derived from an XtendFunction that is marked as such or if they are defined in a Java type and their name starts with an underscore.
    • Nested Class Summary

      Nested Classes 
      Modifier and Type Class Description
      static class  DispatchHelper.DispatchSignature
      A dispatch signature is a pair of a simple name and an arity.
    • Constructor Summary

      Constructors 
      Constructor Description
      DispatchHelper()  
    • Method Summary

      All Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      protected int compare​(org.eclipse.xtext.common.types.JvmOperation o1, org.eclipse.xtext.common.types.JvmOperation o2)  
      java.util.List<org.eclipse.xtext.common.types.JvmOperation> getAllDispatchCases​(org.eclipse.xtext.common.types.JvmOperation dispatcherOperation)
      Return all the cases that are associated with the given dispatch operation.
      protected java.util.List<org.eclipse.xtext.common.types.JvmOperation> getAllDispatchMethods​(DispatchHelper.DispatchSignature signature, org.eclipse.xtext.common.types.JvmDeclaredType type, org.eclipse.xtext.xbase.typesystem.util.ContextualVisibilityHelper contextualVisibilityHelper)  
      com.google.common.collect.ListMultimap<DispatchHelper.DispatchSignature,​org.eclipse.xtext.common.types.JvmOperation> getDeclaredOrEnhancedDispatchMethods​(org.eclipse.xtext.common.types.JvmDeclaredType type)
      Computes all the dispatch methods that are declared in the given type or altered by additional cases in this type.
      org.eclipse.xtext.common.types.JvmOperation getDispatcherOperation​(org.eclipse.xtext.common.types.JvmDeclaredType type, DispatchHelper.DispatchSignature signature)  
      org.eclipse.xtext.common.types.JvmOperation getDispatcherOperation​(org.eclipse.xtext.common.types.JvmOperation dispatchCase)  
      java.util.List<org.eclipse.xtext.common.types.JvmOperation> getLocalDispatchCases​(org.eclipse.xtext.common.types.JvmDeclaredType type, DispatchHelper.DispatchSignature signature)
      Return the local cases that match the given signature (in no particular order, usually as defined in the file).
      java.util.List<org.eclipse.xtext.common.types.JvmOperation> getLocalDispatchCases​(org.eclipse.xtext.common.types.JvmOperation dispatcherOperation)
      Return the local cases that contribute to the given dispatch operation (in no particular order, but usually as defined in the file).
      protected int getMaxDistanceToObject​(org.eclipse.xtext.common.types.JvmTypeReference type)  
      boolean isDispatcherFunction​(org.eclipse.xtext.common.types.JvmOperation inferredOperation)  
      boolean isDispatchFunction​(org.eclipse.xtext.common.types.JvmOperation inferredOperation)  
      void markAsDispatcherFunction​(org.eclipse.xtext.common.types.JvmOperation inferredOperation)  
      protected void sort​(java.util.List<org.eclipse.xtext.common.types.JvmOperation> operations)  
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • Constructor Detail

      • DispatchHelper

        public DispatchHelper()
    • Method Detail

      • markAsDispatcherFunction

        public void markAsDispatcherFunction​(org.eclipse.xtext.common.types.JvmOperation inferredOperation)
      • isDispatcherFunction

        public boolean isDispatcherFunction​(org.eclipse.xtext.common.types.JvmOperation inferredOperation)
      • isDispatchFunction

        public boolean isDispatchFunction​(org.eclipse.xtext.common.types.JvmOperation inferredOperation)
      • getDispatcherOperation

        public org.eclipse.xtext.common.types.JvmOperation getDispatcherOperation​(org.eclipse.xtext.common.types.JvmOperation dispatchCase)
      • getDispatcherOperation

        public org.eclipse.xtext.common.types.JvmOperation getDispatcherOperation​(org.eclipse.xtext.common.types.JvmDeclaredType type,
                                                                                  DispatchHelper.DispatchSignature signature)
      • getLocalDispatchCases

        public java.util.List<org.eclipse.xtext.common.types.JvmOperation> getLocalDispatchCases​(org.eclipse.xtext.common.types.JvmDeclaredType type,
                                                                                                 DispatchHelper.DispatchSignature signature)
        Return the local cases that match the given signature (in no particular order, usually as defined in the file).
      • getLocalDispatchCases

        public java.util.List<org.eclipse.xtext.common.types.JvmOperation> getLocalDispatchCases​(org.eclipse.xtext.common.types.JvmOperation dispatcherOperation)
        Return the local cases that contribute to the given dispatch operation (in no particular order, but usually as defined in the file).
      • getAllDispatchCases

        public java.util.List<org.eclipse.xtext.common.types.JvmOperation> getAllDispatchCases​(org.eclipse.xtext.common.types.JvmOperation dispatcherOperation)
        Return all the cases that are associated with the given dispatch operation.
      • getDeclaredOrEnhancedDispatchMethods

        public com.google.common.collect.ListMultimap<DispatchHelper.DispatchSignature,​org.eclipse.xtext.common.types.JvmOperation> getDeclaredOrEnhancedDispatchMethods​(org.eclipse.xtext.common.types.JvmDeclaredType type)
        Computes all the dispatch methods that are declared in the given type or altered by additional cases in this type. The associated operations are sorted by according their parameter types from left to right where the most special types occur before more common types. Ambiguous ordering is resolved alphabetically. An exemplary order would look like this
           method(String)
           method(Serializable)
           method(CharSequence)
           method(Object)
         
        Returns:
        a mapping from signature to sorted operations.
      • getAllDispatchMethods

        protected java.util.List<org.eclipse.xtext.common.types.JvmOperation> getAllDispatchMethods​(DispatchHelper.DispatchSignature signature,
                                                                                                    org.eclipse.xtext.common.types.JvmDeclaredType type,
                                                                                                    org.eclipse.xtext.xbase.typesystem.util.ContextualVisibilityHelper contextualVisibilityHelper)
      • sort

        protected void sort​(java.util.List<org.eclipse.xtext.common.types.JvmOperation> operations)
      • compare

        protected int compare​(org.eclipse.xtext.common.types.JvmOperation o1,
                              org.eclipse.xtext.common.types.JvmOperation o2)
      • getMaxDistanceToObject

        protected int getMaxDistanceToObject​(org.eclipse.xtext.common.types.JvmTypeReference type)