Author: pkluegl Date: Fri Mar 1 17:20:41 2013 New Revision: 1451652 URL: http://svn.apache.org/r1451652 Log: no jira - added check on null (file ext - autocomplete) and on out-of-bounds (PlainTextAnnotator)
Modified: uima/sandbox/textmarker/trunk/textmarker-core/src/main/java/org/apache/uima/textmarker/engine/PlainTextAnnotator.java uima/sandbox/textmarker/trunk/textmarker-ep-ide/src/main/java/org/apache/uima/textmarker/ide/core/codeassist/TextMarkerCompletionEngine.java Modified: uima/sandbox/textmarker/trunk/textmarker-core/src/main/java/org/apache/uima/textmarker/engine/PlainTextAnnotator.java URL: http://svn.apache.org/viewvc/uima/sandbox/textmarker/trunk/textmarker-core/src/main/java/org/apache/uima/textmarker/engine/PlainTextAnnotator.java?rev=1451652&r1=1451651&r2=1451652&view=diff ============================================================================== --- uima/sandbox/textmarker/trunk/textmarker-core/src/main/java/org/apache/uima/textmarker/engine/PlainTextAnnotator.java (original) +++ uima/sandbox/textmarker/trunk/textmarker-core/src/main/java/org/apache/uima/textmarker/engine/PlainTextAnnotator.java Fri Mar 1 17:20:41 2013 @@ -67,11 +67,12 @@ public class PlainTextAnnotator extends boolean emptyLine = "".equals(eachLine); int offsetAfterLine = offsetTillNow + eachLine.length(); int nlLength = 1; - String substring = documentText.substring(offsetAfterLine, offsetAfterLine + 2); - if (substring.equals("\r\n")) { - nlLength = 2; + if (documentText.length() >= offsetAfterLine + 2) { + String substring = documentText.substring(offsetAfterLine, offsetAfterLine + 2); + if (substring.equals("\r\n")) { + nlLength = 2; + } } - if (lastWasEmpty && !wsLine) { paragraphBegin = offsetTillNow; } @@ -92,7 +93,7 @@ public class PlainTextAnnotator extends AnnotationFS newParaFS = cas.createAnnotation(paragraphType, paragraphBegin, lastLineEnd); cas.addFsToIndexes(newParaFS); } - if(wsLine) { + if (wsLine) { lastWasEmpty = true; } offsetTillNow = offsetTillNow + eachLine.length() + nlLength; Modified: uima/sandbox/textmarker/trunk/textmarker-ep-ide/src/main/java/org/apache/uima/textmarker/ide/core/codeassist/TextMarkerCompletionEngine.java URL: http://svn.apache.org/viewvc/uima/sandbox/textmarker/trunk/textmarker-ep-ide/src/main/java/org/apache/uima/textmarker/ide/core/codeassist/TextMarkerCompletionEngine.java?rev=1451652&r1=1451651&r2=1451652&view=diff ============================================================================== --- uima/sandbox/textmarker/trunk/textmarker-ep-ide/src/main/java/org/apache/uima/textmarker/ide/core/codeassist/TextMarkerCompletionEngine.java (original) +++ uima/sandbox/textmarker/trunk/textmarker-ep-ide/src/main/java/org/apache/uima/textmarker/ide/core/codeassist/TextMarkerCompletionEngine.java Fri Mar 1 17:20:41 2013 @@ -285,7 +285,8 @@ public class TextMarkerCompletionEngine result.addAll(collectTypeSystems(folder2, newPrefix)); } else if (iResource instanceof IFile) { IFile file = (IFile) iResource; - if (file.getFileExtension().equals("xml")) { + String fileExtension = file.getFileExtension(); + if (fileExtension != null && fileExtension.equals("xml")) { File f = new File(file.getLocation().toPortableString()); if (f.exists()) { try {