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.

View | Details | Raw Unified | Return to bug 210454
Collapse All | Expand All

(-)a/java.editor/src/org/netbeans/modules/editor/java/JavaCodeTemplateProcessor.java (+58 lines)
Lines 85-90 Link Here
85
    public static final String UNCAUGHT_EXCEPTION_TYPE = "uncaughtExceptionType"; //NOI18N
85
    public static final String UNCAUGHT_EXCEPTION_TYPE = "uncaughtExceptionType"; //NOI18N
86
    public static final String UNCAUGHT_EXCEPTION_CATCH_STATEMENTS = "uncaughtExceptionCatchStatements"; //NOI18N
86
    public static final String UNCAUGHT_EXCEPTION_CATCH_STATEMENTS = "uncaughtExceptionCatchStatements"; //NOI18N
87
    public static final String CURRENT_CLASS_NAME = "currClassName"; //NOI18N
87
    public static final String CURRENT_CLASS_NAME = "currClassName"; //NOI18N
88
    public static final String CURRENT_CLASS_FULL_NAME = "currClassFullName"; //NOI18N
89
    public static final String CURRENT_PACKAGE = "currPackage"; //NOI18N
88
90
89
    private static final String TRUE = "true"; //NOI18N
91
    private static final String TRUE = "true"; //NOI18N
90
    private static final String NULL = "null"; //NOI18N
92
    private static final String NULL = "null"; //NOI18N
Lines 123-128 Link Here
123
                        || CAST.equals(hint)
125
                        || CAST.equals(hint)
124
                        || NEW_VAR_NAME.equals(hint)
126
                        || NEW_VAR_NAME.equals(hint)
125
                        || CURRENT_CLASS_NAME.equals(hint)
127
                        || CURRENT_CLASS_NAME.equals(hint)
128
                        || CURRENT_CLASS_FULL_NAME.equals(hint)
129
                        || CURRENT_PACKAGE.equals(hint)
126
                        || ITERABLE_ELEMENT_TYPE.equals(hint)
130
                        || ITERABLE_ELEMENT_TYPE.equals(hint)
127
                        || UNCAUGHT_EXCEPTION_TYPE.equals(hint)) {
131
                        || UNCAUGHT_EXCEPTION_TYPE.equals(hint)) {
128
                    initParsing();
132
                    initParsing();
Lines 455-460 Link Here
455
            } else if (CURRENT_CLASS_NAME.equals(entry.getKey())) {
459
            } else if (CURRENT_CLASS_NAME.equals(entry.getKey())) {
456
                param2hints.put(param, CURRENT_CLASS_NAME);
460
                param2hints.put(param, CURRENT_CLASS_NAME);
457
                return owningClassName();
461
                return owningClassName();
462
            } else if (CURRENT_CLASS_FULL_NAME.equals(entry.getKey())) {
463
                param2hints.put(param, CURRENT_CLASS_FULL_NAME);
464
                return owningClassFullName();
465
            } else if (CURRENT_PACKAGE.equals(entry.getKey())) {
466
                param2hints.put(param, CURRENT_PACKAGE);
467
                return owningPackage();
458
            } else if (NAMED.equals(entry.getKey())) {
468
            } else if (NAMED.equals(entry.getKey())) {
459
                name = param.getName();
469
                name = param.getName();
460
            } else if (UNCAUGHT_EXCEPTION_TYPE.equals(entry.getKey())) {
470
            } else if (UNCAUGHT_EXCEPTION_TYPE.equals(entry.getKey())) {
Lines 836-841 Link Here
836
        }
846
        }
837
        return null;
847
        return null;
838
    }
848
    }
849
850
    private String owningClassFullName() {
851
        try {
852
            if (cInfo != null) {
853
                TreePath path = treePath;
854
                String classname = null;
855
                while ((path = Utilities.getPathElementOfKind (TreeUtilities.CLASS_TREE_KINDS, path)) != null) {
856
                    ClassTree tree = (ClassTree) path.getLeaf();
857
                    String result = tree.getSimpleName().toString();
858
                    if (result.length() > 0) {
859
                        if (classname == null) {
860
                            classname = result;
861
                        } else {
862
                            classname = result + '$' + classname;
863
                        }
864
                    }
865
                    path = path.getParentPath();
866
                }
867
868
                String packagename = owningPackage();
869
                if (packagename != null && !packagename.isEmpty()) {
870
                    classname = packagename + '.' + classname;
871
                }
872
873
                return classname;
874
            }
875
        } catch (Exception e) {
876
        }
877
        return null;
878
    }
879
880
    private String owningPackage() {
881
        try {
882
            if (cInfo != null) {
883
                TreePath path = treePath;
884
                while ((path = Utilities.getPathElementOfKind (Tree.Kind.COMPILATION_UNIT, path)) != null) {
885
                    CompilationUnitTree tree = (CompilationUnitTree)path.getLeaf();
886
                    String result = tree.getPackageName().toString();
887
                    if (result.length() > 0)
888
                        return result;
889
                    path = path.getParentPath();
890
                }
891
                return null;
892
            }
893
        } catch (Exception e) {
894
        }
895
        return null;
896
    }
839
    
897
    
840
    private TypeMirror uncaughtExceptionType(int caretOffset) {
898
    private TypeMirror uncaughtExceptionType(int caretOffset) {
841
        try {
899
        try {

Return to bug 210454