aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorReinier Zwitserloot <reinier@zwitserloot.com>2012-08-13 02:45:58 +0200
committerReinier Zwitserloot <reinier@zwitserloot.com>2012-08-13 02:46:43 +0200
commitafcb211e47f387c5c9b42a0d954e247aec84e781 (patch)
tree25e8d72850e532bee879aa4a3d80be8daf79de0e /src
parentd1539a3ec2e49297d358b0690d84e6319c27f93c (diff)
downloadlombok-afcb211e47f387c5c9b42a0d954e247aec84e781.tar.gz
lombok-afcb211e47f387c5c9b42a0d954e247aec84e781.tar.bz2
lombok-afcb211e47f387c5c9b42a0d954e247aec84e781.zip
Fix for issue 401: test(), Object.test(), and super.test() were all allowed in eclipse for @ExtensionMethod, resulting in VerifyErrors in the emitted class files.
Diffstat (limited to 'src')
-rw-r--r--src/eclipseAgent/lombok/eclipse/agent/PatchExtensionMethod.java13
-rw-r--r--src/eclipseAgent/lombok/eclipse/agent/PatchExtensionMethodCompletionProposal.java14
2 files changed, 21 insertions, 6 deletions
diff --git a/src/eclipseAgent/lombok/eclipse/agent/PatchExtensionMethod.java b/src/eclipseAgent/lombok/eclipse/agent/PatchExtensionMethod.java
index b96f70c9..008e722a 100644
--- a/src/eclipseAgent/lombok/eclipse/agent/PatchExtensionMethod.java
+++ b/src/eclipseAgent/lombok/eclipse/agent/PatchExtensionMethod.java
@@ -48,8 +48,10 @@ import org.eclipse.jdt.internal.compiler.ast.MessageSend;
import org.eclipse.jdt.internal.compiler.ast.NameReference;
import org.eclipse.jdt.internal.compiler.ast.QualifiedNameReference;
import org.eclipse.jdt.internal.compiler.ast.SingleNameReference;
+import org.eclipse.jdt.internal.compiler.ast.SuperReference;
import org.eclipse.jdt.internal.compiler.ast.ThisReference;
import org.eclipse.jdt.internal.compiler.ast.TypeDeclaration;
+import org.eclipse.jdt.internal.compiler.lookup.Binding;
import org.eclipse.jdt.internal.compiler.lookup.BlockScope;
import org.eclipse.jdt.internal.compiler.lookup.CompilationUnitScope;
import org.eclipse.jdt.internal.compiler.lookup.MethodBinding;
@@ -201,7 +203,16 @@ public class PatchExtensionMethod {
}
}
- for (Extension extension : extensions) {
+ boolean skip = false;
+
+ if (methodCall.receiver instanceof ThisReference && (((ThisReference)methodCall.receiver).bits & ASTNode.IsImplicitThis) != 0) skip = true;
+ if (methodCall.receiver instanceof SuperReference) skip = true;
+ if (methodCall.receiver instanceof NameReference) {
+ Binding binding = ((NameReference)methodCall.receiver).binding;
+ if (binding instanceof TypeBinding) skip = true;
+ }
+
+ if (!skip) for (Extension extension : extensions) {
if (!extension.suppressBaseMethods && !(methodCall.binding instanceof ProblemMethodBinding)) continue;
for (MethodBinding extensionMethod : extension.extensionMethods) {
if (!Arrays.equals(methodCall.selector, extensionMethod.selector)) continue;
diff --git a/src/eclipseAgent/lombok/eclipse/agent/PatchExtensionMethodCompletionProposal.java b/src/eclipseAgent/lombok/eclipse/agent/PatchExtensionMethodCompletionProposal.java
index 701a2029..97ca5a7e 100644
--- a/src/eclipseAgent/lombok/eclipse/agent/PatchExtensionMethodCompletionProposal.java
+++ b/src/eclipseAgent/lombok/eclipse/agent/PatchExtensionMethodCompletionProposal.java
@@ -45,7 +45,7 @@ import org.eclipse.jdt.internal.compiler.ast.ASTNode;
import org.eclipse.jdt.internal.compiler.ast.Annotation;
import org.eclipse.jdt.internal.compiler.ast.FieldReference;
import org.eclipse.jdt.internal.compiler.ast.NameReference;
-import org.eclipse.jdt.internal.compiler.ast.SingleNameReference;
+import org.eclipse.jdt.internal.compiler.ast.SuperReference;
import org.eclipse.jdt.internal.compiler.ast.TypeDeclaration;
import org.eclipse.jdt.internal.compiler.lookup.Binding;
import org.eclipse.jdt.internal.compiler.lookup.ClassScope;
@@ -103,14 +103,18 @@ public class PatchExtensionMethodCompletionProposal {
if (node == null) return null;
if (!(node instanceof CompletionOnQualifiedNameReference) && !(node instanceof CompletionOnSingleNameReference) && !(node instanceof CompletionOnMemberAccess)) return null;
+ // Never offer on 'super.<autocomplete>'.
+ if (node instanceof FieldReference && ((FieldReference)node).receiver instanceof SuperReference) return null;
+
if (node instanceof NameReference) {
Binding binding = ((NameReference) node).binding;
- if ((node instanceof SingleNameReference) && (((SingleNameReference) node).token.length == 0)) {
+ // Unremark next block to allow a 'blank' autocomplete to list any extensions that apply to the current scope, but make sure we're not in a static context first, which this doesn't do.
+ // Lacking good use cases, and having this particular concept be a little tricky on javac, means for now we don't support extension methods like this. this.X() will be fine, though.
+
+/* if ((node instanceof SingleNameReference) && (((SingleNameReference) node).token.length == 0)) {
firstParameterType = decl.binding;
- } else if (binding instanceof VariableBinding) {
+ } else */if (binding instanceof VariableBinding) {
firstParameterType = ((VariableBinding) binding).type;
- } else if (binding instanceof TypeBinding) {
- firstParameterType = (TypeBinding) binding;
}
} else if (node instanceof FieldReference) {
firstParameterType = ((FieldReference) node).actualReceiverType;