Search in sources :

Example 56 with QualifiedName

use of org.eclipse.xtext.naming.QualifiedName in project xtext-core by eclipse.

the class PortableURIs method createPortableFragmentDescription.

protected PortableURIs.PortableFragmentDescription createPortableFragmentDescription(final IEObjectDescription desc, final EObject target) {
    final EObject possibleContainer = EcoreUtil.resolve(desc.getEObjectOrProxy(), target);
    final String fragmentToTarget = this.getFragment(target, possibleContainer);
    EClass _eClass = desc.getEClass();
    QualifiedName _qualifiedName = desc.getQualifiedName();
    return new PortableURIs.PortableFragmentDescription(_eClass, _qualifiedName, fragmentToTarget);
}
Also used : EClass(org.eclipse.emf.ecore.EClass) EObject(org.eclipse.emf.ecore.EObject) InternalEObject(org.eclipse.emf.ecore.InternalEObject) QualifiedName(org.eclipse.xtext.naming.QualifiedName)

Example 57 with QualifiedName

use of org.eclipse.xtext.naming.QualifiedName in project xtext-core by eclipse.

the class CrossReferenceSerializer method serializeCrossRef.

@Override
public String serializeCrossRef(EObject semanticObject, CrossReference crossref, EObject target, INode node, Acceptor errors) {
    if ((target == null || target.eIsProxy()) && node != null)
        return tokenUtil.serializeNode(node);
    final EReference ref = GrammarUtil.getReference(crossref, semanticObject.eClass());
    final IScope scope = scopeProvider.getScope(semanticObject, ref);
    if (scope == null) {
        if (errors != null)
            errors.accept(diagnostics.getNoScopeFoundDiagnostic(semanticObject, crossref, target));
        return null;
    }
    if (target != null && target.eIsProxy()) {
        target = handleProxy(target, semanticObject, ref);
    }
    if (target != null && node != null) {
        String text = linkingHelper.getCrossRefNodeAsString(node, true);
        QualifiedName qn = qualifiedNameConverter.toQualifiedName(text);
        URI targetURI = EcoreUtil2.getPlatformResourceOrNormalizedURI(target);
        for (IEObjectDescription desc : scope.getElements(qn)) {
            if (targetURI.equals(desc.getEObjectURI()))
                return tokenUtil.serializeNode(node);
        }
    }
    return getCrossReferenceNameFromScope(semanticObject, crossref, target, scope, errors);
}
Also used : QualifiedName(org.eclipse.xtext.naming.QualifiedName) IScope(org.eclipse.xtext.scoping.IScope) URI(org.eclipse.emf.common.util.URI) EReference(org.eclipse.emf.ecore.EReference) IEObjectDescription(org.eclipse.xtext.resource.IEObjectDescription)

Example 58 with QualifiedName

use of org.eclipse.xtext.naming.QualifiedName in project coffeescript-eclipse by adamschmideg.

the class LinkingServiceWithNode method getLinkedObjects.

/**
	 * Basically a copy of super, only linkNode is remembered before calling getScope
	 */
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("")) {
        linkNode = node;
        final IScope scope = getScope(context, ref);
        linkNode = null;
        QualifiedName qualifiedLinkName = qualifiedNameConverter.toQualifiedName(crossRefString);
        IEObjectDescription eObjectDescription = scope.getSingleElement(qualifiedLinkName);
        if (eObjectDescription != null)
            return Collections.singletonList(eObjectDescription.getEObjectOrProxy());
    }
    return Collections.emptyList();
}
Also used : EClass(org.eclipse.emf.ecore.EClass) QualifiedName(org.eclipse.xtext.naming.QualifiedName) IScope(org.eclipse.xtext.scoping.IScope) IEObjectDescription(org.eclipse.xtext.resource.IEObjectDescription)

Example 59 with QualifiedName

use of org.eclipse.xtext.naming.QualifiedName in project mechanoid by robotoworks.

the class XSqliteModelScopeProvider method scopeForTableDefinitionsBeforeStatement.

public IScope scopeForTableDefinitionsBeforeStatement(final DatabaseBlock db, final DDLStatement stmt, final boolean inclusive) {
    ArrayList<TableDefinition> refs = ModelUtil.<TableDefinition>findPreviousStatementsOfType(db, stmt, TableDefinition.class, inclusive);
    final HashMap<String, EObject> map = new HashMap<String, EObject>();
    List<TableDefinition> _reverse = ListExtensions.<TableDefinition>reverse(refs);
    for (final TableDefinition ref : _reverse) {
        {
            String _name = ref.getName();
            boolean _equals = Objects.equal(_name, null);
            if (_equals) {
                return IScope.NULLSCOPE;
            }
            String _name_1 = ref.getName();
            boolean _containsKey = map.containsKey(_name_1);
            boolean _not = (!_containsKey);
            if (_not) {
                String _name_2 = ref.getName();
                map.put(_name_2, ref);
            }
        }
    }
    Collection<EObject> _values = map.values();
    final Function<EObject, QualifiedName> _function = new Function<EObject, QualifiedName>() {

        public QualifiedName apply(final EObject it) {
            return NameHelper.getName(((TableDefinition) it));
        }
    };
    return Scopes.<EObject>scopeFor(_values, _function, IScope.NULLSCOPE);
}
Also used : Function(com.google.common.base.Function) HashMap(java.util.HashMap) EObject(org.eclipse.emf.ecore.EObject) QualifiedName(org.eclipse.xtext.naming.QualifiedName) TableDefinition(com.robotoworks.mechanoid.db.sqliteModel.TableDefinition)

Example 60 with QualifiedName

use of org.eclipse.xtext.naming.QualifiedName in project xtext-xtend by eclipse.

the class LegacyKnownTypesScope method doGetDescriptions.

@Override
protected void doGetDescriptions(JvmType type, JvmType knownType, int index, List<IEObjectDescription> result) {
    super.doGetDescriptions(type, knownType, index, result);
    QualifiedName importName = importNames.get(index);
    if (type == knownType && importName != null) {
        result.add(EObjectDescription.create(QualifiedName.create(importName.getLastSegment()), type));
    }
}
Also used : QualifiedName(org.eclipse.xtext.naming.QualifiedName)

Aggregations

QualifiedName (org.eclipse.xtext.naming.QualifiedName)97 IEObjectDescription (org.eclipse.xtext.resource.IEObjectDescription)32 Test (org.junit.Test)31 EObject (org.eclipse.emf.ecore.EObject)27 IResourceDescription (org.eclipse.xtext.resource.IResourceDescription)16 EClass (org.eclipse.emf.ecore.EClass)12 Resource (org.eclipse.emf.ecore.resource.Resource)12 XtendFile (org.eclipse.xtend.core.xtend.XtendFile)12 StringConcatenation (org.eclipse.xtend2.lib.StringConcatenation)12 IScope (org.eclipse.xtext.scoping.IScope)10 Set (java.util.Set)9 URI (org.eclipse.emf.common.util.URI)7 XtextResource (org.eclipse.xtext.resource.XtextResource)7 StringInputStream (org.eclipse.xtext.util.StringInputStream)7 JvmType (org.eclipse.xtext.common.types.JvmType)6 Function (com.google.common.base.Function)4 HashMap (java.util.HashMap)4 Map (java.util.Map)4 InternalEObject (org.eclipse.emf.ecore.InternalEObject)4 JvmDeclaredType (org.eclipse.xtext.common.types.JvmDeclaredType)4