use of javax.lang.model.element.ModuleElement in project bazel-jdt-java-toolchain by salesforce.
the class ElementsImpl9 method getAllModuleElements.
@Override
public Set<? extends ModuleElement> getAllModuleElements() {
LookupEnvironment lookup = _env.getLookupEnvironment();
HashtableOfModule knownModules = lookup.knownModules;
ModuleBinding[] modules = knownModules.valueTable;
if (modules == null || modules.length == 0) {
return Collections.emptySet();
}
Set<ModuleElement> mods = new HashSet<>(modules.length);
for (ModuleBinding moduleBinding : modules) {
if (moduleBinding == null)
continue;
ModuleElement element = (ModuleElement) _env.getFactory().newElement(moduleBinding);
mods.add(element);
}
mods.add((ModuleElement) _env.getFactory().newElement(lookup.UnNamedModule));
return mods;
}
use of javax.lang.model.element.ModuleElement in project graal by oracle.
the class ModuleCache method getTypeElement.
static TypeElement getTypeElement(final ProcessingEnvironment processingEnv, final CharSequence typeName) {
if (processingEnv.getSourceVersion().compareTo(SourceVersion.RELEASE_9) < 0) {
return processingEnv.getElementUtils().getTypeElement(typeName);
}
final Map<String, ModuleElement> moduleCache = moduleCacheCleaner.computeIfAbsent(processingEnv, new Function<ProcessingEnvironment, Map<String, ModuleElement>>() {
@Override
public Map<String, ModuleElement> apply(ProcessingEnvironment t) {
return new HashMap<>();
}
});
final String typeNameString = typeName.toString();
ModuleElement moduleElement = moduleCache.get(typeNameString);
if (moduleElement == null) {
final TypeElement typeElement = processingEnv.getElementUtils().getTypeElement(typeName);
if (typeElement != null) {
moduleElement = processingEnv.getElementUtils().getModuleOf(typeElement);
moduleCache.put(typeNameString, moduleElement);
}
return typeElement;
} else {
return processingEnv.getElementUtils().getTypeElement(moduleElement, typeName);
}
}
use of javax.lang.model.element.ModuleElement in project bazel-jdt-java-toolchain by salesforce.
the class ElementsImpl9 method getTypeElement.
@Override
public TypeElement getTypeElement(CharSequence name) {
final char[][] compoundName = CharOperation.splitOn('.', name.toString().toCharArray());
Set<? extends ModuleElement> allModuleElements = getAllModuleElements();
for (ModuleElement moduleElement : allModuleElements) {
TypeElement t = getTypeElement(compoundName, ((ModuleElementImpl) moduleElement).binding);
if (t != null) {
return t;
}
}
return null;
}
Aggregations