Author: xcoulon
Date: 2012-03-23 09:57:07 -0400 (Fri, 23 Mar 2012)
New Revision: 39799
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/jdt/JdtUtils.java
Log:
Fixed - JBIDE-11379
Failed to build or refresh the JAX-RS metamodel message while editiing package-info.java
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-03-23
13:56:06 UTC (rev 39798)
+++
trunk/ws/plugins/org.jboss.tools.ws.jaxrs.core/src/org/jboss/tools/ws/jaxrs/core/internal/metamodel/domain/JaxrsElementFactory.java 2012-03-23
13:57:07 UTC (rev 39799)
@@ -67,6 +67,9 @@
public JaxrsJavaElement<?> createElement(IAnnotation javaAnnotation,
CompilationUnit ast, JaxrsMetamodel metamodel)
throws CoreException {
Annotation annotation = JdtUtils.resolveAnnotation(javaAnnotation, ast);
+ if(annotation == null) { // annotation on package declaration are ignored
+ return null;
+ }
final String annotationName = annotation.getName();
if (annotationName.equals(HttpMethod.class.getName())) {
final JaxrsHttpMethod httpMethod = createHttpMethod(annotation, ast, metamodel);
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-03-23
13:56:06 UTC (rev 39798)
+++
trunk/ws/plugins/org.jboss.tools.ws.jaxrs.core/src/org/jboss/tools/ws/jaxrs/core/jdt/JdtUtils.java 2012-03-23
13:57:07 UTC (rev 39799)
@@ -89,8 +89,10 @@
public static ICompilationUnit getCompilationUnit(final IJavaElement element) {
if (element instanceof IMember) {
return ((IMember) element).getCompilationUnit();
- } else if (element instanceof IAnnotation) {
- return ((IMember) ((IAnnotation) element).getParent()).getCompilationUnit();
+ } else if (element instanceof IAnnotation
+ // ignore annotations on PackageDeclaration, such as in package-info.java
+ && element.getParent() instanceof IMember) {
+ return ((IMember) (element.getParent())).getCompilationUnit();
} else if (element instanceof ICompilationUnit) {
return (ICompilationUnit) element;
}
@@ -380,7 +382,11 @@
*/
public static Annotation resolveAnnotation(IAnnotation javaAnnotation, CompilationUnit
ast)
throws JavaModelException {
- return resolveAnnotation((IMember) javaAnnotation.getParent(), ast,
javaAnnotation.getElementName());
+ if (javaAnnotation.getParent() instanceof IMember) {
+ return resolveAnnotation((IMember) javaAnnotation.getParent(), ast,
+ javaAnnotation.getElementName());
+ }
+ return null;
}
private static Map<String, List<String>>
resolveAnnotationElements(IAnnotation annotation)
Show replies by date