Skip to content

Commit

Permalink
Inline out variable declaration
Browse files Browse the repository at this point in the history
  • Loading branch information
laurentkempe committed Aug 25, 2018
1 parent 94ecf03 commit ec22983
Show file tree
Hide file tree
Showing 5 changed files with 15 additions and 27 deletions.
3 changes: 1 addition & 2 deletions GitDiffMargin/Core/DiffUpdateBackgroundParser.cs
Original file line number Diff line number Diff line change
Expand Up @@ -91,8 +91,7 @@ protected override void ReParseImpl()
var stopwatch = Stopwatch.StartNew();

var snapshot = TextBuffer.CurrentSnapshot;
ITextDocument textDocument;
if (!TextDocumentFactoryService.TryGetTextDocument(_documentBuffer, out textDocument)) return;
if (!TextDocumentFactoryService.TryGetTextDocument(_documentBuffer, out var textDocument)) return;

var diff = _commands.GetGitDiffFor(textDocument, _originalPath, snapshot);
var result = new DiffParseResultEventArgs(snapshot, stopwatch.Elapsed, diff.ToList());
Expand Down
4 changes: 2 additions & 2 deletions GitDiffMargin/Core/MarginCore.cs
Original file line number Diff line number Diff line change
Expand Up @@ -226,8 +226,8 @@ public bool RollBack(HunkRangeInfo hunkRangeInfo)

public ITextDocument GetTextDocument()
{
ITextDocument document;
TextView.TextDataModel.DocumentBuffer.Properties.TryGetProperty(typeof(ITextDocument), out document);
TextView.TextDataModel.DocumentBuffer.Properties.TryGetProperty(typeof(ITextDocument),
out ITextDocument document);
return document;
}

Expand Down
6 changes: 2 additions & 4 deletions GitDiffMargin/DiffMarginFactoryBase.cs
Original file line number Diff line number Diff line change
Expand Up @@ -25,8 +25,7 @@ public abstract IWpfTextViewMargin CreateMargin(IWpfTextViewHost wpfTextViewHost

protected IMarginCore TryGetMarginCore(IWpfTextViewHost textViewHost)
{
MarginCore marginCore;
if (textViewHost.TextView.Properties.TryGetProperty(typeof(MarginCore), out marginCore))
if (textViewHost.TextView.Properties.TryGetProperty(typeof(MarginCore), out MarginCore marginCore))
return marginCore;

// play nice with other source control providers
Expand All @@ -36,8 +35,7 @@ protected IMarginCore TryGetMarginCore(IWpfTextViewHost textViewHost)
if (documentBuffer == null)
return null;

ITextDocument textDocument;
if (!TextDocumentFactoryService.TryGetTextDocument(documentBuffer, out textDocument))
if (!TextDocumentFactoryService.TryGetTextDocument(documentBuffer, out var textDocument))
return null;

var fullPath = GetFullPath(textDocument.FilePath);
Expand Down
15 changes: 5 additions & 10 deletions GitDiffMargin/GitDiffMarginCommandHandler.cs
Original file line number Diff line number Diff line change
Expand Up @@ -34,8 +34,7 @@ protected override OLECMDF QueryCommandStatus(ref Guid commandGroup, uint comman
{
case GitDiffMarginCommand.ShowPopup:
{
EditorDiffMarginViewModel viewModel;
if (!TryGetMarginViewModel(out viewModel))
if (!TryGetMarginViewModel(out var viewModel))
return 0;

var diffViewModel = GetCurrentDiffViewModel(viewModel);
Expand All @@ -47,8 +46,7 @@ protected override OLECMDF QueryCommandStatus(ref Guid commandGroup, uint comman
case GitDiffMarginCommand.PreviousChange:
case GitDiffMarginCommand.NextChange:
{
EditorDiffMarginViewModel viewModel;
if (!TryGetMarginViewModel(out viewModel))
if (!TryGetMarginViewModel(out var viewModel))
return 0;

// First look for a diff already showing a popup
Expand All @@ -74,8 +72,7 @@ protected override OLECMDF QueryCommandStatus(ref Guid commandGroup, uint comman
case GitDiffMarginCommand.RollbackChange:
case GitDiffMarginCommand.CopyOldText:
{
EditorDiffMarginViewModel viewModel;
if (!TryGetMarginViewModel(out viewModel))
if (!TryGetMarginViewModel(out var viewModel))
return 0;

var diffViewModel = viewModel.DiffViewModels.OfType<EditorDiffViewModel>()
Expand All @@ -95,8 +92,7 @@ protected override OLECMDF QueryCommandStatus(ref Guid commandGroup, uint comman

case GitDiffMarginCommand.ShowDiff:
{
EditorDiffMarginViewModel viewModel;
if (!TryGetMarginViewModel(out viewModel))
if (!TryGetMarginViewModel(out var viewModel))
return 0;

if (viewModel.DiffViewModels.Any())
Expand All @@ -118,9 +114,8 @@ protected override bool HandlePreExec(ref Guid commandGroup, uint commandId, OLE
{
if (commandGroup == typeof(GitDiffMarginCommand).GUID)
{
EditorDiffMarginViewModel viewModel = null;
EditorDiffViewModel diffViewModel = null;
if (TryGetMarginViewModel(out viewModel))
if (TryGetMarginViewModel(out var viewModel))
diffViewModel = viewModel.DiffViewModels.OfType<EditorDiffViewModel>()
.FirstOrDefault(i => i.ShowPopup);

Expand Down
14 changes: 5 additions & 9 deletions GitDiffMargin/ViewModel/EditorDiffViewModel.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#region using
#region using

using System;
using System.Linq;
Expand Down Expand Up @@ -86,16 +86,13 @@ public object ToolBarTray
if (_toolbarTrayHost == null)
return null;

IVsUIElement toolbarTray;
ErrorHandler.ThrowOnFailure(_toolbarTrayHost.GetToolbarTray(out toolbarTray));
ErrorHandler.ThrowOnFailure(_toolbarTrayHost.GetToolbarTray(out var toolbarTray));

object uiObject;
ErrorHandler.ThrowOnFailure(toolbarTray.GetUIObject(out uiObject));
ErrorHandler.ThrowOnFailure(toolbarTray.GetUIObject(out var uiObject));

var wpfElement = uiObject as IVsUIWpfElement;

object frameworkElement;
ErrorHandler.ThrowOnFailure(wpfElement.GetFrameworkElement(out frameworkElement));
ErrorHandler.ThrowOnFailure(wpfElement.GetFrameworkElement(out var frameworkElement));

return frameworkElement;
}
Expand All @@ -117,8 +114,7 @@ public bool ShowPopup
MarginCore.TextView.Properties.GetProperty<GitDiffMarginCommandHandler>(
typeof(GitDiffMarginCommandHandler));

IVsToolbarTrayHost toolbarTrayHost;
ErrorHandler.ThrowOnFailure(uiShell.CreateToolbarTray(commandTarget, out toolbarTrayHost));
ErrorHandler.ThrowOnFailure(uiShell.CreateToolbarTray(commandTarget, out var toolbarTrayHost));

var toolBarGuid = typeof(GitDiffMarginCommand).GUID;
ErrorHandler.ThrowOnFailure(toolbarTrayHost.AddToolbar(ref toolBarGuid,
Expand Down

0 comments on commit ec22983

Please sign in to comment.