IDEA-66333 Quick documentation lookup on mouse hover

Corrected links appliance in case of partial head match
This commit is contained in:
Denis.Zhdanov
2012-07-24 14:56:56 +04:00
parent 5a3327e431
commit a17fbd9b81
2 changed files with 23 additions and 1 deletions
@@ -191,6 +191,10 @@ public class DocPreviewUtil {
// We don't want to perform the replacement then.
continue;
}
if (end - i > 1 && i > 0 && !ALLOWED_LINK_SEPARATORS.contains(text.charAt(i - 1))) {
// Similar situation but targets head match: from = 'TextRange', text = 'getTextRange()'.
continue;
}
text.replace(i, end, replaceTo);
int diff = replaceTo.length() - replaceFrom.length();
for (int j = 0; j < readOnlyChanges.size(); j++) {
@@ -147,7 +147,7 @@ Qname'''
}
@Test
void substrings() {
void tailSubstrings() {
def header = '''\
PsiResolveHelperImpl
public static com.intellij.openapi.util.Pair&lt;com.intellij.psi.PsiType, com.intellij.psi.ConstraintType&gt; getSubstitutionForTypeParameterConstraint (com.intellij.psi.PsiTypeParameter typeParam, com.intellij.psi.PsiType param, com.intellij.psi.PsiType arg, boolean isContraVariantPosition, com.intellij.pom.java.LanguageLevel languageLevel)'''
@@ -164,4 +164,22 @@ public static com.intellij.openapi.util.Pair&lt;com.intellij.psi.PsiType, com.in
assertEquals(expected, DocPreviewUtil.buildPreview(header, null, fullText))
}
@Test
void headSubstrings() {
def header = '''\
ASTNode
com.intellij.openapi.util.TextRange getTextRange ()'''
def fullText = '''\
<html><head> <style type="text/css"> #error { background-color: #eeeeee; margin-bottom: 10px; } p { margin: 5px 0; } </style></head><body><small><b><a href="psi_element://com.intellij.lang.ASTNode"><code>com.intellij.lang.ASTNode</code></a></b></small><PRE><a href="psi_element://com.intellij.openapi.util.TextRange"><code>TextRange</code></a>&nbsp;<b>getTextRange</b>()</PRE>
Returns the text range (a combination of starting offset in the document and length) for this node.
<DD><DL><DT><b>Returns:</b><DD>the text range.</DD></DL></DD></body></html>'''
def expected = '''\
<a href="psi_element://com.intellij.lang.ASTNode">ASTNode</a><br/><a href="psi_element://com.intellij.openapi.util.TextRange">TextRange</a> getTextRange ()'''
assertEquals(expected, DocPreviewUtil.buildPreview(header, null, fullText))
}
}