Пример #1
0
        private static bool ExtractLineParts(string line, out SourceCodePosition start, out SourceCodePosition end, out string fileName)
        {
            start    = new SourceCodePosition();
            end      = new SourceCodePosition();
            fileName = (string)null;
            line     = line.TrimStart();
            if (!line.StartsWith(".line"))
            {
                return(false);
            }
            line = line.Substring(5).Trim();
            if (string.IsNullOrEmpty(line))
            {
                return(false);
            }
            int           startIndex    = 0;
            string        lineText1     = (string)null;
            string        lineText2     = (string)null;
            string        columnText1   = (string)null;
            string        columnText2   = (string)null;
            StringBuilder stringBuilder = new StringBuilder(line.Length);
            bool          flag          = false;

            for (int index = 0; index < line.Length; ++index)
            {
                char ch = line[index];
                if ((int)ch == 39)
                {
                    if (!flag)
                    {
                        string str = line.Substring(startIndex, index - startIndex).Trim();
                        if (columnText2 == null)
                        {
                            columnText2 = str;
                        }
                    }
                    flag = !flag;
                }
                else if (flag)
                {
                    stringBuilder.Append(ch);
                }
                else if ((int)ch == 44 || (int)ch == 58)
                {
                    string str = line.Substring(startIndex, index - startIndex).Trim();
                    startIndex = index + 1;
                    switch (ch)
                    {
                    case ',':
                        if (lineText1 == null)
                        {
                            lineText1 = str;
                            continue;
                        }
                        columnText1 = str;
                        continue;

                    case ':':
                        if (lineText2 == null)
                        {
                            lineText2 = str;
                            continue;
                        }
                        columnText2 = str;
                        continue;

                    default:
                        continue;
                    }
                }
            }
            start    = SourceCodePosition.FromText(lineText1, columnText1) ?? start;
            end      = SourceCodePosition.FromText(lineText2, columnText2) ?? end;
            fileName = stringBuilder.Length > 0 ? stringBuilder.ToString() : (string)null;
            return(fileName != null);
        }
Пример #2
0
 public SourceCodeRange(string fileName, SourceCodePosition startPosition, SourceCodePosition endPosition)
 {
     this.FileName      = fileName;
     this.StartPosition = startPosition;
     this.EndPosition   = endPosition;
 }