예제 #1
0
 private void AddSourceEntry(SourceEntry sourceEntry)
 {
     //Console.WriteLine($"adding {sourceEntry}");
     if (!PersistencePart.Entries.ContainsKey(sourceEntry.ThisHash))
     {
         PersistencePart.Entries.Add(sourceEntry.ThisHash, new List <SourceEntry> {
             sourceEntry
         });
     }
     else
     {
         PersistencePart.Entries[sourceEntry.ThisHash].Add(sourceEntry);
     }
 }
예제 #2
0
        public void ProcessFile(string filePath)
        {
            if (!File.Exists(filePath))
            {
                Debug.Write("Can not access {0}", filePath);
            }

            int fileHash = filePath.GetHashCode();

            PersistencePart.FilesDictionary.Add(fileHash, filePath);

            var logTokenizer = new WhiteSpaceLogTokenizer();

            var lines = File.ReadAllLines(filePath);
            //int previousHash = 0;

            SourceEntry prevSourceEntry = null;

            for (var lineN = 0; lineN < lines.Length; lineN++)
            {
                var line = lines[lineN];
                foreach (Match match in _scopeRegex.Matches(line))
                {
                    foreach (var token in logTokenizer.TokenizeLine(RemoveQuotes(match.Value)))
                    {
                        var sourceEntry = new SourceEntry(
                            fileHash: fileHash,
                            lineNumber: lineN,
                            lineOffset: match.Index,
                            thisHash: token,
                            previousHash: prevSourceEntry?.ThisHash ?? 0, // o-0~o
                            nextHash: 0);                                 // o-0~o

                        if (prevSourceEntry != null)
                        {
                            prevSourceEntry.NextHash = sourceEntry.ThisHash;                          // o-0-o
                        }
                        AddSourceEntry(sourceEntry);
                        prevSourceEntry = sourceEntry; // current entry is finished
                        //match.
                    }
                }
            }
        }
예제 #3
0
 private int GetDistance(SourceEntry entry1, SourceEntry entry2)
 {
     return(0);
 }
예제 #4
0
 protected bool Equals(
     SourceEntry other)
 {
     return(FileHash == other.FileHash && LineNumber == other.LineNumber && LineOffset == other.LineOffset && ThisHash == other.ThisHash && PreviousHash == other.PreviousHash && NextHash == other.NextHash);
 }