diff --git a/bundles/org.eclipse.ui.editors/src/org/eclipse/ui/internal/texteditor/stickyscroll/DefaultStickyLinesProvider.java b/bundles/org.eclipse.ui.editors/src/org/eclipse/ui/internal/texteditor/stickyscroll/DefaultStickyLinesProvider.java index bf53911a148..2153768f643 100644 --- a/bundles/org.eclipse.ui.editors/src/org/eclipse/ui/internal/texteditor/stickyscroll/DefaultStickyLinesProvider.java +++ b/bundles/org.eclipse.ui.editors/src/org/eclipse/ui/internal/texteditor/stickyscroll/DefaultStickyLinesProvider.java @@ -19,6 +19,9 @@ import org.eclipse.swt.custom.StyledText; +import org.eclipse.jface.text.ITextViewerExtension5; +import org.eclipse.jface.text.source.ISourceViewer; + /** * This class provides sticky lines for the given source code in the source viewer. The * implementation is completely based on indentation and therefore works by default for several @@ -33,14 +36,16 @@ public class DefaultStickyLinesProvider implements IStickyLinesProvider { private StickyLinesProperties fProperties; @Override - public List getStickyLines(StyledText textWidget, int lineNumber, StickyLinesProperties properties) { + public List getStickyLines(ISourceViewer sourceViewer, int lineNumber, StickyLinesProperties properties) { this.fProperties= properties; LinkedList stickyLines= new LinkedList<>(); + StyledText textWidget= sourceViewer.getTextWidget(); + int textWidgetLineNumber= mapLineNumberToWidget(sourceViewer, lineNumber); try { - int startIndetation= getStartIndentation(lineNumber, textWidget); + int startIndetation= getStartIndentation(textWidgetLineNumber, textWidget); - for (int i= lineNumber, previousIndetation= startIndetation; i >= 0; i--) { + for (int i= textWidgetLineNumber, previousIndetation= startIndetation; i >= 0; i--) { String line= textWidget.getLine(i); int indentation= getIndentation(line); @@ -50,7 +55,7 @@ public List getStickyLines(StyledText textWidget, int lineNumber, S if (indentation < previousIndetation) { previousIndetation= indentation; - stickyLines.addFirst(new StickyLine(i, textWidget)); + stickyLines.addFirst(new StickyLine(mapLineNumberToViewer(sourceViewer, i), textWidget)); } } } catch (IllegalArgumentException e) { @@ -101,4 +106,18 @@ private int getIndentation(String line) { return line.length() - line.stripLeading().length(); } + private int mapLineNumberToWidget(ISourceViewer sourceViewer, int line) { + if (sourceViewer instanceof ITextViewerExtension5 extension) { + return extension.modelLine2WidgetLine(line); + } + return line; + } + + private int mapLineNumberToViewer(ISourceViewer sourceViewer, int line) { + if (sourceViewer instanceof ITextViewerExtension5 extension) { + return extension.widgetLine2ModelLine(line); + } + return line; + } + } diff --git a/bundles/org.eclipse.ui.editors/src/org/eclipse/ui/internal/texteditor/stickyscroll/IStickyLinesProvider.java b/bundles/org.eclipse.ui.editors/src/org/eclipse/ui/internal/texteditor/stickyscroll/IStickyLinesProvider.java index 06dc804ef31..cb677202fca 100644 --- a/bundles/org.eclipse.ui.editors/src/org/eclipse/ui/internal/texteditor/stickyscroll/IStickyLinesProvider.java +++ b/bundles/org.eclipse.ui.editors/src/org/eclipse/ui/internal/texteditor/stickyscroll/IStickyLinesProvider.java @@ -15,12 +15,10 @@ import java.util.List; -import org.eclipse.swt.custom.StyledText; - import org.eclipse.jface.text.source.ISourceViewer; /** - * A sticky lines provider calculates the sticky lines for a given text widget. The sticky lines + * A sticky lines provider calculates the sticky lines for a given source viewer. The sticky lines * will be displayed in the top area of the editor. * * TODO move to public package and add since 3.19 @@ -28,24 +26,24 @@ public interface IStickyLinesProvider { /** - * Calculate the sticky lines for the source code of the given textWidget. Specific properties, - * such as the tabWidht and the source viewer, can be retrieved from the + * Calculate the sticky lines for the source code of the given sourceViewer. Specific + * properties, such as the tabWidht, can be retrieved from the * properties. * - * @param textWidget The text widget containing the source code + * @param sourceViewer The source viewer containing the source code and gives access to the text + * widget * @param lineNumber The line number to calculate the sticky lines for * @param properties Properties for additional information * @return The list of sticky lines to show */ - public List getStickyLines(StyledText textWidget, int lineNumber, StickyLinesProperties properties); + public List getStickyLines(ISourceViewer sourceViewer, int lineNumber, StickyLinesProperties properties); /** * Additional properties and access in order to calculate the sticky lines. * * @param tabWith The with of a tab - * @param sourceViewer The sourceViewer to access additional information */ - record StickyLinesProperties(int tabWith, ISourceViewer sourceViewer) { + record StickyLinesProperties(int tabWith) { } } diff --git a/bundles/org.eclipse.ui.editors/src/org/eclipse/ui/internal/texteditor/stickyscroll/StickyScrollingControl.java b/bundles/org.eclipse.ui.editors/src/org/eclipse/ui/internal/texteditor/stickyscroll/StickyScrollingControl.java index 0e02cbd4980..7375afadfc4 100644 --- a/bundles/org.eclipse.ui.editors/src/org/eclipse/ui/internal/texteditor/stickyscroll/StickyScrollingControl.java +++ b/bundles/org.eclipse.ui.editors/src/org/eclipse/ui/internal/texteditor/stickyscroll/StickyScrollingControl.java @@ -206,7 +206,7 @@ private void updateStickyScrollingControls() { for (int i= 0; i < getNumberStickyLines(); i++) { IStickyLine stickyLine= stickyLines.get(i); stickyLineTextJoiner.add(stickyLine.getText()); - int lineNumber= getSourceViewerLineNumber(stickyLine.getLineNumber()); + int lineNumber= stickyLine.getLineNumber(); stickyLineNumberJoiner.add(fillLineNumberWithLeadingSpaces(lineNumber + 1)); } @@ -222,13 +222,6 @@ private void updateStickyScrollingControls() { } } - private int getSourceViewerLineNumber(int i) { - if (sourceViewer instanceof ITextViewerExtension5 extension) { - return extension.widgetLine2ModelLine(i); - } - return i; - } - private String fillLineNumberWithLeadingSpaces(int lineNumber) { int lineCount= sourceViewer.getDocument().getNumberOfLines(); int lineNumberLength= String.valueOf(lineCount).length(); @@ -399,6 +392,8 @@ private int getNumberStickyLines() { * resized/moved.
*/ private void addSourceViewerListeners() { + StyledText textWidget= sourceViewer.getTextWidget(); + if (sourceViewer instanceof ITextViewerExtension4 extension) { textPresentationListener= e -> { Job.create("Update sticky lines styling", (ICoreRunnable) monitor -> { //$NON-NLS-1$ @@ -411,13 +406,12 @@ private void addSourceViewerListeners() { } caretListener= new StickyScollingCaretListener(); - sourceViewer.getTextWidget().addCaretListener(caretListener); - sourceViewer.getTextWidget().addKeyListener(caretListener); + textWidget.addCaretListener(caretListener); + textWidget.addKeyListener(caretListener); controlListener= new ControlListener() { @Override public void controlResized(ControlEvent e) { - StyledText textWidget= sourceViewer.getTextWidget(); limitVisibleStickyLinesToTextWidgetHeight(textWidget); layoutStickyLines(); if (stickyScrollingHandler != null) { @@ -430,7 +424,7 @@ public void controlMoved(ControlEvent e) { layoutStickyLines(); } }; - sourceViewer.getTextWidget().addControlListener(controlListener); + textWidget.addControlListener(controlListener); } private void limitVisibleStickyLinesToTextWidgetHeight(StyledText textWidget) { diff --git a/bundles/org.eclipse.ui.editors/src/org/eclipse/ui/internal/texteditor/stickyscroll/StickyScrollingHandler.java b/bundles/org.eclipse.ui.editors/src/org/eclipse/ui/internal/texteditor/stickyscroll/StickyScrollingHandler.java index 596fdec59ea..de457cf0ca0 100644 --- a/bundles/org.eclipse.ui.editors/src/org/eclipse/ui/internal/texteditor/stickyscroll/StickyScrollingHandler.java +++ b/bundles/org.eclipse.ui.editors/src/org/eclipse/ui/internal/texteditor/stickyscroll/StickyScrollingHandler.java @@ -25,7 +25,6 @@ import java.util.LinkedList; import java.util.List; -import org.eclipse.swt.custom.StyledText; import org.eclipse.swt.graphics.Color; import org.eclipse.swt.graphics.RGB; @@ -140,7 +139,7 @@ private StickyScrollingControlSettings loadControlSettings(IPreferenceStore stor private StickyLinesProperties loadStickyLinesProperties(IPreferenceStore store) { int tabWidth= store.getInt(EDITOR_TAB_WIDTH); - return new StickyLinesProperties(tabWidth, sourceViewer); + return new StickyLinesProperties(tabWidth); } @Override @@ -155,11 +154,10 @@ public void viewportChanged(int newVerticalOffset) { private void calculateAndShowStickyLines() { List stickyLines= Collections.emptyList(); - StyledText textWidget= sourceViewer.getTextWidget(); - int startLine= textWidget.getTopIndex(); + int startLine= sourceViewer.getTopIndex(); if (startLine > 0) { - stickyLines= stickyLinesProvider.getStickyLines(textWidget, startLine, stickyLinesProperties); + stickyLines= stickyLinesProvider.getStickyLines(sourceViewer, sourceViewer.getTopIndex(), stickyLinesProperties); } if (stickyLines == null) { @@ -179,11 +177,10 @@ private List adaptStickyLinesToVisibleArea(List sticky LinkedList adaptedStickyLines= new LinkedList<>(stickyLines); int firstVisibleLine= startLine + adaptedStickyLines.size(); - StyledText textWidget= sourceViewer.getTextWidget(); - int maximumLines= textWidget.getLineCount(); + int numberOfLines= sourceViewer.getDocument().getNumberOfLines(); - for (int i= startLine + 1; i <= firstVisibleLine && i < maximumLines; i++) { - List stickyLinesInLineI= stickyLinesProvider.getStickyLines(textWidget, i, stickyLinesProperties); + for (int i= startLine + 1; i <= firstVisibleLine && i < numberOfLines; i++) { + List stickyLinesInLineI= stickyLinesProvider.getStickyLines(sourceViewer, i, stickyLinesProperties); if (stickyLinesInLineI.size() > adaptedStickyLines.size()) { adaptedStickyLines= new LinkedList<>(stickyLinesInLineI); diff --git a/tests/org.eclipse.ui.editors.tests/src/org/eclipse/ui/internal/texteditor/stickyscroll/DefaultStickyLinesProviderTest.java b/tests/org.eclipse.ui.editors.tests/src/org/eclipse/ui/internal/texteditor/stickyscroll/DefaultStickyLinesProviderTest.java index 44b980e27cc..0ec92b14dc9 100644 --- a/tests/org.eclipse.ui.editors.tests/src/org/eclipse/ui/internal/texteditor/stickyscroll/DefaultStickyLinesProviderTest.java +++ b/tests/org.eclipse.ui.editors.tests/src/org/eclipse/ui/internal/texteditor/stickyscroll/DefaultStickyLinesProviderTest.java @@ -25,9 +25,13 @@ import org.eclipse.swt.SWT; import org.eclipse.swt.custom.StyledText; +import org.eclipse.swt.widgets.Composite; import org.eclipse.swt.widgets.Display; import org.eclipse.swt.widgets.Shell; +import org.eclipse.jface.text.IRegion; +import org.eclipse.jface.text.ITextViewerExtension5; +import org.eclipse.jface.text.source.IVerticalRuler; import org.eclipse.jface.text.source.SourceViewer; import org.eclipse.ui.internal.texteditor.stickyscroll.IStickyLinesProvider.StickyLinesProperties; @@ -46,12 +50,12 @@ public void setup() { sourceViewer = new SourceViewer(shell, null, SWT.None); stickyLinesProvider = new DefaultStickyLinesProvider(); textWidget = sourceViewer.getTextWidget(); - stickyLinesProperties = new StickyLinesProperties(4, sourceViewer); + stickyLinesProperties = new StickyLinesProperties(4); } @Test public void testEmptySourceCode() { - List stickyLines = stickyLinesProvider.getStickyLines(textWidget, 0, stickyLinesProperties); + List stickyLines = stickyLinesProvider.getStickyLines(sourceViewer, 0, stickyLinesProperties); assertThat(stickyLines, is(empty())); } @@ -63,7 +67,7 @@ public void testSingleStickyLine() { line 2<"""; setText(text); - List stickyLines = stickyLinesProvider.getStickyLines(textWidget, 1, stickyLinesProperties); + List stickyLines = stickyLinesProvider.getStickyLines(sourceViewer, 1, stickyLinesProperties); assertEquals(1, stickyLines.size()); assertEquals(0, stickyLines.get(0).getLineNumber()); @@ -78,7 +82,7 @@ public void testLineUnderStickyLine() { line 4"""; setText(text); - List stickyLines = stickyLinesProvider.getStickyLines(textWidget, 1, stickyLinesProperties); + List stickyLines = stickyLinesProvider.getStickyLines(sourceViewer, 1, stickyLinesProperties); assertEquals(1, stickyLines.size()); assertEquals(0, stickyLines.get(0).getLineNumber()); @@ -93,7 +97,7 @@ public void testNewStickyRoot() { line 4<"""; setText(text); - List stickyLines = stickyLinesProvider.getStickyLines(textWidget, 3, stickyLinesProperties); + List stickyLines = stickyLinesProvider.getStickyLines(sourceViewer, 3, stickyLinesProperties); assertEquals(1, stickyLines.size()); assertEquals(2, stickyLines.get(0).getLineNumber()); @@ -109,7 +113,7 @@ public void testIgnoreEmptyLines() { line 3<"""; setText(text); - List stickyLines = stickyLinesProvider.getStickyLines(textWidget, 4, stickyLinesProperties); + List stickyLines = stickyLinesProvider.getStickyLines(sourceViewer, 4, stickyLinesProperties); assertEquals(2, stickyLines.size()); assertEquals(0, stickyLines.get(0).getLineNumber()); @@ -118,14 +122,14 @@ public void testIgnoreEmptyLines() { @Test public void testLinesWithTabs() { - stickyLinesProperties = new StickyLinesProperties(2, sourceViewer); + stickyLinesProperties = new StickyLinesProperties(2); String text = """ line 1 \tline 2 \t\tline 3<"""; setText(text); - List stickyLines = stickyLinesProvider.getStickyLines(textWidget, 2, stickyLinesProperties); + List stickyLines = stickyLinesProvider.getStickyLines(sourceViewer, 2, stickyLinesProperties); assertEquals(2, stickyLines.size()); assertEquals(0, stickyLines.get(0).getLineNumber()); @@ -143,7 +147,7 @@ public void testStartAtEmptyLineWithNext() { textWidget.setText(text); textWidget.setTopIndex(3); - List stickyLines = stickyLinesProvider.getStickyLines(textWidget, 3, stickyLinesProperties); + List stickyLines = stickyLinesProvider.getStickyLines(sourceViewer, 3, stickyLinesProperties); assertEquals(2, stickyLines.size()); assertEquals(0, stickyLines.get(0).getLineNumber()); @@ -160,13 +164,31 @@ public void testStartAtEmptyLineWithPrevious() { line 4"""; setText(text); - List stickyLines = stickyLinesProvider.getStickyLines(textWidget, 3, stickyLinesProperties); + List stickyLines = stickyLinesProvider.getStickyLines(sourceViewer, 3, stickyLinesProperties); assertEquals(2, stickyLines.size()); assertEquals(0, stickyLines.get(0).getLineNumber()); assertEquals(1, stickyLines.get(1).getLineNumber()); } + @Test + public void testStickyLineWithSourceViewerLineMapping() { + sourceViewer = new SourceViewerWithLineMapping(shell, null, SWT.None); + textWidget = sourceViewer.getTextWidget(); + + String text = """ + line 1 + line 2<"""; + setText(text); + + // Source viewer line 43 that is mapped to line 1 in the text widget + List stickyLines = stickyLinesProvider.getStickyLines(sourceViewer, 1 + 42, stickyLinesProperties); + + assertEquals(1, stickyLines.size()); + // Source viewer line 42 that is mapped to line 0 in the text widget + assertEquals(0 + 42, stickyLines.get(0).getLineNumber()); + } + /** * Set the text into the text widget and set the top index to the line * containing the <. @@ -175,4 +197,32 @@ private void setText(String text) { textWidget.setText(text); } + private class SourceViewerWithLineMapping extends SourceViewer implements ITextViewerExtension5 { + + public SourceViewerWithLineMapping(Composite parent, IVerticalRuler ruler, int styles) { + super(parent, ruler, styles); + } + + @Override + public IRegion[] getCoveredModelRanges(IRegion modelRange) { + return null; + } + + @Override + public boolean exposeModelRange(IRegion modelRange) { + return false; + } + + @Override + public int widgetLine2ModelLine(int widgetLine) { + return widgetLine + 42; + } + + @Override + public int modelLine2WidgetLine(int widgetLine) { + return widgetLine - 42; + } + + } + } diff --git a/tests/org.eclipse.ui.editors.tests/src/org/eclipse/ui/internal/texteditor/stickyscroll/StickyScrollingControlTest.java b/tests/org.eclipse.ui.editors.tests/src/org/eclipse/ui/internal/texteditor/stickyscroll/StickyScrollingControlTest.java index d9442aa9ec5..4b8e63506de 100644 --- a/tests/org.eclipse.ui.editors.tests/src/org/eclipse/ui/internal/texteditor/stickyscroll/StickyScrollingControlTest.java +++ b/tests/org.eclipse.ui.editors.tests/src/org/eclipse/ui/internal/texteditor/stickyscroll/StickyScrollingControlTest.java @@ -43,8 +43,6 @@ import org.eclipse.swt.widgets.Shell; import org.eclipse.jface.text.Document; -import org.eclipse.jface.text.IRegion; -import org.eclipse.jface.text.ITextViewerExtension5; import org.eclipse.jface.text.source.IVerticalRuler; import org.eclipse.jface.text.source.SourceViewer; @@ -101,30 +99,6 @@ public void testShowStickyLineTexts() { assertEquals(expStickyLineText, stickyLineText.getText()); } - @Test - public void testShowStickyLineTextsWithSourceViewerMapping() { - shell.dispose(); - shell = new Shell(Display.getDefault()); - shell.setSize(200, 200); - shell.setLayout(new FillLayout()); - - sourceViewer = new SourceViewerLineMapping(shell, ruler, SWT.V_SCROLL | SWT.H_SCROLL); - sourceViewer.setDocument(new Document()); - sourceViewer.getTextWidget().setBounds(0, 0, 200, 200); - - stickyScrollingControl = new StickyScrollingControl(sourceViewer, ruler, settings, null); - - List stickyLines = List.of(new StickyLineStub("line 10", 9), new StickyLineStub("line 20", 19)); - stickyScrollingControl.setStickyLines(stickyLines); - - StyledText stickyLineNumber = getStickyLineNumber(); - String expLineNumber = "52" + System.lineSeparator() + "62"; - assertEquals(expLineNumber, stickyLineNumber.getText()); - StyledText stickyLineText = getStickyLineText(); - String expStickyLineText = "line 10" + System.lineSeparator() + "line 20"; - assertEquals(expStickyLineText, stickyLineText.getText()); - } - @Test public void testCorrectColorsApplied() { List stickyLines = List.of(new StickyLineStub("line 10", 9), new StickyLineStub("line 20", 19)); @@ -480,29 +454,6 @@ private void drainDisplayEventQueue() { } } - private class SourceViewerLineMapping extends SourceViewer implements ITextViewerExtension5 { - - public SourceViewerLineMapping(Composite parent, IVerticalRuler ruler, int styles) { - super(parent, ruler, styles); - } - - @Override - public IRegion[] getCoveredModelRanges(IRegion modelRange) { - return null; - } - - @Override - public boolean exposeModelRange(IRegion modelRange) { - return false; - } - - @Override - public int widgetLine2ModelLine(int widgetLine) { - return widgetLine + 42; - } - - } - private class StickyLineStub implements IStickyLine { private final String text; diff --git a/tests/org.eclipse.ui.editors.tests/src/org/eclipse/ui/internal/texteditor/stickyscroll/StickyScrollingHandlerTest.java b/tests/org.eclipse.ui.editors.tests/src/org/eclipse/ui/internal/texteditor/stickyscroll/StickyScrollingHandlerTest.java index 6798ec1b1e7..0856c70b19e 100644 --- a/tests/org.eclipse.ui.editors.tests/src/org/eclipse/ui/internal/texteditor/stickyscroll/StickyScrollingHandlerTest.java +++ b/tests/org.eclipse.ui.editors.tests/src/org/eclipse/ui/internal/texteditor/stickyscroll/StickyScrollingHandlerTest.java @@ -87,7 +87,7 @@ public void setup() { linesProvider = mock(IStickyLinesProvider.class); stickyScrollingHandler = new StickyScrollingHandler(sourceViewer, ruler, store, linesProvider); - stickyLinesProperties = new StickyLinesProperties(4, sourceViewer); + stickyLinesProperties = new StickyLinesProperties(4); } @After @@ -97,7 +97,7 @@ public void teardown() { @Test public void testShowStickyLines() { - when(linesProvider.getStickyLines(textWidget, 1, stickyLinesProperties)) + when(linesProvider.getStickyLines(sourceViewer, 1, stickyLinesProperties)) .thenReturn(List.of(new StickyLineStub("line 10", 9))); stickyScrollingHandler.viewportChanged(100); @@ -134,7 +134,7 @@ public void testUnistallStickyLines() { @Test public void testPreferencesLoaded() { - when(linesProvider.getStickyLines(textWidget, 1, stickyLinesProperties)) + when(linesProvider.getStickyLines(sourceViewer, 1, stickyLinesProperties)) .thenReturn(List.of(new StickyLineStub("line 10", 9))); stickyScrollingHandler.viewportChanged(100); @@ -145,9 +145,9 @@ public void testPreferencesLoaded() { @Test public void testPreferencesUpdated() { - when(linesProvider.getStickyLines(textWidget, 1, stickyLinesProperties)) + when(linesProvider.getStickyLines(sourceViewer, 1, stickyLinesProperties)) .thenReturn(List.of(new StickyLineStub("line 10", 9), new StickyLineStub("line 20", 19))); - when(linesProvider.getStickyLines(textWidget, 2, stickyLinesProperties)) + when(linesProvider.getStickyLines(sourceViewer, 2, stickyLinesProperties)) .thenReturn(List.of(new StickyLineStub("line 10", 9), new StickyLineStub("line 20", 19))); stickyScrollingHandler.viewportChanged(100); @@ -165,13 +165,13 @@ public void testPreferencesUpdated() { @Test public void testThrottledExecution() throws InterruptedException { - when(linesProvider.getStickyLines(textWidget, 1, stickyLinesProperties)) + when(linesProvider.getStickyLines(sourceViewer, 1, stickyLinesProperties)) .thenReturn(List.of(new StickyLineStub("line 10", 9))); - when(linesProvider.getStickyLines(textWidget, 1, stickyLinesProperties)) + when(linesProvider.getStickyLines(sourceViewer, 1, stickyLinesProperties)) .thenReturn(List.of(new StickyLineStub("line 10", 9))); - when(linesProvider.getStickyLines(textWidget, 1, stickyLinesProperties)) + when(linesProvider.getStickyLines(sourceViewer, 1, stickyLinesProperties)) .thenReturn(List.of(new StickyLineStub("line 10", 9))); - when(linesProvider.getStickyLines(textWidget, 1, stickyLinesProperties)) + when(linesProvider.getStickyLines(sourceViewer, 1, stickyLinesProperties)) .thenReturn(List.of(new StickyLineStub("line 10", 9))); stickyScrollingHandler.viewportChanged(100); @@ -186,15 +186,15 @@ public void testThrottledExecution() throws InterruptedException { // Call to lines provider should be throttled, at least one and at most // 3 calls expected - verify(linesProvider, atMost(3)).getStickyLines(textWidget, 1, stickyLinesProperties); - verify(linesProvider, atLeastOnce()).getStickyLines(textWidget, 1, stickyLinesProperties); + verify(linesProvider, atMost(3)).getStickyLines(sourceViewer, 1, stickyLinesProperties); + verify(linesProvider, atLeastOnce()).getStickyLines(sourceViewer, 1, stickyLinesProperties); } @Test public void testRemoveStickyLines() { - when(linesProvider.getStickyLines(textWidget, 1, stickyLinesProperties)) + when(linesProvider.getStickyLines(sourceViewer, 1, stickyLinesProperties)) .thenReturn(List.of(new StickyLineStub("line 1", 0), new StickyLineStub("line 2", 1))); - when(linesProvider.getStickyLines(textWidget, 2, stickyLinesProperties)) + when(linesProvider.getStickyLines(sourceViewer, 2, stickyLinesProperties)) .thenReturn(List.of(new StickyLineStub("line 3", 2))); stickyScrollingHandler.viewportChanged(100); @@ -206,9 +206,9 @@ public void testRemoveStickyLines() { @Test public void testLineUnderStickyLine() { - when(linesProvider.getStickyLines(textWidget, 1, stickyLinesProperties)) + when(linesProvider.getStickyLines(sourceViewer, 1, stickyLinesProperties)) .thenReturn(List.of(new StickyLineStub("line 1", 0))); - when(linesProvider.getStickyLines(textWidget, 2, stickyLinesProperties)) + when(linesProvider.getStickyLines(sourceViewer, 2, stickyLinesProperties)) .thenReturn(List.of(new StickyLineStub("line 1", 0), new StickyLineStub("line 2", 1))); stickyScrollingHandler.viewportChanged(100);