[jbosstools-commits] JBoss Tools SVN: r43794 - in trunk/ws/plugins/org.jboss.tools.ws.jaxrs.core: src/org/jboss/tools/ws/jaxrs/core/internal/metamodel/validation and 1 other directory.
jbosstools-commits at lists.jboss.org
jbosstools-commits at lists.jboss.org
Tue Sep 18 08:45:37 EDT 2012
Author: xcoulon
Date: 2012-09-18 08:45:37 -0400 (Tue, 18 Sep 2012)
New Revision: 43794
Modified:
trunk/ws/plugins/org.jboss.tools.ws.jaxrs.core/plugin.xml
trunk/ws/plugins/org.jboss.tools.ws.jaxrs.core/src/org/jboss/tools/ws/jaxrs/core/internal/metamodel/validation/JaxrsApplicationValidatorDelegate.java
trunk/ws/plugins/org.jboss.tools.ws.jaxrs.core/src/org/jboss/tools/ws/jaxrs/core/internal/metamodel/validation/JaxrsMetamodelValidator.java
trunk/ws/plugins/org.jboss.tools.ws.jaxrs.core/src/org/jboss/tools/ws/jaxrs/core/internal/metamodel/validation/JaxrsResourceValidatorDelegate.java
trunk/ws/plugins/org.jboss.tools.ws.jaxrs.core/src/org/jboss/tools/ws/jaxrs/core/internal/metamodel/validation/MarkerUtils.java
Log:
Fixed - JBIDE-10287 Add support for JAX-RS Application
Modified: trunk/ws/plugins/org.jboss.tools.ws.jaxrs.core/plugin.xml
===================================================================
--- trunk/ws/plugins/org.jboss.tools.ws.jaxrs.core/plugin.xml 2012-09-18 12:25:27 UTC (rev 43793)
+++ trunk/ws/plugins/org.jboss.tools.ws.jaxrs.core/plugin.xml 2012-09-18 12:45:37 UTC (rev 43794)
@@ -85,6 +85,9 @@
<super
type="org.eclipse.core.resources.problemmarker">
</super>
+ <persistent
+ value="true">
+ </persistent>
</extension>
<extension
point="org.jboss.tools.common.validation.validator">
Modified: trunk/ws/plugins/org.jboss.tools.ws.jaxrs.core/src/org/jboss/tools/ws/jaxrs/core/internal/metamodel/validation/JaxrsApplicationValidatorDelegate.java
===================================================================
--- trunk/ws/plugins/org.jboss.tools.ws.jaxrs.core/src/org/jboss/tools/ws/jaxrs/core/internal/metamodel/validation/JaxrsApplicationValidatorDelegate.java 2012-09-18 12:25:27 UTC (rev 43793)
+++ trunk/ws/plugins/org.jboss.tools.ws.jaxrs.core/src/org/jboss/tools/ws/jaxrs/core/internal/metamodel/validation/JaxrsApplicationValidatorDelegate.java 2012-09-18 12:45:37 UTC (rev 43794)
@@ -1,5 +1,6 @@
package org.jboss.tools.ws.jaxrs.core.internal.metamodel.validation;
+import org.eclipse.core.resources.IResource;
import org.eclipse.core.runtime.CoreException;
import org.jboss.tools.common.validation.TempMarkerManager;
import org.jboss.tools.ws.jaxrs.core.internal.metamodel.domain.JaxrsJavaApplication;
Modified: trunk/ws/plugins/org.jboss.tools.ws.jaxrs.core/src/org/jboss/tools/ws/jaxrs/core/internal/metamodel/validation/JaxrsMetamodelValidator.java
===================================================================
--- trunk/ws/plugins/org.jboss.tools.ws.jaxrs.core/src/org/jboss/tools/ws/jaxrs/core/internal/metamodel/validation/JaxrsMetamodelValidator.java 2012-09-18 12:25:27 UTC (rev 43793)
+++ trunk/ws/plugins/org.jboss.tools.ws.jaxrs.core/src/org/jboss/tools/ws/jaxrs/core/internal/metamodel/validation/JaxrsMetamodelValidator.java 2012-09-18 12:45:37 UTC (rev 43794)
@@ -87,10 +87,28 @@
*/
public IStatus validate(Set<IFile> changedFiles, IProject project, ContextValidationHelper validationHelper,
IProjectValidationContext context, ValidatorManager manager, IReporter reporter) throws ValidationException {
+ Logger.debug("*** Validating project {} after files {} changed... ***", project.getName(), changedFiles.toString());
init(project, validationHelper, context, manager, reporter);
setAsYouTypeValidation(false);
- for (IFile changedFile : changedFiles) {
- validate(reporter, changedFile);
+ try {
+ if (!changedFiles.isEmpty()) {
+ for (IFile changedFile : changedFiles) {
+ try {
+ final JaxrsMetamodel jaxrsMetamodel = JaxrsMetamodelLocator.get(changedFile.getProject());
+ validateJaxrsApplicationDeclarations(jaxrsMetamodel);
+ validate(reporter, changedFile, jaxrsMetamodel);
+ } catch (CoreException e) {
+ Logger.error("Failed to validate changed file " + changedFile.getName() + " in project "
+ + changedFile.getProject(), e);
+ }
+ }
+ }
+ // trigger a full validation instead
+ else {
+ validateAll(project, validationHelper, context, manager, reporter);
+ }
+ } finally {
+ Logger.debug("Validation done.");
}
return Status.OK_STATUS;
}
@@ -100,15 +118,13 @@
* @param file
* @throws CoreException
*/
- private void validate(final IReporter reporter, final IFile file) {
+ private void validate(final IReporter reporter, final IFile file, final JaxrsMetamodel jaxrsMetamodel) {
if (reporter.isCancelled() || !file.isAccessible()) {
return;
}
displaySubtask(JaxrsValidationMessages.VALIDATING_RESOURCE,
new String[] { file.getProject().getName(), file.getName() });
try {
- // clearMarkers((IFile) resource);
- final JaxrsMetamodel jaxrsMetamodel = JaxrsMetamodelLocator.get(file.getProject());
if (jaxrsMetamodel != null) {
List<JaxrsBaseElement> elements = jaxrsMetamodel.getElements(JdtUtils.getCompilationUnit(file));
for (JaxrsBaseElement element : elements) {
@@ -124,6 +140,7 @@
public void validate(org.eclipse.wst.validation.internal.provisional.core.IValidator validatorManager,
IProject rootProject, Collection<IRegion> dirtyRegions, IValidationContext helper, IReporter reporter,
EditorValidationContext validationContext, IProjectValidationContext projectContext, IFile file) {
+ Logger.debug("*** Validating project {} after file {} changed... ***", file.getProject().getName(), file.getFullPath());
ContextValidationHelper validationHelper = new ContextValidationHelper();
validationHelper.setProject(rootProject);
validationHelper.setValidationContextManager(validationContext);
@@ -132,13 +149,24 @@
this.document = validationContext.getDocument();
displaySubtask(JaxrsValidationMessages.VALIDATING_RESOURCE,
new String[] { file.getProject().getName(), file.getName() });
- validate(reporter, file);
+ try {
+ final JaxrsMetamodel jaxrsMetamodel = JaxrsMetamodelLocator.get(file.getProject());
+ validateJaxrsApplicationDeclarations(jaxrsMetamodel);
+ validate(reporter, file, jaxrsMetamodel);
+ } catch (CoreException e) {
+ Logger.error(
+ "Failed to validate changed file " + file.getName() + " in project "
+ + file.getProject(), e);
+ } finally {
+ Logger.debug("Validation done.");
+ }
}
@Override
public IStatus validateAll(IProject project, ContextValidationHelper validationHelper,
IProjectValidationContext validationContext, ValidatorManager manager, IReporter reporter)
throws ValidationException {
+ Logger.debug("*** Validating all files in project {} ***", project.getName());
init(project, validationHelper, validationContext, manager, reporter);
setAsYouTypeValidation(false);
displaySubtask(JaxrsValidationMessages.VALIDATING_PROJECT, new String[] { project.getName() });
@@ -154,12 +182,17 @@
}
} catch (CoreException e) {
Logger.error("Failed to validate project '", e);
+ } finally {
+ Logger.debug("Validation done.");
}
return Status.OK_STATUS;
}
private void validateJaxrsApplicationDeclarations(JaxrsMetamodel jaxrsMetamodel) throws CoreException {
+ if(jaxrsMetamodel == null) {
+ return;
+ }
MarkerUtils.clearMarkers(jaxrsMetamodel.getProject());
final List<IJaxrsApplication> allApplications = jaxrsMetamodel.getAllApplications();
if(allApplications.isEmpty()) {
Modified: trunk/ws/plugins/org.jboss.tools.ws.jaxrs.core/src/org/jboss/tools/ws/jaxrs/core/internal/metamodel/validation/JaxrsResourceValidatorDelegate.java
===================================================================
--- trunk/ws/plugins/org.jboss.tools.ws.jaxrs.core/src/org/jboss/tools/ws/jaxrs/core/internal/metamodel/validation/JaxrsResourceValidatorDelegate.java 2012-09-18 12:25:27 UTC (rev 43793)
+++ trunk/ws/plugins/org.jboss.tools.ws.jaxrs.core/src/org/jboss/tools/ws/jaxrs/core/internal/metamodel/validation/JaxrsResourceValidatorDelegate.java 2012-09-18 12:45:37 UTC (rev 43794)
@@ -1,5 +1,6 @@
package org.jboss.tools.ws.jaxrs.core.internal.metamodel.validation;
+import org.eclipse.core.resources.IResource;
import org.eclipse.core.runtime.CoreException;
import org.jboss.tools.common.validation.TempMarkerManager;
import org.jboss.tools.ws.jaxrs.core.internal.metamodel.domain.JaxrsResource;
Modified: trunk/ws/plugins/org.jboss.tools.ws.jaxrs.core/src/org/jboss/tools/ws/jaxrs/core/internal/metamodel/validation/MarkerUtils.java
===================================================================
--- trunk/ws/plugins/org.jboss.tools.ws.jaxrs.core/src/org/jboss/tools/ws/jaxrs/core/internal/metamodel/validation/MarkerUtils.java 2012-09-18 12:25:27 UTC (rev 43793)
+++ trunk/ws/plugins/org.jboss.tools.ws.jaxrs.core/src/org/jboss/tools/ws/jaxrs/core/internal/metamodel/validation/MarkerUtils.java 2012-09-18 12:45:37 UTC (rev 43794)
@@ -20,12 +20,12 @@
*/
public class MarkerUtils {
- public static void clearMarkers(IResource resource) throws CoreException {
+ public static void clearMarkers(final IResource resource) throws CoreException {
if (resource == null) {
return;
}
- Logger.debug("Clearing JAXRS markers for resource " + resource.getName());
- resource.deleteMarkers(JaxrsMetamodelValidator.JAXRS_PROBLEM_TYPE, true, org.eclipse.core.resources.IResource.DEPTH_INFINITE);
+ Logger.debug("Clearing JAX-RS markers for resource " + resource.getName());
+ resource.deleteMarkers(JaxrsMetamodelValidator.JAXRS_PROBLEM_TYPE, true, IResource.DEPTH_ONE);
}
}
More information about the jbosstools-commits
mailing list