Interface NodeWithVariables<N extends Node>

    • Method Detail

      • getCommonType

        default Type getCommonType()
        Returns the type that is shared between all variables. This is a shortcut for when you are certain that all variables share one type. What makes this difficult is arrays, and being able to set the type.
        For int a; this is int.
        For int a,b,c,d; this is also int.
        For int a,b[],c; this is an assertion error since b is an int[], not an int.
        For int a,b;, then doing setType(String) on b, this is an assertion error. It is also a situation that you don't really want.
      • getElementType

        default Type getElementType()
        Returns the element type.
        For int a; this is int.
        For int a,b,c,d; this is also int.
        For int a,b[],c; this is also int. Note: no mention of b being an array.
        For int a,b;, then doing setType(String) on b, then calling getElementType(). This is an assertion error. It is also a situation that you don't really want.
      • getMaximumCommonType

        default Optional<Type> getMaximumCommonType()
        Returns the type that maximum shared type between all variables. The minimum common type does never include annotations on the array level.


        For int a; this is int.
        For int a,b,c,d; this is also int.
        For int a,b[],c; this is also int.
        For int[] a[][],b[],c[][]; this is int[][].

      • calculateMaximumCommonType

        static Optional<Type> calculateMaximumCommonType​(List<Type> types)