Skip to content

Commit

Permalink
Merge branch 'dev' into bugfix/csx-gotometadata
Browse files Browse the repository at this point in the history
  • Loading branch information
DustinCampbell authored Apr 21, 2017
2 parents 9cb35de + c786717 commit 56dfe3a
Show file tree
Hide file tree
Showing 89 changed files with 257 additions and 235 deletions.
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
namespace OmniSharp.Services
namespace OmniSharp.Eventing
{
public interface IEventEmitter
{
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
using OmniSharp.Models;
using OmniSharp.Models.Events;

namespace OmniSharp.Services
namespace OmniSharp.Eventing
{
public static class IEventEmitterExtensions
{
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
using System;

namespace OmniSharp.Services.FileWatching
namespace OmniSharp.FileWatching
{
// TODO: Flesh out this API more
public interface IFileSystemWatcher
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
using Microsoft.Extensions.Logging;

namespace OmniSharp.Services
namespace OmniSharp
{
public interface IOmniSharpEnvironment
{
Expand Down
2 changes: 0 additions & 2 deletions src/OmniSharp.Abstractions/Models/Events/ErrorMessage.cs
Original file line number Diff line number Diff line change
@@ -1,6 +1,4 @@
using Newtonsoft.Json;
using OmniSharp.Json;

namespace OmniSharp.Models.Events
{
public class ErrorMessage
Expand Down
3 changes: 1 addition & 2 deletions src/OmniSharp.Abstractions/Models/Events/EventTypes.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
namespace OmniSharp.Models
namespace OmniSharp.Models.Events
{
public static class EventTypes
{
Expand All @@ -10,7 +10,6 @@ public static class EventTypes
public static readonly string MsBuildProjectDiagnostics = nameof(MsBuildProjectDiagnostics);
public static readonly string PackageRestoreStarted = nameof(PackageRestoreStarted);
public static readonly string PackageRestoreFinished = nameof(PackageRestoreFinished);
public static readonly string TestMessage = nameof(TestMessage);
public static readonly string UnresolvedDependencies = nameof(UnresolvedDependencies);
}
}
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
namespace OmniSharp.Models
namespace OmniSharp.Models.Events
{
public class PackageDependency
{
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
namespace OmniSharp.Models
namespace OmniSharp.Models.Events
{
public class PackageRestoreMessage
{
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
using System.Collections.Generic;

namespace OmniSharp.Models
namespace OmniSharp.Models.Events
{
public class UnresolvedDependenciesMessage
{
Expand Down
1 change: 0 additions & 1 deletion src/OmniSharp.Abstractions/Models/Request.cs
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
using System.Collections.Generic;
using System.IO;
using Newtonsoft.Json;
using OmniSharp.Json;

namespace OmniSharp.Models
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
using System.Linq;
using Newtonsoft.Json;

namespace OmniSharp.Json
namespace OmniSharp.Models
{
public class ZeroBasedIndexConverter : JsonConverter
{
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
using Newtonsoft.Json;
using OmniSharp.Json;
using OmniSharp.Mef;

namespace OmniSharp.Models.ChangeBuffer
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,4 @@
using Newtonsoft.Json;
using OmniSharp.Json;

namespace OmniSharp.Models.CodeAction
{
public abstract class CodeActionRequest : Request
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
using Newtonsoft.Json;
using OmniSharp.Json;
using OmniSharp.Mef;

namespace OmniSharp.Models.Format
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
using Newtonsoft.Json;
using OmniSharp.Json;
using OmniSharp.Models.Metadata;

namespace OmniSharp.Models.GotoDefinition
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
using Newtonsoft.Json;
using OmniSharp.Json;
using OmniSharp.Mef;

namespace OmniSharp.Models.Highlight
Expand Down
18 changes: 0 additions & 18 deletions src/OmniSharp.Abstractions/Models/v1/Highlight/HighlightSpan.cs
Original file line number Diff line number Diff line change
@@ -1,9 +1,6 @@
using System;
using System.Collections.Generic;
using Microsoft.CodeAnalysis.Classification;
using Microsoft.CodeAnalysis.Text;
using Newtonsoft.Json;
using OmniSharp.Json;

namespace OmniSharp.Models.Highlight
{
Expand All @@ -20,21 +17,6 @@ public class HighlightSpan : IComparable<HighlightSpan>
public string Kind { get; set; }
public IEnumerable<string> Projects { get; set; }

public static HighlightSpan FromClassifiedSpan(ClassifiedSpan span, TextLineCollection lines, IEnumerable<string> projects)
{
var linePos = lines.GetLinePositionSpan(span.TextSpan);

return new HighlightSpan
{
StartLine = linePos.Start.Line,
EndLine = linePos.End.Line,
StartColumn = linePos.Start.Character,
EndColumn = linePos.End.Character,
Kind = span.ClassificationType,
Projects = projects
};
}

public int CompareTo(HighlightSpan other)
{
if (other.StartLine < StartLine)
Expand Down
54 changes: 0 additions & 54 deletions src/OmniSharp.Abstractions/Models/v1/LinePositionSpanTextChange.cs
Original file line number Diff line number Diff line change
@@ -1,63 +1,9 @@
using System.Collections.Generic;
using System.Linq;
using System.Threading.Tasks;
using Microsoft.CodeAnalysis;
using Microsoft.CodeAnalysis.Text;
using Newtonsoft.Json;
using OmniSharp.Json;

namespace OmniSharp.Models
{
public class LinePositionSpanTextChange
{
public static async Task<IEnumerable<LinePositionSpanTextChange>> Convert(Document document, IEnumerable<TextChange> changes)
{
var text = await document.GetTextAsync();

return changes
.OrderByDescending(change => change.Span)
.Select(change =>
{
var span = change.Span;
var newText = change.NewText;
var prefix = string.Empty;
var postfix = string.Empty;

if (newText.Length > 0)
{
// Roslyn computes text changes on character arrays. So it might happen that a
// change starts inbetween \r\n which is OK when you are offset-based but a problem
// when you are line,column-based. This code extends text edits which just overlap
// a with a line break to its full line break

if (span.Start > 0 && newText[0] == '\n' && text[span.Start - 1] == '\r')
{
// text: foo\r\nbar\r\nfoo
// edit: [----)
span = TextSpan.FromBounds(span.Start - 1, span.End);
prefix = "\r";
}
if (span.End < text.Length - 1 && newText[newText.Length - 1] == '\r' && text[span.End] == '\n')
{
// text: foo\r\nbar\r\nfoo
// edit: [----)
span = TextSpan.FromBounds(span.Start, span.End + 1);
postfix = "\n";
}
}

var linePositionSpan = text.Lines.GetLinePositionSpan(span);
return new LinePositionSpanTextChange()
{
NewText = prefix + newText + postfix,
StartLine = linePositionSpan.Start.Line,
StartColumn = linePositionSpan.Start.Character,
EndLine = linePositionSpan.End.Line,
EndColumn = linePositionSpan.End.Character
};
});
}

public string NewText { get; set; }

[JsonConverter(typeof(ZeroBasedIndexConverter))]
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,4 @@
using Newtonsoft.Json;
using OmniSharp.Json;

namespace OmniSharp.Models.Navigate
{
public class NavigateResponse
Expand Down
1 change: 0 additions & 1 deletion src/OmniSharp.Abstractions/Models/v1/QuickFix.cs
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
using System.Collections.Generic;
using Newtonsoft.Json;
using OmniSharp.Json;

namespace OmniSharp.Models
{
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
namespace OmniSharp
namespace OmniSharp.Models.TestCommand
{
public enum TestCommandType
{
Expand Down
1 change: 0 additions & 1 deletion src/OmniSharp.Abstractions/Models/v2/ICodeActionRequest.cs
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
using Newtonsoft.Json;
using OmniSharp.Json;

namespace OmniSharp.Models.V2
{
Expand Down
1 change: 0 additions & 1 deletion src/OmniSharp.Abstractions/Models/v2/Point.cs
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
using Newtonsoft.Json;
using OmniSharp.Json;

namespace OmniSharp.Models.V2
{
Expand Down
6 changes: 1 addition & 5 deletions src/OmniSharp.Abstractions/OmniSharp.Abstractions.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -12,9 +12,7 @@

<ItemGroup>
<PackageReference Include="Newtonsoft.Json" Version="9.0.1" />
<PackageReference Include="Microsoft.CodeAnalysis.Common" Version="2.0.0" />
<PackageReference Include="Microsoft.CodeAnalysis.Workspaces.Common" Version="2.0.0" />
<PackageReference Include="Microsoft.Extensions.Caching.Memory" Version="1.1.0" />
<PackageReference Include="Microsoft.Composition" Version="1.0.30" />
<PackageReference Include="Microsoft.Extensions.Configuration" Version="1.1.0" />
<PackageReference Include="Microsoft.Extensions.Configuration.Binder" Version="1.1.0" />
<PackageReference Include="Microsoft.Extensions.FileProviders.Physical" Version="1.1.0" />
Expand All @@ -27,8 +25,6 @@

<ItemGroup Condition=" '$(TargetFramework)' == 'netstandard1.6' ">
<PackageReference Include="System.Diagnostics.Process" Version="4.3.0" />
<PackageReference Include="System.Dynamic.Runtime" Version="4.3.0" />
<PackageReference Include="System.IO.FileSystem.Watcher" Version="4.3.0" />
<PackageReference Include="System.Threading.Thread" Version="4.3.0" />
</ItemGroup>

Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
namespace OmniSharp.Options
{
// TODO: These are mostly C#-specific. Should they be moved into in OmniSharp.Roslyn.CSharp somehow?
public class FormattingOptions
{
public FormattingOptions()
Expand Down
1 change: 1 addition & 0 deletions src/OmniSharp.Abstractions/Services/DotNetCliService.cs
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
using System.Threading.Tasks;
using Microsoft.Extensions.Logging;
using NuGet.Versioning;
using OmniSharp.Eventing;
using OmniSharp.Utilities;

namespace OmniSharp.Services
Expand Down

This file was deleted.

This file was deleted.

Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
namespace OmniSharp.Services
namespace OmniSharp
{
public enum TransportType
{
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
using System;
using System.Reflection;

namespace OmniSharp.Services
namespace OmniSharp.Utilities
{
public static class ReflectionExtensions
{
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
using System.Threading;
using System.Threading.Tasks;

namespace OmniSharp.Extensions
namespace OmniSharp.Utilities
{
public static class TaskExtensions
{
Expand Down
4 changes: 2 additions & 2 deletions src/OmniSharp.DotNet/Cache/ProjectStatesCache.cs
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,9 @@
using Microsoft.Extensions.Logging;
using NuGet.Frameworks;
using OmniSharp.DotNet.Models;
using OmniSharp.Models;
using OmniSharp.Eventing;
using OmniSharp.Models.Events;
using OmniSharp.Models.ProjectInformation;
using OmniSharp.Services;

namespace OmniSharp.DotNet.Cache
{
Expand Down
9 changes: 5 additions & 4 deletions src/OmniSharp.DotNet/DotNetProjectSystem.cs
Original file line number Diff line number Diff line change
Expand Up @@ -14,10 +14,11 @@
using OmniSharp.DotNet.Extensions;
using OmniSharp.DotNet.Models;
using OmniSharp.DotNet.Tools;
using OmniSharp.Models;
using OmniSharp.Eventing;
using OmniSharp.FileWatching;
using OmniSharp.Models.Events;
using OmniSharp.Models.WorkspaceInformation;
using OmniSharp.Services;
using OmniSharp.Services.FileWatching;

namespace OmniSharp.DotNet
{
Expand All @@ -29,7 +30,7 @@ public class DotNetProjectSystem : IProjectSystem
private readonly IOmniSharpEnvironment _environment;
private readonly OmniSharpWorkspace _workspace;
private readonly DotNetCliService _dotNetCliService;
private readonly IMetadataFileReferenceCache _metadataFileReferenceCache;
private readonly MetadataFileReferenceCache _metadataFileReferenceCache;
private readonly IEventEmitter _eventEmitter;
private readonly IFileSystemWatcher _fileSystemWatcher;
private readonly ILogger _logger;
Expand All @@ -43,7 +44,7 @@ public DotNetProjectSystem(
IOmniSharpEnvironment environment,
OmniSharpWorkspace workspace,
DotNetCliService dotNetCliService,
IMetadataFileReferenceCache metadataFileReferenceCache,
MetadataFileReferenceCache metadataFileReferenceCache,
IEventEmitter eventEmitter,
IFileSystemWatcher fileSystemWatcher,
ILoggerFactory loggerFactory)
Expand Down
6 changes: 3 additions & 3 deletions src/OmniSharp.DotNetTest/Legacy/LegacyTestManager.cs
Original file line number Diff line number Diff line change
Expand Up @@ -9,9 +9,9 @@
using Microsoft.Extensions.Logging;
using Microsoft.VisualStudio.TestPlatform.CommunicationUtilities.ObjectModel;
using OmniSharp.DotNetTest.Models;
using OmniSharp.DotNetTest.Models.Events;
using OmniSharp.DotNetTest.TestFrameworks;
using OmniSharp.Models;
using OmniSharp.Models.Events;
using OmniSharp.Eventing;
using OmniSharp.Services;
using OmniSharp.Utilities;

Expand Down Expand Up @@ -84,7 +84,7 @@ public override RunTestResponse RunTest(string methodName, string testFrameworkN

testProcess.OutputDataReceived += (_, e) =>
{
EventEmitter.Emit(EventTypes.TestMessage,
EventEmitter.Emit(TestMessageEvent.Id,
new TestMessageEvent
{
MessageLevel = "info",
Expand Down
Loading

0 comments on commit 56dfe3a

Please sign in to comment.