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