Author: xcoulon
Date: 2012-01-11 03:55:39 -0500 (Wed, 11 Jan 2012)
New Revision: 37757
Modified:
trunk/ws/plugins/org.jboss.tools.ws.jaxrs.core/src/org/jboss/tools/ws/jaxrs/core/internal/metamodel/builder/ResourceChangedProcessor.java
trunk/ws/plugins/org.jboss.tools.ws.jaxrs.core/src/org/jboss/tools/ws/jaxrs/core/internal/metamodel/domain/JaxrsElementFactory.java
trunk/ws/plugins/org.jboss.tools.ws.jaxrs.core/src/org/jboss/tools/ws/jaxrs/core/internal/metamodel/domain/JaxrsResourceMethod.java
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/src/org/jboss/tools/ws/jaxrs/core/internal/metamodel/builder/ResourceChangedProcessorTestCase.java
Log:
Fixing JBIDE-10509 - JAX-RS validation error/warning doesn't reappear
(
https://issues.jboss.org/browse/JBIDE-10509)
Fixing JBIDE-10510 - JAX-RS validation error doesn't appear after changing @PathParam
parameter from correct to incorrect value (
https://issues.jboss.org/browse/JBIDE-10510)
Modified:
trunk/ws/plugins/org.jboss.tools.ws.jaxrs.core/src/org/jboss/tools/ws/jaxrs/core/internal/metamodel/builder/ResourceChangedProcessor.java
===================================================================
---
trunk/ws/plugins/org.jboss.tools.ws.jaxrs.core/src/org/jboss/tools/ws/jaxrs/core/internal/metamodel/builder/ResourceChangedProcessor.java 2012-01-11
08:02:44 UTC (rev 37756)
+++
trunk/ws/plugins/org.jboss.tools.ws.jaxrs.core/src/org/jboss/tools/ws/jaxrs/core/internal/metamodel/builder/ResourceChangedProcessor.java 2012-01-11
08:55:39 UTC (rev 37757)
@@ -46,6 +46,8 @@
import org.jboss.tools.ws.jaxrs.core.internal.utils.CollectionUtils;
import org.jboss.tools.ws.jaxrs.core.internal.utils.Logger;
import org.jboss.tools.ws.jaxrs.core.internal.utils.WtpUtils;
+import org.jboss.tools.ws.jaxrs.core.jdt.CompilationUnitsRepository;
+import org.jboss.tools.ws.jaxrs.core.jdt.JavaMethodSignature;
import org.jboss.tools.ws.jaxrs.core.jdt.JaxrsAnnotationsScanner;
import org.jboss.tools.ws.jaxrs.core.jdt.JdtUtils;
import org.jboss.tools.ws.jaxrs.core.metamodel.EnumKind;
@@ -583,7 +585,7 @@
}
private List<JaxrsElementDelta> postProcessResource(final JaxrsElementDelta
event,
- final IProgressMonitor progressMonitor) {
+ final IProgressMonitor progressMonitor) throws JavaModelException {
final List<JaxrsElementDelta> results = new
ArrayList<JaxrsElementDelta>();
final JaxrsResource eventResource = (JaxrsResource) event.getElement();
final JaxrsMetamodel metamodel = eventResource.getMetamodel();
@@ -666,7 +668,7 @@
}
private List<JaxrsElementDelta> mergeResourceMethods(final JaxrsResource
existingResource,
- final JaxrsResource matchingResource, final JaxrsMetamodel metamodel) {
+ final JaxrsResource matchingResource, final JaxrsMetamodel metamodel) throws
JavaModelException {
final List<JaxrsElementDelta> changes = new
ArrayList<JaxrsElementDelta>();
final Map<String, JaxrsResourceMethod> addedMethods =
CollectionUtils.difference(matchingResource.getMethods(),
existingResource.getMethods());
@@ -685,6 +687,9 @@
final JaxrsResourceMethod existingMethod = entry.getValue();
final JaxrsResourceMethod matchingMethod =
matchingResource.getMethods().get(entry.getKey());
int flags = existingMethod.mergeAnnotations(matchingMethod.getAnnotations());
+ final CompilationUnit matchingResourceAST =
CompilationUnitsRepository.getInstance().getAST(matchingResource.getResource());
+ final JavaMethodSignature matchingResourceMethodSignature =
JdtUtils.resolveMethodSignature(matchingMethod.getJavaElement(), matchingResourceAST);
+ flags += existingMethod.update(matchingResourceMethodSignature);
if ((flags & F_ELEMENT_KIND) > 0 && existingMethod.getKind() ==
EnumKind.UNDEFINED) {
metamodel.remove(existingMethod);
changes.add(new JaxrsElementDelta(existingMethod, REMOVED));
Modified:
trunk/ws/plugins/org.jboss.tools.ws.jaxrs.core/src/org/jboss/tools/ws/jaxrs/core/internal/metamodel/domain/JaxrsElementFactory.java
===================================================================
---
trunk/ws/plugins/org.jboss.tools.ws.jaxrs.core/src/org/jboss/tools/ws/jaxrs/core/internal/metamodel/domain/JaxrsElementFactory.java 2012-01-11
08:02:44 UTC (rev 37756)
+++
trunk/ws/plugins/org.jboss.tools.ws.jaxrs.core/src/org/jboss/tools/ws/jaxrs/core/internal/metamodel/domain/JaxrsElementFactory.java 2012-01-11
08:55:39 UTC (rev 37757)
@@ -231,7 +231,7 @@
final Annotation producesAnnotation = annotations.get(Produces.class.getName());
final Annotation consumesAnnotation = annotations.get(Consumes.class.getName());
final JavaMethodSignature methodSignature =
JdtUtils.resolveMethodSignature(javaMethod, ast);
- // avoid creating Resource Method when the Java Method cannot be parsed (ie,
syntax/compilation error)
+ // avoid creating Resource Method when the Java Method cannot be parsed (ie,
syntax/compilation error)P
if (methodSignature != null) {
final Builder builder = new JaxrsResourceMethod.Builder(javaMethod, parentResource,
metamodel)
.pathTemplate(pathAnnotation).consumes(consumesAnnotation).produces(producesAnnotation)
Modified:
trunk/ws/plugins/org.jboss.tools.ws.jaxrs.core/src/org/jboss/tools/ws/jaxrs/core/internal/metamodel/domain/JaxrsResourceMethod.java
===================================================================
---
trunk/ws/plugins/org.jboss.tools.ws.jaxrs.core/src/org/jboss/tools/ws/jaxrs/core/internal/metamodel/domain/JaxrsResourceMethod.java 2012-01-11
08:02:44 UTC (rev 37756)
+++
trunk/ws/plugins/org.jboss.tools.ws.jaxrs.core/src/org/jboss/tools/ws/jaxrs/core/internal/metamodel/domain/JaxrsResourceMethod.java 2012-01-11
08:55:39 UTC (rev 37757)
@@ -198,7 +198,7 @@
message.setAttribute(IMarker.CHAR_END, annotation.getRegion().getOffset()
+ annotation.getRegion().getLength());
messages.add(message);
- Logger.debug("Validation message for {}: {}",
this.getJavaElement().getElementName(), message);
+ Logger.debug("Validation message for {}: {}",
this.getJavaElement().getElementName(), message.getAttribute(IMarker.MESSAGE));
}
}
}
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-01-11
08:02:44 UTC (rev 37756)
+++
trunk/ws/plugins/org.jboss.tools.ws.jaxrs.core/src/org/jboss/tools/ws/jaxrs/core/jdt/JavaMethodSignaturesVisitor.java 2012-01-11
08:55:39 UTC (rev 37757)
@@ -139,6 +139,7 @@
/** @return the methodDeclarations */
public JavaMethodSignature getMethodSignature() {
if (this.methodSignatures.size() == 0) {
+ Logger.debug("*** no method signature found ?!? ***");
return null;
}
return this.methodSignatures.get(0);
Modified:
trunk/ws/tests/org.jboss.tools.ws.jaxrs.core.test/src/org/jboss/tools/ws/jaxrs/core/internal/metamodel/builder/ResourceChangedProcessorTestCase.java
===================================================================
---
trunk/ws/tests/org.jboss.tools.ws.jaxrs.core.test/src/org/jboss/tools/ws/jaxrs/core/internal/metamodel/builder/ResourceChangedProcessorTestCase.java 2012-01-11
08:02:44 UTC (rev 37756)
+++
trunk/ws/tests/org.jboss.tools.ws.jaxrs.core.test/src/org/jboss/tools/ws/jaxrs/core/internal/metamodel/builder/ResourceChangedProcessorTestCase.java 2012-01-11
08:55:39 UTC (rev 37757)
@@ -59,6 +59,7 @@
import org.jboss.tools.ws.jaxrs.core.internal.metamodel.domain.JaxrsResourceMethod;
import org.jboss.tools.ws.jaxrs.core.internal.metamodel.domain.JaxrsWebxmlApplication;
import org.jboss.tools.ws.jaxrs.core.jdt.Annotation;
+import org.jboss.tools.ws.jaxrs.core.jdt.CompilationUnitsRepository;
import org.jboss.tools.ws.jaxrs.core.jdt.JdtUtils;
import org.jboss.tools.ws.jaxrs.core.metamodel.EnumElementKind;
import org.jboss.tools.ws.jaxrs.core.metamodel.EnumKind;
@@ -90,6 +91,7 @@
metamodel = spy(JaxrsMetamodel.create(javaProject));
// replace the normal metamodel instance with the one spied by Mockito
javaProject.getProject().setSessionProperty(JaxrsMetamodel.METAMODEL_QUALIFIED_NAME,
metamodel);
+ CompilationUnitsRepository.getInstance().clear();
}
/**