Search in sources :

Example 6 with Parameter

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

the class XSLValidator method checkParameters.

private void checkParameters(XSLValidationReport report, Function function) throws MaxErrorsExceededException {
    List<Parameter> parameters = new ArrayList<Parameter>(function.getParameters());
    // reverse the parameters order for checking - for duplicate parameters
    // the first one is valid
    Collections.reverse(parameters);
    Set<Parameter> duplicateParameters = new HashSet<Parameter>();
    // check parameters
    for (Parameter param : parameters) {
        if (param.getName() == null) {
            // name is required
            createMarker(report, param, getPreference(ValidationPreferences.NAME_ATTRIBUTE_MISSING), Messages.XSLValidator_14);
        } else if (param.getName().trim().length() == 0) {
            // name value is
            // required
            createMarker(report, param, getPreference(ValidationPreferences.NAME_ATTRIBUTE_EMPTY), Messages.XSLValidator_15);
        } else if (duplicateParameters.contains(param)) {
            // the parameter
            continue;
        } else {
            // check a parameter with the same name does not exist
            for (Parameter checkParam : parameters) {
                if (param != checkParam) {
                    if (param.getName().equals(checkParam.getName())) {
                        duplicateParameters.add(checkParam);
                        createMarker(report, param, getPreference(ValidationPreferences.DUPLICATE_PARAMETER), Messages.XSLValidator_16);
                    }
                }
            }
        }
    }
}
Also used : ArrayList(java.util.ArrayList) Parameter(org.eclipse.wst.xsl.core.model.Parameter) HashSet(java.util.HashSet)

Aggregations

Parameter (org.eclipse.wst.xsl.core.model.Parameter)6 CallTemplate (org.eclipse.wst.xsl.core.model.CallTemplate)3 Template (org.eclipse.wst.xsl.core.model.Template)3 Node (org.w3c.dom.Node)3 ArrayList (java.util.ArrayList)2 HashSet (java.util.HashSet)2 NodeList (org.w3c.dom.NodeList)2 IHyperlink (org.eclipse.jface.text.hyperlink.IHyperlink)1 IDOMAttr (org.eclipse.wst.xml.core.internal.provisional.document.IDOMAttr)1 IDOMNode (org.eclipse.wst.xml.core.internal.provisional.document.IDOMNode)1 Function (org.eclipse.wst.xsl.core.model.Function)1 StylesheetModel (org.eclipse.wst.xsl.core.model.StylesheetModel)1 XSLAttribute (org.eclipse.wst.xsl.core.model.XSLAttribute)1 Attr (org.w3c.dom.Attr)1