Beispiel #1
0
        public override TreeElement ParseErrorElement()
        {
            // NOTE: Doesn't Advance
            var result = TreeElementFactory.CreateErrorElement(ParserMessages.GetUnexpectedTokenMessage());

            return(result);
        }
Beispiel #2
0
        public virtual IChameleonNode ReSync(CachingLexer cachingLexer, TreeTextRange changedRange, int insertedTextLen)
        {
            TreeTextRange oldRange = this.GetTreeTextRange();

            Logger.Assert(changedRange.ContainedIn(oldRange), "The condition “changedRange.ContainedIn(oldRange)” is false.");

            int newLength = oldRange.Length - changedRange.Length + insertedTextLen;

            // Find starting comment
            if (!cachingLexer.FindTokenAt(oldRange.StartOffset.Offset) ||
                cachingLexer.TokenType != this.GetTokenType() ||
                cachingLexer.TokenStart != oldRange.StartOffset.Offset ||
                cachingLexer.TokenEnd != oldRange.StartOffset.Offset + newLength)
            {
                return(null);
            }

            var element = TreeElementFactory.CreateLeafElement(
                cachingLexer.TokenType,
                new ProjectedBuffer(
                    cachingLexer.Buffer, new TextRange(cachingLexer.TokenStart, cachingLexer.TokenStart + newLength)),
                0,
                newLength);
            var comment = element as Comment;

            if (comment == null || this.CommentType != comment.CommentType)
            {
                return(null);
            }
            return(comment);
        }
        protected override TreeElement createToken()
        {
            LeafElementBase element = TreeElementFactory.CreateLeafElement(myLexer.TokenType, myLexer.Buffer, myLexer.TokenStart, myLexer.TokenEnd);

            SetOffset(element, myLexer.TokenStart);
            myLexer.Advance();
            return(element);
        }
Beispiel #4
0
        /// <summary>
        /// Commas must be spaced correctly.
        /// </summary>
        /// <param name="node">
        /// The node to use.
        /// </param>
        public void EqualsMustBeSpacedCorrectly(ITreeNode node)
        {
            List <TokenNodeType> tokensThatCanBeLeftSideOfEquals = new List <TokenNodeType>
            {
                CSharpTokenType.WHITE_SPACE,
                CSharpTokenType.NE,
                CSharpTokenType.LT,
                CSharpTokenType.GT
            };

            const string WhiteSpace = " ";

            for (ITreeNode currentNode = node; currentNode != null; currentNode = currentNode.NextSibling)
            {
                if (currentNode is ITokenNode)
                {
                    ITokenNode tokenNode = currentNode as ITokenNode;

                    if (tokenNode.GetTokenType() == CSharpTokenType.EQ)
                    {
                        ITokenNode nextToken = tokenNode.GetNextToken();

                        ITokenNode previousToken = tokenNode.GetPrevToken();

                        if (!nextToken.IsWhitespace())
                        {
                            using (WriteLockCookie.Create(true))
                            {
                                // insert a space
                                LeafElementBase leafElement = TreeElementFactory.CreateLeafElement(
                                    CSharpTokenType.WHITE_SPACE, new JetBrains.Text.StringBuffer(WhiteSpace), 0, WhiteSpace.Length);
                                LowLevelModificationUtil.AddChildBefore(nextToken, new ITreeNode[] { leafElement });
                            }
                        }

                        if (!tokensThatCanBeLeftSideOfEquals.Contains(previousToken.GetTokenType()))
                        {
                            using (WriteLockCookie.Create(true))
                            {
                                // insert a space
                                LeafElementBase leafElement = TreeElementFactory.CreateLeafElement(
                                    CSharpTokenType.WHITE_SPACE, new JetBrains.Text.StringBuffer(WhiteSpace), 0, WhiteSpace.Length);
                                LowLevelModificationUtil.AddChildBefore(tokenNode, new ITreeNode[] { leafElement });
                            }
                        }
                    }
                }

                if (currentNode.FirstChild != null)
                {
                    this.EqualsMustBeSpacedCorrectly(currentNode.FirstChild);
                }
            }
        }
Beispiel #5
0
        public static IncludedFile FromOtherNode([NotNull] IT4FileLikeNode node)
        {
            var includedFile = (IncludedFile)TreeElementFactory.CreateCompositeElement(ElementType.INCLUDED_FILE);

            foreach (var child in node.Children().Cast <TreeElement>().ToList())
            {
                includedFile.AppendNewChild(child);
            }

            includedFile.LogicalPsiSourceFile = node.LogicalPsiSourceFile;
            return(includedFile);
        }
Beispiel #6
0
        /// <summary>Adds the blank line after.</summary>
        /// <param name="statement">The statement.</param>
        public void AddBlankLineAfter([NotNull] IStatement statement)
        {
            if (statement == null)
            {
                throw new ArgumentNullException("statement");
            }

            var       newLineText = new StringBuffer("\r\n");
            ITreeNode newLine     = TreeElementFactory.CreateLeafElement(CSharpTokenType.NEW_LINE, newLineText, 0, newLineText.Length);

            ModificationUtil.AddChildAfter(statement, newLine);
        }
        public override TreeElement parseCsharpOrToken()
        {
            TokenNodeType    tokenType;
            CompositeElement result            = null;
            TreeElement      tempParsingResult = null;

            try
            {
                result            = TreeElementFactory.CreateCompositeElement(ElementType.CSHARP_OR_TOKEN);
                tempParsingResult = match(TokenType.LBRACE);
                result.AppendNewChild(tempParsingResult);
                tokenType = myLexer.TokenType;
                if (tokenType == TokenType.IDENTIFIER)
                {
                    var tempParsingResult1 = parseTokenTypeName();
                    tokenType = myLexer.TokenType;
                    if (tokenType == TokenType.RBRACE)
                    {
                        result.AppendNewChild(tempParsingResult1);
                    }
                    else
                    {
                        var node = TreeElementFactory.CreateCompositeElement(ElementType.CSHARP_IDENTIFIER);
                        node.AddChild(tempParsingResult1.FirstChild);
                        tempParsingResult = parseCSharpBlock(node);
                        result.AppendNewChild(tempParsingResult);
                    }
                }
                else
                {
                    tempParsingResult = parseCSharpBlock();
                    result.AppendNewChild(tempParsingResult);
                }
                tempParsingResult = match(TokenType.RBRACE);
                result.AppendNewChild(tempParsingResult);
            }
            catch (SyntaxError e)
            {
                if (e.ParsingResult != null && result != null)
                {
                    result.AppendNewChild(e.ParsingResult);
                }
                if (result != null)
                {
                    e.ParsingResult = result;
                }
                throw;
            }
            return(result);
        }
Beispiel #8
0
        private TreeElement CreateMissingToken()
        {
            var tokenType = myLexer.TokenType;

            if (tokenType == ShaderLabTokenType.WHITESPACE)
            {
                return(new Whitespace(myWhitespaceIntern.Intern(myLexer)));
            }

            if (tokenType == ShaderLabTokenType.NEW_LINE)
            {
                return(new NewLine(myWhitespaceIntern.Intern(myLexer)));
            }

            return(TreeElementFactory.CreateLeafElement(myLexer));
        }
Beispiel #9
0
        public override void ParseErrorTexturePropertyBlockValues(CompositeElement result)
        {
            // Parse anything with the `{ }` of a texture property block
            if (myOriginalLexer.TokenType == ShaderLabTokenType.RBRACE)
            {
                return;
            }

            var errorElement = TreeElementFactory.CreateErrorElement(ParserMessages.GetUnexpectedTokenMessage());

            while (myOriginalLexer.TokenType != ShaderLabTokenType.RBRACE)
            {
                Skip(errorElement);
            }
            result.AppendNewChild(errorElement);
        }
Beispiel #10
0
        private LeafElementBase CreateMissingToken()
        {
            TokenNodeType tokenType = myLexer.TokenType;

            if (tokenType == PsiTokenType.WHITE_SPACE || tokenType == PsiTokenType.NEW_LINE)
            {
                string text = myLexer.GetCurrTokenText();
                if (tokenType == PsiTokenType.WHITE_SPACE)
                {
                    return(new Whitespace(myWhitespaceIntern.Intern(text)));
                }
                return(new NewLine(text));
            }

            return(TreeElementFactory.CreateLeafElement(myLexer));
        }
Beispiel #11
0
        public override TreeElement parsePrefix()
        {
            CompositeElement result = null;

            try
            {
                result = TreeElementFactory.CreateCompositeElement(ElementType.PREFIX);
                var         tokenType = this.myLexer.TokenType;
                TreeElement tempParsingResult;
                if (tokenType == TokenType.PREFIX_IDENTIFIER)
                {
                    tempParsingResult = this.match(TokenType.PREFIX_IDENTIFIER);
                    result.AppendNewChild(tempParsingResult);
                }
                else if (tokenType == TokenType.IDENTIFIER || tokenType == TokenType.NAMESPACE_SEPARATOR)
                {
                    tokenType = this.myLexer.TokenType;
                    if (tokenType == TokenType.IDENTIFIER)
                    {
                        tempParsingResult = this.match(TokenType.IDENTIFIER);
                        result.AppendNewChild(tempParsingResult);
                    }
                    // The namespace separator parsing is moved into the uri identifier to be it's direct child
                }
                else
                {
                    if (result.firstChild == null)
                    {
                        result = null;
                    }
                    throw new UnexpectedToken(ErrorMessages.GetErrorMessage23());
                }
            }
            catch (SyntaxError e)
            {
                if (e.ParsingResult != null && result != null)
                {
                    result.AppendNewChild(e.ParsingResult);
                }
                if (result != null)
                {
                    e.ParsingResult = result;
                }
                throw;
            }
            return(result);
        }
Beispiel #12
0
        public override TreeElement ParseDirective()
        {
            var lookahead = myLexer.LookaheadToken(1);

            if (lookahead == T4TokenNodeTypes.TEMPLATE)
            {
                return(ParseTemplateDirective());
            }
            if (lookahead == T4TokenNodeTypes.PARAMETER)
            {
                return(ParseParameterDirective());
            }
            if (lookahead == T4TokenNodeTypes.OUTPUT)
            {
                return(ParseOutputDirective());
            }
            if (lookahead == T4TokenNodeTypes.ASSEMBLY)
            {
                return(ParseAssemblyDirective());
            }
            if (lookahead == T4TokenNodeTypes.IMPORT)
            {
                return(ParseImportDirective());
            }
            if (lookahead == T4TokenNodeTypes.INCLUDE)
            {
                return(ParseIncludeDirective());
            }
            if (lookahead == T4TokenNodeTypes.CLEANUP_BEHAVIOR)
            {
                return(ParseCleanupBehaviorDirective());
            }
            if (lookahead == T4TokenNodeTypes.UNKNOWN_DIRECTIVE_NAME)
            {
                return(ParseUnknownDirective());
            }
            // Failure
            var result            = TreeElementFactory.CreateCompositeElement(ElementType.UNKNOWN_DIRECTIVE);
            var tempParsingResult = Match(T4TokenNodeTypes.DIRECTIVE_START);

            result.AppendNewChild(tempParsingResult);
            return(HandleErrorInDirective(result, new UnexpectedToken("Missing directive name")));
        }
Beispiel #13
0
        /// <summary>
        /// Commas must be spaced correctly.
        /// </summary>
        /// <param name="node">
        /// The node to use.
        /// </param>
        public static void CommasMustBeSpacedCorrectly(ITreeNode node)
        {
            List <TokenNodeType> tokensThatCanBeRightSideOfComma = new List <TokenNodeType>
            {
                CSharpTokenType.NEW_LINE,
                CSharpTokenType.WHITE_SPACE,
                CSharpTokenType.RBRACKET,
                CSharpTokenType.GT,
                CSharpTokenType.COMMA,
                CSharpTokenType.RPARENTH
            };

            const string WhiteSpace = " ";

            for (ITreeNode currentNode = node; currentNode != null; currentNode = currentNode.NextSibling)
            {
                if (currentNode is ITokenNode)
                {
                    ITokenNode tokenNode = currentNode as ITokenNode;

                    if (tokenNode.GetTokenType() == CSharpTokenType.COMMA)
                    {
                        ITokenNode nextToken = tokenNode.GetNextToken();

                        if (!tokensThatCanBeRightSideOfComma.Contains(nextToken.GetTokenType()))
                        {
                            using (WriteLockCookie.Create(true))
                            {
                                // insert a space
                                LeafElementBase leafElement = TreeElementFactory.CreateLeafElement(
                                    CSharpTokenType.WHITE_SPACE, new JetBrains.Text.StringBuffer(WhiteSpace), 0, WhiteSpace.Length);
                                LowLevelModificationUtil.AddChildBefore(nextToken, new ITreeNode[] { leafElement });
                            }
                        }
                    }
                }

                if (currentNode.FirstChild != null)
                {
                    CommasMustBeSpacedCorrectly(currentNode.FirstChild);
                }
            }
        }
Beispiel #14
0
        public override TreeElement ParseErrorPropertyValue()
        {
            var result = TreeElementFactory.CreateErrorElement(ParserMessages.GetUnexpectedTokenMessage());

            // Consume until we hit either an identifier (start of another property)
            // an LBRACK (start of attributes for another property) or RBRACE
            while (!IsIdentifier(myOriginalLexer.TokenType) &&
                   myOriginalLexer.TokenType != ShaderLabTokenType.LBRACK &&
                   myOriginalLexer.TokenType != ShaderLabTokenType.RBRACE)
            {
                if (myOriginalLexer.TokenType == ShaderLabTokenType.LBRACE)
                {
                    SkipNestedBraces(result);
                }
                else
                {
                    Skip(result);
                }
            }
            return(result);
        }
        protected override CompositeElement handleErrorInRuleBody(CompositeElement result, SyntaxError error)
        {
            TokenNodeType    tokenType;
            CompositeElement errorElement;

            if (result is IErrorElement)
            {
                errorElement = result;
            }
            else
            {
                errorElement = TreeElementFactory.CreateErrorElement(error.Message);
                result.AppendNewChild(errorElement);
            }
            tokenType = myLexer.TokenType;
            while (tokenType != null && tokenType != TokenType.SEMICOLON && !IsInFollow(tokenType) && (!PsiTokenType.KEYWORDS.Contains(tokenType)) && (tokenType != PsiTokenType.IDENTIFIER))
            {
                skip(errorElement);
                tokenType = myLexer.TokenType;
            }
            return(result);
        }
        private TreeElement CreateMissingToken()
        {
            var ppDirective = myPreProcessor.GetPPDirectiveAtOffset(myLexer.TokenStart);

            if (ppDirective != null)
            {
                return(ppDirective);
            }

            var tokenType = myLexer.TokenType;

            if (tokenType == ShaderLabTokenType.WHITESPACE)
            {
                return(new Whitespace(WhitespaceIntern.Intern(myLexer)));
            }

            if (tokenType == ShaderLabTokenType.NEW_LINE)
            {
                return(new NewLine(WhitespaceIntern.Intern(myLexer)));
            }

            return(TreeElementFactory.CreateLeafElement(myLexer));
        }
Beispiel #17
0
        private TreeElement CreateMissingToken()
        {
            var directive = myPreProcessor.GetPpDirectiveAtOffset(myLexer.TokenStart);

            if (directive != null)
            {
                return(directive);
            }

            var tokenType = myLexer.TokenType;

            if (tokenType == CgTokenNodeTypes.WHITESPACE)
            {
                return(new CgWhitespaceTokenNode(myWhitespaceIntern.Intern(myLexer)));
            }

            if (tokenType == CgTokenNodeTypes.NEW_LINE)
            {
                return(new CgNewLineTokenNode(myWhitespaceIntern.Intern(myLexer)));
            }

            return(TreeElementFactory.CreateLeafElement(myLexer));
        }
Beispiel #18
0
        /// <summary>
        /// Returns a LeafElementBase which contains a NewLine character.
        /// </summary>
        /// <returns>
        /// LeafElementBase containing a NewLine character.
        /// </returns>
        private static LeafElementBase GetLeafElement()
        {
            string newText = Environment.NewLine;

            return(TreeElementFactory.CreateLeafElement(CSharpTokenType.NEW_LINE, new JB::JetBrains.Text.StringBuffer(newText), 0, newText.Length));
        }
        private TreeElement parseCSharpBlock(TreeElement treeElement)
        {
            TokenNodeType    tokenType;
            CompositeElement result            = null;
            TreeElement      tempParsingResult = null;

            try
            {
                result = TreeElementFactory.CreateCompositeElement(ElementType.C_SHARP_BLOCK);
                result.AppendNewChild(treeElement);
                tokenType = myLexer.TokenType;
                while (tokenType != null && TokenBitsets.TokenBitset_2[tokenType])
                {
                    tokenType = myLexer.TokenType;
                    if (tokenType != null && TokenBitsets.TokenBitset_3[tokenType])
                    {
                        tempParsingResult = parseCSharpToken();
                        result.AppendNewChild(tempParsingResult);
                    }
                    else if (tokenType == TokenType.IDENTIFIER)
                    {
                        tempParsingResult = parseCsharpIdentifier();
                        result.AppendNewChild(tempParsingResult);
                    }
                    else if (tokenType == TokenType.NULL_KEYWORD ||
                             tokenType == TokenType.RETURN_KEYWORD)
                    {
                        tempParsingResult = parseCsharpKeyword();
                        result.AppendNewChild(tempParsingResult);
                    }
                    else if (tokenType == TokenType.LBRACE)
                    {
                        tempParsingResult = parseCsharpBraceExpression();
                        result.AppendNewChild(tempParsingResult);
                    }
                    else
                    {
                        tempParsingResult = parseCSharpToken();
                        result.AppendNewChild(tempParsingResult);
                    }
                    tokenType = myLexer.TokenType;
                }
                tokenType = myLexer.TokenType;
                if (tokenType != null && !(tokenType == TokenType.PERC ||
                                           tokenType == TokenType.RBRACE))
                {
                    throw new FollowsFailure(ErrorMessages.GetErrorMessage5());
                }
            }
            catch (SyntaxError e)
            {
                if (e.ParsingResult != null && result != null)
                {
                    result.AppendNewChild(e.ParsingResult);
                }
                if (result != null)
                {
                    e.ParsingResult = result;
                }
                if (result != null)
                {
                    handleErrorInCSharpBlock(result, e);
                }
                else
                {
                    throw;
                }
            }
            return(result);
        }
Beispiel #20
0
 public override ITreeNode[] CreateSpace(string indent, ITreeNode rightNonSpace, ITreeNode replacedSpace)
 {
     return(new ITreeNode[] {
         TreeElementFactory.CreateLeafElement(T4TokenNodeTypes.Space, new StringBuffer(indent), 0, indent.Length)
     });
 }
Beispiel #21
0
        /// <summary>
        /// Fixes the spacing of the using directives in a given file or namespace block
        /// to match the specified configuration. (The directives must already be in
        /// the correct order.)
        /// </summary>
        /// <param name="holder">The file or namespace block in which to fix the spacing
        /// of using directives (if any are present).</param>
        /// <param name="configuration">The configuration determining the correct spacing.</param>
        public static void FixSpacing(
            ICSharpTypeAndNamespaceHolderDeclaration holder,
            OrderUsingsConfiguration configuration)
        {
            // The reordering proceeds one item at a time, so we just keep reapplying it
            // until there's nothing left to do.
            // To avoid hanging VS in the event that an error in the logic causes the
            // sequence of modifications not to terminate, we ensure we don't try to
            // apply more changes than there are either using directives or blank
            // lines in the usings list.
            int tries     = 0;
            int itemCount = 0;

            while (tries == 0 || tries <= itemCount)
            {
                List <UsingDirectiveOrSpace> items = ImportReader.ReadImports(holder);
                if (items == null)
                {
                    return;
                }

                itemCount = items.Count;
                List <UsingDirective>         imports;
                List <List <UsingDirective> > requiredOrderByGroups;
                ImportInspector.FlattenImportsAndDetermineOrderAndSpacing(
                    configuration, items, out imports, out requiredOrderByGroups);

                SpaceChange nextChange = ImportInspector.GetNextSpacingModification(requiredOrderByGroups, items);
                if (nextChange != null)
                {
                    IUsingDirective usingBeforeSpace = holder.Imports[nextChange.Index - 1];
                    if (nextChange.ShouldInsert)
                    {
                        using (WriteLockCookie.Create())
                        {
                            var newLineText = new StringBuffer("\r\n");

                            LeafElementBase newLine = TreeElementFactory.CreateLeafElement(
                                CSharpTokenType.NEW_LINE, newLineText, 0, newLineText.Length);
                            LowLevelModificationUtil.AddChildAfter(usingBeforeSpace, newLine);
                        }
                    }
                    else
                    {
                        var syb = usingBeforeSpace.NextSibling;
                        for (; syb != null && !(syb is IUsingDirective); syb = syb.NextSibling)
                        {
                            if (syb.NodeType == CSharpTokenType.NEW_LINE)
                            {
                                LowLevelModificationUtil.DeleteChild(syb);
                            }
                        }
                    }
                }
                else
                {
                    break;
                }

                tries += 1;
            }
        }
Beispiel #22
0
        public override TreeElement parseUriIdentifier()
        {
            CompositeElement result = null;

            try
            {
                result = TreeElementFactory.CreateCompositeElement(ElementType.URI_IDENTIFIER);
                var         tokenType = this.myLexer.TokenType;
                TreeElement tempParsingResult;
                if (tokenType == TokenType.PREFIX_IDENTIFIER)
                {
                    // PREFIX_IDENTIFIER is converted into Prefix/INDENTIFIER and NAMESPACE_SEPARATOR
                    var prefixElement = TreeElementFactory.CreateCompositeElement(ElementType.PREFIX);
                    var identifier    = TreeElementFactory.CreateLeafElement(
                        TokenType.IDENTIFIER, this.myLexer.Buffer, this.myLexer.TokenStart, this.myLexer.TokenEnd - 1);
                    this.SetOffset(identifier, this.myLexer.TokenStart);
                    prefixElement.AppendNewChild(identifier);
                    result.AppendNewChild(prefixElement);

                    var namespaceSeparator = TreeElementFactory.CreateLeafElement(
                        TokenType.NAMESPACE_SEPARATOR, this.myLexer.Buffer, this.myLexer.TokenEnd - 1, this.myLexer.TokenEnd);
                    this.SetOffset(namespaceSeparator, this.myLexer.TokenEnd - 1);
                    this.myLexer.Advance();
                    result.AppendNewChild(namespaceSeparator);
                    tempParsingResult = this.parseLocalName();
                    result.AppendNewChild(tempParsingResult);
                }
                else if (tokenType == TokenType.IDENTIFIER || tokenType == TokenType.NAMESPACE_SEPARATOR)
                {
                    tempParsingResult = this.parsePrefix();
                    result.AppendNewChild(tempParsingResult);
                    // Namespace separator parsing moved here from parsePrefix
                    tempParsingResult = this.match(TokenType.NAMESPACE_SEPARATOR);
                    result.AppendNewChild(tempParsingResult);
                    tempParsingResult = this.parseLocalName();
                    result.AppendNewChild(tempParsingResult);
                }
                else if (tokenType == TokenType.URI_BEGIN)
                {
                    tempParsingResult = this.match(TokenType.URI_BEGIN);
                    result.AppendNewChild(tempParsingResult);
                    tokenType = this.myLexer.TokenType;
                    if (tokenType == TokenType.URI_STRING)
                    {
                        tempParsingResult = this.parseUriString();
                        result.AppendNewChild(tempParsingResult);
                    }
                    tempParsingResult = this.match(TokenType.URI_END);
                    result.AppendNewChild(tempParsingResult);
                }
                else
                {
                    if (result.firstChild == null)
                    {
                        result = null;
                    }
                    throw new UnexpectedToken(ErrorMessages.GetErrorMessage31());
                }
            }
            catch (SyntaxError e)
            {
                if (e.ParsingResult != null && result != null)
                {
                    result.AppendNewChild(e.ParsingResult);
                }
                if (result != null)
                {
                    e.ParsingResult = result;
                }
                throw;
            }
            return(result);
        }
 protected override ITreeNode[] CreateSpace(string indent)
 {
     return(new[] { TreeElementFactory.CreateLeafElement(JavaScriptTokenType.WHITE_SPACE, FormatterImplHelper.GetPooledWhitespace(indent), 0, indent.Length) });
 }
        public static IWhitespaceNode CreateNewLine()
        {
            var buf = FormatterImplHelper.NewLineBuffer;

            return((IWhitespaceNode)TreeElementFactory.CreateLeafElement(JavaScriptTokenType.NEW_LINE, buf, 0, buf.Length));
        }
 public static IWhitespaceNode CreateSpace(string spaceText)
 {
     return((IWhitespaceNode)TreeElementFactory.CreateLeafElement(JavaScriptTokenType.WHITE_SPACE, FormatterImplHelper.GetPooledWhitespace(spaceText), 0, spaceText.Length));
 }
Beispiel #26
0
 public virtual JetBrains.ReSharper.PsiPlugin.Tree.IRoleName SetRoleName(JetBrains.ReSharper.PsiPlugin.Tree.IRoleName param)
 {
     using (JetBrains.Application.WriteLockCookie.Create(this.IsPhysical()))
     {
         TreeElement current = null, next = GetNextFilteredChild(current), result = null;
         next = GetNextFilteredChild(current);
         if (next == null)
         {
             return((JetBrains.ReSharper.PsiPlugin.Tree.IRoleName)result);
         }
         else
         {
             if (next.NodeType == JetBrains.ReSharper.PsiPlugin.Tree.Impl.ElementType.PATH_NAME)
             {
                 current = next;
             }
             else
             {
                 return((JetBrains.ReSharper.PsiPlugin.Tree.IRoleName)result);
             }
         }
         next = GetNextFilteredChild(current);
         if (next == null)
         {
             result = current = (TreeElement)JetBrains.ReSharper.Psi.ExtensionsAPI.Tree.ModificationUtil.AddChildAfter(this, current, TreeElementFactory.CreateErrorElement(string.Empty));
         }
         else
         {
             if (next.NodeType == JetBrains.ReSharper.PsiPlugin.Tree.Impl.TokenType.COLON)
             {
                 if (param != null)
                 {
                     current = next;
                 }
                 else
                 {
                     current = GetNextFilteredChild(next);
                     JetBrains.ReSharper.Psi.ExtensionsAPI.Tree.ModificationUtil.DeleteChild(next);
                 }
             }
             else
             {
                 return((JetBrains.ReSharper.PsiPlugin.Tree.IRoleName)result);
             }
         }
         next = GetNextFilteredChild(current);
         if (next == null)
         {
             if (param == null)
             {
                 return(null);
             }
             result = current = (TreeElement)JetBrains.ReSharper.Psi.ExtensionsAPI.Tree.ModificationUtil.AddChildAfter(this, current, (JetBrains.ReSharper.Psi.Tree.ITreeNode)param);
         }
         else
         {
             if (next.NodeType == JetBrains.ReSharper.PsiPlugin.Tree.Impl.ElementType.ROLE_NAME)
             {
                 if (param != null)
                 {
                     result = current = (TreeElement)JetBrains.ReSharper.Psi.ExtensionsAPI.Tree.ModificationUtil.ReplaceChild(next, (JetBrains.ReSharper.Psi.Tree.ITreeNode)param);
                 }
                 else
                 {
                     current = GetNextFilteredChild(next);
                     JetBrains.ReSharper.Psi.ExtensionsAPI.Tree.ModificationUtil.DeleteChild(next);
                 }
             }
             else
             {
                 if (param == null)
                 {
                     return(null);
                 }
                 result  = (TreeElement)JetBrains.ReSharper.Psi.ExtensionsAPI.Tree.ModificationUtil.AddChildBefore(next, (JetBrains.ReSharper.Psi.Tree.ITreeNode)param);
                 current = next;
             }
         }
         return((JetBrains.ReSharper.PsiPlugin.Tree.IRoleName)result);
     }
 }
 public virtual JetBrains.ReSharper.PsiPlugin.Tree.IOptionStringValue SetOptionStringValue(JetBrains.ReSharper.PsiPlugin.Tree.IOptionStringValue param)
 {
     using (JetBrains.Application.WriteLockCookie.Create(this.IsPhysical()))
     {
         TreeElement current = null, next = GetNextFilteredChild(current), result = null;
         next = GetNextFilteredChild(current);
         if (next == null)
         {
             return((JetBrains.ReSharper.PsiPlugin.Tree.IOptionStringValue)result);
         }
         else
         {
             if (next.NodeType == JetBrains.ReSharper.PsiPlugin.Tree.Impl.ElementType.OPTION_NAME)
             {
                 current = next;
             }
             else
             {
                 return((JetBrains.ReSharper.PsiPlugin.Tree.IOptionStringValue)result);
             }
         }
         next = GetNextFilteredChild(current);
         if (next.NodeType == JetBrains.ReSharper.PsiPlugin.Tree.Impl.TokenType.EQ)
         {
             next = GetNextFilteredChild(current);
             if (next == null)
             {
                 result = current = (TreeElement)JetBrains.ReSharper.Psi.ExtensionsAPI.Tree.ModificationUtil.AddChildAfter(this, current, TreeElementFactory.CreateErrorElement(string.Empty));
             }
             else
             {
                 if (next.NodeType == JetBrains.ReSharper.PsiPlugin.Tree.Impl.TokenType.EQ)
                 {
                     if (param != null)
                     {
                         current = next;
                     }
                     else
                     {
                         current = GetNextFilteredChild(next);
                         JetBrains.ReSharper.Psi.ExtensionsAPI.Tree.ModificationUtil.DeleteChild(next);
                     }
                 }
                 else
                 {
                     return((JetBrains.ReSharper.PsiPlugin.Tree.IOptionStringValue)result);
                 }
             }
             next = GetNextFilteredChild(current);
             if (next.NodeType == JetBrains.ReSharper.PsiPlugin.Tree.Impl.TokenType.IDENTIFIER)
             {
                 next = GetNextFilteredChild(current);
                 if (next == null)
                 {
                     if (param == null)
                     {
                         return(null);
                     }
                     result = current = (TreeElement)JetBrains.ReSharper.Psi.ExtensionsAPI.Tree.ModificationUtil.AddChildAfter(this, current, (JetBrains.ReSharper.Psi.Tree.ITreeNode)param);
                 }
                 else
                 {
                     if (next.NodeType == JetBrains.ReSharper.PsiPlugin.Tree.Impl.TokenType.IDENTIFIER)
                     {
                         if (param != null)
                         {
                             result = current = (TreeElement)JetBrains.ReSharper.Psi.ExtensionsAPI.Tree.ModificationUtil.ReplaceChild(next, (JetBrains.ReSharper.Psi.Tree.ITreeNode)param);
                         }
                         else
                         {
                             current = GetNextFilteredChild(next);
                             JetBrains.ReSharper.Psi.ExtensionsAPI.Tree.ModificationUtil.DeleteChild(next);
                         }
                     }
                     else
                     {
                         if (param == null)
                         {
                             return(null);
                         }
                         result  = (TreeElement)JetBrains.ReSharper.Psi.ExtensionsAPI.Tree.ModificationUtil.AddChildBefore(next, (JetBrains.ReSharper.Psi.Tree.ITreeNode)param);
                         current = next;
                     }
                 }
             }
             else if (next.NodeType == JetBrains.ReSharper.PsiPlugin.Tree.Impl.ElementType.OPTION_STRING_VALUE)
             {
                 next = GetNextFilteredChild(current);
                 if (next == null)
                 {
                     if (param == null)
                     {
                         return(null);
                     }
                     result = current = (TreeElement)JetBrains.ReSharper.Psi.ExtensionsAPI.Tree.ModificationUtil.AddChildAfter(this, current, (JetBrains.ReSharper.Psi.Tree.ITreeNode)param);
                 }
                 else
                 {
                     if (next.NodeType == JetBrains.ReSharper.PsiPlugin.Tree.Impl.ElementType.OPTION_STRING_VALUE)
                     {
                         if (param != null)
                         {
                             result = current = (TreeElement)JetBrains.ReSharper.Psi.ExtensionsAPI.Tree.ModificationUtil.ReplaceChild(next, (JetBrains.ReSharper.Psi.Tree.ITreeNode)param);
                         }
                         else
                         {
                             current = GetNextFilteredChild(next);
                             JetBrains.ReSharper.Psi.ExtensionsAPI.Tree.ModificationUtil.DeleteChild(next);
                         }
                     }
                     else
                     {
                         if (param == null)
                         {
                             return(null);
                         }
                         result  = (TreeElement)JetBrains.ReSharper.Psi.ExtensionsAPI.Tree.ModificationUtil.AddChildBefore(next, (JetBrains.ReSharper.Psi.Tree.ITreeNode)param);
                         current = next;
                     }
                 }
             }
             else if (next.NodeType == JetBrains.ReSharper.PsiPlugin.Tree.Impl.TokenType.INTEGER_LITERAL)
             {
                 next = GetNextFilteredChild(current);
                 if (next == null)
                 {
                     if (param == null)
                     {
                         return(null);
                     }
                     result = current = (TreeElement)JetBrains.ReSharper.Psi.ExtensionsAPI.Tree.ModificationUtil.AddChildAfter(this, current, (JetBrains.ReSharper.Psi.Tree.ITreeNode)param);
                 }
                 else
                 {
                     if (next.NodeType == JetBrains.ReSharper.PsiPlugin.Tree.Impl.TokenType.INTEGER_LITERAL)
                     {
                         if (param != null)
                         {
                             result = current = (TreeElement)JetBrains.ReSharper.Psi.ExtensionsAPI.Tree.ModificationUtil.ReplaceChild(next, (JetBrains.ReSharper.Psi.Tree.ITreeNode)param);
                         }
                         else
                         {
                             current = GetNextFilteredChild(next);
                             JetBrains.ReSharper.Psi.ExtensionsAPI.Tree.ModificationUtil.DeleteChild(next);
                         }
                     }
                     else
                     {
                         if (param == null)
                         {
                             return(null);
                         }
                         result  = (TreeElement)JetBrains.ReSharper.Psi.ExtensionsAPI.Tree.ModificationUtil.AddChildBefore(next, (JetBrains.ReSharper.Psi.Tree.ITreeNode)param);
                         current = next;
                     }
                 }
             }
             else
             {
                 next = GetNextFilteredChild(current);
                 if (next == null)
                 {
                     if (param == null)
                     {
                         return(null);
                     }
                     result = current = (TreeElement)JetBrains.ReSharper.Psi.ExtensionsAPI.Tree.ModificationUtil.AddChildAfter(this, current, (JetBrains.ReSharper.Psi.Tree.ITreeNode)param);
                 }
                 else
                 {
                     if (next.NodeType == JetBrains.ReSharper.PsiPlugin.Tree.Impl.TokenType.IDENTIFIER)
                     {
                         if (param != null)
                         {
                             result = current = (TreeElement)JetBrains.ReSharper.Psi.ExtensionsAPI.Tree.ModificationUtil.ReplaceChild(next, (JetBrains.ReSharper.Psi.Tree.ITreeNode)param);
                         }
                         else
                         {
                             current = GetNextFilteredChild(next);
                             JetBrains.ReSharper.Psi.ExtensionsAPI.Tree.ModificationUtil.DeleteChild(next);
                         }
                     }
                     else
                     {
                         if (param == null)
                         {
                             return(null);
                         }
                         result  = (TreeElement)JetBrains.ReSharper.Psi.ExtensionsAPI.Tree.ModificationUtil.AddChildBefore(next, (JetBrains.ReSharper.Psi.Tree.ITreeNode)param);
                         current = next;
                     }
                 }
             }
         }
         else if (next.NodeType == JetBrains.ReSharper.PsiPlugin.Tree.Impl.TokenType.COLON)
         {
             next = GetNextFilteredChild(current);
             if (next == null)
             {
                 result = current = (TreeElement)JetBrains.ReSharper.Psi.ExtensionsAPI.Tree.ModificationUtil.AddChildAfter(this, current, TreeElementFactory.CreateErrorElement(string.Empty));
             }
             else
             {
                 if (next.NodeType == JetBrains.ReSharper.PsiPlugin.Tree.Impl.TokenType.COLON)
                 {
                     if (param != null)
                     {
                         current = next;
                     }
                     else
                     {
                         current = GetNextFilteredChild(next);
                         JetBrains.ReSharper.Psi.ExtensionsAPI.Tree.ModificationUtil.DeleteChild(next);
                     }
                 }
                 else
                 {
                     return((JetBrains.ReSharper.PsiPlugin.Tree.IOptionStringValue)result);
                 }
             }
             next = GetNextFilteredChild(current);
             if (next.NodeType == JetBrains.ReSharper.PsiPlugin.Tree.Impl.TokenType.PLUS)
             {
                 next = GetNextFilteredChild(current);
                 if (next == null)
                 {
                     result = current = (TreeElement)JetBrains.ReSharper.Psi.ExtensionsAPI.Tree.ModificationUtil.AddChildAfter(this, current, TreeElementFactory.CreateErrorElement(string.Empty));
                 }
                 else
                 {
                     if (next.NodeType == JetBrains.ReSharper.PsiPlugin.Tree.Impl.TokenType.PLUS)
                     {
                         if (param != null)
                         {
                             current = next;
                         }
                         else
                         {
                             current = GetNextFilteredChild(next);
                             JetBrains.ReSharper.Psi.ExtensionsAPI.Tree.ModificationUtil.DeleteChild(next);
                         }
                     }
                     else
                     {
                         return((JetBrains.ReSharper.PsiPlugin.Tree.IOptionStringValue)result);
                     }
                 }
                 next = GetNextFilteredChild(current);
                 if (next == null)
                 {
                     result = current = (TreeElement)JetBrains.ReSharper.Psi.ExtensionsAPI.Tree.ModificationUtil.AddChildAfter(this, current, TreeElementFactory.CreateErrorElement(string.Empty));
                 }
                 else
                 {
                     if (next.NodeType == JetBrains.ReSharper.PsiPlugin.Tree.Impl.ElementType.RULE_NAME)
                     {
                         if (param != null)
                         {
                             current = next;
                         }
                         else
                         {
                             current = GetNextFilteredChild(next);
                             JetBrains.ReSharper.Psi.ExtensionsAPI.Tree.ModificationUtil.DeleteChild(next);
                         }
                     }
                     else
                     {
                         return((JetBrains.ReSharper.PsiPlugin.Tree.IOptionStringValue)result);
                     }
                 }
             }
             else if (next.NodeType == JetBrains.ReSharper.PsiPlugin.Tree.Impl.TokenType.LPARENTH)
             {
                 next = GetNextFilteredChild(current);
                 if (next == null)
                 {
                     result = current = (TreeElement)JetBrains.ReSharper.Psi.ExtensionsAPI.Tree.ModificationUtil.AddChildAfter(this, current, TreeElementFactory.CreateErrorElement(string.Empty));
                 }
                 else
                 {
                     if (next.NodeType == JetBrains.ReSharper.PsiPlugin.Tree.Impl.TokenType.LPARENTH)
                     {
                         if (param != null)
                         {
                             current = next;
                         }
                         else
                         {
                             current = GetNextFilteredChild(next);
                             JetBrains.ReSharper.Psi.ExtensionsAPI.Tree.ModificationUtil.DeleteChild(next);
                         }
                     }
                     else
                     {
                         return((JetBrains.ReSharper.PsiPlugin.Tree.IOptionStringValue)result);
                     }
                 }
                 next = GetNextFilteredChild(current);
                 if (next == null)
                 {
                     result = current = (TreeElement)JetBrains.ReSharper.Psi.ExtensionsAPI.Tree.ModificationUtil.AddChildAfter(this, current, TreeElementFactory.CreateErrorElement(string.Empty));
                 }
                 else
                 {
                     if (next.NodeType == JetBrains.ReSharper.PsiPlugin.Tree.Impl.TokenType.STRING_LITERAL)
                     {
                         if (param != null)
                         {
                             current = next;
                         }
                         else
                         {
                             current = GetNextFilteredChild(next);
                             JetBrains.ReSharper.Psi.ExtensionsAPI.Tree.ModificationUtil.DeleteChild(next);
                         }
                     }
                     else
                     {
                         return((JetBrains.ReSharper.PsiPlugin.Tree.IOptionStringValue)result);
                     }
                 }
                 next = GetNextFilteredChild(current);
                 if (next == null)
                 {
                     result = current = (TreeElement)JetBrains.ReSharper.Psi.ExtensionsAPI.Tree.ModificationUtil.AddChildAfter(this, current, TreeElementFactory.CreateErrorElement(string.Empty));
                 }
                 else
                 {
                     if (next.NodeType == JetBrains.ReSharper.PsiPlugin.Tree.Impl.ElementType.RULE_NAME)
                     {
                         if (param != null)
                         {
                             current = next;
                         }
                         else
                         {
                             current = GetNextFilteredChild(next);
                             JetBrains.ReSharper.Psi.ExtensionsAPI.Tree.ModificationUtil.DeleteChild(next);
                         }
                     }
                     else
                     {
                         return((JetBrains.ReSharper.PsiPlugin.Tree.IOptionStringValue)result);
                     }
                 }
                 while (next.NodeType == JetBrains.ReSharper.PsiPlugin.Tree.Impl.TokenType.SEMICOLON)
                 {
                     next = GetNextFilteredChild(current);
                     if (next == null)
                     {
                         result = current = (TreeElement)JetBrains.ReSharper.Psi.ExtensionsAPI.Tree.ModificationUtil.AddChildAfter(this, current, TreeElementFactory.CreateErrorElement(string.Empty));
                     }
                     else
                     {
                         if (next.NodeType == JetBrains.ReSharper.PsiPlugin.Tree.Impl.TokenType.SEMICOLON)
                         {
                             if (param != null)
                             {
                                 current = next;
                             }
                             else
                             {
                                 current = GetNextFilteredChild(next);
                                 JetBrains.ReSharper.Psi.ExtensionsAPI.Tree.ModificationUtil.DeleteChild(next);
                             }
                         }
                         else
                         {
                             return((JetBrains.ReSharper.PsiPlugin.Tree.IOptionStringValue)result);
                         }
                     }
                     next = GetNextFilteredChild(current);
                     if (next == null)
                     {
                         result = current = (TreeElement)JetBrains.ReSharper.Psi.ExtensionsAPI.Tree.ModificationUtil.AddChildAfter(this, current, TreeElementFactory.CreateErrorElement(string.Empty));
                     }
                     else
                     {
                         if (next.NodeType == JetBrains.ReSharper.PsiPlugin.Tree.Impl.TokenType.STRING_LITERAL)
                         {
                             if (param != null)
                             {
                                 current = next;
                             }
                             else
                             {
                                 current = GetNextFilteredChild(next);
                                 JetBrains.ReSharper.Psi.ExtensionsAPI.Tree.ModificationUtil.DeleteChild(next);
                             }
                         }
                         else
                         {
                             return((JetBrains.ReSharper.PsiPlugin.Tree.IOptionStringValue)result);
                         }
                     }
                     next = GetNextFilteredChild(current);
                     if (next == null)
                     {
                         result = current = (TreeElement)JetBrains.ReSharper.Psi.ExtensionsAPI.Tree.ModificationUtil.AddChildAfter(this, current, TreeElementFactory.CreateErrorElement(string.Empty));
                     }
                     else
                     {
                         if (next.NodeType == JetBrains.ReSharper.PsiPlugin.Tree.Impl.ElementType.RULE_NAME)
                         {
                             if (param != null)
                             {
                                 current = next;
                             }
                             else
                             {
                                 current = GetNextFilteredChild(next);
                                 JetBrains.ReSharper.Psi.ExtensionsAPI.Tree.ModificationUtil.DeleteChild(next);
                             }
                         }
                         else
                         {
                             return((JetBrains.ReSharper.PsiPlugin.Tree.IOptionStringValue)result);
                         }
                     }
                 }
                 next = GetNextFilteredChild(current);
                 if (next == null)
                 {
                     result = current = (TreeElement)JetBrains.ReSharper.Psi.ExtensionsAPI.Tree.ModificationUtil.AddChildAfter(this, current, TreeElementFactory.CreateErrorElement(string.Empty));
                 }
                 else
                 {
                     if (next.NodeType == JetBrains.ReSharper.PsiPlugin.Tree.Impl.TokenType.RPARENTH)
                     {
                         if (param != null)
                         {
                             current = next;
                         }
                         else
                         {
                             current = GetNextFilteredChild(next);
                             JetBrains.ReSharper.Psi.ExtensionsAPI.Tree.ModificationUtil.DeleteChild(next);
                         }
                     }
                     else
                     {
                         return((JetBrains.ReSharper.PsiPlugin.Tree.IOptionStringValue)result);
                     }
                 }
             }
             else
             {
                 // in case we have multiple lookahead elements and we've failed to find any
                 return(null);
             }
         }
         else
         {
             next = GetNextFilteredChild(current);
             if (next == null)
             {
                 result = current = (TreeElement)JetBrains.ReSharper.Psi.ExtensionsAPI.Tree.ModificationUtil.AddChildAfter(this, current, TreeElementFactory.CreateErrorElement(string.Empty));
             }
             else
             {
                 if (next.NodeType == JetBrains.ReSharper.PsiPlugin.Tree.Impl.TokenType.EQ)
                 {
                     if (param != null)
                     {
                         current = next;
                     }
                     else
                     {
                         current = GetNextFilteredChild(next);
                         JetBrains.ReSharper.Psi.ExtensionsAPI.Tree.ModificationUtil.DeleteChild(next);
                     }
                 }
                 else
                 {
                     return((JetBrains.ReSharper.PsiPlugin.Tree.IOptionStringValue)result);
                 }
             }
             next = GetNextFilteredChild(current);
             if (next.NodeType == JetBrains.ReSharper.PsiPlugin.Tree.Impl.TokenType.IDENTIFIER)
             {
                 next = GetNextFilteredChild(current);
                 if (next == null)
                 {
                     if (param == null)
                     {
                         return(null);
                     }
                     result = current = (TreeElement)JetBrains.ReSharper.Psi.ExtensionsAPI.Tree.ModificationUtil.AddChildAfter(this, current, (JetBrains.ReSharper.Psi.Tree.ITreeNode)param);
                 }
                 else
                 {
                     if (next.NodeType == JetBrains.ReSharper.PsiPlugin.Tree.Impl.TokenType.IDENTIFIER)
                     {
                         if (param != null)
                         {
                             result = current = (TreeElement)JetBrains.ReSharper.Psi.ExtensionsAPI.Tree.ModificationUtil.ReplaceChild(next, (JetBrains.ReSharper.Psi.Tree.ITreeNode)param);
                         }
                         else
                         {
                             current = GetNextFilteredChild(next);
                             JetBrains.ReSharper.Psi.ExtensionsAPI.Tree.ModificationUtil.DeleteChild(next);
                         }
                     }
                     else
                     {
                         if (param == null)
                         {
                             return(null);
                         }
                         result  = (TreeElement)JetBrains.ReSharper.Psi.ExtensionsAPI.Tree.ModificationUtil.AddChildBefore(next, (JetBrains.ReSharper.Psi.Tree.ITreeNode)param);
                         current = next;
                     }
                 }
             }
             else if (next.NodeType == JetBrains.ReSharper.PsiPlugin.Tree.Impl.ElementType.OPTION_STRING_VALUE)
             {
                 next = GetNextFilteredChild(current);
                 if (next == null)
                 {
                     if (param == null)
                     {
                         return(null);
                     }
                     result = current = (TreeElement)JetBrains.ReSharper.Psi.ExtensionsAPI.Tree.ModificationUtil.AddChildAfter(this, current, (JetBrains.ReSharper.Psi.Tree.ITreeNode)param);
                 }
                 else
                 {
                     if (next.NodeType == JetBrains.ReSharper.PsiPlugin.Tree.Impl.ElementType.OPTION_STRING_VALUE)
                     {
                         if (param != null)
                         {
                             result = current = (TreeElement)JetBrains.ReSharper.Psi.ExtensionsAPI.Tree.ModificationUtil.ReplaceChild(next, (JetBrains.ReSharper.Psi.Tree.ITreeNode)param);
                         }
                         else
                         {
                             current = GetNextFilteredChild(next);
                             JetBrains.ReSharper.Psi.ExtensionsAPI.Tree.ModificationUtil.DeleteChild(next);
                         }
                     }
                     else
                     {
                         if (param == null)
                         {
                             return(null);
                         }
                         result  = (TreeElement)JetBrains.ReSharper.Psi.ExtensionsAPI.Tree.ModificationUtil.AddChildBefore(next, (JetBrains.ReSharper.Psi.Tree.ITreeNode)param);
                         current = next;
                     }
                 }
             }
             else if (next.NodeType == JetBrains.ReSharper.PsiPlugin.Tree.Impl.TokenType.INTEGER_LITERAL)
             {
                 next = GetNextFilteredChild(current);
                 if (next == null)
                 {
                     if (param == null)
                     {
                         return(null);
                     }
                     result = current = (TreeElement)JetBrains.ReSharper.Psi.ExtensionsAPI.Tree.ModificationUtil.AddChildAfter(this, current, (JetBrains.ReSharper.Psi.Tree.ITreeNode)param);
                 }
                 else
                 {
                     if (next.NodeType == JetBrains.ReSharper.PsiPlugin.Tree.Impl.TokenType.INTEGER_LITERAL)
                     {
                         if (param != null)
                         {
                             result = current = (TreeElement)JetBrains.ReSharper.Psi.ExtensionsAPI.Tree.ModificationUtil.ReplaceChild(next, (JetBrains.ReSharper.Psi.Tree.ITreeNode)param);
                         }
                         else
                         {
                             current = GetNextFilteredChild(next);
                             JetBrains.ReSharper.Psi.ExtensionsAPI.Tree.ModificationUtil.DeleteChild(next);
                         }
                     }
                     else
                     {
                         if (param == null)
                         {
                             return(null);
                         }
                         result  = (TreeElement)JetBrains.ReSharper.Psi.ExtensionsAPI.Tree.ModificationUtil.AddChildBefore(next, (JetBrains.ReSharper.Psi.Tree.ITreeNode)param);
                         current = next;
                     }
                 }
             }
             else
             {
                 next = GetNextFilteredChild(current);
                 if (next == null)
                 {
                     if (param == null)
                     {
                         return(null);
                     }
                     result = current = (TreeElement)JetBrains.ReSharper.Psi.ExtensionsAPI.Tree.ModificationUtil.AddChildAfter(this, current, (JetBrains.ReSharper.Psi.Tree.ITreeNode)param);
                 }
                 else
                 {
                     if (next.NodeType == JetBrains.ReSharper.PsiPlugin.Tree.Impl.TokenType.IDENTIFIER)
                     {
                         if (param != null)
                         {
                             result = current = (TreeElement)JetBrains.ReSharper.Psi.ExtensionsAPI.Tree.ModificationUtil.ReplaceChild(next, (JetBrains.ReSharper.Psi.Tree.ITreeNode)param);
                         }
                         else
                         {
                             current = GetNextFilteredChild(next);
                             JetBrains.ReSharper.Psi.ExtensionsAPI.Tree.ModificationUtil.DeleteChild(next);
                         }
                     }
                     else
                     {
                         if (param == null)
                         {
                             return(null);
                         }
                         result  = (TreeElement)JetBrains.ReSharper.Psi.ExtensionsAPI.Tree.ModificationUtil.AddChildBefore(next, (JetBrains.ReSharper.Psi.Tree.ITreeNode)param);
                         current = next;
                     }
                 }
             }
         }
         return((JetBrains.ReSharper.PsiPlugin.Tree.IOptionStringValue)result);
     }
 }