@@ -2170,6 +2170,12 @@ public override void VisitForEachStatement(ForEachStatementSyntax node)
21702170
21712171 switch ( kind )
21722172 {
2173+ case SyntaxKind . ElementAccessExpression :
2174+ VisitElementAccessExpression ( ( ElementAccessExpressionSyntax ) asNode ) ;
2175+ break ;
2176+ case SyntaxKind . ThisExpression :
2177+ VisitThisExpression ( ( ThisExpressionSyntax ) asNode ) ;
2178+ break ;
21732179 case SyntaxKind . ExpressionStatement :
21742180 VisitExpressionStatement ( ( ExpressionStatementSyntax ) asNode ) ;
21752181 break ;
@@ -2727,6 +2733,9 @@ public override void VisitParenthesizedExpression(ParenthesizedExpressionSyntax
27272733
27282734 switch ( kind )
27292735 {
2736+ case SyntaxKind . ThisExpression :
2737+ VisitThisExpression ( ( ThisExpressionSyntax ) asNode ) ;
2738+ break ;
27302739 case SyntaxKind . AddExpression :
27312740 case SyntaxKind . SubtractExpression :
27322741 case SyntaxKind . MultiplyExpression :
@@ -3682,6 +3691,10 @@ public override void VisitAnonymousObjectMemberDeclarator(AnonymousObjectMemberD
36823691
36833692 switch ( kind )
36843693 {
3694+ case SyntaxKind . PointerMemberAccessExpression :
3695+ case SyntaxKind . SimpleMemberAccessExpression :
3696+ VisitMemberAccessExpression ( ( MemberAccessExpressionSyntax ) asNode ) ;
3697+ break ;
36853698 case SyntaxKind . SimpleAssignmentExpression :
36863699 {
36873700 AssignmentExpressionSyntax _expr = ( AssignmentExpressionSyntax ) asNode ;
@@ -4509,6 +4522,9 @@ public override void VisitForEachVariableStatement(ForEachVariableStatementSynta
45094522
45104523 switch ( kind )
45114524 {
4525+ case SyntaxKind . IfStatement :
4526+ VisitIfStatement ( ( IfStatementSyntax ) asNode ) ;
4527+ break ;
45124528 case SyntaxKind . ThisExpression :
45134529 VisitThisExpression ( ( ThisExpressionSyntax ) asNode ) ;
45144530 break ;
@@ -4814,6 +4830,15 @@ public override void VisitIfStatement(IfStatementSyntax node)
48144830
48154831 switch ( kind )
48164832 {
4833+ case SyntaxKind . EmptyStatement :
4834+ VisitEmptyStatement ( ( EmptyStatementSyntax ) asNode ) ;
4835+ break ;
4836+ case SyntaxKind . IfStatement :
4837+ VisitIfStatement ( ( IfStatementSyntax ) asNode ) ;
4838+ break ;
4839+ case SyntaxKind . ThrowStatement :
4840+ VisitThrowStatement ( ( ThrowStatementSyntax ) asNode ) ;
4841+ break ;
48174842 case SyntaxKind . BreakStatement :
48184843 VisitBreakStatement ( ( BreakStatementSyntax ) asNode ) ;
48194844 break ;
@@ -6120,25 +6145,24 @@ public bool IdentifierToken(SyntaxNode node)
61206145 _containingNamespace = string . Empty ;
61216146 }
61226147
6123- if ( _GlobalStatement )
6148+ if ( _GlobalStatement || _containingNamespace . Contains ( _NameSpaceStr ) )
61246149 {
61256150 if ( iSymbol . Kind == SymbolKind . Parameter ||
61266151 iSymbol . Kind == SymbolKind . Local )
61276152 {
61286153 return false ;
61296154 }
6155+ }
6156+
6157+ if ( _GlobalStatement )
6158+ {
61306159 if ( iSymbol . Kind == SymbolKind . Method &&
61316160 ( ( IMethodSymbol ) iSymbol ) . MethodKind == MethodKind . LocalFunction )
61326161 return false ;
61336162 }
61346163
61356164 if ( _containingNamespace . Contains ( _NameSpaceStr ) && ! _GlobalStatement )
61366165 {
6137- if ( iSymbol . Kind == SymbolKind . Parameter ||
6138- iSymbol . Kind == SymbolKind . Local )
6139- {
6140- return false ;
6141- }
61426166 if ( ! _ThisIsUsed )
61436167 {
61446168 if ( iSymbol . Kind == SymbolKind . Method &&
@@ -6189,85 +6213,6 @@ public bool IdentifierToken(SyntaxNode node)
61896213 return false ;
61906214 }
61916215 }
6192- /*
6193- ClassDeclarationSyntax? _class = node.Ancestors().FirstOrDefault(n => n.IsKind(SyntaxKind.ClassDeclaration)) as ClassDeclarationSyntax;
6194-
6195- if (_class == null)
6196- {
6197- //TODO?
6198- //Hitting with "TestPropertiesDefaultValue" + "CustomClass()" + "new CustomClass()"
6199- Log.WarningLine("_class is null");
6200- return false;
6201- }
6202- //This is for struct.
6203- //maybe later convert struct to class?
6204- //
6205- if (_class == default(ClassDeclarationSyntax))
6206- {
6207- Log.WarningLine("_class is default");
6208- return false;
6209- }
6210-
6211- SyntaxList<MemberDeclarationSyntax> _members = _class.Members;
6212-
6213- for (int i = 0; i < _members.Count; i++)
6214- {
6215- SyntaxToken _sT = default;
6216- if (_members[i] is MethodDeclarationSyntax m)
6217- {
6218- _sT = m.Identifier;
6219- }
6220-
6221- if (_members[i] is PropertyDeclarationSyntax p)
6222- {
6223- _sT = p.Identifier;
6224- }
6225-
6226- if (_members[i] is FieldDeclarationSyntax f)
6227- {
6228- IEnumerable<SyntaxNode> vds = (from el in f.DescendantNodes()
6229- where el.IsKind(SyntaxKind.VariableDeclarator)
6230- select el);
6231-
6232- IEnumerable<SyntaxNodeOrToken> d3 = from e in vds.First().DescendantNodesAndTokens()
6233- where e.IsKind(SyntaxKind.IdentifierToken)
6234- select e;
6235-
6236- _sT = (SyntaxToken)d3.First();
6237- }
6238-
6239- if (_sT.ToString() == node.ToString())
6240- {
6241- if (node.Parent != null &&
6242- node.Parent.Parent != null &&
6243- !node.Parent.DescendantNodes().Any((e) => e.IsKind(SyntaxKind.ThisExpression)))
6244- {
6245- if (node.Parent is MemberAccessExpressionSyntax member)
6246- {
6247- ISymbol? _iSymbolParent = _Model.GetSymbolInfo(member.Expression).Symbol;
6248- if (_iSymbolParent != null && (_iSymbolParent.Kind == SymbolKind.Local || _iSymbolParent.Kind == SymbolKind.Method))
6249- return false;
6250- }
6251-
6252- if (_class.Identifier.Text == _CurrentClassStr)
6253- {
6254- VisitLeadingTrivia(identifier);
6255-
6256- JSSB.Append($"this.");
6257- VisitToken(identifier.WithoutTrivia());
6258-
6259- VisitTrailingTrivia(identifier);
6260-
6261- return true;
6262- }
6263- }
6264- else
6265- {
6266- Log.WarningLine("node.Parent is null or kind is not ThisExpression");
6267- }
6268- }
6269- }
6270- */
62716216 return false ;
62726217 }
62736218 }
0 commit comments