diff options
author | Quentin Le Menez | 2019-06-14 12:54:36 +0000 |
---|---|---|
committer | Quentin Le Menez | 2019-08-06 13:24:07 +0000 |
commit | 1d290819592299eb05c29550075cfb631f5043c5 (patch) | |
tree | b16f259b2102d2501dde9930ebf19c7fd7b86d08 | |
parent | fa1f3e5c6fbd3dd4b65e11fa85e8ff78a9a959b0 (diff) | |
download | org.eclipse.papyrus-1d290819592299eb05c29550075cfb631f5043c5.tar.gz org.eclipse.papyrus-1d290819592299eb05c29550075cfb631f5043c5.tar.xz org.eclipse.papyrus-1d290819592299eb05c29550075cfb631f5043c5.zip |
Bug 549266 - [Releng] Guava 27.1 compatibility patch
- Add guava Futures compilation corrections (addCallback, transform, transformAsync)
Change-Id: I236e3ba5cf9f4068168f5203688e99ac00fde4e8
Signed-off-by: Quentin Le Menez <quentin.lemenez@cea.fr>
12 files changed, 130 insertions, 108 deletions
diff --git a/plugins/infra/core/org.eclipse.papyrus.infra.tools/src/org/eclipse/papyrus/infra/tools/Activator.java b/plugins/infra/core/org.eclipse.papyrus.infra.tools/src/org/eclipse/papyrus/infra/tools/Activator.java index b04b7dec9d2..6ee032a350a 100644 --- a/plugins/infra/core/org.eclipse.papyrus.infra.tools/src/org/eclipse/papyrus/infra/tools/Activator.java +++ b/plugins/infra/core/org.eclipse.papyrus.infra.tools/src/org/eclipse/papyrus/infra/tools/Activator.java @@ -11,7 +11,7 @@ * Contributors: * CEA LIST - Initial API and implementation * Christian W. Damus = bug 485220 - * + * *****************************************************************************/ package org.eclipse.papyrus.infra.tools; @@ -24,7 +24,7 @@ import org.osgi.util.tracker.ServiceTracker; /** * The activator class controls the plug-in life cycle - * + * * @since 2.0 */ public class Activator extends Plugin { diff --git a/plugins/infra/core/org.eclipse.papyrus.infra.tools/src/org/eclipse/papyrus/infra/tools/util/Suppliers2.java b/plugins/infra/core/org.eclipse.papyrus.infra.tools/src/org/eclipse/papyrus/infra/tools/util/Suppliers2.java index ec802230c36..9c315809a54 100644 --- a/plugins/infra/core/org.eclipse.papyrus.infra.tools/src/org/eclipse/papyrus/infra/tools/util/Suppliers2.java +++ b/plugins/infra/core/org.eclipse.papyrus.infra.tools/src/org/eclipse/papyrus/infra/tools/util/Suppliers2.java @@ -1,6 +1,6 @@ /***************************************************************************** * Copyright (c) 2015 Christian W. Damus and others. - * + * * All rights reserved. This program and the accompanying materials * are made available under the terms of the Eclipse Public License 2.0 * which accompanies this distribution, and is available at @@ -10,7 +10,7 @@ * * Contributors: * Christian W. Damus - Initial API and implementation - * + * *****************************************************************************/ package org.eclipse.papyrus.infra.tools.util; @@ -26,6 +26,7 @@ import com.google.common.base.Suppliers; import com.google.common.util.concurrent.FutureCallback; import com.google.common.util.concurrent.Futures; import com.google.common.util.concurrent.ListenableFuture; +import com.google.common.util.concurrent.MoreExecutors; /** * Utilities for working with suppliers that are not provided by {@linkplain Suppliers Guava}. @@ -44,7 +45,7 @@ public class Suppliers2 { * available, after which it returns that value. If the future completes with an * exception, then the supplier will always provide {@code null} and the exception * will not be accessible. - * + * * @param future * a future result * @return a supplier of the eventual value of the {@code future} @@ -59,7 +60,7 @@ public class Suppliers2 { * available, after which it returns that value. If the future completes with an * exception, then the supplier will always provide the default and the exception * will not be accessible. - * + * * @param future * a future result * @param defaultValue @@ -68,8 +69,8 @@ public class Suppliers2 { */ public static <V> Supplier<V> eventualSupplier(Future<V> future, V defaultValue) { return (future instanceof ListenableFuture<?>) - ? new ListenableFutureSupplier<V>((ListenableFuture<V>) future, defaultValue) - : new FutureSupplier<V>(future, defaultValue); + ? new ListenableFutureSupplier<>((ListenableFuture<V>) future, defaultValue) + : new FutureSupplier<>(future, defaultValue); } // @@ -85,6 +86,7 @@ public class Suppliers2 { this.value = defaultValue; } + @Override public V get() { if ((value == null) && (future != null) && future.isDone()) { try { @@ -112,20 +114,23 @@ public class Suppliers2 { private AtomicReference<V> value; ListenableFutureSupplier(ListenableFuture<V> future, V defaultValue) { - value = new AtomicReference<V>(defaultValue); + value = new AtomicReference<>(defaultValue); Futures.addCallback(future, new FutureCallback<V>() { + @Override public void onSuccess(V result) { value.set(result); } + @Override public void onFailure(Throwable t) { // Normal case. There will never be a value Activator.log.error("Future execution failed", t); } - }); + }, MoreExecutors.directExecutor()); // Added because of compilation error on the executor-less method call } + @Override public V get() { return value.get(); } diff --git a/plugins/infra/emf/org.eclipse.papyrus.infra.emf/src/org/eclipse/papyrus/infra/emf/internal/resource/index/InternalModelIndex.java b/plugins/infra/emf/org.eclipse.papyrus.infra.emf/src/org/eclipse/papyrus/infra/emf/internal/resource/index/InternalModelIndex.java index 9edac0ae384..0f72e93f48f 100644 --- a/plugins/infra/emf/org.eclipse.papyrus.infra.emf/src/org/eclipse/papyrus/infra/emf/internal/resource/index/InternalModelIndex.java +++ b/plugins/infra/emf/org.eclipse.papyrus.infra.emf/src/org/eclipse/papyrus/infra/emf/internal/resource/index/InternalModelIndex.java @@ -1,6 +1,6 @@ /***************************************************************************** * Copyright (c) 2016, 2017 Christian W. Damus and others. - * + * * All rights reserved. This program and the accompanying materials * are made available under the terms of the Eclipse Public License 2.0 * which accompanies this distribution, and is available at @@ -10,7 +10,7 @@ * * Contributors: * Christian W. Damus - Initial API and implementation - * + * *****************************************************************************/ package org.eclipse.papyrus.infra.emf.internal.resource.index; @@ -35,6 +35,7 @@ import org.eclipse.papyrus.infra.emf.resource.index.WorkspaceModelIndex; import com.google.common.util.concurrent.AsyncFunction; import com.google.common.util.concurrent.Futures; import com.google.common.util.concurrent.ListenableFuture; +import com.google.common.util.concurrent.MoreExecutors; import com.google.common.util.concurrent.SettableFuture; /** @@ -78,11 +79,11 @@ public abstract class InternalModelIndex { /** * Obtains the content types matching a {@code file}. - * + * * @param file * a file in the workspace * @return the content types of the {@code file}, or an empty array if none - * + * * @precondition The {@link IndexManager} must have already {@linkplain #start() started} me. */ protected final IContentType[] getContentTypes(IFile file) { @@ -92,25 +93,25 @@ public abstract class InternalModelIndex { /** * Obtains an asynchronous future result that is scheduled to run after * any pending indexing work has completed. - * + * * @param callable * the operation to schedule - * + * * @return the future result of the operation */ protected <V> ListenableFuture<V> afterIndex(final Callable<V> callable) { AsyncFunction<IndexManager, V> indexFunction = mgr -> mgr.afterIndex(this, callable); - return Futures.transformAsync(manager, indexFunction); + return Futures.transformAsync(manager, indexFunction, MoreExecutors.directExecutor()); // Added because of compilation error on the executor-less method call } /** * Executes the specified {@code callable} on the index if it is ready now to provide * a result. - * + * * @param callable * an index operation * @return the result, or {@code null} if the index is not now ready - * + * * @throws CoreException * on failure to get the index manager or exception in the * {@code callable} @@ -164,7 +165,7 @@ public abstract class InternalModelIndex { /** * Do I have an up-to-date index for the given {@code project}? - * + * * @param project * a project * @return whether I have an up-to-date index for it diff --git a/plugins/infra/emf/org.eclipse.papyrus.infra.emf/src/org/eclipse/papyrus/infra/emf/resource/index/WorkspaceModelIndex.java b/plugins/infra/emf/org.eclipse.papyrus.infra.emf/src/org/eclipse/papyrus/infra/emf/resource/index/WorkspaceModelIndex.java index 74b52bc7fc2..81aae046d2d 100644 --- a/plugins/infra/emf/org.eclipse.papyrus.infra.emf/src/org/eclipse/papyrus/infra/emf/resource/index/WorkspaceModelIndex.java +++ b/plugins/infra/emf/org.eclipse.papyrus.infra.emf/src/org/eclipse/papyrus/infra/emf/resource/index/WorkspaceModelIndex.java @@ -1,6 +1,6 @@ /***************************************************************************** * Copyright (c) 2014, 2017 Christian W. Damus and others. - * + * * All rights reserved. This program and the accompanying materials * are made available under the terms of the Eclipse Public License 2.0 * which accompanies this distribution, and is available at @@ -10,7 +10,7 @@ * * Contributors: * Christian W. Damus - Initial API and implementation - * + * *****************************************************************************/ package org.eclipse.papyrus.infra.emf.resource.index; @@ -60,6 +60,7 @@ import com.google.common.collect.SetMultimap; import com.google.common.util.concurrent.FutureCallback; import com.google.common.util.concurrent.Futures; import com.google.common.util.concurrent.ListenableFuture; +import com.google.common.util.concurrent.MoreExecutors; /** * A general-purpose index of model resources in the Eclipse workspace. @@ -289,7 +290,7 @@ public class WorkspaceModelIndex<T> extends InternalModelIndex { /** * Obtains the name of this index. - * + * * @return my name * @since 2.1 */ @@ -306,14 +307,14 @@ public class WorkspaceModelIndex<T> extends InternalModelIndex { * Obtains an asynchronous future result that is scheduled to run after any pending indexing work has completed. * The {@code function} is <em>not</em> invoked under synchronization on the index; it is passed a copy of the * last consistent state of the index after any pending calculations have completed. - * + * * @param function * the function to schedule. Its input is the complete index map - * + * * @return the future result of the function applied to the index */ public <V> ListenableFuture<V> afterIndex(final Function<? super Map<IFile, T>, V> function) { - return Futures.transform(getIndex(), function); + return Futures.transform(getIndex(), function, MoreExecutors.directExecutor()); // Added because of compilation error on the executor-less method call } /** @@ -321,10 +322,10 @@ public class WorkspaceModelIndex<T> extends InternalModelIndex { * pending indexing work has completed. The {@code callable} is invoked under * synchronization on the index, so it must be careful about how it * synchronizes on other objects to avoid deadlocks. - * + * * @param callable * the operation to schedule - * + * * @return the future result of the operation */ @Override @@ -345,7 +346,7 @@ public class WorkspaceModelIndex<T> extends InternalModelIndex { * Schedules an operation to run after any pending indexing work has completed. * The {@code runnable} is invoked under synchronization on the index, so it must be careful about how it * synchronizes on other objects to avoid deadlocks. - * + * * @param runnable * the operation to schedule */ @@ -361,7 +362,7 @@ public class WorkspaceModelIndex<T> extends InternalModelIndex { /** * Obtains the index when it is ready. - * + * * @return the future value of the index, when it is ready */ public ListenableFuture<Map<IFile, T>> getIndex() { @@ -532,7 +533,7 @@ public class WorkspaceModelIndex<T> extends InternalModelIndex { public void onFailure(Throwable t) { // Don't need a listener } - }); + }, MoreExecutors.directExecutor()); // Added because of compilation error on the executor-less method call } public void removeListener(IWorkspaceModelIndexListener listener) { @@ -546,7 +547,7 @@ public class WorkspaceModelIndex<T> extends InternalModelIndex { public void onFailure(Throwable t) { // Couldn't have added the listener anyways } - }); + }, MoreExecutors.directExecutor()); // Added because of compilation error on the executor-less method call } // @@ -559,17 +560,17 @@ public class WorkspaceModelIndex<T> extends InternalModelIndex { public static interface IndexHandler<T> { /** * Updates the index for a file that matches our selection criteria. - * + * * @param file * a file that exists and matches the index selection criteria - * + * * @return the object to store in the index for this {@code file} */ T index(IFile file); /** * Updates the index for a file that no longer exists or no longer matches our selection criteria. - * + * * @param file * a file that no longer exists or otherwise no longer matches our selection criteria. It is removed from the index */ @@ -604,12 +605,12 @@ public class WorkspaceModelIndex<T> extends InternalModelIndex { public static interface PersistentIndexHandler<T> extends IndexHandler<T> { /** * Initializes the {@code index} data for a file from the persistent store. - * + * * @param file * a file in the workspace * @param index * its previously stored index - * + * * @return whether the {@code index} data were successfully integrated. * A {@code false} result indicates that the file must be indexed * from scratch diff --git a/plugins/infra/gmfdiag/assistant/org.eclipse.papyrus.infra.gmfdiag.assistant/src/org/eclipse/papyrus/infra/gmfdiag/assistant/core/util/ModelingAssistantUtil.java b/plugins/infra/gmfdiag/assistant/org.eclipse.papyrus.infra.gmfdiag.assistant/src/org/eclipse/papyrus/infra/gmfdiag/assistant/core/util/ModelingAssistantUtil.java index 5b4ee99c36a..a668f194884 100644 --- a/plugins/infra/gmfdiag/assistant/org.eclipse.papyrus.infra.gmfdiag.assistant/src/org/eclipse/papyrus/infra/gmfdiag/assistant/core/util/ModelingAssistantUtil.java +++ b/plugins/infra/gmfdiag/assistant/org.eclipse.papyrus.infra.gmfdiag.assistant/src/org/eclipse/papyrus/infra/gmfdiag/assistant/core/util/ModelingAssistantUtil.java @@ -1,6 +1,6 @@ /***************************************************************************** * Copyright (c) 2014, 2015 Christian W. Damus and others. - * + * * All rights reserved. This program and the accompanying materials * are made available under the terms of the Eclipse Public License 2.0 * which accompanies this distribution, and is available at @@ -10,7 +10,7 @@ * * Contributors: * Christian W. Damus - Initial API and implementation - * + * *****************************************************************************/ package org.eclipse.papyrus.infra.gmfdiag.assistant.core.util; @@ -66,12 +66,12 @@ public class ModelingAssistantUtil { /** * Best-effort calculation of the element types matching the given {@code input}. - * + * * @param provider * the modeling assistant provider in which context we are calculating element types. Must not be {@code null} * @param input * some manifestation of an object being edited, usually either a diagram edit-part, a semantic model element, or an {@link IEditHelperContext} - * + * * @return the elements, or an empty array if none can be determined (never {@code null}) */ public static IElementType[] getElementTypes(ModelingAssistantProvider provider, Object input) { @@ -164,7 +164,7 @@ public class ModelingAssistantUtil { /** * Collects all of the concrete subtypes of a given {@code supertype} that are referenced by a modeling assistant {@code provider}. - * + * * @param supertype * a possible abstract (or not) element type * @param provider @@ -182,7 +182,7 @@ public class ModelingAssistantUtil { /** * Queries whether a postulated {@code subtype} is a subtype of its presumptive {@code supertype}. - * + * * @param subtype * an element type * @param supertype @@ -195,14 +195,14 @@ public class ModelingAssistantUtil { /** * Obtains the hinted specializations of an element type in the context of the given {@code provider}. - * + * * @param supertype * the element type for which to find hinted specializations * @param provider * the provider context * @param host * the host context in which the {@code provider} is asked for modeling assistants - * + * * @return the hinted specializations */ public static List<IHintedType> getHintedTypes(IElementType supertype, ModelingAssistantProvider provider, IAdaptable host) { @@ -240,7 +240,7 @@ public class ModelingAssistantUtil { /** * Queries whether an {@code elementType} is a specialization of any of a set of other {@code types}. - * + * * @param elementType * an element type * @param types @@ -279,33 +279,35 @@ public class ModelingAssistantUtil { /** * Determines if the passed hint is a visualID - * There is now no reliable way for testing if a semantic hint represents a visual id + * There is now no reliable way for testing if a semantic hint represents a visual id + * * @param hint * @return - * @deprecated This function should not be relied on. Other ways of determining - * if an element type represents a visual element should be used + * @deprecated This function should not be relied on. Other ways of determining + * if an element type represents a visual element should be used */ + @Deprecated public static boolean isVisualID(String hint) { hint = Strings.nullToEmpty(hint); return VISUAL_ID_PATTERN.matcher(hint).matches() || - hint.contains("Diagram") || - hint.contains("Shape") || - hint.contains("Edge") || - hint.contains("Compartment") || + hint.contains("Diagram") || + hint.contains("Shape") || + hint.contains("Edge") || + hint.contains("Compartment") || hint.contains("Label"); } /** * Filters a set of connection types for only those that we think we could actually create in the current diagram context and * sorts them alphabetically. - * + * * @param provider * the contextual assistant provider * @param elementTypes * connection element types matched in the assistant model * @param connectionEnd * the context of the element creation, being one of the edit parts at its ends - * + * * @return the (possibly) reduced set of connection types that we think we could create, sorted */ public static EList<IElementType> filterConnectionTypes(ModelingAssistantProvider provider, Set<IElementType> elementTypes, IAdaptable connectionEnd) { @@ -345,7 +347,7 @@ public class ModelingAssistantUtil { if (input instanceof IHintedType) { String hint = ((IHintedType) input).getSemanticHint(); - if (!Strings.isNullOrEmpty(hint) && CharMatcher.DIGIT.matchesAllOf(hint)) { + if (!Strings.isNullOrEmpty(hint) && CharMatcher.digit().matchesAllOf(hint)) { result = Integer.parseInt(hint); } } diff --git a/plugins/infra/gmfdiag/org.eclipse.papyrus.infra.gmfdiag.canonical/src/org/eclipse/papyrus/infra/gmfdiag/canonical/editpolicy/PapyrusCanonicalEditPolicy.java b/plugins/infra/gmfdiag/org.eclipse.papyrus.infra.gmfdiag.canonical/src/org/eclipse/papyrus/infra/gmfdiag/canonical/editpolicy/PapyrusCanonicalEditPolicy.java index e2e81734607..e6cd53fd1e3 100644 --- a/plugins/infra/gmfdiag/org.eclipse.papyrus.infra.gmfdiag.canonical/src/org/eclipse/papyrus/infra/gmfdiag/canonical/editpolicy/PapyrusCanonicalEditPolicy.java +++ b/plugins/infra/gmfdiag/org.eclipse.papyrus.infra.gmfdiag.canonical/src/org/eclipse/papyrus/infra/gmfdiag/canonical/editpolicy/PapyrusCanonicalEditPolicy.java @@ -79,6 +79,7 @@ import com.google.common.collect.Sets; import com.google.common.util.concurrent.FutureCallback; import com.google.common.util.concurrent.Futures; import com.google.common.util.concurrent.ListenableFuture; +import com.google.common.util.concurrent.MoreExecutors; /** * A specialization of the GMF {@link CanonicalEditPolicy} that alters the standard behaviour in a few key ways: @@ -485,7 +486,7 @@ public class PapyrusCanonicalEditPolicy extends CanonicalEditPolicy implements I public void onFailure(Throwable t) { Activator.log.error(t); } - }); + }, MoreExecutors.directExecutor()); // Added because of compilation error on the executor-less method call } } @@ -599,7 +600,7 @@ public class PapyrusCanonicalEditPolicy extends CanonicalEditPolicy implements I /** * As {@link CanonicalEditPolicy#deleteViews(Iterator)}, deletes a list of views. * The views will be deleted <tt>iff</tt> their semantic element has also been deleted. - * + * * @param views * an iterator on a list of views. * @return <tt>true</tt> if the host editpart should be refreshed; either one one of the supplied @@ -801,7 +802,7 @@ public class PapyrusCanonicalEditPolicy extends CanonicalEditPolicy implements I /** * Queries whether I manage canonical connections. Edit parts such as top shapes and border items manage connections; * other edit parts such as compartments manage contained views only. - * + * * @return whether I manage canonical connections */ protected boolean isManageConnections() { @@ -873,12 +874,12 @@ public class PapyrusCanonicalEditPolicy extends CanonicalEditPolicy implements I /** * Computes, if necessary, a new ordering of the {@code viewChildren} to match the ordering of the {@code semanticChildren}. - * + * * @param viewChildren * the existing view children in the order in which they are currently presented * @param semanticChildren * the semantic children that are now presented (we may have already created views for some) - * + * * @return a new list presenting the {@code viewChildren} in semantic order, or {@code null} if no ordering changes are required */ protected List<? extends View> matchCanonicalOrdering(List<? extends View> viewChildren, final List<EObject> semanticChildren) { diff --git a/plugins/infra/services/org.eclipse.papyrus.infra.services.controlmode/src/org/eclipse/papyrus/infra/services/controlmode/internal/ui/ControlledUnitLabelDecorator.java b/plugins/infra/services/org.eclipse.papyrus.infra.services.controlmode/src/org/eclipse/papyrus/infra/services/controlmode/internal/ui/ControlledUnitLabelDecorator.java index 7cfbc66106e..9e4da02107b 100644 --- a/plugins/infra/services/org.eclipse.papyrus.infra.services.controlmode/src/org/eclipse/papyrus/infra/services/controlmode/internal/ui/ControlledUnitLabelDecorator.java +++ b/plugins/infra/services/org.eclipse.papyrus.infra.services.controlmode/src/org/eclipse/papyrus/infra/services/controlmode/internal/ui/ControlledUnitLabelDecorator.java @@ -1,6 +1,6 @@ /***************************************************************************** * Copyright (c) 2016 Christian W. Damus and others. - * + * * All rights reserved. This program and the accompanying materials * are made available under the terms of the Eclipse Public License 2.0 * which accompanies this distribution, and is available at @@ -10,7 +10,7 @@ * * Contributors: * Christian W. Damus - Initial API and implementation - * + * *****************************************************************************/ package org.eclipse.papyrus.infra.services.controlmode.internal.ui; @@ -39,6 +39,7 @@ import com.google.common.base.Function; import com.google.common.collect.Lists; import com.google.common.util.concurrent.Futures; import com.google.common.util.concurrent.ListenableFuture; +import com.google.common.util.concurrent.MoreExecutors; /** * A label decorator for controlled-unit resources in the Project Explorer. @@ -92,10 +93,10 @@ public class ControlledUnitLabelDecorator extends BaseLabelProvider implements I // A very coarse-grained label change event unregisterHandler = ((CrossReferenceIndex) index).onIndexChanged( __ -> fireLabelProviderChanged(new LabelProviderChangedEvent(this)), - CoreExecutors.getUIExecutorService()); + CoreExecutors.getUIExecutorService()); } } - + private void decorateFile(IFile file, IDecoration decoration) { ListenableFuture<SubunitKind> futureKind = getSubunitKind(file); if (futureKind.isDone()) { @@ -156,7 +157,7 @@ public class ControlledUnitLabelDecorator extends BaseLabelProvider implements I @SuppressWarnings("unchecked") ListenableFuture<?> combined = Futures.allAsList(parents, isShard); - return Futures.transform(combined, kindFunction); + return Futures.transform(combined, kindFunction, MoreExecutors.directExecutor()); // Added because of compilation error on the executor-less method call } private Runnable postUpdate(Object element) { diff --git a/plugins/infra/ui/org.eclipse.papyrus.infra.ui/src/org/eclipse/papyrus/infra/ui/util/EditorUtils.java b/plugins/infra/ui/org.eclipse.papyrus.infra.ui/src/org/eclipse/papyrus/infra/ui/util/EditorUtils.java index a17c0fc38b6..e98bfd784ff 100644 --- a/plugins/infra/ui/org.eclipse.papyrus.infra.ui/src/org/eclipse/papyrus/infra/ui/util/EditorUtils.java +++ b/plugins/infra/ui/org.eclipse.papyrus.infra.ui/src/org/eclipse/papyrus/infra/ui/util/EditorUtils.java @@ -58,6 +58,7 @@ import org.eclipse.ui.PlatformUI; import com.google.common.collect.Iterables; import com.google.common.util.concurrent.Futures; import com.google.common.util.concurrent.ListenableFuture; +import com.google.common.util.concurrent.MoreExecutors; /** * Set of utility methods for the CoreEditor. <br> @@ -734,14 +735,14 @@ public class EditorUtils { /** * Resolves the root resource URI from the URI of a resource that may be a * shard or may be an independent model unit. - * + * * @param index * the shard index to consult * @param resourceURI * a resource URI - * + * * @return the root, which may just be the input resource URI if it is a root - * + * * @see ShardResourceHelper * @see ICrossReferenceIndex#getRoots(URI) * @since 1.3 @@ -769,14 +770,14 @@ public class EditorUtils { /** * Asynchronously resolves the root resource URI from the URI of a resource that * may be a shard or may be an independent model unit. - * + * * @param index * the shard index to consult * @param resourceURI * a resource URI - * + * * @return the root, which may just be the input resource URI if it is a root - * + * * @see ShardResourceHelper * @see ICrossReferenceIndex#getRootsAsync(URI) * @since 1.3 @@ -784,6 +785,6 @@ public class EditorUtils { public static ListenableFuture<URI> resolveShardRootAsync(ICrossReferenceIndex index, URI resourceURI) { // TODO: Handle case of multiple roots return Futures.transform(index.getRootsAsync(resourceURI), - (Set<URI> roots) -> Iterables.getFirst(roots, resourceURI)); + (Set<URI> roots) -> Iterables.getFirst(roots, resourceURI), MoreExecutors.directExecutor()); // Added because of compilation error on the executor-less method call } } diff --git a/plugins/uml/decoratormodel/org.eclipse.papyrus.uml.decoratormodel/src/org/eclipse/papyrus/uml/decoratormodel/helper/DecoratorModelUtils.java b/plugins/uml/decoratormodel/org.eclipse.papyrus.uml.decoratormodel/src/org/eclipse/papyrus/uml/decoratormodel/helper/DecoratorModelUtils.java index a4aff1f93f6..3564ae555a1 100755 --- a/plugins/uml/decoratormodel/org.eclipse.papyrus.uml.decoratormodel/src/org/eclipse/papyrus/uml/decoratormodel/helper/DecoratorModelUtils.java +++ b/plugins/uml/decoratormodel/org.eclipse.papyrus.uml.decoratormodel/src/org/eclipse/papyrus/uml/decoratormodel/helper/DecoratorModelUtils.java @@ -14,7 +14,7 @@ * Christian W. Damus - bug 458197 * Christian W. Damus - bug 459613 * Christian W. Damus - bug 468030 - * Vincent LORENZO - bug 541313 - [UML][CDO] UML calls to the method getCacheAdapter(EObject) must be replaced + * Vincent LORENZO - bug 541313 - [UML][CDO] UML calls to the method getCacheAdapter(EObject) must be replaced *****************************************************************************/ package org.eclipse.papyrus.uml.decoratormodel.helper; @@ -90,6 +90,7 @@ import com.google.common.collect.SetMultimap; import com.google.common.collect.Sets; import com.google.common.util.concurrent.Futures; import com.google.common.util.concurrent.ListenableFuture; +import com.google.common.util.concurrent.MoreExecutors; import com.google.common.util.concurrent.UncheckedExecutionException; /** @@ -998,7 +999,7 @@ public class DecoratorModelUtils { } }; - return Futures.transform(decoratorMap, transform); + return Futures.transform(decoratorMap, transform, MoreExecutors.directExecutor()); // Added because of compilation error on the executor-less method call } /** @@ -1051,7 +1052,7 @@ public class DecoratorModelUtils { } }; - return Futures.transform(decoratorMap, transform); + return Futures.transform(decoratorMap, transform, MoreExecutors.directExecutor()); // Added because of compilation error on the executor-less method call } /** @@ -1082,7 +1083,7 @@ public class DecoratorModelUtils { public Boolean apply(Collection<?> input) { return (input != null) && !input.isEmpty(); } - }); + }, MoreExecutors.directExecutor()); // Added because of compilation error on the executor-less method call } private static void collectUnloadedDecoratorModels(SetMultimap<URI, URI> userModelsToDecoratorModels, Resource modelResource, Set<URI> result) { diff --git a/plugins/uml/decoratormodel/org.eclipse.papyrus.uml.decoratormodel/src/org/eclipse/papyrus/uml/decoratormodel/internal/resource/DecoratorModelIndex.java b/plugins/uml/decoratormodel/org.eclipse.papyrus.uml.decoratormodel/src/org/eclipse/papyrus/uml/decoratormodel/internal/resource/DecoratorModelIndex.java index 67877acacac..4d86116e38d 100644 --- a/plugins/uml/decoratormodel/org.eclipse.papyrus.uml.decoratormodel/src/org/eclipse/papyrus/uml/decoratormodel/internal/resource/DecoratorModelIndex.java +++ b/plugins/uml/decoratormodel/org.eclipse.papyrus.uml.decoratormodel/src/org/eclipse/papyrus/uml/decoratormodel/internal/resource/DecoratorModelIndex.java @@ -1,6 +1,6 @@ /***************************************************************************** * Copyright (c) 2014, 2017 Christian W. Damus and others. - * + * * All rights reserved. This program and the accompanying materials * are made available under the terms of the Eclipse Public License 2.0 * which accompanies this distribution, and is available at @@ -10,7 +10,7 @@ * * Contributors: * Christian W. Damus - Initial API and implementation - * + * *****************************************************************************/ package org.eclipse.papyrus.uml.decoratormodel.internal.resource; @@ -65,6 +65,7 @@ import com.google.common.collect.SetMultimap; import com.google.common.collect.Sets; import com.google.common.util.concurrent.Futures; import com.google.common.util.concurrent.ListenableFuture; +import com.google.common.util.concurrent.MoreExecutors; /** * A workspace-wide index mapping UML model resources to decorator models that apply profiles to them. @@ -101,7 +102,7 @@ public class DecoratorModelIndex { private DecoratorModelIndex() { super(); - index = new WorkspaceModelIndex<IndexedFile<?>>("papyrusUMLProfiles", UMLPackage.eCONTENT_TYPE, indexer(), MAX_INDEX_JOBS); //$NON-NLS-1$ + index = new WorkspaceModelIndex<>("papyrusUMLProfiles", UMLPackage.eCONTENT_TYPE, indexer(), MAX_INDEX_JOBS); //$NON-NLS-1$ } private void initialize() { @@ -137,7 +138,7 @@ public class DecoratorModelIndex { /** * Asynchronously queries the mapping of URIs of user models to URIs of decorator models that apply profiles to them. - * + * * @return a future result of the mapping of user model URIs to decorator model URIs */ public ListenableFuture<SetMultimap<URI, URI>> getDecoratorModelsAsync() { @@ -146,7 +147,7 @@ public class DecoratorModelIndex { /** * Queries the mapping of URIs of user models to URIs of decorator models that apply profiles to them. - * + * * @return the mapping of user model URIs to decorator model URIs */ public SetMultimap<URI, URI> getDecoratorModels() throws CoreException { @@ -164,7 +165,7 @@ public class DecoratorModelIndex { /** * Asynchronously queries the URIs of decorator models that apply profiles to the specified user model resource. - * + * * @param modelResourceURI * the URI of a user model resource * @return a future result of the URIs of decorator models for the user model resource @@ -175,7 +176,7 @@ public class DecoratorModelIndex { /** * Queries the URIs of decorator models that apply profiles to the specified user model resource. - * + * * @param modelResourceURI * the URI of a user model resource * @return the URIs of decorator models for the user model resource @@ -205,7 +206,7 @@ public class DecoratorModelIndex { /** * Asynchronously queries the URIs of profiles applied to the specified user model package by the specified decorator model. - * + * * @param packageURI * the URI of a package in a user model * @param decoratorModel @@ -218,12 +219,12 @@ public class DecoratorModelIndex { public Set<URI> apply(SetMultimap<URI, URI> input) { return input.get(packageURI); } - }); + }, MoreExecutors.directExecutor()); // Added because of compilation error on the executor-less method call } /** * Queries the URIs of profiles applied to the specified user model package by the specified decorator model. - * + * * @param packageURI * the URI of a package in a user model * @param decoratorModel @@ -236,7 +237,7 @@ public class DecoratorModelIndex { /** * Asynchronously queries a mapping of user-model package URIs to URIs of profiles applied to them by the specified decorator model. - * + * * @param decoratorModel * the URI of a decorator model * @return the future result of the URIs of user model packages to profiles applied to them by the resource @@ -247,7 +248,7 @@ public class DecoratorModelIndex { /** * Queries a mapping of user-model package URIs to URIs of profiles applied to them by the specified decorator model. - * + * * @param decoratorModel * the URI of a decorator model * @return the URIs of user model packages to profiles applied to them by the resource @@ -281,7 +282,7 @@ public class DecoratorModelIndex { /** * Asynchronously queries a mapping of all profiles applied externally on a package to the resources that apply those profiles. * The mapping is one-to-many because any number of decorator models can apply the same profile to a package. - * + * * @param package_ * the URI of a user-model package * @return the future result of a mapping of the URIs of profiles externally applied on the package to the resources that apply them @@ -293,7 +294,7 @@ public class DecoratorModelIndex { /** * Queries a mapping of all profiles applied externally on a package to the resources that apply those profiles. * The mapping is one-to-many because any number of decorator models can apply the same profile to a package. - * + * * @param package_ * the URI of a user-model package * @return a mapping of the URIs of profiles externally applied on the package to the resources that apply them @@ -329,7 +330,7 @@ public class DecoratorModelIndex { * Asynchronously queries a mapping of all profiles applied externally on a package to mappings of decorator model resources that apply those profiles * to the Ecore definitions applied by those decorators. That is, (profile ==> decorator-model ==> ecore-definition). * The mapping is one-to-many because any number of decorator models can apply the same profile to a package. - * + * * @param package_ * the URI of a user-model package * @return the future result of a mapping of the URIs of profiles externally applied on the package to the resources that apply them to @@ -343,7 +344,7 @@ public class DecoratorModelIndex { * Queries a mapping of all profiles applied externally on a package to mappings of decorator model resources that apply those profiles * to the Ecore definitions applied by those decorators. That is, (profile ==> decorator-model ==> ecore-definition). * The mapping is one-to-many because any number of decorator models can apply the same profile to a package. - * + * * @param package_ * the URI of a user-model package * @return a mapping of the URIs of profiles externally applied on the package to the resources that apply them to @@ -389,7 +390,7 @@ public class DecoratorModelIndex { /** * Asynchronously queries the set of URIs of decorator models that apply profiles to the specified package. - * + * * @param package_ * the URI of a user-model package * @return the future result of the URIs of all decorator models that apply profiels to it @@ -400,7 +401,7 @@ public class DecoratorModelIndex { /** * Queries the set of URIs of decorator models that apply profiles to the specified package. - * + * * @param package_ * the URI of a user-model package * @return the URIs of all decorator models that apply profiels to it @@ -420,7 +421,7 @@ public class DecoratorModelIndex { /** * Asynchronously queries a mapping of the user-defined names/identifiers of the profile application externalization models in the workspace. - * + * * @return the future result of the known decorator models' names */ public ListenableFuture<Map<URI, String>> getDecoratorModelNamesAsync() { @@ -429,7 +430,7 @@ public class DecoratorModelIndex { /** * Queries a mapping of the user-defined names/identifiers of the profile application externalization models in the workspace. - * + * * @return the known decorator models' names */ public Map<URI, String> getDecoratorModelNames() throws CoreException { @@ -447,7 +448,7 @@ public class DecoratorModelIndex { /** * Asynchronously queries the user-defined names/identifier of a decorator model. - * + * * @param resourceURI * the URI of the decorator model * @return the future result of the decorator model name @@ -458,12 +459,12 @@ public class DecoratorModelIndex { public String apply(Map<URI, String> input) { return input.get(resourceURI); } - }); + }, MoreExecutors.directExecutor()); // Added because of compilation error on the executor-less method call } /** * Queries the user-defined names/identifier of a decorator model. - * + * * @param resourceURI * the URI of the decorator model * @return the decorator model name @@ -474,7 +475,7 @@ public class DecoratorModelIndex { /** * Asynchronously queries the mapping of URIs of decorator models to URIs of user models to which they apply profiles. - * + * * @return a future result of the mapping of decorator model URIs to user model URIs */ public ListenableFuture<SetMultimap<URI, URI>> getUserModelsByDecoratorAsync() { @@ -483,7 +484,7 @@ public class DecoratorModelIndex { /** * Queries the mapping of URIs of decorator models to URIs of user models to which they apply profiles. - * + * * @return the mapping of decorator model URIs to user model URIs */ public SetMultimap<URI, URI> getUserModelsByDecorator() throws CoreException { @@ -502,7 +503,7 @@ public class DecoratorModelIndex { /** * Asynchronously queries the set of URIs of {@link Profile}s applied internally and by decorators to {@link Package}s * within the specified user model. - * + * * @param userModelURI * the URI of a user model * @return a future result of the set of URIs of the profile elements applied to it @@ -514,7 +515,7 @@ public class DecoratorModelIndex { /** * Queries the set of URIs of {@link Profile}s applied internally and by decorators to {@link Package}s * within the specified user model. - * + * * @param userModelURI * the URI of a user model * @return the set of URIs of the profile elements applied to it diff --git a/plugins/uml/tools/org.eclipse.papyrus.uml.tools/src/org/eclipse/papyrus/uml/tools/profile/index/ProfileLanguageProvider.java b/plugins/uml/tools/org.eclipse.papyrus.uml.tools/src/org/eclipse/papyrus/uml/tools/profile/index/ProfileLanguageProvider.java index d75048665a5..110fdfde7de 100644 --- a/plugins/uml/tools/org.eclipse.papyrus.uml.tools/src/org/eclipse/papyrus/uml/tools/profile/index/ProfileLanguageProvider.java +++ b/plugins/uml/tools/org.eclipse.papyrus.uml.tools/src/org/eclipse/papyrus/uml/tools/profile/index/ProfileLanguageProvider.java @@ -1,6 +1,6 @@ /***************************************************************************** * Copyright (c) 2015 Christian W. Damus and others. - * + * * All rights reserved. This program and the accompanying materials * are made available under the terms of the Eclipse Public License 2.0 * which accompanies this distribution, and is available at @@ -10,7 +10,7 @@ * * Contributors: * Christian W. Damus - Initial API and implementation - * + * *****************************************************************************/ package org.eclipse.papyrus.uml.tools.profile.index; @@ -46,6 +46,7 @@ import com.google.common.collect.Sets; import com.google.common.util.concurrent.FutureCallback; import com.google.common.util.concurrent.Futures; import com.google.common.util.concurrent.ListenableFuture; +import com.google.common.util.concurrent.MoreExecutors; /** * <p> @@ -193,7 +194,7 @@ public class ProfileLanguageProvider implements ILanguageProvider, IExecutableEx // Nothing to post Activator.log.error(String.format("Failed to access profile index for resource %s", uriToQuery), t); //$NON-NLS-1$ } - }); + }, MoreExecutors.directExecutor()); // Added because of compilation error on the executor-less method call } } } catch (Exception e) { diff --git a/tests/junit/plugins/infra/core/org.eclipse.papyrus.infra.core.tests/test/org/eclipse/papyrus/infra/core/utils/JobBasedFutureTest.java b/tests/junit/plugins/infra/core/org.eclipse.papyrus.infra.core.tests/test/org/eclipse/papyrus/infra/core/utils/JobBasedFutureTest.java index e49554a04b4..109978e83d7 100644 --- a/tests/junit/plugins/infra/core/org.eclipse.papyrus.infra.core.tests/test/org/eclipse/papyrus/infra/core/utils/JobBasedFutureTest.java +++ b/tests/junit/plugins/infra/core/org.eclipse.papyrus.infra.core.tests/test/org/eclipse/papyrus/infra/core/utils/JobBasedFutureTest.java @@ -43,6 +43,7 @@ import com.google.common.collect.Iterables; import com.google.common.collect.Lists; import com.google.common.util.concurrent.FutureCallback; import com.google.common.util.concurrent.Futures; +import com.google.common.util.concurrent.MoreExecutors; /** * JUnit tests for the {@link JobBasedFuture} class. @@ -164,6 +165,7 @@ public class JobBasedFutureTest extends AbstractPapyrusTest { Runnable reader = new Runnable() { + @Override public void run() { ISchedulingRule rule_ = (rule == null) ? null : rule.get(); @@ -228,16 +230,18 @@ public class JobBasedFutureTest extends AbstractPapyrusTest { for (int i = 0; i < CONCURRENT_THREAD_COUNT; i++) { Futures.addCallback(fixture, new FutureCallback<Boolean>() { + @Override public void onSuccess(Boolean result) { results.add(result); latch.countDown(); } + @Override public void onFailure(Throwable t) { thrown.add(t); latch.countDown(); } - }); + }, MoreExecutors.directExecutor()); // Added because of compilation error on the executor-less method call } try { @@ -318,12 +322,15 @@ public class JobBasedFutureTest extends AbstractPapyrusTest { } static class RuleSupplier implements Supplier<ISchedulingRule> { + @Override public ISchedulingRule get() { return new ISchedulingRule() { + @Override public boolean isConflicting(ISchedulingRule rule) { return rule == this; } + @Override public boolean contains(ISchedulingRule rule) { return rule == this; } |