Author: akazakov
Date: 2011-07-01 17:22:43 -0400 (Fri, 01 Jul 2011)
New Revision: 32533
Added:
trunk/jst/plugins/org.jboss.tools.jst.web.kb/src/org/jboss/tools/jst/web/kb/internal/validation/WebValidator.java
Modified:
trunk/jsf/plugins/org.jboss.tools.jsf/src/org/jboss/tools/jsf/web/validation/composite/CompositeComponentValidator.java
trunk/jst/plugins/org.jboss.tools.jst.web.kb/src/org/jboss/tools/jst/web/kb/internal/validation/ELValidator.java
trunk/jst/plugins/org.jboss.tools.jst.web/src/org/jboss/tools/jst/web/WebUtils.java
trunk/seam/plugins/org.jboss.tools.seam.core/src/org/jboss/tools/seam/internal/core/project/facet/SeamFacetAbstractInstallDelegate.java
Log:
https://issues.jboss.org/browse/JBIDE-9286
Modified:
trunk/jsf/plugins/org.jboss.tools.jsf/src/org/jboss/tools/jsf/web/validation/composite/CompositeComponentValidator.java
===================================================================
---
trunk/jsf/plugins/org.jboss.tools.jsf/src/org/jboss/tools/jsf/web/validation/composite/CompositeComponentValidator.java 2011-07-01
21:03:04 UTC (rev 32532)
+++
trunk/jsf/plugins/org.jboss.tools.jsf/src/org/jboss/tools/jsf/web/validation/composite/CompositeComponentValidator.java 2011-07-01
21:22:43 UTC (rev 32533)
@@ -14,7 +14,6 @@
import java.util.HashSet;
import java.util.Set;
-import org.eclipse.core.resources.IContainer;
import org.eclipse.core.resources.IFile;
import org.eclipse.core.resources.IMarker;
import org.eclipse.core.resources.IProject;
@@ -24,13 +23,6 @@
import org.eclipse.core.runtime.CoreException;
import org.eclipse.core.runtime.IPath;
import org.eclipse.core.runtime.IStatus;
-import org.eclipse.core.runtime.Path;
-import org.eclipse.jst.j2ee.project.facet.IJ2EEFacetConstants;
-import org.eclipse.wst.common.componentcore.ComponentCore;
-import org.eclipse.wst.common.componentcore.resources.IVirtualComponent;
-import org.eclipse.wst.common.componentcore.resources.IVirtualFolder;
-import org.eclipse.wst.common.project.facet.core.IFacetedProject;
-import org.eclipse.wst.common.project.facet.core.ProjectFacetsManager;
import org.eclipse.wst.sse.core.StructuredModelManager;
import org.eclipse.wst.sse.core.internal.provisional.IModelManager;
import org.eclipse.wst.sse.core.internal.provisional.IStructuredModel;
@@ -49,8 +41,8 @@
import org.jboss.tools.jst.web.kb.PageContextFactory;
import org.jboss.tools.jst.web.kb.internal.KbBuilder;
import org.jboss.tools.jst.web.kb.internal.validation.ContextValidationHelper;
-import org.jboss.tools.jst.web.kb.internal.validation.KBValidator;
import org.jboss.tools.jst.web.kb.internal.validation.ValidatorManager;
+import org.jboss.tools.jst.web.kb.internal.validation.WebValidator;
import org.jboss.tools.jst.web.kb.taglib.IComponent;
import org.jboss.tools.jst.web.kb.taglib.ICompositeTagLibrary;
import org.jboss.tools.jst.web.kb.taglib.ITagLibrary;
@@ -67,7 +59,7 @@
*
* @author Alexey Kazakov
*/
-public class CompositeComponentValidator extends KBValidator {
+public class CompositeComponentValidator extends WebValidator {
public static final String ID =
"org.jboss.tools.jsf.CompositeComponentValidator"; //$NON-NLS-1$
public static final String PROBLEM_TYPE =
"org.jboss.tools.jsf.compositeproblem"; //$NON-NLS-1$
@@ -80,22 +72,8 @@
public static final int UNKNOWN_COMPOSITE_COMPONENT_NAME_ID = 1;
public static final int UNKNOWN_COMPOSITE_COMPONENT_ATTRIBUTE_ID = 2;
- private IProject currentProject;
- private IContainer webRootFolder;
-
/*
* (non-Javadoc)
- * @see
org.jboss.tools.jst.web.kb.internal.validation.ValidationErrorManager#init(org.eclipse.core.resources.IProject,
org.jboss.tools.jst.web.kb.internal.validation.ContextValidationHelper,
org.jboss.tools.jst.web.kb.validation.IProjectValidationContext,
org.eclipse.wst.validation.internal.provisional.core.IValidator,
org.eclipse.wst.validation.internal.provisional.core.IReporter)
- */
- @Override
- public void init(IProject project, ContextValidationHelper validationHelper,
IProjectValidationContext context,
org.eclipse.wst.validation.internal.provisional.core.IValidator manager, IReporter
reporter) {
- super.init(project, validationHelper, context, manager, reporter);
- currentProject = null;
- webRootFolder = null;
- }
-
- /*
- * (non-Javadoc)
* @see org.jboss.tools.jst.web.kb.validation.IValidator#validate(java.util.Set,
org.eclipse.core.resources.IProject,
org.jboss.tools.jst.web.kb.internal.validation.ContextValidationHelper,
org.jboss.tools.jst.web.kb.validation.IProjectValidationContext,
org.jboss.tools.jst.web.kb.internal.validation.ValidatorManager,
org.eclipse.wst.validation.internal.provisional.core.IReporter)
*/
public IStatus validate(Set<IFile> changedFiles, IProject project,
ContextValidationHelper validationHelper, IProjectValidationContext validationContext,
ValidatorManager manager, IReporter reporter) throws ValidationException {
@@ -274,49 +252,6 @@
}
}
- private boolean enabled = true;
-
- private boolean shouldFileBeValidated(IFile file) {
- if(!file.isAccessible()) {
- return false;
- }
- IProject project = file.getProject();
- if(!file.isSynchronized(IResource.DEPTH_ZERO)) {
- // The resource is out of sync with the file system
- // Just ignore this resource.
- return false;
- }
- if(!project.equals(currentProject)) {
- currentProject = project;
- enabled = isEnabled(project);
- if(!enabled) {
- return false;
- }
- if(webRootFolder!=null && !project.equals(webRootFolder.getProject())) {
- webRootFolder = null;
- }
- if(webRootFolder==null) {
- IFacetedProject facetedProject = null;
- try {
- facetedProject = ProjectFacetsManager.create(project);
- } catch (CoreException e) {
- JSFModelPlugin.getDefault().logError(e);
- }
- if(facetedProject!=null &&
facetedProject.getProjectFacetVersion(IJ2EEFacetConstants.DYNAMIC_WEB_FACET)!=null) {
- IVirtualComponent component = ComponentCore.createComponent(project);
- if(component!=null) {
- IVirtualFolder webRootVirtFolder = component.getRootFolder().getFolder(new
Path("/")); //$NON-NLS-1$
- webRootFolder = webRootVirtFolder.getUnderlyingFolder();
- }
- }
- }
- currentProject = project;
- }
-
- // Validate files from Web-Content only (in case of WTP project)
- return enabled && webRootFolder!=null &&
webRootFolder.getLocation().isPrefixOf(file.getLocation()) &&
PageContextFactory.isPage(file);
- }
-
/*
* (non-Javadoc)
* @see org.jboss.tools.jst.web.kb.validation.IValidator#getId()
@@ -406,4 +341,13 @@
}
return marker;
}
+
+ /*
+ * (non-Javadoc)
+ * @see
org.jboss.tools.jst.web.kb.internal.validation.WebValidator#shouldValidateJavaSources()
+ */
+ @Override
+ protected boolean shouldValidateJavaSources() {
+ return false;
+ }
}
\ No newline at end of file
Modified:
trunk/jst/plugins/org.jboss.tools.jst.web/src/org/jboss/tools/jst/web/WebUtils.java
===================================================================
---
trunk/jst/plugins/org.jboss.tools.jst.web/src/org/jboss/tools/jst/web/WebUtils.java 2011-07-01
21:03:04 UTC (rev 32532)
+++
trunk/jst/plugins/org.jboss.tools.jst.web/src/org/jboss/tools/jst/web/WebUtils.java 2011-07-01
21:22:43 UTC (rev 32533)
@@ -17,6 +17,7 @@
import java.util.Set;
import java.util.TreeSet;
+import org.eclipse.core.resources.IContainer;
import org.eclipse.core.resources.IFile;
import org.eclipse.core.resources.IProject;
import org.eclipse.core.runtime.CoreException;
@@ -25,12 +26,17 @@
import org.eclipse.core.runtime.IExtensionPoint;
import org.eclipse.core.runtime.IPath;
import org.eclipse.core.runtime.NullProgressMonitor;
+import org.eclipse.core.runtime.Path;
import org.eclipse.core.runtime.Platform;
import org.eclipse.jdt.core.IClasspathEntry;
import org.eclipse.jdt.core.JavaCore;
import org.eclipse.jst.j2ee.internal.project.J2EEProjectUtilities;
+import org.eclipse.jst.j2ee.project.facet.IJ2EEFacetConstants;
import org.eclipse.wst.common.componentcore.ComponentCore;
import org.eclipse.wst.common.componentcore.resources.IVirtualComponent;
+import org.eclipse.wst.common.componentcore.resources.IVirtualFolder;
+import org.eclipse.wst.common.project.facet.core.IFacetedProject;
+import org.eclipse.wst.common.project.facet.core.ProjectFacetsManager;
import org.jboss.tools.common.model.project.IModelNature;
import org.jboss.tools.common.model.util.EclipseResourceUtil;
import org.jboss.tools.jst.web.project.WebProject;
@@ -78,7 +84,23 @@
return (modelNature != null) ?
WebProject.getInstance(modelNature.getModel()).getWebRootLocation() : null;
}
-
+ public static IContainer[] getWebRootFolders(IProject project) {
+ IFacetedProject facetedProject = null;
+ try {
+ facetedProject = ProjectFacetsManager.create(project);
+ } catch (CoreException e) {
+ WebModelPlugin.getDefault().logError(e);
+ }
+ if(facetedProject!=null &&
facetedProject.getProjectFacetVersion(IJ2EEFacetConstants.DYNAMIC_WEB_FACET)!=null) {
+ IVirtualComponent component = ComponentCore.createComponent(project);
+ if(component!=null) {
+ IVirtualFolder webRootVirtFolder = component.getRootFolder().getFolder(new
Path("/")); //$NON-NLS-1$
+ return webRootVirtFolder.getUnderlyingFolders();
+ }
+ }
+ return null;
+ }
+
public static String[] getServletLibraries(String natureId, String templateBase, String
servletVersion) {
String classPathVarName = findClassPathVarByNatureId(natureId);
Modified:
trunk/jst/plugins/org.jboss.tools.jst.web.kb/src/org/jboss/tools/jst/web/kb/internal/validation/ELValidator.java
===================================================================
---
trunk/jst/plugins/org.jboss.tools.jst.web.kb/src/org/jboss/tools/jst/web/kb/internal/validation/ELValidator.java 2011-07-01
21:03:04 UTC (rev 32532)
+++
trunk/jst/plugins/org.jboss.tools.jst.web.kb/src/org/jboss/tools/jst/web/kb/internal/validation/ELValidator.java 2011-07-01
21:22:43 UTC (rev 32533)
@@ -15,7 +15,6 @@
import java.util.List;
import java.util.Set;
-import org.eclipse.core.resources.IContainer;
import org.eclipse.core.resources.IFile;
import org.eclipse.core.resources.IMarker;
import org.eclipse.core.resources.IProject;
@@ -29,14 +28,7 @@
import org.eclipse.core.runtime.IExtensionRegistry;
import org.eclipse.core.runtime.IPath;
import org.eclipse.core.runtime.IStatus;
-import org.eclipse.core.runtime.Path;
import org.eclipse.core.runtime.Platform;
-import org.eclipse.jst.j2ee.project.facet.IJ2EEFacetConstants;
-import org.eclipse.wst.common.componentcore.ComponentCore;
-import org.eclipse.wst.common.componentcore.resources.IVirtualComponent;
-import org.eclipse.wst.common.componentcore.resources.IVirtualFolder;
-import org.eclipse.wst.common.project.facet.core.IFacetedProject;
-import org.eclipse.wst.common.project.facet.core.ProjectFacetsManager;
import org.eclipse.wst.validation.internal.core.ValidationException;
import org.eclipse.wst.validation.internal.provisional.core.IReporter;
import org.jboss.tools.common.el.core.ELReference;
@@ -58,7 +50,6 @@
import org.jboss.tools.common.el.core.resolver.SimpleELContext;
import org.jboss.tools.common.el.core.resolver.TypeInfoCollector;
import org.jboss.tools.common.el.core.resolver.Var;
-import org.jboss.tools.common.model.util.EclipseResourceUtil;
import org.jboss.tools.jst.web.kb.PageContextFactory;
import org.jboss.tools.jst.web.kb.WebKbPlugin;
import org.jboss.tools.jst.web.kb.internal.KbBuilder;
@@ -71,7 +62,7 @@
* EL Validator
* @author Alexey Kazakov
*/
-public class ELValidator extends KBValidator {
+public class ELValidator extends WebValidator {
public static final String ID = "org.jboss.tools.jst.web.kb.ELValidator";
//$NON-NLS-1$
public static final String PROBLEM_TYPE =
"org.jboss.tools.jst.web.kb.elproblem"; //$NON-NLS-1$
@@ -83,9 +74,6 @@
private ELResolver[] resolvers;
protected ELParserFactory mainFactory;
- private IProject currentProject;
- private IResource[] currentSources;
- private IContainer webRootFolder;
private boolean revalidateUnresolvedELs = false;
private boolean validateVars = true;
@@ -148,7 +136,6 @@
resolvers = ELResolverFactoryManager.getInstance().getResolvers(project);
mainFactory = ELParserUtil.getJbossFactory();
validateVars =
ELSeverityPreferences.ENABLE.equals(ELSeverityPreferences.getInstance().getProjectPreference(validatingProject,
ELSeverityPreferences.CHECK_VARS));
- currentProject = null;
}
/*
@@ -157,7 +144,6 @@
*/
public IStatus validate(Set<IFile> changedFiles, IProject project,
ContextValidationHelper validationHelper, IProjectValidationContext context,
ValidatorManager manager, IReporter reporter) throws ValidationException {
init(project, validationHelper, context, manager, reporter);
- webRootFolder = null;
initRevalidationFlag();
IWorkspaceRoot wsRoot = ResourcesPlugin.getWorkspace().getRoot();
@@ -224,7 +210,6 @@
*/
public IStatus validateAll(IProject project, ContextValidationHelper validationHelper,
IProjectValidationContext context, ValidatorManager manager, IReporter reporter) throws
ValidationException {
init(project, validationHelper, context, manager, reporter);
- webRootFolder = null;
initRevalidationFlag();
Set<IFile> files = validationHelper.getProjectSetRegisteredFiles();
Set<IFile> filesToValidate = new HashSet<IFile>();
@@ -243,67 +228,6 @@
return OK_STATUS;
}
- private static final String JAVA_EXT = "java"; //$NON-NLS-1$
-
- private boolean enabled = true;
-
- private boolean shouldFileBeValidated(IFile file) {
- if(!file.isAccessible()) {
- return false;
- }
- IProject project = file.getProject();
- if(!file.isSynchronized(IResource.DEPTH_ZERO)) {
- // The resource is out of sync with the file system
- // Just ignore this resource.
- return false;
- }
- if(!project.equals(currentProject)) {
- currentProject = project;
- enabled = isEnabled(project);
- if(!enabled) {
- return false;
- }
- if(webRootFolder!=null && !project.equals(webRootFolder.getProject())) {
- webRootFolder = null;
- }
- if(webRootFolder==null) {
- IFacetedProject facetedProject = null;
- try {
- facetedProject = ProjectFacetsManager.create(project);
- } catch (CoreException e) {
- WebKbPlugin.getDefault().logError(ELValidationMessages.EL_VALIDATOR_ERROR_VALIDATING,
e);
- }
- if(facetedProject!=null &&
facetedProject.getProjectFacetVersion(IJ2EEFacetConstants.DYNAMIC_WEB_FACET)!=null) {
- IVirtualComponent component = ComponentCore.createComponent(project);
- if(component!=null) {
- IVirtualFolder webRootVirtFolder = component.getRootFolder().getFolder(new
Path("/")); //$NON-NLS-1$
- webRootFolder = webRootVirtFolder.getUnderlyingFolder();
- }
- }
- }
- currentProject = project;
- currentSources = EclipseResourceUtil.getJavaSourceRoots(project);
- }
- if(!enabled) {
- return false;
- }
- // Validate all files from java source folders.
- for (int i = 0; currentSources!=null && i < currentSources.length; i++) {
- if(currentSources[i].getLocation().isPrefixOf(file.getLocation())) {
- return true;
- }
- }
- // If *.java is out of Java Source path then ignore it.
- if(JAVA_EXT.equalsIgnoreCase(file.getFileExtension())) {
- return false;
- }
- // Otherwise validate only files from Web-Content (in case of WTP project)
- if(webRootFolder!=null) {
- return webRootFolder.getLocation().isPrefixOf(file.getLocation());
- }
- return true;
- }
-
private int markers;
private void validateFile(IFile file) {
@@ -553,4 +477,12 @@
return ValidatorManager.validateBuilderOrder(project, getBuilderId(), getId(),
ELSeverityPreferences.getInstance());
}
-}
+ /*
+ * (non-Javadoc)
+ * @see
org.jboss.tools.jst.web.kb.internal.validation.WebValidator#shouldValidateJavaSources()
+ */
+ @Override
+ protected boolean shouldValidateJavaSources() {
+ return true;
+ }
+}
\ No newline at end of file
Added:
trunk/jst/plugins/org.jboss.tools.jst.web.kb/src/org/jboss/tools/jst/web/kb/internal/validation/WebValidator.java
===================================================================
---
trunk/jst/plugins/org.jboss.tools.jst.web.kb/src/org/jboss/tools/jst/web/kb/internal/validation/WebValidator.java
(rev 0)
+++
trunk/jst/plugins/org.jboss.tools.jst.web.kb/src/org/jboss/tools/jst/web/kb/internal/validation/WebValidator.java 2011-07-01
21:22:43 UTC (rev 32533)
@@ -0,0 +1,102 @@
+ /*******************************************************************************
+ * Copyright (c) 2011 Red Hat, Inc.
+ * Distributed under license by Red Hat, Inc. All rights reserved.
+ * This program is made available under the terms of the
+ * Eclipse Public License v1.0 which accompanies this distribution,
+ * and is available at
http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Red Hat, Inc. - initial API and implementation
+ ******************************************************************************/
+package org.jboss.tools.jst.web.kb.internal.validation;
+
+import org.eclipse.core.resources.IContainer;
+import org.eclipse.core.resources.IFile;
+import org.eclipse.core.resources.IProject;
+import org.eclipse.core.resources.IResource;
+import org.eclipse.wst.validation.internal.provisional.core.IReporter;
+import org.jboss.tools.common.model.util.EclipseResourceUtil;
+import org.jboss.tools.jst.web.WebUtils;
+import org.jboss.tools.jst.web.kb.validation.IProjectValidationContext;
+
+/**
+ * @author Alexey Kazakov
+ */
+abstract public class WebValidator extends KBValidator {
+
+ private static final String JAVA_EXT = "java"; //$NON-NLS-1$
+
+ protected IContainer[] webRootFolders;
+ protected IProject currentProject;
+ protected IResource[] currentSources;
+
+ private boolean enabled = true;
+
+ /*
+ * (non-Javadoc)
+ * @see
org.jboss.tools.jst.web.kb.internal.validation.ValidationErrorManager#init(org.eclipse.core.resources.IProject,
org.jboss.tools.jst.web.kb.internal.validation.ContextValidationHelper,
org.jboss.tools.jst.web.kb.validation.IProjectValidationContext,
org.eclipse.wst.validation.internal.provisional.core.IValidator,
org.eclipse.wst.validation.internal.provisional.core.IReporter)
+ */
+ @Override
+ public void init(IProject project, ContextValidationHelper validationHelper,
IProjectValidationContext context,
org.eclipse.wst.validation.internal.provisional.core.IValidator manager, IReporter
reporter) {
+ super.init(project, validationHelper, context, manager, reporter);
+ webRootFolders = null;
+ currentProject = null;
+ }
+
+ abstract protected boolean shouldValidateJavaSources();
+
+ protected boolean shouldFileBeValidated(IFile file) {
+ if(!file.isAccessible()) {
+ return false;
+ }
+ IProject project = file.getProject();
+ if(!file.isSynchronized(IResource.DEPTH_ZERO)) {
+ // The resource is out of sync with the file system
+ // Just ignore this resource.
+ return false;
+ }
+ if(!project.equals(currentProject)) {
+ currentProject = project;
+ enabled = isEnabled(project);
+ if(!enabled) {
+ return false;
+ }
+ if(webRootFolders!=null && webRootFolders.length>0 &&
!project.equals(webRootFolders[0].getProject())) {
+ webRootFolders = null;
+ }
+ if(webRootFolders==null) {
+ webRootFolders = WebUtils.getWebRootFolders(project);
+ }
+ if(shouldValidateJavaSources()) {
+ currentSources = EclipseResourceUtil.getJavaSourceRoots(project);
+ }
+ }
+ if(!enabled) {
+ return false;
+ }
+ // Validate all files from java source folders, if we should.
+ if(shouldValidateJavaSources()) {
+ for (int i = 0; currentSources!=null && i < currentSources.length; i++) {
+ if(currentSources[i].getLocation().isPrefixOf(file.getLocation())) {
+ return true;
+ }
+ }
+ // If *.java is out of Java Source path then ignore it.
+ if(JAVA_EXT.equalsIgnoreCase(file.getFileExtension())) {
+ return false;
+ }
+ }
+ // Otherwise validate only files from Web-Content (in case of WTP project)
+ if(webRootFolders!=null) {
+ for (IContainer webRootFolder : webRootFolders) {
+ if(webRootFolder.getLocation().isPrefixOf(file.getLocation())) {
+ return true;
+ }
+ }
+ if(webRootFolders.length>1) {
+ return false;
+ }
+ }
+ return true;
+ }
+}
\ No newline at end of file
Property changes on:
trunk/jst/plugins/org.jboss.tools.jst.web.kb/src/org/jboss/tools/jst/web/kb/internal/validation/WebValidator.java
___________________________________________________________________
Added: svn:mime-type
+ text/plain
Modified:
trunk/seam/plugins/org.jboss.tools.seam.core/src/org/jboss/tools/seam/internal/core/project/facet/SeamFacetAbstractInstallDelegate.java
===================================================================
---
trunk/seam/plugins/org.jboss.tools.seam.core/src/org/jboss/tools/seam/internal/core/project/facet/SeamFacetAbstractInstallDelegate.java 2011-07-01
21:03:04 UTC (rev 32532)
+++
trunk/seam/plugins/org.jboss.tools.seam.core/src/org/jboss/tools/seam/internal/core/project/facet/SeamFacetAbstractInstallDelegate.java 2011-07-01
21:22:43 UTC (rev 32533)
@@ -330,7 +330,19 @@
IVirtualComponent component = ComponentCore.createComponent(project);
IVirtualFolder webRootVirtFolder = component.getRootFolder().getFolder(new
Path("/")); //$NON-NLS-1$
warDefaultSrcRootFolder = component.getRootFolder().getFolder(new
Path("/WEB-INF/classes")); //$NON-NLS-1$
- webRootFolder = webRootVirtFolder.getUnderlyingFolder();
+ IContainer[] roots = webRootVirtFolder.getUnderlyingFolders();
+ webRootFolder = null;
+ if(roots.length>1) {
+ for (IContainer container : roots) {
+ if(!container.getFullPath().toString().contains("/target/")) {
//$NON-NLS-1$
+ webRootFolder = container;
+ break;
+ }
+ }
+ }
+ if(webRootFolder==null) {
+ webRootFolder = webRootVirtFolder.getUnderlyingFolder();
+ }
webContentFolder = webRootFolder.getLocation().toFile();
webContentPath = webRootFolder.getFullPath();