Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorStephan Herrmann2015-04-14 15:15:24 +0000
committerStephan Herrmann2015-04-14 18:39:06 +0000
commit96a1c4eb2fdb5445d2326ae03dc755cc22a50d35 (patch)
treeee34666e6e8b2223c56f599eefdeca24cbaf6afe
parent969e112c287880aaa166b5c77a56bd62cba0db4b (diff)
downloadeclipse.jdt.core-96a1c4eb2fdb5445d2326ae03dc755cc22a50d35.tar.gz
eclipse.jdt.core-96a1c4eb2fdb5445d2326ae03dc755cc22a50d35.tar.xz
eclipse.jdt.core-96a1c4eb2fdb5445d2326ae03dc755cc22a50d35.zip
Bug 464615 - [dom] ASTParser.createBindings() ignores parameterization
of a method invocation Change-Id: I67a00676eeff1a815d966b526530cec304de06c4 Signed-off-by: Stephan Herrmann <stephan.herrmann@berlin.de>
-rw-r--r--org.eclipse.jdt.core.tests.model/src/org/eclipse/jdt/core/tests/dom/ASTModelBridgeTests.java39
-rw-r--r--org.eclipse.jdt.core/model/org/eclipse/jdt/internal/core/ResolvedBinaryField.java7
-rw-r--r--org.eclipse.jdt.core/model/org/eclipse/jdt/internal/core/ResolvedBinaryMethod.java11
-rw-r--r--org.eclipse.jdt.core/model/org/eclipse/jdt/internal/core/ResolvedBinaryType.java8
4 files changed, 62 insertions, 3 deletions
diff --git a/org.eclipse.jdt.core.tests.model/src/org/eclipse/jdt/core/tests/dom/ASTModelBridgeTests.java b/org.eclipse.jdt.core.tests.model/src/org/eclipse/jdt/core/tests/dom/ASTModelBridgeTests.java
index cdbe0aae36..512b9faff0 100644
--- a/org.eclipse.jdt.core.tests.model/src/org/eclipse/jdt/core/tests/dom/ASTModelBridgeTests.java
+++ b/org.eclipse.jdt.core.tests.model/src/org/eclipse/jdt/core/tests/dom/ASTModelBridgeTests.java
@@ -10,6 +10,7 @@
* Stephan Herrmann - Contributions for
* Bug 463330 - [dom] DOMFinder doesn't find the VariableBinding corresponding to a method argument
* Bug 464463 - [dom] DOMFinder doesn't find an ITypeParameter
+ * Bug 464615 - [dom] ASTParser.createBindings() ignores parameterization of a method invocation
*******************************************************************************/
package org.eclipse.jdt.core.tests.dom;
@@ -1294,6 +1295,44 @@ public class ASTModelBridgeTests extends AbstractASTTests {
}
/*
+ * Ensures that the correct IBindings are created for a given set of IJavaElement
+ * (invocation of a generic method - binary)
+ */
+ public void testCreateBinding27() throws Exception {
+ createClassFile("/P/lib", "p/A.class",
+ "package p;\n" +
+ "public class A {\n" +
+ " public static <T> T foo(T[] arg) { return arg[0]; }\n" +
+ "}");
+ this.workingCopies = new ICompilationUnit[1];
+ String xSource = "public class X {\n" +
+ " public String test(String[] args) {\n" +
+ " return p.A.foo(args);\n" +
+ " }\n" +
+ "}";
+ this.workingCopies[0] = getWorkingCopy(
+ "/P/src/X.java",
+ xSource,
+ this.wcOwner
+ );
+
+ IJavaElement elem= this.workingCopies[0].codeSelect(xSource.indexOf("foo"), 0)[0];
+ ASTParser parser = ASTParser.newParser(AST.JLS8);
+ parser.setProject(getJavaProject("P"));
+ IBinding[] bindings = parser.createBindings(new IJavaElement[]{ elem }, null);
+ assertBindingsEqual(
+ "Lp/A;.foo<T:Ljava/lang/Object;>([TT;)TT;%<Ljava/lang/String;>",
+ bindings);
+ IMethodBinding method = (IMethodBinding) bindings[0];
+ assertBindingsEqual(
+ "[Ljava/lang/String;",
+ method.getParameterTypes());
+ assertBindingsEqual(
+ "Ljava/lang/String;",
+ new IBinding[] {method.getReturnType()});
+ }
+
+ /*
* Ensures that the IJavaElement of an IBinding representing a field is correct.
*/
public void testField1() throws JavaModelException {
diff --git a/org.eclipse.jdt.core/model/org/eclipse/jdt/internal/core/ResolvedBinaryField.java b/org.eclipse.jdt.core/model/org/eclipse/jdt/internal/core/ResolvedBinaryField.java
index 78f79aac02..560ddfe39c 100644
--- a/org.eclipse.jdt.core/model/org/eclipse/jdt/internal/core/ResolvedBinaryField.java
+++ b/org.eclipse.jdt.core/model/org/eclipse/jdt/internal/core/ResolvedBinaryField.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2004, 2009 IBM Corporation and others.
+ * Copyright (c) 2004, 2015 IBM Corporation and others.
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at
@@ -7,6 +7,7 @@
*
* Contributors:
* IBM Corporation - initial API and implementation
+ * Stephan Herrmann - Contribution for Bug 464615 - [dom] ASTParser.createBindings() ignores parameterization of a method invocation
*******************************************************************************/
package org.eclipse.jdt.internal.core;
@@ -33,6 +34,10 @@ public class ResolvedBinaryField extends BinaryField {
return this.uniqueKey;
}
+ public String getKey(boolean forceOpen) {
+ return this.uniqueKey;
+ }
+
/* (non-Javadoc)
* @see org.eclipse.jdt.core.IField#isResolved()
*/
diff --git a/org.eclipse.jdt.core/model/org/eclipse/jdt/internal/core/ResolvedBinaryMethod.java b/org.eclipse.jdt.core/model/org/eclipse/jdt/internal/core/ResolvedBinaryMethod.java
index d36c8d482d..771512282f 100644
--- a/org.eclipse.jdt.core/model/org/eclipse/jdt/internal/core/ResolvedBinaryMethod.java
+++ b/org.eclipse.jdt.core/model/org/eclipse/jdt/internal/core/ResolvedBinaryMethod.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2004, 2009 IBM Corporation and others.
+ * Copyright (c) 2004, 2015 IBM Corporation and others.
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at
@@ -7,9 +7,12 @@
*
* Contributors:
* IBM Corporation - initial API and implementation
+ * Stephan Herrmann - Contribution for Bug 464615 - [dom] ASTParser.createBindings() ignores parameterization of a method invocation
*******************************************************************************/
package org.eclipse.jdt.internal.core;
+import org.eclipse.jdt.core.JavaModelException;
+
/**
* Handle representing a binary method that is resolved.
* The uniqueKey contains the genericSignature of the resolved method. Use BindingKey to decode it.
@@ -31,6 +34,12 @@ public class ResolvedBinaryMethod extends BinaryMethod {
public String getKey() {
return this.uniqueKey;
}
+
+ @Override
+ public String getKey(boolean forceOpen) throws JavaModelException {
+ return this.uniqueKey;
+ }
+
/* (non-Javadoc)
* @see org.eclipse.jdt.core.IMethod#isResolved()
*/
diff --git a/org.eclipse.jdt.core/model/org/eclipse/jdt/internal/core/ResolvedBinaryType.java b/org.eclipse.jdt.core/model/org/eclipse/jdt/internal/core/ResolvedBinaryType.java
index 1c5d2e791a..88b72efe81 100644
--- a/org.eclipse.jdt.core/model/org/eclipse/jdt/internal/core/ResolvedBinaryType.java
+++ b/org.eclipse.jdt.core/model/org/eclipse/jdt/internal/core/ResolvedBinaryType.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2004, 2008 IBM Corporation and others.
+ * Copyright (c) 2004, 2015 IBM Corporation and others.
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at
@@ -7,6 +7,7 @@
*
* Contributors:
* IBM Corporation - initial API and implementation
+ * Stephan Herrmann - Contribution for Bug 464615 - [dom] ASTParser.createBindings() ignores parameterization of a method invocation
*******************************************************************************/
package org.eclipse.jdt.internal.core;
@@ -38,6 +39,11 @@ public class ResolvedBinaryType extends BinaryType {
public String getKey() {
return this.uniqueKey;
}
+
+ @Override
+ public String getKey(boolean forceOpen) throws JavaModelException {
+ return this.uniqueKey;
+ }
/* (non-Javadoc)
* @see org.eclipse.jdt.internal.core.BinaryType#isResolved()

Back to the top