Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorAlexander Kurtakov2016-01-25 13:16:17 +0000
committerAlexander Kurtakov2016-01-25 13:54:02 +0000
commitb0efd3ebae29de16550afd293a8a19930eaa8c40 (patch)
tree47adba3ebaabc234e524229abd69c85133823c99 /profiling
parent8014b15ab193c12c2430996d749dc1b7e94ed375 (diff)
downloadorg.eclipse.linuxtools-b0efd3ebae29de16550afd293a8a19930eaa8c40.tar.gz
org.eclipse.linuxtools-b0efd3ebae29de16550afd293a8a19930eaa8c40.tar.xz
org.eclipse.linuxtools-b0efd3ebae29de16550afd293a8a19930eaa8c40.zip
Lambdas convert.
A few more converts. Change-Id: Iaffb767812618eeae7779607d87f408078f45ef8 Signed-off-by: Alexander Kurtakov <akurtako@redhat.com> Reviewed-on: https://git.eclipse.org/r/65096 Tested-by: Hudson CI
Diffstat (limited to 'profiling')
-rw-r--r--profiling/org.eclipse.linuxtools.profiling.launch/src/org/eclipse/linuxtools/profiling/launch/ProfileLaunchShortcut.java71
-rw-r--r--profiling/org.eclipse.linuxtools.profiling.tests/src/org/eclipse/linuxtools/internal/profiling/tests/CProjectHelper.java62
-rw-r--r--profiling/org.eclipse.linuxtools.profiling.tests/src/org/eclipse/linuxtools/profiling/tests/AbstractTest.java16
3 files changed, 64 insertions, 85 deletions
diff --git a/profiling/org.eclipse.linuxtools.profiling.launch/src/org/eclipse/linuxtools/profiling/launch/ProfileLaunchShortcut.java b/profiling/org.eclipse.linuxtools.profiling.launch/src/org/eclipse/linuxtools/profiling/launch/ProfileLaunchShortcut.java
index a638d9bf2b..52f4993a2d 100644
--- a/profiling/org.eclipse.linuxtools.profiling.launch/src/org/eclipse/linuxtools/profiling/launch/ProfileLaunchShortcut.java
+++ b/profiling/org.eclipse.linuxtools.profiling.launch/src/org/eclipse/linuxtools/profiling/launch/ProfileLaunchShortcut.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2005, 2007 QNX Software Systems and others.
+ * Copyright (c) 2005, 2016 QNX Software Systems and others.
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at
@@ -201,43 +201,40 @@ public abstract class ProfileLaunchShortcut implements ILaunchShortcut {
} else {
final List<IBinary> results = new ArrayList<>();
ProgressMonitorDialog dialog = new ProgressMonitorDialog(getActiveWorkbenchShell());
- IRunnableWithProgress runnable = new IRunnableWithProgress() {
- @Override
- public void run(IProgressMonitor pm) throws InterruptedException {
- int nElements = elements.length;
- pm.beginTask(Messages.ProfileLaunchShortcut_Looking_for_executables, nElements);
- try {
- IProgressMonitor sub = SubMonitor.convert(pm, 1);
- for (int i = 0; i < nElements; i++) {
- if (elements[i] instanceof IAdaptable) {
- IResource r = ((IAdaptable) elements[i]).getAdapter(IResource.class);
- if (r != null) {
- ICProject cproject = CoreModel.getDefault().create(r.getProject());
- if (cproject != null) {
- try {
- IBinary[] bins = cproject.getBinaryContainer().getBinaries();
+ IRunnableWithProgress runnable = pm -> {
+ int nElements = elements.length;
+ pm.beginTask(Messages.ProfileLaunchShortcut_Looking_for_executables, nElements);
+ try {
+ IProgressMonitor sub = SubMonitor.convert(pm, 1);
+ for (int i = 0; i < nElements; i++) {
+ if (elements[i] instanceof IAdaptable) {
+ IResource r = ((IAdaptable) elements[i]).getAdapter(IResource.class);
+ if (r != null) {
+ ICProject cproject = CoreModel.getDefault().create(r.getProject());
+ if (cproject != null) {
+ try {
+ IBinary[] bins = cproject.getBinaryContainer().getBinaries();
- for (IBinary bin : bins) {
- if (bin.isExecutable()) {
- results.add(bin);
- }
- }
- } catch (CModelException e) {
- // TODO should this be simply ignored ?
- }
- }
- }
- }
- if (pm.isCanceled()) {
- throw new InterruptedException();
- }
- sub.done();
- }
- } finally {
- pm.done();
- }
- }
- };
+ for (IBinary bin1 : bins) {
+ if (bin1.isExecutable()) {
+ results.add(bin1);
+ }
+ }
+ } catch (CModelException e) {
+ // TODO should this be simply ignored ?
+ }
+ }
+ }
+ }
+ if (pm.isCanceled()) {
+ throw new InterruptedException();
+ }
+ sub.done();
+ }
+ } finally {
+ pm.done();
+ }
+ };
try {
dialog.run(true, true, runnable);
} catch (InterruptedException e) {
diff --git a/profiling/org.eclipse.linuxtools.profiling.tests/src/org/eclipse/linuxtools/internal/profiling/tests/CProjectHelper.java b/profiling/org.eclipse.linuxtools.profiling.tests/src/org/eclipse/linuxtools/internal/profiling/tests/CProjectHelper.java
index 740696d908..f812074dc5 100644
--- a/profiling/org.eclipse.linuxtools.profiling.tests/src/org/eclipse/linuxtools/internal/profiling/tests/CProjectHelper.java
+++ b/profiling/org.eclipse.linuxtools.profiling.tests/src/org/eclipse/linuxtools/internal/profiling/tests/CProjectHelper.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2005, 2010, 2012 IBM Corporation and others.
+ * Copyright (c) 2005, 2016 IBM Corporation and others.
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at
@@ -81,29 +81,25 @@ public class CProjectHelper {
private static ICProject createCProject2(final String projectName, String binFolderName) throws CoreException {
final IWorkspace ws = ResourcesPlugin.getWorkspace();
final ICProject newProject[] = new ICProject[1];
- ws.run(new IWorkspaceRunnable() {
-
- @Override
- public void run(IProgressMonitor monitor) throws CoreException {
- IWorkspaceRoot root = ws.getRoot();
- IProject project = root.getProject(projectName);
- if (!project.exists()) {
- project.create(null);
- } else {
- project.refreshLocal(IResource.DEPTH_INFINITE, null);
- }
- if (!project.isOpen()) {
- project.open(null);
- }
- if (!project.hasNature(CProjectNature.C_NATURE_ID)) {
- String projectId = PLUGIN_ID + ".TestProject"; //$NON-NLS-1$
- addNatureToProject(project, CProjectNature.C_NATURE_ID, null);
- CCorePlugin.getDefault().mapCProjectOwner(project, projectId, false);
- }
- addDefaultBinaryParser(project);
- newProject[0] = CCorePlugin.getDefault().getCoreModel().create(project);
- }
- }, null);
+ ws.run((IWorkspaceRunnable) monitor -> {
+ IWorkspaceRoot root = ws.getRoot();
+ IProject project = root.getProject(projectName);
+ if (!project.exists()) {
+ project.create(null);
+ } else {
+ project.refreshLocal(IResource.DEPTH_INFINITE, null);
+ }
+ if (!project.isOpen()) {
+ project.open(null);
+ }
+ if (!project.hasNature(CProjectNature.C_NATURE_ID)) {
+ String projectId = PLUGIN_ID + ".TestProject"; //$NON-NLS-1$
+ addNatureToProject(project, CProjectNature.C_NATURE_ID, null);
+ CCorePlugin.getDefault().mapCProjectOwner(project, projectId, false);
+ }
+ addDefaultBinaryParser(project);
+ newProject[0] = CCorePlugin.getDefault().getCoreModel().create(project);
+ }, null);
return newProject[0];
}
@@ -145,17 +141,13 @@ public class CProjectHelper {
public static ICProject createCCProject(final String projectName, final String binFolderName) throws CoreException {
final IWorkspace ws = ResourcesPlugin.getWorkspace();
final ICProject newProject[] = new ICProject[1];
- ws.run(new IWorkspaceRunnable() {
-
- @Override
- public void run(IProgressMonitor monitor) throws CoreException {
- ICProject cproject = createCProject2(projectName, binFolderName);
- if (!cproject.getProject().hasNature(CCProjectNature.CC_NATURE_ID)) {
- addNatureToProject(cproject.getProject(), CCProjectNature.CC_NATURE_ID, null);
- }
- newProject[0] = cproject;
- }
- }, null);
+ ws.run((IWorkspaceRunnable) monitor -> {
+ ICProject cproject = createCProject2(projectName, binFolderName);
+ if (!cproject.getProject().hasNature(CCProjectNature.CC_NATURE_ID)) {
+ addNatureToProject(cproject.getProject(), CCProjectNature.CC_NATURE_ID, null);
+ }
+ newProject[0] = cproject;
+ }, null);
return newProject[0];
}
diff --git a/profiling/org.eclipse.linuxtools.profiling.tests/src/org/eclipse/linuxtools/profiling/tests/AbstractTest.java b/profiling/org.eclipse.linuxtools.profiling.tests/src/org/eclipse/linuxtools/profiling/tests/AbstractTest.java
index 1c5716840f..1bbe058cf7 100644
--- a/profiling/org.eclipse.linuxtools.profiling.tests/src/org/eclipse/linuxtools/profiling/tests/AbstractTest.java
+++ b/profiling/org.eclipse.linuxtools.profiling.tests/src/org/eclipse/linuxtools/profiling/tests/AbstractTest.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2008-2015 Red Hat, Inc.
+ * Copyright (c) 2008, 2016 Red Hat, Inc.
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at
@@ -240,12 +240,7 @@ public abstract class AbstractTest {
Messages.getString("AbstractTest.Build_failed"), curProject.getName(), status.getMessage())); //$NON-NLS-1$
}
- IWorkspaceRunnable runnable = new IWorkspaceRunnable() {
- @Override
- public void run(IProgressMonitor monitor) throws CoreException {
- curProject.refreshLocal(IResource.DEPTH_INFINITE, null);
- }
- };
+ IWorkspaceRunnable runnable = monitor -> curProject.refreshLocal(IResource.DEPTH_INFINITE, null);
wsp.run(runnable, wsp.getRoot(), IWorkspace.AVOID_UPDATE, null);
}
@@ -299,12 +294,7 @@ public abstract class AbstractTest {
}
protected void deleteProject(final ICProject cproject) throws CoreException {
- ResourcesPlugin.getWorkspace().run(new IWorkspaceRunnable() {
- @Override
- public void run(IProgressMonitor monitor) {
- CProjectHelper.delete(cproject);
- }
- }, null);
+ ResourcesPlugin.getWorkspace().run((IWorkspaceRunnable) monitor -> CProjectHelper.delete(cproject), null);
}
protected ILaunchConfiguration createConfiguration(IProject proj)

Back to the top