if (project instanceof FlexProject)
{
final String normalizedBundleName = QNameNormalization.normalize(bundleName);
final FlexProject flexProject = (FlexProject)project;
final ASProjectScope scope = flexProject.getScope();
final Collection<String> locales = flexProject.getLocales();
if(locales.size() == 0)
{
//If the project's locale is empty, then don't try to resolve this
//node because the referenced bundle won't go into swf or swc anyways.
return Collections.emptyMap();
}
Collection<String> unresolvedLocales = new ArrayList<String>(locales);
for(String locale : locales)
{
//resolve the generated qualified name for the bundle name referenced in this metadata tag and this locale
String qualifiedName = ResourceBundleUtils.getQualifiedName(locale, normalizedBundleName);
//find the compilation units for this qualified name
IDefinition def = scope.findDefinitionByName(qualifiedName);
if(def != null)
{
ICompilationUnit compUnit = scope.getCompilationUnitForDefinition(def);
if (isValidCompilationUnit(compUnit, project, bundleName))
{
compilationUnits.put(def.getQualifiedName(), compUnit);
unresolvedLocales.remove(locale);
}
}
}
if (unresolvedLocales.size() > 0 || locales.size() == 0)
{
//If we are at this point, it means that either project's locale is empty or
//we could not resolve the resource bundle for some or all locales.
//The last thing we can check is to see whether we can resolve it using the
//pure bundle name (not the generated name that contains locale$..._properties)
//This is also acceptable because "mx.managers.SystemManager" uses the same logic
//to find a resource bundle. First, it searches for the generated class name and then the pure bundle name.
IDefinition def = scope.findDefinitionByName(normalizedBundleName);
if(def != null)
{
ICompilationUnit compUnit = scope.getCompilationUnitForDefinition(def);
if (isValidCompilationUnit(compUnit, project, bundleName))
{
//This means we resolved the reference by using pure bundle name which will apply
//to all locales during runtime, therefore return from this method.