Skip to main content
summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorspingel2008-08-15 15:50:59 -0400
committerspingel2008-08-15 15:50:59 -0400
commit4ee54166e8ef750bcf05e0425500bf4299c8149a (patch)
treedfbb91ab80704cd1d02b2058738dc6bc51d3eacd
parentf7a0decd17827c154cfddf9936bd863f681dffbc (diff)
downloadorg.eclipse.mylyn.tasks-4ee54166e8ef750bcf05e0425500bf4299c8149a.tar.gz
org.eclipse.mylyn.tasks-4ee54166e8ef750bcf05e0425500bf4299c8149a.tar.xz
org.eclipse.mylyn.tasks-4ee54166e8ef750bcf05e0425500bf4299c8149a.zip
NEW - bug 244017: Hyperlinking support for Trac should handle disabled (escaped) links.
https://bugs.eclipse.org/bugs/show_bug.cgi?id=244017
-rw-r--r--org.eclipse.mylyn.trac.tests/META-INF/MANIFEST.MF3
-rw-r--r--org.eclipse.mylyn.trac.tests/src/org/eclipse/mylyn/internal/trac/ui/TracHyperlinkUtilStandaloneTest.java62
-rw-r--r--org.eclipse.mylyn.trac.ui/src/org/eclipse/mylyn/internal/trac/ui/TracHyperlinkUtil.java4
3 files changed, 66 insertions, 3 deletions
diff --git a/org.eclipse.mylyn.trac.tests/META-INF/MANIFEST.MF b/org.eclipse.mylyn.trac.tests/META-INF/MANIFEST.MF
index 2cdb21e0b..58a79c872 100644
--- a/org.eclipse.mylyn.trac.tests/META-INF/MANIFEST.MF
+++ b/org.eclipse.mylyn.trac.tests/META-INF/MANIFEST.MF
@@ -16,7 +16,8 @@ Require-Bundle: org.apache.xmlrpc;bundle-version="3.0.0",
org.eclipse.mylyn.trac.ui,
org.eclipse.mylyn.trac.core,
org.eclipse.mylyn.commons.net
-Export-Package: org.eclipse.mylyn.trac.tests;x-internal:=true,
+Export-Package: org.eclipse.mylyn.internal.trac.ui;x-internal:=true,
+ org.eclipse.mylyn.trac.tests;x-internal:=true,
org.eclipse.mylyn.trac.tests.client;x-internal:=true,
org.eclipse.mylyn.trac.tests.support;x-internal:=true
Bundle-RequiredExecutionEnvironment: J2SE-1.5
diff --git a/org.eclipse.mylyn.trac.tests/src/org/eclipse/mylyn/internal/trac/ui/TracHyperlinkUtilStandaloneTest.java b/org.eclipse.mylyn.trac.tests/src/org/eclipse/mylyn/internal/trac/ui/TracHyperlinkUtilStandaloneTest.java
new file mode 100644
index 000000000..5da93d304
--- /dev/null
+++ b/org.eclipse.mylyn.trac.tests/src/org/eclipse/mylyn/internal/trac/ui/TracHyperlinkUtilStandaloneTest.java
@@ -0,0 +1,62 @@
+/*******************************************************************************
+ * Copyright (c) 2004, 2007 Mylyn project committers 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
+ * http://www.eclipse.org/legal/epl-v10.html
+ *******************************************************************************/
+
+package org.eclipse.mylyn.internal.trac.ui;
+
+import java.util.regex.Matcher;
+
+import junit.framework.TestCase;
+
+/**
+ * @author David Green
+ */
+public class TracHyperlinkUtilStandaloneTest extends TestCase {
+
+ public void testWikiPattern2SinglePositiveMatch() {
+ Matcher matcher = TracHyperlinkUtil.wikiPattern2.matcher("a HyperLink there");
+ assertTrue(matcher.find());
+ assertEquals(matcher.group(0), "HyperLink");
+ assertFalse(matcher.find());
+ }
+
+ public void testWikiPattern2MultiplePositiveMatch() {
+ Matcher matcher = TracHyperlinkUtil.wikiPattern2.matcher("a HyperLink there and ThereIsAnother");
+ assertTrue(matcher.find());
+ assertEquals(matcher.group(0), "HyperLink");
+ assertTrue(matcher.find());
+ assertEquals(matcher.group(0), "ThereIsAnother");
+ assertFalse(matcher.find());
+ }
+
+ public void testWikiPattern2SingleNegativeMatch() {
+ Matcher matcher = TracHyperlinkUtil.wikiPattern2.matcher("no !HyperLink there");
+ assertFalse(matcher.find());
+ }
+
+ public void testWikiPattern2SinglePositiveMatchAtStartOfLine() {
+ Matcher matcher = TracHyperlinkUtil.wikiPattern2.matcher("HyperLink there");
+ assertTrue(matcher.find());
+ assertEquals(matcher.group(0), "HyperLink");
+ assertFalse(matcher.find());
+ }
+
+ public void testWikiPattern2SingleNegativeMatchAtStartOfLine() {
+ Matcher matcher = TracHyperlinkUtil.wikiPattern2.matcher("!HyperLink there");
+ assertFalse(matcher.find());
+ }
+
+ public void testWikiPattern2MixedPositiveNegativeMatch() {
+ Matcher matcher = TracHyperlinkUtil.wikiPattern2.matcher("a HyperLink there and ThereIsAnother but !NotHere");
+ assertTrue(matcher.find());
+ assertEquals(matcher.group(0), "HyperLink");
+ assertTrue(matcher.find());
+ assertEquals(matcher.group(0), "ThereIsAnother");
+ assertFalse(matcher.find());
+ }
+
+}
diff --git a/org.eclipse.mylyn.trac.ui/src/org/eclipse/mylyn/internal/trac/ui/TracHyperlinkUtil.java b/org.eclipse.mylyn.trac.ui/src/org/eclipse/mylyn/internal/trac/ui/TracHyperlinkUtil.java
index 629a85011..a8c3883ca 100644
--- a/org.eclipse.mylyn.trac.ui/src/org/eclipse/mylyn/internal/trac/ui/TracHyperlinkUtil.java
+++ b/org.eclipse.mylyn.trac.ui/src/org/eclipse/mylyn/internal/trac/ui/TracHyperlinkUtil.java
@@ -42,7 +42,7 @@ public class TracHyperlinkUtil {
static Pattern changesetPattern1 = Pattern.compile("(r|changeset:)(\\d+)(/\\w+)?");
- static Pattern changesetPattern2 = Pattern.compile("(?<![!])\\[(\\d+)(/\\w+)?\\]");
+ static Pattern changesetPattern2 = Pattern.compile("(?<!!)\\[(\\d+)(/\\w+)?\\]");
static Pattern revisionLogPattern1 = Pattern.compile("r(\\d+):(\\d+)");
@@ -56,7 +56,7 @@ public class TracHyperlinkUtil {
static Pattern wikiPattern1 = Pattern.compile("wiki:(\\w+)");
- static Pattern wikiPattern2 = Pattern.compile("(?<![!])[A-Z][a-z0-9]+[A-Z]\\w*");
+ static Pattern wikiPattern2 = Pattern.compile("(?<!!)[A-Z][a-z0-9]+[A-Z]\\w*");
static Pattern milestonePattern = Pattern.compile("milestone:([\\w\\.]+)");

Back to the top