File tree Expand file tree Collapse file tree
CSharpier.Tests/FormattingTests/TestFiles/cs
CSharpier/SyntaxPrinter/SyntaxNodePrinters Expand file tree Collapse file tree Original file line number Diff line number Diff line change 1+ int[] someArray = [.. someOtherArray];
2+ int[] someOtherArray = [.. value1, .. value2, .. value3];
3+
4+ int[] someOtherArray =
5+ [
6+ .. value1________________________________,
7+ .. value2________________________________,
8+ .. value3________________________________
9+ ];
10+
11+ List<KeyValuePair<string, string>> list =
12+ [
13+ .. attribute
14+ .Targets.Select(target =>
15+ KeyValuePair.Create(
16+ target,
17+ context.EntityDefinitions.TryGetValue(target, out var type) ? type.ClassName : null
18+ )
19+ )
20+ .Where(kvp => kvp.Value != null)
21+ ];
Original file line number Diff line number Diff line change 1+ namespace CSharpier . SyntaxPrinter . SyntaxNodePrinters ;
2+
3+ internal static class SpreadElement
4+ {
5+ public static Doc Print ( SpreadElementSyntax node , FormattingContext context )
6+ {
7+ return Doc . Group (
8+ Token . Print ( node . OperatorToken , context ) ,
9+ " " ,
10+ Node . Print ( node . Expression , context )
11+ ) ;
12+ }
13+ }
Original file line number Diff line number Diff line change 1- using Microsoft . CodeAnalysis . CSharp ;
1+ using System . Reflection ;
2+ using Microsoft . CodeAnalysis . CSharp ;
23using SyntaxFinder ;
34
45var files = Directory . EnumerateFiles (
4748 }
4849) ;
4950
50- // ObjectInitializerWalker. WriteResult( );
51+ typeToRun . GetMethod ( " WriteResult" ) ? . Invoke ( null , null ) ;
Original file line number Diff line number Diff line change 1+ namespace SyntaxFinder ;
2+
3+ using System . Collections . Concurrent ;
4+ using Microsoft . CodeAnalysis ;
5+ using Microsoft . CodeAnalysis . CSharp ;
6+ using Microsoft . CodeAnalysis . CSharp . Syntax ;
7+
8+ public class SpreadWalker : CSharpSyntaxWalker
9+ {
10+ private static int total ;
11+ private static int matching ;
12+ private readonly string file ;
13+
14+ public SpreadWalker ( string file )
15+ {
16+ this . file = file ;
17+ }
18+
19+ public override void VisitSpreadElement ( SpreadElementSyntax node )
20+ {
21+ if ( node . Kind ( ) is SyntaxKind . SpreadElement )
22+ {
23+ this . VisitNode ( node ) ;
24+ }
25+
26+ base . VisitSpreadElement ( node ) ;
27+ }
28+
29+ private void VisitNode ( SpreadElementSyntax node )
30+ {
31+ Console . WriteLine ( node . Parent ! . SyntaxTree . GetText ( ) . ToString ( node . Parent ! . FullSpan ) ) ;
32+ Interlocked . Increment ( ref total ) ;
33+
34+ if ( node . Expression . GetLeadingTrivia ( ) . Any ( o => o . Kind ( ) is SyntaxKind . WhitespaceTrivia ) )
35+ {
36+ Interlocked . Increment ( ref matching ) ;
37+ }
38+ }
39+
40+ public static void WriteResult ( )
41+ {
42+ ResultWriter . WriteMatching ( total , matching ) ;
43+ }
44+ }
You can’t perform that action at this time.
0 commit comments