Search in sources :

Example 16 with StandardTypeReferenceOwner

use of org.eclipse.xtext.xbase.typesystem.references.StandardTypeReferenceOwner in project xtext-xtend by eclipse.

the class AbstractOverloadedStaticMethodTest method linksTo.

protected void linksTo(final String invocation, final String method) {
    try {
        final XtendFile file = this.file(this.inMethodBody(invocation), false);
        XtendTypeDeclaration _head = IterableExtensions.<XtendTypeDeclaration>head(file.getXtendTypes());
        final XtendClass c = ((XtendClass) _head);
        XtendMember _head_1 = IterableExtensions.<XtendMember>head(c.getMembers());
        final XtendFunction m = ((XtendFunction) _head_1);
        XExpression _expression = m.getExpression();
        final XBlockExpression body = ((XBlockExpression) _expression);
        XExpression _last = IterableExtensions.<XExpression>last(body.getExpressions());
        final XAbstractFeatureCall featureCall = ((XAbstractFeatureCall) _last);
        JvmIdentifiableElement _feature = featureCall.getFeature();
        final JvmOperation operation = ((JvmOperation) _feature);
        final StandardTypeReferenceOwner owner = new StandardTypeReferenceOwner(this.services, file);
        final ParameterizedTypeReference declaration = owner.newParameterizedTypeReference(operation.getDeclaringType());
        final BottomResolvedOperation resolved = new BottomResolvedOperation(operation, declaration, this.overrideTester);
        Assert.assertEquals(method, resolved.getSimpleSignature());
        Assert.assertTrue(IterableExtensions.join(file.eResource().getErrors(), "\n"), file.eResource().getErrors().isEmpty());
        Assert.assertNull(featureCall.getImplicitReceiver());
        Assert.assertNull(featureCall.getImplicitFirstArgument());
    } catch (Throwable _e) {
        throw Exceptions.sneakyThrow(_e);
    }
}
Also used : XtendFile(org.eclipse.xtend.core.xtend.XtendFile) XtendFunction(org.eclipse.xtend.core.xtend.XtendFunction) XBlockExpression(org.eclipse.xtext.xbase.XBlockExpression) JvmIdentifiableElement(org.eclipse.xtext.common.types.JvmIdentifiableElement) XtendMember(org.eclipse.xtend.core.xtend.XtendMember) XAbstractFeatureCall(org.eclipse.xtext.xbase.XAbstractFeatureCall) JvmOperation(org.eclipse.xtext.common.types.JvmOperation) XtendClass(org.eclipse.xtend.core.xtend.XtendClass) ParameterizedTypeReference(org.eclipse.xtext.xbase.typesystem.references.ParameterizedTypeReference) XtendTypeDeclaration(org.eclipse.xtend.core.xtend.XtendTypeDeclaration) XExpression(org.eclipse.xtext.xbase.XExpression) BottomResolvedOperation(org.eclipse.xtext.xbase.typesystem.override.BottomResolvedOperation) StandardTypeReferenceOwner(org.eclipse.xtext.xbase.typesystem.references.StandardTypeReferenceOwner)

Example 17 with StandardTypeReferenceOwner

use of org.eclipse.xtext.xbase.typesystem.references.StandardTypeReferenceOwner in project xtext-xtend by eclipse.

the class CompilationUnitImpl method setXtendFile.

public void setXtendFile(final XtendFile xtendFile) {
    this.xtendFile = xtendFile;
    StandardTypeReferenceOwner _standardTypeReferenceOwner = new StandardTypeReferenceOwner(this.services, xtendFile);
    LightweightTypeReferenceFactory _lightweightTypeReferenceFactory = new LightweightTypeReferenceFactory(_standardTypeReferenceOwner);
    this.typeRefFactory = _lightweightTypeReferenceFactory;
    this.fileSystemSupport.setContext(xtendFile.eResource().getResourceSet());
    this.fileLocations.setContext(xtendFile.eResource());
}
Also used : IndexingLightweightTypeReferenceFactory(org.eclipse.xtext.xbase.typesystem.references.IndexingLightweightTypeReferenceFactory) LightweightTypeReferenceFactory(org.eclipse.xtext.xbase.typesystem.references.LightweightTypeReferenceFactory) StandardTypeReferenceOwner(org.eclipse.xtext.xbase.typesystem.references.StandardTypeReferenceOwner)

Example 18 with StandardTypeReferenceOwner

use of org.eclipse.xtext.xbase.typesystem.references.StandardTypeReferenceOwner in project xtext-xtend by eclipse.

the class AbstractXtendOutlineTreeBuilder method buildInheritedMembers.

protected void buildInheritedMembers(final JvmDeclaredType inferredType, final IXtendOutlineContext context) {
    ResourceSet _resourceSet = inferredType.eResource().getResourceSet();
    final StandardTypeReferenceOwner owner = new StandardTypeReferenceOwner(this.services, _resourceSet);
    final LightweightTypeReference typeReference = owner.toLightweightTypeReference(inferredType);
    final List<LightweightTypeReference> superTypes = typeReference.getAllSuperTypes();
    IXtendOutlineContext superTypeContext = context;
    for (final LightweightTypeReference superTypeRef : superTypes) {
        {
            superTypeContext = superTypeContext.increaseInheritanceDepth();
            final ResolvedFeatures resolvedFeatures = new ResolvedFeatures(superTypeRef);
            List<IResolvedField> _declaredFields = resolvedFeatures.getDeclaredFields();
            for (final IResolvedField jvmField : _declaredFields) {
                boolean _skipFeature = this.skipFeature(jvmField.getDeclaration());
                boolean _not = (!_skipFeature);
                if (_not) {
                    this.xtendOutlineNodeBuilder.buildResolvedFeatureNode(inferredType, jvmField, superTypeContext);
                }
            }
            List<IResolvedConstructor> _declaredConstructors = resolvedFeatures.getDeclaredConstructors();
            for (final IResolvedConstructor constructor : _declaredConstructors) {
                boolean _skipFeature_1 = this.skipFeature(constructor.getDeclaration());
                boolean _not_1 = (!_skipFeature_1);
                if (_not_1) {
                    this.xtendOutlineNodeBuilder.buildResolvedFeatureNode(inferredType, constructor, superTypeContext);
                }
            }
            List<IResolvedOperation> _declaredOperations = resolvedFeatures.getDeclaredOperations();
            for (final IResolvedOperation operation : _declaredOperations) {
                if (((!this.skipFeature(operation.getDeclaration())) && (!superTypeContext.isProcessed(operation.getDeclaration())))) {
                    this.xtendOutlineNodeBuilder.buildResolvedFeatureNode(inferredType, operation, superTypeContext);
                }
            }
            final JvmType declaredType = superTypeRef.getType();
            if ((declaredType instanceof JvmDeclaredType)) {
                final IXtendOutlineContext nestedTypeContext = superTypeContext.hideInherited();
                final Consumer<JvmDeclaredType> _function = (JvmDeclaredType it) -> {
                    this.buildJvmType(it, nestedTypeContext);
                };
                Iterables.<JvmDeclaredType>filter(((JvmDeclaredType) declaredType).getMembers(), JvmDeclaredType.class).forEach(_function);
            }
        }
    }
}
Also used : LightweightTypeReference(org.eclipse.xtext.xbase.typesystem.references.LightweightTypeReference) ResolvedFeatures(org.eclipse.xtext.xbase.typesystem.override.ResolvedFeatures) IResolvedField(org.eclipse.xtext.xbase.typesystem.override.IResolvedField) JvmDeclaredType(org.eclipse.xtext.common.types.JvmDeclaredType) ResourceSet(org.eclipse.emf.ecore.resource.ResourceSet) JvmType(org.eclipse.xtext.common.types.JvmType) IResolvedOperation(org.eclipse.xtext.xbase.typesystem.override.IResolvedOperation) IResolvedConstructor(org.eclipse.xtext.xbase.typesystem.override.IResolvedConstructor) Consumer(java.util.function.Consumer) IXtendOutlineContext(org.eclipse.xtend.ide.common.outline.IXtendOutlineContext) EList(org.eclipse.emf.common.util.EList) List(java.util.List) StandardTypeReferenceOwner(org.eclipse.xtext.xbase.typesystem.references.StandardTypeReferenceOwner)

Example 19 with StandardTypeReferenceOwner

use of org.eclipse.xtext.xbase.typesystem.references.StandardTypeReferenceOwner in project xtext-xtend by eclipse.

the class ConvertToArrayBenchmark method setUp.

@Override
protected void setUp() throws Exception {
    Injector injector = new XbaseStandaloneSetup().createInjectorAndDoEMFRegistration();
    XtextResourceSet resourceSet = new XtextResourceSet();
    ClassLoader loader = getClass().getClassLoader();
    resourceSet.setClasspathURIContext(loader);
    ClasspathTypeProvider typeProvider = new ClasspathTypeProvider(loader, resourceSet, indexedAccess, null);
    CommonTypeComputationServices services = injector.getInstance(CommonTypeComputationServices.class);
    StandardTypeReferenceOwner owner = new StandardTypeReferenceOwner(services, resourceSet);
    typeReference = type.getReference(typeProvider, owner);
    EcoreUtil.resolveAll(resourceSet);
}
Also used : XbaseStandaloneSetup(org.eclipse.xtext.xbase.XbaseStandaloneSetup) Injector(com.google.inject.Injector) XtextResourceSet(org.eclipse.xtext.resource.XtextResourceSet) CommonTypeComputationServices(org.eclipse.xtext.xbase.typesystem.util.CommonTypeComputationServices) ClasspathTypeProvider(org.eclipse.xtext.common.types.access.impl.ClasspathTypeProvider) StandardTypeReferenceOwner(org.eclipse.xtext.xbase.typesystem.references.StandardTypeReferenceOwner)

Example 20 with StandardTypeReferenceOwner

use of org.eclipse.xtext.xbase.typesystem.references.StandardTypeReferenceOwner in project xtext-xtend by eclipse.

the class ParameterizedTypeReferenceBenchmark method setUp.

@Override
protected void setUp() throws Exception {
    Injector injector = new XbaseStandaloneSetup().createInjectorAndDoEMFRegistration();
    XtextResourceSet resourceSet = new XtextResourceSet();
    ClassLoader loader = getClass().getClassLoader();
    resourceSet.setClasspathURIContext(loader);
    ClasspathTypeProvider typeProvider = new ClasspathTypeProvider(loader, resourceSet, indexedAccess, null);
    CommonTypeComputationServices services = injector.getInstance(CommonTypeComputationServices.class);
    StandardTypeReferenceOwner owner = new StandardTypeReferenceOwner(services, resourceSet);
    typeReference = type.getReference(typeProvider, owner);
    EcoreUtil.resolveAll(resourceSet);
}
Also used : XbaseStandaloneSetup(org.eclipse.xtext.xbase.XbaseStandaloneSetup) Injector(com.google.inject.Injector) XtextResourceSet(org.eclipse.xtext.resource.XtextResourceSet) CommonTypeComputationServices(org.eclipse.xtext.xbase.typesystem.util.CommonTypeComputationServices) ClasspathTypeProvider(org.eclipse.xtext.common.types.access.impl.ClasspathTypeProvider) StandardTypeReferenceOwner(org.eclipse.xtext.xbase.typesystem.references.StandardTypeReferenceOwner)

Aggregations

StandardTypeReferenceOwner (org.eclipse.xtext.xbase.typesystem.references.StandardTypeReferenceOwner)22 ITypeReferenceOwner (org.eclipse.xtext.xbase.typesystem.references.ITypeReferenceOwner)8 LightweightTypeReference (org.eclipse.xtext.xbase.typesystem.references.LightweightTypeReference)8 JvmOperation (org.eclipse.xtext.common.types.JvmOperation)5 XExpression (org.eclipse.xtext.xbase.XExpression)5 ParameterizedTypeReference (org.eclipse.xtext.xbase.typesystem.references.ParameterizedTypeReference)5 JvmDeclaredType (org.eclipse.xtext.common.types.JvmDeclaredType)4 CommonTypeComputationServices (org.eclipse.xtext.xbase.typesystem.util.CommonTypeComputationServices)4 Injector (com.google.inject.Injector)3 List (java.util.List)3 XtendFile (org.eclipse.xtend.core.xtend.XtendFile)3 JvmType (org.eclipse.xtext.common.types.JvmType)3 JvmTypeReference (org.eclipse.xtext.common.types.JvmTypeReference)3 ClasspathTypeProvider (org.eclipse.xtext.common.types.access.impl.ClasspathTypeProvider)3 XtextResource (org.eclipse.xtext.resource.XtextResource)3 XtextResourceSet (org.eclipse.xtext.resource.XtextResourceSet)3 XAbstractFeatureCall (org.eclipse.xtext.xbase.XAbstractFeatureCall)3 XbaseStandaloneSetup (org.eclipse.xtext.xbase.XbaseStandaloneSetup)3 ResourceSet (org.eclipse.emf.ecore.resource.ResourceSet)2 XtendClass (org.eclipse.xtend.core.xtend.XtendClass)2