This Bugzilla instance is a read-only archive of historic NetBeans bug reports. To report a bug in NetBeans please follow the project's instructions for reporting issues.

Bug 104194

Summary: not possible to get FQN of TypeMirror
Product: java Reporter: Tomas Mysik <tmysik>
Component: SourceAssignee: apireviews <apireviews>
Status: RESOLVED FIXED    
Severity: blocker CC: abadea, jbecicka, jlahoda
Priority: P3 Keywords: API, API_REVIEW_FAST
Version: 6.x   
Hardware: All   
OS: All   
Issue Type: DEFECT Exception Reporter:
Attachments: Proposed API change.

Description Tomas Mysik 2007-05-17 16:26:04 UTC
See JavaDoc of toString() method of javax.lang.model.type.TypeMirror
Comment 1 Jan Lahoda 2007-06-18 15:40:06 UTC
I would not say it is not possible - check for kind (TypeMirror.getKind()). If kind is DECLARED, do:
((TypeElement) ((DeclaredType) tm).asElement()).getQualifiedName().toString()

I agree that this could be simpler - and leaving open as an enhancement to cover this - but it is possible to get the
FQN (whatever definition of FQN is appropriate in a given context). Actually, reasonable definition of FQN is probably
hardest part of creating utility to get FQN from a TypeMirror.
Comment 2 Andrei Badea 2007-06-18 16:42:32 UTC
It's not that simple, take for example

java.util.Map<String, java.util.List<String>>

Admittedly the method has a bit unclear semantics, one might want imports to be taken into account (to generate simple
names when possible). But still: the API is incomplete, thus I consider this a defect.
Comment 3 Jan Becicka 2008-11-13 14:35:59 UTC
Will resolve later
Comment 4 Quality Engineering 2009-11-02 11:04:32 UTC
NetBeans.org Migration: changing resolution from LATER to WONTFIX
Comment 5 Jan Lahoda 2010-06-29 09:40:30 UTC
Created attachment 100482 [details]
Proposed API change.
Comment 6 Jan Lahoda 2010-06-29 09:41:30 UTC
I would like to add method org.netbeans.api.java.source.TypeUtilities.getTypeName(TypeMirror, TypeNameOptions...), please review the change. Thanks.
Comment 7 Jan Lahoda 2010-07-13 08:50:11 UTC
Thanks for the review.

http://hg.netbeans.org/jet-main/rev/03bafe62dfb8
Comment 8 Quality Engineering 2010-07-14 02:44:34 UTC
Integrated into 'main-golden', will be available in build *201007140001* on http://bits.netbeans.org/dev/nightly/ (upload may still be in progress)
Changeset: http://hg.netbeans.org/main/rev/03bafe62dfb8
User: Jan Lahoda <jlahoda@netbeans.org>
Log: #104194: introducing TypeUtilities.getTypeName.