diff options
author | Christian W. Damus | 2021-08-11 12:52:04 +0000 |
---|---|---|
committer | Patrick Tessier | 2021-08-30 08:35:04 +0000 |
commit | de558039242c4c0b4a209cccc3a74b64c8054175 (patch) | |
tree | a1a88bf475c93b1aa44d8b02705cb35d4ee56591 | |
parent | c059db8bd1345e202f6a55fae76424aefd96bba1 (diff) | |
download | org.eclipse.papyrus-de558039242c4c0b4a209cccc3a74b64c8054175.tar.gz org.eclipse.papyrus-de558039242c4c0b4a209cccc3a74b64c8054175.tar.xz org.eclipse.papyrus-de558039242c4c0b4a209cccc3a74b64c8054175.zip |
Bug 573042: Spurious indexing
- do not index derived resources in the workspace
Change-Id: Iefde5547bf8722d73d0f3707ec1d07fcccd7ab88
Signed-off-by: Christian W. Damus <give.a.damus@gmail.com>
2 files changed, 42 insertions, 2 deletions
diff --git a/plugins/infra/emf/org.eclipse.papyrus.infra.emf/src/org/eclipse/papyrus/infra/emf/internal/resource/index/IndexManager.java b/plugins/infra/emf/org.eclipse.papyrus.infra.emf/src/org/eclipse/papyrus/infra/emf/internal/resource/index/IndexManager.java index 91d08dc8d31..214c742b7c5 100644 --- a/plugins/infra/emf/org.eclipse.papyrus.infra.emf/src/org/eclipse/papyrus/infra/emf/internal/resource/index/IndexManager.java +++ b/plugins/infra/emf/org.eclipse.papyrus.infra.emf/src/org/eclipse/papyrus/infra/emf/internal/resource/index/IndexManager.java @@ -1122,7 +1122,8 @@ public class IndexManager { @Override public boolean visit(IResource resource) throws CoreException { - boolean result = !monitor.isCanceled(); + // bug 573042: do not index derived resources + boolean result = !monitor.isCanceled() && !resource.isDerived(); if (result && (resource.getType() == IResource.FILE)) { scan((IFile) resource); @@ -1253,7 +1254,8 @@ public class IndexManager { @Override public boolean visit(IResourceDelta delta) throws CoreException { - if (delta.getResource().getType() == IResource.FILE) { + // bug 573042: do not index derived resources + if (delta.getResource().getType() == IResource.FILE && !delta.getResource().isDerived(IResource.CHECK_ANCESTORS)) { IFile file = (IFile) delta.getResource(); switch (delta.getKind()) { diff --git a/tests/junit/plugins/infra/emf/org.eclipse.papyrus.infra.emf.tests/tests/org/eclipse/papyrus/infra/emf/resource/index/WorkspaceModelIndexTest.java b/tests/junit/plugins/infra/emf/org.eclipse.papyrus.infra.emf.tests/tests/org/eclipse/papyrus/infra/emf/resource/index/WorkspaceModelIndexTest.java index e76eba65479..e82124702c8 100644 --- a/tests/junit/plugins/infra/emf/org.eclipse.papyrus.infra.emf.tests/tests/org/eclipse/papyrus/infra/emf/resource/index/WorkspaceModelIndexTest.java +++ b/tests/junit/plugins/infra/emf/org.eclipse.papyrus.infra.emf.tests/tests/org/eclipse/papyrus/infra/emf/resource/index/WorkspaceModelIndexTest.java @@ -46,12 +46,16 @@ import org.eclipse.core.resources.IFile; import org.eclipse.core.resources.IProject; import org.eclipse.core.resources.IResource; import org.eclipse.core.runtime.CoreException; +import org.eclipse.core.runtime.ICoreRunnable; +import org.eclipse.core.runtime.IPath; import org.eclipse.core.runtime.IProgressMonitor; import org.eclipse.core.runtime.IStatus; +import org.eclipse.core.runtime.NullProgressMonitor; import org.eclipse.core.runtime.Path; import org.eclipse.core.runtime.Platform; import org.eclipse.core.runtime.QualifiedName; import org.eclipse.core.runtime.Status; +import org.eclipse.core.runtime.SubMonitor; import org.eclipse.core.runtime.jobs.IJobChangeEvent; import org.eclipse.core.runtime.jobs.Job; import org.eclipse.core.runtime.jobs.JobChangeAdapter; @@ -373,6 +377,40 @@ public class WorkspaceModelIndexTest extends AbstractPapyrusTest { assertIndex(index); } + /** + * Verify that derived resources are not indexed. + * + * @see https://bugs.eclipse.org/bugs/show_bug.cgi?id=573042 + */ + @Test + public void indexNotBuiltForDerivedResources() throws Exception { + IPath newReferencingFilePath = referencingFile.getProjectRelativePath().removeLastSegments(1).append("derived") + .addFileExtension(referencingFile.getFileExtension()); + IFile newReferencingFile = referencingFile.getProject().getFile(newReferencingFilePath); + + ICoreRunnable furtherSetup = monitor -> { + SubMonitor sub = SubMonitor.convert(monitor, 2); + referencingFile.copy(newReferencingFilePath, false, sub.newChild(1)); + newReferencingFile.setDerived(true, sub.newChild(1)); + sub.done(); + }; + + // Interlock with the indexing to ensure that we don't try the index before it hears + // about the file delta + sync.init(SyncMode.TEST, IndexMode.INDEX); + + newReferencingFile.getWorkspace().run(furtherSetup, new NullProgressMonitor()); + + // Wait for the indexing to start. If it doesn't start within five seconds, then + // something is wrong with the resource change notifications + sync.syncFromTest(); + + Map<IFile, CrossReferenceIndex> index = fixture.getIndex().get(); + + // The new Referencing URI is not included in the index + assertIndex(index, true, Set.of(), Set.of(referencingURI), true, Set.of(), Set.of(referencedURI)); + } + // // Test framework // |