Search in sources :

Example 1 with JSPDocumentLoader

use of org.eclipse.jst.jsp.core.internal.encoding.JSPDocumentLoader in project webtools.sourceediting by eclipse.

the class JSPCorePreferencesTest method testDelimiterPreferences.

/**
 * Tests line delimiter preferences by making sure document created
 * follows line delimiter preference.
 */
public void testDelimiterPreferences() {
    // check if content type preferences match
    String preferredDelimiter = ContentTypeEncodingPreferences.getPreferredNewLineDelimiter(ContentTypeIdForJSP.ContentTypeID_JSP);
    Preferences prefs = ContentBasedPreferenceGateway.getPreferences(ContentTypeIdForJSP.ContentTypeID_JSP);
    String gatewayDelimiter = prefs.get(CommonEncodingPreferenceNames.END_OF_LINE_CODE, null);
    assertEquals("ContentTypeEncodingPreferences and ContentBasedPreferenceGateway preferences do not match", gatewayDelimiter, preferredDelimiter);
    // set a particular line delimiter
    prefs.put(CommonEncodingPreferenceNames.END_OF_LINE_CODE, CommonEncodingPreferenceNames.LF);
    // create document
    JSPDocumentLoader loader = new JSPDocumentLoader();
    IEncodedDocument document = loader.createNewStructuredDocument();
    String documentDelimiter = document.getPreferredLineDelimiter();
    // verify delimiter in document matches preference
    assertEquals("Delimiter in document does not match preference", CommonEncodingPreferenceNames.STRING_LF, documentDelimiter);
    // return to original preference
    prefs.remove(CommonEncodingPreferenceNames.END_OF_LINE_CODE);
}
Also used : ContentTypeEncodingPreferences(org.eclipse.wst.sse.core.internal.encoding.ContentTypeEncodingPreferences) Preferences(org.osgi.service.prefs.Preferences) IEclipsePreferences(org.eclipse.core.runtime.preferences.IEclipsePreferences) IEncodedDocument(org.eclipse.wst.sse.core.internal.provisional.document.IEncodedDocument) JSPDocumentLoader(org.eclipse.jst.jsp.core.internal.encoding.JSPDocumentLoader)

Example 2 with JSPDocumentLoader

use of org.eclipse.jst.jsp.core.internal.encoding.JSPDocumentLoader in project webtools.sourceediting by eclipse.

the class XMLJSPRegionHelper method forceParse.

public void forceParse() {
    String contents = fTextToParse;
    IStructuredDocument document = (IStructuredDocument) new JSPDocumentLoader().createNewStructuredDocument();
    if (contents != null && document != null) {
        // from outer class
        List blockMarkers = this.fTranslator.getBlockMarkers();
        // to this parser so parsing works correctly
        for (int i = 0; i < blockMarkers.size(); i++) {
            addBlockMarker((BlockMarker) blockMarkers.get(i));
        }
        reset(contents);
        document.set(contents);
        IStructuredDocumentRegion cursor = document.getFirstStructuredDocumentRegion();
        while (cursor != null) {
            nodeParsed(cursor);
            cursor = cursor.getNext();
        }
    }
}
Also used : IStructuredDocumentRegion(org.eclipse.wst.sse.core.internal.provisional.text.IStructuredDocumentRegion) IStructuredDocument(org.eclipse.wst.sse.core.internal.provisional.text.IStructuredDocument) ITextRegionList(org.eclipse.wst.sse.core.internal.provisional.text.ITextRegionList) List(java.util.List) JSPDocumentLoader(org.eclipse.jst.jsp.core.internal.encoding.JSPDocumentLoader)

Aggregations

JSPDocumentLoader (org.eclipse.jst.jsp.core.internal.encoding.JSPDocumentLoader)2 List (java.util.List)1 IEclipsePreferences (org.eclipse.core.runtime.preferences.IEclipsePreferences)1 ContentTypeEncodingPreferences (org.eclipse.wst.sse.core.internal.encoding.ContentTypeEncodingPreferences)1 IEncodedDocument (org.eclipse.wst.sse.core.internal.provisional.document.IEncodedDocument)1 IStructuredDocument (org.eclipse.wst.sse.core.internal.provisional.text.IStructuredDocument)1 IStructuredDocumentRegion (org.eclipse.wst.sse.core.internal.provisional.text.IStructuredDocumentRegion)1 ITextRegionList (org.eclipse.wst.sse.core.internal.provisional.text.ITextRegionList)1 Preferences (org.osgi.service.prefs.Preferences)1