From 9d2d58cd20a10e988b4e09712f71fd2685b0dfd6 Mon Sep 17 00:00:00 2001 From: "alexey.afanasiev" Date: Mon, 15 May 2017 18:13:04 +0300 Subject: [PATCH] EA-82357 - NPE: ParenthesesUtils.precedenceForBinaryOperator --- .../groovy/lang/psi/impl/utils/ParenthesesUtils.java | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/plugins/groovy/groovy-psi/src/org/jetbrains/plugins/groovy/lang/psi/impl/utils/ParenthesesUtils.java b/plugins/groovy/groovy-psi/src/org/jetbrains/plugins/groovy/lang/psi/impl/utils/ParenthesesUtils.java index 153160a16af7..cd911f0991ea 100644 --- a/plugins/groovy/groovy-psi/src/org/jetbrains/plugins/groovy/lang/psi/impl/utils/ParenthesesUtils.java +++ b/plugins/groovy/groovy-psi/src/org/jetbrains/plugins/groovy/lang/psi/impl/utils/ParenthesesUtils.java @@ -1,5 +1,5 @@ /* - * Copyright 2000-2014 JetBrains s.r.o. + * Copyright 2000-2017 JetBrains s.r.o. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -124,10 +124,14 @@ public class ParenthesesUtils { BINARY_PRECEDENCES.put(GroovyTokenTypes.mNOT_EQUAL, EQUALITY_PRECEDENCE); BINARY_PRECEDENCES.put(GroovyTokenTypes.mCOMPARE_TO, EQUALITY_PRECEDENCE); BINARY_PRECEDENCES.put(GroovyTokenTypes.kAS, SAFE_CAST_PRECEDENCE); + + BINARY_PRECEDENCES.put(GroovyTokenTypes.mREGEX_FIND, EQUALITY_PRECEDENCE); + BINARY_PRECEDENCES.put(GroovyTokenTypes.mREGEX_MATCH, EQUALITY_PRECEDENCE); } public static int precedenceForBinaryOperator(@NotNull IElementType sign) { - return BINARY_PRECEDENCES.get(sign); + Integer result = BINARY_PRECEDENCES.get(sign); + return result != null ? result : 0; }