Author: xcoulon
Date: 2012-03-23 09:50:25 -0400 (Fri, 23 Mar 2012)
New Revision: 39796
Modified:
branches/jbosstools-3.3.0.Beta1/ws/plugins/org.jboss.tools.ws.jaxrs.core/src/org/jboss/tools/ws/jaxrs/core/internal/metamodel/domain/JaxrsElementFactory.java
branches/jbosstools-3.3.0.Beta1/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:
branches/jbosstools-3.3.0.Beta1/ws/plugins/org.jboss.tools.ws.jaxrs.core/src/org/jboss/tools/ws/jaxrs/core/internal/metamodel/domain/JaxrsElementFactory.java
===================================================================
---
branches/jbosstools-3.3.0.Beta1/ws/plugins/org.jboss.tools.ws.jaxrs.core/src/org/jboss/tools/ws/jaxrs/core/internal/metamodel/domain/JaxrsElementFactory.java 2012-03-23
13:44:32 UTC (rev 39795)
+++
branches/jbosstools-3.3.0.Beta1/ws/plugins/org.jboss.tools.ws.jaxrs.core/src/org/jboss/tools/ws/jaxrs/core/internal/metamodel/domain/JaxrsElementFactory.java 2012-03-23
13:50:25 UTC (rev 39796)
@@ -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:
branches/jbosstools-3.3.0.Beta1/ws/plugins/org.jboss.tools.ws.jaxrs.core/src/org/jboss/tools/ws/jaxrs/core/jdt/JdtUtils.java
===================================================================
---
branches/jbosstools-3.3.0.Beta1/ws/plugins/org.jboss.tools.ws.jaxrs.core/src/org/jboss/tools/ws/jaxrs/core/jdt/JdtUtils.java 2012-03-23
13:44:32 UTC (rev 39795)
+++
branches/jbosstools-3.3.0.Beta1/ws/plugins/org.jboss.tools.ws.jaxrs.core/src/org/jboss/tools/ws/jaxrs/core/jdt/JdtUtils.java 2012-03-23
13:50:25 UTC (rev 39796)
@@ -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)