private static int getExprPriorityLevel(GrExpression expr) { int priority = 0; // if (expr instanceof GrNewExpression) priority = 1; if (expr instanceof GrUnaryExpression) priority = ((GrUnaryExpression) expr).isPostfix() ? 5 : 6; else if (expr instanceof GrTypeCastExpression) priority = 6; else if (expr instanceof GrRangeExpressionImpl) priority = 11; else if (expr instanceof GrBinaryExpression) { final IElementType opToken = ((GrBinaryExpression) expr).getOperationTokenType(); if (opToken == mSTAR_STAR) priority = 7; else if (opToken == mSTAR || opToken == mDIV) priority = 8; else if (opToken == mPLUS || opToken == mMINUS) priority = 9; else if (SHIFT_SIGNS.contains(opToken)) priority = 10; else if (RELATIONS.contains(opToken)) priority = 12; else if (opToken == mEQUAL || opToken == mNOT_EQUAL || opToken == mCOMPARE_TO) priority = 13; else if (opToken == mREGEX_FIND || opToken == mREGEX_MATCH) priority = 14; else if (opToken == mBAND) priority = 15; else if (opToken == mBXOR) priority = 16; else if (opToken == mBOR) priority = 17; else if (opToken == mLAND) priority = 18; else if (opToken == mLOR) priority = 19; } else if (expr instanceof GrConditionalExpression) priority = 20; else if (expr instanceof GrSafeCastExpression) priority = 21; else if (expr instanceof GrAssignmentExpression) priority = 22; else if (expr instanceof GrApplicationStatement) priority = 23; return -priority; }
private static boolean isNotAssociative(GrBinaryExpression binaryExpression) { final IElementType opToken = binaryExpression.getOperationTokenType(); if (binaryExpression instanceof GrMultiplicativeExpressionImpl) { return opToken != mSTAR; } if (binaryExpression instanceof GrAdditiveExpressionImpl) { return opToken == mMINUS; } return RELATIONS.contains(opToken) || opToken == mCOMPARE_TO || opToken == mREGEX_FIND || opToken == mREGEX_MATCH || SHIFT_SIGNS.contains(opToken) || opToken == mSTAR; }