コード例 #1
0
ファイル: ReferenceEntry.cs プロジェクト: Runt-Editor/Runt
        public override Entry WithChild(int index, Entry child, JObject changes, JObject subChange)
        {
            var indexChange = new JObject();
            Utils.RegisterChange(indexChange, index.ToString(), child, subChange);

            // Note: I use null here because I don't want to create the lists.
            // given that indexChange will never be null, this is safe.
            Utils.RegisterChange(changes, () => Children, null, indexChange);
            return new ReferenceEntry(RelativePath, IsOpen, _name, _version, _unresolved, _dependencies.SetItem(index, (ReferenceEntry)child));
        }
コード例 #2
0
ファイル: Workspace.cs プロジェクト: Runt-Editor/Runt
        private Workspace(DirectoryInfo dir, Entry tree,
            ImmutableList<string> projects)
        {
            _dir = dir;
            _tree = tree;
            _projects = projects;
            _projectCache = new Lazy<ImmutableList<ProjectEntry>>(() => _projects.Select(p => FindProject(_tree, p)).ToImmutableList());
            _errorList = new Lazy<ImmutableList<DiagnosticMessage>>(() =>
            {
                var diagnostics = ImmutableList.CreateBuilder<DiagnosticMessage>();

                foreach (var project in _projectCache.Value)
                    diagnostics.AddRange(project.Diagnostics);

                return diagnostics.ToImmutable();
            });
        }
コード例 #3
0
ファイル: DirectoryEntry.cs プロジェクト: Runt-Editor/Runt
 public override Entry WithChild(int index, Entry child, JObject changes, JObject subChange)
 {
     var lists = ChangeIndex(index, child, changes, subChange);
     return new DirectoryEntry(RelativePath, IsOpen, _dir, lists.Item1, lists.Item2);
 }
コード例 #4
0
ファイル: DirectoryEntry.cs プロジェクト: Runt-Editor/Runt
        protected Tuple<ImmutableList<DirectoryEntry>, ImmutableList<Entry>> ChangeIndex(
            int index, Entry newVal, JObject changes, JObject subChanges)
        {
            var indexChange = new JObject();
            Utils.RegisterChange(indexChange, index.ToString(), newVal, subChanges);

            // Note: I use null here because I don't want to create the lists.
            // given that indexChange will never be null, this is safe.
            Utils.RegisterChange(changes, () => Children, null, indexChange);

            if (index < _directories.Count)
            {
                var newDirs = _directories.SetItem(index, (DirectoryEntry)newVal);
                return new Tuple<ImmutableList<DirectoryEntry>, ImmutableList<Entry>>(newDirs, _files);
            }
            else
            {
                var newFiles = _files.SetItem(index - _directories.Count, newVal);
                return new Tuple<ImmutableList<DirectoryEntry>, ImmutableList<Entry>>(_directories, newFiles);
            }
        }
コード例 #5
0
ファイル: FileEntry.cs プロジェクト: Runt-Editor/Runt
 public override sealed Entry WithChild(int index, Entry child, JObject changes, JObject subChange)
 {
     throw new InvalidOperationException("Cannot set children on files");
 }
コード例 #6
0
ファイル: PackagesEntry.cs プロジェクト: Runt-Editor/Runt
 public override Entry WithChild(int index, Entry child, JObject changes, JObject subChange)
 {
     throw new InvalidOperationException("Cannot set children on package directories");
 }
コード例 #7
0
ファイル: Entry.cs プロジェクト: Runt-Editor/Runt
 public abstract Entry WithChild(int index, Entry child, JObject changes, JObject subChange);
コード例 #8
0
ファイル: ProjectEntry.cs プロジェクト: Runt-Editor/Runt
        public override Entry WithChild(int index, Entry child, JObject changes, JObject subChange)
        {
            if (index == 0)
            {
                if (child is ReferencesEntry)
                    return WithReferences((ReferencesEntry)child, changes, subChange);
                else
                    throw new InvalidOperationException("Cannot set references entry of a project to a non-references entry");
            }

            var lists = ChangeIndex(index - 1, child, changes, subChange);
            return new ProjectEntry(RelativePath, IsOpen, _dir, lists.Item1, lists.Item2, _references, _diagnostics, _id, _sources, _generatedSources, _configurations);
        }
コード例 #9
0
ファイル: Workspace.cs プロジェクト: Runt-Editor/Runt
        private static ProjectEntry FindProject(Entry entry, string relPath)
        {
            for (int i = 0, l = entry.Children.Count; i < l; i++)
            {
                var child = entry.Children[i];
                if (relPath.Equals(child.RelativePath, StringComparison.OrdinalIgnoreCase))
                {
                    // found the node. Update and recurse back
                    return (ProjectEntry)child;

                }
                else if (relPath.StartsWith(child.RelativePath, StringComparison.OrdinalIgnoreCase))
                {
                    // found a parent of the node in question, recurse downwards
                    return FindProject(child, relPath);
                }
            }

            throw new InvalidOperationException("Project with given path not found");
        }
コード例 #10
0
ファイル: Workspace.cs プロジェクト: Runt-Editor/Runt
 public Workspace WithContent(Entry content, JObject changes, JObject partials)
 {
     Utils.RegisterChange(changes, () => Content, content, partials);
     return new Workspace(_dir, content, _projects);
 }