void AddTypeParameters(AstNode parent, MemberName memberName) { if (memberName == null || memberName.TypeParameters == null) return; var chevronLocs = LocationsBag.GetLocations(memberName.TypeParameters); if (chevronLocs != null) parent.AddChild(new CSharpTokenNode(Convert(chevronLocs [chevronLocs.Count - 2]), Roles.LChevron), Roles.LChevron); for (int i = 0; i < memberName.TypeParameters.Count; i++) { if (chevronLocs != null && i > 0 && i - 1 < chevronLocs.Count) parent.AddChild(new CSharpTokenNode(Convert(chevronLocs [i - 1]), Roles.Comma), Roles.Comma); var arg = memberName.TypeParameters [i]; if (arg == null) continue; var tp = new TypeParameterDeclaration(); List<Location> varianceLocation; switch (arg.Variance) { case Variance.Contravariant: tp.Variance = VarianceModifier.Contravariant; varianceLocation = LocationsBag.GetLocations(arg); if (varianceLocation != null) tp.AddChild(new CSharpTokenNode(Convert(varianceLocation [0]), TypeParameterDeclaration.InVarianceKeywordRole), TypeParameterDeclaration.InVarianceKeywordRole); break; case Variance.Covariant: tp.Variance = VarianceModifier.Covariant; varianceLocation = LocationsBag.GetLocations(arg); if (varianceLocation != null) tp.AddChild(new CSharpTokenNode(Convert(varianceLocation [0]), TypeParameterDeclaration.OutVarianceKeywordRole), TypeParameterDeclaration.OutVarianceKeywordRole); break; default: tp.Variance = VarianceModifier.Invariant; break; } AddAttributeSection(tp, arg.OptAttributes); switch (arg.Variance) { case Variance.Covariant: tp.Variance = VarianceModifier.Covariant; break; case Variance.Contravariant: tp.Variance = VarianceModifier.Contravariant; break; } tp.AddChild(Identifier.Create(arg.Name, Convert(arg.Location)), Roles.Identifier); parent.AddChild(tp, Roles.TypeParameter); } if (chevronLocs != null) parent.AddChild(new CSharpTokenNode(Convert(chevronLocs [chevronLocs.Count - 1]), Roles.RChevron), Roles.RChevron); }
void AddTypeParameters (AstNode parent, List<Location> location, Mono.CSharp.TypeArguments typeArguments) { if (typeArguments == null || typeArguments.IsEmpty) return; for (int i = 0; i < typeArguments.Count; i++) { if (location != null && i > 0 && i - 1 < location.Count) parent.AddChild (new CSharpTokenNode (Convert (location[i - 1]), 1), InvocationExpression.Roles.Comma); var arg = (TypeParameterName)typeArguments.Args[i]; if (arg == null) continue; TypeParameterDeclaration tp = new TypeParameterDeclaration(); // TODO: attributes switch (arg.Variance) { case Variance.Covariant: tp.Variance = VarianceModifier.Covariant; break; case Variance.Contravariant: tp.Variance = VarianceModifier.Contravariant; break; } tp.AddChild (Identifier.Create (arg.Name, Convert (arg.Location)), InvocationExpression.Roles.Identifier); parent.AddChild (tp, InvocationExpression.Roles.TypeParameter); } }
void AddTypeParameters (AstNode parent, Mono.CSharp.TypeArguments typeArguments) { if (typeArguments == null || typeArguments.IsEmpty) return; var chevronLocs = LocationsBag.GetLocations (typeArguments); if (chevronLocs != null) parent.AddChild (new CSharpTokenNode (Convert (chevronLocs[chevronLocs.Count - 2]), 1), InvocationExpression.Roles.LChevron); for (int i = 0; i < typeArguments.Count; i++) { if (chevronLocs != null && i > 0 && i - 1 < chevronLocs.Count) parent.AddChild (new CSharpTokenNode (Convert (chevronLocs[i - 1]), 1), InvocationExpression.Roles.Comma); var arg = (TypeParameterName)typeArguments.Args[i]; if (arg == null) continue; TypeParameterDeclaration tp = new TypeParameterDeclaration(); List<Location> varianceLocation; switch (arg.Variance) { case Variance.Contravariant: tp.Variance = VarianceModifier.Contravariant; varianceLocation = LocationsBag.GetLocations (arg); if (varianceLocation != null) tp.AddChild (new CSharpTokenNode (Convert (varianceLocation[0]), "out".Length), TypeParameterDeclaration.VarianceRole); break; case Variance.Covariant: tp.Variance = VarianceModifier.Covariant; varianceLocation = LocationsBag.GetLocations (arg); if (varianceLocation != null) tp.AddChild (new CSharpTokenNode (Convert (varianceLocation[0]), "out".Length), TypeParameterDeclaration.VarianceRole); break; default: tp.Variance = VarianceModifier.Invariant; break; } AddAttributeSection (tp, arg.OptAttributes); switch (arg.Variance) { case Variance.Covariant: tp.Variance = VarianceModifier.Covariant; break; case Variance.Contravariant: tp.Variance = VarianceModifier.Contravariant; break; } tp.AddChild (Identifier.Create (arg.Name, Convert (arg.Location)), InvocationExpression.Roles.Identifier); parent.AddChild (tp, InvocationExpression.Roles.TypeParameter); } if (chevronLocs != null) parent.AddChild (new CSharpTokenNode (Convert (chevronLocs[chevronLocs.Count - 1]), 1), InvocationExpression.Roles.RChevron); }
void AddTypeParameters (AstNode parent, List<Location> location, Mono.CSharp.TypeArguments typeArguments) { if (typeArguments == null || typeArguments.IsEmpty) return; for (int i = 0; i < typeArguments.Count; i++) { if (location != null && i > 0 && i - 1 < location.Count) parent.AddChild (new CSharpTokenNode (Convert (location[i - 1]), 1), InvocationExpression.Roles.Comma); var arg = (TypeParameterName)typeArguments.Args[i]; if (arg == null) continue; TypeParameterDeclaration tp = new TypeParameterDeclaration(); // TODO: attributes if (arg.Variance != Variance.None) throw new NotImplementedException(); // TODO: variance tp.AddChild (new Identifier (arg.Name, Convert (arg.Location)), InvocationExpression.Roles.Identifier); parent.AddChild (tp, InvocationExpression.Roles.TypeParameter); } }