-
Notifications
You must be signed in to change notification settings - Fork 418
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #247 from OmniSharp/magicv2
created a v2 version of code actions
- Loading branch information
Showing
100 changed files
with
982 additions
and
113 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
using Microsoft.CodeAnalysis.CodeActions; | ||
|
||
namespace OmniSharp.Api.V2 | ||
{ | ||
public static class CodeActionExtensions | ||
{ | ||
public static string GetIdentifier(this CodeAction codeAction) | ||
{ | ||
return codeAction.EquivalenceKey ?? codeAction.Title; | ||
} | ||
} | ||
} |
330 changes: 330 additions & 0 deletions
330
src/OmniSharp/Api/v2/Refactoring/OmnisharpController.CodeActions.cs
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,24 +0,0 @@ | ||
using System.IO; | ||
|
||
namespace OmniSharp.Models | ||
{ | ||
public class Request | ||
{ | ||
private string _fileName; | ||
|
||
public int Line { get; set; } | ||
public int Column { get; set; } | ||
public string Buffer { get; set; } | ||
public string FileName | ||
{ | ||
get | ||
{ | ||
return _fileName?.Replace(Path.AltDirectorySeparatorChar, Path.DirectorySeparatorChar); | ||
} | ||
set | ||
{ | ||
_fileName = value; | ||
} | ||
} | ||
} | ||
} | ||
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -27,4 +27,4 @@ public DnxProject(Project project) | |
SourceFiles = project.SourceFiles; | ||
} | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -23,4 +23,4 @@ public DnxWorkspaceInformation(DnxContext context) | |
public int DesignTimeHostPort { get; } | ||
} | ||
|
||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -10,4 +10,4 @@ public class ChangeBufferRequest | |
public int EndColumn { get; set; } | ||
public string NewText { get; set; } | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -6,4 +6,4 @@ public class CodeFormatResponse | |
{ | ||
public string Buffer { get; set; } | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -4,4 +4,4 @@ public class DiagnosticLocation : QuickFix | |
{ | ||
public string LogLevel { get; set; } | ||
} | ||
} | ||
} |
File renamed without changes.
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -75,4 +75,4 @@ public override int GetHashCode() | |
31 * Location.EndColumn; | ||
} | ||
} | ||
} | ||
} |
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -4,4 +4,4 @@ public class FindSymbolsRequest | |
{ | ||
public string Filter { get; set; } | ||
} | ||
} | ||
} |
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
File renamed without changes.
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -6,4 +6,4 @@ public class GetCodeActionsResponse | |
{ | ||
public IEnumerable<string> CodeActions { get; set; } | ||
} | ||
} | ||
} |
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
using System.IO; | ||
|
||
namespace OmniSharp.Models | ||
{ | ||
public class Request | ||
{ | ||
private string _fileName; | ||
|
||
public int Line { get; set; } | ||
public int Column { get; set; } | ||
public string Buffer { get; set; } | ||
public string FileName | ||
{ | ||
get | ||
{ | ||
return _fileName?.Replace(Path.AltDirectorySeparatorChar, Path.DirectorySeparatorChar); | ||
} | ||
set | ||
{ | ||
_fileName = value; | ||
} | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
namespace OmniSharp.Models.V2 | ||
{ | ||
public class OmniSharpCodeAction | ||
{ | ||
public OmniSharpCodeAction(string identifier, string name) | ||
{ | ||
Identifier = identifier; | ||
Name = name; | ||
} | ||
|
||
public string Identifier { get; } | ||
public string Name { get; } | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
namespace OmniSharp.Models.V2 | ||
{ | ||
public class GetCodeActionsRequest : Request, ICodeActionRequest | ||
{ | ||
public Range Selection { get; set; } | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
using System.Collections.Generic; | ||
|
||
namespace OmniSharp.Models.V2 | ||
{ | ||
public class GetCodeActionsResponse | ||
{ | ||
public IEnumerable<OmniSharpCodeAction> CodeActions { get; set; } | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
namespace OmniSharp.Models.V2 | ||
{ | ||
public interface ICodeActionRequest | ||
{ | ||
int Line { get; } | ||
int Column { get; } | ||
string Buffer { get; } | ||
string FileName { get; } | ||
Range Selection { get; } | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
namespace OmniSharp.Models.V2 | ||
{ | ||
public class Point | ||
{ | ||
public int Line { get; set; } | ||
public int Column { get; set; } | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
namespace OmniSharp.Models.V2 | ||
{ | ||
public class Range | ||
{ | ||
public Point Start { get; set; } | ||
public Point End { get; set; } | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
namespace OmniSharp.Models.V2 | ||
{ | ||
public class RunCodeActionRequest : Request, ICodeActionRequest | ||
{ | ||
public string Identifier { get; set; } | ||
public Range Selection { get; set; } | ||
public bool WantsTextChanges { get; set; } | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
using System.Collections.Generic; | ||
|
||
namespace OmniSharp.Models.V2 | ||
{ | ||
public class RunCodeActionResponse | ||
{ | ||
public IEnumerable<ModifiedFileResponse> Changes { get; set; } | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,43 @@ | ||
#if DNX451 | ||
using System; | ||
using System.Collections.Generic; | ||
using System.Collections.Immutable; | ||
using System.Linq; | ||
using System.Reflection; | ||
using Microsoft.CodeAnalysis.CodeFixes; | ||
using Microsoft.CodeAnalysis.CodeRefactorings; | ||
|
||
namespace OmniSharp.Services | ||
{ | ||
public abstract class AbstractCodeActionProvider : ICodeActionProvider | ||
{ | ||
private readonly IEnumerable<CodeRefactoringProvider> _refactorings; | ||
private readonly IEnumerable<CodeFixProvider> _codeFixes; | ||
|
||
protected AbstractCodeActionProvider(string assemblyName) : this(Assembly.Load(assemblyName)) | ||
{ | ||
} | ||
|
||
protected AbstractCodeActionProvider(Assembly codeActionAssembly) | ||
{ | ||
var features = codeActionAssembly | ||
.GetTypes() | ||
.Where(type => !type.IsInterface | ||
&& !type.IsAbstract | ||
&& !type.ContainsGenericParameters); // TODO: handle providers with generic params | ||
|
||
_refactorings = features.Where(t => typeof(CodeRefactoringProvider).IsAssignableFrom(t)) | ||
.Select(type => (CodeRefactoringProvider)Activator.CreateInstance(type)); | ||
|
||
_codeFixes = features.Where(t => typeof(CodeFixProvider).IsAssignableFrom(t)) | ||
.Select(type => (CodeFixProvider)Activator.CreateInstance(type)); | ||
} | ||
|
||
public virtual IEnumerable<CodeRefactoringProvider> Refactorings => _refactorings; | ||
|
||
public virtual IEnumerable<CodeFixProvider> CodeFixes => _codeFixes; | ||
|
||
public abstract string ProviderName { get; } | ||
} | ||
} | ||
#endif |
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,10 +1,12 @@ | ||
using System.Collections.Generic; | ||
using Microsoft.CodeAnalysis.CodeFixes; | ||
using Microsoft.CodeAnalysis.CodeRefactorings; | ||
|
||
namespace OmniSharp.Services | ||
{ | ||
public interface ICodeActionProvider | ||
{ | ||
IEnumerable<CodeRefactoringProvider> GetProviders(); | ||
IEnumerable<CodeRefactoringProvider> Refactorings { get; } | ||
IEnumerable<CodeFixProvider> CodeFixes { get; } | ||
} | ||
} | ||
} |
Oops, something went wrong.