Skip to content

Commit

Permalink
Fix for #990: use redirect for reference comparison
Browse files Browse the repository at this point in the history
  • Loading branch information
eric-milles committed Nov 11, 2019
1 parent cbdc80d commit 3239180
Show file tree
Hide file tree
Showing 5 changed files with 40 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -347,6 +347,9 @@ public static ClassNode getUnwrapper(ClassNode cn) {
* @see #make(String)
*/
public static boolean isPrimitiveType(ClassNode cn) {
// GRECLIPSE add
cn = cn.redirect();
// GRECLIPSE end
return cn == boolean_TYPE ||
cn == char_TYPE ||
cn == byte_TYPE ||
Expand All @@ -371,6 +374,9 @@ public static boolean isPrimitiveType(ClassNode cn) {
* @see #make(String)
*/
public static boolean isStaticConstantInitializerType(ClassNode cn) {
// GRECLIPSE add
cn = cn.redirect();
// GRECLIPSE end
return cn == int_TYPE ||
cn == float_TYPE ||
cn == long_TYPE ||
Expand All @@ -383,6 +389,9 @@ public static boolean isStaticConstantInitializerType(ClassNode cn) {
}

public static boolean isNumberType(ClassNode cn) {
// GRECLIPSE add
cn = cn.redirect();
// GRECLIPSE end
return cn == Byte_TYPE ||
cn == Short_TYPE ||
cn == Integer_TYPE ||
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -355,6 +355,9 @@ public static boolean isPrimitiveType(ClassNode cn) {
* @see #make(String)
*/
public static boolean isStaticConstantInitializerType(ClassNode cn) {
// GRECLIPSE add
cn = cn.redirect();
// GRECLIPSE end
return cn == int_TYPE ||
cn == float_TYPE ||
cn == long_TYPE ||
Expand All @@ -367,6 +370,9 @@ public static boolean isStaticConstantInitializerType(ClassNode cn) {
}

public static boolean isNumberType(ClassNode cn) {
// GRECLIPSE add
cn = cn.redirect();
// GRECLIPSE end
return cn == Byte_TYPE ||
cn == Short_TYPE ||
cn == Integer_TYPE ||
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -384,6 +384,9 @@ public static boolean isPrimitiveType(ClassNode cn) {
* @see #make(String)
*/
public static boolean isStaticConstantInitializerType(ClassNode cn) {
// GRECLIPSE add
cn = cn.redirect();
// GRECLIPSE end
return cn == int_TYPE ||
cn == float_TYPE ||
cn == long_TYPE ||
Expand All @@ -396,6 +399,9 @@ public static boolean isStaticConstantInitializerType(ClassNode cn) {
}

public static boolean isNumberType(ClassNode cn) {
// GRECLIPSE add
cn = cn.redirect();
// GRECLIPSE end
return cn == Byte_TYPE ||
cn == Short_TYPE ||
cn == Integer_TYPE ||
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -263,7 +263,7 @@ public static String getTypeSignatureWithoutGenerics(ClassNode node, boolean qua
}

public static ClassNode getWrapperTypeIfPrimitive(ClassNode type) {
if (ClassHelper.isPrimitiveType(type) && !ClassHelper.VOID_TYPE.equals(type)) {
if (type != null && ClassHelper.isPrimitiveType(type) && !ClassHelper.VOID_TYPE.equals(type)) {
return ClassHelper.getWrapper(type);
}
return type;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -978,6 +978,24 @@ final class SemanticHighlightingTests extends GroovyEclipseTestSuite {
new HighlightedTypedPosition(contents.lastIndexOf('zero'), 4, METHOD_CALL))
}

@Test
void testMultiAssign1() {
String contents = '''\
|@groovy.transform.CompileStatic
|void meth() {
| def (Integer i, String s) = [123, 'abc']
|}
|'''.stripMargin()

assertHighlighting(contents,
new HighlightedTypedPosition(contents.indexOf('meth'), 4, METHOD),
new HighlightedTypedPosition(contents.indexOf('Integer'), 7, CLASS),
new HighlightedTypedPosition(contents.indexOf('i,'), 1, VARIABLE),
new HighlightedTypedPosition(contents.indexOf('String'), 6, CLASS),
new HighlightedTypedPosition(contents.indexOf('s)'), 1, VARIABLE),
new HighlightedTypedPosition(contents.indexOf('123'), 3, NUMBER))
}

@Test
void testCatchParam() {
// don't want PARAMETER
Expand Down

0 comments on commit 3239180

Please sign in to comment.