diff options
author | Alexander Kurtakov | 2017-02-27 14:29:34 +0000 |
---|---|---|
committer | Alexander Kurtakov | 2017-02-27 14:29:34 +0000 |
commit | 194eae6d5ad097ac7bb614004c8bb5b3f342e0c5 (patch) | |
tree | 4fe7fde3a06ee9b0775028d41cd1b67a6bfc8ea2 /core/plugins/org.eclipse.dltk.core/model/org/eclipse/dltk/internal/core/ModelManager.java | |
parent | 4f2338266f5dd9dcac0adbd8a2fdc491b29cc409 (diff) | |
download | org.eclipse.dltk.core-194eae6d5ad097ac7bb614004c8bb5b3f342e0c5.tar.gz org.eclipse.dltk.core-194eae6d5ad097ac7bb614004c8bb5b3f342e0c5.tar.xz org.eclipse.dltk.core-194eae6d5ad097ac7bb614004c8bb5b3f342e0c5.zip |
Convert various listeners to lambdas.
Change-Id: I1312d6a12136b7e782429609ccd47888e1bc0293
Signed-off-by: Alexander Kurtakov <akurtako@redhat.com>
Diffstat (limited to 'core/plugins/org.eclipse.dltk.core/model/org/eclipse/dltk/internal/core/ModelManager.java')
-rw-r--r-- | core/plugins/org.eclipse.dltk.core/model/org/eclipse/dltk/internal/core/ModelManager.java | 190 |
1 files changed, 82 insertions, 108 deletions
diff --git a/core/plugins/org.eclipse.dltk.core/model/org/eclipse/dltk/internal/core/ModelManager.java b/core/plugins/org.eclipse.dltk.core/model/org/eclipse/dltk/internal/core/ModelManager.java index d7e98593a..15215f3f9 100644 --- a/core/plugins/org.eclipse.dltk.core/model/org/eclipse/dltk/internal/core/ModelManager.java +++ b/core/plugins/org.eclipse.dltk.core/model/org/eclipse/dltk/internal/core/ModelManager.java @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2005, 2016 IBM Corporation and others. + * Copyright (c) 2005, 2017 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 @@ -57,7 +57,6 @@ import org.eclipse.core.runtime.jobs.Job; import org.eclipse.core.runtime.preferences.DefaultScope; import org.eclipse.core.runtime.preferences.IEclipsePreferences; import org.eclipse.core.runtime.preferences.IEclipsePreferences.IPreferenceChangeListener; -import org.eclipse.core.runtime.preferences.IEclipsePreferences.PreferenceChangeEvent; import org.eclipse.core.runtime.preferences.IPreferencesService; import org.eclipse.core.runtime.preferences.InstanceScope; import org.eclipse.dltk.compiler.problem.IProblem; @@ -1279,22 +1278,14 @@ public class ModelManager implements ISaveParticipant { // Initialize eclipse preferences initializePreferences(); // Listen to preference changes - this.propertyListener = new IEclipsePreferences.IPreferenceChangeListener() { - @Override - public void preferenceChange(PreferenceChangeEvent event) { - ModelManager.this.optionsCache = null; - } - }; + this.propertyListener = event -> ModelManager.this.optionsCache = null; installPreferenceChangeListener(DLTKCore.PLUGIN_ID, this.propertyListener); // listen for encoding changes (see // https://bugs.eclipse.org/bugs/show_bug.cgi?id=255501 ) - this.resourcesPropertyListener = new IEclipsePreferences.IPreferenceChangeListener() { - @Override - public void preferenceChange(PreferenceChangeEvent event) { - if (ResourcesPlugin.PREF_ENCODING.equals(event.getKey())) { - ModelManager.this.optionsCache = null; - } + this.resourcesPropertyListener = event -> { + if (ResourcesPlugin.PREF_ENCODING.equals(event.getKey())) { + ModelManager.this.optionsCache = null; } }; installPreferenceChangeListener(ResourcesPlugin.getPlugin() @@ -1327,24 +1318,19 @@ public class ModelManager implements ISaveParticipant { // add save participant and process delta atomically // see // https://bugs.eclipse.org/bugs/show_bug.cgi?id=59937 - workspace.run(new IWorkspaceRunnable() { - @Override - public void run(IProgressMonitor progress) - throws CoreException { - ISavedState savedState = workspace - .addSaveParticipant( - DLTKCore.getPlugin(), - ModelManager.this); - if (savedState != null) { - // the event type coming from the saved - // state is always POST_AUTO_BUILD - // force it to be POST_CHANGE so that the - // delta processor can handle it - ModelManager.this.deltaState - .getDeltaProcessor().overridenEventType = IResourceChangeEvent.POST_CHANGE; - savedState - .processResourceChangeEvents(ModelManager.this.deltaState); - } + workspace.run(progress -> { + ISavedState savedState = workspace + .addSaveParticipant(DLTKCore.getPlugin(), + ModelManager.this); + if (savedState != null) { + // the event type coming from the saved + // state is always POST_AUTO_BUILD + // force it to be POST_CHANGE so that the + // delta processor can handle it + ModelManager.this.deltaState + .getDeltaProcessor().overridenEventType = IResourceChangeEvent.POST_CHANGE; + savedState.processResourceChangeEvents( + ModelManager.this.deltaState); } }, monitor); } catch (CoreException e) { @@ -1921,34 +1907,32 @@ public class ModelManager implements ISaveParticipant { // if possible run inside an IWokspaceRunnable with AVOID_UPATE to // avoid unwanted builds // (see https://bugs.eclipse.org/bugs/show_bug.cgi?id=118507) - IWorkspaceRunnable runnable = new IWorkspaceRunnable() { - public void run(IProgressMonitor monitor) throws CoreException { - Set keys = allContainerPaths.keySet(); - int length = keys.size(); - IScriptProject[] scriptProjects = new IScriptProject[length]; // clone - // as - // the - // following - // will - // have - // a - // side - // effect - keys.toArray(scriptProjects); - for (int i = 0; i < length; i++) { - IScriptProject scriptProject = scriptProjects[i]; - HashSet pathSet = (HashSet) allContainerPaths - .get(scriptProject); - if (pathSet == null) - continue; - int length2 = pathSet.size(); - IPath[] paths = new IPath[length2]; - pathSet.toArray(paths); // clone as the following will - // have a side effect - for (int j = 0; j < length2; j++) { - IPath path = paths[j]; - initializeContainer(scriptProject, path); - } + IWorkspaceRunnable runnable = monitor -> { + Set keys = allContainerPaths.keySet(); + int length = keys.size(); + IScriptProject[] scriptProjects = new IScriptProject[length]; // clone + // as + // the + // following + // will + // have + // a + // side + // effect + keys.toArray(scriptProjects); + for (int i = 0; i < length; i++) { + IScriptProject scriptProject = scriptProjects[i]; + HashSet pathSet = (HashSet) allContainerPaths + .get(scriptProject); + if (pathSet == null) + continue; + int length2 = pathSet.size(); + IPath[] paths = new IPath[length2]; + pathSet.toArray(paths); // clone as the following will + // have a side effect + for (int j = 0; j < length2; j++) { + IPath path = paths[j]; + initializeContainer(scriptProject, path); } } }; @@ -2203,16 +2187,14 @@ public class ModelManager implements ISaveParticipant { " project: " + project.getElementName() + '\n' + //$NON-NLS-1$ " container path: " + containerPath + '\n' + //$NON-NLS-1$ " classpath entries: {\n" + //$NON-NLS-1$ - Util.toString(classpathEntries, new Util.Displayable() { - public String displayString(Object o) { - StringBuffer buffer = new StringBuffer(" "); //$NON-NLS-1$ - if (o == null) { - buffer.append("<null>"); //$NON-NLS-1$ - return buffer.toString(); - } - buffer.append(o); + Util.toString(classpathEntries, o -> { + StringBuffer buffer = new StringBuffer(" "); //$NON-NLS-1$ + if (o == null) { + buffer.append("<null>"); //$NON-NLS-1$ return buffer.toString(); } + buffer.append(o); + return buffer.toString(); }) + "\n }" //$NON-NLS-1$ ); } @@ -2275,55 +2257,47 @@ public class ModelManager implements ISaveParticipant { + containerPath + '\n' + " projects: {" //$NON-NLS-1$ - + Util.toString(projects, new Util.Displayable() { - public String displayString(Object o) { - return ((IScriptProject) o) - .getElementName(); - } - }) + + Util.toString(projects, + o -> ((IScriptProject) o).getElementName()) + "}\n values on previous session: {\n" + //$NON-NLS-1$ Util.toString(respectiveContainers, - new Util.Displayable() { - public String displayString(Object o) { - StringBuffer buffer = new StringBuffer( - " "); //$NON-NLS-1$ - if (o == null) { - buffer.append("<null>"); //$NON-NLS-1$ - return buffer.toString(); - } - buffer.append(container - .getDescription()); - buffer.append(" {\n"); //$NON-NLS-1$ - for (int j = 0; j < oldEntries.length; j++) { - buffer.append(" "); //$NON-NLS-1$ - buffer.append(oldEntries[j]); - buffer.append('\n'); - } - buffer.append(" }"); //$NON-NLS-1$ + o -> { + StringBuffer buffer = new StringBuffer( + " "); //$NON-NLS-1$ + if (o == null) { + buffer.append("<null>"); //$NON-NLS-1$ return buffer.toString(); } + buffer.append( + container.getDescription()); + buffer.append(" {\n"); //$NON-NLS-1$ + for (int j = 0; j < oldEntries.length; j++) { + buffer.append(" "); //$NON-NLS-1$ + buffer.append(oldEntries[j]); + buffer.append('\n'); + } + buffer.append(" }"); //$NON-NLS-1$ + return buffer.toString(); }) + "}\n new values: {\n" + //$NON-NLS-1$ Util.toString(respectiveContainers, - new Util.Displayable() { - public String displayString(Object o) { - StringBuffer buffer = new StringBuffer( - " "); //$NON-NLS-1$ - if (o == null) { - buffer.append("<null>"); //$NON-NLS-1$ - return buffer.toString(); - } - buffer.append(container - .getDescription()); - buffer.append(" {\n"); //$NON-NLS-1$ - for (int j = 0; j < newEntries.length; j++) { - buffer.append(" "); //$NON-NLS-1$ - buffer.append(newEntries[j]); - buffer.append('\n'); - } - buffer.append(" }"); //$NON-NLS-1$ + o -> { + StringBuffer buffer = new StringBuffer( + " "); //$NON-NLS-1$ + if (o == null) { + buffer.append("<null>"); //$NON-NLS-1$ return buffer.toString(); } + buffer.append( + container.getDescription()); + buffer.append(" {\n"); //$NON-NLS-1$ + for (int j = 0; j < newEntries.length; j++) { + buffer.append(" "); //$NON-NLS-1$ + buffer.append(newEntries[j]); + buffer.append('\n'); + } + buffer.append(" }"); //$NON-NLS-1$ + return buffer.toString(); }) + "\n }"); //$NON-NLS-1$ } return false; |