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 227521 Details for
Bug 400062
[hovering][javadoc] Failure to access attached Javadoc should be shown to the user
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Requests
|
Help
|
Log In
[x]
|
Terms of Use
|
Copyright Agent
[patch]
Fix and Testcase.
400062_HandlePreviouslyIgnoredExceptions_20130225.patch (text/plain), 13.39 KB, created by
Martin Mathew
on 2013-02-25 01:37:15 EST
(
hide
)
Description:
Fix and Testcase.
Filename:
MIME Type:
Creator:
Martin Mathew
Created:
2013-02-25 01:37:15 EST
Size:
13.39 KB
patch
obsolete
>diff --git a/org.eclipse.jdt.ui.tests/ui/org/eclipse/jdt/ui/tests/packageHover/PackageJavadocTests.java b/org.eclipse.jdt.ui.tests/ui/org/eclipse/jdt/ui/tests/packageHover/PackageJavadocTests.java >index f8c69ff..9ae5547 100644 >--- a/org.eclipse.jdt.ui.tests/ui/org/eclipse/jdt/ui/tests/packageHover/PackageJavadocTests.java >+++ b/org.eclipse.jdt.ui.tests/ui/org/eclipse/jdt/ui/tests/packageHover/PackageJavadocTests.java >@@ -229,7 +229,8 @@ > Assert.assertTrue(actualHtmlContent.contains("Provides classes for performing arbitrary-precision integer arithmetic")); > } catch (Exception e) { > //there is no internet connection, so the Javadoc cannot be retrieved. >- Assert.assertTrue(actualHtmlContent.contains(CorextMessages.JavaDocLocations_noAttachedSource) || actualHtmlContent.contains(CorextMessages.JavaDocLocations_error_gettingJavadoc)); >+ Assert.assertTrue(actualHtmlContent.contains(CorextMessages.JavaDocLocations_noAttachedSource) || actualHtmlContent.contains(CorextMessages.JavaDocLocations_error_gettingJavadoc) >+ || actualHtmlContent.contains(CorextMessages.JavaDocLocations_error_gettingAttachedJavadoc)); > } > > } >@@ -291,6 +292,42 @@ > Assert.assertTrue(actualHtmlContent.contains(CorextMessages.JavaDocLocations_noAttachedJavadoc)); > } > >+ public void testErrotGettingAttachedJavadoc() throws Exception { >+ File junitSrcArchive= JavaTestPlugin.getDefault().getFileInPlugin(new Path("testresources/PackageJavadocTests/JavadocHover_src.zip")); >+ >+ assertTrue("junit src not found", junitSrcArchive != null && junitSrcArchive.exists()); >+ >+ JavaProjectHelper.addSourceContainerWithImport(fJProject1, "src", junitSrcArchive, JavaProjectHelper.JUNIT_SRC_ENCODING); >+ ICompilationUnit cu= (ICompilationUnit)fJProject1.findElement(new Path("junit/javadochoverhtml/JavaDocHoverTest.java")); >+ assertNotNull("JavaDocHoverTest.java", cu); >+ >+ //set a wrong Javadoc location URL >+ IClasspathAttribute attribute= >+ JavaCore.newClasspathAttribute( >+ IClasspathAttribute.JAVADOC_LOCATION_ATTRIBUTE_NAME, >+ "url:http://download.oracle.com/javase/6/docs/apii/"); >+ IClasspathEntry[] rawClasspath= fJProject1.getRawClasspath(); >+ IClasspathEntry newEntry= JavaCore.newLibraryEntry(new Path(JavaTestPlugin.getDefault().getFileInPlugin(new Path("/testresources/rtstubs15.jar")).getAbsolutePath()), null, null, null, >+ new IClasspathAttribute[] { attribute }, false); >+ rawClasspath[0]= newEntry; >+ IClasspathEntry[] newPathEntry= new IClasspathEntry[] { rawClasspath[0], rawClasspath[1] }; >+ this.fJProject1.setRawClasspath(newPathEntry, null); >+ this.fJProject1.getResolvedClasspath(false); >+ >+ int offset= cu.getSource().indexOf("java.math"); >+ int length= "java.math".length(); >+ IJavaElement[] codeSelect= cu.codeSelect(offset, length); >+ Assert.assertNotNull(codeSelect); >+ Assert.assertTrue("No package found !", codeSelect.length > 0); >+ >+ JavadocBrowserInformationControlInput hoverInfo= JavadocHover.getHoverInfo(codeSelect, cu, new Region(offset, length), null); >+ String actualHtmlContent= hoverInfo.getHtml(); >+ Assert.assertNotNull(actualHtmlContent); >+ >+ Assert.assertTrue(actualHtmlContent.contains(CorextMessages.JavaDocLocations_error_gettingAttachedJavadoc)); >+ >+ } >+ > public static Test setUpTest(Test test) { > return new ProjectTestSetup(test); > } >diff --git a/org.eclipse.jdt.ui/core extension/org/eclipse/jdt/internal/corext/CorextMessages.java b/org.eclipse.jdt.ui/core extension/org/eclipse/jdt/internal/corext/CorextMessages.java >index 338adbd..365b0da 100644 >--- a/org.eclipse.jdt.ui/core extension/org/eclipse/jdt/internal/corext/CorextMessages.java >+++ b/org.eclipse.jdt.ui/core extension/org/eclipse/jdt/internal/corext/CorextMessages.java >@@ -1,5 +1,5 @@ > /******************************************************************************* >- * Copyright (c) 2000, 2012 IBM Corporation and others. >+ * Copyright (c) 2000, 2013 IBM Corporation and others. > * All rights reserved. This program and the accompanying materials > * are made available under the terms of the Eclipse Public License v1.0 > * which accompanies this distribution, and is available at >@@ -26,6 +26,7 @@ > public static String Resources_fileModified; > > public static String JavaDocLocations_migrate_operation; >+ public static String JavaDocLocations_error_gettingAttachedJavadoc; > public static String JavaDocLocations_error_gettingJavadoc; > public static String JavaDocLocations_error_readXML; > public static String JavaDocLocations_migratejob_name; >diff --git a/org.eclipse.jdt.ui/core extension/org/eclipse/jdt/internal/corext/CorextMessages.properties b/org.eclipse.jdt.ui/core extension/org/eclipse/jdt/internal/corext/CorextMessages.properties >index 7801e94..5a99503 100644 >--- a/org.eclipse.jdt.ui/core extension/org/eclipse/jdt/internal/corext/CorextMessages.properties >+++ b/org.eclipse.jdt.ui/core extension/org/eclipse/jdt/internal/corext/CorextMessages.properties >@@ -1,5 +1,5 @@ > ############################################################################### >-# Copyright (c) 2000, 2012 IBM Corporation and others. >+# Copyright (c) 2000, 2013 IBM Corporation and others. > # All rights reserved. This program and the accompanying materials > # are made available under the terms of the Eclipse Public License v1.0 > # which accompanies this distribution, and is available at >@@ -14,6 +14,7 @@ > Resources_fileModified= File ''{0}'' has been modified since the beginning of the operation > > JavaDocLocations_migrate_operation=Migrate Javadoc locations to build path attributes... >+JavaDocLocations_error_gettingAttachedJavadoc=<em>Note: The attached Javadoc could not be retrieved as the specified Javadoc location is either wrong or currently not accessible.</em> > JavaDocLocations_error_gettingJavadoc=<em>Note: An exception occurred while getting the Javadoc. See log for details.</em> > JavaDocLocations_error_readXML=Problems while reading the Javadoc locations from XML > JavaDocLocations_migratejob_name=Migrate Javadoc locations to build path attributes >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 28a5480..71aa8b7 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 >@@ -67,6 +67,7 @@ > import org.eclipse.jdt.core.IField; > import org.eclipse.jdt.core.IImportDeclaration; > import org.eclipse.jdt.core.IJavaElement; >+import org.eclipse.jdt.core.IJavaModelStatusConstants; > import org.eclipse.jdt.core.IJavaProject; > import org.eclipse.jdt.core.IMember; > import org.eclipse.jdt.core.IMethod; >@@ -670,6 +671,26 @@ > } > > /** >+ * Handles the exception thrown from <code>org.eclipse.jdt.core</code> when the attached Javadoc >+ * cannot be retrieved due to accessibility issues or location URL issue. This exception is not >+ * logged but the exceptions occurred due to other reasons are logged. >+ * >+ * @param e the exception thrown when retrieving the Javadoc fails >+ * @return the String message for why the Javadoc could not be retrieved >+ */ >+ public static String handleFailedJavadocFetch(CoreException e) { >+ //filter the exception thrown from JavaElement while trying to fetch the attached Javadoc >+ if (e.getCause() instanceof IOException) { >+ IStatus status= e.getStatus(); >+ if (status.getCode() == IJavaModelStatusConstants.CANNOT_RETRIEVE_ATTACHED_JAVADOC && JavaCore.PLUGIN_ID.equals(status.getPlugin())) { >+ return CorextMessages.JavaDocLocations_error_gettingAttachedJavadoc; >+ } >+ } >+ JavaPlugin.log(e); >+ return CorextMessages.JavaDocLocations_error_gettingJavadoc; >+ } >+ >+ /** > * Parse a URL from a String. This method first tries to treat <code>url</code> as a valid, encoded URL. > * If that didn't work, it tries to recover from bad URLs, e.g. the unencoded form we used to use in persistent storage. > * >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 7a11720..4c0a811 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 >@@ -465,7 +465,7 @@ > private LinkAction fToggleLinkAction; > > /** >- * Action to open the attached Javadoc. >+ * Action to open the attached Javadoc. > * @since 3.4 > */ > private OpenInBrowserAction fOpenBrowserAction; >@@ -1081,8 +1081,7 @@ > content= JavadocContentAccess2.getHTMLContent((IPackageFragment) curr); > } > } catch (CoreException e) { >- reader= new StringReader(InfoViewMessages.JavadocView_error_gettingJavadoc); >- JavaPlugin.log(e); >+ reader= new StringReader(JavaDocLocations.handleFailedJavadocFetch(e)); > } > IPackageFragmentRoot root= (IPackageFragmentRoot) curr.getAncestor(IJavaElement.PACKAGE_FRAGMENT_ROOT); > try { >@@ -1090,7 +1089,7 @@ > if (content != null) { > base= JavaDocLocations.getBaseURL(curr, isBinary); > reader= new StringReader(content); >- } else { >+ } else if (reader == null) { > String explanationForMissingJavadoc= JavaDocLocations.getExplanationForMissingJavadoc(curr, root); > if (explanationForMissingJavadoc != null) { > reader= new StringReader(explanationForMissingJavadoc); >@@ -1141,8 +1140,7 @@ > } > } > } catch (JavaModelException ex) { >- reader= new StringReader(InfoViewMessages.JavadocView_error_gettingJavadoc); >- JavaPlugin.log(ex.getStatus()); >+ reader= new StringReader(JavaDocLocations.handleFailedJavadocFetch(ex)); > } > if (reader != null) { > HTMLPrinter.addParagraph(buffer, reader); >@@ -1242,7 +1240,7 @@ > @Override > protected IJavaElement findSelectedJavaElement(IWorkbenchPart part, ISelection selection) { > IJavaElement element= super.findSelectedJavaElement(part, selection); >- try { >+ try { > //update the Javadoc view when package.html is selected in project explorer view > if (element == null && selection instanceof IStructuredSelection) { > Object selectedElement= ((IStructuredSelection) selection).getFirstElement(); >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 51305ac..eaaa8a9 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 >@@ -19,7 +19,8 @@ > import org.eclipse.jdt.core.IPackageFragment; > import org.eclipse.jdt.core.JavaModelException; > >-import org.eclipse.jdt.internal.ui.JavaPlugin; >+import org.eclipse.jdt.internal.corext.javadoc.JavaDocLocations; >+ > import org.eclipse.jdt.internal.ui.text.javadoc.JavadocContentAccess2; > > >@@ -75,7 +76,7 @@ > final IJavaElement javaElement= getJavaElement(); > return extractJavadoc(javaElement); > } catch (CoreException e) { >- JavaPlugin.log(e); >+ JavaDocLocations.handleFailedJavadocFetch(e); > } > return null; > } >diff --git a/org.eclipse.jdt.ui/ui/org/eclipse/jdt/internal/ui/text/java/hover/JavaHoverMessages.java b/org.eclipse.jdt.ui/ui/org/eclipse/jdt/internal/ui/text/java/hover/JavaHoverMessages.java >index af4b4f0..d5d377f 100644 >--- a/org.eclipse.jdt.ui/ui/org/eclipse/jdt/internal/ui/text/java/hover/JavaHoverMessages.java >+++ b/org.eclipse.jdt.ui/ui/org/eclipse/jdt/internal/ui/text/java/hover/JavaHoverMessages.java >@@ -32,7 +32,6 @@ > public static String JavadocHover_back; > public static String JavadocHover_back_toElement_toolTip; > public static String JavadocHover_constantValue_hexValue; >- public static String JavadocHover_error_gettingJavadoc; > public static String JavadocHover_forward; > public static String JavadocHover_forward_toElement_toolTip; > public static String JavadocHover_forward_toolTip; >diff --git a/org.eclipse.jdt.ui/ui/org/eclipse/jdt/internal/ui/text/java/hover/JavaHoverMessages.properties b/org.eclipse.jdt.ui/ui/org/eclipse/jdt/internal/ui/text/java/hover/JavaHoverMessages.properties >index 6765a2e..7201da4 100644 >--- a/org.eclipse.jdt.ui/ui/org/eclipse/jdt/internal/ui/text/java/hover/JavaHoverMessages.properties >+++ b/org.eclipse.jdt.ui/ui/org/eclipse/jdt/internal/ui/text/java/hover/JavaHoverMessages.properties >@@ -25,7 +25,6 @@ > JavadocHover_back_toElement_toolTip=Back to {0} > # The first parameter is the constant value string and the second is its hex representation > JavadocHover_constantValue_hexValue={0} [{1}] >-JavadocHover_error_gettingJavadoc= <em>Note: An exception occurred while getting the Javadoc. See log for details.</em> > JavadocHover_forward= Forward > JavadocHover_forward_toElement_toolTip=Forward to {0} > JavadocHover_forward_toolTip=Forward >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 b70fbb9..b0e49f9 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 >@@ -704,8 +704,7 @@ > reader= new StringReader(explanationForMissingJavadoc); > } > } catch (CoreException ex) { >- reader= new StringReader(JavaHoverMessages.JavadocHover_error_gettingJavadoc); >- JavaPlugin.log(ex); >+ reader= new StringReader(JavaDocLocations.handleFailedJavadocFetch(ex)); > } > > if (reader != null) {
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 400062
:
227457
| 227521