String uri= JavaElementLinks.createURI(JavaElementLinks.JAVADOC_SCHEME, type); String name= type.getElementName(); addLink(buf, uri, name); String uri= JavaElementLinks.createURI(JavaElementLinks.JAVADOC_SCHEME, variable); String name= variable.getElementName(); addLink(buf, uri, name); addAnnotation(buf, element, annotationBinding); buf.append(JavaElementLabels.COMMA_STRING); addValue(buf, element, values[i]);
public static void addAnnotations(StringBuffer buf, IJavaElement element, ITypeRoot editorInputElement, IRegion hoverRegion) { try { if (element instanceof IAnnotatable) { String annotationString= getAnnotations(element, editorInputElement, hoverRegion); if (annotationString != null) { buf.append("<div style='margin-bottom: 5px;'>"); //$NON-NLS-1$ IPackageDeclaration[] packDecls= cu.getPackageDeclarations(); if (packDecls.length > 0) { addAnnotations(buf, packDecls[0], null, null); addAnnotations(buf, classFile.getType(), null, null);
public static String getHexConstantValue(Object constantValue) { if (constantValue instanceof Character) { String constantResult= '\'' + constantValue.toString() + '\''; char charValue= ((Character) constantValue).charValue(); String hexString= Integer.toHexString(charValue); StringBuffer hexResult= new StringBuffer("\\u"); //$NON-NLS-1$ for (int i= hexString.length(); i < 4; i++) { hexResult.append('0'); } hexResult.append(hexString); return formatWithHexValue(constantResult, hexResult.toString()); } else if (constantValue instanceof Byte) { int byteValue= ((Byte) constantValue).intValue() & 0xFF; return formatWithHexValue(constantValue, "0x" + Integer.toHexString(byteValue)); //$NON-NLS-1$ } else if (constantValue instanceof Short) { int shortValue= ((Short) constantValue).shortValue() & 0xFFFF; return formatWithHexValue(constantValue, "0x" + Integer.toHexString(shortValue)); //$NON-NLS-1$ } else if (constantValue instanceof Integer) { int intValue= ((Integer) constantValue).intValue(); return formatWithHexValue(constantValue, "0x" + Integer.toHexString(intValue)); //$NON-NLS-1$ } else if (constantValue instanceof Long) { long longValue= ((Long) constantValue).longValue(); return formatWithHexValue(constantValue, "0x" + Long.toHexString(longValue)); //$NON-NLS-1$ } else { return constantValue.toString(); } }
private static String getInfoText(IJavaElement element, ITypeRoot editorInputElement, IRegion hoverRegion, boolean allowImage) { long flags= getHeaderFlags(element); ASTNode node= haveSource ? getHoveredASTNode(editorInputElement, hoverRegion) : null; IBinding binding= getHoverBinding(element, node); String constantValue= getConstantValue((IField) element, editorInputElement, hoverRegion); if (constantValue != null) { constantValue= HTMLPrinter.convertToHTMLContentWithWhitespace(constantValue); return getImageAndLabel(element, allowImage, label.toString());
private static String getAnnotations(IJavaElement element, ITypeRoot editorInputElement, IRegion hoverRegion) throws URISyntaxException, JavaModelException { if (!(element instanceof IPackageFragment)) { if (!(element instanceof IAnnotatable)) return null; if (((IAnnotatable)element).getAnnotations().length == 0) return null; } IBinding binding= getHoveredNodeBinding(element, editorInputElement, hoverRegion); if (binding == null) return null; IAnnotationBinding[] annotations= binding.getAnnotations(); if (annotations.length == 0) return null; StringBuffer buf= new StringBuffer(); for (int i= 0; i < annotations.length; i++) { //TODO: skip annotations that don't have an @Documented annotation? addAnnotation(buf, annotations[i], true); buf.append("<br>"); //$NON-NLS-1$ } return buf.toString(); }
int leadingImageWidth= 0; elements= filterDuplicatePackages(elements); IJavaElement curr= elements[i]; if (curr instanceof IMember || curr.getElementType() == IJavaElement.LOCAL_VARIABLE) { String label= JavaElementLabels.getElementLabel(curr, getHeaderFlags(curr)); String link; try { HTMLPrinter.addSmallHeader(buffer, getInfoText(element, editorInputElement, hoverRegion, true)); buffer.append("<br>"); //$NON-NLS-1$ addAnnotations(buffer, element, editorInputElement, hoverRegion); Reader reader= null; try { HTMLPrinter.insertPageProlog(buffer, 0, JavadocHover.getStyleSheet()); if (base != null) { int endHeadIdx= buffer.indexOf("</head>"); //$NON-NLS-1$
ASTNode node= getHoveredASTNode(editorInputElement, hoverRegion); binding= resolveBinding(node); for (int i= 0; i < annotations.length; i++) { addAnnotation(buf, element, annotations[i]); buf.append("<br>"); //$NON-NLS-1$
IJavaElement curr= result[i]; if (curr instanceof IMember || curr.getElementType() == IJavaElement.LOCAL_VARIABLE) { HTMLPrinter.addBullet(buffer, getInfoText(curr)); hasContents= true; if (curr instanceof IMember) { IMember member= (IMember) curr; HTMLPrinter.addSmallHeader(buffer, getInfoText(member)); Reader reader; try { HTMLPrinter.addSmallHeader(buffer, getInfoText(curr)); hasContents= true; HTMLPrinter.insertPageProlog(buffer, 0, getStyleSheet()); HTMLPrinter.addPageEpilog(buffer); return buffer.toString();
private static void addAnnotation(StringBuffer buf, IJavaElement element, IAnnotationBinding annotation) throws URISyntaxException { IJavaElement javaElement= annotation.getAnnotationType().getJavaElement(); buf.append('@'); if (javaElement != null) { String uri= JavaElementLinks.createURI(JavaElementLinks.JAVADOC_SCHEME, javaElement); addLink(buf, uri, annotation.getName()); } else { buf.append(annotation.getName()); } IMemberValuePairBinding[] mvPairs= annotation.getDeclaredMemberValuePairs(); if (mvPairs.length > 0) { buf.append('('); for (int j= 0; j < mvPairs.length; j++) { if (j > 0) { buf.append(JavaElementLabels.COMMA_STRING); } IMemberValuePairBinding mvPair= mvPairs[j]; String memberURI= JavaElementLinks.createURI(JavaElementLinks.JAVADOC_SCHEME, mvPair.getMethodBinding().getJavaElement()); addLink(buf, memberURI, mvPair.getName()); buf.append('='); addValue(buf, element, mvPair.getValue()); } buf.append(')'); } }
IBinding binding= getHoveredNodeBinding(method, editorInputElement, hoverRegion); if (binding instanceof IMethodBinding) { Object value= ((IMethodBinding) binding).getDefaultValue(); StringBuffer buf= new StringBuffer(); try { addValue(buf, value, false); } catch (URISyntaxException e) {
ITypeRoot typeRoot= (ITypeRoot) ((IPackageDeclaration) curr).getParent(); Region hoverRegion= new Region(nameRange.getOffset(), nameRange.getLength()); JavadocHover.addAnnotations(buffer, typeRoot.getParent(), typeRoot, hoverRegion); JavadocHover.addAnnotations(buffer, curr, null, null); content= JavadocContentAccess2.getHTMLContent((IPackageFragment) curr); if (element instanceof IMethod) { try { defaultValue= JavadocHover.getAnnotationMemberDefaultValue((IMethod) element, typeRoot, hoverRegion); if (defaultValue != null) { defaultValue= HTMLPrinter.convertToHTMLContentWithWhitespace(defaultValue); JavadocHover.addAnnotations(buffer, curr, typeRoot, hoverRegion);
ITypeRoot typeRoot= (ITypeRoot) ((IPackageDeclaration) curr).getParent(); Region hoverRegion= new Region(nameRange.getOffset(), nameRange.getLength()); JavadocHover.addAnnotations(buffer, typeRoot.getParent(), typeRoot, hoverRegion); JavadocHover.addAnnotations(buffer, curr, null, null); content= JavadocContentAccess2.getHTMLContent((IPackageFragment) curr); JavadocHover.addAnnotations(buffer, curr, typeRoot, hoverRegion);
int leadingImageWidth= 0; elements= filterDuplicatePackages(elements); IJavaElement curr= elements[i]; if (curr instanceof IMember || curr.getElementType() == IJavaElement.LOCAL_VARIABLE) { String label= JavaElementLabels.getElementLabel(curr, getHeaderFlags(curr)); String link; try { HTMLPrinter.addSmallHeader(buffer, getInfoText(element, editorInputElement, hoverRegion, true)); buffer.append("<br>"); //$NON-NLS-1$ addAnnotations(buffer, element, editorInputElement, hoverRegion); Reader reader= null; try { RGB bgRGB= registry.getRGB("org.eclipse.jdt.ui.Javadoc.backgroundColor"); //$NON-NLS-1$ HTMLPrinter.insertPageProlog(buffer, 0, fgRGB, bgRGB, JavadocHover.getStyleSheet()); if (base != null) { int endHeadIdx= buffer.indexOf("</head>"); //$NON-NLS-1$
private static String getInfoText(IJavaElement element, ITypeRoot editorInputElement, IRegion hoverRegion, boolean allowImage) { long flags= getHeaderFlags(element); ASTNode node= haveSource ? getHoveredASTNode(editorInputElement, hoverRegion) : null; IBinding binding= getHoverBinding(element, node); String constantValue= getConstantValue((IField) element, editorInputElement, hoverRegion); if (constantValue != null) { constantValue= HTMLPrinter.convertToHTMLContentWithWhitespace(constantValue); String defaultValue; try { defaultValue= getAnnotationMemberDefaultValue((IMethod) element, editorInputElement, hoverRegion); } catch (JavaModelException e) { defaultValue= null; return getImageAndLabel(element, allowImage, label.toString());
private static void addAnnotation(StringBuffer buf, IAnnotationBinding annotation, boolean addLinks) throws URISyntaxException { IJavaElement javaElement= annotation.getAnnotationType().getJavaElement(); buf.append('@'); if (javaElement == null || !addLinks) { buf.append(annotation.getName()); } else { String uri= JavaElementLinks.createURI(JavaElementLinks.JAVADOC_SCHEME, javaElement); addLink(buf, uri, annotation.getName()); } IMemberValuePairBinding[] mvPairs= annotation.getDeclaredMemberValuePairs(); if (mvPairs.length > 0) { buf.append('('); for (int j= 0; j < mvPairs.length; j++) { if (j > 0) { buf.append(JavaElementLabels.COMMA_STRING); } IMemberValuePairBinding mvPair= mvPairs[j]; if (addLinks) { String memberURI= JavaElementLinks.createURI(JavaElementLinks.JAVADOC_SCHEME, mvPair.getMethodBinding().getJavaElement()); addLink(buf, memberURI, mvPair.getName()); } else { buf.append(mvPair.getName()); } buf.append('='); addValue(buf, mvPair.getValue(), addLinks); } buf.append(')'); } }
String uri= JavaElementLinks.createURI(JavaElementLinks.JAVADOC_SCHEME, type); String name= type.getElementName(); addLink(buf, uri, name); String uri= JavaElementLinks.createURI(JavaElementLinks.JAVADOC_SCHEME, variable); String name= variable.getElementName(); addLink(buf, uri, name); addAnnotation(buf, annotationBinding, addLinks); buf.append(JavaElementLabels.COMMA_STRING); addValue(buf, values[i], addLinks);
public static void addAnnotations(StringBuilder buf, IJavaElement element, ITypeRoot editorInputElement, IRegion hoverRegion) { try { if (element instanceof IAnnotatable) { String annotationString= getAnnotations(element, editorInputElement, hoverRegion); if (annotationString != null) { buf.append("<div style='margin-bottom: 5px;'>"); //$NON-NLS-1$ IPackageDeclaration[] packDecls= cu.getPackageDeclarations(); if (packDecls.length > 0) { addAnnotations(buf, packDecls[0], null, null); addAnnotations(buf, classFile.getType(), null, null);
public static String getHexConstantValue(Object constantValue) { if (constantValue instanceof Character) { String constantResult= '\'' + constantValue.toString() + '\''; char charValue= ((Character) constantValue).charValue(); String hexString= Integer.toHexString(charValue); StringBuffer hexResult= new StringBuffer("\\u"); //$NON-NLS-1$ for (int i= hexString.length(); i < 4; i++) { hexResult.append('0'); } hexResult.append(hexString); return formatWithHexValue(constantResult, hexResult.toString()); } else if (constantValue instanceof Byte) { int byteValue= ((Byte) constantValue).intValue() & 0xFF; return formatWithHexValue(constantValue, "0x" + Integer.toHexString(byteValue)); //$NON-NLS-1$ } else if (constantValue instanceof Short) { int shortValue= ((Short) constantValue).shortValue() & 0xFFFF; return formatWithHexValue(constantValue, "0x" + Integer.toHexString(shortValue)); //$NON-NLS-1$ } else if (constantValue instanceof Integer) { int intValue= ((Integer) constantValue).intValue(); return formatWithHexValue(constantValue, "0x" + Integer.toHexString(intValue)); //$NON-NLS-1$ } else if (constantValue instanceof Long) { long longValue= ((Long) constantValue).longValue(); return formatWithHexValue(constantValue, "0x" + Long.toHexString(longValue)); //$NON-NLS-1$ } else { return constantValue.toString(); } }