当前位置: 首页>>代码示例>>C#>>正文


C# EditKind类代码示例

本文整理汇总了C#中EditKind的典型用法代码示例。如果您正苦于以下问题:C# EditKind类的具体用法?C# EditKind怎么用?C# EditKind使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。


EditKind类属于命名空间,在下文中一共展示了EditKind类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: IsGetterToExpressionBodyTransformation

        private static bool IsGetterToExpressionBodyTransformation(EditKind editKind, SyntaxNode node, Dictionary<SyntaxNode, EditKind> editMap)
        {
            if ((editKind == EditKind.Insert || editKind == EditKind.Delete) && node.IsKind(SyntaxKind.GetAccessorDeclaration))
            {
                Debug.Assert(node.Parent.IsKind(SyntaxKind.AccessorList));
                Debug.Assert(node.Parent.Parent.IsKind(SyntaxKind.PropertyDeclaration) || node.Parent.Parent.IsKind(SyntaxKind.IndexerDeclaration));

                EditKind parentEdit;
                return editMap.TryGetValue(node.Parent, out parentEdit) && parentEdit == editKind &&
                       editMap.TryGetValue(node.Parent.Parent, out parentEdit) && parentEdit == EditKind.Update;
            }

            return false;
        }
开发者ID:GeertVL,项目名称:roslyn,代码行数:14,代码来源:CSharpEditAndContinueAnalyzer.cs

示例2: EditClassifier

 public EditClassifier(
     CSharpEditAndContinueAnalyzer analyzer,
     List<RudeEditDiagnostic> diagnostics,
     SyntaxNode oldNode,
     SyntaxNode newNode,
     EditKind kind,
     Match<SyntaxNode> match = null,
     TextSpan? span = null)
 {
     _analyzer = analyzer;
     _diagnostics = diagnostics;
     _oldNode = oldNode;
     _newNode = newNode;
     _kind = kind;
     _span = span;
     _match = match;
 }
开发者ID:GeertVL,项目名称:roslyn,代码行数:17,代码来源:CSharpEditAndContinueAnalyzer.cs

示例3: GetSymbolForEdit

        protected override ISymbol GetSymbolForEdit(SemanticModel model, SyntaxNode node, EditKind editKind, Dictionary<SyntaxNode, EditKind> editMap, CancellationToken cancellationToken)
        {
            if (node.IsKind(SyntaxKind.Parameter))
            {
                return null;
            }

            if (editKind == EditKind.Update)
            {
                if (node.IsKind(SyntaxKind.EnumDeclaration))
                {
                    // Enum declaration update that removes/adds a trailing comma.
                    return null;
                }

                if (node.IsKind(SyntaxKind.IndexerDeclaration) || node.IsKind(SyntaxKind.PropertyDeclaration))
                {
                    // The only legitimate update of an indexer/property declaration is an update of its expression body.
                    // The expression body itself may have been updated, replaced with an explicit getter, or added to replace an explicit getter.
                    // In any case, the update is to the property getter symbol.
                    var propertyOrIndexer = model.GetDeclaredSymbol(node, cancellationToken);
                    return ((IPropertySymbol)propertyOrIndexer).GetMethod;
                }
            }

            if (IsGetterToExpressionBodyTransformation(editKind, node, editMap))
            {
                return null;
            }

            return model.GetDeclaredSymbol(node, cancellationToken);
        }
开发者ID:GeertVL,项目名称:roslyn,代码行数:32,代码来源:CSharpEditAndContinueAnalyzer.cs

示例4: GetStatementDisplayName

 protected override string GetStatementDisplayName(SyntaxNode node, EditKind editKind)
 {
     return GetStatementDisplayNameImpl(node);
 }
开发者ID:GeertVL,项目名称:roslyn,代码行数:4,代码来源:CSharpEditAndContinueAnalyzer.cs

示例5: GetTopLevelDisplayNameImpl

        // internal for testing
        internal static string GetTopLevelDisplayNameImpl(SyntaxNode node, EditKind editKind)
        {
            switch (node.Kind())
            {
                case SyntaxKind.GlobalStatement:
                    return CSharpFeaturesResources.GlobalStatement;

                case SyntaxKind.ExternAliasDirective:
                    return CSharpFeaturesResources.UsingNamespace;

                case SyntaxKind.UsingDirective:
                    // Dev12 distinguishes using alias from using namespace and reports different errors for removing alias.
                    // None of these changes are allowed anyways, so let's keep it simple.
                    return CSharpFeaturesResources.UsingDirective;

                case SyntaxKind.NamespaceDeclaration:
                    return FeaturesResources.Namespace;

                case SyntaxKind.ClassDeclaration:
                    return FeaturesResources.Class;

                case SyntaxKind.StructDeclaration:
                    return CSharpFeaturesResources.Struct;

                case SyntaxKind.InterfaceDeclaration:
                    return FeaturesResources.Interface;

                case SyntaxKind.EnumDeclaration:
                    return FeaturesResources.Enum;

                case SyntaxKind.DelegateDeclaration:
                    return FeaturesResources.Delegate;

                case SyntaxKind.FieldDeclaration:
                    var declaration = (FieldDeclarationSyntax)node;
                    return declaration.Modifiers.Any(SyntaxKind.ConstKeyword) ? FeaturesResources.ConstField : FeaturesResources.Field;

                case SyntaxKind.EventFieldDeclaration:
                    return CSharpFeaturesResources.EventField;

                case SyntaxKind.VariableDeclaration:
                case SyntaxKind.VariableDeclarator:
                    return GetTopLevelDisplayNameImpl(node.Parent, editKind);

                case SyntaxKind.MethodDeclaration:
                    return FeaturesResources.Method;

                case SyntaxKind.ConversionOperatorDeclaration:
                    return CSharpFeaturesResources.ConversionOperator;

                case SyntaxKind.OperatorDeclaration:
                    return FeaturesResources.Operator;

                case SyntaxKind.ConstructorDeclaration:
                    return FeaturesResources.Constructor;

                case SyntaxKind.DestructorDeclaration:
                    return CSharpFeaturesResources.Destructor;

                case SyntaxKind.PropertyDeclaration:
                    return SyntaxUtilities.HasBackingField((PropertyDeclarationSyntax)node) ? FeaturesResources.AutoProperty : FeaturesResources.Property;

                case SyntaxKind.IndexerDeclaration:
                    return CSharpFeaturesResources.Indexer;

                case SyntaxKind.EventDeclaration:
                    return FeaturesResources.Event;

                case SyntaxKind.EnumMemberDeclaration:
                    return FeaturesResources.EnumValue;

                case SyntaxKind.GetAccessorDeclaration:
                    if (node.Parent.Parent.IsKind(SyntaxKind.PropertyDeclaration))
                    {
                        return CSharpFeaturesResources.PropertyGetter;
                    }
                    else
                    {
                        Debug.Assert(node.Parent.Parent.IsKind(SyntaxKind.IndexerDeclaration));
                        return CSharpFeaturesResources.IndexerGetter;
                    }

                case SyntaxKind.SetAccessorDeclaration:
                    if (node.Parent.Parent.IsKind(SyntaxKind.PropertyDeclaration))
                    {
                        return CSharpFeaturesResources.PropertySetter;
                    }
                    else
                    {
                        Debug.Assert(node.Parent.Parent.IsKind(SyntaxKind.IndexerDeclaration));
                        return CSharpFeaturesResources.IndexerSetter;
                    }

                case SyntaxKind.AddAccessorDeclaration:
                case SyntaxKind.RemoveAccessorDeclaration:
                    return FeaturesResources.EventAccessor;

                case SyntaxKind.TypeParameterConstraintClause:
                    return FeaturesResources.TypeConstraint;
//.........这里部分代码省略.........
开发者ID:GeertVL,项目名称:roslyn,代码行数:101,代码来源:CSharpEditAndContinueAnalyzer.cs

示例6: GetDiagnosticSpanImpl

        // internal for testing; kind is passed explicitly for testing as well
        internal static TextSpan GetDiagnosticSpanImpl(SyntaxKind kind, SyntaxNode node, EditKind editKind)
        {
            switch (kind)
            {
                case SyntaxKind.CompilationUnit:
                    return default(TextSpan);

                case SyntaxKind.GlobalStatement:
                    // TODO:
                    return default(TextSpan);

                case SyntaxKind.ExternAliasDirective:
                case SyntaxKind.UsingDirective:
                    return node.Span;

                case SyntaxKind.NamespaceDeclaration:
                    var ns = (NamespaceDeclarationSyntax)node;
                    return TextSpan.FromBounds(ns.NamespaceKeyword.SpanStart, ns.Name.Span.End);

                case SyntaxKind.ClassDeclaration:
                case SyntaxKind.StructDeclaration:
                case SyntaxKind.InterfaceDeclaration:
                    var typeDeclaration = (TypeDeclarationSyntax)node;
                    return GetDiagnosticSpan(typeDeclaration.Modifiers, typeDeclaration.Keyword,
                        typeDeclaration.TypeParameterList ?? (SyntaxNodeOrToken)typeDeclaration.Identifier);

                case SyntaxKind.EnumDeclaration:
                    var enumDeclaration = (EnumDeclarationSyntax)node;
                    return GetDiagnosticSpan(enumDeclaration.Modifiers, enumDeclaration.EnumKeyword, enumDeclaration.Identifier);

                case SyntaxKind.DelegateDeclaration:
                    var delegateDeclaration = (DelegateDeclarationSyntax)node;
                    return GetDiagnosticSpan(delegateDeclaration.Modifiers, delegateDeclaration.DelegateKeyword, delegateDeclaration.ParameterList);

                case SyntaxKind.FieldDeclaration:
                    var fieldDeclaration = (BaseFieldDeclarationSyntax)node;
                    return GetDiagnosticSpan(fieldDeclaration.Modifiers, fieldDeclaration.Declaration, fieldDeclaration.Declaration);

                case SyntaxKind.EventFieldDeclaration:
                    var eventFieldDeclaration = (EventFieldDeclarationSyntax)node;
                    return GetDiagnosticSpan(eventFieldDeclaration.Modifiers, eventFieldDeclaration.EventKeyword, eventFieldDeclaration.Declaration);

                case SyntaxKind.VariableDeclaration:
                    return GetDiagnosticSpanImpl(node.Parent, editKind);

                case SyntaxKind.VariableDeclarator:
                    return node.Span;

                case SyntaxKind.MethodDeclaration:
                    var methodDeclaration = (MethodDeclarationSyntax)node;
                    return GetDiagnosticSpan(methodDeclaration.Modifiers, methodDeclaration.ReturnType, methodDeclaration.ParameterList);

                case SyntaxKind.ConversionOperatorDeclaration:
                    var conversionOperatorDeclaration = (ConversionOperatorDeclarationSyntax)node;
                    return GetDiagnosticSpan(conversionOperatorDeclaration.Modifiers, conversionOperatorDeclaration.ImplicitOrExplicitKeyword, conversionOperatorDeclaration.ParameterList);

                case SyntaxKind.OperatorDeclaration:
                    var operatorDeclaration = (OperatorDeclarationSyntax)node;
                    return GetDiagnosticSpan(operatorDeclaration.Modifiers, operatorDeclaration.ReturnType, operatorDeclaration.ParameterList);

                case SyntaxKind.ConstructorDeclaration:
                    var constructorDeclaration = (ConstructorDeclarationSyntax)node;
                    return GetDiagnosticSpan(constructorDeclaration.Modifiers, constructorDeclaration.Identifier, constructorDeclaration.ParameterList);

                case SyntaxKind.DestructorDeclaration:
                    var destructorDeclaration = (DestructorDeclarationSyntax)node;
                    return GetDiagnosticSpan(destructorDeclaration.Modifiers, destructorDeclaration.TildeToken, destructorDeclaration.ParameterList);

                case SyntaxKind.PropertyDeclaration:
                    var propertyDeclaration = (PropertyDeclarationSyntax)node;
                    return GetDiagnosticSpan(propertyDeclaration.Modifiers, propertyDeclaration.Type, propertyDeclaration.Identifier);

                case SyntaxKind.IndexerDeclaration:
                    var indexerDeclaration = (IndexerDeclarationSyntax)node;
                    return GetDiagnosticSpan(indexerDeclaration.Modifiers, indexerDeclaration.Type, indexerDeclaration.ParameterList);

                case SyntaxKind.EventDeclaration:
                    var eventDeclaration = (EventDeclarationSyntax)node;
                    return GetDiagnosticSpan(eventDeclaration.Modifiers, eventDeclaration.EventKeyword, eventDeclaration.Identifier);

                case SyntaxKind.EnumMemberDeclaration:
                    return node.Span;

                case SyntaxKind.GetAccessorDeclaration:
                case SyntaxKind.SetAccessorDeclaration:
                case SyntaxKind.AddAccessorDeclaration:
                case SyntaxKind.RemoveAccessorDeclaration:
                case SyntaxKind.UnknownAccessorDeclaration:
                    var accessorDeclaration = (AccessorDeclarationSyntax)node;
                    return GetDiagnosticSpan(accessorDeclaration.Modifiers, accessorDeclaration.Keyword, accessorDeclaration.Keyword);

                case SyntaxKind.TypeParameterConstraintClause:
                    var constraint = (TypeParameterConstraintClauseSyntax)node;
                    return TextSpan.FromBounds(constraint.WhereKeyword.SpanStart, constraint.Constraints.Last().Span.End);

                case SyntaxKind.TypeParameter:
                    var typeParameter = (TypeParameterSyntax)node;
                    return typeParameter.Identifier.Span;

//.........这里部分代码省略.........
开发者ID:GeertVL,项目名称:roslyn,代码行数:101,代码来源:CSharpEditAndContinueAnalyzer.cs

示例7: GetTopLevelDisplayName

 protected override string GetTopLevelDisplayName(SyntaxNode node, EditKind editKind)
 {
     return GetTopLevelDisplayNameImpl(node, editKind);
 }
开发者ID:GeertVL,项目名称:roslyn,代码行数:4,代码来源:CSharpEditAndContinueAnalyzer.cs

示例8: GetDiagnosticSpan

 protected override TextSpan GetDiagnosticSpan(SyntaxNode node, EditKind editKind)
 {
     return GetDiagnosticSpanImpl(node, editKind);
 }
开发者ID:GeertVL,项目名称:roslyn,代码行数:4,代码来源:CSharpEditAndContinueAnalyzer.cs

示例9: GetPrefixChar

 private static char? GetPrefixChar(EditKind editKind)
 {
     switch (editKind)
     {
         case EditKind.None:
             return null;
         case EditKind.Command:
             return ':';
         case EditKind.SearchForward:
             return '/';
         case EditKind.SearchBackward:
             return '?';
         default:
             Contract.FailEnumValue(editKind);
             return null;
     }
 }
开发者ID:louisfeng,项目名称:VsVim,代码行数:17,代码来源:CommandMarginController.cs

示例10: ChangeEditKind

        private void ChangeEditKind(EditKind editKind)
        {
            if (editKind == _editKind)
            {
                return;
            }

            _editKind = editKind;
            switch (editKind)
            {
                case EditKind.None:
                    // Make sure that the editor has focus
                    if (ParentVisualElement != null)
                    {
                        ParentVisualElement.Focus();
                    }
                    _margin.IsEditReadOnly = true;
                    break;
                case EditKind.Command:
                case EditKind.SearchForward:
                case EditKind.SearchBackward:
                    WpfKeyboard.Focus(_margin.CommandLineTextBox);
                    _margin.IsEditReadOnly = false;
                    break;
                default:
                    Contract.FailEnumValue(editKind);
                    break;
            }
        }
开发者ID:louisfeng,项目名称:VsVim,代码行数:29,代码来源:CommandMarginController.cs

示例11: btnWaterLinks_Click

 private void btnWaterLinks_Click(object sender, EventArgs e)
 {
     this.CurrentKind = EditKind.水上;
     this.TargetArchitecture = null;
     this.lbConment.Text = "请先点击一个建筑物,然后再点击需要添加水上链接的建筑。";
 }
开发者ID:skicean,项目名称:ZhongHuaSanGuoZhi,代码行数:6,代码来源:formMapEditor.cs

示例12: btnEnlargeArchitecture_Click

 private void btnEnlargeArchitecture_Click(object sender, EventArgs e)
 {
     this.CurrentKind = EditKind.増筑;
     this.TargetArchitecture = null;
     this.lbConment.Text = "请先点击一个建筑物,然后再点击需要増筑的相邻坐标。";
 }
开发者ID:skicean,项目名称:ZhongHuaSanGuoZhi,代码行数:6,代码来源:formMapEditor.cs

示例13: btnDeleteArchitecture_Click

 private void btnDeleteArchitecture_Click(object sender, EventArgs e)
 {
     this.CurrentKind = EditKind.删除;
     this.TargetArchitecture = null;
 }
开发者ID:skicean,项目名称:ZhongHuaSanGuoZhi,代码行数:5,代码来源:formMapEditor.cs

示例14: btnArchitecturePort_Click

 private void btnArchitecturePort_Click(object sender, EventArgs e)
 {
     this.ArchitectureIndex = 3;
     this.CurrentKind = EditKind.新增;
 }
开发者ID:skicean,项目名称:ZhongHuaSanGuoZhi,代码行数:5,代码来源:formMapEditor.cs

示例15: GetTopLevelDisplayNameImpl

        // internal for testing
        internal static string GetTopLevelDisplayNameImpl(SyntaxNode node, EditKind editKind)
        {
            switch (node.Kind())
            {
                case SyntaxKind.GlobalStatement:
                    return "global statement";

                case SyntaxKind.ExternAliasDirective:
                    return "using namespace";

                case SyntaxKind.UsingDirective:
                    // Dev12 distinguishes using alias from using namespace and reports different errors for removing alias.
                    // None of these changes are allowed anyways, so let's keep it simple.
                    return "using directive";

                case SyntaxKind.NamespaceDeclaration:
                    return "namespace";

                case SyntaxKind.ClassDeclaration:
                    return "class";

                case SyntaxKind.StructDeclaration:
                    return "struct";

                case SyntaxKind.InterfaceDeclaration:
                    return "interface";

                case SyntaxKind.EnumDeclaration:
                    return "enum";

                case SyntaxKind.DelegateDeclaration:
                    return "delegate";

                case SyntaxKind.FieldDeclaration:
                    return "field";

                case SyntaxKind.EventFieldDeclaration:
                    return "event field";

                case SyntaxKind.VariableDeclaration:
                case SyntaxKind.VariableDeclarator:
                    return GetTopLevelDisplayNameImpl(node.Parent, editKind);

                case SyntaxKind.MethodDeclaration:
                    return "method";

                case SyntaxKind.ConversionOperatorDeclaration:
                    return "conversion operator";

                case SyntaxKind.OperatorDeclaration:
                    return "operator";

                case SyntaxKind.ConstructorDeclaration:
                    return "constructor";

                case SyntaxKind.DestructorDeclaration:
                    return "destructor";

                case SyntaxKind.PropertyDeclaration:
                    return SyntaxUtilities.HasBackingField((PropertyDeclarationSyntax)node) ? "auto-property" : "property";

                case SyntaxKind.IndexerDeclaration:
                    return "indexer";

                case SyntaxKind.EventDeclaration:
                    return "event";

                case SyntaxKind.EnumMemberDeclaration:
                    return "enum value";

                case SyntaxKind.GetAccessorDeclaration:
                    if (node.Parent.Parent.IsKind(SyntaxKind.PropertyDeclaration))
                    {
                        return "property getter";
                    }
                    else
                    {
                        Debug.Assert(node.Parent.Parent.IsKind(SyntaxKind.IndexerDeclaration));
                        return "indexer getter";
                    }

                case SyntaxKind.SetAccessorDeclaration:
                    if (node.Parent.Parent.IsKind(SyntaxKind.PropertyDeclaration))
                    {
                        return "property setter";
                    }
                    else
                    {
                        Debug.Assert(node.Parent.Parent.IsKind(SyntaxKind.IndexerDeclaration));
                        return "indexer setter";
                    }

                case SyntaxKind.AddAccessorDeclaration:
                case SyntaxKind.RemoveAccessorDeclaration:
                    return "event accessor";

                case SyntaxKind.TypeParameterConstraintClause:
                    return "type constraint";

//.........这里部分代码省略.........
开发者ID:elemk0vv,项目名称:roslyn-1,代码行数:101,代码来源:CSharpEditAndContinueAnalyzer.cs


注:本文中的EditKind类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。