File: Classification\SyntaxClassification\OperatorOverloadSyntaxClassifier.vb
Web Access
Project: ..\..\..\src\Workspaces\VisualBasic\Portable\Microsoft.CodeAnalysis.VisualBasic.Workspaces.vbproj (Microsoft.CodeAnalysis.VisualBasic.Workspaces)
' Licensed to the .NET Foundation under one or more agreements.
' The .NET Foundation licenses this file to you under the MIT license.
' See the LICENSE file in the project root for more information.
 
Imports System.Collections.Immutable
Imports System.Threading
Imports Microsoft.CodeAnalysis.Classification
Imports Microsoft.CodeAnalysis.Classification.Classifiers
Imports Microsoft.CodeAnalysis.PooledObjects
Imports Microsoft.CodeAnalysis.VisualBasic.Syntax
 
Namespace Microsoft.CodeAnalysis.VisualBasic.Classification.Classifiers
 
    Friend Class OperatorOverloadSyntaxClassifier
        Inherits AbstractSyntaxClassifier
 
        Public Overrides ReadOnly Property SyntaxNodeTypes As ImmutableArray(Of Type) = ImmutableArray.Create(
            GetType(BinaryExpressionSyntax),
            GetType(UnaryExpressionSyntax))
 
        Public Overrides Sub AddClassifications(
            syntax As SyntaxNode,
            semanticModel As SemanticModel,
options As ClassificationOptions,
            result As ArrayBuilder(Of ClassifiedSpan), cancellationToken As CancellationToken)
 
            Dim symbolInfo = semanticModel.GetSymbolInfo(syntax, cancellationToken)
            If TypeOf symbolInfo.Symbol Is IMethodSymbol AndAlso
                DirectCast(symbolInfo.Symbol, IMethodSymbol).MethodKind = MethodKind.UserDefinedOperator Then
 
                If TypeOf syntax Is BinaryExpressionSyntax Then
                    result.Add(New ClassifiedSpan(DirectCast(syntax, BinaryExpressionSyntax).OperatorToken.Span, ClassificationTypeNames.OperatorOverloaded))
                ElseIf TypeOf syntax Is UnaryExpressionSyntax Then
                    result.Add(New ClassifiedSpan(DirectCast(syntax, UnaryExpressionSyntax).OperatorToken.Span, ClassificationTypeNames.OperatorOverloaded))
                End If
            End If
        End Sub
    End Class
End Namespace