Download
Getting Started
Members
Projects
Community
Marketplace
Events
Planet Eclipse
Newsletter
Videos
Participate
Report a Bug
Forums
Mailing Lists
Wiki
IRC
How to Contribute
Working Groups
Automotive
Internet of Things
LocationTech
Long-Term Support
PolarSys
Science
OpenMDM
More
Community
Marketplace
Events
Planet Eclipse
Newsletter
Videos
Participate
Report a Bug
Forums
Mailing Lists
Wiki
IRC
How to Contribute
Working Groups
Automotive
Internet of Things
LocationTech
Long-Term Support
PolarSys
Science
OpenMDM
Toggle navigation
Bugzilla – Attachment 252167 Details for
Bug 403917
[1.8] Render TYPE_USE annotations in Javadoc hover/view
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Requests
|
Help
|
Log In
[x]
|
Terms of Use
|
Copyright Agent
[patch]
binding based javadoc hover/view v3
Bug-403917--18-Render-TYPEUSE-annotations-in-Javadoc.patch (text/plain), 20.92 KB, created by
Stephan Herrmann
on 2015-04-05 13:22:35 EDT
(
hide
)
Description:
binding based javadoc hover/view v3
Filename:
MIME Type:
Creator:
Stephan Herrmann
Created:
2015-04-05 13:22:35 EDT
Size:
20.92 KB
patch
obsolete
>diff --git a/org.eclipse.jdt.ui/ui/org/eclipse/jdt/internal/ui/infoviews/JavadocView.java b/org.eclipse.jdt.ui/ui/org/eclipse/jdt/internal/ui/infoviews/JavadocView.java >index 6757de4..34c243d 100644 >--- a/org.eclipse.jdt.ui/ui/org/eclipse/jdt/internal/ui/infoviews/JavadocView.java >+++ b/org.eclipse.jdt.ui/ui/org/eclipse/jdt/internal/ui/infoviews/JavadocView.java >@@ -150,6 +150,7 @@ > import org.eclipse.jdt.internal.ui.text.java.hover.JavadocHover.FallbackInformationPresenter; > import org.eclipse.jdt.internal.ui.text.javadoc.JavadocContentAccess2; > import org.eclipse.jdt.internal.ui.viewsupport.BasicElementLabels; >+import org.eclipse.jdt.internal.ui.viewsupport.BindingLinkedLabelComposer; > import org.eclipse.jdt.internal.ui.viewsupport.JavaElementLinks; > > >@@ -1155,7 +1156,15 @@ > * @return a string containing the member's label > */ > private String getInfoText(IJavaElement member, String constantValue, boolean allowImage) { >- StringBuffer label= new StringBuffer(JavaElementLinks.getElementLabel(member, JavadocHover.getHeaderFlags(member))); >+ long flags= JavadocHover.getHeaderFlags(member); >+ IBinding binding= JavadocHover.getHoverBinding(member, null); >+ StringBuffer label; >+ if (binding != null) { >+ label= new StringBuffer(); >+ new BindingLinkedLabelComposer(member, label).appendBindingLabel(binding, flags); >+ } else { >+ label= new StringBuffer(JavaElementLinks.getElementLabel(member, flags)); >+ } > if (member.getElementType() == IJavaElement.FIELD && constantValue != null) { > label.append(constantValue); > } >diff --git a/org.eclipse.jdt.ui/ui/org/eclipse/jdt/internal/ui/text/java/hover/JavadocHover.java b/org.eclipse.jdt.ui/ui/org/eclipse/jdt/internal/ui/text/java/hover/JavadocHover.java >index 5288fe2..fe25f1e 100644 >--- a/org.eclipse.jdt.ui/ui/org/eclipse/jdt/internal/ui/text/java/hover/JavadocHover.java >+++ b/org.eclipse.jdt.ui/ui/org/eclipse/jdt/internal/ui/text/java/hover/JavadocHover.java >@@ -73,6 +73,7 @@ > import org.eclipse.jdt.core.IPackageDeclaration; > import org.eclipse.jdt.core.IPackageFragment; > import org.eclipse.jdt.core.IPackageFragmentRoot; >+import org.eclipse.jdt.core.ISourceReference; > import org.eclipse.jdt.core.ITypeParameter; > import org.eclipse.jdt.core.ITypeRoot; > import org.eclipse.jdt.core.JavaCore; >@@ -759,8 +760,17 @@ > > private static String getInfoText(IJavaElement element, ITypeRoot editorInputElement, IRegion hoverRegion, boolean allowImage) { > long flags= getHeaderFlags(element); >- StringBuffer label= new StringBuffer(JavaElementLinks.getElementLabel(element, flags)); > >+ ASTNode node= (editorInputElement instanceof ICompilationUnit) ? getHoveredASTNode(editorInputElement, hoverRegion) : null; >+ IBinding binding= getHoverBinding(element, node); >+ >+ StringBuffer label; >+ if (binding != null) { >+ label= new StringBuffer(JavaElementLinks.getBindingLabel(binding, element, flags)); >+ } else { >+ label= new StringBuffer(JavaElementLinks.getElementLabel(element, flags)); >+ } >+ > if (element.getElementType() == IJavaElement.FIELD) { > String constantValue= getConstantValue((IField) element, editorInputElement, hoverRegion); > if (constantValue != null) { >@@ -778,6 +788,34 @@ > > return getImageAndLabel(element, allowImage, label.toString()); > } >+ >+ /** >+ * Try to acquire a binding corresponding to the given element >+ * for more precise information about (type) annotations. >+ * @param element the element being rendered >+ * @param node the AST node corresponding to the given element, or null, if no AST node is available. >+ * @return either a binding corresponding to the given element or null. >+ */ >+ public static IBinding getHoverBinding(IJavaElement element, ASTNode node) { >+ >+ if (element.getJavaProject().getOption(JavaCore.COMPILER_ANNOTATION_NULL_ANALYSIS, true).equals(JavaCore.ENABLED)) { >+ if (node == null) { >+ if (element instanceof ISourceReference) { >+ ASTParser p= ASTParser.newParser(ASTProvider.SHARED_AST_LEVEL); >+ p.setProject(element.getJavaProject()); >+ p.setBindingsRecovery(true); >+ try { >+ return p.createBindings(new IJavaElement[] { element }, null)[0]; >+ } catch (OperationCanceledException e) { >+ return null; >+ } >+ } >+ } else { >+ return resolveBinding(node); >+ } >+ } >+ return null; >+ } > > private static String getImageURL(IJavaElement element) { > String imageName= null; >diff --git a/org.eclipse.jdt.ui/ui/org/eclipse/jdt/internal/ui/viewsupport/BindingLinkedLabelComposer.java b/org.eclipse.jdt.ui/ui/org/eclipse/jdt/internal/ui/viewsupport/BindingLinkedLabelComposer.java >new file mode 100644 >index 0000000..983107b >--- /dev/null >+++ b/org.eclipse.jdt.ui/ui/org/eclipse/jdt/internal/ui/viewsupport/BindingLinkedLabelComposer.java >@@ -0,0 +1,340 @@ >+package org.eclipse.jdt.internal.ui.viewsupport; >+ >+import static org.eclipse.jdt.internal.ui.viewsupport.JavaElementLinks.JAVADOC_SCHEME; >+import static org.eclipse.jdt.internal.ui.viewsupport.JavaElementLinks.createHeaderLink; >+import static org.eclipse.jdt.internal.ui.viewsupport.JavaElementLinks.createURI; >+ >+import java.net.URISyntaxException; >+ >+import org.eclipse.jdt.core.Flags; >+import org.eclipse.jdt.core.IJavaElement; >+import org.eclipse.jdt.core.IMethod; >+import org.eclipse.jdt.core.IType; >+import org.eclipse.jdt.core.JavaModelException; >+import org.eclipse.jdt.core.dom.IAnnotationBinding; >+import org.eclipse.jdt.core.dom.IBinding; >+import org.eclipse.jdt.core.dom.IMemberValuePairBinding; >+import org.eclipse.jdt.core.dom.IMethodBinding; >+import org.eclipse.jdt.core.dom.ITypeBinding; >+import org.eclipse.jdt.core.dom.IVariableBinding; >+ >+import org.eclipse.jdt.internal.corext.util.JavaModelUtil; >+import org.eclipse.jdt.internal.corext.util.Messages; >+ >+import org.eclipse.jdt.ui.JavaElementLabels; >+ >+import org.eclipse.jdt.internal.ui.JavaPlugin; >+import org.eclipse.jdt.internal.ui.JavaUIMessages; >+import org.eclipse.jdt.internal.ui.viewsupport.JavaElementLinks.JavaElementLinkedLabelComposer; >+ >+public class BindingLinkedLabelComposer extends JavaElementLinkedLabelComposer { >+ >+ private IJavaElement fEnclosingElement; >+ >+ public BindingLinkedLabelComposer(IJavaElement enclosingElement, StringBuffer buffer) { >+ super(enclosingElement, buffer); >+ fEnclosingElement= enclosingElement; >+ } >+ >+ /** >+ * <p>Supported flags: >+ * <ul> >+ * <li>{@link JavaElementLabels#ALL_FULLY_QUALIFIED} (set)</li> >+ * <li>{@link JavaElementLabels#M_PRE_RETURNTYPE}</li> >+ * <li>{@link JavaElementLabels#M_PARAMETER_ANNOTATIONS}</li> >+ * <li>{@link JavaElementLabels#M_PARAMETER_TYPES}</li> >+ * <li>{@link JavaElementLabels#M_PARAMETER_NAMES}</li> >+ * <li>{@link JavaElementLabels#M_EXCEPTIONS}</li> >+ * <li>{@link JavaElementLabels#F_PRE_TYPE_SIGNATURE}</li> >+ * <li>{@link JavaElementLabels#M_PRE_TYPE_PARAMETERS}</li> >+ * <li>{@link JavaElementLabels#T_TYPE_PARAMETERS}</li> >+ * <li>{@link JavaElementLabels#USE_RESOLVED}</li> >+ * <li>{@link JavaElementLabels#F_POST_QUALIFIED}</li> >+ * <li>{@link JavaElementLabels#TP_POST_QUALIFIED}</li> >+ * </ul> >+ * @param binding a binding to be rendered >+ * @param flags rendering flags, see above for supported values. >+ */ >+ public void appendBindingLabel(IBinding binding, long flags) { >+ switch (binding.getKind()) { >+ case IBinding.METHOD: >+ appendMethodBindingLabel((IMethodBinding) binding, flags); >+ return; >+ case IBinding.TYPE: >+ appendTypeBindingLabel((ITypeBinding) binding, flags); // TODO: compare w/ JavaElementLabelComposer.appendTypeLabel(IType, long) >+ return; >+ case IBinding.VARIABLE: >+ appendVariableLabel((IVariableBinding) binding, flags); >+ return; >+ default: >+ throw new IllegalArgumentException("Unsupported binding kind "+binding); // FIXME >+ } >+ >+ } >+ >+ private void appendMethodBindingLabel(IMethodBinding method, long flags) { >+ // type parameters >+ if (getFlag(flags, JavaElementLabels.M_PRE_TYPE_PARAMETERS)) { >+ appendTypeArgumentsBindingLabel(method.getTypeParameters(), flags); >+ fBuffer.append(' '); >+ } >+ >+ // return type >+ if (getFlag(flags, JavaElementLabels.M_PRE_RETURNTYPE) && !method.isConstructor()) { >+ appendTypeBindingLabel(method.getReturnType(), flags); >+ fBuffer.append(' '); >+ } >+ >+ // qualification >+ if (getFlag(flags, JavaElementLabels.M_FULLY_QUALIFIED)) { >+ // TODO: still Java-model-based: >+ appendTypeLabel((IType) fEnclosingElement.getParent(), JavaElementLabels.T_FULLY_QUALIFIED | (flags & QUALIFIER_FLAGS)); >+ fBuffer.append('.'); >+ } >+ >+ fBuffer.append(method.getName()); >+ >+ // constructor type arguments >+ if (getFlag(flags, JavaElementLabels.T_TYPE_PARAMETERS) && method.isConstructor()) { >+ appendTypeArgumentsBindingLabel(method.getTypeArguments(), flags); >+ } >+ >+ // parameters >+ fBuffer.append('('); >+ if (getFlag(flags, JavaElementLabels.M_PARAMETER_TYPES | JavaElementLabels.M_PARAMETER_NAMES)) { >+ ITypeBinding[] types= null; >+ int nParams= 0; >+ boolean renderVarargs= false; >+ boolean isPolymorphic= false; >+ if (getFlag(flags, JavaElementLabels.M_PARAMETER_TYPES)) { >+ if (getFlag(flags, JavaElementLabels.M_PARAMETER_TYPES)) { >+ types= method.getParameterTypes(); >+ nParams= types.length; >+ renderVarargs= method.isVarargs(); >+ if (fEnclosingElement instanceof IMethod) { >+ // retrieval of flag isPolymorphic uses strategy from JavaElementLabelComposer: >+ IMethod iMethod= (IMethod) fEnclosingElement; >+ if (iMethod.getParameterTypes().length == 1 >+ && JavaModelUtil.isPolymorphicSignature(iMethod)) { >+ renderVarargs= false; >+ isPolymorphic= true; >+ } >+ } >+ } >+ String[] names= null; >+ if (getFlag(flags, JavaElementLabels.M_PARAMETER_NAMES) && fEnclosingElement instanceof IMethod) { >+ // mostly from JavaElementLabelComposer: >+ try { >+ names= ((IMethod) fEnclosingElement).getParameterNames(); >+ } catch (JavaModelException e) { >+ JavaPlugin.log(e); >+ } >+ if (isPolymorphic) { >+ // handled specially below >+ } else if (types == null) { >+ nParams= names.length; >+ } else { // types != null >+ if (nParams != names.length) { >+ if (types.length > names.length) { >+ // see https://bugs.eclipse.org/bugs/show_bug.cgi?id=99137 >+ nParams= names.length; >+ ITypeBinding[] typesWithoutSyntheticParams= new ITypeBinding[nParams]; >+ System.arraycopy(types, types.length - nParams, typesWithoutSyntheticParams, 0, nParams); >+ types= typesWithoutSyntheticParams; >+ } else { >+ // https://bugs.eclipse.org/bugs/show_bug.cgi?id=101029 >+ // JavaPlugin.logErrorMessage("JavaElementLabels: Number of param types(" + nParams + ") != number of names(" + names.length + "): " + method.getElementName()); //$NON-NLS-1$//$NON-NLS-2$//$NON-NLS-3$ >+ names= null; // no names rendered >+ } >+ } >+ } >+ } >+ IAnnotationBinding[][] parameterAnnotations= null; >+ if (nParams > 0 && getFlag(flags, JavaElementLabels.M_PARAMETER_ANNOTATIONS)) { >+ parameterAnnotations= new IAnnotationBinding[nParams][]; >+ for (int i= 0; i < nParams; i++) { >+ parameterAnnotations[i]= method.getParameterAnnotations(i); >+ } >+ } >+ >+ for (int i= 0; i < nParams; i++) { >+ if (i > 0) >+ fBuffer.append(JavaElementLabels.COMMA_STRING); >+ if (parameterAnnotations != null && i < parameterAnnotations.length) { >+ appendAnnotationLabels(parameterAnnotations[i], flags); >+ } >+ >+ if (types != null) { >+ ITypeBinding paramSig= types[i]; >+ if (renderVarargs && (i == nParams - 1)) { >+ int newDim= paramSig.getDimensions() - 1; >+ appendTypeBindingLabel(paramSig.getElementType(), flags); >+ for (int k= 0; k < newDim; k++) { >+ fBuffer.append('[').append(']'); >+ } >+ fBuffer.append(JavaElementLabels.ELLIPSIS_STRING); >+ } else { >+ appendTypeBindingLabel(paramSig, flags); >+ } >+ } >+ if (names != null) { >+ if (types != null) { >+ fBuffer.append(' '); >+ } >+ if (isPolymorphic) { >+ fBuffer.append(names[0] + i); >+ } else { >+ fBuffer.append(names[i]); >+ } >+ } >+ } >+ } >+ } else { >+ if (method.getParameterTypes().length > 0) { >+ fBuffer.append(JavaElementLabels.ELLIPSIS_STRING); >+ } >+ } >+ fBuffer.append(')'); >+ >+ >+ if (getFlag(flags, JavaElementLabels.M_EXCEPTIONS)) { >+ ITypeBinding[] types= method.getExceptionTypes(); >+ if (types.length > 0) { >+ fBuffer.append(" throws "); //$NON-NLS-1$ >+ for (int i= 0; i < types.length; i++) { >+ if (i > 0) >+ fBuffer.append(JavaElementLabels.COMMA_STRING); >+ appendTypeBindingLabel(types[i], flags); >+ } >+ } >+ } >+ } >+ >+ private void appendVariableLabel(IVariableBinding variable, long flags) { >+ if (getFlag(flags, JavaElementLabels.F_PRE_TYPE_SIGNATURE) && !Flags.isEnum(variable.getModifiers())) { >+ appendTypeBindingLabel(variable.getType(), flags); >+ fBuffer.append(' '); >+ } >+ >+ // qualification >+ if (variable.isField() && getFlag(flags, JavaElementLabels.F_FULLY_QUALIFIED)) { >+ // TODO: still Java-model-based: >+ appendTypeLabel((IType) fEnclosingElement.getParent(), JavaElementLabels.T_FULLY_QUALIFIED | (flags & QUALIFIER_FLAGS)); >+ fBuffer.append('.'); >+ } >+ fBuffer.append(variable.getName()); >+ } >+ >+ private void appendTypeArgumentsBindingLabel(ITypeBinding[] parameters, long flags) { >+ if (parameters.length > 0) { >+ fBuffer.append(getLT()); >+ for (int i = 0; i < parameters.length; i++) { >+ if (i > 0) >+ fBuffer.append(JavaElementLabels.COMMA_STRING); >+ appendTypeBindingLabel(parameters[i], flags); >+ } >+ fBuffer.append(getGT()); >+ } >+ } >+ >+ private void appendTypeBindingLabel(ITypeBinding typeBinding, long flags) { >+ if (!typeBinding.isArray()) { // different textual order for type annotations on array types >+ appendAnnotationLabels(typeBinding.getTypeAnnotations(), flags); >+ } >+ if (typeBinding.isPrimitive()) { >+ fBuffer.append(typeBinding.getName()); >+ } else if (typeBinding.isArray()) { >+ appendTypeBindingLabel(typeBinding.getElementType(), flags); >+ IAnnotationBinding[] typeAnnotations= typeBinding.getTypeAnnotations(); >+ if (typeAnnotations.length > 0) { >+ fBuffer.append(' '); >+ appendAnnotationLabels(typeAnnotations, flags); >+ } >+ for (int dim= typeBinding.getDimensions(); dim > 0; dim--) { >+ fBuffer.append('[').append(']'); >+ } >+ } else if (typeBinding.isClass() || typeBinding.isInterface() || typeBinding.isEnum()) { >+ fBuffer.append(getSimpleTypeName(typeBinding)); >+ appendTypeArgumentsBindingLabel(typeBinding.getTypeArguments(), flags); >+ } else if (typeBinding.isParameterizedType()) { >+ fBuffer.append(getSimpleTypeName(typeBinding.getTypeDeclaration())); >+ fBuffer.append(getLT()); >+ ITypeBinding[] typeArguments= typeBinding.getTypeArguments(); >+ for (int i= 0; i < typeArguments.length; i++) { >+ if (i > 0) >+ fBuffer.append(JavaElementLabels.COMMA_STRING); >+ appendTypeBindingLabel(typeArguments[i], flags); >+ } >+ fBuffer.append(getGT()); >+ } else if (typeBinding.isTypeVariable()) { >+ fBuffer.append(getSimpleTypeName(typeBinding)); >+ } else if (typeBinding.isAnnotation()) { >+ fBuffer.append(getSimpleTypeName(typeBinding)); >+ } else if (typeBinding.isWildcardType()) { >+ ITypeBinding bound= typeBinding.getBound(); >+ if (bound == null || bound.getSuperclass() == null) { // no relevant bound / only j.l.Object >+ fBuffer.append('?'); >+ } else { >+ if (typeBinding.isUpperbound()) >+ fBuffer.append("? extends "); //$NON-NLS-1$ >+ else >+ fBuffer.append("? super "); //$NON-NLS-1$ >+ appendTypeBindingLabel(bound, flags); >+ } >+ } else if (typeBinding.isCapture()) { >+ appendTypeBindingLabel(typeBinding.getWildcard(), flags); >+ } >+ // TODO: intersection type >+ } >+ >+ private String getSimpleTypeName(ITypeBinding typeBinding) { >+ typeBinding= typeBinding.getTypeDeclaration(); >+ String typeName = typeBinding.getName(); >+ String qualifiedName = typeBinding.getQualifiedName(); >+ String title= ""; //$NON-NLS-1$ >+ int qualifierLength= qualifiedName.length() - typeName.length() - 1; >+ if (qualifierLength > 0) { >+ if (qualifiedName.endsWith(typeName)) { >+ title= qualifiedName.substring(0, qualifierLength); >+ title= Messages.format(JavaUIMessages.JavaElementLinks_title, title); >+ } else { >+ title= qualifiedName; // Not expected. Just show the whole qualifiedName. >+ } >+ } >+ >+ try { >+ String uri= createURI(JAVADOC_SCHEME, fEnclosingElement, qualifiedName, null, null); >+ return createHeaderLink(uri, typeName, title); >+ } catch (URISyntaxException e) { >+ JavaPlugin.log(e); >+ return typeName; >+ } >+ } >+ >+ private void appendAnnotationLabels(IAnnotationBinding[] annotationBindings, long flags) { >+ for (int i= 0; i < annotationBindings.length; i++) { >+ appendAnnotationLabel(annotationBindings[i], flags); >+ fBuffer.append(' '); >+ } >+ } >+ >+ private void appendAnnotationLabel(IAnnotationBinding annotation, long flags) { >+ fBuffer.append('@'); >+ appendTypeBindingLabel(annotation.getAnnotationType(), flags); >+ IMemberValuePairBinding[] memberValuePairs= annotation.getAllMemberValuePairs(); >+ if (memberValuePairs.length == 0) >+ return; >+ fBuffer.append('('); >+ for (int i= 0; i < memberValuePairs.length; i++) { >+ if (i > 0) >+ fBuffer.append(JavaElementLabels.COMMA_STRING); >+ IMemberValuePairBinding memberValuePair= memberValuePairs[i]; >+ fBuffer.append(getMemberName(fEnclosingElement, annotation.getName(), memberValuePair.getName())); >+ fBuffer.append('='); >+// FIXME: >+ fBuffer.append(memberValuePair.getValue().toString()); >+// appendAnnotationValue(annotation, memberValuePair.getValue(), memberValuePair.getValueKind(), flags); >+ } >+ fBuffer.append(')'); >+ } >+} >diff --git a/org.eclipse.jdt.ui/ui/org/eclipse/jdt/internal/ui/viewsupport/JavaElementLabelComposer.java b/org.eclipse.jdt.ui/ui/org/eclipse/jdt/internal/ui/viewsupport/JavaElementLabelComposer.java >index 02b7554..d38cc44 100644 >--- a/org.eclipse.jdt.ui/ui/org/eclipse/jdt/internal/ui/viewsupport/JavaElementLabelComposer.java >+++ b/org.eclipse.jdt.ui/ui/org/eclipse/jdt/internal/ui/viewsupport/JavaElementLabelComposer.java >@@ -196,7 +196,7 @@ > } > > >- private final static long QUALIFIER_FLAGS= JavaElementLabels.P_COMPRESSED | JavaElementLabels.USE_RESOLVED; >+ final static long QUALIFIER_FLAGS= JavaElementLabels.P_COMPRESSED | JavaElementLabels.USE_RESOLVED; > > private static final Styler QUALIFIER_STYLE= StyledString.QUALIFIER_STYLER; > private static final Styler COUNTER_STYLE= StyledString.COUNTER_STYLER; >@@ -219,7 +219,7 @@ > > protected final FlexibleBuffer fBuffer; > >- private static final boolean getFlag(long flags, long flag) { >+ protected static final boolean getFlag(long flags, long flag) { > return (flags & flag) != 0; > } > >diff --git a/org.eclipse.jdt.ui/ui/org/eclipse/jdt/internal/ui/viewsupport/JavaElementLinks.java b/org.eclipse.jdt.ui/ui/org/eclipse/jdt/internal/ui/viewsupport/JavaElementLinks.java >index 43add76..a2f2e6f 100644 >--- a/org.eclipse.jdt.ui/ui/org/eclipse/jdt/internal/ui/viewsupport/JavaElementLinks.java >+++ b/org.eclipse.jdt.ui/ui/org/eclipse/jdt/internal/ui/viewsupport/JavaElementLinks.java >@@ -39,6 +39,7 @@ > import org.eclipse.jdt.core.JavaCore; > import org.eclipse.jdt.core.JavaModelException; > import org.eclipse.jdt.core.Signature; >+import org.eclipse.jdt.core.dom.IBinding; > > import org.eclipse.jdt.internal.corext.util.JavaModelUtil; > import org.eclipse.jdt.internal.corext.util.Messages; >@@ -102,7 +103,7 @@ > void handleTextSet(); > } > >- private static final class JavaElementLinkedLabelComposer extends JavaElementLabelComposer { >+ static class JavaElementLinkedLabelComposer extends JavaElementLabelComposer { > private final IJavaElement fElement; > > public JavaElementLinkedLabelComposer(IJavaElement member, StringBuffer buf) { >@@ -665,7 +666,7 @@ > * @return the HTML link > * @since 3.10 > */ >- private static String createHeaderLink(String uri, String label, String title) { >+ public static String createHeaderLink(String uri, String label, String title) { > if (title.length() > 0) { > title= " title='" + title + "'"; //$NON-NLS-1$ //$NON-NLS-2$ > } >@@ -708,4 +709,28 @@ > return label.replaceAll("<", "<").replaceAll(">", ">"); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$ > } > } >+ >+ /** >+ * Returns the label for a binding with the flags as defined by {@link JavaElementLabels}. >+ * Referenced element names in the label are rendered as header links. >+ * >+ * @param binding the binding to render >+ * @param enclosingElement the corresponding Java element, used for javadoc hyperlinks >+ * @param flags the rendering flags >+ * @return the label of the binding >+ * @since 3.11 >+ */ >+ public static String getBindingLabel(IBinding binding, IJavaElement enclosingElement, long flags) { >+ StringBuffer buf= new StringBuffer(); >+ >+ if (!Strings.USE_TEXT_PROCESSOR) { >+ new BindingLinkedLabelComposer(enclosingElement, buf).appendBindingLabel(binding, flags); >+ return Strings.markJavaElementLabelLTR(buf.toString()); >+ } else { >+ // TODO ? >+ return ""; >+// String label= JavaElementLabels.getElementLabel(element, flags); >+// return label.replaceAll("<", "<").replaceAll(">", ">"); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$ >+ } >+ } > }
You cannot view the attachment while viewing its details because your browser does not support IFRAMEs.
View the attachment on a separate page
.
View Attachment As Diff
View Attachment As Raw
Actions:
View
|
Diff
Attachments on
bug 403917
:
251199
|
251569
|
252167
|
252324
|
252516
|
252659