@@ -60,7 +60,7 @@ internal class Walker : CSharpSyntaxWalker
6060
6161 private int _EnumMembers = 0 ;
6262
63- private AttributeData [ ] ? _AttributeDatasForInvocation = null ;
63+ private string [ ] _AttributeDatasForInvocation = new string [ 2 ] ;
6464 public Walker ( CSTOJSOptions options , SemanticModel model ) : base ( SyntaxWalkerDepth . Trivia )
6565 {
6666 _Options = options ;
@@ -3412,8 +3412,10 @@ public override void VisitGenericName(GenericNameSyntax node)
34123412
34133413 switch ( kind )
34143414 {
3415- case SyntaxKind . IdentifierToken :
3415+ case SyntaxKind . IdentifierToken :
34163416 {
3417+ //TODO! See "VisitIdentifierName"
3418+
34173419 if ( IdentifierToken ( node ) == false )
34183420 {
34193421 base . VisitGenericName ( node ) ;
@@ -3498,56 +3500,60 @@ public override void VisitIdentifierName(IdentifierNameSyntax node)
34983500 if ( _symbol != null )
34993501 {
35003502 CheckParentAttributes :
3501- _AttributeDatasForInvocation = _symbol . GetAttributes ( ) . ToArray ( ) ;
3502- for ( int j = 0 ; j < _AttributeDatasForInvocation . Length ; j ++ )
3503+ AttributeData [ ] _attributeData = _symbol . GetAttributes ( ) . ToArray ( ) ;
3504+ for ( int j = 0 ; j < _attributeData . Length ; j ++ )
35033505 {
3504- if ( _AttributeDatasForInvocation [ j ] . AttributeClass != null )
3506+ if ( _attributeData [ j ] . AttributeClass != null )
35053507 {
3506- if ( _AttributeDatasForInvocation [ j ] . AttributeClass ! . Name == nameof ( BinaryAttribute ) ||
3507- _AttributeDatasForInvocation [ j ] . AttributeClass ! . Name == nameof ( UnaryAttribute ) )
3508+ if ( _attributeData [ j ] . AttributeClass ! . Name == nameof ( BinaryAttribute ) ||
3509+ _attributeData [ j ] . AttributeClass ! . Name == nameof ( UnaryAttribute ) )
35083510 {
3509- goto BreakIndetifierName ;
3511+ _AttributeDatasForInvocation [ 0 ] = _attributeData [ j ] . AttributeClass ! . Name ;
3512+ _AttributeDatasForInvocation [ 1 ] = _attributeData [ j ] . ConstructorArguments [ 0 ] . Value . ToString ( ) ;
3513+ goto BreakIndetifierToken ;
35103514 }
35113515
3512- if ( _AttributeDatasForInvocation [ j ] . AttributeClass . Name == nameof ( EnumValueAttribute ) )
3516+ if ( _attributeData [ j ] . AttributeClass . Name == nameof ( EnumValueAttribute ) )
35133517 {
35143518 SyntaxTriviaList _syntaxTrivias = _identifier . GetLeadingTrivia ( ) ;
35153519 for ( int _i = 0 ; _i < _syntaxTrivias . Count ; _i ++ )
35163520 {
35173521 VisitTrivia ( _syntaxTrivias [ _i ] ) ;
35183522 }
35193523
3520- JSSB . Append ( $ "\" { _AttributeDatasForInvocation [ j ] . ConstructorArguments [ 0 ] . Value } \" ") ;
3524+ JSSB . Append ( $ "\" { _attributeData [ j ] . ConstructorArguments [ 0 ] . Value } \" ") ;
35213525
35223526 _syntaxTrivias = _identifier . GetTrailingTrivia ( ) ;
35233527 for ( int _i = 0 ; _i < _syntaxTrivias . Count ; _i ++ )
35243528 {
35253529 VisitTrivia ( _syntaxTrivias [ _i ] ) ;
35263530 }
3527- goto BreakIndetifierName ;
3531+
3532+ goto BreakIndetifierToken ;
35283533 }
35293534
3530- if ( _AttributeDatasForInvocation [ j ] . AttributeClass . Name == nameof ( ValueAttribute ) )
3535+ if ( _attributeData [ j ] . AttributeClass . Name == nameof ( ValueAttribute ) )
35313536 {
35323537 SyntaxTriviaList _syntaxTrivias = _identifier . GetLeadingTrivia ( ) ;
35333538 for ( int _i = 0 ; _i < _syntaxTrivias . Count ; _i ++ )
35343539 {
35353540 VisitTrivia ( _syntaxTrivias [ _i ] ) ;
35363541 }
35373542
3538- JSSB . Append ( $ "{ _AttributeDatasForInvocation [ j ] . ConstructorArguments [ 0 ] . Value } ") ;
3543+ JSSB . Append ( $ "{ _attributeData [ j ] . ConstructorArguments [ 0 ] . Value } ") ;
35393544
35403545 _syntaxTrivias = _identifier . GetTrailingTrivia ( ) ;
35413546 for ( int _i = 0 ; _i < _syntaxTrivias . Count ; _i ++ )
35423547 {
35433548 VisitTrivia ( _syntaxTrivias [ _i ] ) ;
35443549 }
3545- goto BreakIndetifierName ;
3550+
3551+ goto BreakIndetifierToken ;
35463552 }
35473553
3548- if ( _AttributeDatasForInvocation [ j ] . AttributeClass . Name == nameof ( ToAttribute ) )
3554+ if ( _attributeData [ j ] . AttributeClass . Name == nameof ( ToAttribute ) )
35493555 {
3550- ToAttribute _toAttr = new ToAttribute ( _AttributeDatasForInvocation [ j ] . ConstructorArguments [ 0 ] . Value . ToString ( ) ) ;
3556+ ToAttribute _toAttr = new ToAttribute ( _attributeData [ j ] . ConstructorArguments [ 0 ] . Value . ToString ( ) ) ;
35513557
35523558 if ( _toAttr . To == ToAttribute . None )
35533559 _IgnoreTailingDot = true ;
@@ -3565,8 +3571,8 @@ public override void VisitIdentifierName(IdentifierNameSyntax node)
35653571 {
35663572 VisitTrivia ( _syntaxTrivias [ _i ] ) ;
35673573 }
3568-
3569- goto BreakIndetifierName ;
3574+
3575+ goto BreakIndetifierToken ;
35703576 }
35713577 }
35723578 }
@@ -3577,13 +3583,11 @@ public override void VisitIdentifierName(IdentifierNameSyntax node)
35773583 }
35783584 }
35793585
3580- _AttributeDatasForInvocation = null ;
3581-
35823586 if ( IdentifierToken ( node ) == false )
35833587 {
35843588 base . VisitIdentifierName ( node ) ;
35853589 }
3586- BreakIndetifierName :
3590+ BreakIndetifierToken :
35873591 break ;
35883592 }
35893593 default :
@@ -4988,36 +4992,45 @@ public override void VisitInvocationExpression(InvocationExpressionSyntax node)
49884992
49894993 switch ( kind )
49904994 {
4995+ case SyntaxKind . GenericName :
4996+ VisitGenericName ( ( GenericNameSyntax ) asNode ) ;
4997+ break ;
49914998 case SyntaxKind . IdentifierName :
4992- {
49934999 VisitIdentifierName ( ( IdentifierNameSyntax ) asNode ) ;
49945000 break ;
4995- }
49965001 case SyntaxKind . ArgumentList :
49975002 {
49985003 ArgumentListSyntax _arguments = ( ArgumentListSyntax ) asNode ;
4999- if ( _AttributeDatasForInvocation != null )
5004+ if ( _AttributeDatasForInvocation [ 0 ] != string . Empty )
50005005 {
5001- for ( int j = 0 ; j < _AttributeDatasForInvocation . Length ; j ++ )
5006+ if ( _AttributeDatasForInvocation [ 0 ] == nameof ( BinaryAttribute ) )
50025007 {
5003- if ( _AttributeDatasForInvocation [ j ] . AttributeClass != null )
5008+ _AttributeDatasForInvocation [ 0 ] = string . Empty ;
5009+ string _arg = _AttributeDatasForInvocation [ 1 ] ;
5010+
5011+ VisitArgument ( _arguments . Arguments [ 0 ] ) ;
5012+ JSSB . Append ( _arg ) ;
5013+ VisitTrailingTrivia ( _arguments . Arguments . GetSeparator ( 0 ) ) ;
5014+ VisitArgument ( _arguments . Arguments [ 1 ] ) ;
5015+
5016+ SyntaxTriviaList _syntaxTrivias = _arguments . GetTrailingTrivia ( ) ;
5017+ for ( int _i = 0 ; _i < _syntaxTrivias . Count ; _i ++ )
50045018 {
5005- if ( _AttributeDatasForInvocation [ j ] . AttributeClass ! . Name == nameof ( BinaryAttribute ) )
5006- {
5007- VisitArgument ( _arguments . Arguments [ 0 ] ) ;
5008- JSSB . Append ( _AttributeDatasForInvocation [ j ] . ConstructorArguments [ 0 ] . Value ) ;
5009- VisitTrailingTrivia ( _arguments . Arguments . GetSeparator ( 0 ) ) ;
5010- VisitArgument ( _arguments . Arguments [ 1 ] ) ;
5011- goto BreakArgumentList ;
5012- }
5013-
5014- if ( _AttributeDatasForInvocation [ j ] . AttributeClass ! . Name == nameof ( UnaryAttribute ) )
5015- {
5016- JSSB . Append ( _AttributeDatasForInvocation [ j ] . ConstructorArguments [ 0 ] . Value ) ;
5017- VisitArgument ( _arguments . Arguments [ 0 ] ) ;
5018- goto BreakArgumentList ;
5019- }
5019+ VisitTrivia ( _syntaxTrivias [ _i ] ) ;
50205020 }
5021+
5022+ goto BreakArgumentList ;
5023+ }
5024+
5025+ if ( _AttributeDatasForInvocation [ 0 ] == nameof ( UnaryAttribute ) )
5026+ {
5027+ _AttributeDatasForInvocation [ 0 ] = string . Empty ;
5028+ string _arg = _AttributeDatasForInvocation [ 1 ] ;
5029+
5030+ JSSB . Append ( _arg ) ;
5031+ VisitArgument ( _arguments . Arguments [ 0 ] ) ;
5032+
5033+ goto BreakArgumentList ;
50215034 }
50225035 }
50235036
@@ -5092,14 +5105,6 @@ public override void VisitLabeledStatement(LabeledStatementSyntax node)
50925105#endif
50935106 base . VisitLabeledStatement ( node ) ;
50945107 }
5095- /*
5096- public override void VisitLeadingTrivia(SyntaxToken token)
5097- {
5098- if (_Options.Debug)
5099- Log.WarningLine($"Not implemented or unlikely to be implemented. Calling base! ({token.FullSpan}|l:{_Line}|{token.FullSpan.Start - _Characters}-{token.FullSpan.End - _Characters})\n|{token.ToFullString()}|");
5100-
5101- base.VisitLeadingTrivia(token);
5102- }*/
51035108 public override void VisitLetClause ( LetClauseSyntax node )
51045109 {
51055110#if DEBUG
@@ -5710,14 +5715,6 @@ public override void VisitThrowStatement(ThrowStatementSyntax node)
57105715#endif
57115716 base . VisitThrowStatement ( node ) ;
57125717 }
5713- /*
5714- public override void VisitTrailingTrivia(SyntaxToken token)
5715- {
5716- if (_Options.Debug)
5717- Log.WarningLine($"Not implemented or unlikely to be implemented. Calling base! ({token.FullSpan}|l:{_Line}|{token.FullSpan.Start - _Characters}-{token.FullSpan.End - _Characters})\n|{token.ToFullString()}|");
5718-
5719- base.VisitTrailingTrivia(token);
5720- }*/
57215718 public override void VisitTryStatement ( TryStatementSyntax node )
57225719 {
57235720#if DEBUG
@@ -5762,10 +5759,52 @@ public override void VisitTypeCref(TypeCrefSyntax node)
57625759 }
57635760 public override void VisitTypeOfExpression ( TypeOfExpressionSyntax node )
57645761 {
5765- #if DEBUG
5766- Log . WarningLine ( $ "Not implemented or unlikely to be implemented. Calling base! (FullSpan: { node . FullSpan } |Location{ node . GetLocation ( ) . GetLineSpan ( ) } )\n |{ node . ToFullString ( ) } |") ;
5767- #endif
5768- base . VisitTypeOfExpression ( node ) ;
5762+ if ( _Options . Debug )
5763+ {
5764+ JSSB . Append ( "/*" ) ;
5765+ string [ ] strings = node . ToFullString ( ) . Split ( [ "\r \n " , "\r " , "\n " ] , StringSplitOptions . RemoveEmptyEntries ) ;
5766+ JSSB . Append ( string . IsNullOrWhiteSpace ( strings [ 0 ] ) ? strings [ 1 ] : strings [ 0 ] ) ;
5767+ JSSB . AppendLine ( "*/" ) ;
5768+ }
5769+
5770+ ChildSyntaxList nodesAndTokens = node . ChildNodesAndTokens ( ) ;
5771+
5772+ for ( int i = 0 ; i < nodesAndTokens . Count ; i ++ )
5773+ {
5774+ SyntaxNode ? asNode = nodesAndTokens [ i ] . AsNode ( ) ;
5775+
5776+ if ( asNode != null )
5777+ {
5778+ SyntaxKind kind = asNode . Kind ( ) ;
5779+
5780+ switch ( kind )
5781+ {
5782+ case SyntaxKind . IdentifierName :
5783+ VisitIdentifierName ( ( IdentifierNameSyntax ) asNode ) ;
5784+ break ;
5785+ default :
5786+ Log . ErrorLine ( $ "asNode : { kind } \n |{ asNode . ToFullString ( ) } |") ;
5787+ break ;
5788+ }
5789+ }
5790+ else
5791+ {
5792+ SyntaxToken asToken = nodesAndTokens [ i ] . AsToken ( ) ;
5793+ SyntaxKind kind = asToken . Kind ( ) ;
5794+
5795+ switch ( kind )
5796+ {
5797+ case SyntaxKind . OpenParenToken :
5798+ case SyntaxKind . CloseParenToken :
5799+ case SyntaxKind . TypeOfKeyword :
5800+ VisitToken ( asToken ) ;
5801+ break ;
5802+ default :
5803+ Log . ErrorLine ( $ "asToken : { kind } ") ;
5804+ break ;
5805+ }
5806+ }
5807+ }
57695808 }
57705809 public override void VisitTypeParameter ( TypeParameterSyntax node )
57715810 {
0 commit comments