public static SyntaxList <TypeParameterConstraintClauseSyntax> GetTypeParameterConstraintList( IEnumerable <SyntaxNode> typeParamsAndConstraints, Whitespace2Collection whitespace2Set, WhitespaceKindLookup whitespaceLookup) { var typeParameters = typeParamsAndConstraints .OfType <TypeParameterSyntax>() .ToList(); var typeConstraintClauses = typeParamsAndConstraints .OfType <TypeParameterConstraintClauseSyntax>() .ToList(); var clauses = new List <TypeParameterConstraintClauseSyntax>(); foreach (var typeParameter in typeParameters) { var name = typeParameter.Identifier.ToString(); var constraint = typeConstraintClauses .Where(x => x.Name.ToString() == name && x.Constraints.Any()) .ToList() .SingleOrDefault(); if (constraint != null) { clauses.Add(constraint); } } return(SyntaxFactory.List(clauses)); }
internal T AttachWhitespace <T>(T syntaxNode, Whitespace2Collection whitespace2Set, WhitespaceKindLookup whitespaceLookup, LanguagePart languagePart) where T : SyntaxNode { var ret = syntaxNode; var whitespaceList = whitespace2Set.Where(x => x.LanguagePart == languagePart); var missingWhitespace = whitespaceLookup.NotUsedInWhitespaceList(whitespaceList); whitespaceList = whitespaceList .Union(missingWhitespace .Select(x => new Whitespace2(languagePart, x))); foreach (var whitespace in whitespaceList) { ret = AttachWhitespaceItem(ret, whitespace, whitespaceLookup); } // Not sure the functional approah is best here ret = CheckToken <T>(ret, x => x.GetLastToken(), t => t.TrailingTrivia, s => SyntaxFactory.ParseTrailingTrivia(s), (t, trivia) => t.WithTrailingTrivia(trivia), whitespace2Set.ForceTrailing); ret = CheckToken <T>(ret, x => x.GetFirstToken(), t => t.LeadingTrivia, s => SyntaxFactory.ParseLeadingTrivia(s), (t, trivia) => t.WithLeadingTrivia(trivia), whitespace2Set.ForceLeading); return(ret); }
public static TypeParameterListSyntax GetTypeParameterSyntaxList( IEnumerable <SyntaxNode> typeParamsAndConstraints, Whitespace2Collection whitespace2Set, WhitespaceKindLookup whitespaceLookup) { var typeParameters = typeParamsAndConstraints .OfType <TypeParameterSyntax>() .ToList(); if (typeParameters.Any()) { var typeParameterListSyntax = SyntaxFactory.TypeParameterList( SyntaxFactory.SeparatedList <TypeParameterSyntax>(typeParameters)); typeParameterListSyntax = AttachWhitespace( typeParameterListSyntax, whitespace2Set, whitespaceLookup); return(typeParameterListSyntax);; } return(null); }
public static T AttachWhitespace <T>(T syntaxNode, Whitespace2Collection whitespace2Set, WhitespaceKindLookup whitespaceLookup, LanguagePart languagePart) where T : SyntaxNode { return(triviaManager.AttachWhitespace(syntaxNode, whitespace2Set, whitespaceLookup, languagePart)); }
private void Initialize() { Whitespace2Set = new Whitespace2Collection(); }
internal T AttachWhitespace <T>(T syntaxNode, Whitespace2Collection whitespace2Set, WhitespaceKindLookup whitespaceLookup) where T : SyntaxNode { return(AttachWhitespace(syntaxNode, whitespace2Set, whitespaceLookup, LanguagePart.Current)); }
protected RDomBase() { Whitespace2Set = new Whitespace2Collection(); }