Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

v2.5.9.1 #6175

Merged
merged 38 commits into from
Nov 27, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
38 commits
Select commit Hold shift + click to select a range
b5c1684
revert a942e43c
retailcoder Sep 4, 2023
23fe626
revert 64992714
retailcoder Sep 4, 2023
7681fee
revert e3d7de9b
retailcoder Sep 4, 2023
f13297c
revert c3841931
retailcoder Sep 4, 2023
5f4496e
revert 42a47874
retailcoder Sep 4, 2023
2d68e69
revert 9494f3d9
retailcoder Sep 4, 2023
f1f0b5e
Revert "Continue With #5451"
retailcoder Sep 4, 2023
7a5f201
revert 383fe173
retailcoder Sep 4, 2023
c6ad408
revert 127f5843
retailcoder Sep 4, 2023
3143d25
revert efbe192e
retailcoder Sep 4, 2023
c0bf3ed
revert 0fb4ee1f
retailcoder Sep 4, 2023
83cdf61
Revert "#5451 AddRemoveReferences Form Convert"
retailcoder Sep 4, 2023
65ea041
Revert "Revert "#5451 AddRemoveReferences Form conversion to Dynamic""
retailcoder Sep 4, 2023
5ee8893
Revert "#5451 AddRemoveReferences Form conversion to Dynamic"
retailcoder Sep 4, 2023
dd25d54
revert 49d8d42f
retailcoder Sep 4, 2023
75c979d
fix markup
retailcoder Sep 4, 2023
bfadccb
Merge pull request #6149 from retailcoder/revert-dynamic-resources
retailcoder Sep 4, 2023
5a02aa5
Update appveyor.yml
retailcoder Sep 5, 2023
b51003c
refactor, write red test
retailcoder Sep 21, 2023
fd41eed
fix bug, green test
retailcoder Sep 21, 2023
babcc12
remove superfluous try/catch
retailcoder Sep 21, 2023
320ddf9
rename
retailcoder Sep 22, 2023
4038174
fix fallback/default base url
retailcoder Sep 22, 2023
4d4853b
Merge pull request #6158 from retailcoder/FixVersionCheckCrash
retailcoder Sep 25, 2023
f4d1750
Make parser understand multiple line continuations inside lExpressions
MDoerner Oct 21, 2023
877d0f6
Merge pull request #6168 from MDoerner/LineContinuationParserFix
retailcoder Oct 21, 2023
eb75069
Make the parser understand completely empty single line if statements
MDoerner Oct 21, 2023
7ec28f3
Try to avoid RCW exception at shutdown
MDoerner Oct 21, 2023
6cf1536
Replace Exit Sub when converting Subs to Functions
MDoerner Oct 23, 2023
3dd7ee4
Merge pull request #6171 from MDoerner/FixSubToFunctionQuickFixForExi…
retailcoder Oct 24, 2023
415ae07
Merge pull request #6169 from MDoerner/OneLineIfStatementParserFix
retailcoder Oct 24, 2023
c8057ec
Merge pull request #6170 from MDoerner/TryToAvoidExceptionAtTeardown
retailcoder Oct 24, 2023
32da47c
Update RubberduckBaseProject.csproj
retailcoder Nov 5, 2023
f3254a0
Fix unsafe conversion from Char to int
MDoerner Nov 8, 2023
9323f70
Merge pull request #6178 from MDoerner/FixCharToIntConversion
retailcoder Nov 9, 2023
ce21fbf
Fix selection end column if pruning an empty last column
tommy9 Nov 25, 2023
fee096f
Merge pull request #6184 from tommy9/Issue6181
retailcoder Nov 26, 2023
22b5a72
Merge branch 'main' into next
retailcoder Nov 26, 2023
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -59,23 +59,31 @@ public override void Fix(IInspectionResult result, IRewriteSession rewriteSessio
var arg = parameterizedDeclaration.Parameters.First(p => p.IsByRef || p.IsImplicitByRef);
var argIndex = parameterizedDeclaration.Parameters.IndexOf(arg);

UpdateSignature(result.Target, arg, rewriteSession);
UpdateProcedure(result.Target, arg, rewriteSession);
foreach (var reference in result.Target.References.Where(reference => !reference.IsDefaultMemberAccess))
{
UpdateCall(reference, argIndex, rewriteSession);
}
}

private void UpdateSignature(Declaration target, ParameterDeclaration arg, IRewriteSession rewriteSession)
private void UpdateProcedure(Declaration target, ParameterDeclaration arg, IRewriteSession rewriteSession)
{
var subStmt = (VBAParser.SubStmtContext) target.Context;
var argContext = (VBAParser.ArgContext)arg.Context;

var argName = argContext.unrestrictedIdentifier().GetText();
var rewriter = rewriteSession.CheckOutModuleRewriter(target.QualifiedModuleName);

UpdateSignature(subStmt, arg, rewriter);
AddReturnStatement(subStmt, argName, rewriter);
ReplaceExitSubs(subStmt, argName, rewriter);
}

private void UpdateSignature(VBAParser.SubStmtContext subStmt, ParameterDeclaration arg, IModuleRewriter rewriter)
{
rewriter.Replace(subStmt.SUB(), Tokens.Function);
rewriter.Replace(subStmt.END_SUB(), "End Function");

var argContext = (VBAParser.ArgContext)arg.Context;
rewriter.InsertAfter(subStmt.argList().Stop.TokenIndex, $" As {arg.AsTypeName}");

if (arg.IsByRef)
Expand All @@ -86,11 +94,26 @@ private void UpdateSignature(Declaration target, ParameterDeclaration arg, IRewr
{
rewriter.InsertBefore(argContext.unrestrictedIdentifier().Start.TokenIndex, Tokens.ByVal);
}
}

var returnStmt = $" {subStmt.subroutineName().GetText()} = {argContext.unrestrictedIdentifier().GetText()}{Environment.NewLine}";
private void AddReturnStatement(VBAParser.SubStmtContext subStmt, string argName, IModuleRewriter rewriter)
{
var returnStmt = $" {subStmt.subroutineName().GetText()} = {argName}{Environment.NewLine}";
// This exploits that the VBE will realign the End Function statement automatically.
rewriter.InsertBefore(subStmt.END_SUB().Symbol.TokenIndex, returnStmt);
}

private void ReplaceExitSubs(VBAParser.SubStmtContext subStmt, string argName, IModuleRewriter rewriter)
{
// We use a statement separator here to be able to deal with single line if statments without too much issues.
var exitFunctionCode = $"{subStmt.subroutineName().GetText()} = {argName}: Exit Function";
foreach (var exitSub in subStmt.GetDescendents<VBAParser.ExitStmtContext>())
{
rewriter.Replace(exitSub, exitFunctionCode);
}
}


private void UpdateCall(IdentifierReference reference, int argIndex, IRewriteSession rewriteSession)
{
var rewriter = rewriteSession.CheckOutModuleRewriter(reference.QualifiedModuleName);
Expand Down
2 changes: 1 addition & 1 deletion Rubberduck.Core/Properties/Settings.Designer.cs

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

13 changes: 13 additions & 0 deletions Rubberduck.Core/Rubberduck.Core.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -93,4 +93,17 @@
<Version>2.0.20525</Version>
</PackageReference>
</ItemGroup>
<ItemGroup>
<Compile Update="Properties\Settings.Designer.cs">
<DesignTimeSharedInput>True</DesignTimeSharedInput>
<AutoGen>True</AutoGen>
<DependentUpon>Settings.settings</DependentUpon>
</Compile>
</ItemGroup>
<ItemGroup>
<None Update="Properties\Settings.settings">
<Generator>SettingsSingleFileGenerator</Generator>
<LastGenOutput>Settings.Designer.cs</LastGenOutput>
</None>
</ItemGroup>
</Project>
5 changes: 4 additions & 1 deletion Rubberduck.Core/Settings/GeneralSettings.cs
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ public interface IGeneralSettings
DisplayLanguageSetting Language { get; set; }
bool CanShowSplash { get; set; }
bool CanCheckVersion { get; set; }
string ApiBaseUrl { get; set; }
bool IncludePreRelease { get; set; }
bool CompileBeforeParse { get; set; }
bool IsSmartIndenterPrompted { get; set; }
Expand Down Expand Up @@ -45,6 +46,7 @@ public DisplayLanguageSetting Language

public bool CanShowSplash { get; set; }
public bool CanCheckVersion { get; set; }
public string ApiBaseUrl { get; set; }
public bool IncludePreRelease { get; set; }
public bool CompileBeforeParse { get; set; }
public bool IsSmartIndenterPrompted { get; set; }
Expand Down Expand Up @@ -103,7 +105,8 @@ public bool Equals(GeneralSettings other)
EnableExperimentalFeatures.Count == other.EnableExperimentalFeatures.Count &&
EnableExperimentalFeatures.All(other.EnableExperimentalFeatures.Contains) &&
SetDpiUnaware == other.SetDpiUnaware &&
EnableFolderDragAndDrop == other.EnableFolderDragAndDrop;
EnableFolderDragAndDrop == other.EnableFolderDragAndDrop &&
ApiBaseUrl == other.ApiBaseUrl;
}
}
}
Loading