You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
In the following code, I've attempted both a Refactor|Move closer to usage and a Refactor|Rename on the variable curLen, and I get what appears to be the same error presented in two different ways.
This issue has survived two restarts of Excel and seems very specific to this bit of code. I've been doing clean up for the last several days and have used both Move closer to usage and Rename dozens, if not hundreds of times without any issues all all.
Look for the big comment block about 2/3 of the way down this (very long) Sub (that is in desperate need of several applications of a functioning Refactor|Extract Method):
PrivateSub GenerateGraph(ByRef clinicList AsProcessClinic, ByRef report AsWorksheet, ByVal DataRange AsRange, ByVal projSettings AsProjectSettings)
Const clinicCol AsLong = 1Const NPSCol AsLong = 2Const GoalCol AsLong = 3Const SATCol AsLong = 4Const SatSurveyGoalCol AsLong = 5Dim theChart AsChartObjectSet theChart = report.ChartObjects.Add(20, 20, 1000, 500)
Dim ser AsSeriesWith theChart
Set ser = .Chart.SeriesCollection.NewSeries
With ser
'@Ignore ObjectVariableNotSet
.Values = "='" & DataRange.Parent.Name & "'!" & DataRange.Columns(NPSCol).Address(external:=False)
.AxisGroup = xlPrimary
.ChartType = xlColumnClustered
.XValues = "'" & DataRange.Parent.Name & "'!" & DataRange.Columns(clinicCol).Address(external:=False)
.ApplyDataLabels
.DataLabels.Format.TextFrame2.TextRange.Font.Bold = msoTrue
End With
FormatNPSBars ser, projSettings
Set ser = .Chart.SeriesCollection.NewSeries
With ser
'@Ignore ObjectVariableNotSet
.Values = "='" & DataRange.Parent.Name & "'!" & DataRange.Columns(GoalCol).Address(external:=False)
.ChartType = xlLine
With .Format.Line
.ForeColor.ObjectThemeColor = msoThemeColorAccent1
.ForeColor.TintAndShade = 0
.ForeColor.Brightness = -0.25
.Transparency = 0.6End With
.Name = "NPS Goal"Dim NPSGoalLabelLocation AsLongIf .Points.count > 1Then'just in case we ever run for only 1 clinic
NPSGoalLabelLocation = .Points.count - 1Else
NPSGoalLabelLocation = .Points.count
End IfWith .Points(NPSGoalLabelLocation)
.HasDataLabel = True
.DataLabel.text = "NPS Goal"
.DataLabel.Position = xlLabelPositionAbove
.DataLabel.HorizontalAlignment = xlLeft
End WithEnd WithIfNot clinicList.GenerateEOHS ThenSet ser = .Chart.SeriesCollection.NewSeries
With ser
.AxisGroup = xlSecondary
'@Ignore ObjectVariableNotSet
.Values = "='" & DataRange.Parent.Name & "'!" & DataRange.Columns(SATCol).Address(external:=False)
.ChartType = xlLine
.ApplyDataLabels
.DataLabels.Position = xlLabelPositionBelow
With .Format.Line
.ForeColor.ObjectThemeColor = msoThemeColorText1
.ForeColor.TintAndShade = 0
.ForeColor.Brightness = 0
.Transparency = 0End With
.Name = "Patient Satisfaction"End WithSet ser = .Chart.SeriesCollection.NewSeries
With ser
.AxisGroup = xlSecondary
'@Ignore ObjectVariableNotSet
.Values = "='" & DataRange.Parent.Name & "'!" & DataRange.Columns(SatSurveyGoalCol).Address(external:=False)
.ChartType = xlLine
With .Format.Line
.ForeColor.ObjectThemeColor = msoThemeColorBackground1
.ForeColor.TintAndShade = 0
.ForeColor.Brightness = -0.349999994
.Transparency = 0End With
.Name = "Satisfaction Goal"If .Points.count > 1Then'just in case we ever run for only 1 clinic
NPSGoalLabelLocation = .Points.count - 1Else
NPSGoalLabelLocation = .Points.count
End IfWith .Points(NPSGoalLabelLocation)
.HasDataLabel = True
.DataLabel.text = "Satisfaction Goal"
.DataLabel.Position = xlLabelPositionAbove
.DataLabel.HorizontalAlignment = xlLeft
End WithEnd WithEnd If
.Chart.Legend.Position = xlLegendPositionBottom
.Chart.Legend.LegendEntries(1).Delete 'hate the hard code, but this is series 1, the NPS scores themselves, being removed from the legend
.Chart.Axes(xlValue).MaximumScale = 100
.Chart.Axes(xlCategory).TickLabels.Font.Size = 9
.Chart.Axes(xlValue).MajorGridlines.Delete
.Placement = xlFreeFloating 'prevents the chart from moving/stretching when columns are resized
.Chart.HasTitle = TrueConst MAIN_TITLE_TEXT AsString = "Business Solutions NPS"Const NPS_TITLE_TEXT AsString = "NPS"Const DATA_RANGE_TEXT AsString = " - Data Collection Range: "Const PATIENT_SATISFACTION_TITLE_TEXT AsString = "Patient Satisfaction"'vvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvv'vvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvv'error happens when working with this declarationDim curLen AsLong'^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^'^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^With .Chart.chartTitle
.text = MAIN_TITLE_TEXT & Chr$(10) & _
NPS_TITLE_TEXT & DATA_RANGE_TEXT & Format$(clinicList.YtdStartDate, "mmmm d - ") & Format$(clinicList.YtdEndDate, "mmmm d, yyyy") & Chr$(10) & _
PATIENT_SATISFACTION_TITLE_TEXT & DATA_RANGE_TEXT & Format$(clinicList.YtdStartDate, "mmmm d - ") & Format$(clinicList.YtdEndDate, "mmmm d, yyyy")
With .Format.TextFrame2.TextRange.Characters(1, Len(MAIN_TITLE_TEXT)).Font
.Bold = msoTrue
.Size = 14End With
curLen = InStr(1, .text, Chr$(10))
With .Format.TextFrame2.TextRange.Characters(curLen, Len(.text) - curLen + 1).Font
.Bold = msoFalse
.Italic = msoTrue
.Size = 10.5End WithWith .Format.TextFrame2.TextRange.Characters(curLen, Len(NPS_TITLE_TEXT) + 1).Font
.Fill.ForeColor.ObjectThemeColor = msoThemeColorText2
.Fill.ForeColor.Brightness = -0.25
.Bold = msoTrue
End With
curLen = InStr(curLen + 1, .text, Chr$(10))
With .Format.TextFrame2.TextRange.Characters(curLen, Len(PATIENT_SATISFACTION_TITLE_TEXT) + 1).Font
.Fill.ForeColor.ObjectThemeColor = msoThemeColorAccent6
.Fill.ForeColor.Brightness = -0.5
.Bold = msoTrue
End WithEnd WithEnd With
CreateLabelDef Green, theChart, projSettings
CreateLabelDef Yellow, theChart, projSettings
CreateLabelDef Red, theChart, projSettings
End Sub
When attempting to Move closer to usage, I get the following lines in the error log:
2018-09-06 07:58:50.6977;DEBUG-2.2.0.3751;Rubberduck.UI.Command.MenuItems.ParentMenus.ParentMenuItemBase;(59242391) Executing click handler for menu item 'Move Closer To &Usage', hash code 25427556;
2018-09-06 07:58:50.7446;ERROR-2.2.0.3751;Rubberduck.UI.Command.Refactorings.RefactorMoveCloserToUsageCommand;System.ArgumentException: replace op boundaries of <ReplaceOp@[@2860,7464:7464='.',<41>,184:11]..[@2869,7504:7509='curLen',<237>,184:51]:"curLen"> overlap with previous <ReplaceOp@[@2860,7464:7464='.',<41>,184:11]..[@2880,7525:7530='curLen',<237>,184:72]:"curLen">
at Antlr4.Runtime.TokenStreamRewriter.ReduceToSingleOperationPerIndex(IList`1 rewrites)
at Antlr4.Runtime.TokenStreamRewriter.GetText(String programName, Interval interval)
at Rubberduck.Parsing.Rewriter.ModuleRewriter.get_IsDirty() in C:\projects\rubberduck\Rubberduck.Parsing\Rewriter\ModuleRewriter.cs:line 27
at Rubberduck.Parsing.Rewriter.ModuleRewriter.Rewrite() in C:\projects\rubberduck\Rubberduck.Parsing\Rewriter\ModuleRewriter.cs:line 31
at Rubberduck.Refactorings.MoveCloserToUsage.MoveCloserToUsageRefactoring.MoveCloserToUsage() in C:\projects\rubberduck\Rubberduck.Refactorings\MoveCloserToUsage\MoveCloserToUsageRefactoring.cs:line 118
at Rubberduck.UI.Command.Refactorings.RefactorMoveCloserToUsageCommand.OnExecute(Object parameter) in C:\projects\rubberduck\Rubberduck.Core\UI\Command\Refactorings\RefactorMoveCloserToUsageCommand.cs:line 49
at Rubberduck.UI.Command.CommandBase.Execute(Object parameter) in C:\projects\rubberduck\Rubberduck.Core\UI\Command\CommandBase.cs:line 47;System.ArgumentException: replace op boundaries of <ReplaceOp@[@2860,7464:7464='.',<41>,184:11]..[@2869,7504:7509='curLen',<237>,184:51]:"curLen"> overlap with previous <ReplaceOp@[@2860,7464:7464='.',<41>,184:11]..[@2880,7525:7530='curLen',<237>,184:72]:"curLen">
at Antlr4.Runtime.TokenStreamRewriter.ReduceToSingleOperationPerIndex(IList`1 rewrites)
at Antlr4.Runtime.TokenStreamRewriter.GetText(String programName, Interval interval)
at Rubberduck.Parsing.Rewriter.ModuleRewriter.get_IsDirty() in C:\projects\rubberduck\Rubberduck.Parsing\Rewriter\ModuleRewriter.cs:line 27
at Rubberduck.Parsing.Rewriter.ModuleRewriter.Rewrite() in C:\projects\rubberduck\Rubberduck.Parsing\Rewriter\ModuleRewriter.cs:line 31
at Rubberduck.Refactorings.MoveCloserToUsage.MoveCloserToUsageRefactoring.MoveCloserToUsage() in C:\projects\rubberduck\Rubberduck.Refactorings\MoveCloserToUsage\MoveCloserToUsageRefactoring.cs:line 118
at Rubberduck.UI.Command.Refactorings.RefactorMoveCloserToUsageCommand.OnExecute(Object parameter) in C:\projects\rubberduck\Rubberduck.Core\UI\Command\Refactorings\RefactorMoveCloserToUsageCommand.cs:line 49
at Rubberduck.UI.Command.CommandBase.Execute(Object parameter) in C:\projects\rubberduck\Rubberduck.Core\UI\Command\CommandBase.cs:line 47
Here is the complete and fresh log showing the issue: RubberduckLog.txt
When attempting to Rename I get this error message:
The text was updated successfully, but these errors were encountered:
I just came across another instance in code where Rename is giving an error attempting to rename parameter WS. I tried a couple of different text strings, just to be sure it wasn't somehow related to that - same results.
This time I actually paid attention to the error message in the dialog box, I'm trying to rename WS, but the error quotes curLen, as in my original issue report.
The problem here seems to be that the refactoring tries to rewrite the same tokens multiple times, which is not possible. There are two possible reasons for this: either the refactoring itself does it or there is stale state in the rewriter.
Win10, Excel2016 (desktop), RD build .3751
In the following code, I've attempted both a
Refactor|Move closer to usage
and aRefactor|Rename
on the variablecurLen
, and I get what appears to be the same error presented in two different ways.This issue has survived two restarts of Excel and seems very specific to this bit of code. I've been doing clean up for the last several days and have used both
Move closer to usage
andRename
dozens, if not hundreds of times without any issues all all.Look for the big comment block about 2/3 of the way down this (very long)
Sub
(that is in desperate need of several applications of a functioningRefactor|Extract Method
):When attempting to
Move closer to usage
, I get the following lines in the error log:Here is the complete and fresh log showing the issue:
RubberduckLog.txt
When attempting to
Rename
I get this error message:The text was updated successfully, but these errors were encountered: