* Helper method to convert the type string into an IDefinition. This method
* will handle nested vectors, like a Vector of Vectors of Vectors of Foo.
*/
private IDefinition resolveElementType(String value, FlexProject project)
{
IDefinition def = null;
int dotLessIdx = value.indexOf(DOT_LESS_THAN_ESCAPED);
if (dotLessIdx != -1)
{
int endIdx = value.lastIndexOf(GREATER_THAN_ESCAPED);
if (endIdx != -1)
{
// We have something that looks like a parameterized type - pull apart the base name
// and type arg, and try to resolve them to a Vector.
// When we add real generic support, we'll need to revisit this code
// Resolve the element type - it could be yet another Vector, so call this method again
// e.g. Vector.<Vector.<Vector.<Vector.<Turtles>>>>
String typeArg = value.substring(dotLessIdx + 5, endIdx);
IDefinition typeParam = resolveElementType(typeArg, project);
String baseName = value.substring(0, dotLessIdx);
IDefinition baseType = null;
// Get the base type
if (baseName.equals(IASLanguageConstants.Vector))
baseType = project.getBuiltinType(IASLanguageConstants.BuiltinType.VECTOR);
else
baseType = project.getScope().findDefinitionByName(baseName);
if (baseType instanceof ITypeDefinition && typeParam instanceof ITypeDefinition)
{
IDefinition vectorType = project.getBuiltinType(IASLanguageConstants.BuiltinType.VECTOR);
if (baseType == vectorType) //only vectors are parameterizable today
{
def = AppliedVectorDefinitionFactory.newVector(project, (ITypeDefinition)typeParam);
}