--- a/java.editor/src/org/netbeans/modules/editor/java/JavaCodeTemplateProcessor.java Thu Mar 29 15:33:54 2012 -0500 +++ a/java.editor/src/org/netbeans/modules/editor/java/JavaCodeTemplateProcessor.java Fri Mar 30 10:35:10 2012 -0500 @@ -85,6 +85,8 @@ public static final String UNCAUGHT_EXCEPTION_TYPE = "uncaughtExceptionType"; //NOI18N public static final String UNCAUGHT_EXCEPTION_CATCH_STATEMENTS = "uncaughtExceptionCatchStatements"; //NOI18N public static final String CURRENT_CLASS_NAME = "currClassName"; //NOI18N + public static final String CURRENT_CLASS_FULL_NAME = "currClassFullName"; //NOI18N + public static final String CURRENT_PACKAGE = "currPackage"; //NOI18N private static final String TRUE = "true"; //NOI18N private static final String NULL = "null"; //NOI18N @@ -123,6 +125,8 @@ || CAST.equals(hint) || NEW_VAR_NAME.equals(hint) || CURRENT_CLASS_NAME.equals(hint) + || CURRENT_CLASS_FULL_NAME.equals(hint) + || CURRENT_PACKAGE.equals(hint) || ITERABLE_ELEMENT_TYPE.equals(hint) || UNCAUGHT_EXCEPTION_TYPE.equals(hint)) { initParsing(); @@ -455,6 +459,12 @@ } else if (CURRENT_CLASS_NAME.equals(entry.getKey())) { param2hints.put(param, CURRENT_CLASS_NAME); return owningClassName(); + } else if (CURRENT_CLASS_FULL_NAME.equals(entry.getKey())) { + param2hints.put(param, CURRENT_CLASS_FULL_NAME); + return owningClassFullName(); + } else if (CURRENT_PACKAGE.equals(entry.getKey())) { + param2hints.put(param, CURRENT_PACKAGE); + return owningPackage(); } else if (NAMED.equals(entry.getKey())) { name = param.getName(); } else if (UNCAUGHT_EXCEPTION_TYPE.equals(entry.getKey())) { @@ -836,6 +846,54 @@ } return null; } + + private String owningClassFullName() { + try { + if (cInfo != null) { + TreePath path = treePath; + String classname = null; + while ((path = Utilities.getPathElementOfKind (TreeUtilities.CLASS_TREE_KINDS, path)) != null) { + ClassTree tree = (ClassTree) path.getLeaf(); + String result = tree.getSimpleName().toString(); + if (result.length() > 0) { + if (classname == null) { + classname = result; + } else { + classname = result + '$' + classname; + } + } + path = path.getParentPath(); + } + + String packagename = owningPackage(); + if (packagename != null && !packagename.isEmpty()) { + classname = packagename + '.' + classname; + } + + return classname; + } + } catch (Exception e) { + } + return null; + } + + private String owningPackage() { + try { + if (cInfo != null) { + TreePath path = treePath; + while ((path = Utilities.getPathElementOfKind (Tree.Kind.COMPILATION_UNIT, path)) != null) { + CompilationUnitTree tree = (CompilationUnitTree)path.getLeaf(); + String result = tree.getPackageName().toString(); + if (result.length() > 0) + return result; + path = path.getParentPath(); + } + return null; + } + } catch (Exception e) { + } + return null; + } private TypeMirror uncaughtExceptionType(int caretOffset) { try {