[jbosstools-commits] JBoss Tools SVN: r41792 - in trunk/ws/plugins/org.jboss.tools.ws.jaxrs.core/src/org/jboss/tools/ws/jaxrs/core: jdt and 1 other directory.

jbosstools-commits at lists.jboss.org jbosstools-commits at lists.jboss.org
Thu Jun 7 17:17:56 EDT 2012


Author: xcoulon
Date: 2012-06-07 17:17:56 -0400 (Thu, 07 Jun 2012)
New Revision: 41792

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/jdt/JdtUtils.java
Log:
Fixed - JBIDE-12128
NPE when moving JAX-RS resource into another package

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-06-07 21:15:56 UTC (rev 41791)
+++ trunk/ws/plugins/org.jboss.tools.ws.jaxrs.core/src/org/jboss/tools/ws/jaxrs/core/internal/metamodel/builder/ResourceChangedProcessor.java	2012-06-07 21:17:56 UTC (rev 41792)
@@ -694,12 +694,14 @@
 			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));
-			} else if (flags > 0) {
-				changes.add(new JaxrsElementDelta(existingMethod, CHANGED, flags));
+			if(matchingResourceMethodSignature != null) {
+				flags += existingMethod.update(matchingResourceMethodSignature);
+				if ((flags & F_ELEMENT_KIND) > 0 && existingMethod.getKind() == EnumKind.UNDEFINED) {
+					metamodel.remove(existingMethod);
+					changes.add(new JaxrsElementDelta(existingMethod, REMOVED));
+				} else if (flags > 0) {
+					changes.add(new JaxrsElementDelta(existingMethod, CHANGED, flags));
+				}
 			}
 		}
 		for (Entry<String, JaxrsResourceMethod> entry : removedMethods.entrySet()) {

Modified: trunk/ws/plugins/org.jboss.tools.ws.jaxrs.core/src/org/jboss/tools/ws/jaxrs/core/jdt/JdtUtils.java
===================================================================
--- trunk/ws/plugins/org.jboss.tools.ws.jaxrs.core/src/org/jboss/tools/ws/jaxrs/core/jdt/JdtUtils.java	2012-06-07 21:15:56 UTC (rev 41791)
+++ trunk/ws/plugins/org.jboss.tools.ws.jaxrs.core/src/org/jboss/tools/ws/jaxrs/core/jdt/JdtUtils.java	2012-06-07 21:17:56 UTC (rev 41792)
@@ -582,7 +582,16 @@
 		return methodsVisitor.getMethodSignatures();
 	}
 
+	/**
+	 * Returns the method signature for the given method with the given AST.
+	 * @param method the java method 
+	 * @param ast the associated Compilation Unit AST
+	 * @return the JavaMethodSignature or null if the given AST is null.
+	 */
 	public static JavaMethodSignature resolveMethodSignature(IMethod method, CompilationUnit ast) {
+		if(ast == null) {
+			return null;
+		}
 		JavaMethodSignaturesVisitor methodsVisitor = new JavaMethodSignaturesVisitor(method);
 		ast.accept(methodsVisitor);
 		return methodsVisitor.getMethodSignature();



More information about the jbosstools-commits mailing list