本文整理汇总了Java中org.eclipse.xtext.resource.IReferenceDescription类的典型用法代码示例。如果您正苦于以下问题:Java IReferenceDescription类的具体用法?Java IReferenceDescription怎么用?Java IReferenceDescription使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
IReferenceDescription类属于org.eclipse.xtext.resource包,在下文中一共展示了IReferenceDescription类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: getIncomingReferences
import org.eclipse.xtext.resource.IReferenceDescription; //导入依赖的package包/类
/***/
public static Set<IReferenceDescription> getIncomingReferences(URI uri) {
Set<IReferenceDescription> desc = Sets.newHashSet();
Iterable<IResourceDescription> descriptions = getAllResourceDescriptions();
for (IResourceDescription res : descriptions) {
Iterable<IReferenceDescription> descriptions2 = res.getReferenceDescriptions();
for (IReferenceDescription ref : descriptions2) {
if (uri.hasFragment()) {
if (ref.getTargetEObjectUri().equals(uri))
desc.add(ref);
} else {
if (ref.getTargetEObjectUri().trimFragment().equals(uri.trimFragment()))
desc.add(ref);
}
}
}
return desc;
}
示例2: getContainedReferences
import org.eclipse.xtext.resource.IReferenceDescription; //导入依赖的package包/类
/***/
public static Set<IReferenceDescription> getContainedReferences(URI uri) {
Set<IReferenceDescription> desc = Sets.newHashSet();
Iterable<IResourceDescription> descriptions = getAllResourceDescriptions();
for (IResourceDescription res : descriptions) {
Iterable<IReferenceDescription> descriptions2 = res.getReferenceDescriptions();
for (IReferenceDescription ref : descriptions2) {
if (uri.hasFragment()) {
if (ref.getSourceEObjectUri().equals(uri))
desc.add(ref);
} else {
if (ref.getSourceEObjectUri().trimFragment().equals(uri.trimFragment()))
desc.add(ref);
}
}
}
return desc;
}
示例3: isRelevantToUser
import org.eclipse.xtext.resource.IReferenceDescription; //导入依赖的package包/类
/**
* Returns <code>true</code> if the reference should be presented to the user.
*/
@Override
protected boolean isRelevantToUser(IReferenceDescription referenceDescription) {
if (referenceDescription instanceof LabelledReferenceDescription) {
EObject source = ((LabelledReferenceDescription) referenceDescription).getSource();
if (source.eContainer() instanceof JSXElementName && source.eContainer()
.eContainingFeature() == N4JSPackage.eINSTANCE.getJSXElement_JsxClosingName()) {
// Do not show JSX element's closing tag
return false;
} else {
return true;
}
} else {
return super.isRelevantToUser(referenceDescription);
}
}
示例4: toAcceptor
import org.eclipse.xtext.resource.IReferenceDescription; //导入依赖的package包/类
@Override
protected Acceptor toAcceptor(IAcceptor<IReferenceDescription> acceptor) {
return new ReferenceAcceptor(acceptor, getResourceServiceProviderRegistry()) {
@Override
public void accept(EObject source, URI sourceURI, EReference eReference, int index, EObject targetOrProxy,
URI targetURI) {
// Check if we should ignore named import specifier
if (N4JSReferenceQueryExecutor.ignoreNamedImportSpecifier && source instanceof NamedImportSpecifier)
return;
EObject displayObject = calculateDisplayEObject(source);
String logicallyQualifiedDisplayName = N4JSHierarchicalNameComputerHelper
.calculateLogicallyQualifiedDisplayName(displayObject, labelProvider, false);
ICompositeNode srcNode = NodeModelUtils.getNode(source);
int line = srcNode.getStartLine();
LabelledReferenceDescription description = new LabelledReferenceDescription(source, displayObject,
sourceURI,
targetOrProxy,
targetURI,
eReference, index, logicallyQualifiedDisplayName, line);
accept(description);
}
};
}
示例5: findReferencesTo
import org.eclipse.xtext.resource.IReferenceDescription; //导入依赖的package包/类
/**
* 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;
}
示例6: testNoReferenceDescriptionsForPackageFragments
import org.eclipse.xtext.resource.IReferenceDescription; //导入依赖的package包/类
@Test
public void testNoReferenceDescriptionsForPackageFragments() {
try {
final XExpression expression = this.expression("java::lang::String::valueOf(\"\")");
final Resource resource = expression.eResource();
final IResourceDescription description = this.resourceDescriptionManager.getResourceDescription(resource);
final Function1<IReferenceDescription, String> _function = (IReferenceDescription it) -> {
return it.getTargetEObjectUri().toString();
};
final Set<String> referenceDescriptions = IterableExtensions.<String>toSet(IterableExtensions.<IReferenceDescription, String>map(description.getReferenceDescriptions(), _function));
Assert.assertEquals(2, referenceDescriptions.size());
final Set<String> expectation = Collections.<String>unmodifiableSet(CollectionLiterals.<String>newHashSet("java:/Objects/java.lang.String#java.lang.String", "java:/Objects/java.lang.String#java.lang.String.valueOf(java.lang.Object)"));
Assert.assertEquals(expectation, referenceDescriptions);
} catch (Throwable _e) {
throw Exceptions.sneakyThrow(_e);
}
}
示例7: computeReferenceDescriptions
import org.eclipse.xtext.resource.IReferenceDescription; //导入依赖的package包/类
protected List<IReferenceDescription> computeReferenceDescriptions() {
final List<IReferenceDescription> referenceDescriptions = Lists.newArrayList();
IAcceptor<IReferenceDescription> acceptor = new IAcceptor<IReferenceDescription>() {
@Override
public void accept(IReferenceDescription referenceDescription) {
referenceDescriptions.add(referenceDescription);
}
};
EcoreUtil2.resolveLazyCrossReferences(resource, CancelIndicator.NullImpl);
Map<EObject, IEObjectDescription> eObject2exportedEObjects = createEObject2ExportedEObjectsMap(getExportedObjects());
TreeIterator<EObject> contents = EcoreUtil.getAllProperContents(this.resource, true);
while (contents.hasNext()) {
EObject eObject = contents.next();
URI exportedContainerURI = findExportedContainerURI(eObject, eObject2exportedEObjects);
if (!strategy.createReferenceDescriptions(eObject, exportedContainerURI, acceptor))
contents.prune();
}
return referenceDescriptions;
}
示例8: convertExternalURIsToPortableURIs
import org.eclipse.xtext.resource.IReferenceDescription; //导入依赖的package包/类
protected void convertExternalURIsToPortableURIs(final SerializableResourceDescription description, final StorageAwareResource resource) {
Iterable<IReferenceDescription> _referenceDescriptions = description.getReferenceDescriptions();
for (final IReferenceDescription ref : _referenceDescriptions) {
URI _trimFragment = ref.getTargetEObjectUri().trimFragment();
URI _uRI = resource.getURI();
boolean _notEquals = (!Objects.equal(_trimFragment, _uRI));
if (_notEquals) {
URI _elvis = null;
URI _portableURI = resource.getPortableURIs().toPortableURI(resource, ref.getTargetEObjectUri());
if (_portableURI != null) {
_elvis = _portableURI;
} else {
URI _targetEObjectUri = ref.getTargetEObjectUri();
_elvis = _targetEObjectUri;
}
((SerializableReferenceDescription) ref).setTargetEObjectUri(_elvis);
}
}
}
示例9: testgetReferenceDescriptions
import org.eclipse.xtext.resource.IReferenceDescription; //导入依赖的package包/类
@Test public void testgetReferenceDescriptions() throws Exception {
with(new LangATestLanguageStandaloneSetup());
XtextResource targetResource = getResource("type C", "bar.langatestlanguage");
EObject typeC = targetResource.getContents().get(0).eContents().get(0);
XtextResource resource = (XtextResource) targetResource.getResourceSet().createResource(URI.createURI("foo.langatestlanguage"));
resource.load(new StringInputStream("type A extends C type B extends A"), null);
EcoreUtil2.resolveLazyCrossReferences(resource, CancelIndicator.NullImpl);
IResourceDescription resDesc = resource.getResourceServiceProvider().getResourceDescriptionManager().getResourceDescription(resource);
Iterable<IReferenceDescription> descriptions = resDesc.getReferenceDescriptions();
Collection<IReferenceDescription> collection = Lists.newArrayList(descriptions);
assertEquals(1,collection.size());
IReferenceDescription refDesc = descriptions.iterator().next();
Main m = (Main) resource.getParseResult().getRootASTElement();
assertEquals(m.getTypes().get(0),resource.getResourceSet().getEObject(refDesc.getSourceEObjectUri(),false));
assertEquals(typeC, resource.getResourceSet().getEObject(refDesc.getTargetEObjectUri(),false));
assertEquals(-1,refDesc.getIndexInList());
assertEquals(LangATestLanguagePackage.Literals.TYPE__EXTENDS,refDesc.getEReference());
}
示例10: testgetReferenceDescriptionForMultiValue
import org.eclipse.xtext.resource.IReferenceDescription; //导入依赖的package包/类
@Test public void testgetReferenceDescriptionForMultiValue() throws Exception {
with(new LangATestLanguageStandaloneSetup());
XtextResource targetResource = getResource("type C type D", "bar.langatestlanguage");
EObject typeC = targetResource.getContents().get(0).eContents().get(0);
EObject typeD = targetResource.getContents().get(0).eContents().get(1);
XtextResource resource = (XtextResource) targetResource.getResourceSet().createResource(URI.createURI("foo.langatestlanguage"));
resource.load(new StringInputStream("type A implements B,C,D type B"), null);
EcoreUtil2.resolveLazyCrossReferences(resource, CancelIndicator.NullImpl);
IResourceDescription resDesc = resource.getResourceServiceProvider().getResourceDescriptionManager().getResourceDescription(resource);
Iterable<IReferenceDescription> descriptions = resDesc.getReferenceDescriptions();
Collection<IReferenceDescription> collection = Lists.newArrayList(descriptions);
assertEquals(2,collection.size());
Iterator<IReferenceDescription> iterator = descriptions.iterator();
IReferenceDescription refDesc1 = iterator.next();
IReferenceDescription refDesc2 = iterator.next();
Main m = (Main) resource.getParseResult().getRootASTElement();
assertEquals(m.getTypes().get(0),resource.getResourceSet().getEObject(refDesc1.getSourceEObjectUri(),false));
assertEquals(typeC,resource.getResourceSet().getEObject(refDesc1.getTargetEObjectUri(),false));
assertEquals(1,refDesc1.getIndexInList());
assertEquals(LangATestLanguagePackage.Literals.TYPE__IMPLEMENTS,refDesc1.getEReference());
assertEquals(m.getTypes().get(0),resource.getResourceSet().getEObject(refDesc2.getSourceEObjectUri(),false));
assertEquals(typeD,resource.getResourceSet().getEObject(refDesc2.getTargetEObjectUri(),false));
assertEquals(2,refDesc2.getIndexInList());
assertEquals(LangATestLanguagePackage.Literals.TYPE__IMPLEMENTS,refDesc2.getEReference());
}
示例11: getReferences
import org.eclipse.xtext.resource.IReferenceDescription; //导入依赖的package包/类
public List<? extends Location> getReferences(final XtextResource resource, final int offset, final IReferenceFinder.IResourceAccess resourceAccess, final IResourceDescriptions indexData, final CancelIndicator cancelIndicator) {
final EObject element = this._eObjectAtOffsetHelper.resolveElementAt(resource, offset);
if ((element == null)) {
return CollectionLiterals.<Location>emptyList();
}
final ArrayList<Location> locations = CollectionLiterals.<Location>newArrayList();
final TargetURIs targetURIs = this.collectTargetURIs(element);
final IAcceptor<IReferenceDescription> _function = (IReferenceDescription reference) -> {
final Procedure1<EObject> _function_1 = (EObject obj) -> {
final Location location = this._documentExtensions.newLocation(obj, reference.getEReference(), reference.getIndexInList());
if ((location != null)) {
locations.add(location);
}
};
this.doRead(resourceAccess, reference.getSourceEObjectUri(), _function_1);
};
ReferenceAcceptor _referenceAcceptor = new ReferenceAcceptor(this.resourceServiceProviderRegistry, _function);
CancelIndicatorProgressMonitor _cancelIndicatorProgressMonitor = new CancelIndicatorProgressMonitor(cancelIndicator);
this.referenceFinder.findAllReferences(targetURIs, resourceAccess, indexData, _referenceAcceptor, _cancelIndicatorProgressMonitor);
return locations;
}
示例12: buildChildren
import org.eclipse.xtext.resource.IReferenceDescription; //导入依赖的package包/类
@Override
public Collection<IHierarchyNode> buildChildren(final IHierarchyNode parent, final IProgressMonitor monitor) {
boolean _mayHaveChildren = parent.mayHaveChildren();
boolean _not = (!_mayHaveChildren);
if (_not) {
return CollectionLiterals.<IHierarchyNode>emptyList();
}
final LinkedHashMap<URI, IHierarchyNode> children = CollectionLiterals.<URI, IHierarchyNode>newLinkedHashMap();
final Procedure2<IEObjectDescription, IReferenceDescription> _function = (IEObjectDescription declaration, IReferenceDescription reference) -> {
final IHierarchyNode childNode = this.createChild(children, declaration, parent);
if ((childNode != null)) {
final IHierarchyNodeReference nodeReference = this.createNodeReference(reference);
if ((nodeReference != null)) {
Collection<IHierarchyNodeReference> _references = childNode.getReferences();
_references.add(nodeReference);
}
}
};
this.findDeclarations(parent, monitor, _function);
return children.values();
}
示例13: findTargetDeclarations
import org.eclipse.xtext.resource.IReferenceDescription; //导入依赖的package包/类
protected void findTargetDeclarations(final URI sourceDeclarationURI, final IProgressMonitor monitor, final Procedure2<? super IEObjectDescription, ? super IReferenceDescription> acceptor) {
final IUnitOfWork<Object, EObject> _function = (EObject sourceDeclaration) -> {
Object _xblockexpression = null;
{
IResourceServiceProvider.Registry _resourceServiceProviderRegistry = this.getResourceServiceProviderRegistry();
final IAcceptor<IReferenceDescription> _function_1 = (IReferenceDescription reference) -> {
boolean _filterReference = this.filterReference(reference);
if (_filterReference) {
IEObjectDescription _findTargetDeclaration = null;
if (reference!=null) {
_findTargetDeclaration=this.findTargetDeclaration(reference);
}
final IEObjectDescription targetDeclaration = _findTargetDeclaration;
acceptor.apply(targetDeclaration, reference);
}
};
ReferenceAcceptor _referenceAcceptor = new ReferenceAcceptor(_resourceServiceProviderRegistry, _function_1);
this.getReferenceFinder().findAllReferences(sourceDeclaration, _referenceAcceptor, monitor);
_xblockexpression = null;
}
return _xblockexpression;
};
this.<Object>readOnly(sourceDeclarationURI, _function);
}
示例14: findSourceDeclarations
import org.eclipse.xtext.resource.IReferenceDescription; //导入依赖的package包/类
protected void findSourceDeclarations(final URI targetDeclarationURI, final IProgressMonitor monitor, final Procedure2<? super IEObjectDescription, ? super IReferenceDescription> acceptor) {
final TargetURIs targetURIs = this.collectTargetURIs(targetDeclarationURI);
IResourceServiceProvider.Registry _resourceServiceProviderRegistry = this.getResourceServiceProviderRegistry();
final IAcceptor<IReferenceDescription> _function = (IReferenceDescription reference) -> {
boolean _filterReference = this.filterReference(reference);
if (_filterReference) {
IEObjectDescription _findSourceDeclaration = null;
if (reference!=null) {
_findSourceDeclaration=this.findSourceDeclaration(reference);
}
final IEObjectDescription sourceDeclaration = _findSourceDeclaration;
acceptor.apply(sourceDeclaration, reference);
}
};
ReferenceAcceptor _referenceAcceptor = new ReferenceAcceptor(_resourceServiceProviderRegistry, _function);
this.getReferenceFinder().findAllReferences(targetURIs,
this.getResourceAccess(),
this.getIndexData(), _referenceAcceptor, monitor);
}
示例15: computeReferenceDescriptions
import org.eclipse.xtext.resource.IReferenceDescription; //导入依赖的package包/类
@Override
protected List<IReferenceDescription> computeReferenceDescriptions() {
final ImmutableList.Builder<IReferenceDescription> referenceDescriptions = ImmutableList.builder();
EcoreUtil2.resolveLazyCrossReferences(getResource(), CancelIndicator.NullImpl);
Map<EObject, IEObjectDescription> eObject2exportedEObjects = createEObject2ExportedEObjectsMap(getExportedObjects());
TreeIterator<EObject> contents = EcoreUtil.getAllProperContents(getResource(), true);
while (contents.hasNext()) {
EObject eObject = contents.next();
URI exportedContainerURI = findExportedContainerURI(eObject, eObject2exportedEObjects);
if (!strategy.createReferenceDescriptions(eObject, exportedContainerURI, referenceDescriptions::add)) {
contents.prune();
}
}
if (strategy instanceof AbstractResourceDescriptionStrategy) {
((AbstractResourceDescriptionStrategy) strategy).createImplicitReferenceDescriptions(getResource(), referenceDescriptions::add);
}
return referenceDescriptions.build();
}