Author: rombert Date: Tue Oct 13 12:10:23 2015 New Revision: 1708361 URL: http://svn.apache.org/viewvc?rev=1708361&view=rev Log: SLING-4189 - Add basic code completion for Sightly
Create FacetHelper in eclipse-core to reduce code duplication. Added: sling/trunk/tooling/ide/eclipse-core/src/org/apache/sling/ide/eclipse/core/facet/ sling/trunk/tooling/ide/eclipse-core/src/org/apache/sling/ide/eclipse/core/facet/FacetHelper.java - copied, changed from r1708360, sling/trunk/tooling/ide/eclipse-sightly-core/src/org/apache/sling/ide/eclipse/sightly/FacetHelper.java sling/trunk/tooling/ide/eclipse-sightly-core/src/org/apache/sling/ide/eclipse/sightly/SightlyFacetHelper.java - copied, changed from r1708360, sling/trunk/tooling/ide/eclipse-sightly-core/src/org/apache/sling/ide/eclipse/sightly/FacetHelper.java Removed: sling/trunk/tooling/ide/eclipse-sightly-core/src/org/apache/sling/ide/eclipse/sightly/FacetHelper.java Modified: sling/trunk/tooling/ide/eclipse-core/META-INF/MANIFEST.MF sling/trunk/tooling/ide/eclipse-core/src/org/apache/sling/ide/eclipse/core/internal/ProjectHelper.java sling/trunk/tooling/ide/eclipse-sightly-core/META-INF/MANIFEST.MF sling/trunk/tooling/ide/eclipse-sightly-core/src/org/apache/sling/ide/eclipse/sightly/internal/Validator.java sling/trunk/tooling/ide/eclipse-sightly-ui/src/org/apache/sling/ide/eclipse/sightly/ui/internal/ProposalComputer.java Modified: sling/trunk/tooling/ide/eclipse-core/META-INF/MANIFEST.MF URL: http://svn.apache.org/viewvc/sling/trunk/tooling/ide/eclipse-core/META-INF/MANIFEST.MF?rev=1708361&r1=1708360&r2=1708361&view=diff ============================================================================== --- sling/trunk/tooling/ide/eclipse-core/META-INF/MANIFEST.MF (original) +++ sling/trunk/tooling/ide/eclipse-core/META-INF/MANIFEST.MF Tue Oct 13 12:10:23 2015 @@ -46,5 +46,5 @@ Import-Package: org.apache.commons.httpc Export-Package: org.apache.sling.ide.eclipse.core,org.apache.sling.ide .eclipse.core.debug,org.apache.sling.ide.eclipse.core.internal,org.ap ache.sling.ide.eclipse.core.progress,org.apache.sling.ide.eclipse.int - ernal.validation;x-friends:="org.apache.sling.ide.eclipse-test" + ernal.validation;x-friends:="org.apache.sling.ide.eclipse-test",org.apache.sling.ide.eclipse.core.facet Service-Component: OSGI-INF/TraceCommandExecutionEventsHandler.xml Copied: sling/trunk/tooling/ide/eclipse-core/src/org/apache/sling/ide/eclipse/core/facet/FacetHelper.java (from r1708360, sling/trunk/tooling/ide/eclipse-sightly-core/src/org/apache/sling/ide/eclipse/sightly/FacetHelper.java) URL: http://svn.apache.org/viewvc/sling/trunk/tooling/ide/eclipse-core/src/org/apache/sling/ide/eclipse/core/facet/FacetHelper.java?p2=sling/trunk/tooling/ide/eclipse-core/src/org/apache/sling/ide/eclipse/core/facet/FacetHelper.java&p1=sling/trunk/tooling/ide/eclipse-sightly-core/src/org/apache/sling/ide/eclipse/sightly/FacetHelper.java&r1=1708360&r2=1708361&rev=1708361&view=diff ============================================================================== --- sling/trunk/tooling/ide/eclipse-sightly-core/src/org/apache/sling/ide/eclipse/sightly/FacetHelper.java (original) +++ sling/trunk/tooling/ide/eclipse-core/src/org/apache/sling/ide/eclipse/core/facet/FacetHelper.java Tue Oct 13 12:10:23 2015 @@ -14,34 +14,41 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -package org.apache.sling.ide.eclipse.sightly; +package org.apache.sling.ide.eclipse.core.facet; import org.eclipse.core.resources.IProject; import org.eclipse.wst.common.project.facet.core.IFacetedProject; import org.eclipse.wst.common.project.facet.core.IProjectFacet; import org.eclipse.wst.common.project.facet.core.ProjectFacetsManager; -public class FacetHelper { - - - private static final String SIGHTLY_FACET = "sightly"; +/** + * Groups common utility methods related to project facets + */ +public abstract class FacetHelper { - public static boolean hasSightlyFacet(IProject project) { + private FacetHelper() { - return containsFacet(project, SIGHTLY_FACET); } - // TODO - copied from eclipse-core/.../ProjectHelper - private static boolean containsFacet(IProject project, String facetId) { - // deleted modules can trigger a publish call without having an attached project + /** + * Checks if the specified project has the specified facet + * + * @param project the project, may be <code>null</code> + * @param facetId the facet to check for + * @return true if the specified <tt>project</tt> has the specified <tt>facetId</tt> + */ + public static boolean containsFacet(IProject project, String facetId) { + if (project == null) { return false; } + IFacetedProject facetedProject = (IFacetedProject) project.getAdapter(IFacetedProject.class); if (facetedProject==null ) { return false; } + IProjectFacet facet = ProjectFacetsManager.getProjectFacet(facetId); return facetedProject.hasProjectFacet(facet); - } + } } Modified: sling/trunk/tooling/ide/eclipse-core/src/org/apache/sling/ide/eclipse/core/internal/ProjectHelper.java URL: http://svn.apache.org/viewvc/sling/trunk/tooling/ide/eclipse-core/src/org/apache/sling/ide/eclipse/core/internal/ProjectHelper.java?rev=1708361&r1=1708360&r2=1708361&view=diff ============================================================================== --- sling/trunk/tooling/ide/eclipse-core/src/org/apache/sling/ide/eclipse/core/internal/ProjectHelper.java (original) +++ sling/trunk/tooling/ide/eclipse-core/src/org/apache/sling/ide/eclipse/core/internal/ProjectHelper.java Tue Oct 13 12:10:23 2015 @@ -22,6 +22,7 @@ import javax.xml.parsers.DocumentBuilder import javax.xml.parsers.DocumentBuilderFactory; import javax.xml.parsers.ParserConfigurationException; +import org.apache.sling.ide.eclipse.core.facet.FacetHelper; import org.eclipse.core.resources.IContainer; import org.eclipse.core.resources.IFile; import org.eclipse.core.resources.IFolder; @@ -33,9 +34,6 @@ import org.eclipse.jdt.core.IJavaModel; import org.eclipse.jdt.core.IJavaProject; import org.eclipse.jdt.core.JavaCore; import org.eclipse.jdt.core.JavaModelException; -import org.eclipse.wst.common.project.facet.core.IFacetedProject; -import org.eclipse.wst.common.project.facet.core.IProjectFacet; -import org.eclipse.wst.common.project.facet.core.ProjectFacetsManager; import org.w3c.dom.Document; import org.w3c.dom.Element; import org.w3c.dom.Node; @@ -135,26 +133,13 @@ public class ProjectHelper { } public static boolean isBundleProject(IProject project) { - return containsFacet(project, SlingBundleModuleFactory.SLING_BUNDLE_FACET_ID); + return FacetHelper.containsFacet(project, SlingBundleModuleFactory.SLING_BUNDLE_FACET_ID); } public static boolean isContentProject(IProject project) { - return containsFacet(project, SlingContentModuleFactory.SLING_CONTENT_FACET_ID); + return FacetHelper.containsFacet(project, SlingContentModuleFactory.SLING_CONTENT_FACET_ID); } - private static boolean containsFacet(IProject project, String facetId) { - // deleted modules can trigger a publish call without having an attached project - if (project == null) { - return false; - } - IFacetedProject facetedProject = (IFacetedProject) project.getAdapter(IFacetedProject.class); - if (facetedProject==null ) { - return false; - } - IProjectFacet facet = ProjectFacetsManager.getProjectFacet(facetId); - return facetedProject.hasProjectFacet(facet); - } - public static IJavaProject asJavaProject(IProject project) { return JavaCore.create(project); } Modified: sling/trunk/tooling/ide/eclipse-sightly-core/META-INF/MANIFEST.MF URL: http://svn.apache.org/viewvc/sling/trunk/tooling/ide/eclipse-sightly-core/META-INF/MANIFEST.MF?rev=1708361&r1=1708360&r2=1708361&view=diff ============================================================================== --- sling/trunk/tooling/ide/eclipse-sightly-core/META-INF/MANIFEST.MF (original) +++ sling/trunk/tooling/ide/eclipse-sightly-core/META-INF/MANIFEST.MF Tue Oct 13 12:10:23 2015 @@ -23,7 +23,8 @@ Import-Package: org.eclipse.jface.resour org.eclipse.wst.validation.internal.model, org.eclipse.wst.validation.internal.provisional.core, org.eclipse.wst.xml.core.internal.provisional.document, - org.eclipse.wst.xml.core.internal.regions + org.eclipse.wst.xml.core.internal.regions, + org.apache.sling.ide.eclipse.core.facet Export-Package: org.apache.sling.ide.eclipse.sightly, org.apache.sling.ide.eclipse.sightly.model, org.apache.sling.ide.eclipse.sightly.validation Copied: sling/trunk/tooling/ide/eclipse-sightly-core/src/org/apache/sling/ide/eclipse/sightly/SightlyFacetHelper.java (from r1708360, sling/trunk/tooling/ide/eclipse-sightly-core/src/org/apache/sling/ide/eclipse/sightly/FacetHelper.java) URL: http://svn.apache.org/viewvc/sling/trunk/tooling/ide/eclipse-sightly-core/src/org/apache/sling/ide/eclipse/sightly/SightlyFacetHelper.java?p2=sling/trunk/tooling/ide/eclipse-sightly-core/src/org/apache/sling/ide/eclipse/sightly/SightlyFacetHelper.java&p1=sling/trunk/tooling/ide/eclipse-sightly-core/src/org/apache/sling/ide/eclipse/sightly/FacetHelper.java&r1=1708360&r2=1708361&rev=1708361&view=diff ============================================================================== --- sling/trunk/tooling/ide/eclipse-sightly-core/src/org/apache/sling/ide/eclipse/sightly/FacetHelper.java (original) +++ sling/trunk/tooling/ide/eclipse-sightly-core/src/org/apache/sling/ide/eclipse/sightly/SightlyFacetHelper.java Tue Oct 13 12:10:23 2015 @@ -16,32 +16,15 @@ */ package org.apache.sling.ide.eclipse.sightly; +import org.apache.sling.ide.eclipse.core.facet.FacetHelper; import org.eclipse.core.resources.IProject; -import org.eclipse.wst.common.project.facet.core.IFacetedProject; -import org.eclipse.wst.common.project.facet.core.IProjectFacet; -import org.eclipse.wst.common.project.facet.core.ProjectFacetsManager; - -public class FacetHelper { +public class SightlyFacetHelper { private static final String SIGHTLY_FACET = "sightly"; public static boolean hasSightlyFacet(IProject project) { - return containsFacet(project, SIGHTLY_FACET); - } - - // TODO - copied from eclipse-core/.../ProjectHelper - private static boolean containsFacet(IProject project, String facetId) { - // deleted modules can trigger a publish call without having an attached project - if (project == null) { - return false; - } - IFacetedProject facetedProject = (IFacetedProject) project.getAdapter(IFacetedProject.class); - if (facetedProject==null ) { - return false; - } - IProjectFacet facet = ProjectFacetsManager.getProjectFacet(facetId); - return facetedProject.hasProjectFacet(facet); + return FacetHelper.containsFacet(project, SIGHTLY_FACET); } } Modified: sling/trunk/tooling/ide/eclipse-sightly-core/src/org/apache/sling/ide/eclipse/sightly/internal/Validator.java URL: http://svn.apache.org/viewvc/sling/trunk/tooling/ide/eclipse-sightly-core/src/org/apache/sling/ide/eclipse/sightly/internal/Validator.java?rev=1708361&r1=1708360&r2=1708361&view=diff ============================================================================== --- sling/trunk/tooling/ide/eclipse-sightly-core/src/org/apache/sling/ide/eclipse/sightly/internal/Validator.java (original) +++ sling/trunk/tooling/ide/eclipse-sightly-core/src/org/apache/sling/ide/eclipse/sightly/internal/Validator.java Tue Oct 13 12:10:23 2015 @@ -16,7 +16,7 @@ */ package org.apache.sling.ide.eclipse.sightly.internal; -import org.apache.sling.ide.eclipse.sightly.FacetHelper; +import org.apache.sling.ide.eclipse.sightly.SightlyFacetHelper; import org.apache.sling.ide.eclipse.sightly.validation.ValidatorReporter; import org.eclipse.core.resources.IFile; import org.eclipse.wst.html.core.internal.validation.HTMLValidationReporter; @@ -30,7 +30,7 @@ public class Validator extends HTMLValid @Override protected HTMLValidationReporter getReporter(IReporter reporter, IFile file, IDOMModel model) { - if ( FacetHelper.hasSightlyFacet(file.getProject() )) { + if ( SightlyFacetHelper.hasSightlyFacet(file.getProject() )) { return new ValidatorReporter(this, reporter, file, model); } Modified: sling/trunk/tooling/ide/eclipse-sightly-ui/src/org/apache/sling/ide/eclipse/sightly/ui/internal/ProposalComputer.java URL: http://svn.apache.org/viewvc/sling/trunk/tooling/ide/eclipse-sightly-ui/src/org/apache/sling/ide/eclipse/sightly/ui/internal/ProposalComputer.java?rev=1708361&r1=1708360&r2=1708361&view=diff ============================================================================== --- sling/trunk/tooling/ide/eclipse-sightly-ui/src/org/apache/sling/ide/eclipse/sightly/ui/internal/ProposalComputer.java (original) +++ sling/trunk/tooling/ide/eclipse-sightly-ui/src/org/apache/sling/ide/eclipse/sightly/ui/internal/ProposalComputer.java Tue Oct 13 12:10:23 2015 @@ -16,7 +16,7 @@ */ package org.apache.sling.ide.eclipse.sightly.ui.internal; -import org.apache.sling.ide.eclipse.sightly.FacetHelper; +import org.apache.sling.ide.eclipse.sightly.SightlyFacetHelper; import org.apache.sling.ide.eclipse.sightly.model.Attribute; import org.apache.sling.ide.eclipse.sightly.model.ModelElements; import org.apache.sling.ide.eclipse.sightly.model.ProposalDescription; @@ -84,7 +84,7 @@ public class ProposalComputer extends De IFile file = getFile(element.getModel()); - return FacetHelper.hasSightlyFacet(file.getProject()); + return SightlyFacetHelper.hasSightlyFacet(file.getProject()); } public static final IFile getFile(IStructuredModel model) {