use of org.eclipse.xtext.naming.QualifiedName in project xtext-eclipse by eclipse.
the class SyntheticResourceAwareScopeProvider method scope_Codetemplates_language.
public IScope scope_Codetemplates_language(Codetemplates templates, EReference reference) {
if (TemplateResourceProvider.SYNTHETIC_SCHEME.equals(templates.eResource().getURI().scheme())) {
ResourceSet resourceSet = templates.eResource().getResourceSet();
List<Grammar> grammars = Lists.newArrayListWithExpectedSize(1);
for (Resource resource : resourceSet.getResources()) {
EObject root = resource.getContents().get(0);
if (root instanceof Grammar) {
grammars.add((Grammar) root);
}
}
return Scopes.scopeFor(grammars, new Function<Grammar, QualifiedName>() {
@Override
public QualifiedName apply(Grammar from) {
return qualifiedNameConverter.toQualifiedName(from.getName());
}
}, IScope.NULLSCOPE);
} else {
return delegateGetScope(templates, reference);
}
}
use of org.eclipse.xtext.naming.QualifiedName in project xtext-eclipse by eclipse.
the class BuilderStateFactoryTest method testEmptyStringToQualifiedName.
@Test
public void testEmptyStringToQualifiedName() {
QualifiedName qn = (QualifiedName) factory.createFromString(dataType, "");
assertEquals(QualifiedName.EMPTY, qn);
}
use of org.eclipse.xtext.naming.QualifiedName in project xtext-eclipse by eclipse.
the class ReferenceQueryExecutor method getElementName.
protected String getElementName(EObject primaryTarget) {
QualifiedName qualifiedName = qualifiedNameProvider.getFullyQualifiedName(primaryTarget);
if (qualifiedName != null) {
return qualifiedNameConverter.toString(qualifiedName);
}
String simpleName = SimpleAttributeResolver.NAME_RESOLVER.getValue(primaryTarget);
return (simpleName != null) ? simpleName : primaryTarget.eResource().getURIFragment(primaryTarget);
}
use of org.eclipse.xtext.naming.QualifiedName in project xtext-core by eclipse.
the class FileAwareTestLanguageImportScopeProvider method internalGetImportedNamespaceResolvers.
@Override
protected List<ImportNormalizer> internalGetImportedNamespaceResolvers(final EObject context, final boolean ignoreCase) {
final List<ImportNormalizer> resolvers = super.internalGetImportedNamespaceResolvers(context, ignoreCase);
if ((context instanceof PackageDeclaration)) {
QualifiedName _qualifiedName = this.getQualifiedNameConverter().toQualifiedName(((PackageDeclaration) context).getName());
ImportNormalizer _importNormalizer = new ImportNormalizer(_qualifiedName, true, false);
resolvers.add(_importNormalizer);
EList<Import> _imports = ((PackageDeclaration) context).getImports();
for (final Import imp : _imports) {
{
final QualifiedName name = this.getImportedNamespace(imp);
ImportNormalizer _importNormalizer_1 = new ImportNormalizer(name, false, false);
resolvers.add(_importNormalizer_1);
}
}
}
return resolvers;
}
use of org.eclipse.xtext.naming.QualifiedName in project xtext-core by eclipse.
the class EObjectDescriptionProvider method computeSimpleName.
protected QualifiedName computeSimpleName(Multimap<EObject, IEObjectDescription> descs, IEObjectDescription desc) {
QualifiedName name = desc.getQualifiedName();
int segmentCount = name.getSegmentCount();
if (segmentCount < 2) {
return name;
}
EObject container = desc.getEObjectOrProxy().eContainer();
while (container != null) {
Collection<IEObjectDescription> candidates = descs.get(container);
for (IEObjectDescription cand : candidates) {
QualifiedName candName = cand.getQualifiedName();
int candCount = candName.getSegmentCount();
if (candCount < segmentCount && name.startsWith(candName)) {
return name.skipFirst(candCount);
}
}
container = container.eContainer();
}
return name;
}
Aggregations