if (isCmpTheme && !imports.isEmpty()) {
throw new InvalidDefinitionException("Component themes cannot import another theme", getLocation());
}
for (DefDescriptor<ThemeDef> theme : imports) {
ThemeDef def = theme.getDef();
// can't import a cmp theme
if (def.isCmpTheme()) {
String msg = String.format("Theme %s cannot be imported because it is a component theme", theme);
throw new InvalidDefinitionException(msg, getLocation());
}
// can't import a theme with a parent. This is an arbitrary restriction to enforce a level of var lookup
// simplicity and prevent misuse of imports.
if (def.getExtendsDescriptor() != null) {
String msg = String.format("Theme %s cannot be imported since it uses the 'extends' attribute", theme);
throw new InvalidDefinitionException(msg, getLocation());
}
// can't import a theme that uses a provider.
if (def.getDescriptorProvider() != null || def.getMapProvider() != null) {
String msg = String.format("Theme %s cannot be imported since it uses a provider", theme);
throw new InvalidDefinitionException(msg, getLocation());
}
}
// vars
for (VarDef def : vars.values()) {
def.validateReferences();
}
// verify var cross references refer to something defined on this theme or on a parent theme. Or if this is a
// cmp theme it can also refer to something on the namespace default theme.
Iterable<String> names = getAllNames();