Skip to content

Commit

Permalink
Accept R# suggestions
Browse files Browse the repository at this point in the history
  • Loading branch information
IvenBach committed Oct 26, 2018
1 parent 07b6d2e commit f5da764
Showing 1 changed file with 6 additions and 13 deletions.
19 changes: 6 additions & 13 deletions Rubberduck.Core/UI/CodeExplorer/Commands/ImportCommand.cs
Original file line number Diff line number Diff line change
Expand Up @@ -144,17 +144,10 @@ private string RewrittenModuleText((IParseTree parseTree, TokenStreamRewriter re
}
else
{
if (HasOptionExplicit(startRule.parseTree, out var optionExplicitStmt))
{
startRule.rewriter.InsertBefore(optionExplicitStmt.SourceInterval.a, FolderAnnotationWithFolderName(updatedFolderName) + Environment.NewLine);
}
else
{
//var lastNewline = moduleDeclarations.GetDescendents<VBAParser.EndOfLineContext>().Last();
//startRule.rewriter.InsertBefore(lastNewline.SourceInterval.a, FolderAnnotationWithFolderName(updatedFolderName) + Environment.NewLine);
startRule.rewriter.InsertBefore(moduleDeclarations.SourceInterval.a, FolderAnnotationWithFolderName(updatedFolderName) + Environment.NewLine);

}
var index = HasOptionExplicit(startRule.parseTree, out var optionExplicitStmt)
? optionExplicitStmt.SourceInterval.a
: moduleDeclarations.SourceInterval.a;
startRule.rewriter.InsertBefore(index, FolderAnnotationWithFolderName(updatedFolderName) + Environment.NewLine);
}
}
else
Expand Down Expand Up @@ -187,7 +180,7 @@ private bool HasFolderAnnotation(IParseTree parseTree, out VBAParser.AnnotationC
var startRuleContext = (ParserRuleContext)parseTree;
var folderDescendents = startRuleContext.GetDescendents<VBAParser.AnnotationContext>()
.Where(a => a.GetText().Contains(AnnotationType.Folder.ToString()));
if (folderDescendents.Count() > 0)
if (folderDescendents.Any())
{
folderAnnotation = folderDescendents.ElementAt(0);
return true;
Expand All @@ -201,7 +194,7 @@ private bool HasOptionExplicit(IParseTree parseTree, out VBAParser.OptionExplici
{
var startRuleContext = (ParserRuleContext)parseTree;
var optionExplicitDescendents = startRuleContext.GetDescendents<VBAParser.OptionExplicitStmtContext>();
if (optionExplicitDescendents.Count() > 0)
if (optionExplicitDescendents.Any())
{
optionExplicit = optionExplicitDescendents.ElementAt(0);
return true;
Expand Down

0 comments on commit f5da764

Please sign in to comment.