Skip to main content
summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorSergey Prigogin2011-01-14 02:41:21 +0000
committerSergey Prigogin2011-01-14 02:41:21 +0000
commit1f8f493753882ac0a5ad06e5dd223e601da1c3aa (patch)
tree23efebd3cd8fd2ec9aea9663f6b898d75d3ac44d
parent75e050aa7f3f0e372cdb3a7e112136b15df4b142 (diff)
downloadorg.eclipse.cdt-1f8f493753882ac0a5ad06e5dd223e601da1c3aa.tar.gz
org.eclipse.cdt-1f8f493753882ac0a5ad06e5dd223e601da1c3aa.tar.xz
org.eclipse.cdt-1f8f493753882ac0a5ad06e5dd223e601da1c3aa.zip
Bug 333050 - Hyperlinks don't work inside macros
-rw-r--r--core/org.eclipse.cdt.ui.tests/ui/org/eclipse/cdt/ui/tests/text/HyperlinkTest.java10
-rw-r--r--core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/editor/CElementHyperlinkDetector.java13
2 files changed, 14 insertions, 9 deletions
diff --git a/core/org.eclipse.cdt.ui.tests/ui/org/eclipse/cdt/ui/tests/text/HyperlinkTest.java b/core/org.eclipse.cdt.ui.tests/ui/org/eclipse/cdt/ui/tests/text/HyperlinkTest.java
index 32eaf4cddaa..e9280526d5f 100644
--- a/core/org.eclipse.cdt.ui.tests/ui/org/eclipse/cdt/ui/tests/text/HyperlinkTest.java
+++ b/core/org.eclipse.cdt.ui.tests/ui/org/eclipse/cdt/ui/tests/text/HyperlinkTest.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2000, 2010 IBM Corporation and others.
+ * Copyright (c) 2000, 2011 IBM Corporation 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
@@ -160,8 +160,8 @@ public class HyperlinkTest extends TestCase {
assertNotHyperlink(CPP_CODE.indexOf("#define") + 1);
assertHyperlink(CPP_CODE.indexOf("SOMEMACRO"), CPP_CODE.indexOf("SOMEMACRO"), "SOMEMACRO".length());
// see bug 259015
-// assertNotHyperlink(CPP_CODE.indexOf("macro_token1") + 1);
-// assertNotHyperlink(CPP_CODE.indexOf("macro_token2") + 1);
+ assertHyperlink(CPP_CODE.indexOf("macro_token1"), CPP_CODE.indexOf("macro_token1"), "macro_token1".length());
+ assertHyperlink(CPP_CODE.indexOf("macro_token2"), CPP_CODE.indexOf("macro_token2"), "macro_token2".length());
// no hyperlinks for comments
assertNotHyperlink(CPP_CODE.indexOf("//") + 1);
@@ -214,8 +214,8 @@ public class HyperlinkTest extends TestCase {
assertNotHyperlink(CPP_CODE.indexOf("#define") + 1);
assertHyperlink(CPP_CODE.indexOf("SOMEMACRO"), CPP_CODE.indexOf("SOMEMACRO"), "SOMEMACRO".length());
// see bug 259015
-// assertNotHyperlink(CPP_CODE.indexOf("macro_token1") + 1);
-// assertNotHyperlink(CPP_CODE.indexOf("macro_token2") + 1);
+ assertHyperlink(CPP_CODE.indexOf("macro_token1"), CPP_CODE.indexOf("macro_token1"), "macro_token1".length());
+ assertHyperlink(CPP_CODE.indexOf("macro_token2"), CPP_CODE.indexOf("macro_token2"), "macro_token2".length());
// no hyperlinks for comments
assertNotHyperlink(CPP_CODE.indexOf("//") + 1);
diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/editor/CElementHyperlinkDetector.java b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/editor/CElementHyperlinkDetector.java
index c7fdc82727c..b6e7664dfb9 100644
--- a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/editor/CElementHyperlinkDetector.java
+++ b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/editor/CElementHyperlinkDetector.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2000, 2010 QNX Software Systems and others.
+ * Copyright (c) 2000, 2011 QNX Software Systems 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
@@ -96,15 +96,20 @@ public class CElementHyperlinkDetector extends AbstractHyperlinkDetector {
}
}
}
- if (linkLocation != null) {
- hyperlinkRegion[0] = new Region(linkLocation.getNodeOffset(), linkLocation.getNodeLength());
+ if (linkLocation == null) {
+ // Consider a fallback way of finding the hyperlink
+ // (see http://bugs.eclipse.org/bugs/show_bug.cgi?id=333050).
+ return Status.CANCEL_STATUS;
}
+
+ hyperlinkRegion[0] = new Region(linkLocation.getNodeOffset(), linkLocation.getNodeLength());
return Status.OK_STATUS;
}
});
if (status == Status.CANCEL_STATUS) {
- // AST is not available yet, try to compute the hyperlink without it.
+ // AST was not available yet or didn't help us to find the hyperlink, try to compute
+ // the hyperlink without it.
try {
// Check partition type.
String partitionType= TextUtilities.getContentType(document, ICPartitions.C_PARTITIONING, region.getOffset(), false);

Back to the top