* @param fileName - name of the file.
* @param fileText - data file text.
* @throws IOException
*/
protected static void configureFromFileText(@NonNls final String fileName, @NonNls String fileText) throws IOException {
final Document fakeDocument = new DocumentImpl(fileText);
int caretIndex = fileText.indexOf(CARET_MARKER);
int selStartIndex = fileText.indexOf(SELECTION_START_MARKER);
int selEndIndex = fileText.indexOf(SELECTION_END_MARKER);
final RangeMarker caretMarker = caretIndex >= 0 ? fakeDocument.createRangeMarker(caretIndex, caretIndex) : null;
final RangeMarker selStartMarker = selStartIndex >= 0 ? fakeDocument.createRangeMarker(selStartIndex, selStartIndex) : null;
final RangeMarker selEndMarker = selEndIndex >= 0 ? fakeDocument.createRangeMarker(selEndIndex, selEndIndex) : null;
if (caretMarker != null) {
fakeDocument.deleteString(caretMarker.getStartOffset(), caretMarker.getStartOffset() + CARET_MARKER.length());
}
if (selStartMarker != null) {
fakeDocument.deleteString(selStartMarker.getStartOffset(),
selStartMarker.getStartOffset() + SELECTION_START_MARKER.length());
}
if (selEndMarker != null) {
fakeDocument.deleteString(selEndMarker.getStartOffset(),
selEndMarker.getStartOffset() + SELECTION_END_MARKER.length());
}
String newFileText = fakeDocument.getText();
setupFileEditorAndDocument(fileName, newFileText);
setupCaret(caretMarker, newFileText);
setupSelection(selStartMarker, selEndMarker);
setupEditorForInjectedLanguage();
}