* @return A new {@link Multiname} created from information in the specified
* name
*/
public static Multiname crackDottedQName(ICompilerProject project, String name, boolean includeInternal)
{
Workspace workspace = (Workspace)project.getWorkspace();
final Set<INamespaceDefinition> namespaceSet = new HashSet<INamespaceDefinition>(includeInternal ? 2 : 1);
if (name != null)
{
int lastIndexOfDot = name != null ? name.lastIndexOf('.') : -1;
if (lastIndexOfDot != -1)
{
final String definitionName = name.substring(lastIndexOfDot + 1);
final String packageName = name.substring(0, lastIndexOfDot);
INamespaceDefinition publicPackageNS =
workspace.getPackageNamespaceDefinitionCache().get(packageName, false);
namespaceSet.add(publicPackageNS);
if (includeInternal)
{
INamespaceDefinition internalPackageNS =
workspace.getPackageNamespaceDefinitionCache().get(packageName, true);
namespaceSet.add(internalPackageNS);
}
return new Multiname(namespaceSet, definitionName);
}
}
final INamespaceDefinition publicPackageNS = NamespaceDefinition.getPublicNamespaceDefinition();
namespaceSet.add(publicPackageNS);
if (includeInternal)
{
INamespaceDefinition internalPackageNS =
workspace.getPackageNamespaceDefinitionCache().get("", true);
namespaceSet.add(internalPackageNS);
}
return new Multiname(namespaceSet, name);
}