Пример #1
0
 public void Load(CodexFile file)
 {
     using (var reader = new StreamReader(Path.Combine(m_filesDirectory,
                                                       file.AnnotationFileName)))
     {
         file.Read(reader);
     }
 }
Пример #2
0
        public void SaveFile(CodexFile file)
        {
            file.Spans.Sort((cs1, cs2) => cs1.Start.CompareTo(cs2.Start));
            file.AnnotationFileName = Path.GetFileName(file.Path) + file.Path.ToLowerInvariant().GetHashCode() + ".txt";
            Directory.CreateDirectory(m_filesDirectory);

            using (var writer = new StreamWriter(Path.Combine(m_filesDirectory, file.AnnotationFileName)))
            {
                file.Write(writer);
            }
        }
Пример #3
0
        public static void Annotate(BoundSourceFileBuilder builder, CodexFile file)
        {
            builder.AddClassifications(FilterSpans(file.Spans.Select(span => ToClassification(file.Store, span)).Where(c => c != null)));

            foreach (var reference in FilterSpans(file.Spans.Select(span => ToReference(file.Store, builder, span)).Where(c => c != null)))
            {
                builder.AnnotateReferences(reference.Start, reference.Length, reference.Reference);
            }

            foreach (var definition in FilterSpans(file.Spans.Select(span => ToDefinition(file.Store, builder, span)).Where(c => c != null)))
            {
                builder.AnnotateDefinition(definition.Start, definition.Length, definition.Definition);
            }
        }
Пример #4
0
        public static CodexFile ReadEntry(string line)
        {
            string[] parts = line.Split('|');

            var file = new CodexFile()
            {
                Path               = parts[0],
                Length             = int.Parse(parts[1]),
                AnnotationFileName = parts[2],
                Hash               = parts[3]
            };

            file.Project.Read(parts[4]);
            return(file);
        }
Пример #5
0
        public void Load()
        {
            using (var reader = new StreamReader(Path.Combine(m_directory, "classifications.txt")))
            {
                CodexClassification classification;
                while ((classification = CodexClassification.Read(reader)) != null)
                {
                    Classifications.Add(classification);
                }
            }

            using (var reader = new StreamReader(Path.Combine(m_directory, "referencekinds.txt")))
            {
                CodexRefKind refKind;
                while ((refKind = CodexRefKind.Read(reader)) != null)
                {
                    ReferenceKinds.Add(refKind);
                }
            }

            ReadLinesFromFile("symbols.txt", line =>
            {
                var symbol = CodexSymbol.Read(line);
                Symbols.Add(symbol);
            });

            ReadLinesFromFile("projects.txt", line =>
            {
                var project   = CodexProject.ReadEntry(line);
                project.Store = this;
                Projects.Add(project);
            });

            ReadLinesFromFile("files.txt", line =>
            {
                var file   = CodexFile.ReadEntry(line);
                file.Store = this;
                Files.Add(file);
            });
        }