Search in sources :

Example 1 with CallTemplate

use of org.eclipse.wst.xsl.core.model.CallTemplate in project webtools.sourceediting by eclipse.

the class XSLValidator method checkCallTemplates.

private void checkCallTemplates(StylesheetModel stylesheetComposed, XSLValidationReport report) throws MaxErrorsExceededException {
    for (CallTemplate calledTemplate : stylesheetComposed.getStylesheet().getCalledTemplates()) {
        if (calledTemplate.getName() != null) {
            // get the list of templates that might be being called by this
            // template call
            List<Template> templateList = stylesheetComposed.getTemplatesByName(calledTemplate.getName());
            if (templateList.size() == 0) {
                Object[] messageArgs = { calledTemplate.getName() };
                createMarker(report, calledTemplate.getAttribute("name"), getPreference(ValidationPreferences.CALL_TEMPLATES), // $NON-NLS-1$
                MessageFormat.format(Messages.XSLValidator_18, messageArgs));
            } else {
                Template namedTemplate = templateList.get(0);
                for (Parameter calledTemplateParam : calledTemplate.getParameters()) {
                    boolean found = false;
                    for (Parameter namedTemplateParam : namedTemplate.getParameters()) {
                        if (calledTemplateParam.getName().equals(namedTemplateParam.getName())) {
                            found = true;
                            if (!namedTemplateParam.isValue() && !calledTemplateParam.isValue()) {
                                Object[] messageArgs = { calledTemplateParam.getName() };
                                createMarker(report, calledTemplateParam, getPreference(ValidationPreferences.EMPTY_PARAM), MessageFormat.format(Messages.XSLValidator_20, messageArgs));
                            }
                            break;
                        }
                    }
                    if (!found) {
                        Object[] messageArgs = { calledTemplateParam.getName() };
                        createMarker(report, calledTemplateParam.getAttribute("name"), getPreference(ValidationPreferences.MISSING_PARAM), // $NON-NLS-1$
                        MessageFormat.format(Messages.XSLValidator_22, messageArgs));
                    }
                }
                if (getPreference(ValidationPreferences.MISSING_PARAM) > IMarker.SEVERITY_INFO) {
                    for (Parameter namedTemplateParam : namedTemplate.getParameters()) {
                        if (!namedTemplateParam.isValue()) {
                            boolean found = false;
                            for (Parameter calledTemplateParam : calledTemplate.getParameters()) {
                                if (calledTemplateParam.getName().equals(namedTemplateParam.getName())) {
                                    found = true;
                                    break;
                                }
                            }
                            if (!found) {
                                Object[] messageArgs = { namedTemplateParam.getName() };
                                createMarker(report, calledTemplate, getPreference(ValidationPreferences.MISSING_PARAM), MessageFormat.format(Messages.XSLValidator_3, messageArgs));
                            }
                        }
                    }
                }
            }
        }
    }
}
Also used : Parameter(org.eclipse.wst.xsl.core.model.Parameter) CallTemplate(org.eclipse.wst.xsl.core.model.CallTemplate) CallTemplate(org.eclipse.wst.xsl.core.model.CallTemplate) Template(org.eclipse.wst.xsl.core.model.Template)

Example 2 with CallTemplate

use of org.eclipse.wst.xsl.core.model.CallTemplate in project webtools.sourceediting by eclipse.

the class XSLElementFactory method createCallTemplate.

public XSLElement createCallTemplate() {
    CallTemplate currentCallTemplate = new CallTemplate(stylesheetParserData.getStylesheet());
    stylesheetParserData.getCallTemplates().push(currentCallTemplate);
    stylesheetParserData.getStylesheet().addCalledTemplate(currentCallTemplate);
    return currentCallTemplate;
}
Also used : CallTemplate(org.eclipse.wst.xsl.core.model.CallTemplate)

Example 3 with CallTemplate

use of org.eclipse.wst.xsl.core.model.CallTemplate in project webtools.sourceediting by eclipse.

the class XSLElementFactory method createWithParamParm.

public XSLElement createWithParamParm() {
    Parameter param = new Parameter(stylesheetParserData.getStylesheet());
    // determine whether param has a value
    NodeList childNodes = element.getChildNodes();
    for (int i = 0; i < childNodes.getLength(); i++) {
        Node childNode = childNodes.item(i);
        if (childNode.getNodeType() != Node.ATTRIBUTE_NODE) {
            param.setValue(true);
            break;
        }
    }
    // get the previous call-template
    CallTemplate currentCallTemplate = stylesheetParserData.getCallTemplates().peek();
    currentCallTemplate.addParameter(param);
    return param;
}
Also used : NodeList(org.w3c.dom.NodeList) Node(org.w3c.dom.Node) Parameter(org.eclipse.wst.xsl.core.model.Parameter) CallTemplate(org.eclipse.wst.xsl.core.model.CallTemplate)

Example 4 with CallTemplate

use of org.eclipse.wst.xsl.core.model.CallTemplate in project webtools.sourceediting by eclipse.

the class TemplateNameAttributeContentAssist method getCompletionProposals.

/* (non-Javadoc)
	 * @see org.eclipse.wst.xsl.ui.internal.contentassist.AbstractXSLContentAssistRequest#getCompletionProposals()
	 */
@Override
public ArrayList<ICompletionProposal> getCompletionProposals() {
    proposals.clear();
    StylesheetModel model = getStylesheetModel();
    List<CallTemplate> templates = model.getCallTemplates();
    for (CallTemplate template : templates) {
        CustomCompletionProposal proposal = createProposal(template);
        addUniqueProposal(proposal);
    }
    return getAllCompletionProposals();
}
Also used : CustomCompletionProposal(org.eclipse.wst.sse.ui.internal.contentassist.CustomCompletionProposal) StylesheetModel(org.eclipse.wst.xsl.core.model.StylesheetModel) CallTemplate(org.eclipse.wst.xsl.core.model.CallTemplate)

Aggregations

CallTemplate (org.eclipse.wst.xsl.core.model.CallTemplate)4 Parameter (org.eclipse.wst.xsl.core.model.Parameter)2 CustomCompletionProposal (org.eclipse.wst.sse.ui.internal.contentassist.CustomCompletionProposal)1 StylesheetModel (org.eclipse.wst.xsl.core.model.StylesheetModel)1 Template (org.eclipse.wst.xsl.core.model.Template)1 Node (org.w3c.dom.Node)1 NodeList (org.w3c.dom.NodeList)1