Exemplo n.º 1
0
        public List <ProgramElement> Parse(string filename)
        {
            if (File.Exists(filename) && GetSizeInMb(filename) > 15)
            {
                return(new List <ProgramElement>());
            }
            var list = new List <ProgramElement>();

            try
            {
                // Create an instance of StreamReader to read from a file.
                // The using statement also closes the StreamReader.
                using (var sr = new StreamReader(filename))
                {
                    String line;
                    int    linenum = 0;
                    // Read and display lines from the file until the end of
                    // the file is reached.
                    while ((line = sr.ReadLine()) != null)
                    {
                        linenum++;
                        if (String.IsNullOrWhiteSpace(line))
                        {
                            continue;
                        }
                        //var name = Regex.Replace(line, @"(\w+)\W+", "$1 ");
                        var name = line.TrimStart(' ', '\n', '\r', '\t');
                        name = name.TrimEnd(' ');
                        var snippet = SrcMLParsingUtils.RetrieveSource(name);
                        var element = new TextLineElement(name, linenum, -1000, filename, snippet, line);
                        list.Add(element);
                    }
                }
            }
            catch (Exception e)
            {
                LogEvents.ParserGenericFileError(this, filename);
            }
            return(list);
        }
Exemplo n.º 2
0
        public List <ProgramElement> Parse(string filename)
        {
            var programElements = new List <ProgramElement>();

            XmlTextReader reader = new XmlTextReader(filename);

            while (reader.Read())
            {
                string text = String.Empty;

                if (reader.NodeType == XmlNodeType.Text)
                {
                    text = reader.Value;
                }
                else if (reader.NodeType == XmlNodeType.Element)
                {
                    while (reader.MoveToNextAttribute())
                    {
                        text += reader.Value + " ";
                    }
                }

                if (!String.IsNullOrWhiteSpace(text))
                {
                    var cleanedText = text.TrimStart(' ', '\n', '\r', '\t');
                    cleanedText = cleanedText.TrimEnd(' ', '\n', '\r', '\t');
                    var linenum = reader.LineNumber;
                    var snippet = SrcMLParsingUtils.RetrieveSource(cleanedText);
                    var pe      = new TextLineElement(cleanedText, linenum, -1000, filename, snippet, cleanedText);
                    programElements.Add(pe);
                }
            }


            return(programElements);
        }
Exemplo n.º 3
0
 private static IEnumerable <string> ExtractTextLineElement(TextLineElement element)
 {
     return(GetDefaultLetterWords(element.Body));
 }
 public TextLineDocument(TextLineElement classElement)
     : base(classElement)
 {
 }