Search in sources :

Example 61 with QualifiedName

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

the class TypeScopeWithWildcardImports method getSingleElement.

@Override
public IEObjectDescription getSingleElement(QualifiedName name) {
    for (int i = 0; i < imports.length; i++) {
        ImportNormalizer[] chunk = imports[i];
        IEObjectDescription result = null;
        for (int j = 0; j < chunk.length; j++) {
            ImportNormalizer normalizer = chunk[j];
            QualifiedName resolvedName = normalizer.resolve(name);
            if (resolvedName != null) {
                IEObjectDescription candidate = typeScope.getSingleElement(resolvedName, true);
                if (candidate != null) {
                    if (result == null) {
                        result = candidate;
                    } else {
                        return null;
                    }
                }
            }
        }
        if (result != null) {
            return result;
        }
    }
    return getSingleElementFromParent(name);
}
Also used : ImportNormalizer(org.eclipse.xtext.scoping.impl.ImportNormalizer) QualifiedName(org.eclipse.xtext.naming.QualifiedName) IEObjectDescription(org.eclipse.xtext.resource.IEObjectDescription)

Example 62 with QualifiedName

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

the class Declarators method getDeclaratorData.

public Declarators.DeclaratorsData getDeclaratorData(final TargetURIs targetURIs, final IReferenceFinder.IResourceAccess resourceAccess) {
    Declarators.DeclaratorsData result = targetURIs.<Declarators.DeclaratorsData>getUserData(Declarators.KEY);
    if ((result != null)) {
        return result;
    }
    final HashSet<QualifiedName> declaratorNames = CollectionLiterals.<QualifiedName>newHashSet();
    final Consumer<URI> _function = (URI uri) -> {
        final IUnitOfWork<Object, ResourceSet> _function_1 = (ResourceSet it) -> {
            Object _xblockexpression = null;
            {
                final Consumer<URI> _function_2 = (URI objectURI) -> {
                    final EObject object = it.getEObject(objectURI, true);
                    if ((object != null)) {
                        final JvmType type = EcoreUtil2.<JvmType>getContainerOfType(object, JvmType.class);
                        if ((type != null)) {
                            QualifiedName _lowerCase = this.nameConverter.toQualifiedName(type.getIdentifier()).toLowerCase();
                            declaratorNames.add(_lowerCase);
                            QualifiedName _lowerCase_1 = this.nameConverter.toQualifiedName(type.getQualifiedName('.')).toLowerCase();
                            declaratorNames.add(_lowerCase_1);
                        }
                    }
                };
                targetURIs.getEObjectURIs(uri).forEach(_function_2);
                _xblockexpression = null;
            }
            return _xblockexpression;
        };
        resourceAccess.<Object>readOnly(uri, _function_1);
    };
    targetURIs.getTargetResourceURIs().forEach(_function);
    Declarators.DeclaratorsData _declaratorsData = new Declarators.DeclaratorsData(declaratorNames);
    result = _declaratorsData;
    targetURIs.<Declarators.DeclaratorsData>putUserData(Declarators.KEY, result);
    return result;
}
Also used : QualifiedName(org.eclipse.xtext.naming.QualifiedName) ResourceSet(org.eclipse.emf.ecore.resource.ResourceSet) JvmType(org.eclipse.xtext.common.types.JvmType) URI(org.eclipse.emf.common.util.URI) IUnitOfWork(org.eclipse.xtext.util.concurrent.IUnitOfWork) Consumer(java.util.function.Consumer) EObject(org.eclipse.emf.ecore.EObject) EObject(org.eclipse.emf.ecore.EObject)

Example 63 with QualifiedName

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

the class OperatorDeclarationTest method testOperatorDeclaration_genericReturnTypeWithFunctionType_02.

@Test
public void testOperatorDeclaration_genericReturnTypeWithFunctionType_02() {
    try {
        StringConcatenation _builder = new StringConcatenation();
        _builder.append("class A {");
        _builder.newLine();
        {
            Set<QualifiedName> _operators = this.operatorMapping.getOperators();
            for (final QualifiedName op : _operators) {
                _builder.append("\t");
                _builder.append("def Iterable< =>void> ");
                _builder.append(op, "\t");
                _builder.append("() { return null }");
                _builder.newLineIfNotEmpty();
            }
        }
        _builder.append("}");
        _builder.newLine();
        final XtendFile file = this._parseHelper.parse(_builder);
        Assert.assertTrue(IterableExtensions.join(file.eResource().getErrors(), "\n"), file.eResource().getErrors().isEmpty());
    } catch (Throwable _e) {
        throw Exceptions.sneakyThrow(_e);
    }
}
Also used : XtendFile(org.eclipse.xtend.core.xtend.XtendFile) Set(java.util.Set) QualifiedName(org.eclipse.xtext.naming.QualifiedName) StringConcatenation(org.eclipse.xtend2.lib.StringConcatenation) Test(org.junit.Test)

Example 64 with QualifiedName

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

the class OperatorDeclarationTest method testOperatorDeclaration_genericReturnType.

@Test
public void testOperatorDeclaration_genericReturnType() {
    try {
        StringConcatenation _builder = new StringConcatenation();
        _builder.append("class A {");
        _builder.newLine();
        {
            Set<QualifiedName> _operators = this.operatorMapping.getOperators();
            for (final QualifiedName op : _operators) {
                _builder.append("\t");
                _builder.append("def Iterable<String> ");
                _builder.append(op, "\t");
                _builder.append("() { return null }");
                _builder.newLineIfNotEmpty();
            }
        }
        _builder.append("}");
        _builder.newLine();
        final XtendFile file = this._parseHelper.parse(_builder);
        Assert.assertTrue(IterableExtensions.join(file.eResource().getErrors(), "\n"), file.eResource().getErrors().isEmpty());
    } catch (Throwable _e) {
        throw Exceptions.sneakyThrow(_e);
    }
}
Also used : XtendFile(org.eclipse.xtend.core.xtend.XtendFile) Set(java.util.Set) QualifiedName(org.eclipse.xtext.naming.QualifiedName) StringConcatenation(org.eclipse.xtend2.lib.StringConcatenation) Test(org.junit.Test)

Example 65 with QualifiedName

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

the class XtendLabelProvider method text.

protected StyledString text(final XtendFunction element) {
    final String simpleName = element.getName();
    if ((simpleName != null)) {
        final QualifiedName qnName = QualifiedName.create(simpleName);
        final QualifiedName operator = this.operatorMapping.getOperator(qnName);
        if ((operator != null)) {
            final StyledString result = this.signature(operator.getFirstSegment(), this._iXtendJvmAssociations.getDirectlyInferredOperation(element));
            result.append(((" (" + simpleName) + ")"), StyledString.COUNTER_STYLER);
            return result;
        }
    }
    return this.signature(element.getName(), this._iXtendJvmAssociations.getDirectlyInferredOperation(element));
}
Also used : QualifiedName(org.eclipse.xtext.naming.QualifiedName) StyledString(org.eclipse.jface.viewers.StyledString) StyledString(org.eclipse.jface.viewers.StyledString)

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