示例#1
0
 public static bool For_DO(Word word, ref Span span)
 {
     if (word.Text == Data.DO.Text)
     {
         Subsidiary.SelectOperator(word, Data.ConditionalOperatorsColor, ref span);
         return(true);
     }
     return(false);
 }
示例#2
0
 public static bool ForSquareBrackets(Word word, ref Span span)
 {
     if (word.Text == "[")
     {
         Subsidiary.AddOperator(word, Data.OtherOperatorsColor, ref span);
         return(true);
     }
     if (word.Text == "]")
     {
         Subsidiary.SelectOperator(word, Data.OtherOperatorsColor, ref span);
         return(true);
     }
     return(false);
 }
示例#3
0
        public static bool CompareWithConditionalOperators(Word word, ref Span span, int lineNumber)
        {
            if (Subsidiary.ConditionalCompare(word, Data.IF.Text, ref span, lineNumber) ||
                Subsidiary.ConditionalCompare(word, Data.SWITCH.Text, ref span, lineNumber) ||
                Subsidiary.ConditionalCompare(word, Data.FOR.Text, ref span, lineNumber) ||
                Subsidiary.ConditionalCompare(word, Data.WHILE.Text, ref span, lineNumber))
            {
                return(true);
            }

            if (word == Data.ELSE.Text)
            {
                Subsidiary.SelectOperator(word, Data.ConditionalOperatorsColor, ref span);
                return(true);
            }

            if (word == Data.ELSEIF.Text)
            {
                Subsidiary.SelectOperator(Data.ELSEIF.Text, Data.ConditionalOperatorsColor, ref span);
                return(true);
            }
            return(false);
        }
示例#4
0
        private static void SearchForAllOperatorsInLineWithoutQuotes(Word[] words, int lineNumber, ref Span span)
        {
            MakeGapsAfterWords(words);
            bool wasFunction = false;

            bool       needsCheckingForTernaryOperator = Word.ContainsString(words, Data.QUESTION_MARK.Text);
            List <int> colonsIndexes = new List <int>();

            for (int i = 0; i < words.Length; i++)
            {
                if (wasFunction)
                {
                    if (words[i] == "{")
                    {
                        wasFunction = false;
                    }
                    else
                    {
                        span.Inlines.Add(words[i].ToString());
                        continue;
                    }
                }

                if (Split.IsTag(words[i].Text))
                {
                    span.Inlines.Add(words[i].ToString());
                    continue;
                }

                if (words[i].Text == Data.FUNCTION.Text)
                {
                    wasFunction = true;
                    span.Inlines.Add(words[i].ToString());
                    continue;
                }

                if (Search.InSymbolicOperators(words[i], ref span))
                {
                    continue;
                }

                if (Search.InSingleWordsOperators(words[i], ref span))
                {
                    continue;
                }

                if (Search.InWordOperatorsWithoutBrackets(words[i], ref span))
                {
                    continue;
                }

                if (Search.InWordOperatorsWithBrackets(words[i], ref span))
                {
                    continue;
                }

                if (Search.For_DO(words[i], ref span))
                {
                    continue;
                }

                if (Search.ForSquareBrackets(words[i], ref span))
                {
                    continue;
                }

                if (Search.CompareWithConditionalOperators(words[i], ref span, lineNumber))
                {
                    continue;
                }

                if (needsCheckingForTernaryOperator)
                {
                    if (Search.ForTernaryOperator(i, words, ref span, ref colonsIndexes))
                    {
                        continue;
                    }
                }

                if (words[i].Text == "(" || words[i].Text == "{" || words[i].Text == "[")
                {
                    words[i].IsSpaceAfter = false;
                }
                if (Line.TrimmedLine(words[i].Text) == "")
                {
                    words[i].IsSpaceAfter = false;
                }
                if (needsCheckingForTernaryOperator)
                {
                    if (!colonsIndexes.Contains(i))
                    {
                        span.Inlines.Add(words[i].ToString());
                    }
                    else
                    {
                        Subsidiary.SelectOperator(words[i], Data.ConditionalOperatorsColor, ref span);
                    }
                }
                else
                {
                    span.Inlines.Add(words[i].ToString());
                }
            }
        }