391723: stack trace block misses special case of synthetic proxy class Modify matcher for fully qualified class name to match names such as "$Proxy10" Change-Id: Ie892f9049dffcc8006d784df1e16f738b1b04f3e Task-Url: https://bugs.eclipse.org/bugs/show_bug.cgi?id=391723
diff --git a/org.eclipse.mylyn.wikitext.core/src/org/eclipse/mylyn/wikitext/core/parser/markup/block/JavaStackTraceBlock.java b/org.eclipse.mylyn.wikitext.core/src/org/eclipse/mylyn/wikitext/core/parser/markup/block/JavaStackTraceBlock.java index ce8014e..fb14e42 100644 --- a/org.eclipse.mylyn.wikitext.core/src/org/eclipse/mylyn/wikitext/core/parser/markup/block/JavaStackTraceBlock.java +++ b/org.eclipse.mylyn.wikitext.core/src/org/eclipse/mylyn/wikitext/core/parser/markup/block/JavaStackTraceBlock.java
@@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2009, 2010 David Green and others. + * Copyright (c) 2009, 2012 David Green and others. * All rights reserved. This program and the accompanying materials * are made available under the terms of the Eclipse Public License v1.0 * which accompanies this distribution, and is available at @@ -35,7 +35,7 @@ private static final String CLASS_PART = "[A-Za-z][a-zA-Z0-9_$]*"; //$NON-NLS-1$ - private static final String FQN_PART = PACKAGE_PART + "(\\." + PACKAGE_PART + ")*\\." + CLASS_PART; //$NON-NLS-1$ //$NON-NLS-2$ + private static final String FQN_PART = "((" + PACKAGE_PART + "(\\." + PACKAGE_PART + ")*\\." + CLASS_PART + ")|(\\$Proxy\\d+))"; //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$ private static final Pattern STACK_TRACE_PATTERN = Pattern.compile("\\s*((" + "((Caused by:\\s+)|(at\\s+))?" //$NON-NLS-1$//$NON-NLS-2$ + FQN_PART + "((:\\s+\\w.*)|(\\.((\\<(?:cl)?init\\>)|([a-zA-Z0-9_$]+))\\(.*?\\)))?" //$NON-NLS-1$
diff --git a/org.eclipse.mylyn.wikitext.tests/src/org/eclipse/mylyn/wikitext/tests/TestUtil.java b/org.eclipse.mylyn.wikitext.tests/src/org/eclipse/mylyn/wikitext/tests/TestUtil.java index 5b741ac..c4799aa 100644 --- a/org.eclipse.mylyn.wikitext.tests/src/org/eclipse/mylyn/wikitext/tests/TestUtil.java +++ b/org.eclipse.mylyn.wikitext.tests/src/org/eclipse/mylyn/wikitext/tests/TestUtil.java
@@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2009, 2010 David Green and others. + * Copyright (c) 2009, 2012 David Green and others. * All rights reserved. This program and the accompanying materials * are made available under the terms of the Eclipse Public License v1.0 * which accompanies this distribution, and is available at @@ -11,6 +11,9 @@ package org.eclipse.mylyn.wikitext.tests; +import java.util.regex.Matcher; +import java.util.regex.Pattern; + public class TestUtil { private static final boolean useSystemOutput = !Boolean.getBoolean("org.eclipse.mylyn.wikitext.tests.disableOutput"); @@ -24,4 +27,13 @@ System.out.println(message); } } + + public static String tagFragment(String tagName, String html) { + Pattern pattern = Pattern.compile("<" + tagName + ".*?>.*?</" + tagName + ">", Pattern.DOTALL); + Matcher matcher = pattern.matcher(html); + if (!matcher.find()) { + return null; + } + return matcher.group(); + } }
diff --git a/org.eclipse.mylyn.wikitext.tests/src/org/eclipse/mylyn/wikitext/textile/core/BugzillaTextileLanguageTest.java b/org.eclipse.mylyn.wikitext.tests/src/org/eclipse/mylyn/wikitext/textile/core/BugzillaTextileLanguageTest.java index 672b2fd..476d8c7 100644 --- a/org.eclipse.mylyn.wikitext.tests/src/org/eclipse/mylyn/wikitext/textile/core/BugzillaTextileLanguageTest.java +++ b/org.eclipse.mylyn.wikitext.tests/src/org/eclipse/mylyn/wikitext/textile/core/BugzillaTextileLanguageTest.java
@@ -19,14 +19,12 @@ import org.eclipse.mylyn.wikitext.core.parser.markup.MarkupLanguageConfiguration; import org.eclipse.mylyn.wikitext.core.parser.markup.block.JavaStackTraceBlock; import org.eclipse.mylyn.wikitext.tests.EclipseRuntimeRequired; -import org.eclipse.mylyn.wikitext.tests.HeadRequired; import org.eclipse.mylyn.wikitext.tests.TestUtil; /** * @author David Green */ @EclipseRuntimeRequired -@HeadRequired public class BugzillaTextileLanguageTest extends TestCase { private MarkupParser parser; @@ -166,6 +164,20 @@ assertTrue(html.contains("<pre class=\"javaStackTrace\">java.io.EOFException\nat java.io.DataInputStream.readInt(Unknown Source)\nat org.eclipse.jdt.internal.core.JavaModelManager.loadNonChainingJarsCache(JavaModelManager.java:2843)\nat org.eclipse.jdt.internal.core.JavaModelManager.<init>(JavaModelManager.java:1477)\nat org.eclipse.jdt.internal.core.JavaModelManager.<clinit>(JavaModelManager.java:1012)\nat org.eclipse.jdt.core.JavaCore.start(JavaCore.java:4965)\nat org.eclipse.osgi.framework.internal.core.BundleContextImpl$1.run(BundleContextImpl.java:783)\nat java.security.AccessController.doPrivileged(Native Method)\n</pre>")); } + public void testJavaStackTraceDetection_bug391723() { + String markup = "java.lang.IllegalStateException: message\n" + // + " at com.foo.Bar.baz(Bar.java:199)\n" + // + " at $Proxy40.findProcessArea(Unknown Source)"; + + String html = parser.parseToHtml(markup); + + TestUtil.println(html); + + assertEquals("<body><pre class=\"javaStackTrace\">java.lang.IllegalStateException: message\n" + + " at com.foo.Bar.baz(Bar.java:199)\n" + " at $Proxy40.findProcessArea(Unknown Source)\n" + + "</pre></body>", TestUtil.tagFragment("body", html)); + } + public void testEclipseErrorDetailsBlock() { String html = parser.parseToHtml("text\n-- Error Details --\ndetail line 1\n\nno detail"); TestUtil.println(html);