Made sure that ProjectResourceScope can operate consistently on
in-memory model files by reworking
ProjectResourceScope#belongsToRootOrReferencedProjects(URI, boolean) -
converted provided URI to corresponding IFile and delegated to
ProjectResourceScope#belongsTo(IFile, boolean)} rather
than relying on mappings of physically existing IFiles to URIs provided
by ProjectResourceCache
diff --git a/plugins/org.eclipse.sphinx.emf/src/org/eclipse/sphinx/emf/scoping/ProjectResourceCache.java b/plugins/org.eclipse.sphinx.emf/src/org/eclipse/sphinx/emf/scoping/ProjectResourceCache.java
index 469e14e..bd36f68 100644
--- a/plugins/org.eclipse.sphinx.emf/src/org/eclipse/sphinx/emf/scoping/ProjectResourceCache.java
+++ b/plugins/org.eclipse.sphinx.emf/src/org/eclipse/sphinx/emf/scoping/ProjectResourceCache.java
@@ -1,14 +1,14 @@
/**
* <copyright>
*
- * Copyright (c) {contributing company name} and others.
+ * Copyright (c) 2008-2019 BWM Car IT, See4sys, itemis 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
* http://www.eclipse.org/legal/epl-v10.html
*
* Contributors:
- * {contributing company name} - Initial API and implementation
+ * BMW Car IT - Initial API and implementation
*
* </copyright>
*/
@@ -21,6 +21,7 @@
import java.util.Set;
import org.eclipse.core.resources.IContainer;
+import org.eclipse.core.resources.IFile;
import org.eclipse.core.resources.IProject;
import org.eclipse.core.resources.IResource;
import org.eclipse.core.resources.IResourceChangeEvent;
@@ -37,6 +38,13 @@
import org.eclipse.sphinx.platform.resources.ResourceDeltaVisitor;
import org.eclipse.sphinx.platform.util.PlatformLogUtil;
+/**
+ * @deprecated Was used by {@link ProjectResourceScope#belongsToRootOrReferencedProjects(URI, boolean)} before whose
+ * implementation has been greatly simplified by converting provided {@link URI} to corresponding
+ * {@link IFile} and delegating to {@link ProjectResourceScope#belongsTo(IFile, boolean)} rather than
+ * relying on {@link IFile} to {@link URI} mappings provided by this cache.
+ */
+@Deprecated
public class ProjectResourceCache {
class InvalidationListener implements IResourceChangeListener {
diff --git a/plugins/org.eclipse.sphinx.emf/src/org/eclipse/sphinx/emf/scoping/ProjectResourceScope.java b/plugins/org.eclipse.sphinx.emf/src/org/eclipse/sphinx/emf/scoping/ProjectResourceScope.java
index 7481ec9..e192b7d 100644
--- a/plugins/org.eclipse.sphinx.emf/src/org/eclipse/sphinx/emf/scoping/ProjectResourceScope.java
+++ b/plugins/org.eclipse.sphinx.emf/src/org/eclipse/sphinx/emf/scoping/ProjectResourceScope.java
@@ -1,7 +1,7 @@
/**
* <copyright>
*
- * Copyright (c) 2008-2014 See4sys, itemis, BMW Car IT and others.
+ * Copyright (c) 2008-2019 See4sys, itemis, BMW Car IT 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
@@ -29,12 +29,12 @@
import org.eclipse.emf.ecore.resource.Resource;
import org.eclipse.sphinx.emf.scoping.ProjectResourceScopeProvider.IReferencedProjectsProvider;
import org.eclipse.sphinx.emf.scoping.ProjectResourceScopeProvider.ReferencedProjectsProvider;
+import org.eclipse.sphinx.emf.util.EcorePlatformUtil;
import org.eclipse.sphinx.platform.util.ExtendedPlatform;
public class ProjectResourceScope extends AbstractResourceScope {
protected IProject rootProject;
- private ProjectResourceCache resourceCache;
// Use a non-caching provider by default
protected IReferencedProjectsProvider referencedProjectsProvider = new ReferencedProjectsProvider();
@@ -42,7 +42,6 @@
public ProjectResourceScope(IResource resource) {
Assert.isNotNull(resource);
rootProject = resource.getProject();
- resourceCache = new ProjectResourceCache();
}
protected void setReferencedProjectsProvider(IReferencedProjectsProvider referencedProjectsProvider) {
@@ -157,20 +156,9 @@
return belongsToRootOrReferencedProjects(uri, includeReferencedScopes);
}
- protected boolean belongsToRootOrReferencedProjects(URI model, boolean includeReferencedScopes) {
- if (model != null) {
- if (resourceCache.getResources(rootProject).contains(model)) {
- return true;
- }
- if (includeReferencedScopes) {
- for (IResource referenced : getReferencedRoots()) {
- if (resourceCache.getResources(referenced.getProject()).contains(model)) {
- return true;
- }
- }
- }
- }
- return false;
+ protected boolean belongsToRootOrReferencedProjects(URI uri, boolean includeReferencedScopes) {
+ IFile file = EcorePlatformUtil.getFile(uri);
+ return belongsTo(file, includeReferencedScopes);
}
protected boolean belongsToRootOrReferencedProjects(IFile file, boolean includeReferencedScopes) {