diff -r d8f6b85f7497 java.source/apichanges.xml --- a/java.source/apichanges.xml Wed Feb 24 15:36:37 2010 +0100 +++ b/java.source/apichanges.xml Wed Feb 24 17:23:33 2010 +0100 @@ -105,6 +105,21 @@ + + + Added SourceUtils.getAttributeValueCompletions method. + + + + + + Added SourceUtils.getAttributeValueCompletions method, which + returns a list of completions for an annotation attribute value suggested by + annotation processors. + + + + Added GeneratorUtilities.copyComments method. diff -r d8f6b85f7497 java.source/nbproject/project.properties --- a/java.source/nbproject/project.properties Wed Feb 24 15:36:37 2010 +0100 +++ b/java.source/nbproject/project.properties Wed Feb 24 17:23:33 2010 +0100 @@ -43,7 +43,7 @@ javadoc.title=Java Source javadoc.arch=${basedir}/arch.xml javadoc.apichanges=${basedir}/apichanges.xml -spec.version.base=0.55.0 +spec.version.base=0.56.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:\ diff -r d8f6b85f7497 java.source/src/org/netbeans/api/java/source/SourceUtils.java --- a/java.source/src/org/netbeans/api/java/source/SourceUtils.java Wed Feb 24 15:36:37 2010 +0100 +++ b/java.source/src/org/netbeans/api/java/source/SourceUtils.java Wed Feb 24 17:23:33 2010 +0100 @@ -49,6 +49,8 @@ import java.net.URL; import java.util.*; +import javax.annotation.processing.Completion; +import javax.annotation.processing.Processor; import javax.lang.model.element.*; import javax.lang.model.element.VariableElement; import javax.lang.model.type.ArrayType; @@ -94,6 +96,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.indexing.APTUtils; import org.netbeans.modules.java.source.indexing.JavaCustomIndexer; import org.netbeans.modules.java.source.indexing.JavaIndex; import org.netbeans.modules.java.source.parsing.ClasspathInfoProvider; @@ -167,7 +170,54 @@ Type.TypeVar bound = ((Type.WildcardType)wildcardType).bound; return bound != null ? bound.bound : null; } - + + /** + * Returns a list of completions for an annotation attribute value suggested by + * annotation processors. + * + * @param info the CompilationInfo used to resolve annotation processors + * @param element the element being annotated + * @param annotation the (perhaps partial) annotation being applied to the element + * @param member the annotation member to return possible completions for + * @param userText source code text to be completed + * @return suggested completions to the annotation member + * + * @since 0.56 + */ + public static List getAttributeValueCompletions(CompilationInfo info, Element element, AnnotationMirror annotation, ExecutableElement member, String userText) { + List completions = new LinkedList(); + if (info.getPhase().compareTo(Phase.ELEMENTS_RESOLVED) >= 0) { + String fqn = ((TypeElement) annotation.getAnnotationType().asElement()).getQualifiedName().toString(); + Iterable processors = info.impl.getJavacTask().getProcessors(); + if (processors != null) { + for (Processor processor : processors) { + boolean match = false; + for (String sat : processor.getSupportedAnnotationTypes()) { + if ("*".equals(sat)) { //NOI18N + match = true; + break; + } else if (sat.endsWith(".*")) { //NOI18N + sat = sat.substring(0, sat.length() - 1); + if (fqn.startsWith(sat)) { + match = true; + break; + } + } else if (fqn.equals(sat)) { + match = true; + break; + } + } + if (match) { + for (Completion c : processor.getCompletions(element, annotation, member, userText)) { + completions.add(c); + } + } + } + } + } + return completions; + } + /** * Returns the type element within which this member or constructor * is declared. Does not accept packages