From 8ff58a52626f76582a3e021b65f29f0999eaf3c0 Mon Sep 17 00:00:00 2001 From: Jonah Graham Date: Mon, 30 Jan 2023 12:00:07 -0500 Subject: [PATCH] Remove field in test The field implies that the fSourceViewer has a longer life than it does. But reality is that the viewer is only valid until the editor gets reopened while the test is running. --- .../tests/text/doctools/DocCommentHighlightingTest.java | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-) diff --git a/core/org.eclipse.cdt.ui.tests/ui/org/eclipse/cdt/ui/tests/text/doctools/DocCommentHighlightingTest.java b/core/org.eclipse.cdt.ui.tests/ui/org/eclipse/cdt/ui/tests/text/doctools/DocCommentHighlightingTest.java index 440c2fa4f4c..bf01484ff9e 100644 --- a/core/org.eclipse.cdt.ui.tests/ui/org/eclipse/cdt/ui/tests/text/doctools/DocCommentHighlightingTest.java +++ b/core/org.eclipse.cdt.ui.tests/ui/org/eclipse/cdt/ui/tests/text/doctools/DocCommentHighlightingTest.java @@ -80,8 +80,6 @@ public class DocCommentHighlightingTest extends BaseUITestCase { private ICProject fCProject; private final String fTestFilename = "/" + PROJECT + "/src/this.cpp"; - private static SourceViewer fSourceViewer; - public static Test suite() { return new TestSuite(DocCommentHighlightingTest.class); } @@ -99,11 +97,11 @@ public class DocCommentHighlightingTest extends BaseUITestCase { preferenceStore.setValue(PreferenceConstants.EDITOR_FOLDING_ENABLED, false); AbstractTextEditor fEditor = (CEditor) EditorTestHelper.openInEditor(ResourceTestHelper.findFile(fTestFilename), true); - fSourceViewer = EditorTestHelper.getSourceViewer(fEditor); + SourceViewer sourceViewer = EditorTestHelper.getSourceViewer(fEditor); // Source positions depend on Windows line separator - adjustLineSeparator(fSourceViewer.getDocument(), "\r\n"); + adjustLineSeparator(sourceViewer.getDocument(), "\r\n"); fEditor.doSave(new NullProgressMonitor()); - assertTrue(EditorTestHelper.joinReconciler(fSourceViewer, 0, 10000, 100)); + assertTrue(EditorTestHelper.joinReconciler(sourceViewer, 0, 10000, 100)); } @Override