mirror of
https://github.com/sigmasternchen/xtext-core
synced 2025-03-16 08:48:55 +00:00
[bug 489745][callHierarchy] Refactoring:
1. Make interfaces' names start with I; 2. Replace TargetURIs with Predicate<URI> for finding references in resource and object scopes. Change-Id: I5ff7b485f6438e8d447377d4f0942ca79fbc6c45 Signed-off-by: akosyakov <anton.kosyakov@typefox.io>
This commit is contained in:
parent
8e2f343c71
commit
69064ac12f
19 changed files with 69 additions and 132 deletions
|
@ -30,7 +30,7 @@ import static extension org.eclipse.xtext.EcoreUtil2.*
|
|||
* @since 2.10
|
||||
*/
|
||||
@Accessors(PUBLIC_SETTER, PROTECTED_GETTER)
|
||||
abstract class AbstractHierarchyBuilder implements HierarchyBuilder {
|
||||
abstract class AbstractHierarchyBuilder implements IHierarchyBuilder {
|
||||
|
||||
IResourceAccess resourceAccess
|
||||
|
||||
|
@ -46,7 +46,7 @@ abstract class AbstractHierarchyBuilder implements HierarchyBuilder {
|
|||
Provider<TargetURIs> targetURIProvider
|
||||
|
||||
@Inject
|
||||
HierarchyNodeLocationProvider hierarchyNodeLocationProvider
|
||||
IHierarchyNodeLocationProvider hierarchyNodeLocationProvider
|
||||
|
||||
@Inject
|
||||
IResourceServiceProvider.Registry resourceServiceProviderRegistry
|
||||
|
|
|
@ -30,7 +30,7 @@ import static extension org.eclipse.xtext.nodemodel.util.NodeModelUtils.*
|
|||
* @author kosyakov - Initial contribution and API
|
||||
* @since 2.10
|
||||
*/
|
||||
class DefaultCallHierarchyBuilder extends AbstractHierarchyBuilder implements CallHierarchyBuilder {
|
||||
class DefaultCallHierarchyBuilder extends AbstractHierarchyBuilder implements ICallHierarchyBuilder {
|
||||
|
||||
@Accessors
|
||||
CallHierarchyType hierarchyType = CallHierarchyType.CALLER
|
||||
|
@ -41,7 +41,7 @@ class DefaultCallHierarchyBuilder extends AbstractHierarchyBuilder implements Ca
|
|||
return #[rootDeclaration.createRoot]
|
||||
}
|
||||
|
||||
override buildChildren(HierarchyNode parent, IProgressMonitor monitor) {
|
||||
override buildChildren(IHierarchyNode parent, IProgressMonitor monitor) {
|
||||
if (!parent.mayHaveChildren)
|
||||
return emptyList
|
||||
|
||||
|
@ -55,7 +55,7 @@ class DefaultCallHierarchyBuilder extends AbstractHierarchyBuilder implements Ca
|
|||
}
|
||||
|
||||
protected def void findDeclarations(
|
||||
HierarchyNode parent,
|
||||
IHierarchyNode parent,
|
||||
IProgressMonitor monitor,
|
||||
(IEObjectDescription, IReferenceDescription)=>void acceptor
|
||||
) {
|
||||
|
@ -137,7 +137,7 @@ class DefaultCallHierarchyBuilder extends AbstractHierarchyBuilder implements Ca
|
|||
/**
|
||||
* @returns a root hierarchy node for the given declaration; cannot be <code>null</code>
|
||||
*/
|
||||
protected def HierarchyNode createRoot(IEObjectDescription declaration) {
|
||||
protected def IHierarchyNode createRoot(IEObjectDescription declaration) {
|
||||
val node = new DefaultHierarchyNode
|
||||
node.element = declaration
|
||||
node.mayHaveChildren = true
|
||||
|
@ -147,7 +147,7 @@ class DefaultCallHierarchyBuilder extends AbstractHierarchyBuilder implements Ca
|
|||
/**
|
||||
* @returns a child node for the given declaration and the parent node; cannot be <code>null</code>
|
||||
*/
|
||||
protected def HierarchyNode createChild(IEObjectDescription declaration, HierarchyNode parent) {
|
||||
protected def IHierarchyNode createChild(IEObjectDescription declaration, IHierarchyNode parent) {
|
||||
val node = new DefaultHierarchyNode
|
||||
node.parent = parent
|
||||
node.element = declaration
|
||||
|
@ -155,10 +155,10 @@ class DefaultCallHierarchyBuilder extends AbstractHierarchyBuilder implements Ca
|
|||
return node
|
||||
}
|
||||
|
||||
protected def HierarchyNode createChild(
|
||||
Map<URI, HierarchyNode> children,
|
||||
protected def IHierarchyNode createChild(
|
||||
Map<URI, IHierarchyNode> children,
|
||||
IEObjectDescription declaration,
|
||||
HierarchyNode parent
|
||||
IHierarchyNode parent
|
||||
) {
|
||||
if(declaration === null) return null;
|
||||
|
||||
|
@ -173,7 +173,7 @@ class DefaultCallHierarchyBuilder extends AbstractHierarchyBuilder implements Ca
|
|||
/**
|
||||
* @returns a hierarchy node reference for the given reference; cannot be <code>null</code>
|
||||
*/
|
||||
protected def HierarchyNodeReference createNodeReference(IReferenceDescription reference) {
|
||||
protected def IHierarchyNodeReference createNodeReference(IReferenceDescription reference) {
|
||||
return readOnly(reference.sourceEObjectUri) [ sourceObject |
|
||||
val textRegion = sourceObject.getTextRegion(reference.EReference, reference.indexInList)
|
||||
val text = sourceObject.getText(textRegion)
|
||||
|
|
|
@ -7,6 +7,7 @@
|
|||
*******************************************************************************/
|
||||
package org.eclipse.xtext.ide.editor.hierarchy
|
||||
|
||||
import java.util.List
|
||||
import org.eclipse.xtend.lib.annotations.Accessors
|
||||
import org.eclipse.xtext.resource.IEObjectDescription
|
||||
import org.eclipse.xtext.util.Wrapper
|
||||
|
@ -15,10 +16,10 @@ import org.eclipse.xtext.util.Wrapper
|
|||
* @author kosyakov - Initial contribution and API
|
||||
* @since 2.10
|
||||
*/
|
||||
class DefaultHierarchyNode implements HierarchyNode {
|
||||
class DefaultHierarchyNode implements IHierarchyNode {
|
||||
|
||||
@Accessors
|
||||
HierarchyNode parent
|
||||
IHierarchyNode parent
|
||||
|
||||
@Accessors(PUBLIC_SETTER)
|
||||
boolean mayHaveChildren
|
||||
|
@ -27,7 +28,7 @@ class DefaultHierarchyNode implements HierarchyNode {
|
|||
IEObjectDescription element
|
||||
|
||||
@Accessors(PUBLIC_GETTER)
|
||||
val references = <HierarchyNodeReference>newArrayList
|
||||
val List<IHierarchyNodeReference> references = <IHierarchyNodeReference>newArrayList
|
||||
|
||||
Wrapper<Boolean> recursive
|
||||
|
||||
|
|
|
@ -23,7 +23,7 @@ import static extension org.eclipse.xtext.nodemodel.util.NodeModelUtils.*
|
|||
* @since 2.10
|
||||
*/
|
||||
@Singleton
|
||||
class DefaultHierarchyNodeLocationProvider implements HierarchyNodeLocationProvider {
|
||||
class DefaultHierarchyNodeLocationProvider implements IHierarchyNodeLocationProvider {
|
||||
|
||||
@Inject
|
||||
protected ILocationInFileProvider locationInFileProvider
|
||||
|
|
|
@ -18,7 +18,7 @@ import org.eclipse.xtext.util.ITextRegionWithLineInformation
|
|||
*/
|
||||
@Accessors
|
||||
@FinalFieldsConstructor
|
||||
class DefaultHierarchyNodeReference implements HierarchyNodeReference {
|
||||
class DefaultHierarchyNodeReference implements IHierarchyNodeReference {
|
||||
val String text
|
||||
@Delegate
|
||||
val ITextRegionWithLineInformation textRegion
|
||||
|
|
|
@ -7,6 +7,7 @@
|
|||
*******************************************************************************/
|
||||
package org.eclipse.xtext.ide.editor.hierarchy
|
||||
|
||||
import java.util.List
|
||||
import org.eclipse.xtend.lib.annotations.Accessors
|
||||
|
||||
/**
|
||||
|
@ -14,6 +15,6 @@ import org.eclipse.xtend.lib.annotations.Accessors
|
|||
* @since 2.10
|
||||
*/
|
||||
@Accessors
|
||||
class DefaultHierarchyRoot implements HierarchyRoot {
|
||||
val roots = <HierarchyNode>newArrayList
|
||||
class DefaultHierarchyRoot implements IHierarchyRoot {
|
||||
val List<IHierarchyNode> roots = <IHierarchyNode>newArrayList
|
||||
}
|
||||
|
|
|
@ -13,7 +13,7 @@ package org.eclipse.xtext.ide.editor.hierarchy
|
|||
* @author kosyakov - Initial contribution and API
|
||||
* @since 2.10
|
||||
*/
|
||||
interface CallHierarchyBuilder extends HierarchyBuilder {
|
||||
interface ICallHierarchyBuilder extends IHierarchyBuilder {
|
||||
|
||||
static enum CallHierarchyType {
|
||||
CALLER,
|
|
@ -17,16 +17,16 @@ import org.eclipse.emf.common.util.URI
|
|||
* @author kosyakov - Initial contribution and API
|
||||
* @since 2.10
|
||||
*/
|
||||
interface HierarchyBuilder {
|
||||
interface IHierarchyBuilder {
|
||||
|
||||
/**
|
||||
* @returns root hierarchy nodes for the given URI; empty if the hierarchy cannot be built for the given URI
|
||||
*/
|
||||
def Collection<HierarchyNode> buildRoots(URI rootURI, IProgressMonitor monitor)
|
||||
def Collection<IHierarchyNode> buildRoots(URI rootURI, IProgressMonitor monitor)
|
||||
|
||||
/**
|
||||
* @returns child nodes for the given parent node; empty if {@link HierarchyNode#mayHaveChildren} returns <code>false</code> for the parent
|
||||
* @returns child nodes for the given parent node; empty if {@link IHierarchyNode#mayHaveChildren} returns <code>false</code> for the parent
|
||||
*/
|
||||
def Collection<HierarchyNode> buildChildren(HierarchyNode parent, IProgressMonitor monitor)
|
||||
def Collection<IHierarchyNode> buildChildren(IHierarchyNode parent, IProgressMonitor monitor)
|
||||
|
||||
}
|
|
@ -8,7 +8,7 @@
|
|||
package org.eclipse.xtext.ide.editor.hierarchy
|
||||
|
||||
import java.util.Collection
|
||||
import org.eclipse.xtext.ide.editor.navigation.Navigatable
|
||||
import org.eclipse.xtext.ide.editor.navigation.INavigatable
|
||||
import org.eclipse.xtext.resource.IEObjectDescription
|
||||
|
||||
/**
|
||||
|
@ -17,7 +17,7 @@ import org.eclipse.xtext.resource.IEObjectDescription
|
|||
* @author kosyakov - Initial contribution and API
|
||||
* @since 2.10
|
||||
*/
|
||||
interface HierarchyNode extends Navigatable {
|
||||
interface IHierarchyNode extends INavigatable {
|
||||
|
||||
/**
|
||||
* @returns an associated element that is used to build child nodes
|
||||
|
@ -27,12 +27,12 @@ interface HierarchyNode extends Navigatable {
|
|||
/**
|
||||
* @returns a parent; <code>null</code> if the node is a root
|
||||
*/
|
||||
def HierarchyNode getParent()
|
||||
def IHierarchyNode getParent()
|
||||
|
||||
/**
|
||||
* @returns references used to reach the node from a parent; empty if the node is a root
|
||||
*/
|
||||
def Collection<HierarchyNodeReference> getReferences()
|
||||
def Collection<IHierarchyNodeReference> getReferences()
|
||||
|
||||
/**
|
||||
* @returns whether there is a parent (can be transitive) containing the same element as the node
|
|
@ -13,13 +13,13 @@ import org.eclipse.emf.ecore.EStructuralFeature
|
|||
import org.eclipse.xtext.util.ITextRegionWithLineInformation
|
||||
|
||||
/**
|
||||
* This class is used to identify a region for {@link HierarchyNode} and {@link HierarchyNodeReference}.
|
||||
* This class is used to identify a region for {@link IHierarchyNode} and {@link IHierarchyNodeReference}.
|
||||
*
|
||||
* @author kosyakov - Initial contribution and API
|
||||
* @since 2.10
|
||||
*/
|
||||
@ImplementedBy(DefaultHierarchyNodeLocationProvider)
|
||||
interface HierarchyNodeLocationProvider {
|
||||
interface IHierarchyNodeLocationProvider {
|
||||
def ITextRegionWithLineInformation getTextRegion(EObject obj)
|
||||
|
||||
def ITextRegionWithLineInformation getTextRegion(EObject owner, EStructuralFeature feature, int indexInList)
|
|
@ -7,7 +7,7 @@
|
|||
*******************************************************************************/
|
||||
package org.eclipse.xtext.ide.editor.hierarchy
|
||||
|
||||
import org.eclipse.xtext.ide.editor.navigation.Navigatable
|
||||
import org.eclipse.xtext.ide.editor.navigation.INavigatable
|
||||
import org.eclipse.xtext.util.ITextRegionWithLineInformation
|
||||
|
||||
/**
|
||||
|
@ -16,6 +16,6 @@ import org.eclipse.xtext.util.ITextRegionWithLineInformation
|
|||
* @author kosyakov - Initial contribution and API
|
||||
* @since 2.10
|
||||
*/
|
||||
interface HierarchyNodeReference extends Navigatable, ITextRegionWithLineInformation {
|
||||
interface IHierarchyNodeReference extends INavigatable, ITextRegionWithLineInformation {
|
||||
def String getText()
|
||||
}
|
|
@ -15,11 +15,11 @@ import java.util.Collection
|
|||
* @author kosyakov - Initial contribution and API
|
||||
* @since 2.10
|
||||
*/
|
||||
interface HierarchyRoot {
|
||||
interface IHierarchyRoot {
|
||||
|
||||
def Collection<HierarchyNode> getRoots()
|
||||
def Collection<IHierarchyNode> getRoots()
|
||||
|
||||
val EMPTY = new HierarchyRoot() {
|
||||
val EMPTY = new IHierarchyRoot() {
|
||||
|
||||
override getRoots() {
|
||||
emptyList
|
|
@ -13,7 +13,7 @@ package org.eclipse.xtext.ide.editor.navigation
|
|||
* @author kosyakov - Initial contribution and API
|
||||
* @since 2.10
|
||||
*/
|
||||
interface Navigatable {
|
||||
interface INavigatable {
|
||||
|
||||
/**
|
||||
* <p>
|
|
@ -14,8 +14,6 @@ import org.eclipse.emf.common.util.URI
|
|||
import org.eclipse.emf.ecore.resource.ResourceSet
|
||||
import org.eclipse.xtend.lib.annotations.Accessors
|
||||
import org.eclipse.xtext.ide.editor.hierarchy.AbstractHierarchyBuilder
|
||||
import org.eclipse.xtext.ide.editor.hierarchy.HierarchyBuilder
|
||||
import org.eclipse.xtext.ide.editor.hierarchy.HierarchyNode
|
||||
import org.eclipse.xtext.junit4.validation.ValidationTestHelper
|
||||
import org.eclipse.xtext.resource.EObjectAtOffsetHelper
|
||||
import org.eclipse.xtext.resource.IResourceDescriptionsProvider
|
||||
|
@ -27,7 +25,9 @@ import org.eclipse.xtext.util.LazyStringInputStream
|
|||
import static org.junit.Assert.*
|
||||
|
||||
import static extension org.eclipse.xtext.EcoreUtil2.*
|
||||
import org.eclipse.xtext.ide.editor.hierarchy.HierarchyNodeReference
|
||||
import org.eclipse.xtext.ide.editor.hierarchy.IHierarchyBuilder
|
||||
import org.eclipse.xtext.ide.editor.hierarchy.IHierarchyNode
|
||||
import org.eclipse.xtext.ide.editor.hierarchy.IHierarchyNodeReference
|
||||
|
||||
/**
|
||||
* @author kosyakov - Initial contribution and API
|
||||
|
@ -80,19 +80,19 @@ abstract class AbstractHierarchyBuilderTest {
|
|||
return hierarchyBuilder
|
||||
}
|
||||
|
||||
protected def String toExpectation(URI rootURI, HierarchyBuilder builder) '''
|
||||
protected def String toExpectation(URI rootURI, IHierarchyBuilder builder) '''
|
||||
«FOR root : builder.buildRoots(rootURI, null)»
|
||||
«root.toExpectation(builder)»
|
||||
«ENDFOR»
|
||||
'''
|
||||
|
||||
protected def String toExpectation(HierarchyNode node, HierarchyBuilder builder) '''
|
||||
protected def String toExpectation(IHierarchyNode node, IHierarchyBuilder builder) '''
|
||||
«node.element» {
|
||||
«node.internalToExpectation(builder)»
|
||||
}
|
||||
'''
|
||||
|
||||
protected def String internalToExpectation(HierarchyNode node, HierarchyBuilder builder) '''
|
||||
protected def String internalToExpectation(IHierarchyNode node, IHierarchyBuilder builder) '''
|
||||
«FOR location : node.references»
|
||||
«location.toExpectation»
|
||||
«ENDFOR»
|
||||
|
@ -103,13 +103,13 @@ abstract class AbstractHierarchyBuilderTest {
|
|||
«ENDIF»
|
||||
'''
|
||||
|
||||
protected def String toExpectation(HierarchyNodeReference location) {
|
||||
protected def String toExpectation(IHierarchyNodeReference location) {
|
||||
''''«location.text»' [«location.offset», «location.length»]'''
|
||||
}
|
||||
|
||||
@Accessors
|
||||
protected static class HierarchyBuilderTestConfiguration {
|
||||
(ResourceSet)=>HierarchyBuilder hierarchyBuilderProvider
|
||||
(ResourceSet)=>IHierarchyBuilder hierarchyBuilderProvider
|
||||
Collection<Pair<String, String>> models = newArrayList
|
||||
int index
|
||||
String resourceURI
|
||||
|
|
|
@ -1,71 +0,0 @@
|
|||
/*******************************************************************************
|
||||
* Copyright (c) 2016 TypeFox GmbH (http://www.typefox.io) 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
|
||||
*******************************************************************************/
|
||||
package org.eclipse.xtext.findReferences
|
||||
|
||||
import com.google.common.collect.Iterators
|
||||
import com.google.inject.Singleton
|
||||
import org.eclipse.emf.common.util.URI
|
||||
|
||||
/**
|
||||
* It is used to look up all references for a resource or object scope.
|
||||
*
|
||||
* @author kosyakov - Initial contribution and API
|
||||
* @since 2.10
|
||||
*/
|
||||
@Singleton
|
||||
package class AnyTargetURISet implements TargetURIs {
|
||||
|
||||
override addAllURIs(Iterable<URI> uris) {
|
||||
// do nothing
|
||||
}
|
||||
|
||||
override addURI(URI uri) {
|
||||
// do nothing
|
||||
}
|
||||
|
||||
override asSet() {
|
||||
emptySet
|
||||
}
|
||||
|
||||
override contains(URI uri) {
|
||||
true
|
||||
}
|
||||
|
||||
override containsResource(URI resourceURI) {
|
||||
true
|
||||
}
|
||||
|
||||
override getEObjectURIs(URI resourceURI) {
|
||||
emptySet
|
||||
}
|
||||
|
||||
override getTargetResourceURIs() {
|
||||
emptySet
|
||||
}
|
||||
|
||||
override <T> getUserData(Key<T> key) {
|
||||
null
|
||||
}
|
||||
|
||||
override isEmpty() {
|
||||
true
|
||||
}
|
||||
|
||||
override <T> putUserData(Key<T> key, T data) {
|
||||
// do nothing
|
||||
}
|
||||
|
||||
override size() {
|
||||
0
|
||||
}
|
||||
|
||||
override iterator() {
|
||||
Iterators.emptyIterator
|
||||
}
|
||||
|
||||
}
|
|
@ -21,6 +21,7 @@ import org.eclipse.xtext.resource.IResourceDescriptions;
|
|||
import org.eclipse.xtext.resource.impl.DefaultResourceDescriptionStrategy;
|
||||
import org.eclipse.xtext.util.concurrent.IUnitOfWork;
|
||||
|
||||
import com.google.common.base.Predicate;
|
||||
import com.google.inject.ImplementedBy;
|
||||
|
||||
/**
|
||||
|
@ -108,7 +109,7 @@ public interface IReferenceFinder {
|
|||
* Finds the references from the given source resource to the given <code>targetURIs</code>.
|
||||
*
|
||||
* @param targetURIs
|
||||
* the URIs of the target elements of the references. Should be normalized.
|
||||
* a predicate that returns true if an URI belongs to target URIs; otherwise false.
|
||||
* @param resource
|
||||
* the search scope for the resources containing the sources of the references.
|
||||
* @param acceptor
|
||||
|
@ -117,7 +118,7 @@ public interface IReferenceFinder {
|
|||
* the progress monitor. Can be null.
|
||||
*/
|
||||
void findReferences(
|
||||
TargetURIs targetURIs,
|
||||
Predicate<URI> targetURIs,
|
||||
Resource resource,
|
||||
Acceptor acceptor,
|
||||
IProgressMonitor monitor);
|
||||
|
@ -141,7 +142,7 @@ public interface IReferenceFinder {
|
|||
* Finds the references from the given source object to the given <code>targetURIs</code>.
|
||||
*
|
||||
* @param targetURIs
|
||||
* the URIs of the target elements of the references. Should be normalized.
|
||||
* a predicate that returns true if an URI belongs to target URIs; otherwise false.
|
||||
* @param scope
|
||||
* the search scope for the object containing the sources of the references.
|
||||
* @param acceptor
|
||||
|
@ -150,7 +151,7 @@ public interface IReferenceFinder {
|
|||
* the progress monitor. Can be null.
|
||||
*/
|
||||
void findReferences(
|
||||
TargetURIs targetURIs,
|
||||
Predicate<URI> targetURIs,
|
||||
EObject scope,
|
||||
Acceptor acceptor,
|
||||
IProgressMonitor monitor);
|
||||
|
|
|
@ -29,6 +29,8 @@ import org.eclipse.xtext.resource.IResourceDescriptions;
|
|||
import org.eclipse.xtext.resource.IResourceServiceProvider;
|
||||
import org.eclipse.xtext.util.concurrent.IUnitOfWork;
|
||||
|
||||
import com.google.common.base.Predicate;
|
||||
import com.google.common.base.Predicates;
|
||||
import com.google.inject.Inject;
|
||||
import com.google.inject.Singleton;
|
||||
|
||||
|
@ -38,9 +40,6 @@ import com.google.inject.Singleton;
|
|||
*/
|
||||
@Singleton
|
||||
public class ReferenceFinder implements IReferenceFinder {
|
||||
|
||||
@Inject
|
||||
private AnyTargetURISet anyTargetURISet;
|
||||
|
||||
@Inject
|
||||
private IResourceServiceProvider.Registry serviceProviderRegistry;
|
||||
|
@ -118,11 +117,11 @@ public class ReferenceFinder implements IReferenceFinder {
|
|||
|
||||
@Override
|
||||
public void findAllReferences(Resource scope, Acceptor acceptor, IProgressMonitor monitor) {
|
||||
findReferences(anyTargetURISet, scope, acceptor, monitor);
|
||||
findReferences(Predicates.<URI>alwaysTrue(), scope, acceptor, monitor);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void findReferences(TargetURIs targetURIs, Resource resource, Acceptor acceptor, IProgressMonitor monitor) {
|
||||
public void findReferences(Predicate<URI> targetURIs, Resource resource, Acceptor acceptor, IProgressMonitor monitor) {
|
||||
for (EObject content : resource.getContents()) {
|
||||
findReferences(targetURIs, content, acceptor, monitor);
|
||||
}
|
||||
|
@ -130,11 +129,11 @@ public class ReferenceFinder implements IReferenceFinder {
|
|||
|
||||
@Override
|
||||
public void findAllReferences(EObject scope, Acceptor acceptor, IProgressMonitor monitor) {
|
||||
findReferences(anyTargetURISet, scope, acceptor, monitor);
|
||||
findReferences(Predicates.<URI>alwaysTrue(), scope, acceptor, monitor);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void findReferences(TargetURIs targetURIs, EObject scope, Acceptor acceptor, IProgressMonitor monitor) {
|
||||
public void findReferences(Predicate<URI> targetURIs, EObject scope, Acceptor acceptor, IProgressMonitor monitor) {
|
||||
if (monitor != null && monitor.isCanceled()) {
|
||||
throw new OperationCanceledException();
|
||||
}
|
||||
|
@ -189,7 +188,7 @@ public class ReferenceFinder implements IReferenceFinder {
|
|||
}
|
||||
|
||||
protected void findLocalReferencesFromElement(
|
||||
TargetURIs targetURIs,
|
||||
Predicate<URI> targetURIs,
|
||||
EObject sourceCandidate,
|
||||
Resource localResource,
|
||||
Acceptor acceptor) {
|
||||
|
@ -223,7 +222,7 @@ public class ReferenceFinder implements IReferenceFinder {
|
|||
EObject instanceOrProxy = toValidInstanceOrNull(localResource, targetURIs, values.basicGet(i));
|
||||
if (instanceOrProxy != null) {
|
||||
URI refURI= EcoreUtil2.getPlatformResourceOrNormalizedURI(instanceOrProxy);
|
||||
if(targetURIs.contains(refURI)) {
|
||||
if(targetURIs.apply(refURI)) {
|
||||
sourceURI = (sourceURI == null) ? EcoreUtil2.getPlatformResourceOrNormalizedURI(sourceCandidate) : sourceURI;
|
||||
acceptor.accept(sourceCandidate, sourceURI, ref, i, instanceOrProxy, refURI);
|
||||
}
|
||||
|
@ -233,7 +232,7 @@ public class ReferenceFinder implements IReferenceFinder {
|
|||
EObject instanceOrProxy = toValidInstanceOrNull(localResource, targetURIs, (EObject) value);
|
||||
if (instanceOrProxy != null) {
|
||||
URI refURI = EcoreUtil2.getPlatformResourceOrNormalizedURI(instanceOrProxy);
|
||||
if (targetURIs.contains(refURI)) {
|
||||
if (targetURIs.apply(refURI)) {
|
||||
sourceURI = (sourceURI == null) ? EcoreUtil2
|
||||
.getPlatformResourceOrNormalizedURI(sourceCandidate) : sourceURI;
|
||||
acceptor.accept(sourceCandidate, sourceURI, ref, -1, instanceOrProxy, refURI);
|
||||
|
@ -247,7 +246,7 @@ public class ReferenceFinder implements IReferenceFinder {
|
|||
}
|
||||
}
|
||||
|
||||
protected EObject toValidInstanceOrNull(Resource resource, TargetURIs targetURIs, EObject value) {
|
||||
protected EObject toValidInstanceOrNull(Resource resource, Predicate<URI> targetURIs, EObject value) {
|
||||
EObject result = resolveInternalProxy(value, resource);
|
||||
return result;
|
||||
}
|
||||
|
@ -259,11 +258,11 @@ public class ReferenceFinder implements IReferenceFinder {
|
|||
return elementOrProxy;
|
||||
}
|
||||
|
||||
protected boolean doProcess(EObject sourceCandidate, TargetURIs targetURISet) {
|
||||
protected boolean doProcess(EObject sourceCandidate, Predicate<URI> targetURIs) {
|
||||
return true;
|
||||
}
|
||||
|
||||
protected boolean doProcess(EReference reference, TargetURIs targetURISet) {
|
||||
protected boolean doProcess(EReference reference, Predicate<URI> targetURIs) {
|
||||
return true;
|
||||
}
|
||||
|
||||
|
|
|
@ -89,6 +89,11 @@ public class TargetURISet extends AbstractSet<URI> implements TargetURIs {
|
|||
return Collections.unmodifiableCollection(index.get(resourceURI));
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean apply(URI uri) {
|
||||
return contains(uri);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean contains(URI uri) {
|
||||
return uris.contains(uri);
|
||||
|
|
|
@ -12,6 +12,7 @@ import java.util.Set;
|
|||
|
||||
import org.eclipse.emf.common.util.URI;
|
||||
|
||||
import com.google.common.base.Predicate;
|
||||
import com.google.inject.ImplementedBy;
|
||||
|
||||
/**
|
||||
|
@ -26,7 +27,7 @@ import com.google.inject.ImplementedBy;
|
|||
* @since 2.10
|
||||
*/
|
||||
@ImplementedBy(TargetURISet.class)
|
||||
public interface TargetURIs extends Iterable<URI> {
|
||||
public interface TargetURIs extends Iterable<URI>, Predicate<URI> {
|
||||
|
||||
/**
|
||||
* A user data key with equalitiy semantics on the type of the value and the
|
||||
|
|
Loading…
Reference in a new issue