Fixed bug 349933: [clipboard] Open from Clipboard throws StringIndexOutOfBoundsException for incomplete stacktrace
diff --git a/org.eclipse.jdt.debug.tests/tests/org/eclipse/jdt/debug/tests/ui/OpenFromClipboardTests.java b/org.eclipse.jdt.debug.tests/tests/org/eclipse/jdt/debug/tests/ui/OpenFromClipboardTests.java
index 63846fb..df68064 100644
--- a/org.eclipse.jdt.debug.tests/tests/org/eclipse/jdt/debug/tests/ui/OpenFromClipboardTests.java
+++ b/org.eclipse.jdt.debug.tests/tests/org/eclipse/jdt/debug/tests/ui/OpenFromClipboardTests.java
@@ -289,6 +289,16 @@
 		assertEquals(1, matches.size());
 	}
 
+	public void testStackTraceLine_7() throws Exception {
+		// https://bugs.eclipse.org/bugs/show_bug.cgi?id=349933#c2
+		String s = "getMatchingPattern ( OpenFromClipboardTests.java : 121 )";
+		assertEquals(STACK_TRACE_LINE, getMatachingPattern(s));
+
+		setupTypeTest("OpenFromClipboardTests");
+		List matches = getJavaElementMatches(s);
+		assertEquals(1, matches.size());
+	}
+
 	// method tests
 	private void setupMethodTest() throws JavaModelException {
 		IPackageFragment pack= fSourceFolder.createPackageFragment("p", false, null);
diff --git a/org.eclipse.jdt.debug.ui/ui/org/eclipse/jdt/internal/debug/ui/actions/OpenFromClipboardAction.java b/org.eclipse.jdt.debug.ui/ui/org/eclipse/jdt/internal/debug/ui/actions/OpenFromClipboardAction.java
index 44fd716..9aa3edd 100644
--- a/org.eclipse.jdt.debug.ui/ui/org/eclipse/jdt/internal/debug/ui/actions/OpenFromClipboardAction.java
+++ b/org.eclipse.jdt.debug.ui/ui/org/eclipse/jdt/internal/debug/ui/actions/OpenFromClipboardAction.java
@@ -86,12 +86,20 @@
 
 	/**
 	 * Pattern to match a qualified name e.g.
-	 * <code>org.eclipse.jdt.internal.debug.ui.actions.OpenFromClipboardAction</code>
+	 * <code>org.eclipse.jdt.internal.debug.ui.actions.OpenFromClipboardAction</code>, or match a
+	 * simple name e.g. <code>OpenFromClipboardAction</code>.
 	 */
 	private static final String QUALIFIED_NAME_PATTERN = "(" + SIMPLE_NAME_PATTERN //$NON-NLS-1$
 			+ "\\.)*" + SIMPLE_NAME_PATTERN; //$NON-NLS-1$
 
 	/**
+	 * Pattern to match a qualified name e.g.
+	 * <code>org.eclipse.jdt.internal.debug.ui.actions.OpenFromClipboardAction</code>.
+	 */
+	private static final String STRICT_QUALIFIED_NAME_PATTERN = "(" + SIMPLE_NAME_PATTERN //$NON-NLS-1$
+			+ "\\.)+" + SIMPLE_NAME_PATTERN; //$NON-NLS-1$
+
+	/**
 	 * Pattern to match whitespace characters.
 	 */
 	private static final String WS = "\\s*"; //$NON-NLS-1$
@@ -118,7 +126,7 @@
 	 * <code> at org.eclipse.core.runtime.Assert.isLegal(Assert.java:41)</code>
 	 */
 	private static final String STACK_TRACE_LINE_PATTERN = ".*\\(" //$NON-NLS-1$
-			+ WS + JAVA_FILE_LINE_PATTERN + WS + "\\).*"; //$NON-NLS-1$
+			+ WS + JAVA_FILE_LINE_PATTERN + WS + "\\)"; //$NON-NLS-1$
 
 	/**
 	 * Pattern to match a method e.g.
@@ -303,7 +311,7 @@
 			String lineNumber = typeLine.substring(index + 1, typeLine.length()).trim();
 			int line = (Integer.valueOf(lineNumber)).intValue();
 
-			Pattern pattern = Pattern.compile(QUALIFIED_NAME_PATTERN + WS + "\\("); //$NON-NLS-1$
+			Pattern pattern = Pattern.compile(STRICT_QUALIFIED_NAME_PATTERN + WS + "\\("); //$NON-NLS-1$
 			Matcher matcher = pattern.matcher(s);
 			if (matcher.find()) {
 				String qualifiedName = matcher.group();