Skip to content

Commit c0da6d7

Browse files
Maximilian WittmerMaximilian Wittmer
authored andcommitted
Find in the MarkersView
1 parent f33cfd8 commit c0da6d7

File tree

3 files changed

+32
-21
lines changed

3 files changed

+32
-21
lines changed

bundles/org.eclipse.ui.ide/src/org/eclipse/ui/internal/views/markers/ExtendedMarkersView.java

Lines changed: 28 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,7 @@
4545
import org.eclipse.jface.text.IFindReplaceTarget;
4646
import org.eclipse.jface.text.IFindReplaceTargetExtension5;
4747
import org.eclipse.jface.util.OpenStrategy;
48+
import org.eclipse.jface.viewers.ColumnLabelProvider;
4849
import org.eclipse.jface.viewers.ColumnPixelData;
4950
import org.eclipse.jface.viewers.EditingSupport;
5051
import org.eclipse.jface.viewers.IContentProvider;
@@ -55,6 +56,8 @@
5556
import org.eclipse.jface.viewers.ITreeSelection;
5657
import org.eclipse.jface.viewers.StructuredSelection;
5758
import org.eclipse.jface.viewers.TableLayout;
59+
import org.eclipse.jface.viewers.TreePath;
60+
import org.eclipse.jface.viewers.TreeSelection;
5861
import org.eclipse.jface.viewers.TreeViewer;
5962
import org.eclipse.jface.viewers.TreeViewerColumn;
6063
import org.eclipse.jface.window.Window;
@@ -137,10 +140,12 @@
137140
* specification of the view. If this list is left out the problems
138141
* markerContentProvider will be used.
139142
*
143+
* @param <auto>
144+
*
140145
* @since 3.4
141146
*
142147
*/
143-
public class ExtendedMarkersView extends ViewPart implements IFindReplaceTarget, IFindReplaceTargetExtension5 {
148+
public class ExtendedMarkersView<auto> extends ViewPart implements IFindReplaceTarget, IFindReplaceTargetExtension5 {
144149

145150
/**
146151
* The Markers View Update Job Family
@@ -1796,7 +1801,6 @@ public void updateLayout() {
17961801
public void endInlineSession() {
17971802
findComposite.dispose();
17981803
findComposite = null;
1799-
;
18001804
}
18011805

18021806
@Override
@@ -1808,34 +1812,39 @@ public boolean canPerformFind() {
18081812
@Override
18091813
public int findAndSelect(int widgetOffset, String findString, boolean searchForward, boolean caseSensitive,
18101814
boolean wholeWord) {
1811-
IMarker[] markers = getAllMarkers();
1812-
int foundIndex = 0;
1813-
1814-
widgetOffset = 0;
18151815

1816-
try {
1817-
for (int searchIndex = widgetOffset; searchIndex < markers.length; searchIndex++) {
1818-
String markerMessage = (String) markers[searchIndex].getAttribute("message"); //$NON-NLS-1$
1819-
if (markerMessage.contains(findString)) {
1820-
foundIndex = searchIndex;
1821-
break;
1816+
var tree = viewer.getTree();
1817+
var items = tree.getItems();
1818+
ArrayList<TreePath> selection = new ArrayList<>();
1819+
for (var item : items) {
1820+
// TODO: has children?
1821+
for (var child : ((MarkerViewerContentProvider) viewer.getContentProvider()).getElements(item)) {
1822+
MarkerSupportItem[] markerCategoryChildren = ((MarkerCategory) child).getChildren();
1823+
for (var markerSupportItem : markerCategoryChildren) {
1824+
String markerMessage = markerSupportItem.getMarker().getAttribute(IMarker.MESSAGE,
1825+
MarkerSupportInternalUtilities.UNKNOWN_ATRRIBTE_VALUE_STRING);
1826+
if (markerMessage.contains(findString)) {
1827+
ArrayList<Object> selectionPath = new ArrayList<>();
1828+
selectionPath.add(item);
1829+
selectionPath.add(markerSupportItem);
1830+
selection.add(new TreePath(selectionPath.toArray()));
1831+
}
18221832
}
1833+
var text = ((ColumnLabelProvider) viewer.getLabelProvider(1)).getText(child);
1834+
System.out.println(text);
18231835
}
1824-
} catch (Exception e) {
1825-
18261836
}
18271837

1828-
viewer.setSelection(new StructuredSelection(new Object[] { markers[foundIndex] }), true);
1829-
1838+
viewer.setSelection(new TreeSelection(selection.toArray(new TreePath[0])));
18301839

1831-
return foundIndex;
1840+
// very messy! TODO revisit how inline findreplace works
1841+
return 0;
18321842
}
18331843

18341844
@Override
18351845
public Point getSelection() {
1836-
IStructuredSelection selection = (IStructuredSelection) viewer.getSelection();
18371846

1838-
return new Point(selection.getFirstElement().hashCode(), 0);
1847+
return new Point(0, 0);
18391848
}
18401849

18411850
@Override

bundles/org.eclipse.ui.workbench.texteditor/src/org/eclipse/ui/texteditor/FindReplacer.java

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -150,6 +150,7 @@ public int selectAll(String findString) {
150150
selectedRegions.add(new Region(selection.x, selection.y));
151151
replaceCount++;
152152
position = selection.x + selection.y;
153+
index = -1;
153154
}
154155
} while (index != -1);
155156
if (target instanceof IFindReplaceTargetExtension4) {

bundles/org.eclipse.ui.workbench.texteditor/src/org/eclipse/ui/texteditor/InlineFindReplaceComponent.java

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -269,10 +269,11 @@ public void keyTraversed(final TraverseEvent event) {
269269
}
270270
}
271271
});
272-
searchBar.addModifyListener(new ModifyListener() { // MW -> @HeikoKlare we need to revisit this - this is very
273-
// buggy!
272+
searchBar.addModifyListener(new ModifyListener() {
274273
@Override
275274
public void modifyText(ModifyEvent e) {
275+
timer.cancel();
276+
timer = new Timer();
276277
timer.schedule(new TimerTask() {
277278
@Override
278279
public void run() {

0 commit comments

Comments
 (0)