public IEnumerable<GrapeEntity> GetEntitiesForObjectCreationExpression(GrapeCodeGeneratorConfiguration config, GrapeObjectCreationExpression objectCreationExpression, GrapeEntity parent, out string errorMessage) { errorMessage = ""; GrapeClass c = astUtils.GetClassWithNameFromImportedPackagesInFile(config.Ast, GetTypeNameForTypeAccessExpression(config, objectCreationExpression.ClassName), objectCreationExpression.FileName); if (c != null) { List<GrapeMethod> constructors = c.GetConstructors(); if (constructors.Count == 0) { GrapeMethod method = new GrapeConstructor(new GrapeList<GrapeModifier>(new GrapePublicModifier()), new GrapeIdentifier(c.Name), new GrapeList<GrapeParameter>(), new GrapeList<GrapeStatement>()); method.Parent = c; return new GrapeEntity[] { method }; } else { errorMessage = ""; GrapeModifier.GrapeModifierType modifiers = objectCreationExpression.GetLogicalParentOfEntityType<GrapeClass>().GetAppropriateModifiersForEntityAccess(config, constructors[0]); List<GrapeMethod> methodsWithSignature = GetMethodsWithSignature(config, constructors, modifiers, c.Name, new GrapeSimpleType(new GrapeList<GrapeIdentifier>(new GrapeIdentifier(c.Name))), new List<GrapeExpression>(objectCreationExpression.Parameters), ref errorMessage); if (methodsWithSignature.Count > 1) { errorMessage = "Multiple methods with signature '" + GetMethodSignatureString(config, c.Name, new GrapeSimpleType(new GrapeList<GrapeIdentifier>(new GrapeIdentifier(c.Name))), new List<GrapeExpression>(objectCreationExpression.Parameters)) + "' found."; return new GrapeEntity[] { null }; } if (methodsWithSignature.Count == 0) { return new GrapeEntity[] { null }; } return methodsWithSignature; } } return new GrapeEntity[] { null }; }
public IEnumerable<GrapeEntity> GetEntitiesForObjectCreationExpression(GrapeCodeGeneratorConfiguration config, GrapeObjectCreationExpression objectCreationExpression, GrapeEntity parent) { string dummyMessage = ""; return GetEntitiesForObjectCreationExpression(config, objectCreationExpression, parent, out dummyMessage); }