Skip to content

Commit b1103fb

Browse files
committed
Cleanup in o.e.jface.text.contentassist
A prep step for #3293 . Makes sure that comments are not lost.
1 parent 868cd97 commit b1103fb

File tree

10 files changed

+536
-321
lines changed

10 files changed

+536
-321
lines changed

bundles/org.eclipse.jface.text/src/org/eclipse/jface/text/contentassist/AdditionalInfoController.java

Lines changed: 15 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -287,16 +287,19 @@ public synchronized final void reset(ICompletionProposal p) {
287287
long oldWakeup= fNextWakeup;
288288
Task task= taskOnReset(p);
289289
schedule(task, System.currentTimeMillis());
290-
if (fNextWakeup < oldWakeup)
290+
if (fNextWakeup < oldWakeup) {
291291
notifyAll();
292+
}
292293
}
293294
}
294295

295296
private Task taskOnReset(ICompletionProposal p) {
296-
if (p == null)
297+
if (p == null) {
297298
return IDLE;
298-
if (isExt5(p))
299+
}
300+
if (isExt5(p)) {
299301
return FIRST_WAIT;
302+
}
300303
return LEGACY_WAIT;
301304
}
302305

@@ -325,10 +328,11 @@ private Task currentTask() {
325328
private void schedule(Task task, long current) {
326329
fTask= task;
327330
long nextWakeup= current + task.delay();
328-
if (nextWakeup <= current)
331+
if (nextWakeup <= current) {
329332
fNextWakeup= Long.MAX_VALUE;
330-
else
333+
} else {
331334
fNextWakeup= nextWakeup;
335+
}
332336
}
333337

334338
private boolean isExt5(ICompletionProposal p) {
@@ -473,8 +477,9 @@ public void install(Control control) {
473477
@Override
474478
protected void showInformation(ICompletionProposal proposal, Object info) {
475479
InformationControlReplacer replacer= getInternalAccessor().getInformationControlReplacer();
476-
if (replacer != null)
480+
if (replacer != null) {
477481
replacer.hideInformationControl();
482+
}
478483
AdditionalInfoController.this.showInformation(proposal, info);
479484
}
480485
};
@@ -601,10 +606,12 @@ protected Point computeSizeConstraints(Control subjectControl, IInformationContr
601606
size.y -= shellTrim.height;
602607
}
603608

604-
if (sizeConstraint.x < size.x)
609+
if (sizeConstraint.x < size.x) {
605610
sizeConstraint.x= size.x;
606-
if (sizeConstraint.y < size.y)
611+
}
612+
if (sizeConstraint.y < size.y) {
607613
sizeConstraint.y= size.y;
614+
}
608615
return sizeConstraint;
609616
}
610617

bundles/org.eclipse.jface.text/src/org/eclipse/jface/text/contentassist/AsyncCompletionProposalPopup.java

Lines changed: 11 additions & 6 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
@@ -159,8 +159,9 @@ public AsyncCompletionProposalPopup(ContentAssistant contentAssistant, ITextView
159159
*/
160160
@Override
161161
public String showProposals(boolean autoActivated) {
162-
if (fKeyListener == null)
162+
if (fKeyListener == null) {
163163
fKeyListener= new ProposalSelectionListener();
164+
}
164165

165166
final Control control= fContentAssistSubjectControlAdapter.getControl();
166167

@@ -304,11 +305,13 @@ public String incrementalComplete() {
304305
}
305306
final Control control= fContentAssistSubjectControlAdapter.getControl();
306307

307-
if (fKeyListener == null)
308+
if (fKeyListener == null) {
308309
fKeyListener= new ProposalSelectionListener();
310+
}
309311

310-
if (!isValid(fProposalShell) && !control.isDisposed())
312+
if (!isValid(fProposalShell) && !control.isDisposed()) {
311313
fContentAssistSubjectControlAdapter.addKeyListener(fKeyListener);
314+
}
312315

313316
fInvocationOffset= fContentAssistSubjectControlAdapter.getSelectedRange().x;
314317
fFilterOffset= fInvocationOffset;
@@ -458,8 +461,9 @@ public void run() {
458461
try {
459462
while (true) {
460463
synchronized (fMutex) {
461-
if (fAutoActivationDelay != 0)
464+
if (fAutoActivationDelay != 0) {
462465
fMutex.wait(fAutoActivationDelay);
466+
}
463467
}
464468
Optional<Display> display= Optional.ofNullable(fContentAssistSubjectControlAdapter.getControl()).map(Control::getDisplay);
465469
display.ifPresent(d -> d.asyncExec(() -> displayProposals(true)));
@@ -472,8 +476,9 @@ public void run() {
472476

473477
protected void stop() {
474478
Thread threadToStop= fThread;
475-
if (threadToStop != null && threadToStop.isAlive())
479+
if (threadToStop != null && threadToStop.isAlive()) {
476480
threadToStop.interrupt();
481+
}
477482
}
478483

479484
}

bundles/org.eclipse.jface.text/src/org/eclipse/jface/text/contentassist/CompletionProposal.java

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -111,8 +111,9 @@ public Image getImage() {
111111

112112
@Override
113113
public String getDisplayString() {
114-
if (fDisplayString != null)
114+
if (fDisplayString != null) {
115115
return fDisplayString;
116+
}
116117
return fReplacementString;
117118
}
118119

0 commit comments

Comments
 (0)