Skip to content

Commit 0d1c75b

Browse files
committed
Add more tracing to QuickAccessContents
This change adds tracing in QuickAccessContents.updateProposals(), so that job creation order is also traced. In addition, previously added tracings are now guarded by the respective tracing flag. See: #4009
1 parent 56d707c commit 0d1c75b

1 file changed

Lines changed: 36 additions & 9 deletions

File tree

bundles/org.eclipse.ui.workbench/eclipseui/org/eclipse/ui/internal/quickaccess/QuickAccessContents.java

Lines changed: 36 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -147,6 +147,9 @@ private int computeNumberOfItems() {
147147
* @param filter The filter text to apply to results
148148
*/
149149
public void updateProposals(String filter) {
150+
if (Policy.DEBUG_QUICK_ACCESS) {
151+
trace("Updating proposals with filter: \"" + filter + "\""); //$NON-NLS-1$ //$NON-NLS-2$
152+
}
150153
if (computeProposalsJob != null) {
151154
computeProposalsJob.cancel();
152155
computeProposalsJob = null;
@@ -165,12 +168,15 @@ public void updateProposals(String filter) {
165168
final Job currentComputeEntriesJob = Job.create(computingMessage, theMonitor -> {
166169
entries.set(
167170
computeMatchingEntries(filter, perfectMatch, maxNumberOfItemsInTable, theMonitor));
168-
Tracing.printTrace(QuickAccessContents.class.getName(),
169-
"[" + Thread.currentThread() + "] Computed entries: " + //$NON-NLS-1$ //$NON-NLS-2$
170-
Stream.of(entries.get()).flatMap(List::stream).map(e -> e.element.getId()).toList());
171+
if (Policy.DEBUG_QUICK_ACCESS) {
172+
trace("Computed entries: " + toIds(entries)); //$NON-NLS-1$
173+
}
171174
return theMonitor.isCanceled() ? Status.CANCEL_STATUS : Status.OK_STATUS;
172175
});
173176
currentComputeEntriesJob.setPriority(Job.INTERACTIVE);
177+
if (Policy.DEBUG_QUICK_ACCESS) {
178+
trace("Will compute proposals with Job: " + currentComputeEntriesJob); //$NON-NLS-1$
179+
}
174180
// feedback is delayed in a job as we don't want to show it on every keystroke
175181
// but only when user seems to be waiting
176182
UIJob computingFeedbackJob = new UIJob(table.getDisplay(), QuickAccessMessages.QuickAccessContents_computeMatchingEntries_displayFeedback_jobName) {
@@ -186,16 +192,17 @@ public IStatus runInUIThread(IProgressMonitor monitor) {
186192
currentComputeEntriesJob.addJobChangeListener(new JobChangeAdapter() {
187193
@Override
188194
public void done(IJobChangeEvent event) {
189-
Tracing.printTrace(QuickAccessContents.class.getName(),
190-
"[" + Thread.currentThread() + "] Compute entries Job result: " + event.getResult()); //$NON-NLS-1$ //$NON-NLS-2$
195+
if (Policy.DEBUG_QUICK_ACCESS) {
196+
trace("Compute entries Job result: " + event.getResult() + //$NON-NLS-1$
197+
", Job: " + currentComputeEntriesJob + //$NON-NLS-1$
198+
", last proposals Job: " + computeProposalsJob + //$NON-NLS-1$
199+
", entries: " + toIds(entries)); //$NON-NLS-1$
200+
}
191201
computingFeedbackJob.cancel();
192202
if (computeProposalsJob == currentComputeEntriesJob && event.getResult().isOK()
193203
&& !table.isDisposed()) {
194204
if (Policy.DEBUG_QUICK_ACCESS) {
195-
Tracing.printTrace(QuickAccessContents.class.getName(),
196-
"[" + Thread.currentThread() + "] Setting quick access contents: " + //$NON-NLS-1$ //$NON-NLS-2$
197-
Stream.of(entries.get()).flatMap(List::stream).map(e -> e.element.getId())
198-
.toList());
205+
trace("Setting quick access contents: " + toIds(entries)); //$NON-NLS-1$
199206
}
200207
display.asyncExec(() -> {
201208
computingFeedbackJob.cancel();
@@ -205,6 +212,9 @@ public void done(IJobChangeEvent event) {
205212
}
206213
});
207214
this.computeProposalsJob = currentComputeEntriesJob;
215+
if (Policy.DEBUG_QUICK_ACCESS) {
216+
trace("Set last proposals Job: " + computeProposalsJob); //$NON-NLS-1$
217+
}
208218
currentComputeEntriesJob.schedule();
209219
computingFeedbackJob.schedule(200); // delay a bit so if proposals compute fast enough, we don't show feedback
210220
}
@@ -239,6 +249,9 @@ public void setShowAllMatches(boolean showAll) {
239249
if (showAllMatches != showAll) {
240250
showAllMatches = showAll;
241251
updateInfoLabel();
252+
if (Policy.DEBUG_QUICK_ACCESS) {
253+
trace("setShowAllMatches triggering proposals update"); //$NON-NLS-1$
254+
}
242255
updateProposals(filterText.getText().toLowerCase());
243256
}
244257
}
@@ -689,6 +702,9 @@ public void keyReleased(KeyEvent e) {
689702
});
690703
filterText.addModifyListener(e -> {
691704
String text = ((Text) e.widget).getText();
705+
if (Policy.DEBUG_QUICK_ACCESS) {
706+
trace("Modify listener triggering proposals update"); //$NON-NLS-1$
707+
}
692708
updateProposals(text);
693709
});
694710
}
@@ -759,6 +775,9 @@ public void controlResized(ControlEvent e) {
759775
e.display.timerExec(100, () -> {
760776
if (table != null && !table.isDisposed() && filterText != null
761777
&& !filterText.isDisposed()) {
778+
if (Policy.DEBUG_QUICK_ACCESS) {
779+
trace("Resize listener triggering proposals update"); //$NON-NLS-1$
780+
}
762781
updateProposals(filterText.getText().toLowerCase());
763782
}
764783
resized = false;
@@ -932,4 +951,12 @@ public Text getFilterText() {
932951
public Table getTable() {
933952
return table;
934953
}
954+
955+
private static List<String> toIds(AtomicReference<List<QuickAccessEntry>[]> entries) {
956+
return Stream.of(entries.get()).flatMap(List::stream).map(e -> e.element.getId()).toList();
957+
}
958+
959+
private static void trace(String message) {
960+
Tracing.printTrace(QuickAccessContents.class.getName(), " | " + Thread.currentThread() + " | " + message); //$NON-NLS-1$ //$NON-NLS-2$
961+
}
935962
}

0 commit comments

Comments
 (0)