--- a/java.source/apichanges.xml +++ a/java.source/apichanges.xml @@ -108,6 +108,19 @@ + + + Added SourceUtils.getJVMSignature to obtain the JVM signature for an ElementHandle + + + + + + Added a method SourceUtils.getJVMSignature to obtain the JVM signature for an ElementHandle. + + + + Added several methods to CodeStyle to support reformatting of comments. --- a/java.source/nbproject/project.properties +++ a/java.source/nbproject/project.properties @@ -46,7 +46,7 @@ javadoc.title=Java Source javadoc.arch=${basedir}/arch.xml javadoc.apichanges=${basedir}/apichanges.xml -spec.version.base=0.83.0 +spec.version.base=0.84.0 test.qa-functional.cp.extra=${refactoring.java.dir}/modules/ext/javac-api-nb-7.0-b07.jar test.unit.run.cp.extra=${o.n.core.dir}/core/core.jar:\ ${o.n.core.dir}/lib/boot.jar:\ --- a/java.source/src/org/netbeans/api/java/source/ElementHandle.java +++ a/java.source/src/org/netbeans/api/java/source/ElementHandle.java @@ -49,6 +49,7 @@ import com.sun.tools.javac.code.Symtab; import com.sun.tools.javac.jvm.Target; import com.sun.tools.javac.model.JavacElements; +import java.util.Arrays; import java.util.List; import java.util.logging.Logger; import java.util.logging.Level; @@ -554,6 +555,13 @@ public T resolve(ElementHandle handle, JavacTaskImpl jti) { return handle.resolveImpl (jti); } + + @Override + @NonNull + public String[] getJVMSignature(@NonNull final ElementHandle handle) { + return Arrays.copyOf(handle.signatures, handle.signatures.length); + } + } private static Element getTypeElementByBinaryName (final String signature, final JavacTaskImpl jt) { --- a/java.source/src/org/netbeans/api/java/source/SourceUtils.java +++ a/java.source/src/org/netbeans/api/java/source/SourceUtils.java @@ -98,6 +98,7 @@ import org.netbeans.api.lexer.TokenHierarchy; import org.netbeans.api.lexer.TokenSequence; import org.netbeans.modules.java.JavaDataLoader; +import org.netbeans.modules.java.source.ElementHandleAccessor; import org.netbeans.modules.java.source.JavadocHelper; import org.netbeans.modules.java.source.indexing.JavaCustomIndexer; import org.netbeans.modules.java.source.parsing.ClasspathInfoProvider; @@ -245,7 +246,25 @@ return (TypeElement)ec; } - + + /** + * Returns an array containing the JVM signature of the {@link ElementHandle}. + * @param handle to obtain the JVM signature for. + * @return an array containing the JVM signature. The signature depends on + * the {@link ElementHandle}'s {@link ElementKind}. For class or package + * it returns a single element array containing the class (package) binary + * name (JLS section 13.1). For field (method) it returns three element array + * containing owner class binary name (JLS section 13.1) in the first element, + * field (method) name in the second element and JVM type (JVM method formal + * parameters (JVMS section 2.10.1)) in the third element. + */ + @NonNull + public static String[] getJVMSignature(@NonNull final ElementHandle handle) { + Parameters.notNull("handle", handle); //NOI18N + return ElementHandleAccessor.INSTANCE.getJVMSignature(handle); + } + + /**Resolve full qualified name in the given context. Adds import statement as necessary. * Returns name that resolved to a given FQN in given context (either simple name * or full qualified name). Handles import conflicts. --- a/java.source/src/org/netbeans/modules/java/source/ElementHandleAccessor.java +++ a/java.source/src/org/netbeans/modules/java/source/ElementHandleAccessor.java @@ -47,6 +47,7 @@ import com.sun.tools.javac.api.JavacTaskImpl; import javax.lang.model.element.Element; import javax.lang.model.element.ElementKind; +import org.netbeans.api.annotations.common.NonNull; import org.netbeans.api.java.source.ElementHandle; /** @@ -74,6 +75,8 @@ public abstract ElementHandle create (ElementKind kind, String... descriptors); public abstract T resolve (ElementHandle handle, JavacTaskImpl jti); - - + + @NonNull + public abstract String[] getJVMSignature(@NonNull ElementHandle handle); + }