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));
}
}
}
}
}
}
}
}
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;
}
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;
}
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();
}
Aggregations