javax.lang.model.element.PackageElement Java Examples
The following examples show how to use
javax.lang.model.element.PackageElement.
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: AbstractPackageIndexWriter.java From openjdk-jdk9 with GNU General Public License v2.0 | 6 votes |
/** * Adds package index contents. Call appropriate methods from * the sub-classes. Adds it to the body HtmlTree * * @param packages a collection of packages to be documented * @param text string which will be used as the heading * @param tableSummary summary for the table * @param body the document tree to which the index contents will be added */ protected void addIndexContents(Collection<PackageElement> packages, String text, String tableSummary, Content body) { if (!packages.isEmpty()) { HtmlTree htmlTree = (configuration.allowTag(HtmlTag.NAV)) ? HtmlTree.NAV() : new HtmlTree(HtmlTag.DIV); htmlTree.addStyle(HtmlStyle.indexNav); HtmlTree ul = new HtmlTree(HtmlTag.UL); addAllClassesLink(ul); if (configuration.showModules && configuration.modules.size() > 1) { addAllModulesLink(ul); } htmlTree.addContent(ul); body.addContent(htmlTree); addPackagesList(packages, text, tableSummary, body); } }
Example #2
Source File: JavacPackageInfo.java From netbeans with Apache License 2.0 | 6 votes |
@Override public Collection<SourceClassInfo> getClasses() { final List<SourceClassInfo> clzs = new ArrayList<SourceClassInfo>(); ParsingUtils.invokeScanSensitiveTask(cpInfo, new ScanSensitiveTask<CompilationController> () { @Override public void run(CompilationController cc) throws Exception { cc.toPhase(JavaSource.Phase.PARSED); PackageElement pelem = cc.getElements().getPackageElement(getSimpleName()); if (pelem != null) { for (TypeElement type : ElementFilter.typesIn(pelem.getEnclosedElements())) { if ((type.getKind() == ElementKind.CLASS) || (type.getKind() == ElementKind.ENUM)) { clzs.add(new JavacClassInfo(ElementHandle.create(type), indexInfo)); } } } else { LOGGER.log(Level.FINEST, "Package name {0} resulted into a NULL element", getBinaryName()); // NOI18N } } }); return clzs; }
Example #3
Source File: DeptectiveTreeVisitor.java From deptective with Apache License 2.0 | 6 votes |
/** * Returns the qualified Package Name of the given Tree object or null if the package could not be determined */ protected String getQualifiedPackageName(Tree tree) { TypeMirror typeMirror = trees.getTypeMirror(getCurrentPath()); if (typeMirror == null) { return null; } if (typeMirror.getKind() != TypeKind.DECLARED && typeMirror.getKind() != TypeKind.TYPEVAR) { return null; } Element typeMirrorElement = types.asElement(typeMirror); if (typeMirrorElement == null) { throw new IllegalStateException("Could not get Element for type '" + typeMirror + "'"); } PackageElement pakkage = elements.getPackageOf(typeMirrorElement); return pakkage.getQualifiedName().toString(); }
Example #4
Source File: PackagePrefixes.java From j2objc with Apache License 2.0 | 6 votes |
/** * Return the prefix for a specified package. If a prefix was specified * for the package, then that prefix is returned. Otherwise, a camel-cased * prefix is created from the package name. */ public String getPrefix(PackageElement packageElement) { if (packageElement == null) { return ""; } String packageName = packageElement.getQualifiedName().toString(); String prefix = getPrefix(packageName); if (prefix != null) { return prefix; } prefix = packageLookup.getObjectiveCName(packageName); if (prefix == null) { AnnotationMirror annotation = ElementUtil.getAnnotation(packageElement, ObjectiveCName.class); if (annotation != null) { prefix = (String) ElementUtil.getAnnotationValue(annotation, "value"); } } if (prefix == null) { prefix = NameTable.camelCaseQualifiedName(packageName); } addPrefix(packageName, prefix); return prefix; }
Example #5
Source File: TypeDefElementVisitor.java From sundrio with Apache License 2.0 | 6 votes |
public TypeDefBuilder visit(Element e) { if (e instanceof TypeElement) { return new TypeDefBuilder(ElementTo.TYPEDEF.apply((TypeElement) e)); } String name = e.getSimpleName().toString(); builder.withName(name); if (e.getKind() == ElementKind.INTERFACE) { builder.withKind(Kind.INTERFACE); } else if (e.getKind() == ElementKind.ENUM) { builder.withKind(Kind.ENUM); }else if (e.getKind() == ElementKind.ANNOTATION_TYPE) { builder.withKind(Kind.ANNOTATION); } else { builder.withKind(Kind.CLASS); } if (e.getEnclosingElement() instanceof PackageElement) { String packageName = e.getEnclosingElement().toString(); builder.withPackageName(packageName); } return builder; }
Example #6
Source File: MemberAdditionTest.java From netbeans with Apache License 2.0 | 6 votes |
public void testEmptyClass() throws Exception { performTest("EmptyClass"); source.runModificationTask(new Task<WorkingCopy>() { public void run(WorkingCopy copy) throws IOException { copy.toPhase(Phase.RESOLVED); ClassTree topLevel = findTopLevelClass(copy); SourceUtilsTestUtil2.run(copy, new AddSimpleField(), topLevel); } }).commit(); JavaSourceAccessor.getINSTANCE().revalidate(source); CompilationInfo check = SourceUtilsTestUtil.getCompilationInfo(source, Phase.RESOLVED); CompilationUnitTree cu = check.getCompilationUnit(); assertEquals(check.getDiagnostics().toString(), 0, check.getDiagnostics().size()); ClassTree newTopLevel = findTopLevelClass(check); Element clazz = check.getTrees().getElement(TreePath.getPath(cu, newTopLevel)); Element pack = clazz.getEnclosingElement(); assertEquals(ElementKind.PACKAGE, pack.getKind()); assertEquals("test", ((PackageElement) pack).getQualifiedName().toString()); assertEquals(clazz.getEnclosedElements().toString(), 1 + 1/*syntetic default constructor*/, clazz.getEnclosedElements().size()); }
Example #7
Source File: ElementsTable.java From openjdk-jdk9 with GNU General Public License v2.0 | 6 votes |
private Set<PackageElement> getAllModulePackages(ModuleElement mdle) throws ToolException { Set<PackageElement> result = new HashSet<>(); ModuleSymbol msym = (ModuleSymbol) mdle; List<Location> msymlocs = getModuleLocation(locations, msym.name.toString()); for (Location msymloc : msymlocs) { for (JavaFileObject fo : fmList(msymloc, "", sourceKinds, true)) { if (fo.getName().endsWith("module-info.java")) { continue; } String binaryName = fm.inferBinaryName(msymloc, fo); String pn = getPackageName(binaryName); PackageSymbol psym = syms.enterPackage(msym, names.fromString(pn)); result.add((PackageElement) psym); } } return result; }
Example #8
Source File: ClasspathInfoTest.java From netbeans with Apache License 2.0 | 6 votes |
public void testGetPackageDeclaration() throws Exception { ClasspathInfo ci = ClasspathInfo.create( bootPath, classPath, null); JavaFileManager fm = ClasspathInfoAccessor.getINSTANCE().createFileManager(ci, null); JarFile jf = new JarFile( rtJar ); for( Enumeration entries = jf.entries(); entries.hasMoreElements(); ) { JarEntry je = (JarEntry)entries.nextElement(); String jeName = je.getName(); if ( je.isDirectory() ) { String packageName = jeName.replace( "/", "." ); if ( !fm.list( StandardLocation.PLATFORM_CLASS_PATH,packageName, EnumSet.of( JavaFileObject.Kind.CLASS ), false).iterator().hasNext() ) { // empty package continue; } PackageElement pd = JavacParser.createJavacTask(ci, (DiagnosticListener) null, (String) null, null, null, null, null, null, Collections.emptyList()).getElements().getPackageElement( packageName ); assertNotNull( "Declaration for " + packageName + " should not be null.", pd ); } } }
Example #9
Source File: ClassIndex.java From netbeans with Apache License 2.0 | 6 votes |
/** * Returns a set of {@link ElementHandle}s containing reference(s) to given package element. * @param element the {@link ElementHandle} of a {@link PackageElement} for which usages should be found * @param searchKind type of reference, {@see SearchKind} * @param scope to search in {@see SearchScope} * @return set of {@link ElementHandle}s containing the reference(s) * It may return null when the caller is a CancellableTask<CompilationInfo> and is cancelled * inside call of this method. * @since 0.89 */ public @NullUnknown Set<ElementHandle<TypeElement>> getElementsForPackage ( final @NonNull ElementHandle<PackageElement> element, final @NonNull Set<SearchKind> searchKind, final @NonNull Set<? extends SearchScopeType> scope) { return searchImpl( element, searchKind, scope, new Convertor<ClassIndexImpl, Convertor<Document,ElementHandle<TypeElement>>>(){ @NonNull @Override public Convertor<Document, ElementHandle<TypeElement>> convert(@NonNull final ClassIndexImpl p) { return DocumentUtil.typeElementConvertor(); } }); }
Example #10
Source File: ReferencesCount.java From netbeans with Apache License 2.0 | 6 votes |
/** * Returns all packages used by classes on given source path (source root). * @return the used packages */ @NonNull public Iterable<? extends ElementHandle<? extends PackageElement>> getUsedPackages() { try { init(); return new AsHandlesIterable<String, ElementHandle<PackageElement>>( pkgFreqs.keySet(), new Convertor<String, ElementHandle<PackageElement>>() { @NonNull @Override public ElementHandle<PackageElement> convert(@NonNull final String p) { return ElementHandleAccessor.getInstance().create(ElementKind.PACKAGE, p); } }); } catch (InterruptedException ie) { return Collections.<ElementHandle<PackageElement>>emptySet(); } }
Example #11
Source File: SourceToHTMLConverter.java From openjdk-jdk9 with GNU General Public License v2.0 | 6 votes |
void generate() throws DocFileIOException, SimpleDocletException { if (docEnv == null || outputdir == null) { return; } for (PackageElement pkg : configuration.getSpecifiedPackageElements()) { // If -nodeprecated option is set and the package is marked as deprecated, // do not convert the package files to HTML. if (!(configuration.nodeprecated && utils.isDeprecated(pkg))) convertPackage(pkg, outputdir); } for (TypeElement te : configuration.getSpecifiedTypeElements()) { // If -nodeprecated option is set and the class is marked as deprecated // or the containing package is deprecated, do not convert the // package files to HTML. if (!(configuration.nodeprecated && (utils.isDeprecated(te) || utils.isDeprecated(utils.containingPackage(te))))) convertClass(te, outputdir); } }
Example #12
Source File: SPIProcessor.java From core with GNU Lesser General Public License v2.1 | 6 votes |
@SuppressWarnings("unchecked") private void handleBeanFactoryElement(Element element) { List<? extends AnnotationMirror> annotationMirrors = element.getAnnotationMirrors(); for (AnnotationMirror mirror : annotationMirrors) { final String annotationType = mirror.getAnnotationType().toString(); if (annotationType.equals(BeanFactoryExtension.class.getName())) { PackageElement packageElement = processingEnv.getElementUtils().getPackageOf(element); String fqn = packageElement.getQualifiedName().toString() + "." + element.getSimpleName().toString(); System.out.println("Factory: " + fqn); discoveredBeanFactories.add(fqn); } else if (annotationType.equals("com.google.web.bindery.autobean.shared.AutoBeanFactory.Category")) { final Collection<? extends AnnotationValue> values = mirror.getElementValues().values(); if (values.size() > 0) { for (AnnotationValue categoryClass : (List<? extends AnnotationValue>) values.iterator().next() .getValue()) { categoryClasses.add(categoryClass.getValue().toString()); } } } } }
Example #13
Source File: HeaderMap.java From j2objc with Apache License 2.0 | 6 votes |
public String get(TypeElement type) { String explicitHeader = ElementUtil.getHeader(type); if (explicitHeader != null) { return explicitHeader; } String qualifiedName = ElementUtil.getQualifiedName(type); String mappedHeader = map.get(qualifiedName); if (mappedHeader != null) { return mappedHeader; } String name = inferSourceName(type); PackageElement pkg = ElementUtil.getPackage(type); return outputDirFromPackage(pkg) + name + ".h"; }
Example #14
Source File: Utils.java From openjdk-jdk9 with GNU General Public License v2.0 | 6 votes |
public boolean isSpecified(Element e) { if (specifiedVisitor == null) { specifiedVisitor = new SimpleElementVisitor9<Boolean, Void>() { @Override public Boolean visitModule(ModuleElement e, Void p) { return configuration.getSpecifiedModuleElements().contains(e); } @Override public Boolean visitPackage(PackageElement e, Void p) { return configuration.getSpecifiedPackageElements().contains(e); } @Override public Boolean visitType(TypeElement e, Void p) { return configuration.getSpecifiedTypeElements().contains(e); } @Override protected Boolean defaultAction(Element e, Void p) { return false; } }; } return specifiedVisitor.visit(e); }
Example #15
Source File: TreeBackedTypeResolutionSimulator.java From buck with Apache License 2.0 | 6 votes |
@Override protected TreeBackedResolvedType resolvePackage( TreePath referencingPath, PackageElement referencedPackage, QualifiedNameable canonicalPackage) { // PackageElements are not considered to be enclosed by their parent elements, but // our logic is a lot simpler if we can pretend they are. TreeBackedResolvedType enclosingElement = null; String qualifiedName = canonicalPackage.getQualifiedName().toString(); int lastDot = qualifiedName.lastIndexOf('.'); if (lastDot > 0) { String enclosingPackageQualifiedName = qualifiedName.substring(0, lastDot); PackageElement enclosingPackage = Objects.requireNonNull( MoreElements.getPackageElementEvenIfEmpty(elements, enclosingPackageQualifiedName)); enclosingElement = resolveEnclosingElement(enclosingPackage); } return new TreeBackedResolvedType(referencingPath, canonicalPackage, enclosingElement); }
Example #16
Source File: ElementOverlay.java From netbeans with Apache License 2.0 | 5 votes |
private Element createElement(ASTService ast, Elements elements, String name, Element original, ModuleElement modle) { Element el = elementCache.get(name); if (el == null) { if (original != null) { if (original.getKind().isClass() || original.getKind().isInterface()) { elementCache.put(name, el = new TypeElementWrapper(ast, elements, (TypeElement) original)); return el; } if (original.getKind() == ElementKind.PACKAGE) { elementCache.put(name, el = new PackageElementWrapper(ast, elements, (PackageElement) original)); return el; } return original; } int lastDot = name.lastIndexOf('.'); Name simpleName = elements.getName(name.substring(lastDot + 1)); Name fqnName = elements.getName(name); if (classes.containsKey(name)) { Element parent = lastDot > 0 ? resolve(ast, elements, name.substring(0, lastDot), modle) : elements.getPackageElement(""); elementCache.put(name, el = new FakeTypeElement(ast, elements, simpleName, fqnName, name, parent, classes.get(name), modle)); } else if (packages.contains(name)) { elementCache.put(name, el = new FakePackageElement(ast, elements, fqnName, name, simpleName, modle)); } else { return null;//XXX: handling of this null in callers! } } return el; }
Example #17
Source File: MatchProcessor.java From openjdk-jdk9 with GNU General Public License v2.0 | 5 votes |
private String findPackage(Element type) { PackageElement p = processingEnv.getElementUtils().getPackageOf(type); if (p != null) { return p.getQualifiedName().toString(); } throw new GraalError("can't find package for %s", type); }
Example #18
Source File: WebServiceVisitor.java From openjdk-8 with GNU General Public License v2.0 | 5 votes |
protected void preProcessWebService(WebService webService, TypeElement element) { processedMethods = new HashSet<String>(); seiContext = context.getSeiContext(element); String targetNamespace = null; if (webService != null) targetNamespace = webService.targetNamespace(); PackageElement packageElement = builder.getProcessingEnvironment().getElementUtils().getPackageOf(element); if (targetNamespace == null || targetNamespace.length() == 0) { String packageName = packageElement.getQualifiedName().toString(); if (packageName == null || packageName.length() == 0) { builder.processError(WebserviceapMessages.WEBSERVICEAP_NO_PACKAGE_CLASS_MUST_HAVE_TARGETNAMESPACE( element.getQualifiedName()), element); } targetNamespace = RuntimeModeler.getNamespace(packageName); } seiContext.setNamespaceUri(targetNamespace); if (serviceImplName == null) serviceImplName = seiContext.getSeiImplName(); if (serviceImplName != null) { seiContext.setSeiImplName(serviceImplName); context.addSeiContext(serviceImplName, seiContext); } portName = ClassNameInfo.getName(element.getSimpleName().toString().replace('$', '_')); packageName = packageElement.getQualifiedName(); portName = webService != null && webService.name() != null && webService.name().length() > 0 ? webService.name() : portName; serviceName = ClassNameInfo.getName(element.getQualifiedName().toString()) + WebServiceConstants.SERVICE.getValue(); serviceName = webService != null && webService.serviceName() != null && webService.serviceName().length() > 0 ? webService.serviceName() : serviceName; wsdlNamespace = seiContext.getNamespaceUri(); typeNamespace = wsdlNamespace; SOAPBinding soapBinding = element.getAnnotation(SOAPBinding.class); if (soapBinding != null) { pushedSoapBinding = pushSoapBinding(soapBinding, element, element); } else if (element.equals(typeElement)) { pushedSoapBinding = pushSoapBinding(new MySoapBinding(), element, element); } }
Example #19
Source File: CommentHelper.java From openjdk-jdk9 with GNU General Public License v2.0 | 5 votes |
public PackageElement getReferencedPackage(Configuration c, DocTree dtree) { Element e = getReferencedElement(c, dtree); if (e != null) { return c.utils.containingPackage(e); } return null; }
Example #20
Source File: Hinter.java From netbeans with Apache License 2.0 | 5 votes |
private PackageElement findPackage(Element e) { if (e.getKind() == ElementKind.PACKAGE) { return ((PackageElement) e); } Element parent = e.getEnclosingElement(); if (parent == null) { return null; } return findPackage(parent); }
Example #21
Source File: ExternalAnnotationInjector.java From j2objc with Apache License 2.0 | 5 votes |
@Override public boolean visit(PackageDeclaration node) { PackageElement element = node.getPackageElement(); String elementName = element.getQualifiedName() + ".package-info"; AClass annotatedElement = annotatedAst.classes.get(elementName); if (annotatedElement != null) { recordAnnotations(element, annotatedElement.tlAnnotationsHere); } return false; }
Example #22
Source File: JavaUtils.java From netbeans with Apache License 2.0 | 5 votes |
@Override public TypeElement visitPackage(PackageElement packElem, String binaryName) { for(Element e : packElem.getEnclosedElements()) { if(e.getKind().isClass()) { TypeElement ret = e.accept(this, binaryName); if(ret != null) { return ret; } } } return null; }
Example #23
Source File: ElementJavadoc.java From netbeans with Apache License 2.0 | 5 votes |
private static boolean isLocalized(final URL docURL, final Element element) { if (docURL == null) { return false; } Element pkg = element; while (pkg.getKind() != ElementKind.PACKAGE) { pkg = pkg.getEnclosingElement(); if (pkg == null) { return false; } } String pkgBinName = ((PackageElement)pkg).getQualifiedName().toString(); String surl = docURL.toString(); int index = surl.lastIndexOf('/'); //NOI18N if (index < 0) { return false; } index-=(pkgBinName.length()+1); if (index < 0) { return false; } index-=API.length(); if (index < 0 || !surl.regionMatches(index,API,0,API.length())) { return false; } int index2 = surl.lastIndexOf('/', index-1); //NOI18N if (index2 < 0) { return false; } String lang = surl.substring(index2+1, index); return LANGS.contains(lang); }
Example #24
Source File: ElementUtil.java From j2objc with Apache License 2.0 | 5 votes |
public boolean areParametersNonnullByDefault(Element element, Options options) { if (ElementUtil.hasAnnotation(element, ParametersAreNonnullByDefault.class)) { return true; } PackageElement pkg = getPackage(element); if (ElementUtil.hasAnnotation(pkg, ParametersAreNonnullByDefault.class)) { return true; } String pkgName = pkg.getQualifiedName().toString(); return options.getPackageInfoLookup().hasParametersAreNonnullByDefault(pkgName); }
Example #25
Source File: ClassCompleter.java From netbeans with Apache License 2.0 | 5 votes |
/** * Loads classes imported by explicit or star import. */ private Set<ElementHandle<TypeElement>> loadImportedClasses() { Set<ElementHandle<TypeElement>> handles = new HashSet<ElementHandle<TypeElement>>(); Collection<ImportDecl> imports = ctx.getModel().getImports(); for (ImportDecl decl : imports) { if (decl.isWildcard()) { if (packagePrefix != null && !CompletionUtils.startsWith(decl.getImportedName(), namePrefix)) { continue; } // import all relevant classes from the package PackageElement pel = ctx.getCompilationInfo().getElements().getPackageElement(decl.getImportedName()); for (Element e : pel.getEnclosedElements()) { TypeElement tel = (TypeElement)e; if (acceptsName(tel.getSimpleName()) && acceptsType(tel)) { handles.add(ElementHandle.create((TypeElement)e)); } } } else if (CompletionUtils.startsWithCamelCase(decl.getImportedName(), namePrefix)) { TypeElement el = ctx.getCompilationInfo().getElements().getTypeElement(decl.getImportedName()); if (el != null && acceptsType(el)) { handles.add(ElementHandle.create(el)); } } } return handles; }
Example #26
Source File: SourceCodeAnalysisImpl.java From openjdk-jdk9 with GNU General Public License v2.0 | 5 votes |
private PackageElement createPackageElement(AnalyzeTask at, String packageName) { Names names = Names.instance(at.getContext()); Symtab syms = Symtab.instance(at.getContext()); PackageElement existing = syms.enterPackage(syms.unnamedModule, names.fromString(packageName)); return existing; }
Example #27
Source File: Utils.java From openjdk-jdk9 with GNU General Public License v2.0 | 5 votes |
public Map<ModuleElement, Set<PackageElement>> getModulePackageMap() { if (modulePackageMap == null) { modulePackageMap = new HashMap<>(); Set<PackageElement> pkgs = configuration.getIncludedPackageElements(); pkgs.forEach((pkg) -> { ModuleElement mod = elementUtils.getModuleOf(pkg); modulePackageMap.computeIfAbsent(mod, m -> new HashSet<>()).add(pkg); }); } return modulePackageMap; }
Example #28
Source File: PluginGenerator.java From openjdk-jdk9 with GNU General Public License v2.0 | 5 votes |
private static void createPluginFactory(ProcessingEnvironment env, Element topLevelClass, List<GeneratedPlugin> plugins) { PackageElement pkg = (PackageElement) topLevelClass.getEnclosingElement(); String genClassName = "PluginFactory_" + topLevelClass.getSimpleName(); try { JavaFileObject factory = env.getFiler().createSourceFile(pkg.getQualifiedName() + "." + genClassName, topLevelClass); try (PrintWriter out = new PrintWriter(factory.openWriter())) { out.printf("// CheckStyle: stop header check\n"); out.printf("// CheckStyle: stop line length check\n"); out.printf("// GENERATED CONTENT - DO NOT EDIT\n"); out.printf("// GENERATORS: %s, %s\n", VerifierAnnotationProcessor.class.getName(), PluginGenerator.class.getName()); out.printf("package %s;\n", pkg.getQualifiedName()); out.printf("\n"); createImports(out, plugins); out.printf("\n"); out.printf("@ServiceProvider(NodeIntrinsicPluginFactory.class)\n"); out.printf("public class %s implements NodeIntrinsicPluginFactory {\n", genClassName); for (GeneratedPlugin plugin : plugins) { out.printf("\n"); plugin.generate(env, out); } out.printf("\n"); createPluginFactoryMethod(out, plugins); out.printf("}\n"); } } catch (IOException e) { env.getMessager().printMessage(Diagnostic.Kind.ERROR, e.getMessage()); } }
Example #29
Source File: JavacTrees.java From lua-for-android with BSD 3-Clause "New" or "Revised" License | 5 votes |
@Override @DefinedBy(Api.COMPILER_TREE) public DocTreePath getDocTreePath(FileObject fileObject, PackageElement packageElement) { JavaFileObject jfo = asJavaFileObject(fileObject); DocCommentTree docCommentTree = getDocCommentTree(jfo); TreePath treePath = makeTreePath((PackageSymbol)packageElement, jfo, docCommentTree); return new DocTreePath(treePath, docCommentTree); }
Example #30
Source File: TreeBackedPackageElementTest.java From buck with Apache License 2.0 | 5 votes |
@Test public void testUnnamedPackageCanContainStuff() throws IOException { compile("class Foo { }"); PackageElement unnamedPackage = elements.getPackageElement(""); TypeElement fooElement = elements.getTypeElement("Foo"); assertPackageContains(unnamedPackage, fooElement); }