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;
            }
        }
Exemple #2
0
        internal Edit(EditKind kind, TreeComparer <TNode> comparer, TNode node1, TNode node2)
        {
            Debug.Assert((node1 == null || node1.Equals(default(TNode))) == (kind == EditKind.Insert));
            Debug.Assert((node2 == null || node2.Equals(default(TNode))) == (kind == EditKind.Delete));

            Debug.Assert((node1 == null || node1.Equals(default(TNode))) ||
                         (node2 == null || node2.Equals(default(TNode))) ||
                         !comparer.TreesEqual(node1, node2));

            this.comparer = comparer;
            this.kind     = kind;
            this.node1    = node1;
            this.node2    = node2;
        }
Exemple #3
0
        internal Edit(EditKind kind, TreeComparer <TNode> comparer, TNode oldNode, TNode newNode)
        {
            Debug.Assert((oldNode == null || oldNode.Equals(null)) == (kind == EditKind.Insert));
            Debug.Assert((newNode == null || newNode.Equals(null)) == (kind == EditKind.Delete));

            Debug.Assert((oldNode == null || oldNode.Equals(null)) ||
                         (newNode == null || newNode.Equals(null)) ||
                         !comparer.TreesEqual(oldNode, newNode));

            _comparer = comparer;
            _kind     = kind;
            _oldNode  = oldNode;
            _newNode  = newNode;
        }
Exemple #4
0
        internal Edit(EditKind kind, TreeComparer <TNode> comparer, TNode oldNode, TNode newNode)
        {
            Debug.Assert((oldNode == null || oldNode.Equals(default(TNode))) == (kind == EditKind.Insert));
            Debug.Assert((newNode == null || newNode.Equals(default(TNode))) == (kind == EditKind.Delete));

            Debug.Assert((oldNode == null || oldNode.Equals(default(TNode))) ||
                         (newNode == null || newNode.Equals(default(TNode))) ||
                         !comparer.TreesEqual(oldNode, newNode));

            this.comparer = comparer;
            this.kind     = kind;
            this.oldNode  = oldNode;
            this.newNode  = newNode;
        }
        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);
            }
        }
        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;
        }
 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;
 }
        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);
        }
 protected override string GetStatementDisplayName(SyntaxNode node, EditKind editKind)
 {
     return GetStatementDisplayNameImpl(node);
 }
        // 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;

                case SyntaxKind.TypeParameterList:
                case SyntaxKind.TypeParameter:
                    return FeaturesResources.TypeParameter;

                case SyntaxKind.Parameter:
                    return FeaturesResources.Parameter;

                case SyntaxKind.AttributeList:
                    return (editKind == EditKind.Update) ? CSharpFeaturesResources.AttributeTarget : FeaturesResources.Attribute;

                case SyntaxKind.Attribute:
                    return FeaturesResources.Attribute;

                default:
                    throw ExceptionUtilities.UnexpectedValue(node.Kind());
            }
        }
 private void btnEnlargeArchitecture_Click(object sender, EventArgs e)
 {
     this.CurrentKind = EditKind.増筑;
     this.TargetArchitecture = null;
     this.lbConment.Text = "请先点击一个建筑物,然后再点击需要増筑的相邻坐标。";
 }
 protected override string GetTopLevelDisplayName(SyntaxNode node, EditKind editKind)
 {
     return GetTopLevelDisplayNameImpl(node, editKind);
 }
 protected override TextSpan GetDiagnosticSpan(SyntaxNode node, EditKind editKind)
 {
     return GetDiagnosticSpanImpl(node, editKind);
 }
 private static TextSpan GetDiagnosticSpanImpl(SyntaxNode node, EditKind editKind)
 {
     return GetDiagnosticSpanImpl(node.Kind(), node, editKind);
 }
        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;
            }
        }
 private void btnArchitecturePort_Click(object sender, EventArgs e)
 {
     this.ArchitectureIndex = 3;
     this.CurrentKind = EditKind.新增;
 }
 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;
     }
 }
 private void btnDeleteArchitecture_Click(object sender, EventArgs e)
 {
     this.CurrentKind = EditKind.删除;
     this.TargetArchitecture = null;
 }
Exemple #19
0
 internal Edit(EditKind kind, TreeComparer <TNode> comparer, TNode oldNode, TNode newNode)
 {
     Debug.Assert((oldNode == null || oldNode.Equals(default)) == (kind == EditKind.Insert));
Exemple #20
0
 internal Edit(EditKind kind, int indexA, int indexB)
 {
     this.Kind   = kind;
     this.IndexA = indexA;
     this.IndexB = indexB;
 }
        // 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;

                case SyntaxKind.AccessorList:
                case SyntaxKind.TypeParameterList:
                case SyntaxKind.ParameterList:
                case SyntaxKind.BracketedParameterList:
                    if (editKind == EditKind.Delete)
                    {
                        return GetDiagnosticSpanImpl(node.Parent, editKind);
                    }
                    else
                    {
                        return node.Span;
                    }

                case SyntaxKind.Parameter:
                    // We ignore anonymous methods and lambdas, 
                    // we only care about parameters of member declarations.
                    var parameter = (ParameterSyntax)node;
                    return GetDiagnosticSpan(parameter.Modifiers, parameter.Type, parameter);

                case SyntaxKind.AttributeList:
                    var attributeList = (AttributeListSyntax)node;
                    if (editKind == EditKind.Update)
                    {
                        return (attributeList.Target != null) ? attributeList.Target.Span : attributeList.Span;
                    }
                    else
                    {
                        return attributeList.Span;
                    }

                case SyntaxKind.Attribute:
                case SyntaxKind.ArrowExpressionClause:
                    return node.Span;

                // We only need a diagnostic span if reporting an error for a child statement.
                // The following statements may have child statements.

                case SyntaxKind.Block:
                    return ((BlockSyntax)node).OpenBraceToken.Span;

                case SyntaxKind.UsingStatement:
                    var usingStatement = (UsingStatementSyntax)node;
                    return TextSpan.FromBounds(usingStatement.UsingKeyword.SpanStart, usingStatement.CloseParenToken.Span.End);

                case SyntaxKind.FixedStatement:
                    var fixedStatement = (FixedStatementSyntax)node;
                    return TextSpan.FromBounds(fixedStatement.FixedKeyword.SpanStart, fixedStatement.CloseParenToken.Span.End);

                case SyntaxKind.LockStatement:
                    var lockStatement = (LockStatementSyntax)node;
                    return TextSpan.FromBounds(lockStatement.LockKeyword.SpanStart, lockStatement.CloseParenToken.Span.End);

                case SyntaxKind.StackAllocArrayCreationExpression:
                    return ((StackAllocArrayCreationExpressionSyntax)node).StackAllocKeyword.Span;

                case SyntaxKind.TryStatement:
                    return ((TryStatementSyntax)node).TryKeyword.Span;

                case SyntaxKind.CatchClause:
                    return ((CatchClauseSyntax)node).CatchKeyword.Span;

                case SyntaxKind.CatchDeclaration:
                case SyntaxKind.CatchFilterClause:
                    return node.Span;

                case SyntaxKind.FinallyClause:
                    return ((FinallyClauseSyntax)node).FinallyKeyword.Span;

                case SyntaxKind.IfStatement:
                    var ifStatement = (IfStatementSyntax)node;
                    return TextSpan.FromBounds(ifStatement.IfKeyword.SpanStart, ifStatement.CloseParenToken.Span.End);

                case SyntaxKind.ElseClause:
                    return ((ElseClauseSyntax)node).ElseKeyword.Span;

                case SyntaxKind.SwitchStatement:
                    var switchStatement = (SwitchStatementSyntax)node;
                    return TextSpan.FromBounds(switchStatement.SwitchKeyword.SpanStart, switchStatement.CloseParenToken.Span.End);

                case SyntaxKind.SwitchSection:
                    return ((SwitchSectionSyntax)node).Labels.Last().Span;

                case SyntaxKind.WhileStatement:
                    var whileStatement = (WhileStatementSyntax)node;
                    return TextSpan.FromBounds(whileStatement.WhileKeyword.SpanStart, whileStatement.CloseParenToken.Span.End);

                case SyntaxKind.DoStatement:
                    return ((DoStatementSyntax)node).DoKeyword.Span;

                case SyntaxKind.ForStatement:
                    var forStatement = (ForStatementSyntax)node;
                    return TextSpan.FromBounds(forStatement.ForKeyword.SpanStart, forStatement.CloseParenToken.Span.End);

                case SyntaxKind.ForEachStatement:
                    var forEachStatement = (ForEachStatementSyntax)node;
                    return TextSpan.FromBounds(forEachStatement.ForEachKeyword.SpanStart, forEachStatement.CloseParenToken.Span.End);

                case SyntaxKind.LabeledStatement:
                    return ((LabeledStatementSyntax)node).Identifier.Span;

                case SyntaxKind.CheckedStatement:
                case SyntaxKind.UncheckedStatement:
                    return ((CheckedStatementSyntax)node).Keyword.Span;

                case SyntaxKind.UnsafeStatement:
                    return ((UnsafeStatementSyntax)node).UnsafeKeyword.Span;

                case SyntaxKind.YieldBreakStatement:
                case SyntaxKind.YieldReturnStatement:
                case SyntaxKind.ReturnStatement:
                case SyntaxKind.ThrowStatement:
                case SyntaxKind.ExpressionStatement:
                case SyntaxKind.LocalDeclarationStatement:
                case SyntaxKind.GotoStatement:
                case SyntaxKind.GotoCaseStatement:
                case SyntaxKind.GotoDefaultStatement:
                case SyntaxKind.BreakStatement:
                case SyntaxKind.ContinueStatement:
                    return node.Span;

                case SyntaxKind.AwaitExpression:
                    return ((AwaitExpressionSyntax)node).AwaitKeyword.Span;

                case SyntaxKind.AnonymousObjectCreationExpression:
                    return ((AnonymousObjectCreationExpressionSyntax)node).NewKeyword.Span;

                case SyntaxKind.ParenthesizedLambdaExpression:
                    return ((ParenthesizedLambdaExpressionSyntax)node).ParameterList.Span;

                case SyntaxKind.SimpleLambdaExpression:
                    return ((SimpleLambdaExpressionSyntax)node).Parameter.Span;

                case SyntaxKind.AnonymousMethodExpression:
                    return ((AnonymousMethodExpressionSyntax)node).DelegateKeyword.Span;

                case SyntaxKind.QueryExpression:
                    return ((QueryExpressionSyntax)node).FromClause.FromKeyword.Span;

                case SyntaxKind.QueryBody:
                    var queryBody = (QueryBodySyntax)node;
                    return GetDiagnosticSpanImpl(queryBody.Clauses.FirstOrDefault() ?? queryBody.Parent, editKind);

                case SyntaxKind.QueryContinuation:
                    return ((QueryContinuationSyntax)node).IntoKeyword.Span;

                case SyntaxKind.FromClause:
                    return ((FromClauseSyntax)node).FromKeyword.Span;

                case SyntaxKind.JoinClause:
                    return ((JoinClauseSyntax)node).JoinKeyword.Span;

                case SyntaxKind.JoinIntoClause:
                    return ((JoinIntoClauseSyntax)node).IntoKeyword.Span;

                case SyntaxKind.LetClause:
                    return ((LetClauseSyntax)node).LetKeyword.Span;

                case SyntaxKind.WhereClause:
                    return ((WhereClauseSyntax)node).WhereKeyword.Span;

                case SyntaxKind.OrderByClause:
                    return ((OrderByClauseSyntax)node).OrderByKeyword.Span;

                case SyntaxKind.AscendingOrdering:
                case SyntaxKind.DescendingOrdering:
                    return node.Span;

                case SyntaxKind.SelectClause:
                    return ((SelectClauseSyntax)node).SelectKeyword.Span;

                case SyntaxKind.GroupClause:
                    return ((GroupClauseSyntax)node).GroupKeyword.Span;

                default:
                    throw ExceptionUtilities.UnexpectedValue(kind);
            }
        }
        // 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";

                case SyntaxKind.TypeParameterList:
                case SyntaxKind.TypeParameter:
                    return "type parameter";

                case SyntaxKind.Parameter:
                    return "parameter";

                case SyntaxKind.AttributeList:
                    return (editKind == EditKind.Update) ? "attribute target" : "attribute";

                case SyntaxKind.Attribute:
                    return "attribute";

                default:
                    throw ExceptionUtilities.Unreachable;
            }
        }
 private void btnWaterLinks_Click(object sender, EventArgs e)
 {
     this.CurrentKind = EditKind.水上;
     this.TargetArchitecture = null;
     this.lbConment.Text = "请先点击一个建筑物,然后再点击需要添加水上链接的建筑。";
 }