Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorLars Vogel2018-02-05 15:05:17 -0500
committerLars Vogel2018-02-05 15:05:17 -0500
commit0dc062f382827e272c08169e8ad9278e19a87761 (patch)
treec2e919e7917ab0be2f10554ff9fc774ed3f7a4d2
parent538d6e9e80239627f53ad500444d6e4fbe6820a2 (diff)
downloadeclipse.platform.text-0dc062f382827e272c08169e8ad9278e19a87761.tar.gz
eclipse.platform.text-0dc062f382827e272c08169e8ad9278e19a87761.tar.xz
eclipse.platform.text-0dc062f382827e272c08169e8ad9278e19a87761.zip
Bug 530751 - Use lambdas in org.eclipse.search
Part 1 Change-Id: Ifa78eccabb7bd77dc2bff7069b83e9567ddee562 Signed-off-by: Lars Vogel <Lars.Vogel@vogella.com>
-rw-r--r--org.eclipse.search/search/org/eclipse/search/internal/core/text/TextSearchVisitor.java30
-rw-r--r--org.eclipse.search/search/org/eclipse/search/internal/ui/text/DecoratingFileSearchLabelProvider.java7
-rw-r--r--org.eclipse.search/search/org/eclipse/search/internal/ui/text/FileLabelProvider.java7
-rw-r--r--org.eclipse.search/search/org/eclipse/search/internal/ui/text/FileSearchPage.java14
-rw-r--r--org.eclipse.search/search/org/eclipse/search/internal/ui/text/ReplaceConfigurationPage.java9
-rw-r--r--org.eclipse.search/search/org/eclipse/search/internal/ui/text/SearchResultUpdater.java34
-rw-r--r--org.eclipse.search/search/org/eclipse/search/internal/ui/text/TextSearchPage.java33
7 files changed, 42 insertions, 92 deletions
diff --git a/org.eclipse.search/search/org/eclipse/search/internal/core/text/TextSearchVisitor.java b/org.eclipse.search/search/org/eclipse/search/internal/core/text/TextSearchVisitor.java
index bdb76c70f..b798c00aa 100644
--- a/org.eclipse.search/search/org/eclipse/search/internal/core/text/TextSearchVisitor.java
+++ b/org.eclipse.search/search/org/eclipse/search/internal/core/text/TextSearchVisitor.java
@@ -19,7 +19,6 @@ import java.nio.charset.UnsupportedCharsetException;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collections;
-import java.util.Comparator;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
@@ -375,23 +374,20 @@ public class TextSearchVisitor {
System.arraycopy(files, 0, filesByLocation, 0, files.length);
// Sorting files to search by location allows to more easily reuse
// search results from one file to the other when they have same location
- Arrays.sort(filesByLocation, new Comparator<IFile>() {
- @Override
- public int compare(IFile o1, IFile o2) {
- if (o1 == o2) {
- return 0;
- }
- if (o1.getLocation() == o2.getLocation()) {
- return 0;
- }
- if (o1.getLocation() == null) {
- return +1;
- }
- if (o2.getLocation() == null) {
- return -1;
- }
- return o1.getLocation().toString().compareTo(o2.getLocation().toString());
+ Arrays.sort(filesByLocation, (o1, o2) -> {
+ if (o1 == o2) {
+ return 0;
+ }
+ if (o1.getLocation() == o2.getLocation()) {
+ return 0;
+ }
+ if (o1.getLocation() == null) {
+ return +1;
+ }
+ if (o2.getLocation() == null) {
+ return -1;
}
+ return o1.getLocation().toString().compareTo(o2.getLocation().toString());
});
for (int first= 0; first < filesByLocation.length; first += filesPerJob) {
int end= Math.min(filesByLocation.length, first + filesPerJob);
diff --git a/org.eclipse.search/search/org/eclipse/search/internal/ui/text/DecoratingFileSearchLabelProvider.java b/org.eclipse.search/search/org/eclipse/search/internal/ui/text/DecoratingFileSearchLabelProvider.java
index 32ad46749..3d4c4e4bd 100644
--- a/org.eclipse.search/search/org/eclipse/search/internal/ui/text/DecoratingFileSearchLabelProvider.java
+++ b/org.eclipse.search/search/org/eclipse/search/internal/ui/text/DecoratingFileSearchLabelProvider.java
@@ -90,12 +90,7 @@ public class DecoratingFileSearchLabelProvider extends DecoratingStyledCellLabel
String property= event.getProperty();
if (property.equals(JFacePreferences.QUALIFIER_COLOR) || property.equals(JFacePreferences.COUNTER_COLOR) || property.equals(JFacePreferences.DECORATIONS_COLOR)
|| property.equals(HIGHLIGHT_BG_COLOR_NAME) || property.equals(IWorkbenchPreferenceConstants.USE_COLORED_LABELS)) {
- Display.getDefault().asyncExec(new Runnable() {
- @Override
- public void run() {
- refresh();
- }
- });
+ Display.getDefault().asyncExec(() -> refresh());
}
}
diff --git a/org.eclipse.search/search/org/eclipse/search/internal/ui/text/FileLabelProvider.java b/org.eclipse.search/search/org/eclipse/search/internal/ui/text/FileLabelProvider.java
index 079404508..da630d72e 100644
--- a/org.eclipse.search/search/org/eclipse/search/internal/ui/text/FileLabelProvider.java
+++ b/org.eclipse.search/search/org/eclipse/search/internal/ui/text/FileLabelProvider.java
@@ -59,12 +59,7 @@ public class FileLabelProvider extends LabelProvider implements IStyledLabelProv
fOrder= orderFlag;
fPage= page;
fLineMatchImage= SearchPluginImages.get(SearchPluginImages.IMG_OBJ_TEXT_SEARCH_LINE);
- fMatchComparator= new Comparator<FileMatch>() {
- @Override
- public int compare(FileMatch o1, FileMatch o2) {
- return o1.getOriginalOffset() - o2.getOriginalOffset();
- }
- };
+ fMatchComparator= (o1, o2) -> o1.getOriginalOffset() - o2.getOriginalOffset();
}
public void setOrder(int orderFlag) {
diff --git a/org.eclipse.search/search/org/eclipse/search/internal/ui/text/FileSearchPage.java b/org.eclipse.search/search/org/eclipse/search/internal/ui/text/FileSearchPage.java
index 96d561365..6d4252855 100644
--- a/org.eclipse.search/search/org/eclipse/search/internal/ui/text/FileSearchPage.java
+++ b/org.eclipse.search/search/org/eclipse/search/internal/ui/text/FileSearchPage.java
@@ -126,12 +126,7 @@ public class FileSearchPage extends AbstractTextSearchViewPage implements IAdapt
private static final String[] SHOW_IN_TARGETS= new String[] { IPageLayout.ID_RES_NAV };
- private static final IShowInTargetList SHOW_IN_TARGET_LIST= new IShowInTargetList() {
- @Override
- public String[] getShowInTargetIds() {
- return SHOW_IN_TARGETS;
- }
- };
+ private static final IShowInTargetList SHOW_IN_TARGET_LIST= () -> SHOW_IN_TARGETS;
public FileSearchPage() {
fSortByNameAction= new SortAction(SearchMessages.FileSearchPage_sort_name_label, this, FileLabelProvider.SHOW_LABEL_PATH);
@@ -393,12 +388,7 @@ public class FileSearchPage extends AbstractTextSearchViewPage implements IAdapt
newSelection.add(element);
}
- return (T) new IShowInSource() {
- @Override
- public ShowInContext getShowInContext() {
- return new ShowInContext(null, new StructuredSelection(new ArrayList<>(newSelection)));
- }
- };
+ return (T) (IShowInSource) () -> new ShowInContext(null, new StructuredSelection(new ArrayList<>(newSelection)));
}
return null;
}
diff --git a/org.eclipse.search/search/org/eclipse/search/internal/ui/text/ReplaceConfigurationPage.java b/org.eclipse.search/search/org/eclipse/search/internal/ui/text/ReplaceConfigurationPage.java
index ee0710c58..a2efdb889 100644
--- a/org.eclipse.search/search/org/eclipse/search/internal/ui/text/ReplaceConfigurationPage.java
+++ b/org.eclipse.search/search/org/eclipse/search/internal/ui/text/ReplaceConfigurationPage.java
@@ -14,8 +14,6 @@ import java.util.ArrayList;
import java.util.regex.PatternSyntaxException;
import org.eclipse.swt.SWT;
-import org.eclipse.swt.events.ModifyEvent;
-import org.eclipse.swt.events.ModifyListener;
import org.eclipse.swt.events.SelectionAdapter;
import org.eclipse.swt.events.SelectionEvent;
import org.eclipse.swt.layout.GridData;
@@ -103,12 +101,7 @@ public class ReplaceConfigurationPage extends UserInputWizardPage {
gd.widthHint= convertWidthInCharsToPixels(50);
fTextField.setLayoutData(gd);
fTextField.setFocus();
- fTextField.addModifyListener(new ModifyListener() {
- @Override
- public void modifyText(ModifyEvent e) {
- updateOKStatus();
- }
- });
+ fTextField.addModifyListener(e -> updateOKStatus());
IDialogSettings settings= SearchPlugin.getDefault().getDialogSettings().getSection(SETTINGS_GROUP);
if (settings != null) {
diff --git a/org.eclipse.search/search/org/eclipse/search/internal/ui/text/SearchResultUpdater.java b/org.eclipse.search/search/org/eclipse/search/internal/ui/text/SearchResultUpdater.java
index 100baa75d..2b62c590e 100644
--- a/org.eclipse.search/search/org/eclipse/search/internal/ui/text/SearchResultUpdater.java
+++ b/org.eclipse.search/search/org/eclipse/search/internal/ui/text/SearchResultUpdater.java
@@ -17,7 +17,6 @@ import org.eclipse.core.resources.IResource;
import org.eclipse.core.resources.IResourceChangeEvent;
import org.eclipse.core.resources.IResourceChangeListener;
import org.eclipse.core.resources.IResourceDelta;
-import org.eclipse.core.resources.IResourceDeltaVisitor;
import org.eclipse.core.resources.ResourcesPlugin;
import org.eclipse.search.internal.ui.SearchPlugin;
@@ -45,25 +44,22 @@ public class SearchResultUpdater implements IResourceChangeListener, IQueryListe
private void handleDelta(IResourceDelta d) {
try {
- d.accept(new IResourceDeltaVisitor() {
- @Override
- public boolean visit(IResourceDelta delta) throws CoreException {
- switch (delta.getKind()) {
- case IResourceDelta.ADDED :
- return false;
- case IResourceDelta.REMOVED :
- IResource res= delta.getResource();
- if (res instanceof IFile) {
- Match[] matches= fResult.getMatches(res);
- fResult.removeMatches(matches);
- }
- break;
- case IResourceDelta.CHANGED :
- // handle changed resource
- break;
- }
- return true;
+ d.accept(delta -> {
+ switch (delta.getKind()) {
+ case IResourceDelta.ADDED :
+ return false;
+ case IResourceDelta.REMOVED :
+ IResource res= delta.getResource();
+ if (res instanceof IFile) {
+ Match[] matches= fResult.getMatches(res);
+ fResult.removeMatches(matches);
+ }
+ break;
+ case IResourceDelta.CHANGED :
+ // handle changed resource
+ break;
}
+ return true;
});
} catch (CoreException e) {
SearchPlugin.log(e);
diff --git a/org.eclipse.search/search/org/eclipse/search/internal/ui/text/TextSearchPage.java b/org.eclipse.search/search/org/eclipse/search/internal/ui/text/TextSearchPage.java
index 21e3f295e..a4b997bc6 100644
--- a/org.eclipse.search/search/org/eclipse/search/internal/ui/text/TextSearchPage.java
+++ b/org.eclipse.search/search/org/eclipse/search/internal/ui/text/TextSearchPage.java
@@ -26,8 +26,6 @@ import java.util.regex.PatternSyntaxException;
import org.eclipse.swt.SWT;
import org.eclipse.swt.custom.CLabel;
-import org.eclipse.swt.events.ModifyEvent;
-import org.eclipse.swt.events.ModifyListener;
import org.eclipse.swt.events.SelectionAdapter;
import org.eclipse.swt.events.SelectionEvent;
import org.eclipse.swt.layout.GridData;
@@ -292,16 +290,13 @@ public class TextSearchPage extends DialogPage implements ISearchPage, IReplaceP
ErrorDialog.openError(getShell(), SearchMessages.TextSearchPage_replace_searchproblems_title, SearchMessages.TextSearchPage_replace_runproblem_message, status);
}
- Display.getCurrent().asyncExec(new Runnable() {
- @Override
- public void run() {
- ISearchResultViewPart view= NewSearchUI.activateSearchResultView();
- if (view != null) {
- ISearchResultPage page= view.getActivePage();
- if (page instanceof FileSearchPage) {
- FileSearchPage filePage= (FileSearchPage) page;
- new ReplaceAction(filePage.getSite().getShell(), (FileSearchResult)filePage.getInput(), null).run();
- }
+ Display.getCurrent().asyncExec(() -> {
+ ISearchResultViewPart view= NewSearchUI.activateSearchResultView();
+ if (view != null) {
+ ISearchResultPage page= view.getActivePage();
+ if (page instanceof FileSearchPage) {
+ FileSearchPage filePage= (FileSearchPage) page;
+ new ReplaceAction(filePage.getSite().getShell(), (FileSearchResult)filePage.getInput(), null).run();
}
}
});
@@ -518,12 +513,7 @@ public class TextSearchPage extends DialogPage implements ISearchPage, IReplaceP
}
});
// add some listeners for regex syntax checking
- fPattern.addModifyListener(new ModifyListener() {
- @Override
- public void modifyText(ModifyEvent e) {
- updateOKStatus();
- }
- });
+ fPattern.addModifyListener(e -> updateOKStatus());
fPattern.setFont(group.getFont());
GridData data= new GridData(GridData.FILL, GridData.FILL, true, false, 1, 2);
data.widthHint= convertWidthInCharsToPixels(50);
@@ -695,12 +685,7 @@ public class TextSearchPage extends DialogPage implements ISearchPage, IReplaceP
label.setFont(group.getFont());
fExtensions= new Combo(group, SWT.SINGLE | SWT.BORDER);
- fExtensions.addModifyListener(new ModifyListener() {
- @Override
- public void modifyText(ModifyEvent e) {
- updateOKStatus();
- }
- });
+ fExtensions.addModifyListener(e -> updateOKStatus());
GridData data= new GridData(GridData.FILL, GridData.FILL, true, false, 1, 1);
data.widthHint= convertWidthInCharsToPixels(50);
fExtensions.setLayoutData(data);

Back to the top