Search in sources :

Example 1 with PropertyGroup

use of org.eclipse.jst.jsp.core.internal.contenttype.DeploymentDescriptorPropertyCache.PropertyGroup in project webtools.sourceediting by eclipse.

the class JSPTranslator method translatePreludes.

private void translatePreludes() {
    fProcessIncludes = false;
    IPath modelpath = getModelPath();
    if (modelpath != null) {
        PropertyGroup[] propertyGroups = DeploymentDescriptorPropertyCache.getInstance().getPropertyGroups(modelpath);
        for (int j = 0; j < propertyGroups.length; j++) {
            IPath[] preludes = propertyGroups[j].getIncludePrelude();
            for (int i = 0; i < preludes.length; i++) {
                if (!getIncludes().contains(preludes[i].toString()) && !preludes[i].equals(modelpath)) {
                    getIncludes().push(preludes[i]);
                    JSPIncludeRegionHelper helper = new JSPIncludeRegionHelper(this, true);
                    helper.parse(preludes[i].toString());
                    getIncludes().pop();
                }
            }
        }
    }
    fProcessIncludes = true;
}
Also used : PropertyGroup(org.eclipse.jst.jsp.core.internal.contenttype.DeploymentDescriptorPropertyCache.PropertyGroup) IPath(org.eclipse.core.runtime.IPath) IExtensionPoint(org.eclipse.core.runtime.IExtensionPoint)

Example 2 with PropertyGroup

use of org.eclipse.jst.jsp.core.internal.contenttype.DeploymentDescriptorPropertyCache.PropertyGroup in project webtools.sourceediting by eclipse.

the class TLDCMDocumentManager method handlePreludes.

void handlePreludes() {
    IStructuredDocumentRegion anchor = new ZeroStructuredDocumentRegion(null, -1);
    fProcessIncludes = false;
    IPath currentPath = getCurrentParserPath();
    if (currentPath != null) {
        PropertyGroup[] propertyGroups = DeploymentDescriptorPropertyCache.getInstance().getPropertyGroups(currentPath);
        for (int k = 0; k < propertyGroups.length; k++) {
            IPath[] preludes = propertyGroups[k].getIncludePrelude();
            for (int i = 0; i < preludes.length; i++) {
                if (!getIncludes().contains(preludes[i]) && !preludes[i].equals(currentPath)) {
                    getIncludes().push(preludes[i]);
                    if (getParser() != null) {
                        IncludeHelper includeHelper = new IncludeHelper(anchor, getParser());
                        includeHelper.parse(preludes[i]);
                        List references = includeHelper.taglibReferences;
                        fTLDCMReferencesMap.put(preludes[i], references);
                        if (getParser() instanceof JSPCapableParser) {
                            for (int j = 0; j < references.size(); j++) {
                                TLDCMDocumentReference reference = (TLDCMDocumentReference) references.get(j);
                                // $NON-NLS-1$
                                ((JSPCapableParser) getParser()).addNestablePrefix(new TagMarker(reference.prefix + ":"));
                            }
                        }
                    } else
                        // $NON-NLS-1$ //$NON-NLS-2$
                        Logger.log(Logger.WARNING, "Warning: parser text was requested by " + getClass().getName() + " but none was available; taglib support disabled");
                    getIncludes().pop();
                }
            }
        }
    }
    fProcessIncludes = true;
}
Also used : IStructuredDocumentRegion(org.eclipse.wst.sse.core.internal.provisional.text.IStructuredDocumentRegion) PropertyGroup(org.eclipse.jst.jsp.core.internal.contenttype.DeploymentDescriptorPropertyCache.PropertyGroup) IPath(org.eclipse.core.runtime.IPath) List(java.util.List) ITextRegionList(org.eclipse.wst.sse.core.internal.provisional.text.ITextRegionList) ArrayList(java.util.ArrayList) JSPCapableParser(org.eclipse.wst.sse.core.internal.ltk.parser.JSPCapableParser) TagMarker(org.eclipse.wst.sse.core.internal.ltk.parser.TagMarker) ZeroStructuredDocumentRegion(org.eclipse.jst.jsp.core.internal.util.ZeroStructuredDocumentRegion)

Example 3 with PropertyGroup

use of org.eclipse.jst.jsp.core.internal.contenttype.DeploymentDescriptorPropertyCache.PropertyGroup in project webtools.sourceediting by eclipse.

the class JSPActionValidator method isElIgnored.

/**
 * Determines if EL should be ignored. Checks
 * <ol>
 *  <li>JSP version</li>
 * 	<li>Page directive isELIgnored</li>
 *  <li>Deployment descriptor's el-ignored</li>
 * </ol>
 * @return true if EL should be ignored, false otherwise. If the JSP version is < 2.0, EL is ignored by default
 */
private boolean isElIgnored(IPath path, IStructuredModel model) {
    if (DeploymentDescriptorPropertyCache.getInstance().getJSPVersion(path) < 2.0f)
        return true;
    PageDirectiveAdapter pdAdapter = ((PageDirectiveAdapter) (((IDOMModel) model).getDocument().getAdapterFor(PageDirectiveAdapter.class)));
    if (pdAdapter == null) {
        // double-check the factory (although there just might not be a page directive in the file)
        if (model.getFactoryRegistry().getFactoryFor(PageDirectiveAdapter.class) == null) {
            model.getFactoryRegistry().addFactory(new PageDirectiveAdapterFactory());
            pdAdapter = ((PageDirectiveAdapter) (((IDOMModel) model).getDocument().getAdapterFor(PageDirectiveAdapter.class)));
        }
    }
    if (pdAdapter != null) {
        String directiveIsELIgnored = pdAdapter.getElIgnored();
        // isELIgnored directive found
        if (directiveIsELIgnored != null)
            return Boolean.valueOf(directiveIsELIgnored).booleanValue();
    }
    // Check the deployment descriptor for el-ignored
    PropertyGroup[] groups = DeploymentDescriptorPropertyCache.getInstance().getPropertyGroups(path);
    if (groups.length > 0)
        return groups[0].isELignored();
    // JSP version >= 2.0 defaults to evaluating EL
    return false;
}
Also used : PropertyGroup(org.eclipse.jst.jsp.core.internal.contenttype.DeploymentDescriptorPropertyCache.PropertyGroup) IDOMModel(org.eclipse.wst.xml.core.internal.provisional.document.IDOMModel) PageDirectiveAdapterFactory(org.eclipse.jst.jsp.core.internal.document.PageDirectiveAdapterFactory) PageDirectiveAdapter(org.eclipse.jst.jsp.core.internal.document.PageDirectiveAdapter)

Example 4 with PropertyGroup

use of org.eclipse.jst.jsp.core.internal.contenttype.DeploymentDescriptorPropertyCache.PropertyGroup in project webtools.sourceediting by eclipse.

the class JSPBatchValidator method validate.

public ValidationResult validate(final IResource resource, int kind, ValidationState state, IProgressMonitor monitor) {
    if (resource.getType() != IResource.FILE)
        return null;
    if (!shouldValidate((IFile) resource))
        return null;
    final ValidationResult result = new ValidationResult();
    final IReporter reporter = result.getReporter(monitor);
    if (result.getDependsOn() != null) {
        fDependsOn = new HashSet(Arrays.asList(result.getDependsOn()));
    } else {
        fDependsOn = new HashSet();
    }
    // add web.xml as a dependency
    addDependsOn(DeploymentDescriptorPropertyCache.getInstance().getWebXML(resource.getFullPath()));
    // List relevant JSP 2.0 preludes/codas as dependencies
    IWorkspaceRoot workspaceRoot = ResourcesPlugin.getWorkspace().getRoot();
    PropertyGroup[] propertyGroups = DeploymentDescriptorPropertyCache.getInstance().getPropertyGroups(resource.getFullPath());
    for (int j = 0; j < propertyGroups.length; j++) {
        IPath[] preludes = propertyGroups[j].getIncludePrelude();
        for (int i = 0; i < preludes.length; i++) {
            addDependsOn(workspaceRoot.getFile(preludes[i]));
        }
        IPath[] codas = propertyGroups[j].getIncludeCoda();
        for (int i = 0; i < codas.length; i++) {
            addDependsOn(workspaceRoot.getFile(codas[i]));
        }
    }
    IWorkspaceRunnable validationRunnable = new IWorkspaceRunnable() {

        public void run(IProgressMonitor monitor) throws CoreException {
            if (fragmentCheck((IFile) resource)) {
                validateFile((IFile) resource, reporter);
            }
            IResource[] resources = (IResource[]) fDependsOn.toArray(new IResource[fDependsOn.size()]);
            result.setDependsOn(resources);
            fDependsOn.clear();
        }
    };
    Job currentJob = Job.getJobManager().currentJob();
    ISchedulingRule rule = null;
    if (currentJob != null) {
        rule = currentJob.getRule();
    }
    try {
        JavaCore.run(validationRunnable, rule, new NullProgressMonitor());
    } catch (CoreException e) {
        Logger.logException(e);
    }
    return result;
}
Also used : IWorkspaceRunnable(org.eclipse.core.resources.IWorkspaceRunnable) NullProgressMonitor(org.eclipse.core.runtime.NullProgressMonitor) IFile(org.eclipse.core.resources.IFile) IReporter(org.eclipse.wst.validation.internal.provisional.core.IReporter) PropertyGroup(org.eclipse.jst.jsp.core.internal.contenttype.DeploymentDescriptorPropertyCache.PropertyGroup) IPath(org.eclipse.core.runtime.IPath) ValidationResult(org.eclipse.wst.validation.ValidationResult) ISchedulingRule(org.eclipse.core.runtime.jobs.ISchedulingRule) IProgressMonitor(org.eclipse.core.runtime.IProgressMonitor) IWorkspaceRoot(org.eclipse.core.resources.IWorkspaceRoot) CoreException(org.eclipse.core.runtime.CoreException) IValidatorJob(org.eclipse.wst.validation.internal.provisional.core.IValidatorJob) Job(org.eclipse.core.runtime.jobs.Job) IResource(org.eclipse.core.resources.IResource) HashSet(java.util.HashSet)

Example 5 with PropertyGroup

use of org.eclipse.jst.jsp.core.internal.contenttype.DeploymentDescriptorPropertyCache.PropertyGroup in project webtools.sourceediting by eclipse.

the class JSPTranslator method translateCodas.

private void translateCodas() {
    fProcessIncludes = false;
    IPath modelpath = getModelPath();
    if (modelpath != null) {
        PropertyGroup[] propertyGroups = DeploymentDescriptorPropertyCache.getInstance().getPropertyGroups(modelpath);
        for (int j = 0; j < propertyGroups.length; j++) {
            IPath[] codas = propertyGroups[j].getIncludeCoda();
            for (int i = 0; i < codas.length; i++) {
                if (!getIncludes().contains(codas[i].toString()) && !codas[i].equals(modelpath)) {
                    getIncludes().push(codas[i]);
                    JSPIncludeRegionHelper helper = new JSPIncludeRegionHelper(this, true);
                    helper.parse(codas[i].toString());
                    getIncludes().pop();
                }
            }
        }
    }
    fProcessIncludes = true;
}
Also used : PropertyGroup(org.eclipse.jst.jsp.core.internal.contenttype.DeploymentDescriptorPropertyCache.PropertyGroup) IPath(org.eclipse.core.runtime.IPath) IExtensionPoint(org.eclipse.core.runtime.IExtensionPoint)

Aggregations

PropertyGroup (org.eclipse.jst.jsp.core.internal.contenttype.DeploymentDescriptorPropertyCache.PropertyGroup)5 IPath (org.eclipse.core.runtime.IPath)4 IExtensionPoint (org.eclipse.core.runtime.IExtensionPoint)2 ArrayList (java.util.ArrayList)1 HashSet (java.util.HashSet)1 List (java.util.List)1 IFile (org.eclipse.core.resources.IFile)1 IResource (org.eclipse.core.resources.IResource)1 IWorkspaceRoot (org.eclipse.core.resources.IWorkspaceRoot)1 IWorkspaceRunnable (org.eclipse.core.resources.IWorkspaceRunnable)1 CoreException (org.eclipse.core.runtime.CoreException)1 IProgressMonitor (org.eclipse.core.runtime.IProgressMonitor)1 NullProgressMonitor (org.eclipse.core.runtime.NullProgressMonitor)1 ISchedulingRule (org.eclipse.core.runtime.jobs.ISchedulingRule)1 Job (org.eclipse.core.runtime.jobs.Job)1 PageDirectiveAdapter (org.eclipse.jst.jsp.core.internal.document.PageDirectiveAdapter)1 PageDirectiveAdapterFactory (org.eclipse.jst.jsp.core.internal.document.PageDirectiveAdapterFactory)1 ZeroStructuredDocumentRegion (org.eclipse.jst.jsp.core.internal.util.ZeroStructuredDocumentRegion)1 JSPCapableParser (org.eclipse.wst.sse.core.internal.ltk.parser.JSPCapableParser)1 TagMarker (org.eclipse.wst.sse.core.internal.ltk.parser.TagMarker)1