Exemple #1
0
            public void RemoveCircular()
            {
                var reachable = new HashSet <string>();
                var roots     = new HashSet <string>()
                {
                    @"C:\dev\app\src\main.rs", @"C:\dev\app\src\foo.rs"
                };
                var imports = new ModuleImport()
                {
                    { new PathSegment("frob.rs", true), new ModuleImport() },
                };
                var frobImports = new ModuleImport()
                {
                    { new PathSegment("in1", true), new ModuleImport()
                      {
                          { new PathSegment("in2.rs", true), new ModuleImport() }
                      } }
                };
                var in2Imports = new ModuleImport()
                {
                    { new PathSegment("ext1.rs", true), new ModuleImport() },
                    { new PathSegment("ext2.rs", true), new ModuleImport() },
                    { new PathSegment(@"..\frob.rs", true), new ModuleImport() },
                    { new PathSegment(@"..\main.rs", true), new ModuleImport() },
                    { new PathSegment(@"..\foo.rs", true), new ModuleImport() },
                };
                var tracker = new ModuleTracker(@"C:\dev\app\src\main.rs");

                foreach (string path in roots)
                {
                    tracker.AddRootModule(path);
                }
                tracker.ExtractReachableAndMakeIncremental();
                var orphanSet = tracker.DeleteModule(@"C:\dev\app\src\in1\in2.rs");
            }
Exemple #2
0
        protected void ReloadCore()
        {
            string outputType = GetProjectProperty(ProjectFileConstants.OutputType, true);
            string entryPoint = GetCrateFileNodePath(outputType);

            containsEntryPoint = GetCrateFileNode(outputType) != null;
            ModuleTracker      = new ModuleTracker(entryPoint);
            base.Reload();
            // This project for some reason doesn't include entrypoint node, add it
            if (!containsEntryPoint)
            {
                HierarchyNode   parent = this.CreateFolderNodes(Path.GetDirectoryName(entryPoint), true);
                TrackedFileNode node   = (TrackedFileNode)this.CreateFileNode(entryPoint);
                node.IsEntryPoint = true;
                parent.AddChild(node);
            }
            MarkEntryPointFolders(outputType);
            foreach (string file in ModuleTracker.ExtractReachableAndMakeIncremental())
            {
                HierarchyNode parent = this.CreateFolderNodes(Path.GetDirectoryName(file), false);
                parent.AddChild(CreateUntrackedNode(file));
            }
        }
        protected override void Reload()
        {
            string outputType = GetProjectProperty(ProjectFileConstants.OutputType, false);
            string entryPoint = Path.Combine(Path.GetDirectoryName(this.FileName), outputType == "library" ? @"src\lib.rs" : @"src\main.rs");

            containsEntryPoint = false;
            ModuleTracker      = new ModuleTracker(entryPoint);
            base.Reload();
            // This project for some reason doesn't include entrypoint node, add it
            if (!containsEntryPoint)
            {
                HierarchyNode   parent = this.CreateFolderNodes(Path.GetDirectoryName(entryPoint), true);
                TrackedFileNode node   = (TrackedFileNode)this.CreateFileNode(entryPoint);
                node.IsEntryPoint = true;
                parent.AddChild(node);
            }
            foreach (string file in ModuleTracker.ExtractReachableAndMakeIncremental())
            {
                HierarchyNode parent = this.CreateFolderNodes(Path.GetDirectoryName(file), false);
                parent.AddChild(CreateUntrackedNode(file));
            }
            this.BuildProject.Save();
        }