Author: xcoulon
Date: 2012-04-26 11:30:22 -0400 (Thu, 26 Apr 2012)
New Revision: 40519
Added:
trunk/ws/tests/org.jboss.tools.ws.jaxrs.core.test/projects/org.jboss.tools.ws.jaxrs.tests.sampleproject/src/main/java/org/jboss/tools/ws/jaxrs/sample/services/ParameterizedResource.java
Modified:
trunk/ws/plugins/org.jboss.tools.ws.jaxrs.core/src/org/jboss/tools/ws/jaxrs/core/jdt/JavaMethodSignaturesVisitor.java
trunk/ws/tests/org.jboss.tools.ws.jaxrs.core.test/projects/org.jboss.tools.ws.jaxrs.tests.sampleproject/src/main/java/org/jboss/tools/ws/jaxrs/sample/services/BarResource.java
trunk/ws/tests/org.jboss.tools.ws.jaxrs.core.test/projects/org.jboss.tools.ws.jaxrs.tests.sampleproject/src/main/java/org/jboss/tools/ws/jaxrs/sample/services/BazResource.java
trunk/ws/tests/org.jboss.tools.ws.jaxrs.core.test/src/org/jboss/tools/ws/jaxrs/core/jdt/JdtUtilsTestCase.java
Log:
Fixed - JBIDE-11576
ClassCastException in JavaMethodSignaturesVisitor
Fixing failing tests
Modified:
trunk/ws/plugins/org.jboss.tools.ws.jaxrs.core/src/org/jboss/tools/ws/jaxrs/core/jdt/JavaMethodSignaturesVisitor.java
===================================================================
---
trunk/ws/plugins/org.jboss.tools.ws.jaxrs.core/src/org/jboss/tools/ws/jaxrs/core/jdt/JavaMethodSignaturesVisitor.java 2012-04-26
11:21:04 UTC (rev 40518)
+++
trunk/ws/plugins/org.jboss.tools.ws.jaxrs.core/src/org/jboss/tools/ws/jaxrs/core/jdt/JavaMethodSignaturesVisitor.java 2012-04-26
15:30:22 UTC (rev 40519)
@@ -84,8 +84,8 @@
if (methodBinding == null) {
Logger.warn("Could not resolve bindings form method " +
method.getElementName());
} else {
- final IType returnedType = methodBinding.getReturnType() != null ? (IType)
methodBinding
- .getReturnType().getJavaElement().getAdapter(IType.class) : null;
+ final IType returnedType = getReturnType(methodBinding);
+ //.getReturnType().getJavaElement() : null;
List<JavaMethodParameter> methodParameters = new
ArrayList<JavaMethodParameter>();
@SuppressWarnings("unchecked")
List<SingleVariableDeclaration> parameters = declaration.parameters();
@@ -122,6 +122,18 @@
return true;
}
+ /**
+ * Returns the ReturnType for the given method or null of the return type could not be
found or is 'void'
+ * @param methodBinding
+ * @return
+ */
+ private IType getReturnType(final IMethodBinding methodBinding) {
+ if (methodBinding.getReturnType() != null &&
methodBinding.getReturnType().getJavaElement() != null) {
+ return (IType)
methodBinding.getReturnType().getJavaElement().getAdapter(IType.class);
+ }
+ return null;
+ }
+
private static Map<String, List<String>>
resolveAnnotationElements(IAnnotationBinding annotationBinding) {
final Map<String, List<String>> annotationElements = new HashMap<String,
List<String>>();
for (IMemberValuePairBinding binding : annotationBinding.getAllMemberValuePairs()) {
Modified:
trunk/ws/tests/org.jboss.tools.ws.jaxrs.core.test/projects/org.jboss.tools.ws.jaxrs.tests.sampleproject/src/main/java/org/jboss/tools/ws/jaxrs/sample/services/BarResource.java
===================================================================
---
trunk/ws/tests/org.jboss.tools.ws.jaxrs.core.test/projects/org.jboss.tools.ws.jaxrs.tests.sampleproject/src/main/java/org/jboss/tools/ws/jaxrs/sample/services/BarResource.java 2012-04-26
11:21:04 UTC (rev 40518)
+++
trunk/ws/tests/org.jboss.tools.ws.jaxrs.core.test/projects/org.jboss.tools.ws.jaxrs.tests.sampleproject/src/main/java/org/jboss/tools/ws/jaxrs/sample/services/BarResource.java 2012-04-26
15:30:22 UTC (rev 40519)
@@ -1,4 +1,4 @@
-package org.bytesparadise.pastebin.service;
+package org.jboss.tools.ws.jaxrs.sample.services;
import javax.servlet.http.HttpServletRequest;
import javax.ws.rs.PUT;
Modified:
trunk/ws/tests/org.jboss.tools.ws.jaxrs.core.test/projects/org.jboss.tools.ws.jaxrs.tests.sampleproject/src/main/java/org/jboss/tools/ws/jaxrs/sample/services/BazResource.java
===================================================================
---
trunk/ws/tests/org.jboss.tools.ws.jaxrs.core.test/projects/org.jboss.tools.ws.jaxrs.tests.sampleproject/src/main/java/org/jboss/tools/ws/jaxrs/sample/services/BazResource.java 2012-04-26
11:21:04 UTC (rev 40518)
+++
trunk/ws/tests/org.jboss.tools.ws.jaxrs.core.test/projects/org.jboss.tools.ws.jaxrs.tests.sampleproject/src/main/java/org/jboss/tools/ws/jaxrs/sample/services/BazResource.java 2012-04-26
15:30:22 UTC (rev 40519)
@@ -1,4 +1,4 @@
-package org.bytesparadise.pastebin.service;
+package org.jboss.tools.ws.jaxrs.sample.services;
import javax.servlet.http.HttpServletRequest;
import javax.ws.rs.PUT;
Added:
trunk/ws/tests/org.jboss.tools.ws.jaxrs.core.test/projects/org.jboss.tools.ws.jaxrs.tests.sampleproject/src/main/java/org/jboss/tools/ws/jaxrs/sample/services/ParameterizedResource.java
===================================================================
---
trunk/ws/tests/org.jboss.tools.ws.jaxrs.core.test/projects/org.jboss.tools.ws.jaxrs.tests.sampleproject/src/main/java/org/jboss/tools/ws/jaxrs/sample/services/ParameterizedResource.java
(rev 0)
+++
trunk/ws/tests/org.jboss.tools.ws.jaxrs.core.test/projects/org.jboss.tools.ws.jaxrs.tests.sampleproject/src/main/java/org/jboss/tools/ws/jaxrs/sample/services/ParameterizedResource.java 2012-04-26
15:30:22 UTC (rev 40519)
@@ -0,0 +1,9 @@
+package org.jboss.tools.ws.jaxrs.sample.services;
+
+public class ParameterizedResource<T> {
+
+ public T getType() {
+ return null;
+ }
+
+}
\ No newline at end of file
Property changes on:
trunk/ws/tests/org.jboss.tools.ws.jaxrs.core.test/projects/org.jboss.tools.ws.jaxrs.tests.sampleproject/src/main/java/org/jboss/tools/ws/jaxrs/sample/services/ParameterizedResource.java
___________________________________________________________________
Added: svn:mime-type
+ text/plain
Modified:
trunk/ws/tests/org.jboss.tools.ws.jaxrs.core.test/src/org/jboss/tools/ws/jaxrs/core/jdt/JdtUtilsTestCase.java
===================================================================
---
trunk/ws/tests/org.jboss.tools.ws.jaxrs.core.test/src/org/jboss/tools/ws/jaxrs/core/jdt/JdtUtilsTestCase.java 2012-04-26
11:21:04 UTC (rev 40518)
+++
trunk/ws/tests/org.jboss.tools.ws.jaxrs.core.test/src/org/jboss/tools/ws/jaxrs/core/jdt/JdtUtilsTestCase.java 2012-04-26
15:30:22 UTC (rev 40519)
@@ -454,6 +454,16 @@
}
@Test
+ public void shouldResolveJavaMethodSignaturesForParameterizedType() throws CoreException
{
+ final IType type =
getType("org.jboss.tools.ws.jaxrs.sample.services.ParameterizedResource");
+ // operation
+ final List<JavaMethodSignature> methodSignatures =
JdtUtils.resolveMethodSignatures(type,
+ JdtUtils.parse(type, progressMonitor));
+ // verification
+ Assert.assertEquals(1, methodSignatures.size());
+ }
+
+ @Test
public void shouldResolveJavaMethodSignature() throws CoreException {
final IType type =
getType("org.jboss.tools.ws.jaxrs.sample.services.CustomerResource");
final IMethod method = getMethod(type, "getCustomers");
Show replies by date