| author | Manju Mathew | 2012-12-03 07:26:32 (EST) |
|---|---|---|
| committer | Dani Megert | 2012-12-03 07:26:32 (EST) |
| commit | 0ca71554e07b36bd8666dfc5e988cb0b05f52686 (patch) (side-by-side diff) | |
| tree | 48cd171e57064549e087f2847c71b158782dc7e6 | |
| parent | b6211a29d6c19f8b25da38b79746e5caa52300c7 (diff) | |
| download | eclipse.jdt.ui-0ca71554e07b36bd8666dfc5e988cb0b05f52686.zip eclipse.jdt.ui-0ca71554e07b36bd8666dfc5e988cb0b05f52686.tar.gz eclipse.jdt.ui-0ca71554e07b36bd8666dfc5e988cb0b05f52686.tar.bz2 | |
Patch 3 for review
9 files changed, 50 insertions, 46 deletions
diff --git a/org.eclipse.jdt.ui/core extension/org/eclipse/jdt/internal/corext/javadoc/JavaDocLocations.java b/org.eclipse.jdt.ui/core extension/org/eclipse/jdt/internal/corext/javadoc/JavaDocLocations.java index 17dee43..66f0ea4 100644 --- a/org.eclipse.jdt.ui/core extension/org/eclipse/jdt/internal/corext/javadoc/JavaDocLocations.java +++ b/org.eclipse.jdt.ui/core extension/org/eclipse/jdt/internal/corext/javadoc/JavaDocLocations.java @@ -592,8 +592,8 @@ public class JavaDocLocations { /** * Fetch the location of the javadoc. * - * @param element - an object of type JavaElement. - * @param isBinary - true if the JavaElement is from a a Binary container. + * @param element an object of type JavaElement. + * @param isBinary true if the JavaElement is from a a Binary container. * @return the location URL of the Javadoc or <code>null</code> if the location cannot be * retrieved. * @throws JavaModelException thrown when the element can not be accessed 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 405b7f4..11e606f 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 @@ -1092,8 +1092,8 @@ public class JavadocView extends AbstractInfoView { IJavaElement curr= result[i]; if (curr instanceof IMember || curr instanceof IPackageFragment || curr instanceof IPackageDeclaration || curr.getElementType() == IJavaElement.LOCAL_VARIABLE) { HTMLPrinter.addBullet(buffer, getInfoText(curr, null, false)); - HTMLPrinter.endBulletList(buffer); - } + HTMLPrinter.endBulletList(buffer); + } } } else { @@ -1122,8 +1122,8 @@ public class JavadocView extends AbstractInfoView { if (reader != null) { HTMLPrinter.addParagraph(buffer, reader); } - }else if (curr instanceof IMember) { - final IMember member= (IMember)curr; + } else if (curr instanceof IMember) { + final IMember member= (IMember) curr; String constantValue= null; if (member instanceof IField) { @@ -1135,9 +1135,9 @@ public class JavadocView extends AbstractInfoView { HTMLPrinter.addSmallHeader(buffer, getInfoText(member, constantValue, true)); try { - ISourceRange nameRange= ((IMember)curr).getNameRange(); + ISourceRange nameRange= ((IMember) curr).getNameRange(); if (SourceRange.isAvailable(nameRange)) { - ITypeRoot typeRoot= ((IMember)curr).getTypeRoot(); + ITypeRoot typeRoot= ((IMember) curr).getTypeRoot(); Region hoverRegion= new Region(nameRange.getOffset(), nameRange.getLength()); buffer.append("<br>"); //$NON-NLS-1$ JavadocHover.addAnnotations(buffer, curr, typeRoot, hoverRegion); @@ -1145,7 +1145,7 @@ public class JavadocView extends AbstractInfoView { } catch (JavaModelException e) { // no annotations this time... } - + Reader reader; try { String content= JavadocContentAccess2.getHTMLContent(member, true); @@ -1172,7 +1172,7 @@ public class JavadocView extends AbstractInfoView { } } } - + if (buffer.length() == 0) return null; @@ -1190,12 +1190,12 @@ public class JavadocView extends AbstractInfoView { * selected IJavaElement and also return the location URL where the Javadoc is present or * <code>null</code> if no location is specified. * - * @param reader - the StringReader - * @param element - an object of type IJavaElement - * @param root - IPackageFragmentRoot of the java element - * @param isBinary - whether the content is coming from jar - * @return - baseURL of the JavaDoc, <code>null</code> if there is no associated javadoc - * @throws JavaModelException - if this element does not exist or if an exception occurs while + * @param reader the StringReader or <code>null</code> + * @param element an object of type IJavaElement + * @param root the IPackageFragmentRoot of the java element or <code>null</code> + * @param isBinary is true if the content is coming from a jar + * @return baseURL of the JavaDoc, <code>null</code> if there is no associated javadoc + * @throws JavaModelException if this element does not exist or if an exception occurs while * accessing its corresponding resource. * @since 3.9 */ @@ -1232,7 +1232,7 @@ public class JavadocView extends AbstractInfoView { * @return a string containing the member's label */ private String getInfoText(IJavaElement member, String constantValue, boolean allowImage) { - StringBuffer label= new StringBuffer(JavaElementLinks.getElementLabel(member, LABEL_FLAGS)); + StringBuffer label= new StringBuffer(JavaElementLinks.getElementLabel(member, getHeaderFlag(member))); if (member.getElementType() == IJavaElement.FIELD && constantValue != null) { label.append(constantValue); } @@ -1250,6 +1250,17 @@ public class JavadocView extends AbstractInfoView { return buf.toString(); } + + private long getHeaderFlag(IJavaElement element) { + switch (element.getElementType()) { + case IJavaElement.PACKAGE_FRAGMENT: + case IJavaElement.PACKAGE_DECLARATION: + return JavaElementLabels.P_COMPRESSED; + default: + return LABEL_FLAGS; + } + } + /* * @see org.eclipse.jdt.internal.ui.infoviews.AbstractInfoView#isIgnoringNewInput(org.eclipse.jdt.core.IJavaElement, org.eclipse.jface.viewers.ISelection) * @since 3.2 diff --git a/org.eclipse.jdt.ui/ui/org/eclipse/jdt/internal/ui/text/java/PackageProposalInfo.java b/org.eclipse.jdt.ui/ui/org/eclipse/jdt/internal/ui/text/java/PackageProposalInfo.java index d46047c..7b24d1a 100644 --- a/org.eclipse.jdt.ui/ui/org/eclipse/jdt/internal/ui/text/java/PackageProposalInfo.java +++ b/org.eclipse.jdt.ui/ui/org/eclipse/jdt/internal/ui/text/java/PackageProposalInfo.java @@ -18,7 +18,6 @@ import org.eclipse.core.runtime.Path; import org.eclipse.jdt.core.CompletionProposal; import org.eclipse.jdt.core.IJavaElement; import org.eclipse.jdt.core.IJavaProject; -import org.eclipse.jdt.core.IPackageFragment; import org.eclipse.jdt.core.JavaModelException; import org.eclipse.jdt.internal.corext.template.java.SignatureUtil; @@ -48,7 +47,7 @@ public class PackageProposalInfo extends ProposalInfo { } /** - * Resolve to {@link IPackageFragment}. + * Resolve to a PackageFragment. * * @return the <code>IPackageFragment</code> or <code>null</code> if no element can be found. * @throws JavaModelException thrown if the path to the element is null or absolute. diff --git a/org.eclipse.jdt.ui/ui/org/eclipse/jdt/internal/ui/text/java/ProposalInfo.java b/org.eclipse.jdt.ui/ui/org/eclipse/jdt/internal/ui/text/java/ProposalInfo.java index 46167b6..b6afb9d 100644 --- a/org.eclipse.jdt.ui/ui/org/eclipse/jdt/internal/ui/text/java/ProposalInfo.java +++ b/org.eclipse.jdt.ui/ui/org/eclipse/jdt/internal/ui/text/java/ProposalInfo.java @@ -72,7 +72,7 @@ public class ProposalInfo { private String computeInfo(IProgressMonitor monitor) { try { final IJavaElement javaElement= getJavaElement(); - return extractJavadoc(javaElement, monitor); + return extractJavadoc(javaElement); } catch (JavaModelException e) { JavaPlugin.log(e); } @@ -80,16 +80,15 @@ public class ProposalInfo { } /** - * Extracts the javadoc for the given <code>IMember</code> and returns it + * Extracts the javadoc for the given <code>IJavaElement</code> and returns it * as HTML. * - * @param element the member to get the documentation for - * @param monitor a progress monitor + * @param element the IJavaElement to get the documentation for * @return the javadoc for <code>member</code> or <code>null</code> if * it is not available * @throws JavaModelException if accessing the javadoc fails */ - private String extractJavadoc(IJavaElement element, IProgressMonitor monitor) throws JavaModelException { + private String extractJavadoc(IJavaElement element) throws JavaModelException { if (element instanceof IMember) { return JavadocContentAccess2.getHTMLContent((IMember) element, true); } else if (element instanceof IPackageDeclaration) { 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 0bba39d..cfb2ba9 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 @@ -545,6 +545,7 @@ public class JavadocHover extends AbstractJavaEditorTextHover { /** * @deprecated see {@link org.eclipse.jface.text.ITextHover#getHoverInfo(ITextViewer, IRegion)} */ + @Deprecated public String getHoverInfo(ITextViewer textViewer, IRegion hoverRegion) { JavadocBrowserInformationControlInput info= (JavadocBrowserInformationControlInput) getHoverInfo2(textViewer, hoverRegion); return info != null ? info.getHtml() : null; @@ -678,9 +679,9 @@ public class JavadocHover extends AbstractJavaEditorTextHover { /** * Retrieve the URL for the Javadoc location or provide an hint why there is no javadoc. * - * @param reader the StringReader to store the reason for why there is no javadoc. + * @param reader the StringReader or <code>null</code> * @param element an object of type IJavaElement. - * @param root the PackageFragmentRoot of the element. + * @param root the PackageFragmentRoot of the element or <code>null</code> * @param isBinary true if the element is from a binary container. * @return the location URL or <code>null</code> if there is no javadoc associated with the * element. @@ -756,6 +757,8 @@ public class JavadocHover extends AbstractJavaEditorTextHover { return LOCAL_VARIABLE_FLAGS; case IJavaElement.TYPE_PARAMETER: return TYPE_PARAMETER_FLAGS; + case IJavaElement.PACKAGE_FRAGMENT: + return JavaElementLabels.P_COMPRESSED; default: return LABEL_FLAGS; } diff --git a/org.eclipse.jdt.ui/ui/org/eclipse/jdt/internal/ui/text/javadoc/JavaDocMessages.java b/org.eclipse.jdt.ui/ui/org/eclipse/jdt/internal/ui/text/javadoc/JavaDocMessages.java index 6aa0c17..47d4f32 100644 --- a/org.eclipse.jdt.ui/ui/org/eclipse/jdt/internal/ui/text/javadoc/JavaDocMessages.java +++ b/org.eclipse.jdt.ui/ui/org/eclipse/jdt/internal/ui/text/javadoc/JavaDocMessages.java @@ -35,10 +35,6 @@ final class JavaDocMessages extends NLS { public static String JavaDoc2HTMLTextReader_specified_by_section; public static String JavaDoc2HTMLTextReader_version_section; - public static String JavadocContentAccess2_PACKAGE_HTML; - public static String JavadocContentAccess2_PACKAGE_INFO_CLASS; - public static String JavadocContentAccess2_PACKAGE_INFO_JAVA; - static { NLS.initializeMessages(BUNDLE_NAME, JavaDocMessages.class); } diff --git a/org.eclipse.jdt.ui/ui/org/eclipse/jdt/internal/ui/text/javadoc/JavaDocMessages.properties b/org.eclipse.jdt.ui/ui/org/eclipse/jdt/internal/ui/text/javadoc/JavaDocMessages.properties index 3c91bf9..e957e8e 100644 --- a/org.eclipse.jdt.ui/ui/org/eclipse/jdt/internal/ui/text/javadoc/JavaDocMessages.properties +++ b/org.eclipse.jdt.ui/ui/org/eclipse/jdt/internal/ui/text/javadoc/JavaDocMessages.properties @@ -20,6 +20,3 @@ JavaDoc2HTMLTextReader_see_section=See Also: JavaDoc2HTMLTextReader_since_section=Since: JavaDoc2HTMLTextReader_specified_by_section=Specified by: JavaDoc2HTMLTextReader_version_section=Version: -JavadocContentAccess2_PACKAGE_HTML=package.html -JavadocContentAccess2_PACKAGE_INFO_CLASS=package-info.class -JavadocContentAccess2_PACKAGE_INFO_JAVA=package-info.java diff --git a/org.eclipse.jdt.ui/ui/org/eclipse/jdt/internal/ui/text/javadoc/JavadocContentAccess2.java b/org.eclipse.jdt.ui/ui/org/eclipse/jdt/internal/ui/text/javadoc/JavadocContentAccess2.java index abcc2c4..d728380 100644 --- a/org.eclipse.jdt.ui/ui/org/eclipse/jdt/internal/ui/text/javadoc/JavadocContentAccess2.java +++ b/org.eclipse.jdt.ui/ui/org/eclipse/jdt/internal/ui/text/javadoc/JavadocContentAccess2.java @@ -1632,7 +1632,7 @@ public class JavadocContentAccess2 { * When user select the package declaration in the outline view, the Javadoc View has to be * updated with the corresponding package documentation. * - * @param packageDeclaraion - element of type IPackageDeclaration. + * @param packageDeclaraion an element of type IPackageDeclaration. * @return Package documentation in HTML format or <code>null</code> if there is no associated * javadoc. * @since 3.9 @@ -1661,11 +1661,11 @@ public class JavadocContentAccess2 { } /** - * Java doc for a package can be found in package.html or package-info.java file. Depending on + * Java doc for a package can be found in package.html, package-info.java or from an attached javadoc. Depending on * the availability of the document, pick the correct content. * - * @param packageFragment - The package which is requesting for the document. - * @return - the document content in HTML format or <code>null</code> if there is no associated + * @param packageFragment the package which is requesting for the document. + * @return the document content in HTML format or <code>null</code> if there is no associated * javadoc. * @since 3.9 */ @@ -1776,12 +1776,11 @@ public class JavadocContentAccess2 { Reader reader= new BufferedReader(new InputStreamReader(in, ResourcesPlugin.getEncoding()), DEFAULT_FILE_SIZE); char[] readBuffer= new char[2048]; - int n; - n= reader.read(readBuffer); + int charCount= reader.read(readBuffer); - while (n > 0) { - buffer.append(readBuffer, 0, n); - n= reader.read(readBuffer); + while (charCount > 0) { + buffer.append(readBuffer, 0, charCount); + charCount= reader.read(readBuffer); } } catch (UnsupportedEncodingException e) { JavaPlugin.log(e.getCause()); @@ -1795,7 +1794,7 @@ public class JavadocContentAccess2 { /** * * Reads a ICompilationUnit and creates the AST DOM for manipulating the Java source file * - * @param javaElement - The compilation unit + * @param javaElement an object of IJavaElement * @return parsed compilation unit */ @@ -1820,8 +1819,8 @@ public class JavadocContentAccess2 { /** * Read the content of the IFile * - * @param resource The resource whose content has to be read - * @return the content of the file + * @param resource the IFile whose content has to be read + * @return the content of the IFile */ private static String getIFileContent(IFile resource) { String content= null; 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 f915f98..b6e68eb 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 @@ -291,7 +291,7 @@ public class JavaElementLabelComposer { appendCompilationUnitLabel((ICompilationUnit) element, flags); break; case IJavaElement.PACKAGE_FRAGMENT: - appendPackageFragmentLabel((IPackageFragment) element, flags & QUALIFIER_FLAGS); + appendPackageFragmentLabel((IPackageFragment) element, flags); break; case IJavaElement.PACKAGE_FRAGMENT_ROOT: appendPackageFragmentRootLabel((IPackageFragmentRoot) element, flags); |

