Bug 560686: [SourceEditor] Make PathCompletionComputor more flexible
(allow direct parsing/decoding via .getPrefix)

Change-Id: Iab58a0b392bdb07dd6f372fe04232886731963a3
diff --git a/ltk/org.eclipse.statet.ltk.ui/src/org/eclipse/statet/ltk/ui/sourceediting/assist/PathCompletionComputor.java b/ltk/org.eclipse.statet.ltk.ui/src/org/eclipse/statet/ltk/ui/sourceediting/assist/PathCompletionComputor.java
index f0700a1..d5ef25d 100644
--- a/ltk/org.eclipse.statet.ltk.ui/src/org/eclipse/statet/ltk/ui/sourceediting/assist/PathCompletionComputor.java
+++ b/ltk/org.eclipse.statet.ltk.ui/src/org/eclipse/statet/ltk/ui/sourceediting/assist/PathCompletionComputor.java
@@ -253,13 +253,13 @@
 			final AssistProposalCollector proposals, final IProgressMonitor monitor) {
 		try {
 			final int offset= context.getInvocationOffset();
-			final TextRegion contentRange= getContentRange(context, mode);
-			if (contentRange == null) {
+			final TextRegion contentRange= getContentRegion(context, mode);
+			if (contentRange == null
+					|| offset < contentRange.getStartOffset() || offset > contentRange.getEndOffset()) {
 				return;
 			}
 			
-			String prefix= checkPrefix(context.getSourceViewer().getDocument().get(
-					contentRange.getStartOffset(), offset - contentRange.getStartOffset() ));
+			String prefix= getPrefix(context, contentRange, offset);
 			
 			if (prefix == null) {
 				return;
@@ -357,11 +357,21 @@
 	}
 	
 	
+	protected @Nullable String getPrefix(final AssistInvocationContext context,
+			final TextRegion contentRegion, final int offset)
+			throws BadLocationException {
+		return checkPrefix(context.getSourceViewer().getDocument().get(
+				contentRegion.getStartOffset(), offset - contentRegion.getStartOffset() ));
+	}
+	
 	/**
 	 * @param prefix to check
 	 * @return the prefix, if valid, otherwise <code>null</code>
 	 */
-	protected @Nullable String checkPrefix(final String prefix) {
+	protected @Nullable String checkPrefix(final @Nullable String prefix) {
+		if (prefix == null) {
+			return null;
+		}
 		final char[] breakingChars= "\n\r+<>|?*\"".toCharArray(); //$NON-NLS-1$
 		for (int i= 0; i < breakingChars.length; i++) {
 			if (prefix.indexOf(breakingChars[i]) >= 0) {
@@ -427,7 +437,7 @@
 	}
 	
 	
-	protected abstract @Nullable TextRegion getContentRange(AssistInvocationContext context, int mode)
+	protected abstract @Nullable TextRegion getContentRegion(AssistInvocationContext context, int mode)
 			throws BadLocationException;
 	
 	protected @Nullable IPath getRelativeBasePath() {