Search in sources :

Example 6 with StylesheetModel

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

the class CallTemplateContentAssistRequest method getCompletionProposals.

/**
 * (non-Javadoc)
 * @see org.eclipse.wst.xml.ui.internal.contentassist.ContentAssistRequest#getCompletionProposals()
 */
@Override
public ArrayList<ICompletionProposal> getCompletionProposals() {
    proposals.clear();
    IFile editorFile = ResourcesPlugin.getWorkspace().getRoot().getFile(new Path(getLocation()));
    StylesheetModel model = XSLCore.getInstance().getStylesheet(editorFile);
    List<Template> templates = model.getTemplates();
    for (Template template : templates) {
        XSLAttribute attribute = template.getAttribute(ATTR_NAME);
        if (attribute != null) {
            String proposalInfo = getAdditionalInfo(template);
            CustomCompletionProposal proposal = new CustomCompletionProposal(attribute.getValue(), getStartOffset() + 1, 0, attribute.getValue().length(), XSLPluginImageHelper.getInstance().getImage(XSLPluginImages.IMG_TEMPLATE), attribute.getValue(), null, proposalInfo, 0);
            addProposal(proposal);
        }
    }
    return getAllCompletionProposals();
}
Also used : Path(org.eclipse.core.runtime.Path) IFile(org.eclipse.core.resources.IFile) XSLAttribute(org.eclipse.wst.xsl.core.model.XSLAttribute) CustomCompletionProposal(org.eclipse.wst.sse.ui.internal.contentassist.CustomCompletionProposal) StylesheetModel(org.eclipse.wst.xsl.core.model.StylesheetModel) Template(org.eclipse.wst.xsl.core.model.Template)

Example 7 with StylesheetModel

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

the class TemplateModeAttributeContentAssist method getCompletionProposals.

/**
 * The main method that returns an array of proposals. Returns the available
 * modes that have been defined in the {@link StylesheetModel}.  If no proposals
 * are found it returns a NULL value.
 * @return ICompletionPropsal[]
 * @see org.eclipse.wst.xml.ui.internal.contentassist.ContentAssistRequest#getCompletionProposals()
 */
@Override
public ArrayList<ICompletionProposal> getCompletionProposals() {
    proposals.clear();
    StylesheetModel model = getStylesheetModel();
    addModeProposals(model);
    return getAllCompletionProposals();
}
Also used : StylesheetModel(org.eclipse.wst.xsl.core.model.StylesheetModel)

Example 8 with StylesheetModel

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

the class XSLCore method buildStylesheet.

/**
 * Completely rebuild the source file from its DOM
 *
 * @param file
 * @return the stylesheet model, or null if it could not be created.
 * @since 1.0
 */
public synchronized StylesheetModel buildStylesheet(IFile file) {
    Stylesheet stylesheet = StylesheetBuilder.getInstance().getStylesheet(file, true);
    if (stylesheet == null)
        return null;
    StylesheetModel stylesheetComposed = new StylesheetModel(stylesheet);
    stylesheetsComposed.put(file, stylesheetComposed);
    stylesheetComposed.fix();
    return stylesheetComposed;
}
Also used : StylesheetModel(org.eclipse.wst.xsl.core.model.StylesheetModel) Stylesheet(org.eclipse.wst.xsl.core.model.Stylesheet)

Example 9 with StylesheetModel

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

the class Validator method validate.

@Override
public ValidationResult validate(IResource resource, int kind, ValidationState state, IProgressMonitor monitor) {
    ValidationResult res = super.validate(resource, kind, state, monitor);
    if (resource.getType() == IResource.FILE) {
        StylesheetModel stylesheet = XSLCore.getInstance().getStylesheet((IFile) resource);
        IFile[] dependencies = stylesheet.getFileDependencies().toArray(new IFile[0]);
        res.setDependsOn(dependencies);
    }
    return res;
}
Also used : IFile(org.eclipse.core.resources.IFile) ValidationResult(org.eclipse.wst.validation.ValidationResult) StylesheetModel(org.eclipse.wst.xsl.core.model.StylesheetModel)

Example 10 with StylesheetModel

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

the class AbstractValidationTest method validate.

/**
 * Validate the file
 *
 * @param file
 * @return
 * @throws CoreException
 * @throws XPathExpressionException
 * @throws IOException
 */
protected XSLValidationReport validate(IFile file) throws CoreException, XPathExpressionException, IOException {
    XSLValidationReport report = new XSLValidationReport(file.getLocationURI().toString());
    XSLValidator.getInstance().validate(file, report, true);
    StylesheetModel model = XSLCore.getInstance().getStylesheet(file);
    assertFalse("Stylesheet model is null", model == null);
    Map<Integer, String> expectedErrors = calculateErrorsAndWarnings(file);
    validateErrors(model, report, expectedErrors);
    return report;
}
Also used : XSLValidationReport(org.eclipse.wst.xsl.core.internal.validation.XSLValidationReport) StylesheetModel(org.eclipse.wst.xsl.core.model.StylesheetModel)

Aggregations

StylesheetModel (org.eclipse.wst.xsl.core.model.StylesheetModel)13 IFile (org.eclipse.core.resources.IFile)5 Template (org.eclipse.wst.xsl.core.model.Template)4 Path (org.eclipse.core.runtime.Path)2 IHyperlink (org.eclipse.jface.text.hyperlink.IHyperlink)2 CustomCompletionProposal (org.eclipse.wst.sse.ui.internal.contentassist.CustomCompletionProposal)2 ValidationResult (org.eclipse.wst.validation.ValidationResult)2 XSLValidationReport (org.eclipse.wst.xsl.core.internal.validation.XSLValidationReport)2 XSLAttribute (org.eclipse.wst.xsl.core.model.XSLAttribute)2 HashMap (java.util.HashMap)1 Iterator (java.util.Iterator)1 Map (java.util.Map)1 Position (org.eclipse.jface.text.Position)1 Annotation (org.eclipse.jface.text.source.Annotation)1 IAnnotationModelExtension (org.eclipse.jface.text.source.IAnnotationModelExtension)1 ValidatorMessage (org.eclipse.wst.validation.ValidatorMessage)1 IDOMAttr (org.eclipse.wst.xml.core.internal.provisional.document.IDOMAttr)1 IDOMNode (org.eclipse.wst.xml.core.internal.provisional.document.IDOMNode)1 ValidationMessage (org.eclipse.wst.xml.core.internal.validation.core.ValidationMessage)1 ValidationReport (org.eclipse.wst.xml.core.internal.validation.core.ValidationReport)1