use of org.eclipse.n4js.ts.findReferences.SimpleResourceAccess in project n4js by eclipse.
the class FindReferenceHelper method findReferences.
/**
* @return all references to the given declaration. Respect editor states.
*/
public List<EObject> findReferences(EObject declaration) {
declaration = getDeclaration(declaration);
TargetURIs targets = getTargets(declaration);
Resource eResource = declaration.eResource();
SimpleResourceAccess resourceAccess = new SimpleResourceAccess(eResource.getResourceSet());
IResourceDescriptions index = resourceDescriptionsProvider.getResourceDescriptions(eResource);
ReferenceAcceptor acceptor = new ReferenceAcceptor();
referenceFinder.findAllReferences(targets, resourceAccess, index, acceptor, null);
return acceptor.results;
}
use of org.eclipse.n4js.ts.findReferences.SimpleResourceAccess in project n4js by eclipse.
the class HeadlessReferenceFinder method findReferencesTo.
/**
* Find all references to the given target with its resource set as working environment.
*
* @param target
* the object to look for.
* @param monitor
* the progress monitor.
* @return the list of reference descriptions.
*/
public List<IReferenceDescription> findReferencesTo(EObject target, IProgressMonitor monitor) {
final TargetURIs targetURIs = getTargetURIs(target);
final ResourceSet resourceSet = target.eResource().getResourceSet();
final List<IReferenceDescription> result = Lists.newArrayList();
IReferenceFinder.IResourceAccess resourceAccess = new SimpleResourceAccess(resourceSet);
IReferenceFinder.Acceptor acceptor = new IReferenceFinder.Acceptor() {
@Override
public void accept(IReferenceDescription description) {
result.add(description);
}
@Override
public void accept(EObject source, URI sourceURI, EReference eReference, int index, EObject targetOrProxy, URI targetURI) {
accept(new DefaultReferenceDescription(sourceURI, targetURI, eReference, index, null));
}
};
referenceFinder.findAllReferences(targetURIs, resourceAccess, resourceDescriptionsProvider.getResourceDescriptions(resourceSet), acceptor, monitor);
return result;
}
use of org.eclipse.n4js.ts.findReferences.SimpleResourceAccess in project n4js by eclipse.
the class ConcreteSyntaxAwareReferenceFinder method findReferences.
@Override
public void findReferences(Predicate<URI> targetURIs, Resource resource, Acceptor acceptor, IProgressMonitor monitor) {
// make sure data is present
keys.getData((TargetURIs) targetURIs, new SimpleResourceAccess(resource.getResourceSet()));
EList<EObject> astContents;
if (resource instanceof N4JSResource) {
// In case of N4JSResource, we search only in the AST but NOT in TModule tree!
Script script = (Script) ((N4JSResource) resource).getContents().get(0);
astContents = new BasicEList<>();
astContents.add(script);
} else {
astContents = resource.getContents();
}
for (EObject content : astContents) {
findReferences(targetURIs, content, acceptor, monitor);
}
}
Aggregations