Skip to content

Commit

Permalink
Merge remote-tracking branch 'refs/remotes/origin/master' into stable
Browse files Browse the repository at this point in the history
  • Loading branch information
codecadwallader committed May 20, 2017
2 parents 85bc35c + c1d7d7a commit 7273b60
Show file tree
Hide file tree
Showing 14 changed files with 241 additions and 112 deletions.
18 changes: 15 additions & 3 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# Changelog

## vNext (10.4)
## vNext (10.5)

These changes have not been released to the Visual Studio marketplace, but (if checked) are available in preview within the [CI build](http://vsixgallery.com/extension/4c82e17d-927e-42d2-8460-b473ac7df316/).

Expand All @@ -12,17 +12,29 @@ These changes have not been released to the Visual Studio marketplace, but (if c

These are the changes to each version that has been released to the Visual Studio marketplace.

## 10.4

**2017-03-26**

- [x] Features
- [x] [#444](https://github.com/codecadwallader/codemaid/pull/444) - Cleaning: VB now supports many of the same cleanups as C# - thanks [thehutman](https://github.com/thehutman)!
- [x] [#449](https://github.com/codecadwallader/codemaid/pull/449) - Undo a previous pull request for hiding Spade during full screen mode (inconsistent with other extensions) - thanks [iouri-s](https://github.com/iouri-s)!

- [x] Fixes
- [x] [#333](https://github.com/codecadwallader/codemaid/issues/333) - Reorganizing: VB now moves attributes - thanks [thehutman](https://github.com/thehutman)!
- [x] [#440](https://github.com/codecadwallader/codemaid/issues/440) - Cleaning: Exclude *.min.css and *.min.js files by default

## 10.3

**2017-03-26**

- [x] Features
- [x] [#359](https://github.com/codecadwallader/codemaid/pull/359) - Reorganizing: Add option to sort private->public vs. public->private - thanks [ahalassy](https://github.com/ahalassy)!
- [x] [#394](https://github.com/codecadwallader/codemaid/pull/394) - Finding: Add ability to clear solution explorer search before finding - thanks [joeburdick](https://github.com/joeburdick)!
- [x] [#420](https://github.com/codecadwallader/codemaid/issues/420) - Upgraded projects to .NET 4.6.1 and misc. fixes for VS2017 build support
- [x] [#420](https://github.com/codecadwallader/codemaid/pull/420) - Upgraded projects to .NET 4.6.1 and misc. fixes for VS2017 build support

- [x] Fixes
- [x] [#419](https://github.com/codecadwallader/codemaid/issues/419) - Cleaning: Switched using statement cleanup command to workaround VS2017+ReSharper issue that prevented using statement cleanup from activating - thanks [jlbeard84](https://github.com/jlbeard84)!
- [x] [#419](https://github.com/codecadwallader/codemaid/pull/419) - Cleaning: Switched using statement cleanup command to workaround VS2017+ReSharper issue that prevented using statement cleanup from activating - thanks [jlbeard84](https://github.com/jlbeard84)!

## 10.2

Expand Down
42 changes: 1 addition & 41 deletions CodeMaid/CodeMaidPackage.cs
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ namespace SteveCadwallader.CodeMaid
[ProvideToolWindow(typeof(SpadeToolWindow), MultiInstances = false, Style = VsDockStyle.Tabbed, Orientation = ToolWindowOrientation.Left, Window = EnvDTE.Constants.vsWindowKindSolutionExplorer)]
[ProvideToolWindowVisibility(typeof(SpadeToolWindow), "{F1536EF8-92EC-443C-9ED7-FDADF150DA82}")]
[Guid(PackageGuids.GuidCodeMaidPackageString)] // Package unique GUID.
public sealed class CodeMaidPackage : Package, IVsInstalledProduct, IVsPackageDynamicToolOwner
public sealed class CodeMaidPackage : Package, IVsInstalledProduct
{
#region Fields

Expand Down Expand Up @@ -307,46 +307,6 @@ public string GetResourceString(string resourceName)

#endregion IVsInstalledProduct Members

#region IVsPackageDynamicToolOwner members

/// <summary>
/// Allows the package to control whether the tool window should be shown or hidden. This
/// method is called by the shell when the user switches to a different window view or
/// context, for example Design, Debugging, Full Screen, etc.
/// </summary>
/// <returns>
/// If the method succeeds, it returns <see
/// cref="F:Microsoft.VisualStudio.VSConstants.S_OK"/>. If it fails, it returns an error code.
/// </returns>
/// <param name="rguidPersistenceSlot">[in] The GUID of the window.</param>
/// <param name="pfShowTool">[out] true to show the window, otherwise false.</param>
public int QueryShowTool(ref Guid rguidPersistenceSlot, out int pfShowTool)
{
pfShowTool = 1;

if (rguidPersistenceSlot == PackageGuids.GuidCodeMaidToolWindowSpade)
{
var monitorSelection = GetService(typeof(IVsMonitorSelection)) as IVsMonitorSelection;
if (monitorSelection != null)
{
var guidCmdUI = VSConstants.UICONTEXT_FullScreenMode;
uint dwCmdUICookie;
monitorSelection.GetCmdUIContextCookie(ref guidCmdUI, out dwCmdUICookie);

int fActive;
monitorSelection.IsCmdUIContextActive(dwCmdUICookie, out fActive);
if (fActive == 1)
{
pfShowTool = 0;
}
}
}

return VSConstants.S_OK;
}

#endregion IVsPackageDynamicToolOwner members

#region Private Methods

/// <summary>
Expand Down
Binary file modified CodeMaid/Integration/Images/about.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified CodeMaid/Integration/Images/about.xcf
Binary file not shown.
104 changes: 103 additions & 1 deletion CodeMaid/Logic/Cleaning/CodeCleanupManager.cs
Original file line number Diff line number Diff line change
Expand Up @@ -191,6 +191,9 @@ private Action<Document> FindCodeCleanupMethod(Document document)
case CodeLanguage.CSharp:
return RunCodeCleanupCSharp;

case CodeLanguage.VisualBasic:
return RunCodeCleanupVB;

case CodeLanguage.CPlusPlus:
case CodeLanguage.CSS:
case CodeLanguage.JavaScript:
Expand All @@ -209,7 +212,6 @@ private Action<Document> FindCodeCleanupMethod(Document document)
return RunCodeCleanupMarkup;

case CodeLanguage.FSharp:
case CodeLanguage.VisualBasic:
case CodeLanguage.Unknown:
return RunCodeCleanupGeneric;

Expand Down Expand Up @@ -338,6 +340,106 @@ private void RunCodeCleanupCSharp(Document document)
_commentFormatLogic.FormatComments(textDocument);
}

/// <summary>
/// Attempts to run code cleanup on the specified VB.Net document.
/// </summary>
/// <param name="document">The document for cleanup.</param>
private void RunCodeCleanupVB(Document document)
{
var textDocument = document.GetTextDocument();

// Perform any actions that can modify the file code model first.
RunExternalFormatting(textDocument);
if (!document.IsExternal())
{
_usingStatementCleanupLogic.RemoveAndSortUsingStatements(textDocument);
}

// Interpret the document into a collection of elements.
var codeItems = _codeModelManager.RetrieveAllCodeItems(document);

var regions = codeItems.OfType<CodeItemRegion>().ToList();
var usingStatements = codeItems.OfType<CodeItemUsingStatement>().ToList();
var namespaces = codeItems.OfType<CodeItemNamespace>().ToList();
var classes = codeItems.OfType<CodeItemClass>().ToList();
var delegates = codeItems.OfType<CodeItemDelegate>().ToList();
var enumerations = codeItems.OfType<CodeItemEnum>().ToList();
var events = codeItems.OfType<CodeItemEvent>().ToList();
var fields = codeItems.OfType<CodeItemField>().ToList();
var interfaces = codeItems.OfType<CodeItemInterface>().ToList();
var methods = codeItems.OfType<CodeItemMethod>().ToList();
var properties = codeItems.OfType<CodeItemProperty>().ToList();
var structs = codeItems.OfType<CodeItemStruct>().ToList();

// Build up more complicated collections.
var usingStatementBlocks = CodeModelHelper.GetCodeItemBlocks(usingStatements).ToList();
var usingStatementsThatStartBlocks = (from IEnumerable<CodeItemUsingStatement> block in usingStatementBlocks select block.First()).ToList();
var usingStatementsThatEndBlocks = (from IEnumerable<CodeItemUsingStatement> block in usingStatementBlocks select block.Last()).ToList();

// Perform file header cleanup.
_fileHeaderLogic.UpdateFileHeader(textDocument);

// Perform removal cleanup.
_removeRegionLogic.RemoveRegionsPerSettings(regions);
_removeWhitespaceLogic.RemoveEOLWhitespace(textDocument);
_removeWhitespaceLogic.RemoveBlankLinesAtTop(textDocument);
_removeWhitespaceLogic.RemoveBlankLinesAtBottom(textDocument);
_removeWhitespaceLogic.RemoveEOFTrailingNewLine(textDocument);
_removeWhitespaceLogic.RemoveBlankLinesAfterAttributes(textDocument);
_removeWhitespaceLogic.RemoveBlankLinesBetweenChainedStatements(textDocument);
_removeWhitespaceLogic.RemoveMultipleConsecutiveBlankLines(textDocument);

// Perform insertion of blank line padding cleanup.
_insertBlankLinePaddingLogic.InsertPaddingBeforeRegionTags(regions);
_insertBlankLinePaddingLogic.InsertPaddingAfterRegionTags(regions);

_insertBlankLinePaddingLogic.InsertPaddingBeforeEndRegionTags(regions);
_insertBlankLinePaddingLogic.InsertPaddingAfterEndRegionTags(regions);

_insertBlankLinePaddingLogic.InsertPaddingBeforeCodeElements(usingStatementsThatStartBlocks);
_insertBlankLinePaddingLogic.InsertPaddingAfterCodeElements(usingStatementsThatEndBlocks);

_insertBlankLinePaddingLogic.InsertPaddingBeforeCodeElements(namespaces);
_insertBlankLinePaddingLogic.InsertPaddingAfterCodeElements(namespaces);

_insertBlankLinePaddingLogic.InsertPaddingBeforeCodeElements(classes);
_insertBlankLinePaddingLogic.InsertPaddingAfterCodeElements(classes);

_insertBlankLinePaddingLogic.InsertPaddingBeforeCodeElements(delegates);
_insertBlankLinePaddingLogic.InsertPaddingAfterCodeElements(delegates);

_insertBlankLinePaddingLogic.InsertPaddingBeforeCodeElements(enumerations);
_insertBlankLinePaddingLogic.InsertPaddingAfterCodeElements(enumerations);

_insertBlankLinePaddingLogic.InsertPaddingBeforeCodeElements(events);
_insertBlankLinePaddingLogic.InsertPaddingAfterCodeElements(events);

_insertBlankLinePaddingLogic.InsertPaddingBeforeCodeElements(fields);
_insertBlankLinePaddingLogic.InsertPaddingAfterCodeElements(fields);

_insertBlankLinePaddingLogic.InsertPaddingBeforeCodeElements(interfaces);
_insertBlankLinePaddingLogic.InsertPaddingAfterCodeElements(interfaces);

_insertBlankLinePaddingLogic.InsertPaddingBeforeCodeElements(methods);
_insertBlankLinePaddingLogic.InsertPaddingAfterCodeElements(methods);

_insertBlankLinePaddingLogic.InsertPaddingBeforeCodeElements(properties);
_insertBlankLinePaddingLogic.InsertPaddingBetweenMultiLinePropertyAccessors(properties);
_insertBlankLinePaddingLogic.InsertPaddingAfterCodeElements(properties);

_insertBlankLinePaddingLogic.InsertPaddingBeforeCodeElements(structs);
_insertBlankLinePaddingLogic.InsertPaddingAfterCodeElements(structs);

_insertBlankLinePaddingLogic.InsertPaddingBeforeCaseStatements(textDocument);
_insertBlankLinePaddingLogic.InsertPaddingBeforeSingleLineComments(textDocument);

// Perform insertion of whitespace cleanup.
_insertWhitespaceLogic.InsertEOFTrailingNewLine(textDocument);

// Perform comment cleaning.
_commentFormatLogic.FormatComments(textDocument);
}

/// <summary>
/// Attempts to run code cleanup on the specified C/C++ document.
/// </summary>
Expand Down
15 changes: 9 additions & 6 deletions CodeMaid/Model/CodeItems/BaseCodeItemElement.cs
Original file line number Diff line number Diff line change
Expand Up @@ -40,12 +40,12 @@ protected BaseCodeItemElement()
/// <summary>
/// Gets the start point adjusted for leading comments, may be null.
/// </summary>
public override EditPoint StartPoint => CodeElement != null ? GetStartPointAdjustedForComments(CodeElement.StartPoint) : null;
public override EditPoint StartPoint => CodeElement != null ? GetStartPointAdjustedForComments(CodeElement.GetStartPoint()) : null;

/// <summary>
/// Gets the end point, may be null.
/// </summary>
public override EditPoint EndPoint => CodeElement?.EndPoint.CreateEditPoint();
public override EditPoint EndPoint => CodeElement?.GetEndPoint().CreateEditPoint();

/// <summary>
/// Loads all lazy initialized values immediately.
Expand All @@ -66,10 +66,13 @@ public override void LoadLazyInitializedValues()
/// </summary>
public override void RefreshCachedPositionAndName()
{
StartLine = CodeElement.StartPoint.Line;
StartOffset = CodeElement.StartPoint.AbsoluteCharOffset;
EndLine = CodeElement.EndPoint.Line;
EndOffset = CodeElement.EndPoint.AbsoluteCharOffset;
var startPoint = CodeElement.GetStartPoint();
var endPoint = CodeElement.GetEndPoint();

StartLine = startPoint.Line;
StartOffset = startPoint.AbsoluteCharOffset;
EndLine = endPoint.Line;
EndOffset = endPoint.AbsoluteCharOffset;
Name = CodeElement.Name;
}

Expand Down
11 changes: 7 additions & 4 deletions CodeMaid/Model/CodeItems/CodeItemUsingStatement.cs
Original file line number Diff line number Diff line change
Expand Up @@ -36,10 +36,13 @@ public CodeItemUsingStatement()
/// </remarks>
public override void RefreshCachedPositionAndName()
{
StartLine = CodeElement.StartPoint.Line;
StartOffset = CodeElement.StartPoint.AbsoluteCharOffset;
EndLine = CodeElement.EndPoint.Line;
EndOffset = CodeElement.EndPoint.AbsoluteCharOffset;
var startPoint = CodeElement.GetStartPoint();
var endPoint = CodeElement.GetEndPoint();

StartLine = startPoint.Line;
StartOffset = startPoint.AbsoluteCharOffset;
EndLine = endPoint.Line;
EndOffset = endPoint.AbsoluteCharOffset;
}

#endregion BaseCodeItem Overrides
Expand Down
4 changes: 2 additions & 2 deletions CodeMaid/Properties/Settings.Designer.cs

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion CodeMaid/Properties/Settings.settings
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
<Value Profile="(Default)">True</Value>
</Setting>
<Setting Name="Cleaning_ExclusionExpression" Type="System.String" Scope="User">
<Value Profile="(Default)">\.Designer\.cs$||\.Designer\.vb$||\.resx$</Value>
<Value Profile="(Default)">\.Designer\.cs$||\.Designer\.vb$||\.resx$||\.min\.css$||\.min\.js$</Value>
</Setting>
<Setting Name="Cleaning_IncludeCPlusPlus" Type="System.Boolean" Scope="User">
<Value Profile="(Default)">True</Value>
Expand Down
Loading

0 comments on commit 7273b60

Please sign in to comment.