Search in sources :

Example 16 with QualifiedName

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);
    }
}
Also used : EObject(org.eclipse.emf.ecore.EObject) QualifiedName(org.eclipse.xtext.naming.QualifiedName) Resource(org.eclipse.emf.ecore.resource.Resource) ResourceSet(org.eclipse.emf.ecore.resource.ResourceSet) Grammar(org.eclipse.xtext.Grammar)

Example 17 with QualifiedName

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);
}
Also used : QualifiedName(org.eclipse.xtext.naming.QualifiedName) Test(org.junit.Test)

Example 18 with QualifiedName

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);
}
Also used : QualifiedName(org.eclipse.xtext.naming.QualifiedName)

Example 19 with QualifiedName

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;
}
Also used : Import(org.eclipse.xtext.testlanguages.fileAware.fileAware.Import) ImportNormalizer(org.eclipse.xtext.scoping.impl.ImportNormalizer) QualifiedName(org.eclipse.xtext.naming.QualifiedName) PackageDeclaration(org.eclipse.xtext.testlanguages.fileAware.fileAware.PackageDeclaration)

Example 20 with QualifiedName

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;
}
Also used : QualifiedName(org.eclipse.xtext.naming.QualifiedName) EObject(org.eclipse.emf.ecore.EObject) IEObjectDescription(org.eclipse.xtext.resource.IEObjectDescription)

Aggregations

QualifiedName (org.eclipse.xtext.naming.QualifiedName)215 IEObjectDescription (org.eclipse.xtext.resource.IEObjectDescription)78 EObject (org.eclipse.emf.ecore.EObject)46 Test (org.junit.Test)46 URI (org.eclipse.emf.common.util.URI)24 IResourceDescription (org.eclipse.xtext.resource.IResourceDescription)21 IScope (org.eclipse.xtext.scoping.IScope)21 EClass (org.eclipse.emf.ecore.EClass)18 Resource (org.eclipse.emf.ecore.resource.Resource)16 StringConcatenation (org.eclipse.xtend2.lib.StringConcatenation)13 XtendFile (org.eclipse.xtend.core.xtend.XtendFile)12 Set (java.util.Set)10 StyledString (org.eclipse.jface.viewers.StyledString)8 JvmType (org.eclipse.xtext.common.types.JvmType)8 XtextResource (org.eclipse.xtext.resource.XtextResource)8 ResourceSet (org.eclipse.emf.ecore.resource.ResourceSet)7 Grammar (org.eclipse.xtext.Grammar)6 JvmDeclaredType (org.eclipse.xtext.common.types.JvmDeclaredType)6 HashMap (java.util.HashMap)5 InternalEObject (org.eclipse.emf.ecore.InternalEObject)5