use correct length

This commit is contained in:
liana.bakradze
2015-09-03 15:25:23 +03:00
parent 639c8d8b6b
commit 73593d0d35
2 changed files with 6 additions and 2 deletions
@@ -94,12 +94,12 @@ public class EduUtils {
fileWindows = taskDir.createChildData(taskFile, name);
printWriter = new PrintWriter(new FileOutputStream(fileWindows.getPath()));
for (AnswerPlaceholder answerPlaceholder : taskFile.getAnswerPlaceholders()) {
if (!answerPlaceholder.isValid(document)) {
int length = useLength ? answerPlaceholder.getLength() : answerPlaceholder.getPossibleAnswerLength();
if (!answerPlaceholder.isValid(document, length)) {
printWriter.println("#educational_plugin_window = ");
continue;
}
int start = answerPlaceholder.getRealStartOffset(document);
int length = useLength ? answerPlaceholder.getLength() : answerPlaceholder.getPossibleAnswerLength();
final String windowDescription = document.getText(new TextRange(start, start + length));
printWriter.println("#educational_plugin_window = " + windowDescription);
}
@@ -116,6 +116,10 @@ public class AnswerPlaceholder {
}
public boolean isValid(@NotNull final Document document) {
return isValid(document, length);
}
public boolean isValid(@NotNull final Document document, int length) {
boolean isLineValid = line < document.getLineCount() && line >= 0;
if (!isLineValid) return false;
boolean isStartValid = start >= 0 && start < document.getLineEndOffset(line);