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

jbosstools-commits at lists.jboss.org jbosstools-commits at lists.jboss.org
Fri Sep 28 18:43:41 EDT 2012


Author: xcoulon
Date: 2012-09-28 18:43:41 -0400 (Fri, 28 Sep 2012)
New Revision: 44131

Modified:
   trunk/ws/plugins/org.jboss.tools.ws.jaxrs.core/src/org/jboss/tools/ws/jaxrs/core/internal/metamodel/builder/JavaElementChangedBuildJob.java
   trunk/ws/plugins/org.jboss.tools.ws.jaxrs.core/src/org/jboss/tools/ws/jaxrs/core/internal/metamodel/builder/JavaElementChangedListener.java
   trunk/ws/plugins/org.jboss.tools.ws.jaxrs.core/src/org/jboss/tools/ws/jaxrs/core/internal/metamodel/builder/JavaElementDeltaScanner.java
   trunk/ws/plugins/org.jboss.tools.ws.jaxrs.core/src/org/jboss/tools/ws/jaxrs/core/internal/metamodel/domain/JaxrsElementFactory.java
Log:
Fixed - JBIDE-12760 - JAX-RS error message "Failed to analyse compilation unit methods" when editing method body
https://issues.jboss.org/browse/JBIDE-12760 

Modified: trunk/ws/plugins/org.jboss.tools.ws.jaxrs.core/src/org/jboss/tools/ws/jaxrs/core/internal/metamodel/builder/JavaElementChangedBuildJob.java
===================================================================
--- trunk/ws/plugins/org.jboss.tools.ws.jaxrs.core/src/org/jboss/tools/ws/jaxrs/core/internal/metamodel/builder/JavaElementChangedBuildJob.java	2012-09-28 22:40:02 UTC (rev 44130)
+++ trunk/ws/plugins/org.jboss.tools.ws.jaxrs.core/src/org/jboss/tools/ws/jaxrs/core/internal/metamodel/builder/JavaElementChangedBuildJob.java	2012-09-28 22:43:41 UTC (rev 44131)
@@ -16,6 +16,7 @@
 
 import org.eclipse.core.runtime.IProgressMonitor;
 import org.eclipse.core.runtime.IStatus;
+import org.eclipse.core.runtime.NullProgressMonitor;
 import org.eclipse.core.runtime.Status;
 import org.eclipse.core.runtime.SubProgressMonitor;
 import org.eclipse.core.runtime.jobs.Job;
@@ -38,6 +39,10 @@
 		Logger.debug("Initiating an incremental JAX-RS Metamodel build after " + event); //$NON-NLS-1$
 	}
 	
+	public void execute() {
+		run(new NullProgressMonitor());
+	}
+	
 	@Override
 	protected IStatus run(final IProgressMonitor progressMonitor) {
 		try {

Modified: trunk/ws/plugins/org.jboss.tools.ws.jaxrs.core/src/org/jboss/tools/ws/jaxrs/core/internal/metamodel/builder/JavaElementChangedListener.java
===================================================================
--- trunk/ws/plugins/org.jboss.tools.ws.jaxrs.core/src/org/jboss/tools/ws/jaxrs/core/internal/metamodel/builder/JavaElementChangedListener.java	2012-09-28 22:40:02 UTC (rev 44130)
+++ trunk/ws/plugins/org.jboss.tools.ws.jaxrs.core/src/org/jboss/tools/ws/jaxrs/core/internal/metamodel/builder/JavaElementChangedListener.java	2012-09-28 22:43:41 UTC (rev 44131)
@@ -18,7 +18,6 @@
 
 import org.eclipse.core.resources.IProject;
 import org.eclipse.core.runtime.CoreException;
-import org.eclipse.core.runtime.jobs.Job;
 import org.eclipse.jdt.core.ElementChangedEvent;
 import org.eclipse.jdt.core.IElementChangedListener;
 import org.eclipse.jdt.core.IJavaElement;
@@ -46,9 +45,11 @@
 		try {
 			if (isApplicable(event.getDelta())) {
 				logDelta(event.getDelta(), event.getType());
-				Job job = new JavaElementChangedBuildJob(event);
-				job.setRule(MutexJobSchedulingRule.getInstance());
-				job.schedule();
+				JavaElementChangedBuildJob job = new JavaElementChangedBuildJob(event);
+				job.execute(); // not using this class as a job, just calling the execute() method for immediate execution.
+				/*job.setRule(MutexJobSchedulingRule.getInstance());
+				job.schedule();*/
+				//job.join();
 			}
 		} catch (CoreException e) {
 			Logger.error("Failed to process Java Element change", e);

Modified: trunk/ws/plugins/org.jboss.tools.ws.jaxrs.core/src/org/jboss/tools/ws/jaxrs/core/internal/metamodel/builder/JavaElementDeltaScanner.java
===================================================================
--- trunk/ws/plugins/org.jboss.tools.ws.jaxrs.core/src/org/jboss/tools/ws/jaxrs/core/internal/metamodel/builder/JavaElementDeltaScanner.java	2012-09-28 22:40:02 UTC (rev 44130)
+++ trunk/ws/plugins/org.jboss.tools.ws.jaxrs.core/src/org/jboss/tools/ws/jaxrs/core/internal/metamodel/builder/JavaElementDeltaScanner.java	2012-09-28 22:43:41 UTC (rev 44131)
@@ -106,7 +106,8 @@
 			// compilationUnitAST is null when the given compilation unit'w
 			// working copy is being commited (ie, Java Editor is being closed
 			// for the given compilation unit, etc.)
-			if (compilationUnit.isWorkingCopy() && compilationUnitAST != null) {
+			if (compilationUnit.exists() // see https://issues.jboss.org/browse/JBIDE-12760: compilationUnit may not exist
+					&& compilationUnit.isWorkingCopy() && compilationUnitAST != null) {
 				// Looking for changes in the method signatures (return type,
 				// param types and param annotations). Other changes in methods
 				// (renaming, adding/removing params) result in add+remove

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-09-28 22:40:02 UTC (rev 44130)
+++ trunk/ws/plugins/org.jboss.tools.ws.jaxrs.core/src/org/jboss/tools/ws/jaxrs/core/internal/metamodel/domain/JaxrsElementFactory.java	2012-09-28 22:43:41 UTC (rev 44131)
@@ -142,11 +142,14 @@
 	 *            the AST associated to the java type
 	 * @param metamodel
 	 *            the current metamodel, in which the JAX-RS Resource should be added
-	 * @return the created resource
+	 * @return the created resource, or null if the java type did not exist.
 	 * @throws CoreException
 	 */
 	public JaxrsResource createResource(IType javaType, CompilationUnit ast, JaxrsMetamodel metamodel)
 			throws CoreException {
+		if(!javaType.exists()) {
+			return null;
+		}
 		// create the resource:
 		final JaxrsResource resource = internalCreateResource(javaType, ast, metamodel);
 		// find the resource methods, subresource methods and subresource
@@ -207,7 +210,9 @@
 	 */
 	public JaxrsResourceMethod createResourceMethod(IMethod method, CompilationUnit ast, JaxrsMetamodel metamodel)
 			throws CoreException {
-
+		if(!method.exists()) {
+			return null;
+		}
 		final IType parentType = (IType) method.getParent();
 		JaxrsResource parentResource = (JaxrsResource) metamodel.getElement(parentType);
 		if (parentResource == null) {
@@ -272,6 +277,9 @@
 	 */
 	public JaxrsHttpMethod createHttpMethod(final IType javaType, final CompilationUnit ast,
 			final JaxrsMetamodel metamodel) throws CoreException {
+		if(!javaType.exists()) {
+			return null;
+		}
 		Map<String, Annotation> annotations = JdtUtils.resolveAnnotations(javaType, ast, HTTP_METHOD.qualifiedName, TARGET.qualifiedName, RETENTION.qualifiedName);
 		if (annotations == null || annotations.isEmpty()) {
 			return null;
@@ -312,6 +320,9 @@
 	 */
 	public JaxrsJavaApplication createApplication(final IType javaType, final CompilationUnit ast,
 			final JaxrsMetamodel metamodel) throws CoreException {
+		if(!javaType.exists()) {
+			return null;
+		}
 		Annotation applicationPathAnnotation = JdtUtils.resolveAnnotation(javaType, ast, APPLICATION_PATH.qualifiedName);
 		return createApplication(javaType, applicationPathAnnotation, metamodel);
 	}
@@ -349,6 +360,9 @@
 	 */
 	private JaxrsJavaApplication createApplication(final IType applicationType, final Annotation appPathAnnotation, 
 			final JaxrsMetamodel metamodel) throws CoreException {
+		if(!applicationType.exists()) {
+			return null;
+		}
 		final IType applicationSupertype = JdtUtils.resolveType(EnumJaxrsClassname.APPLICATION.qualifiedName, applicationType.getJavaProject(), new NullProgressMonitor());
 		final boolean isApplicationSubclass = JdtUtils.isTypeOrSuperType(applicationSupertype, applicationType);
 		if(isApplicationSubclass || appPathAnnotation != null) {
@@ -376,6 +390,9 @@
 
 	public JaxrsResourceField createField(IField javaField, CompilationUnit ast, JaxrsMetamodel metamodel)
 			throws JavaModelException {
+		if(!javaField.exists()) {
+			return null;
+		}
 		final IType parentType = (IType) javaField.getParent();
 		IJaxrsElement parentResource = metamodel.getElement(parentType);
 		if (parentResource == null) {
@@ -423,7 +440,9 @@
 	 * @return a representation of the given provider or null in case of invalid type (ie, not a valid JAX-RS Provider)
 	 */
 	public JaxrsProvider createProvider(final IType javaType, final CompilationUnit ast, final JaxrsMetamodel metamodel, final IProgressMonitor progressMonitor ) throws CoreException {
-
+		if(!javaType.exists()) {
+			return null;
+		}
 		final Map<String, Annotation> annotations = JdtUtils.resolveAnnotations(javaType, ast, PROVIDER.qualifiedName,
 				CONSUMES.qualifiedName, PRODUCES.qualifiedName);
 		// assert that given java type is not abstract 



More information about the jbosstools-commits mailing list