本文整理汇总了Java中javax.lang.model.element.PackageElement.getEnclosedElements方法的典型用法代码示例。如果您正苦于以下问题:Java PackageElement.getEnclosedElements方法的具体用法?Java PackageElement.getEnclosedElements怎么用?Java PackageElement.getEnclosedElements使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类javax.lang.model.element.PackageElement
的用法示例。
在下文中一共展示了PackageElement.getEnclosedElements方法的9个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: getIndexedClassNames
import javax.lang.model.element.PackageElement; //导入方法依赖的package包/类
@SuppressWarnings("unchecked")
private FoundIndexedClassNames getIndexedClassNames(PackageElement glideGenPackage) {
Set<String> glideModules = new HashSet<>();
Set<String> extensions = new HashSet<>();
List<? extends Element> glideGeneratedElements = glideGenPackage.getEnclosedElements();
for (Element indexer : glideGeneratedElements) {
Index annotation = indexer.getAnnotation(Index.class);
// If the annotation is null, it means we've come across another class in the same package
// that we can safely ignore.
if (annotation != null) {
Collections.addAll(glideModules, annotation.modules());
Collections.addAll(extensions, annotation.extensions());
}
}
processorUtil.debugLog("Found GlideModules: " + glideModules);
return new FoundIndexedClassNames(glideModules, extensions);
}
示例2: addPackageContent
import javax.lang.model.element.PackageElement; //导入方法依赖的package包/类
private void addPackageContent(PackageElement pe, EnumSet<ElementKind> kinds, DeclaredType baseType, Set<? extends Element> toExclude, String prefix, int substitutionOffset, JavadocContext jdctx) {
CompilationInfo controller = jdctx.javac;
Element srcEl = jdctx.handle.resolve(controller);
Elements elements = controller.getElements();
Types types = controller.getTypes();
Trees trees = controller.getTrees();
TreeUtilities tu = controller.getTreeUtilities();
ElementUtilities eu = controller.getElementUtilities();
TreePath docpath = srcEl != null ? trees.getPath(srcEl) : null;
Scope scope = docpath != null ? trees.getScope(docpath) : tu.scopeFor(caretOffset);
for(Element e : pe.getEnclosedElements()) {
if ((e.getKind().isClass() || e.getKind().isInterface()) && (toExclude == null || !toExclude.contains(e))) {
String name = e.getSimpleName().toString();
if (Utilities.startsWith(name, prefix) && (Utilities.isShowDeprecatedMembers() || !elements.isDeprecated(e))
&& trees.isAccessible(scope, (TypeElement)e)
&& isOfKindAndType(e.asType(), e, kinds, baseType, scope, trees, types)
&& !Utilities.isExcluded(eu.getElementName(e, true))) {
items.add(JavadocCompletionItem.createTypeItem(jdctx.javac, (TypeElement) e, substitutionOffset, null, elements.isDeprecated(e)/*, isOfSmartType(env, e.asType(), smartTypes)*/));
}
}
}
}
示例3: visitPackage
import javax.lang.model.element.PackageElement; //导入方法依赖的package包/类
@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;
}
示例4: visitPackage
import javax.lang.model.element.PackageElement; //导入方法依赖的package包/类
@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;
}
示例5: complete
import javax.lang.model.element.PackageElement; //导入方法依赖的package包/类
@Override
public List<CompletionItem> complete() {
if (ctx.getType() == CompletionContext.Type.INSTRUCTION_TARGET || ctx.getType() == CompletionContext.Type.ROOT) {
CompletionItem item = completeTarget();
return item != null ? Collections.singletonList(completeTarget()) : null;
}
results = new ArrayList<CompletionItem>();
Set<String> packages = ctx.getClasspathInfo().getClassIndex().getPackageNames(ctx.getPrefix(), true,
EnumSet.of(ClassIndex.SearchScope.SOURCE, ClassIndex.SearchScope.DEPENDENCIES));
if (!"".equals(ctx.getPrefix())) {
if (ctx.getPrefix().endsWith("*")) {
return null;
}
if (ctx.getPrefix().endsWith(".")) {
PackageElement pel = ctx.getCompilationInfo().getElements().getPackageElement(ctx.getPrefix().substring(0, ctx.getPrefix().length() - 1));
if (pel != null) {
List<?> els = pel.getEnclosedElements();
if (!els.isEmpty()) {
results.add(new PackageItem(ctx, ctx.getPrefix() + "*"));
}
}
}
}
for (String s : packages) {
// results.add(JavaCompletionItem.createPackageItem(s, ctx.getStartOffset(), true));
results.add(new PackageItem(ctx, s));
}
return results;
}
示例6: loadImportedClasses
import javax.lang.model.element.PackageElement; //导入方法依赖的package包/类
/**
* 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;
}
示例7: findPublicTypes
import javax.lang.model.element.PackageElement; //导入方法依赖的package包/类
Map<PackageElement, List<TypeElement>> findPublicTypes(Collection<PackageElement> pkgs) {
Map<PackageElement, List<TypeElement>> map = new HashMap<>();
for (PackageElement pkg : pkgs) {
List<TypeElement> enclosed = new ArrayList<>();
for (Element e : pkg.getEnclosedElements()) {
addPublicTypes(enclosed, e);
}
map.put(pkg, enclosed);
}
return map;
}
示例8: visitPackage
import javax.lang.model.element.PackageElement; //导入方法依赖的package包/类
@Override
public Void visitPackage(PackageElement e, Void p) {
List<Element> types = new ArrayList<>(e.getEnclosedElements());
Collections.sort(types, (e1, e2) -> e1.getSimpleName().toString().compareTo(e2.getSimpleName().toString()));
for (Element encl : types) {
visit(encl, p);
}
return null;
}
示例9: verifySelfContainedAPI
import javax.lang.model.element.PackageElement; //导入方法依赖的package包/类
private void verifySelfContainedAPI(PackageElement pel) {
for (Element e : pel.getEnclosedElements()) {
verifySelfContainedAPI(e, null);
}
}