Skip to content

Commit

Permalink
Merge pull request #3 from matkoch/master
Browse files Browse the repository at this point in the history
Update to new ReSharper SDK 2017.1
  • Loading branch information
citizenmatt authored Apr 6, 2017
2 parents 061bbb1 + e1b6876 commit b6d5149
Show file tree
Hide file tree
Showing 9 changed files with 190 additions and 137 deletions.
4 changes: 4 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -5,3 +5,7 @@ install/*.nupkg
*.user
*.suo
.vs/

# ReSharper is a .NET coding add-in
_ReSharper*
_dotTrace*
7 changes: 5 additions & 2 deletions install/StyleCop.nuspec
Original file line number Diff line number Diff line change
Expand Up @@ -3,12 +3,15 @@
<metadata>
<id>StyleCop.StyleCop</id>
<title>StyleCop by JetBrains</title>
<version>2016.3.2</version>
<version>2017.1.0</version>
<authors>Matt Ellis, Andy Reeves</authors>
<owners>JetBrains, Matt Ellis</owners>
<summary>StyleCop analyzes C# source code to enforce a set of style and consistency rules. Maintained by JetBrains</summary>
<description>StyleCop analyzes C# source code to enforce a set of style and consistency rules. This plugin is compatible with StyleCop 4.7.54, and maintained by JetBrains.</description>
<releaseNotes>
&#8226; Updated to ReSharper 2017.1

From 2016.3.2:
&#8226; Fix some Cleanup rules that modify single line comments, should not apply to file headers (#1)
&#8226; Fix Cleanup bug that would insert blank line before comment if it was first line after a switch label (#1)
Thanks @SanjayGuntur for the PR!
Expand Down Expand Up @@ -60,7 +63,7 @@ From previous releases:
<licenseUrl>https://github.com/StyleCop/StyleCop/blob/master/License.html</licenseUrl>
<iconUrl>https://raw.githubusercontent.com/StyleCop/StyleCop/master/logo.png</iconUrl>
<dependencies>
<dependency id="Wave" version="[7.0]" />
<dependency id="Wave" version="[8.0]" />
</dependencies>
<tags>StyleCop analysis</tags>
</metadata>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ public override void ExecuteTransactionInner(ISolution solution, ITextControl te
ITreeNode element = Utils.GetElementAtCaret(solution, textControl);
IUsingDirective containingElement = element.GetContainingNode<IUsingDirective>(true);

Utils.FormatLines(solution, textControl.Document, line.Minus1(), line.Plus1());
Utils.FormatLines(element.Language, solution, textControl.Document, line.Minus1(), line.Plus1());

if (containingElement != null)
{
Expand Down
2 changes: 1 addition & 1 deletion src/StyleCop.ReSharper/CodeCleanup/Rules/LayoutRules.cs
Original file line number Diff line number Diff line change
Expand Up @@ -363,7 +363,7 @@ private static void CommentsMustBePreceededByBlankLine(ITreeNode node)
continue;
}

if (siblingMinus3 is ISwitchLabelStatement)
if (siblingMinus3 is ISwitchCaseLabel)
{
// if we're the start of a switch block then don't insert a new line.
continue;
Expand Down
21 changes: 9 additions & 12 deletions src/StyleCop.ReSharper/CodeCleanup/Rules/ReadabilityRules.cs
Original file line number Diff line number Diff line change
Expand Up @@ -211,7 +211,7 @@ public static void ReplaceEmptyStringsWithStringDotEmpty(ITreeNode node)
if (tokenNode.GetTokenType().IsStringLiteral)
{
IAttribute attribute = tokenNode.GetContainingNode<IAttribute>(true);
ISwitchLabelStatement switchLabelStatement = tokenNode.GetContainingNode<ISwitchLabelStatement>(true);
ISwitchCaseLabel switchLabelStatement = tokenNode.GetContainingNode<ISwitchCaseLabel>(true);
IConstantDeclaration constantDeclaration = tokenNode.GetContainingNode<IConstantDeclaration>(true);
IRegularParameterDeclaration parameterDeclaration = tokenNode.GetContainingNode<IRegularParameterDeclaration>(true);

Expand Down Expand Up @@ -465,20 +465,17 @@ private static void DeleteChildRange(ITokenNode first, ITokenNode last)
/// <summary>
/// Process for each variable declaration.
/// </summary>
/// <param name="foreachVariableDeclaration">
/// <param name="singleVariableDesignation">
/// The for each variable declaration.
/// </param>
private static void ProcessForeachVariableDeclaration(IForeachVariableDeclaration foreachVariableDeclaration)
private static void ProcessSingleVariableDesignation (ISingleVariableDesignation singleVariableDesignation)
{
ILocalVariable variable = foreachVariableDeclaration.DeclaredElement;
if (variable != null)
ILocalVariable variable = singleVariableDesignation.DeclaredElement;
if (!singleVariableDesignation.IsVar)
{
if (!foreachVariableDeclaration.IsVar)
using (WriteLockCookie.Create(true))
{
using (WriteLockCookie.Create(true))
{
foreachVariableDeclaration.SetType(variable.Type);
}
singleVariableDesignation.SetType(variable.Type);
}
}
}
Expand Down Expand Up @@ -653,9 +650,9 @@ private static void SwapVariableDeclarationToBuiltInType(IVariableDeclaration va
{
ProcessLocalVariableDeclaration((ILocalVariableDeclaration)variableDeclaration);
}
else if (variableDeclaration is IForeachVariableDeclaration)
else if (variableDeclaration is ISingleVariableDesignation)
{
ProcessForeachVariableDeclaration((IForeachVariableDeclaration)variableDeclaration);
ProcessSingleVariableDesignation((ISingleVariableDesignation) variableDeclaration);
}
else
{
Expand Down
7 changes: 4 additions & 3 deletions src/StyleCop.ReSharper/Core/Utils.cs
Original file line number Diff line number Diff line change
Expand Up @@ -519,6 +519,7 @@ public static void FormatLineForTextControl(ISolution solution, ITextControl tex
/// The line to end the formatting.
/// </param>
public static void FormatLines(
PsiLanguageType language,
ISolution solution,
IDocument document,
JetBrains.Util.dataStructures.TypedIntrinsics.Int32<DocLine> startLine,
Expand All @@ -539,9 +540,9 @@ public static void FormatLines(
int startOffset = document.GetLineStartOffset(startLine);
int endOffset = document.GetLineEndOffsetNoLineBreak(endLine);

ICSharpCodeFormatter codeFormatter = (ICSharpCodeFormatter)CSharpLanguage.Instance.LanguageService().CodeFormatter;
codeFormatter.Format(
solution,
CodeFormatterHelper.Format (
language,
solution,
new DocumentRange(document, new JetBrains.Util.TextRange(startOffset, endOffset)),
CodeFormatProfile.DEFAULT,
true,
Expand Down
Loading

0 comments on commit b6d5149

Please sign in to comment.