Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add support for Miscellaneous Files #1252

Merged
merged 59 commits into from
Aug 13, 2018
Merged
Show file tree
Hide file tree
Changes from 28 commits
Commits
Show all changes
59 commits
Select commit Hold shift + click to select a range
a784769
Basic of the orphan file system
akshita31 Jun 28, 2018
f0cc59e
Initialise the project system
akshita31 Jun 28, 2018
b26552b
add csproj
akshita31 Jun 29, 2018
48548a7
Test using MSBuildProjectSystem
akshita31 Jul 3, 2018
774cc9b
Orphan file system using the msbuild system
akshita31 Jul 4, 2018
2d46149
Remove unnecessary change
akshita31 Jul 4, 2018
27266dd
csproj temp
akshita31 Jul 5, 2018
6f972d0
Get only syntactic diagnostics for misc files
akshita31 Jul 6, 2018
7bb4708
Logic to delete the document
akshita31 Jul 9, 2018
bf59f02
Edit csproj
akshita31 Jul 9, 2018
0db4d70
Rename to misc files
akshita31 Jul 9, 2018
8e6baec
Order the project systems
akshita31 Jul 10, 2018
439e9ad
Ordering failing
akshita31 Jul 10, 2018
2bbfe5b
Order project systems based on DisplayName
akshita31 Jul 11, 2018
35e2630
Remove orphan system
akshita31 Jul 11, 2018
999bf3f
Put inside the partial class
akshita31 Jul 11, 2018
81321cd
Clean up the miscellanous file system
akshita31 Jul 11, 2018
7e6ba33
Tests for the misc project system
akshita31 Jul 23, 2018
eba6ae2
Make MEF work
Jul 23, 2018
af435a6
Merge pull request #1 from rchande/MEFfix
akshita31 Jul 23, 2018
895cf5b
Returns only semantic diagnostics running
akshita31 Jul 24, 2018
c422035
Add more failing tests
akshita31 Jul 24, 2018
57bfbc5
Clean up
akshita31 Jul 25, 2018
48b4c26
Extension Ordering working for the project systems
akshita31 Jul 25, 2018
9a9cfa9
Merge master
akshita31 Jul 30, 2018
36af94b
Clean the solution
akshita31 Jul 30, 2018
11251b0
Change the target framework
akshita31 Jul 30, 2018
dd73d39
Add references
akshita31 Jul 30, 2018
2b599a6
Rename project system
akshita31 Jul 31, 2018
42c9049
Add few tests
akshita31 Jul 31, 2018
d0574cb
Refactor the tests to add a method to the test host
akshita31 Aug 1, 2018
6d8201a
Remove roslyn dependency in abstractions
akshita31 Aug 1, 2018
7a419ed
use only one project for all the miscellanous files
akshita31 Aug 2, 2018
def58ec
Add project system names class
akshita31 Aug 2, 2018
5788c37
Modifying the files changed facts to use absolute path instead of rel…
akshita31 Aug 2, 2018
9a8d447
Add the empty project
akshita31 Aug 2, 2018
c7158ba
Add the IUpdates interface
akshita31 Aug 2, 2018
c243202
Add absolute paths for the misc file system
akshita31 Aug 7, 2018
3cf76e6
Merge remote-tracking branch 'upstream/master' into orphan_system
akshita31 Aug 7, 2018
98e4de3
Add dotnet project system for the updates
akshita31 Aug 8, 2018
6228db3
CR feedback
akshita31 Aug 8, 2018
069d6f0
Remove comment
akshita31 Aug 9, 2018
2e5e7fc
Add project handling in the workspace
akshita31 Aug 9, 2018
850f3fd
Merge remote-tracking branch 'origin/orphan_system' into orphan_system
akshita31 Aug 9, 2018
f89946d
Add assembly info
akshita31 Aug 9, 2018
20bf194
Deal with race condition between project system updates
akshita31 Aug 9, 2018
4163f3f
add property type
akshita31 Aug 9, 2018
9e2e0b9
CR feedback
akshita31 Aug 10, 2018
6dfca92
Move the check for the Misc files into the workspace
akshita31 Aug 10, 2018
c5db9c9
edit comment
akshita31 Aug 10, 2018
2a3666a
Merge branch 'master' into orphan_system
akshita31 Aug 10, 2018
7a70a07
Check for the project id for the document
akshita31 Aug 10, 2018
ce3a437
Dont keep track of the documents in the project system
akshita31 Aug 10, 2018
2355ded
Add test for multiple files
akshita31 Aug 10, 2018
b8d11e2
Add test to handle deletion
akshita31 Aug 10, 2018
67003aa
Call TryRemoveMiscDocument
akshita31 Aug 12, 2018
4d3e853
Naming consistency
akshita31 Aug 13, 2018
f0d3255
Use the default references same as the script system
akshita31 Aug 13, 2018
cdecdad
CR feedback
akshita31 Aug 13, 2018
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
33 changes: 32 additions & 1 deletion OmniSharp.sln
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@

Microsoft Visual Studio Solution File, Format Version 12.00
# Visual Studio 15
VisualStudioVersion = 15.0.27004.2005
Expand All @@ -11,7 +12,7 @@ Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Solution Items", "Solution
global.json = global.json
EndProjectSection
ProjectSection(FolderGlobals) = preProject
global_1json__JSONSchema = http://json.schemastore.org/global
global_1json__JSONSchema = http://json.schemastore.org/global
EndProjectSection
EndProject
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "tests", "tests", "{35E025BF-BBB2-4FAC-9F4B-37CBA083EE47}"
Expand Down Expand Up @@ -68,6 +69,10 @@ Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "OmniSharp.Stdio.Driver", "s
EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "OmniSharp.Script.Tests", "tests\OmniSharp.Script.Tests\OmniSharp.Script.Tests.csproj", "{9E4BA68C-7F4B-429A-A0C7-8CE7D41D610F}"
EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "OmniSharp.MiscellanousFiles", "src\OmniSharp.MiscellanousFiles\OmniSharp.MiscellanousFiles.csproj", "{2BF50528-38C4-4928-9FB2-7539A3C20DA8}"
EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "OmniSharp.MiscellanousFiles.Tests", "tests\OmniSharp.MiscellanousFiles.Tests\OmniSharp.MiscellanousFiles.Tests.csproj", "{CFDBAAF4-C579-4514-9A25-EA132CD47C65}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Any CPU = Debug|Any CPU
Expand Down Expand Up @@ -390,6 +395,30 @@ Global
{9E4BA68C-7F4B-429A-A0C7-8CE7D41D610F}.Release|x64.Build.0 = Release|Any CPU
{9E4BA68C-7F4B-429A-A0C7-8CE7D41D610F}.Release|x86.ActiveCfg = Release|Any CPU
{9E4BA68C-7F4B-429A-A0C7-8CE7D41D610F}.Release|x86.Build.0 = Release|Any CPU
{2BF50528-38C4-4928-9FB2-7539A3C20DA8}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{2BF50528-38C4-4928-9FB2-7539A3C20DA8}.Debug|Any CPU.Build.0 = Debug|Any CPU
{2BF50528-38C4-4928-9FB2-7539A3C20DA8}.Debug|x64.ActiveCfg = Debug|Any CPU
{2BF50528-38C4-4928-9FB2-7539A3C20DA8}.Debug|x64.Build.0 = Debug|Any CPU
{2BF50528-38C4-4928-9FB2-7539A3C20DA8}.Debug|x86.ActiveCfg = Debug|Any CPU
{2BF50528-38C4-4928-9FB2-7539A3C20DA8}.Debug|x86.Build.0 = Debug|Any CPU
{2BF50528-38C4-4928-9FB2-7539A3C20DA8}.Release|Any CPU.ActiveCfg = Release|Any CPU
{2BF50528-38C4-4928-9FB2-7539A3C20DA8}.Release|Any CPU.Build.0 = Release|Any CPU
{2BF50528-38C4-4928-9FB2-7539A3C20DA8}.Release|x64.ActiveCfg = Release|Any CPU
{2BF50528-38C4-4928-9FB2-7539A3C20DA8}.Release|x64.Build.0 = Release|Any CPU
{2BF50528-38C4-4928-9FB2-7539A3C20DA8}.Release|x86.ActiveCfg = Release|Any CPU
{2BF50528-38C4-4928-9FB2-7539A3C20DA8}.Release|x86.Build.0 = Release|Any CPU
{CFDBAAF4-C579-4514-9A25-EA132CD47C65}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{CFDBAAF4-C579-4514-9A25-EA132CD47C65}.Debug|Any CPU.Build.0 = Debug|Any CPU
{CFDBAAF4-C579-4514-9A25-EA132CD47C65}.Debug|x64.ActiveCfg = Debug|Any CPU
{CFDBAAF4-C579-4514-9A25-EA132CD47C65}.Debug|x64.Build.0 = Debug|Any CPU
{CFDBAAF4-C579-4514-9A25-EA132CD47C65}.Debug|x86.ActiveCfg = Debug|Any CPU
{CFDBAAF4-C579-4514-9A25-EA132CD47C65}.Debug|x86.Build.0 = Debug|Any CPU
{CFDBAAF4-C579-4514-9A25-EA132CD47C65}.Release|Any CPU.ActiveCfg = Release|Any CPU
{CFDBAAF4-C579-4514-9A25-EA132CD47C65}.Release|Any CPU.Build.0 = Release|Any CPU
{CFDBAAF4-C579-4514-9A25-EA132CD47C65}.Release|x64.ActiveCfg = Release|Any CPU
{CFDBAAF4-C579-4514-9A25-EA132CD47C65}.Release|x64.Build.0 = Release|Any CPU
{CFDBAAF4-C579-4514-9A25-EA132CD47C65}.Release|x86.ActiveCfg = Release|Any CPU
{CFDBAAF4-C579-4514-9A25-EA132CD47C65}.Release|x86.Build.0 = Release|Any CPU
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
Expand Down Expand Up @@ -421,6 +450,8 @@ Global
{BC640CBF-F6E2-42EA-9D61-FB6E515AEA44} = {2C348365-A9D8-459E-9276-56FC46AAEE31}
{D2A78CEE-B278-476F-AF34-A7D6F792F973} = {2C348365-A9D8-459E-9276-56FC46AAEE31}
{9E4BA68C-7F4B-429A-A0C7-8CE7D41D610F} = {35E025BF-BBB2-4FAC-9F4B-37CBA083EE47}
{2BF50528-38C4-4928-9FB2-7539A3C20DA8} = {2C348365-A9D8-459E-9276-56FC46AAEE31}
{CFDBAAF4-C579-4514-9A25-EA132CD47C65} = {35E025BF-BBB2-4FAC-9F4B-37CBA083EE47}
EndGlobalSection
GlobalSection(ExtensibilityGlobals) = postSolution
SolutionGuid = {4DD725CE-B49A-4151-8B77-BB33FE88E46E}
Expand Down
19 changes: 19 additions & 0 deletions src/OmniSharp.Abstractions/Mef/ExportIProjectSystemAttribute.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
using System;
using System.Composition;
using Microsoft.CodeAnalysis;
using OmniSharp.Services;

namespace OmniSharp.Mef
{
[MetadataAttribute]
[AttributeUsage(AttributeTargets.Class, AllowMultiple = false)]
public class ExportIProjectSystemAttribute: ExportAttribute
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Naming: remove the "I" and go with "ExportProjectSystemAttribute".

{
public string Name { get; }

public ExportIProjectSystemAttribute(string name) : base(typeof(IProjectSystem))
{
Name = name;
}
}
}
7 changes: 7 additions & 0 deletions src/OmniSharp.Abstractions/Mef/ProjectSystemMetadata.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
namespace OmniSharp.Mef
{
public class ProjectSystemMetadata
{
public string Name { get; set; }
}
}
1 change: 1 addition & 0 deletions src/OmniSharp.Abstractions/OmniSharp.Abstractions.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
</PropertyGroup>

<ItemGroup>
<PackageReference Include="Microsoft.CodeAnalysis" Version="2.8.2" />
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think this breaks layering. IIRC, OmniSharp.Abstractions was not supposed to have a dependency on Roslyn. @david-driscoll, is that right?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

that was definitely the idea, that's also why OmniSharp.Roslyn is there, as an extra layer over OmniSharp.Roslyn.CSharp

<PackageReference Include="Microsoft.Extensions.Configuration" />
<PackageReference Include="Microsoft.Extensions.Configuration.Binder" />
<PackageReference Include="Microsoft.Extensions.FileProviders.Physical" />
Expand Down
88 changes: 88 additions & 0 deletions src/OmniSharp.Abstractions/Utilities/ExtensionOrderer.Graph.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,88 @@
// Adapted from ExtensionOrderer in Roslyn
using System.Collections.Generic;

namespace OmniSharp.Utilities
{
static partial class ExtensionOrderer
{
internal class Graph<T>
{
//Dictionary to map between nodes and the names
private Dictionary<string, Node<T>> Nodes { get; }
private List<Node<T>> AllNodes { get; }
private Graph(List<Node<T>> nodesList)
{
Nodes = new Dictionary<string, Node<T>>();
AllNodes = nodesList;
}
internal static Graph<T> GetGraph(List<Node<T>> nodesList)
{
var graph = new Graph<T>(nodesList);

foreach (Node<T> node in graph.AllNodes)
{
graph.Nodes[node.Name] = node;
}

foreach (Node<T> node in graph.AllNodes)
{
foreach (var before in node.Before)
{
if (graph.Nodes.ContainsKey(before))
{
var beforeNode = graph.Nodes[before];
beforeNode.NodesBeforeMeSet.Add(node);
}
}

foreach (var after in node.After)
{
if (graph.Nodes.ContainsKey(after))
{
var afterNode = graph.Nodes[after];
node.NodesBeforeMeSet.Add(afterNode);
}
}
}

return graph;
}

public bool HasCycles()
{
foreach (var node in this.AllNodes)
{
if (node.CheckForCycles())
return true;
}
return false;
}

public List<T> TopologicalSort()
{
List<T> result = new List<T>();
var seenNodes = new HashSet<Node<T>>();

foreach (var node in AllNodes)
{
Visit(node, result, seenNodes);
}

return result;
}

private void Visit(Node<T> node, List<T> result, HashSet<Node<T>> seenNodes)
{
if (seenNodes.Add(node))
{
foreach (var before in node.NodesBeforeMeSet)
{
Visit(before, result, seenNodes);
}

result.Add(node.Extension);
}
}
}
}
}
76 changes: 76 additions & 0 deletions src/OmniSharp.Abstractions/Utilities/ExtensionOrderer.Node.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,76 @@
// Adapted from ExtensionOrderer in Roslyn
using System;
using System.Collections.Generic;
using System.Reflection;
using Microsoft.CodeAnalysis;

namespace OmniSharp.Utilities
{
static partial class ExtensionOrderer
{
internal class Node<TNode>
{
public string Name { get; set; }
public List<string> Before { get; set; }
public List<string> After { get; set; }
public TNode Extension { get; set; }
public HashSet<Node<TNode>> NodesBeforeMeSet { get; set; }

public static Node<TNode> From<TNodeAttribute>(TNode extension, Func<TNodeAttribute, string> nameExtractor) where TNodeAttribute : Attribute
{
string name = string.Empty;
var attribute = extension.GetType().GetCustomAttribute<TNodeAttribute>();
if (attribute is TNodeAttribute && !string.IsNullOrEmpty(nameExtractor(attribute)))
{
name = nameExtractor(attribute);
}
var orderAttributes = extension.GetType().GetCustomAttributes<ExtensionOrderAttribute>(true);
return new Node<TNode>(extension, name, orderAttributes);
}

private Node(TNode extension, string name, IEnumerable<ExtensionOrderAttribute> orderAttributes)
{
Extension = extension;
Name = name;
Before = new List<string>();
After = new List<string>();
NodesBeforeMeSet = new HashSet<Node<TNode>>();
foreach (var attribute in orderAttributes)
{
AddAttribute(attribute);
}
}

private void AddAttribute(ExtensionOrderAttribute attribute)
{
if (attribute.Before != null)
Before.Add(attribute.Before);
if (attribute.After != null)
After.Add(attribute.After);
}

internal bool CheckForCycles()
{
return CheckForCycles(new HashSet<Node<TNode>>());
}

private bool CheckForCycles(HashSet<Node<TNode>> seenNodes)
{
if (!seenNodes.Add(this))
{
//Cycle detected
return true;
}

foreach (var before in this.NodesBeforeMeSet)
{
if (before.CheckForCycles(seenNodes))
return true;
}

seenNodes.Remove(this);
return false;
}
}
}
}
19 changes: 19 additions & 0 deletions src/OmniSharp.Abstractions/Utilities/ExtensionOrderer.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace OmniSharp.Utilities
{
static partial class ExtensionOrderer
{
/* Returns a sorted order of the nodes if such a sorting exists, else returns the unsorted list */
public static IEnumerable<TExtension> GetOrderedOrUnorderedList<TExtension, TAttribute>(IEnumerable<TExtension> unsortedList, Func<TAttribute, string> nameExtractor) where TAttribute: Attribute
{
var nodesList = unsortedList.Select(elem => Node<TExtension>.From(elem, nameExtractor));
var graph = Graph<TExtension>.GetGraph(nodesList.ToList());
return graph.HasCycles() ? unsortedList : graph.TopologicalSort();
}
}
}
3 changes: 2 additions & 1 deletion src/OmniSharp.Cake/CakeProjectSystem.cs
Original file line number Diff line number Diff line change
Expand Up @@ -16,13 +16,14 @@
using OmniSharp.FileSystem;
using OmniSharp.FileWatching;
using OmniSharp.Helpers;
using OmniSharp.Mef;
using OmniSharp.Models.WorkspaceInformation;
using OmniSharp.Roslyn.Utilities;
using OmniSharp.Services;

namespace OmniSharp.Cake
{
[Export(typeof(IProjectSystem)), Shared]
[ExportIProjectSystem(nameof(CakeProjectSystem)), Shared]
public class CakeProjectSystem : IProjectSystem
{
private readonly OmniSharpWorkspace _workspace;
Expand Down
3 changes: 2 additions & 1 deletion src/OmniSharp.DotNet/DotNetProjectSystem.cs
Original file line number Diff line number Diff line change
Expand Up @@ -17,13 +17,14 @@
using OmniSharp.Eventing;
using OmniSharp.FileWatching;
using OmniSharp.Helpers;
using OmniSharp.Mef;
using OmniSharp.Models.Events;
using OmniSharp.Models.WorkspaceInformation;
using OmniSharp.Services;

namespace OmniSharp.DotNet
{
[Export(typeof(IProjectSystem)), Shared]
[ExportIProjectSystem(nameof(DotNetProjectSystem)), Shared]
public class DotNetProjectSystem : IProjectSystem
{
private const string CompilationConfiguration = "Debug";
Expand Down
12 changes: 10 additions & 2 deletions src/OmniSharp.Host/WorkspaceInitializer.cs
Original file line number Diff line number Diff line change
@@ -1,13 +1,19 @@
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Composition;
using System.Composition.Hosting;
using System.Linq;
using Microsoft.Extensions.Configuration;
using Microsoft.Extensions.DependencyInjection;
using Microsoft.Extensions.Logging;
using Microsoft.Extensions.Options;
using OmniSharp.Mef;
using OmniSharp.Options;
using OmniSharp.Roslyn;
using OmniSharp.Roslyn.Options;
using OmniSharp.Services;
using OmniSharp.Utilities;

namespace OmniSharp
{
Expand All @@ -24,9 +30,11 @@ public static void Initialize(

var projectEventForwarder = compositionHost.GetExport<ProjectEventForwarder>();
projectEventForwarder.Initialize();
var projectSystems = compositionHost.GetExports<Lazy<IProjectSystem, ProjectSystemMetadata>>();
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

maybe we should hide that logic in some generic extension method? this way it could be reused in the future against other potentially ordered look ups like i.e.

foreach (var workspaceOptionsProvider in compositionHost.GetExports<IWorkspaceOptionsProvider>())

var ps = projectSystems.Select(n => n.Value);
var orderedProjectSystems = ExtensionOrderer.GetOrderedOrUnorderedList<IProjectSystem, ExportIProjectSystemAttribute>(ps, eps => eps.Name);

// Initialize all the project systems
foreach (var projectSystem in compositionHost.GetExports<IProjectSystem>())
foreach (var projectSystem in orderedProjectSystems)
{
try
{
Expand Down
8 changes: 7 additions & 1 deletion src/OmniSharp.MSBuild/ProjectSystem.cs
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
using OmniSharp.Eventing;
using OmniSharp.FileSystem;
using OmniSharp.FileWatching;
using OmniSharp.Mef;
using OmniSharp.Models.WorkspaceInformation;
using OmniSharp.MSBuild.Discovery;
using OmniSharp.MSBuild.Models;
Expand All @@ -20,7 +21,7 @@

namespace OmniSharp.MSBuild
{
[Export(typeof(IProjectSystem)), Shared]
[ExportIProjectSystem(nameof(ProjectSystem)), Shared]
public class ProjectSystem : IProjectSystem
{
private readonly IOmniSharpEnvironment _environment;
Expand Down Expand Up @@ -209,5 +210,10 @@ async Task<object> IProjectSystem.GetProjectModelAsync(string filePath)

return new MSBuildProjectInfo(projectFileInfo);
}

public async Task HasCompletedUpdateRequest()
Copy link
Contributor

@DustinCampbell DustinCampbell Aug 2, 2018

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think this needs a better name. "HasCompletedUpdateRequest" implies that this would return a boolean and doesn't really indicate that it's asynchronous.

How about WaitForInitializeAsync? Or, something like that?

Copy link
Contributor

@DustinCampbell DustinCampbell Aug 2, 2018

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Or, if you decide to introduce a different interface for this behavior, maybe a WaitForPendingUpdatesAsync method?

{
await _manager.WaitForQueueEmptyAsync();
}
}
}
Loading