本文整理汇总了Java中com.intellij.codeInsight.documentation.DocumentationManager.createHyperlink方法的典型用法代码示例。如果您正苦于以下问题:Java DocumentationManager.createHyperlink方法的具体用法?Java DocumentationManager.createHyperlink怎么用?Java DocumentationManager.createHyperlink使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类com.intellij.codeInsight.documentation.DocumentationManager
的用法示例。
在下文中一共展示了DocumentationManager.createHyperlink方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: getExternalDocInfoForElement
import com.intellij.codeInsight.documentation.DocumentationManager; //导入方法依赖的package包/类
@Override
@Nullable
public String getExternalDocInfoForElement(final String docURL, final PsiElement element) throws Exception {
String externalDoc = super.getExternalDocInfoForElement(docURL, element);
if (externalDoc != null) {
if (element instanceof PsiMethod) {
final String className = ApplicationManager.getApplication().runReadAction(
new NullableComputable<String>() {
@Override
@Nullable
public String compute() {
PsiClass aClass = ((PsiMethod)element).getContainingClass();
return aClass == null ? null : aClass.getQualifiedName();
}
}
);
Matcher matcher = ourMethodHeading.matcher(externalDoc);
final StringBuilder buffer = new StringBuilder();
DocumentationManager.createHyperlink(buffer, className, className, false);
//noinspection HardCodedStringLiteral
return matcher.replaceFirst("<H3>" + buffer.toString() + "</H3>");
}
}
return externalDoc;
}
示例2: getDocumentationForValue
import com.intellij.codeInsight.documentation.DocumentationManager; //导入方法依赖的package包/类
public String getDocumentationForValue(MetadataNode propertyNode, String value) {
StringBuilder builder =
new StringBuilder().append("<b>").append(propertyNode.getFullPath()).append("</b>");
if (type != null) {
StringBuilder buffer = new StringBuilder();
DocumentationManager
.createHyperlink(buffer, typeForDocumentationNavigation(type), type, false);
String typeInJavadocFormat = buffer.toString();
builder.append(" (").append(typeInJavadocFormat).append(")");
}
String trimmedValue = unescapeValue(value);
builder.append("<p>").append(trimmedValue).append("</p>");
Set<Suggestion> choices = getValueSuggestions(propertyNode, classLoader);
if (choices != null) {
choices.stream().filter(choice -> choice.getSuggestion().equals(trimmedValue)).findFirst()
.ifPresent(suggestion -> {
if (suggestion.getDescription() != null) {
builder.append("<p>").append(suggestion.getDescription()).append("</p>");
}
});
}
return builder.toString();
}
示例3: convertLink
import com.intellij.codeInsight.documentation.DocumentationManager; //导入方法依赖的package包/类
private static String convertLink(String javadoc, String tag) {
StringBuilder buffer = new StringBuilder();
int length = javadoc.length();
int start = 0;
while (true) {
int index = javadoc.indexOf(tag, start);
if (index == -1) {
buffer.append(javadoc.substring(start, length));
break;
}
else {
buffer.append(javadoc.substring(start, index));
int linkStart = index + tag.length();
int end = javadoc.indexOf('}', linkStart);
String linkValue = javadoc.substring(linkStart, end).trim();
String href;
String text;
int spaceIndex = linkValue.indexOf(' ');
if (spaceIndex != -1) {
href = linkValue.substring(0, spaceIndex);
text = linkValue.substring(spaceIndex + 1);
}
else {
href = text = linkValue;
}
text = text.replace('#', '.');
DocumentationManager.createHyperlink(buffer, href, text, true);
start = end + 1;
}
}
return buffer.toString();
}
示例4: appendHyperLinkToElement
import com.intellij.codeInsight.documentation.DocumentationManager; //导入方法依赖的package包/类
public static void appendHyperLinkToElement(@Nullable PsiElement element, String elementName, final StringBuilder buffer,
final String presentableName, final @Nullable String presentableFileName)
{
final PsiFile containingFile = element != null ? element.getContainingFile() : null;
String fileName = containingFile == null ? null : !JSResolveUtil.isPredefinedFile(containingFile) ? containingFile.getVirtualFile()
.getPresentableUrl() : containingFile.getViewProvider().getVirtualFile().getName();
DocumentationManager.createHyperlink(buffer, (fileName != null ? fileName + ":" : "") + elementName + (element != null ? ":" + element
.getTextOffset() : ""), presentableName + (presentableFileName != null ? " in " + presentableFileName : ""), true);
}
示例5: getExternalDocInfoForElement
import com.intellij.codeInsight.documentation.DocumentationManager; //导入方法依赖的package包/类
@Override
@Nullable
public String getExternalDocInfoForElement(final String docURL, final PsiElement element) throws Exception
{
String externalDoc = super.getExternalDocInfoForElement(docURL, element);
if(externalDoc != null)
{
if(element instanceof PsiMethod)
{
final String className = ApplicationManager.getApplication().runReadAction(new
NullableComputable<String>()
{
@Override
@Nullable
public String compute()
{
PsiClass aClass = ((PsiMethod) element).getContainingClass();
return aClass == null ? null : aClass.getQualifiedName();
}
});
Matcher matcher = ourMethodHeading.matcher(externalDoc);
final StringBuilder buffer = new StringBuilder();
DocumentationManager.createHyperlink(buffer, className, className, false);
//noinspection HardCodedStringLiteral
return matcher.replaceFirst("<H3>" + buffer.toString() + "</H3>");
}
}
return externalDoc;
}
示例6: getExternalDocInfoForElement
import com.intellij.codeInsight.documentation.DocumentationManager; //导入方法依赖的package包/类
@Override
@Nullable
public String getExternalDocInfoForElement(@NotNull String docURL, final PsiElement element) throws Exception {
String externalDoc = null;
myElement = element;
String builtInServer = "http://localhost:" + BuiltInServerOptions.getInstance().getEffectiveBuiltInServerPort() + "/" + myProject.getName() + "/";
if (docURL.startsWith(builtInServer)) {
int refPosition = docURL.lastIndexOf('#');
VirtualFile file = WebServerPathToFileManager.getInstance(myProject).findVirtualFile(
docURL.substring(builtInServer.length(), refPosition < builtInServer.length() ? docURL.length() : refPosition)
);
if (file != null) {
InputStreamReader reader = new InputStreamReader(file.getInputStream(), CharsetToolkit.UTF8_CHARSET);
StringBuilder result = new StringBuilder();
try {
doBuildFromStream(docURL, reader, result);
}
finally {
reader.close();
}
externalDoc = correctDocText(docURL, result);
}
}
if (externalDoc == null) {
externalDoc = super.getExternalDocInfoForElement(docURL, element);
}
if (externalDoc == null) {
return null;
}
if (element instanceof PsiMethod) {
final String className = ApplicationManager.getApplication().runReadAction(
new NullableComputable<String>() {
@Override
@Nullable
public String compute() {
PsiClass aClass = ((PsiMethod)element).getContainingClass();
return aClass == null ? null : aClass.getQualifiedName();
}
}
);
Matcher matcher = ourMethodHeading.matcher(externalDoc);
StringBuilder buffer = new StringBuilder("<h3>");
DocumentationManager.createHyperlink(buffer, className, className, false);
return matcher.replaceFirst(buffer.append("</h3>").toString());
}
return externalDoc;
}