コード例 #1
0
        private void CompleteElementTag(ActiproSoftware.SyntaxEditor.SyntaxEditor syntaxEditor, int offset)
        {
            string     str        = null;
            TextStream textStream = syntaxEditor.get_Document().GetTextStream(offset);

            if (textStream.GoToPreviousToken() && ((textStream.get_Token().get_Key() == "StartTagEndToken") && ((offset - textStream.get_Offset()) == 1)))
            {
                bool flag = false;
                while (textStream.GoToPreviousToken())
                {
                    string str2 = textStream.get_Token().get_Key();
                    if (str2 != null)
                    {
                        if (!(str2 == "StartTagNameToken"))
                        {
                            if ((str2 == "StartTagStartToken") || (str2 == "EndTagEndToken"))
                            {
                                return;
                            }
                        }
                        else
                        {
                            str  = textStream.get_TokenText().Trim();
                            flag = true;
                        }
                    }
                    if (flag)
                    {
                        break;
                    }
                }
                if (str != null)
                {
                    textStream.set_Offset(offset);
                    flag = false;
                    while (!textStream.get_IsAtDocumentEnd())
                    {
                        switch (textStream.get_Token().get_Key())
                        {
                        case "EndTagDefaultToken":
                            if (str == textStream.get_TokenText().Trim())
                            {
                                return;
                            }
                            flag = true;
                            break;

                        case "StartTagStartToken":
                        case "EndTagEndToken":
                            flag = true;
                            break;
                        }
                        if (flag)
                        {
                            break;
                        }
                        textStream.GoToNextToken();
                    }
                    syntaxEditor.get_SelectedView().InsertSurroundingText(0, null, "</" + str + ">");
                }
            }
        }