mirror of
https://github.com/eclipse-cdt/cdt
synced 2025-07-23 00:45:28 +02:00
Bug 333050 - Hyperlinks don't work inside macros
This commit is contained in:
parent
9488ed0ba8
commit
3bf6639e4b
2 changed files with 12 additions and 7 deletions
|
@ -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);
|
||||
|
|
|
@ -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);
|
||||
|
|
Loading…
Add table
Reference in a new issue