diff options
Diffstat (limited to 'plugins/org.eclipse.etrice.core.room/src/org/eclipse/etrice/core/scoping/FilteringScope.java')
-rw-r--r-- | plugins/org.eclipse.etrice.core.room/src/org/eclipse/etrice/core/scoping/FilteringScope.java | 132 |
1 files changed, 66 insertions, 66 deletions
diff --git a/plugins/org.eclipse.etrice.core.room/src/org/eclipse/etrice/core/scoping/FilteringScope.java b/plugins/org.eclipse.etrice.core.room/src/org/eclipse/etrice/core/scoping/FilteringScope.java index c9b7109c7..3549345b7 100644 --- a/plugins/org.eclipse.etrice.core.room/src/org/eclipse/etrice/core/scoping/FilteringScope.java +++ b/plugins/org.eclipse.etrice.core.room/src/org/eclipse/etrice/core/scoping/FilteringScope.java @@ -1,66 +1,66 @@ -/******************************************************************************* - * Copyright (c) 2010 protos software gmbh (http://www.protos.de). - * 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 - * http://www.eclipse.org/legal/epl-v10.html - * - * CONTRIBUTORS: - * Thomas Schuetz and Henrik Rentz-Reichert (initial contribution) - * - *******************************************************************************/ - -package org.eclipse.etrice.core.scoping; - -import org.eclipse.emf.ecore.EObject; -import org.eclipse.xtext.resource.IEObjectDescription; -import org.eclipse.xtext.scoping.IScope; - -import com.google.common.base.Predicate; -import com.google.common.collect.Iterables; - -public class FilteringScope implements IScope { - - private IScope delegate; - private Predicate<IEObjectDescription> filter; - - public FilteringScope(IScope delegate, Predicate<IEObjectDescription> filter) { - this.delegate = delegate; - this.filter = filter; - } - - public IScope getOuterScope() { - return new FilteringScope(delegate.getOuterScope(), filter); - } - - public Iterable<IEObjectDescription> getContents() { - return filter(delegate.getContents()); - } - - public Iterable<IEObjectDescription> getAllContents() { - return filter(delegate.getAllContents()); - } - - public IEObjectDescription getContentByName(String name) { - return filter(delegate.getContentByName(name)); - } - - public IEObjectDescription getContentByEObject(EObject object) { - return filter(delegate.getContentByEObject(object)); - } - - public Iterable<IEObjectDescription> getAllContentsByEObject(EObject object) { - return filter(delegate.getAllContentsByEObject(object)); - } - - protected Iterable<IEObjectDescription> filter( - Iterable<IEObjectDescription> unfiltered) { - return Iterables.filter(unfiltered, filter); - } - - protected IEObjectDescription filter(IEObjectDescription contentByEObject) { - if (!filter.apply(contentByEObject)) - return null; - return contentByEObject; - } -} +/*******************************************************************************
+ * Copyright (c) 2010 protos software gmbh (http://www.protos.de).
+ * 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
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * CONTRIBUTORS:
+ * Thomas Schuetz and Henrik Rentz-Reichert (initial contribution)
+ *
+ *******************************************************************************/
+
+package org.eclipse.etrice.core.scoping;
+
+import org.eclipse.emf.ecore.EObject;
+import org.eclipse.xtext.resource.IEObjectDescription;
+import org.eclipse.xtext.scoping.IScope;
+
+import com.google.common.base.Predicate;
+import com.google.common.collect.Iterables;
+
+public class FilteringScope implements IScope {
+
+ private IScope delegate;
+ private Predicate<IEObjectDescription> filter;
+
+ public FilteringScope(IScope delegate, Predicate<IEObjectDescription> filter) {
+ this.delegate = delegate;
+ this.filter = filter;
+ }
+
+ public IScope getOuterScope() {
+ return new FilteringScope(delegate.getOuterScope(), filter);
+ }
+
+ public Iterable<IEObjectDescription> getContents() {
+ return filter(delegate.getContents());
+ }
+
+ public Iterable<IEObjectDescription> getAllContents() {
+ return filter(delegate.getAllContents());
+ }
+
+ public IEObjectDescription getContentByName(String name) {
+ return filter(delegate.getContentByName(name));
+ }
+
+ public IEObjectDescription getContentByEObject(EObject object) {
+ return filter(delegate.getContentByEObject(object));
+ }
+
+ public Iterable<IEObjectDescription> getAllContentsByEObject(EObject object) {
+ return filter(delegate.getAllContentsByEObject(object));
+ }
+
+ protected Iterable<IEObjectDescription> filter(
+ Iterable<IEObjectDescription> unfiltered) {
+ return Iterables.filter(unfiltered, filter);
+ }
+
+ protected IEObjectDescription filter(IEObjectDescription contentByEObject) {
+ if (!filter.apply(contentByEObject))
+ return null;
+ return contentByEObject;
+ }
+}
|