Skip to content

Commit f70ee0a

Browse files
committed
Less noise to sysout from genericeditor tests
1 parent d291a39 commit f70ee0a

File tree

1 file changed

+15
-10
lines changed

1 file changed

+15
-10
lines changed

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

Lines changed: 15 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*******************************************************************************
2-
* Copyright (c) 2016 Red Hat Inc. and others.
2+
* Copyright (c) 2016, 2025 Red Hat Inc. and others.
33
*
44
* This program and the accompanying materials
55
* are made available under the terms of the Eclipse Public License 2.0
@@ -42,16 +42,21 @@ public BarContentAssistProcessor(String completeString) {
4242

4343
@Override
4444
public ICompletionProposal[] computeCompletionProposals(ITextViewer viewer, int offset) {
45-
for (int offsetInProposal = Math.min(this.completeString.length(), viewer.getDocument().getLength()); offsetInProposal > 0; offsetInProposal--) {
46-
String maybeMatchingString = this.completeString.substring(0, offsetInProposal);
47-
try {
48-
int lastIndex = offset - offsetInProposal + this.completeString.length();
49-
if (offset >= offsetInProposal && viewer.getDocument().get(offset - offsetInProposal, maybeMatchingString.length()).equals(maybeMatchingString)) {
50-
CompletionProposal proposal = new CompletionProposal(this.completeString.substring(offsetInProposal), offset, 0, lastIndex);
51-
return new ICompletionProposal[] { proposal };
45+
if (viewer.getDocument() != null) {
46+
for (int offsetInProposal = Math.min(this.completeString.length(),
47+
viewer.getDocument().getLength()); offsetInProposal > 0; offsetInProposal--) {
48+
String maybeMatchingString = this.completeString.substring(0, offsetInProposal);
49+
try {
50+
int lastIndex = offset - offsetInProposal + this.completeString.length();
51+
if (offset >= offsetInProposal && viewer.getDocument()
52+
.get(offset - offsetInProposal, maybeMatchingString.length()).equals(maybeMatchingString)) {
53+
CompletionProposal proposal = new CompletionProposal(
54+
this.completeString.substring(offsetInProposal), offset, 0, lastIndex);
55+
return new ICompletionProposal[] { proposal };
56+
}
57+
} catch (BadLocationException e) {
58+
e.printStackTrace();
5259
}
53-
} catch (BadLocationException e) {
54-
e.printStackTrace();
5560
}
5661
}
5762
return new ICompletionProposal[0];

0 commit comments

Comments
 (0)