Some Eclipse Foundation services are deprecated, or will be soon. Please ensure you've read this important communication.
Bug 332030 - [navigation] Open Declared Type hyperlink should not show up when the variable type is primitive
Summary: [navigation] Open Declared Type hyperlink should not show up when the variabl...
Status: VERIFIED FIXED
Alias: None
Product: JDT
Classification: Eclipse Project
Component: UI (show other bugs)
Version: 3.7   Edit
Hardware: PC Windows 7
: P3 trivial (vote)
Target Milestone: 3.7 M5   Edit
Assignee: Raksha Vasisht CLA
QA Contact:
URL:
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2010-12-07 10:07 EST by Markus Keller CLA
Modified: 2011-01-25 13:35 EST (History)
2 users (show)

See Also:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Markus Keller CLA 2010-12-07 10:07:52 EST
HEAD

Open Declared Type hyperlink should not show up when the variable type is primitive. Same as bug 331320.
Comment 1 Raksha Vasisht CLA 2011-01-11 02:07:19 EST
Fixed in HEAD in org.eclipse.jdt.internal.ui.javaeditor.JavaElementHyperlinkDeclaredTypeDetector.
Comment 2 Dani Megert CLA 2011-01-11 04:10:09 EST
The fix works, however, we should avoid the duplication of isPrimitive(...) either by adding a helper to JavaElementHyperlinkDetector or to JavaModelUtil.
Comment 3 Raksha Vasisht CLA 2011-01-11 07:23:51 EST
(In reply to comment #2)
> The fix works, however, we should avoid the duplication of isPrimitive(...)
> either by adding a helper to JavaElementHyperlinkDetector or to JavaModelUtil.

Added the helper method to JavaElementHyperlinkDetector.
Comment 4 Markus Keller CLA 2011-01-11 08:10:50 EST
(In reply to comment #3)
> Added the helper method to JavaElementHyperlinkDetector.

Reopening, I don't see that in HEAD.
Comment 5 Raksha Vasisht CLA 2011-01-12 02:16:07 EST
(In reply to comment #4)
> (In reply to comment #3)
> > Added the helper method to JavaElementHyperlinkDetector.
> 
> Reopening, I don't see that in HEAD.

Oops, my bad. I had fixed the duplication of check inside isPrimitive(..) but had not moved it to the util class. Now fixed by moving isPrimitive(..) to JavaModelUtil  as it might be more useful in a util class.
Comment 6 Dani Megert CLA 2011-01-12 11:44:16 EST
The fix is still not good as it can cause NPEs: take a closer look at 
JavaModelUtil.isPrimitive(getTypeSignature(element))
in JavaElementHyperlinkDeclaredTypeDetector.
Comment 7 Raksha Vasisht CLA 2011-01-13 01:37:48 EST
(In reply to comment #6)
> The fix is still not good as it can cause NPEs: take a closer look at 
> JavaModelUtil.isPrimitive(getTypeSignature(element))
> in JavaElementHyperlinkDeclaredTypeDetector.

No it cant cause an NPE since we already check for the element to be either a IJavaElement.FIELD or a IJavaElement.LOCAL_VARIABLE and the javadoc for these element types say that "A Java element with this type can be safely cast to IField/ILocalVariable" respectively. Pls reopen if you do see a NPE.
Comment 8 Dani Megert CLA 2011-01-13 03:38:04 EST
> Pls reopen if you do see a NPE.
It's my pleasure.
Comment 9 Dani Megert CLA 2011-01-13 13:06:51 EST
Mea culpa! I somehow had an old version of JavaElementHyperlinkDeclaredTypeDetector.getTypeSignature(IJavaElement) in my workspace which caught the exception and hence returned 'null'.

Having said that, we should improve getTypeSignature(...) and never return 'null': since we already specify that only field and local variable are allowed - I've done that in HEAD.

Sorry again!
Comment 10 Rajesh CLA 2011-01-25 13:35:21 EST
Verified for 3.7 M5 with I20110124-1800.