Ejemplo n.º 1
0
        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));
        }
Ejemplo n.º 2
0
        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();
            });
        }
Ejemplo n.º 3
0
 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);
 }
Ejemplo n.º 4
0
        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);
            }
        }
Ejemplo n.º 5
0
 public override sealed Entry WithChild(int index, Entry child, JObject changes, JObject subChange)
 {
     throw new InvalidOperationException("Cannot set children on files");
 }
Ejemplo n.º 6
0
 public override Entry WithChild(int index, Entry child, JObject changes, JObject subChange)
 {
     throw new InvalidOperationException("Cannot set children on package directories");
 }
Ejemplo n.º 7
0
 public abstract Entry WithChild(int index, Entry child, JObject changes, JObject subChange);
Ejemplo n.º 8
0
        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);
        }
Ejemplo n.º 9
0
        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");
        }
Ejemplo n.º 10
0
 public Workspace WithContent(Entry content, JObject changes, JObject partials)
 {
     Utils.RegisterChange(changes, () => Content, content, partials);
     return new Workspace(_dir, content, _projects);
 }