Skip to content

Commit 05c67f7

Browse files
committed
Fix warnings in org.eclipse.ui.genericeditor.tests
Minor non-functional changes to tests in org.eclipse.ui.genericeditor.tests to fix existing warnings.
1 parent f243cf0 commit 05c67f7

File tree

4 files changed

+22
-19
lines changed

4 files changed

+22
-19
lines changed

tests/org.eclipse.ui.genericeditor.tests/src/org/eclipse/ui/genericeditor/tests/CompletionTest.java

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,8 @@
1313
*******************************************************************************/
1414
package org.eclipse.ui.genericeditor.tests;
1515

16+
import static org.eclipse.ui.genericeditor.tests.contributions.BarContentAssistProcessor.BAR_CONTENT_ASSIST_PROPOSAL;
17+
import static org.eclipse.ui.genericeditor.tests.contributions.LongRunningBarContentAssistProcessor.LONG_RUNNING_BAR_CONTENT_ASSIST_PROPOSAL;
1618
import static org.hamcrest.CoreMatchers.endsWith;
1719
import static org.hamcrest.MatcherAssert.assertThat;
1820
import static org.junit.Assert.assertEquals;
@@ -65,7 +67,6 @@
6567
import org.eclipse.jface.text.contentassist.IContextInformationValidator;
6668
import org.eclipse.jface.text.tests.util.DisplayHelper;
6769

68-
import org.eclipse.ui.genericeditor.tests.contributions.BarContentAssistProcessor;
6970
import org.eclipse.ui.genericeditor.tests.contributions.EnabledPropertyTester;
7071
import org.eclipse.ui.genericeditor.tests.contributions.LongRunningBarContentAssistProcessor;
7172

@@ -184,7 +185,7 @@ private void checkCompletionContent(final Table completionProposalList) {
184185
final TableItem initialProposalItem = completionProposalList.getItem(1);
185186
final String initialProposalString = ((ICompletionProposal)initialProposalItem.getData()).getDisplayString();
186187
assertThat("Unexpected initial proposal item",
187-
BarContentAssistProcessor.PROPOSAL, endsWith(initialProposalString));
188+
BAR_CONTENT_ASSIST_PROPOSAL, endsWith(initialProposalString));
188189
completionProposalList.setSelection(initialProposalItem);
189190
// asynchronous
190191
waitForProposalRelatedCondition("Proposal list did not show two items after finishing computing", completionProposalList,
@@ -193,9 +194,9 @@ private void checkCompletionContent(final Table completionProposalList) {
193194
final TableItem firstCompletionProposalItem = completionProposalList.getItem(0);
194195
final TableItem secondCompletionProposalItem = completionProposalList.getItem(1);
195196
String firstCompletionProposalText = ((ICompletionProposal)firstCompletionProposalItem.getData()).getDisplayString();
196-
String secondCOmpletionProposalText = ((ICompletionProposal)secondCompletionProposalItem.getData()).getDisplayString();
197-
assertThat("Unexpected first proposal item", BarContentAssistProcessor.PROPOSAL, endsWith(firstCompletionProposalText));
198-
assertThat("Unexpected second proposal item", LongRunningBarContentAssistProcessor.PROPOSAL, endsWith(secondCOmpletionProposalText));
197+
String secondCompletionProposalText = ((ICompletionProposal)secondCompletionProposalItem.getData()).getDisplayString();
198+
assertThat("Unexpected first proposal item", BAR_CONTENT_ASSIST_PROPOSAL, endsWith(firstCompletionProposalText));
199+
assertThat("Unexpected second proposal item", LONG_RUNNING_BAR_CONTENT_ASSIST_PROPOSAL, endsWith(secondCompletionProposalText));
199200
String selectedProposalString = ((ICompletionProposal)completionProposalList.getSelection()[0].getData()).getDisplayString();
200201
assertEquals("Addition of completion proposal should keep selection", initialProposalString, selectedProposalString);
201202
}

tests/org.eclipse.ui.genericeditor.tests/src/org/eclipse/ui/genericeditor/tests/ContextInfoTest.java

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@
1313
*******************************************************************************/
1414
package org.eclipse.ui.genericeditor.tests;
1515

16+
import static org.eclipse.ui.genericeditor.tests.contributions.BarContentAssistProcessor.BAR_CONTENT_ASSIST_PROPOSAL;
1617
import static org.junit.Assert.assertEquals;
1718
import static org.junit.Assert.assertTrue;
1819

@@ -33,7 +34,6 @@
3334
import org.eclipse.jface.text.contentassist.ContentAssistant;
3435
import org.eclipse.jface.text.source.SourceViewer;
3536

36-
import org.eclipse.ui.genericeditor.tests.contributions.BarContentAssistProcessor;
3737
import org.eclipse.ui.tests.harness.util.UITestCase;
3838

3939
import org.eclipse.ui.texteditor.ITextEditorActionConstants;
@@ -49,7 +49,7 @@ public class ContextInfoTest extends AbstratGenericEditorTest {
4949
@Test
5050
public void testContextInfo() throws Exception {
5151
cleanFileAndEditor();
52-
createAndOpenFile("foobar.txt", BarContentAssistProcessor.PROPOSAL);
52+
createAndOpenFile("foobar.txt", BAR_CONTENT_ASSIST_PROPOSAL);
5353

5454
final Set<Shell> beforeShells = Arrays.stream(editor.getSite().getShell().getDisplay().getShells()).filter(Shell::isVisible).collect(Collectors.toSet());
5555
TextOperationAction action = (TextOperationAction) editor.getAction(ITextEditorActionConstants.CONTENT_ASSIST_CONTEXT_INFORMATION);
@@ -74,7 +74,7 @@ public void testContextInfo() throws Exception {
7474
@Test
7575
public void testContextInfo_hide_Bug512251() throws Exception {
7676
cleanFileAndEditor();
77-
createAndOpenFile("foobar.txt", BarContentAssistProcessor.PROPOSAL);
77+
createAndOpenFile("foobar.txt", BAR_CONTENT_ASSIST_PROPOSAL);
7878

7979
final Set<Shell> beforeShells = Arrays.stream(editor.getSite().getShell().getDisplay().getShells()).filter(Shell::isVisible).collect(Collectors.toSet());
8080
TextOperationAction action = (TextOperationAction) editor.getAction(ITextEditorActionConstants.CONTENT_ASSIST_CONTEXT_INFORMATION);

tests/org.eclipse.ui.genericeditor.tests/src/org/eclipse/ui/genericeditor/tests/contributions/BarContentAssistProcessor.java

Lines changed: 11 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -29,11 +29,11 @@
2929

3030
public class BarContentAssistProcessor implements IContentAssistProcessor {
3131

32-
public static final String PROPOSAL = "bars are good for a beer.";
32+
public static final String BAR_CONTENT_ASSIST_PROPOSAL = "bars are good for a beer.";
3333
private final String completeString;
3434

3535
public BarContentAssistProcessor() {
36-
this(PROPOSAL);
36+
this(BAR_CONTENT_ASSIST_PROPOSAL);
3737
}
3838

3939
public BarContentAssistProcessor(String completeString) {
@@ -96,20 +96,22 @@ public IContextInformation[] computeContextInformation(ITextViewer viewer, int o
9696
@Override
9797
public IContextInformationValidator getContextInformationValidator() {
9898
return new IContextInformationValidator() {
99-
ITextViewer viewer;
100-
int offset;
99+
private ITextViewer viewer;
100+
private int offset;
101+
101102
@Override
102-
public void install(IContextInformation info, ITextViewer viewer, int offset) {
103-
this.viewer= viewer;
104-
this.offset= offset;
103+
public void install(IContextInformation info, ITextViewer infoViewer, int documentOffset) {
104+
this.viewer= infoViewer;
105+
this.offset= documentOffset;
105106
}
107+
106108
@Override
107-
public boolean isContextInformationValid(int offset) {
109+
public boolean isContextInformationValid(int offsetToTest) {
108110
try {
109111
IDocument document= viewer.getDocument();
110112
IRegion line= document.getLineInformationOfOffset(this.offset);
111113
int end= line.getOffset() + line.getLength();
112-
return (offset >= this.offset && offset < end);
114+
return (offsetToTest >= this.offset && offsetToTest < end);
113115
} catch (BadLocationException e) {
114116
return false;
115117
}

tests/org.eclipse.ui.genericeditor.tests/src/org/eclipse/ui/genericeditor/tests/contributions/LongRunningBarContentAssistProcessor.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,11 +18,11 @@
1818

1919
public class LongRunningBarContentAssistProcessor extends BarContentAssistProcessor {
2020

21-
public static final String PROPOSAL = "bars are also good for soft drink cocktails.";
21+
public static final String LONG_RUNNING_BAR_CONTENT_ASSIST_PROPOSAL = "bars are also good for soft drink cocktails.";
2222
public static final int DELAY = 2000;
2323

2424
public LongRunningBarContentAssistProcessor() {
25-
super(PROPOSAL);
25+
super(LONG_RUNNING_BAR_CONTENT_ASSIST_PROPOSAL);
2626
}
2727

2828
@Override

0 commit comments

Comments
 (0)