From 25def866b50860715ee7c315c678b8c3d1ba9b56 Mon Sep 17 00:00:00 2001 From: Roel Spilker Date: Sun, 29 Apr 2012 23:32:25 +0200 Subject: Issue 366: don't call the getter twice, fixed for Eclipse. --- .../eclipse/handlers/HandleEqualsAndHashCode.java | 180 ++++++++++++--------- .../javac/handlers/HandleEqualsAndHashCode.java | 2 +- 2 files changed, 109 insertions(+), 73 deletions(-) (limited to 'src') diff --git a/src/core/lombok/eclipse/handlers/HandleEqualsAndHashCode.java b/src/core/lombok/eclipse/handlers/HandleEqualsAndHashCode.java index 82a8f00e..50991e7b 100644 --- a/src/core/lombok/eclipse/handlers/HandleEqualsAndHashCode.java +++ b/src/core/lombok/eclipse/handlers/HandleEqualsAndHashCode.java @@ -1,5 +1,5 @@ /* - * Copyright (C) 2009-2011 The Project Lombok Authors. + * Copyright (C) 2009-2012 The Project Lombok Authors. * * Permission is hereby granted, free of charge, to any person obtaining a copy * of this software and associated documentation files (the "Software"), to deal @@ -32,6 +32,16 @@ import java.util.HashSet; import java.util.List; import java.util.Set; +import lombok.AccessLevel; +import lombok.EqualsAndHashCode; +import lombok.core.AST.Kind; +import lombok.core.AnnotationValues; +import lombok.eclipse.Eclipse; +import lombok.eclipse.EclipseAnnotationHandler; +import lombok.eclipse.EclipseNode; +import lombok.eclipse.handlers.EclipseHandlerUtil.FieldAccess; +import lombok.eclipse.handlers.EclipseHandlerUtil.MemberExistsResult; + import org.eclipse.jdt.internal.compiler.ast.ASTNode; import org.eclipse.jdt.internal.compiler.ast.Annotation; import org.eclipse.jdt.internal.compiler.ast.Argument; @@ -72,19 +82,15 @@ import org.eclipse.jdt.internal.compiler.lookup.TypeConstants; import org.eclipse.jdt.internal.compiler.lookup.TypeIds; import org.mangosdk.spi.ProviderFor; -import lombok.AccessLevel; -import lombok.EqualsAndHashCode; -import lombok.core.AnnotationValues; -import lombok.core.AST.Kind; -import lombok.eclipse.Eclipse; -import lombok.eclipse.EclipseAnnotationHandler; -import lombok.eclipse.EclipseNode; - /** * Handles the {@code EqualsAndHashCode} annotation for eclipse. */ @ProviderFor(EclipseAnnotationHandler.class) public class HandleEqualsAndHashCode extends EclipseAnnotationHandler { + + private final char[] PRIME = "PRIME".toCharArray(); + private final char[] RESULT = "result".toCharArray(); + private static final Set BUILT_IN_TYPES = Collections.unmodifiableSet(new HashSet(Arrays.asList( "byte", "short", "int", "long", "char", "boolean", "double", "float"))); @@ -257,10 +263,7 @@ public class HandleEqualsAndHashCode extends EclipseAnnotationHandler statements = new ArrayList(); - List intoResult = new ArrayList(); - final char[] PRIME = "PRIME".toCharArray(); - final char[] RESULT = "result".toCharArray(); final boolean isEmpty = fields.isEmpty(); /* final int PRIME = 31; */ { @@ -294,16 +297,30 @@ public class HandleEqualsAndHashCode extends EclipseAnnotationHandler 0 && token != null) { /* Arrays.deepHashCode(array) //just hashCode for simple arrays */ @@ -374,29 +382,7 @@ public class HandleEqualsAndHashCode extends EclipseAnnotationHandler list = new ArrayList(); @@ -611,21 +631,37 @@ public class HandleEqualsAndHashCode extends EclipseAnnotationHandler