private Expression handleIdentifierSuffix(Java7Parser.PrimaryContext primaryContext, AdapterParameters adapterParameters) {
        /*
            identifierSuffix
            locals [int operationType]
                :   (LBRACKET RBRACKET)+ DOT CLASS                      {$operationType = 1;}
                |   (LBRACKET expression RBRACKET)+                     {$operationType = 2;}
                |   arguments                                           {$operationType = 3;}
                |   DOT CLASS                                           {$operationType = 4;}
                |   DOT nonWildcardTypeArguments Identifier arguments   {$operationType = 5;}
                |   DOT THIS                                            {$operationType = 6;}
                |   innerCreator                                        {$operationType = 7;}
                ;


        //this.m.m.m[].class;        // 0 :   (LBRACKET RBRACKET)+ DOT CLASS                      // ClassOrInterfaceType ClassOrInterfaceType ClassOrInterfaceType ReferenceType ClassExpr
        this.m.m.m[1];             // 1 |   (LBRACKET expression RBRACKET)+                     // NameExpr FieldAccessExpr FieldAccessExpr ArrayAccessExpr
        this.m.m.m("");            // 2 |   arguments                                           // NameExpr FieldAccessExpr MethodCallExpr
        //this.m.m.m.class;          // 3 |   DOT CLASS                                           // ClassOrInterfaceType ClassOrInterfaceType ClassOrInterfaceType ReferenceType ClassExpr
        this.m.m.<T>m("");         // 4 |   DOT nonWildcardTypeArguments Identifier arguments   // NameExpr FieldAccessExpr MethodCallExpr
        this.m.m.m.this;           // 5 |   DOT THIS                                            // NameExpr FieldAccessExpr FieldAccessExpr ThisExpr
        //m.m.super("");      // 6 |   DOT SUPER arguments

        */

        NameExpr nameExpr = new NameExpr();
        nameExpr.setName(primaryContext.Identifier(0).getText());
        Expression leftExpression = nameExpr;

        for (int i = 1; i < primaryContext.Identifier().size(); i++) {
            FieldAccessExpr fieldAccessExpr = new FieldAccessExpr();
            fieldAccessExpr.setField(primaryContext.Identifier(i).getText());
            fieldAccessExpr.setScope(leftExpression);
            leftExpression = fieldAccessExpr;
        }

        // if identifierSuffix is null/not specified
        if (primaryContext.identifierSuffix() == null) {
            return leftExpression;
        }

        ClassOrInterfaceType rootType = new ClassOrInterfaceType();

        if (primaryContext.Identifier() != null && primaryContext.Identifier().size() > 0) {
            rootType.setName(primaryContext.Identifier(0).getText());
        }

        switch (primaryContext.identifierSuffix().operationType) {
            case 1:
            case 4:

                // Need to consider these Identifiers as Types
                // The last one should be a referenceType
                ClassOrInterfaceType leftType = rootType;
                for (int i = 0; i < primaryContext.Identifier().size(); i++) {
                    ClassOrInterfaceType classOrInterfaceType = new ClassOrInterfaceType();
                    classOrInterfaceType.setName(primaryContext.Identifier(i).getText());

                    // Don't set the scope on the first type (because it will be itself)
                    if (i > 0) {
                        classOrInterfaceType.setScope(leftType);
                    }

                    leftType = classOrInterfaceType;
                }

                ReferenceType referenceType = new ReferenceType();
                referenceType.setType(leftType);

                if (primaryContext.identifierSuffix().LBRACKET() != null) {
                    referenceType.setArrayCount(primaryContext.identifierSuffix().LBRACKET().size());
                }

                ClassExpr classExpr = new ClassExpr();
                classExpr.setType(referenceType);

                return classExpr;
            case 2:
                for (int i = 0; i < primaryContext.identifierSuffix().LBRACKET().size(); i++) {
                    ArrayAccessExpr arrayAccessExpr = new ArrayAccessExpr();
                    arrayAccessExpr.setName(leftExpression);
                    arrayAccessExpr.setIndex(Adapters.getExpressionContextAdapter().adapt(primaryContext.identifierSuffix().expression(i), adapterParameters));
                    leftExpression = arrayAccessExpr;
                }

                return leftExpression;
            case 3:
                MethodCallExpr methodCallExpr = new MethodCallExpr();

                if (leftExpression instanceof NameExpr) {
                    methodCallExpr.setName(((NameExpr)leftExpression).getName());
                } else if (leftExpression instanceof FieldAccessExpr) {
                    methodCallExpr.setName(((FieldAccessExpr)leftExpression).getField());

                    // Set the leftExpression back one since we're changing the top one to a method call
                    leftExpression = ((FieldAccessExpr) leftExpression).getScope();
                    methodCallExpr.setScope(leftExpression);
                }

                methodCallExpr.setArgs(Adapters.getArgumentsContextAdapter().adapt(primaryContext.identifierSuffix().arguments(), adapterParameters));
                leftExpression = methodCallExpr;

                return leftExpression;
            case 5:
                List<Type> typeList = Adapters.getTypeListContextAdapter().adapt(primaryContext.identifierSuffix().nonWildcardTypeArguments().typeList(), adapterParameters);

                MethodCallExpr typeArgMethodCallExpr = new MethodCallExpr();
                typeArgMethodCallExpr.setName(primaryContext.identifierSuffix().Identifier().getText());
                typeArgMethodCallExpr.setTypeArgs(typeList);
                typeArgMethodCallExpr.setScope(leftExpression);
                typeArgMethodCallExpr.setArgs(Adapters.getArgumentsContextAdapter().adapt(primaryContext.identifierSuffix().arguments(), adapterParameters));
                leftExpression = typeArgMethodCallExpr;

                return leftExpression;
            case 6:
                ThisExpr thisExpr= new ThisExpr();
                thisExpr.setClassExpr(leftExpression);
                return thisExpr;
            case 7:
                ObjectCreationExpr objectCreationExpr = Adapters.getInnerCreatorContextAdapter().adapt(primaryContext.identifierSuffix().innerCreator(), adapterParameters);
                objectCreationExpr.setScope(leftExpression);
                return objectCreationExpr;
        }

        return null;
    }
private Expression handleIdentifierSuffix ( Java7Parser . PrimaryContext primaryContext , AdapterParameters adapterParameters ) { NameExpr nameExpr = new NameExpr ( ) ; nameExpr . setName ( primaryContext . Identifier ( 0 ) . getText ( ) ) ; Expression leftExpression = nameExpr ; for ( int i = 1 ; i < primaryContext . Identifier ( ) . size ( ) ; i ++ ) { FieldAccessExpr fieldAccessExpr = new FieldAccessExpr ( ) ; fieldAccessExpr . setField ( primaryContext . Identifier ( i ) . getText ( ) ) ; fieldAccessExpr . setScope ( leftExpression ) ; leftExpression = fieldAccessExpr ; } if ( primaryContext . identifierSuffix ( ) == null ) { return leftExpression ; } ClassOrInterfaceType rootType = new ClassOrInterfaceType ( ) ; if ( primaryContext . Identifier ( ) != null && primaryContext . Identifier ( ) . size ( ) > 0 ) { rootType . setName ( primaryContext . Identifier ( 0 ) . getText ( ) ) ; } switch ( primaryContext . identifierSuffix ( ) . operationType ) { case 1 : case 4 : ClassOrInterfaceType leftType = rootType ; for ( int i = 0 ; i < primaryContext . Identifier ( ) . size ( ) ; i ++ ) { ClassOrInterfaceType classOrInterfaceType = new ClassOrInterfaceType ( ) ; classOrInterfaceType . setName ( primaryContext . Identifier ( i ) . getText ( ) ) ; if ( i > 0 ) { classOrInterfaceType . setScope ( leftType ) ; } leftType = classOrInterfaceType ; } ReferenceType referenceType = new ReferenceType ( ) ; referenceType . setType ( leftType ) ; if ( primaryContext . identifierSuffix ( ) . LBRACKET ( ) != null ) { referenceType . setArrayCount ( primaryContext . identifierSuffix ( ) . LBRACKET ( ) . size ( ) ) ; } ClassExpr classExpr = new ClassExpr ( ) ; classExpr . setType ( referenceType ) ; return classExpr ; case 2 : for ( int i = 0 ; i < primaryContext . identifierSuffix ( ) . LBRACKET ( ) . size ( ) ; i ++ ) { ArrayAccessExpr arrayAccessExpr = new ArrayAccessExpr ( ) ; arrayAccessExpr . setName ( leftExpression ) ; arrayAccessExpr . setIndex ( Adapters . getExpressionContextAdapter ( ) . adapt ( primaryContext . identifierSuffix ( ) . expression ( i ) , adapterParameters ) ) ; leftExpression = arrayAccessExpr ; } return leftExpression ; case 3 : MethodCallExpr methodCallExpr = new MethodCallExpr ( ) ; if ( leftExpression instanceof NameExpr ) { methodCallExpr . setName ( ( ( NameExpr ) leftExpression ) . getName ( ) ) ; } else if ( leftExpression instanceof FieldAccessExpr ) { methodCallExpr . setName ( ( ( FieldAccessExpr ) leftExpression ) . getField ( ) ) ; leftExpression = ( ( FieldAccessExpr ) leftExpression ) . getScope ( ) ; methodCallExpr . setScope ( leftExpression ) ; } methodCallExpr . setArgs ( Adapters . getArgumentsContextAdapter ( ) . adapt ( primaryContext . identifierSuffix ( ) . arguments ( ) , adapterParameters ) ) ; leftExpression = methodCallExpr ; return leftExpression ; case 5 : List < Type > typeList = Adapters . getTypeListContextAdapter ( ) . adapt ( primaryContext . identifierSuffix ( ) . nonWildcardTypeArguments ( ) . typeList ( ) , adapterParameters ) ; MethodCallExpr typeArgMethodCallExpr = new MethodCallExpr ( ) ; typeArgMethodCallExpr . setName ( primaryContext . identifierSuffix ( ) . Identifier ( ) . getText ( ) ) ; typeArgMethodCallExpr . setTypeArgs ( typeList ) ; typeArgMethodCallExpr . setScope ( leftExpression ) ; typeArgMethodCallExpr . setArgs ( Adapters . getArgumentsContextAdapter ( ) . adapt ( primaryContext . identifierSuffix ( ) . arguments ( ) , adapterParameters ) ) ; leftExpression = typeArgMethodCallExpr ; return leftExpression ; case 6 : ThisExpr thisExpr = new ThisExpr ( ) ; thisExpr . setClassExpr ( leftExpression ) ; return thisExpr ; case 7 : ObjectCreationExpr objectCreationExpr = Adapters . getInnerCreatorContextAdapter ( ) . adapt ( primaryContext . identifierSuffix ( ) . innerCreator ( ) , adapterParameters ) ; objectCreationExpr . setScope ( leftExpression ) ; return objectCreationExpr ; } return null ; }
Identifier (DOT Identifier)* (identifierSuffix)?   {$operationType = 3;}