public void Visit(JsConditionalCompilationComment node)
 {
     if (node != null)
     {
         if (node.Statements != null)
         {
             node.Statements.Accept(this);
         }
     }
 }
示例#2
0
 public override void Visit(JsConditionalCompilationComment node)
 {
     if (node != null && node.Statements != null && node.Statements.Count > 0)
     {
         // increment the conditional comment level, recurse (process all the
         // statements), then decrement the level when we are through.
         ++m_conditionalCommentLevel;
         base.Visit(node);
         --m_conditionalCommentLevel;
     }
 }
示例#3
0
        // unnest any child blocks
        private static void UnnestBlocks(JsBlock node)
        {
            // walk the list of items backwards -- if we come
            // to any blocks, unnest the block recursively.
            // Remove any empty statements as well.
            // We walk backwards because we could be adding any number of statements
            // and we don't want to have to modify the counter.
            for (int ndx = node.Count - 1; ndx >= 0; --ndx)
            {
                var nestedBlock = node[ndx] as JsBlock;
                if (nestedBlock != null)
                {
                    // unnest recursively
                    UnnestBlocks(nestedBlock);

                    // if the block has a block scope, then we can't really unnest it
                    // without merging lexical scopes
                    if (nestedBlock.BlockScope == null)
                    {
                        // remove the nested block
                        node.RemoveAt(ndx);

                        // then start adding the statements in the nested block to our own.
                        // go backwards so we can just keep using the same index
                        node.InsertRange(ndx, nestedBlock.Children);
                    }
                }
                else if (node[ndx] is JsEmptyStatement)
                {
                    // remove empty statements (lone semicolons)
                    node.RemoveAt(ndx);
                }
                else if (ndx > 0)
                {
                    // see if the previous node is a conditional-compilation comment, because
                    // we will also combine adjacent those
                    var previousComment = node[ndx - 1] as JsConditionalCompilationComment;
                    if (previousComment != null)
                    {
                        JsConditionalCompilationComment thisComment = node[ndx] as JsConditionalCompilationComment;
                        if (thisComment != null)
                        {
                            // two adjacent conditional comments -- combine them into the first.
                            previousComment.Statements.Append(thisComment.Statements);

                            // and remove the second one (which is now a duplicate)
                            node.RemoveAt(ndx);
                        }
                    }
                }
            }
        }
示例#4
0
 public void Visit(JsConditionalCompilationComment node)
 {
     if (node != null)
     {
         // recurse the children, but as soon as we get the flag set to true, bail
         foreach (var child in node.Children)
         {
             child.Accept(this);
             if (m_needsParens)
             {
                 break;
             }
         }
     }
 }
 public void Visit(JsConditionalCompilationComment node)
 {
     // invalid! ignore
     IsValid = false;
 }
 public void Visit(JsConditionalCompilationComment node)
 {
     // starts with a '/*@' or '//@', so we don't care
 }
示例#7
0
 public void Visit(JsConditionalCompilationComment node)
 {
     // not applicable; terminate
 }
示例#8
0
 public void Visit(JsConditionalCompilationComment node)
 {
     // invalid! ignore
     IsValid = false;
 }
 public void Visit(JsConditionalCompilationComment node)
 {
     if (node != null)
     {
         if (node.Statements != null)
         {
             node.Statements.Accept(this);
         }
     }
 }
 public override void Visit(JsConditionalCompilationComment node)
 {
     if (node != null && node.Statements != null && node.Statements.Count > 0)
     {
         // increment the conditional comment level, recurse (process all the
         // statements), then decrement the level when we are through.
         ++m_conditionalCommentLevel;
         base.Visit(node);
         --m_conditionalCommentLevel;
     }
 }
 public void Visit(JsConditionalCompilationComment node)
 {
     if (node != null)
     {
         // recurse the children, but as soon as we get the flag set to true, bail
         foreach (var child in node.Children)
         {
             child.Accept(this);
             if (m_needsParens)
             {
                 break;
             }
         }
     }
 }
示例#12
0
        JsAstNode ParseStatementLevelConditionalComment(bool fSourceElement)
        {
            JsContext context = m_currentToken.Clone();
            JsConditionalCompilationComment conditionalComment = new JsConditionalCompilationComment(context, this);

            GetNextToken();
            while(m_currentToken.Token != JsToken.ConditionalCommentEnd && m_currentToken.Token != JsToken.EndOfFile)
            {
                // if we get ANOTHER start token, it's superfluous and we should ignore it.
                // otherwise parse another statement and keep going
                if (m_currentToken.Token == JsToken.ConditionalCommentStart)
                {
                    GetNextToken();
                }
                else
                {
                    conditionalComment.Append(ParseStatement(fSourceElement));
                }
            }

            GetNextToken();

            // if the conditional comment is empty (for whatever reason), then
            // we don't want to return anything -- we found nothing.
            return conditionalComment.Statements.Count > 0 ? conditionalComment : null;
        }
 public void Visit(JsConditionalCompilationComment node)
 {
     // not applicable; terminate
 }
        public void Visit(JsConditionalCompilationComment node)
        {
            if (node != null)
            {
                var symbol = StartSymbol(node);

                // if we have already output a cc_on and we don't want to keep any dupes, let's
                // skip over any @cc_on statements at the beginning now
                var ndx = 0;
                if (m_outputCCOn && m_settings.IsModificationAllowed(JsTreeModifications.RemoveUnnecessaryCCOnStatements))
                {
                    while (ndx < node.Statements.Count
                        && (node.Statements[ndx].HideFromOutput || node.Statements[ndx] is JsConditionalCompilationOn))
                    {
                        ++ndx;
                    }
                }

                // if there's anything left....
                if (ndx < node.Statements.Count)
                {
                    // start of comment
                    Output("/*");
                    MarkSegment(node, null, node.Context);
                    SetContextOutputPosition(node.Context);

                    // get the next statement, which will be the first one we output
                    var statement = node.Statements[ndx];
                    if (statement is JsConditionalCompilationStatement
                        || statement is JsConstantWrapperPP)
                    {
                        // the next statement STARTS with an @-sign, so just output it. It will add the @ sign to begin
                        // the conditional-compilation comment
                        statement.Accept(this);
                    }
                    else
                    {
                        // next statement does NOT start with an @-sign, so add one now.
                        // outputting an @-sign as the last character will ensure that a
                        // space is inserted before any identifier character coming after.
                        OutputPossibleLineBreak('@');

                        // and then output the first statement
                        statement.Accept(this);
                    }

                    // go through the rest of the statements (if any)
                    JsAstNode prevStatement = statement;
                    while (++ndx < node.Statements.Count)
                    {
                        statement = node.Statements[ndx];
                        if (statement != null && !statement.HideFromOutput)
                        {
                            if (prevStatement != null && prevStatement.RequiresSeparator)
                            {
                                OutputPossibleLineBreak(';');
                                MarkSegment(prevStatement, null, prevStatement.TerminatingContext);
                            }

                            NewLine();
                            m_startOfStatement = true;
                            statement.Accept(this);
                            prevStatement = statement;
                        }
                    }

                    // output the closing comment
                    Output("@*/");
                    MarkSegment(node, null, node.Context);
                }

                EndSymbol(symbol);
            }
        }