use of org.eclipse.xtext.naming.QualifiedName in project xtext-core by eclipse.
the class ImportNormalizerTest method testDeresolveIgnoreCase.
@Test
public void testDeresolveIgnoreCase() throws Exception {
QualifiedName namespace = QualifiedName.create("org", "eclipse", "xtext");
QualifiedName xtextFQN = namespace.append("Xtext");
QualifiedName ytextFQN = namespace.skipLast(1).append("ytext");
QualifiedName xytextFQN = namespace.append("ytext");
ImportNormalizer importNormalizer = new ImportNormalizer(xtextFQN.toUpperCase(), false, true);
assertEquals(QualifiedName.create("Xtext"), importNormalizer.deresolve(xtextFQN));
assertEquals(null, importNormalizer.deresolve(ytextFQN));
assertEquals(null, importNormalizer.deresolve(xytextFQN));
importNormalizer = new ImportNormalizer(xytextFQN.toUpperCase(), false, true);
assertEquals(null, importNormalizer.deresolve(xtextFQN));
assertEquals(null, importNormalizer.deresolve(ytextFQN));
assertEquals(QualifiedName.create("ytext"), importNormalizer.deresolve(xytextFQN));
ImportNormalizer wildCardImportNormalizer = new ImportNormalizer(namespace.toUpperCase(), true, true);
assertEquals(QualifiedName.create("Xtext"), wildCardImportNormalizer.deresolve(xtextFQN));
assertEquals(null, wildCardImportNormalizer.deresolve(ytextFQN));
assertEquals(QualifiedName.create("ytext"), wildCardImportNormalizer.deresolve(xytextFQN));
}
use of org.eclipse.xtext.naming.QualifiedName in project xtext-core by eclipse.
the class SlotEntry method matches.
protected boolean matches(Set<EClass> eclasses, IEObjectDescription desc) {
boolean valid = eclasses.isEmpty();
for (Iterator<EClass> iterator = eclasses.iterator(); !valid && iterator.hasNext(); ) {
EClass eClass = iterator.next();
valid = valid || EcorePackage.Literals.EOBJECT == eClass || eClass.isSuperTypeOf(desc.getEClass());
}
if (name != null) {
if (Strings.isEmpty(namespaceDelimiter)) {
return valid && name.equals(desc.getName().toString());
} else {
QualifiedName qualifiedName = QualifiedName.create(name.split(Pattern.quote(getNamespaceDelimiter())));
return valid && (qualifiedName == null || qualifiedName.equals(desc.getName()));
}
}
return valid;
}
use of org.eclipse.xtext.naming.QualifiedName in project xtext-core by eclipse.
the class DefaultLinkingService method getLinkedObjects.
/**
* @return the first element returned from the injected {@link IScopeProvider} which matches the text of the passed
* {@link INode node}
*/
@Override
public List<EObject> getLinkedObjects(EObject context, EReference ref, INode node) throws IllegalNodeException {
final EClass requiredType = ref.getEReferenceType();
if (requiredType == null) {
return Collections.<EObject>emptyList();
}
final String crossRefString = getCrossRefNodeAsString(node);
if (crossRefString == null || crossRefString.equals("")) {
return Collections.<EObject>emptyList();
}
if (logger.isDebugEnabled()) {
logger.debug("before getLinkedObjects: node: '" + crossRefString + "'");
}
final IScope scope = getScope(context, ref);
if (scope == null) {
throw new AssertionError("Scope provider " + scopeProvider.getClass().getName() + " must not return null for context " + context + ", reference " + ref + "! Consider to return IScope.NULLSCOPE instead.");
}
final QualifiedName qualifiedLinkName = qualifiedNameConverter.toQualifiedName(crossRefString);
final IEObjectDescription eObjectDescription = scope.getSingleElement(qualifiedLinkName);
if (logger.isDebugEnabled()) {
logger.debug("after getLinkedObjects: node: '" + crossRefString + "' result: " + eObjectDescription);
}
if (eObjectDescription == null) {
return Collections.emptyList();
}
final EObject result = eObjectDescription.getEObjectOrProxy();
return Collections.singletonList(result);
}
use of org.eclipse.xtext.naming.QualifiedName in project xtext-core by eclipse.
the class DefaultResourceDescription method getImportedNames.
@Override
public Iterable<QualifiedName> getImportedNames() {
EcoreUtil2.resolveLazyCrossReferences(resource, CancelIndicator.NullImpl);
ImportedNamesAdapter adapter = ImportedNamesAdapter.find(getResource());
if (adapter != null) {
ImmutableSet<QualifiedName> result = ImmutableSet.copyOf(adapter.getImportedNames());
return result;
}
return Collections.emptySet();
}
use of org.eclipse.xtext.naming.QualifiedName in project xtext-core by eclipse.
the class PortableURIs method fromFragmentString.
protected PortableURIs.PortableFragmentDescription fromFragmentString(final String fragmentString) {
final Iterator<String> segments = Splitter.on("#").split(fragmentString).iterator();
segments.next();
final URI eClassURI = URI.createURI(URI.decode(segments.next()));
final EPackage ePackage = this.packageRegistry.getEPackage(eClassURI.trimFragment().toString());
Resource _eResource = null;
if (ePackage != null) {
_eResource = ePackage.eResource();
}
EObject _eObject = null;
if (_eResource != null) {
_eObject = _eResource.getEObject(eClassURI.fragment());
}
final EClass eClass = ((EClass) _eObject);
final QualifiedName qname = QualifiedName.create(IterableExtensions.<String>toList(Splitter.on(":").split(URI.decode(segments.next()))));
String _xifexpression = null;
boolean _hasNext = segments.hasNext();
if (_hasNext) {
_xifexpression = URI.decode(segments.next());
}
final String fragment = _xifexpression;
EClass _elvis = null;
if (eClass != null) {
_elvis = eClass;
} else {
_elvis = EcorePackage.Literals.EOBJECT;
}
return new PortableURIs.PortableFragmentDescription(_elvis, qname, fragment);
}
Aggregations