Skip to content

Commit

Permalink
Merge pull request #207 from micbou/drive-letter
Browse files Browse the repository at this point in the history
Remove LowerCaseDriveLetter function
  • Loading branch information
nosami committed Aug 29, 2015
2 parents 2ae4019 + 523a820 commit e190291
Show file tree
Hide file tree
Showing 9 changed files with 12 additions and 17 deletions.
4 changes: 2 additions & 2 deletions OmniSharp.Tests/FakeSolution.cs
Original file line number Diff line number Diff line change
Expand Up @@ -32,13 +32,13 @@ public CSharpFile GetFile(string filename)
{
return (from project in Projects
from file in project.Files
where file.FileName.LowerCaseDriveLetter() == filename
where file.FileName == filename
select file).FirstOrDefault();
}

public IProject ProjectContainingFile(string filename)
{
return Projects.FirstOrDefault(p => p.Files.Any(f => f.FileName.LowerCaseDriveLetter().Equals(filename.LowerCaseDriveLetter(), StringComparison.InvariantCultureIgnoreCase)));
return Projects.FirstOrDefault(p => p.Files.Any(f => f.FileName.Equals(filename, StringComparison.InvariantCultureIgnoreCase)));
}

public void Reload()
Expand Down
2 changes: 1 addition & 1 deletion OmniSharp.Tests/Solution/SolutionTest.cs
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ public void Should_put_unknown_file_into_orphan_project()
[Test]
public void Should_put_unknown_file_near_to_close_project_file()
{
_solution.ProjectContainingFile((Environment.CurrentDirectory + "/Solution/minimal/minimal/test.cs").LowerCaseDriveLetter())
_solution.ProjectContainingFile((Environment.CurrentDirectory + "/Solution/minimal/minimal/test.cs"))
.Title.ShouldEqual("minimal");
}

Expand Down
4 changes: 2 additions & 2 deletions OmniSharp/Common/Request.cs
Original file line number Diff line number Diff line change
Expand Up @@ -13,9 +13,9 @@ public string FileName
get { return _fileName; }
set
{
_fileName = value.ApplyPathReplacementsForServer().LowerCaseDriveLetter();
_fileName = value.ApplyPathReplacementsForServer();
}
}
}
}


6 changes: 3 additions & 3 deletions OmniSharp/FindUsages/FindUsagesHandler.cs
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ public QuickFixResponse FindUsages(FindUsagesRequest request)
{
var result = FindUsageNodes(request)
.Distinct(new NodeComparer())
.OrderBy(n => n.GetRegion().FileName.LowerCaseDriveLetter())
.OrderBy(n => n.GetRegion().FileName)
.ThenBy(n => n.StartLocation.Line)
.ThenBy(n => n.StartLocation.Column);

Expand All @@ -45,7 +45,7 @@ public QuickFixResponse FindUsages(FindUsagesRequest request)
var usages = result.Select(node => new QuickFix
{
FileName = node.GetRegion().FileName,
Text = node.Preview(_solution.GetFile(node.GetRegion().FileName.LowerCaseDriveLetter()), request.MaxWidth).Replace("'", "''"),
Text = node.Preview(_solution.GetFile(node.GetRegion().FileName), request.MaxWidth).Replace("'", "''"),
Line = node.StartLocation.Line,
Column = node.StartLocation.Column,
});
Expand Down Expand Up @@ -120,7 +120,7 @@ public IEnumerable<AstNode> FindUsageNodes(Request request)

Parallel.ForEach(interesting.Distinct(), file =>
{
string text = _solution.GetFile(file.FileName.LowerCaseDriveLetter()).Content.Text;
string text = _solution.GetFile(file.FileName).Content.Text;
SyntaxTree unit ;
if(project.CompilerSettings!=null){
unit = new CSharpParser(project.CompilerSettings).Parse(text, file.FileName);
Expand Down
2 changes: 1 addition & 1 deletion OmniSharp/GotoDefinition/GotoDefinitionHandler.cs
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ public GotoDefinitionResponse GetGotoDefinitionResponse(GotoDefinitionRequest re
if (resolveResult != null)
{
var region = resolveResult.GetDefinitionRegion();
response.FileName = region.FileName == null ? null : region.FileName.LowerCaseDriveLetter().ApplyPathReplacementsForClient();
response.FileName = region.FileName == null ? null : region.FileName.ApplyPathReplacementsForClient();
response.Line = region.BeginLine;
response.Column = region.BeginColumn;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ public AddReferenceResponse AddReference(IProject project, string reference)
projectXml.Element(MsBuildNameSpace + "Project").Add(projectItemGroup);
}

project.AddReference(reference.LowerCaseDriveLetter());
project.AddReference(reference);
project.Save(projectXml);

response.Message = string.Format("Reference to {0} added successfully", referenceName);
Expand Down
2 changes: 1 addition & 1 deletion OmniSharp/Rename/RenameHandler.cs
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ public RenameResponse Rename(RenameRequest req)
var modfiedFiles = new List<ModifiedFileResponse>();
response.Changes = modfiedFiles;

foreach (IGrouping<string, AstNode> groupedNodes in nodes.GroupBy(n => n.GetRegion().FileName.LowerCaseDriveLetter()))
foreach (IGrouping<string, AstNode> groupedNodes in nodes.GroupBy(n => n.GetRegion().FileName))
{
string fileName = groupedNodes.Key;
OmniSharpRefactoringContext context;
Expand Down
2 changes: 1 addition & 1 deletion OmniSharp/Solution/CSharpSolution.cs
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,7 @@ public void LoadSolution()
{
string typeGuid = match.Groups["TypeGuid"].Value;
string title = match.Groups["Title"].Value;
string location = Path.Combine(directory, match.Groups["Location"].Value).LowerCaseDriveLetter();
string location = Path.Combine(directory, match.Groups["Location"].Value);
string guid = match.Groups["Guid"].Value;

switch (typeGuid.ToUpperInvariant())
Expand Down
5 changes: 0 additions & 5 deletions OmniSharp/Solution/StringExtensions.cs
Original file line number Diff line number Diff line change
Expand Up @@ -18,11 +18,6 @@ public static string MultipleWhitespaceCharsToSingleSpace
return Regex.Replace(stringToTrim, @"\s+", " ");
}

public static string LowerCaseDriveLetter(this string path)
{
return path.Replace(@"C:\", @"c:\").Replace(@"D:\", @"d:\");
}

public static string ForceWindowsPathSeparator(this string path)
{
return path.Replace ('/', '\\');
Expand Down

0 comments on commit e190291

Please sign in to comment.