本文整理汇总了Java中org.eclipse.jface.internal.text.html.HTMLPrinter.convertToHTMLContentWithWhitespace方法的典型用法代码示例。如果您正苦于以下问题:Java HTMLPrinter.convertToHTMLContentWithWhitespace方法的具体用法?Java HTMLPrinter.convertToHTMLContentWithWhitespace怎么用?Java HTMLPrinter.convertToHTMLContentWithWhitespace使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.eclipse.jface.internal.text.html.HTMLPrinter
的用法示例。
在下文中一共展示了HTMLPrinter.convertToHTMLContentWithWhitespace方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: getInfoText
import org.eclipse.jface.internal.text.html.HTMLPrinter; //导入方法依赖的package包/类
private static String getInfoText(IJavaElement element, ITypeRoot editorInputElement, IRegion hoverRegion, boolean allowImage) {
long flags= getHeaderFlags(element);
StringBuffer label= new StringBuffer(JavaElementLinks.getElementLabel(element, flags));
if (element.getElementType() == IJavaElement.FIELD) {
String constantValue= getConstantValue((IField) element, editorInputElement, hoverRegion);
if (constantValue != null) {
constantValue= HTMLPrinter.convertToHTMLContentWithWhitespace(constantValue);
IJavaProject javaProject= element.getJavaProject();
label.append(getFormattedAssignmentOperator(javaProject));
label.append(constantValue);
}
}
// if (element.getElementType() == IJavaElement.METHOD) {
// IMethod method= (IMethod)element;
// //TODO: add default value for annotation type members, see https://bugs.eclipse.org/bugs/show_bug.cgi?id=249016
// }
return getImageAndLabel(element, allowImage, label.toString());
}
示例2: getInfoText
import org.eclipse.jface.internal.text.html.HTMLPrinter; //导入方法依赖的package包/类
private static String getInfoText(IJavaElement element, ITypeRoot editorInputElement, IRegion hoverRegion, boolean allowImage) {
long flags= getHeaderFlags(element);
StringBuffer label= new StringBuffer(JavaElementLinks.getElementLabel(element, flags));
if (element.getElementType() == IJavaElement.FIELD) {
String constantValue= getConstantValue((IField) element, editorInputElement, hoverRegion);
if (constantValue != null) {
constantValue= HTMLPrinter.convertToHTMLContentWithWhitespace(constantValue);
IJavaProject javaProject= element.getJavaProject();
if (JavaCore.INSERT.equals(javaProject.getOption(DefaultCodeFormatterConstants.FORMATTER_INSERT_SPACE_BEFORE_ASSIGNMENT_OPERATOR, true)))
label.append(' ');
label.append('=');
if (JavaCore.INSERT.equals(javaProject.getOption(DefaultCodeFormatterConstants.FORMATTER_INSERT_SPACE_AFTER_ASSIGNMENT_OPERATOR, true)))
label.append(' ');
label.append(constantValue);
}
}
// if (element.getElementType() == IJavaElement.METHOD) {
// IMethod method= (IMethod)element;
// //TODO: add default value for annotation type members, see https://bugs.eclipse.org/bugs/show_bug.cgi?id=249016
// }
String imageName= null;
if (allowImage) {
URL imageUrl= JavaPlugin.getDefault().getImagesOnFSRegistry().getImageURL(element);
if (imageUrl != null) {
imageName= imageUrl.toExternalForm();
}
}
StringBuffer buf= new StringBuffer();
addImageAndLabel(buf, element, imageName, 16, 16, label.toString(), 20, 2);
return buf.toString();
}
示例3: handleConstantValue
import org.eclipse.jface.internal.text.html.HTMLPrinter; //导入方法依赖的package包/类
private boolean handleConstantValue(IField field, boolean link) throws JavaModelException {
String text= null;
ISourceRange nameRange= field.getNameRange();
if (SourceRange.isAvailable(nameRange)) {
CompilationUnit cuNode= SharedASTProvider.getAST(field.getTypeRoot(), SharedASTProvider.WAIT_ACTIVE_ONLY, null);
if (cuNode != null) {
ASTNode nameNode= NodeFinder.perform(cuNode, nameRange);
if (nameNode instanceof SimpleName) {
IBinding binding= ((SimpleName) nameNode).resolveBinding();
if (binding instanceof IVariableBinding) {
IVariableBinding variableBinding= (IVariableBinding) binding;
Object constantValue= variableBinding.getConstantValue();
if (constantValue != null) {
if (constantValue instanceof String) {
text= ASTNodes.getEscapedStringLiteral((String) constantValue);
} else {
text= constantValue.toString(); // Javadoc tool is even worse for chars...
}
}
}
}
}
}
if (text == null) {
Object constant= field.getConstant();
if (constant != null) {
text= constant.toString();
}
}
if (text != null) {
text= HTMLPrinter.convertToHTMLContentWithWhitespace(text);
if (link) {
String uri;
try {
uri= JavaElementLinks.createURI(JavaElementLinks.JAVADOC_SCHEME, field);
fBuf.append(JavaElementLinks.createLink(uri, text));
} catch (URISyntaxException e) {
JavaPlugin.log(e);
return false;
}
} else {
handleText(text);
}
return true;
}
return false;
}