eclipse / xtext-core

xtext-core
Eclipse Public License 2.0
117 stars 96 forks source link

IncrementalBuilder: not working for xtend #52

Closed cdietrich closed 8 years ago

cdietrich commented 8 years ago

the incremental builder is not working with the xtend-gradle-plugin. there are complaints about types that cannot be resolved. having a look at the stack trace it seems the incremental builder cannot deal with the lazy user data correct (Indexer.addToIndex does a copy which forces the user data to be calculated inside the indexing phase - to calculate hashes)

cdietrich commented 8 years ago

here is the trace

owns: BatchLinkableResource  (id=12808) 
    ScopeProviderAccess$ErrorDescription.<init>(INode, QualifiedName) line: 244 
    ScopeProviderAccess.getCandidateDescriptions(XExpression, EReference, EObject, IFeatureScopeSession, IResolvedTypes) line: 149  
    ExpressionTypeComputationState(AbstractTypeComputationState).getLinkingCandidates(XConstructorCall) line: 534   
    XtendTypeComputer(XbaseTypeComputer)._computeTypes(XConstructorCall, ITypeComputationState) line: 576   
    XtendTypeComputer(XbaseTypeComputer).computeTypes(XExpression, ITypeComputationState) line: 113 
    XtendTypeComputer(XbaseWithAnnotationsTypeComputer).computeTypes(XExpression, ITypeComputationState) line: 46   
    XtendTypeComputer.computeTypes(XExpression, ITypeComputationState) line: 64 
    RootExpressionTypeComputationState(AbstractTypeComputationState).doComputeTypes(XExpression) line: 121  
    RootExpressionTypeComputationState(ExpressionTypeComputationState).doComputeTypes(XExpression) line: 59 
    RootExpressionTypeComputationState(AbstractTypeComputationState).computeTypes(XExpression) line: 109    
    XtendTypeComputer(XbaseTypeComputer)._computeTypes(XBlockExpression, ITypeComputationState) line: 472   
    XtendTypeComputer(XbaseTypeComputer).computeTypes(XExpression, ITypeComputationState) line: 105 
    XtendTypeComputer(XbaseWithAnnotationsTypeComputer).computeTypes(XExpression, ITypeComputationState) line: 46   
    XtendTypeComputer.computeTypes(XExpression, ITypeComputationState) line: 64 
    TypeComputationStateWithRootExpectation$1(AbstractTypeComputationState).doComputeTypes(XExpression) line: 121   
    TypeComputationStateWithRootExpectation$1(AbstractTypeComputationState).computeTypes(XExpression) line: 109 
    ExtensionAwareClosureTypeComputer$1(ClosureWithExpectationHelper).computeTypes() line: 99   
    ExtensionAwareClosureTypeComputer(ClosureTypeComputer).computeTypes() line: 48  
    XtendTypeComputer._computeTypes(XClosure, ITypeComputationState) line: 205  
    XtendTypeComputer(XbaseTypeComputer).computeTypes(XExpression, ITypeComputationState) line: 111 
    XtendTypeComputer(XbaseWithAnnotationsTypeComputer).computeTypes(XExpression, ITypeComputationState) line: 46   
    XtendTypeComputer.computeTypes(XExpression, ITypeComputationState) line: 64 
    AbstractLinkingCandidate$ArgumentTypeComputationState(AbstractTypeComputationState).doComputeTypes(XExpression) line: 121   
    AbstractLinkingCandidate$ArgumentTypeComputationState(AbstractTypeComputationState).computeTypes(XExpression) line: 109 
    AbstractTypeComputationState$5(AbstractLinkingCandidate<Expression>).resolveArgumentType(XExpression, LightweightTypeReference, ITypeComputationState) line: 627    
    AbstractTypeComputationState$5(FeatureLinkingCandidate).resolveArgumentType(XExpression, LightweightTypeReference, ITypeComputationState) line: 958 
    AbstractTypeComputationState$5(AbstractLinkingCandidate<Expression>).computeFixedArityArgumentType(IFeatureCallArgumentSlot, TypeParameterSubstitutor<?>) line: 579 
    AbstractTypeComputationState$5(AbstractLinkingCandidate<Expression>).computeArgumentType(IFeatureCallArgumentSlot) line: 443    
    AbstractTypeComputationState$5(AbstractLinkingCandidate<Expression>).computeArgumentTypes() line: 430   
    AbstractTypeComputationState$5(AbstractLinkingCandidate<Expression>).preApply() line: 378   
    AbstractTypeComputationState$5(FeatureLinkingCandidate).preApply() line: 891    
    AbstractTypeComputationState$5(AbstractLinkingCandidate<Expression>).applyToComputationState() line: 286    
    AbstractTypeComputationState$5.applyToComputationState() line: 511  
    XtendTypeComputer(XbaseTypeComputer)._computeTypes(XAbstractFeatureCall, ITypeComputationState) line: 1036  
    XtendTypeComputer(XbaseTypeComputer).computeTypes(XExpression, ITypeComputationState) line: 99  
    XtendTypeComputer(XbaseWithAnnotationsTypeComputer).computeTypes(XExpression, ITypeComputationState) line: 46   
    XtendTypeComputer.computeTypes(XExpression, ITypeComputationState) line: 64 
    AbstractLinkingCandidate$ArgumentTypeComputationState(AbstractTypeComputationState).doComputeTypes(XExpression) line: 121   
    AbstractLinkingCandidate$ArgumentTypeComputationState(AbstractTypeComputationState).computeTypes(XExpression) line: 109 
    FeatureLinkingCandidate(AbstractLinkingCandidate<Expression>).resolveArgumentType(XExpression, LightweightTypeReference, ITypeComputationState) line: 627   
    FeatureLinkingCandidate.resolveArgumentType(XExpression, LightweightTypeReference, ITypeComputationState) line: 958 
    FeatureLinkingCandidate(AbstractLinkingCandidate<Expression>).computeFixedArityArgumentType(IFeatureCallArgumentSlot, TypeParameterSubstitutor<?>) line: 579    
    FeatureLinkingCandidate(AbstractLinkingCandidate<Expression>).computeArgumentType(IFeatureCallArgumentSlot) line: 443   
    FeatureLinkingCandidate(AbstractLinkingCandidate<Expression>).computeArgumentTypes() line: 430  
    FeatureLinkingCandidate(AbstractLinkingCandidate<Expression>).preApply() line: 378  
    FeatureLinkingCandidate.preApply() line: 891    
    FeatureLinkingCandidate(AbstractLinkingCandidate<Expression>).applyToComputationState() line: 286   
    XtendTypeComputer(XbaseTypeComputer)._computeTypes(XAssignment, ITypeComputationState) line: 1027   
    XtendTypeComputer(XbaseTypeComputer).computeTypes(XExpression, ITypeComputationState) line: 97  
    XtendTypeComputer(XbaseWithAnnotationsTypeComputer).computeTypes(XExpression, ITypeComputationState) line: 46   
    XtendTypeComputer.computeTypes(XExpression, ITypeComputationState) line: 64 
    ExpressionTypeComputationStateWithExpectation(AbstractTypeComputationState).doComputeTypes(XExpression) line: 121   
    ExpressionTypeComputationStateWithExpectation(AbstractTypeComputationState).computeTypes(XExpression) line: 109 
    XtendTypeComputer(XbaseTypeComputer)._computeTypes(XBlockExpression, ITypeComputationState) line: 460   
    XtendTypeComputer(XbaseTypeComputer).computeTypes(XExpression, ITypeComputationState) line: 105 
    XtendTypeComputer(XbaseWithAnnotationsTypeComputer).computeTypes(XExpression, ITypeComputationState) line: 46   
    XtendTypeComputer.computeTypes(XExpression, ITypeComputationState) line: 64 
    ConstructorBodyComputationState(AbstractTypeComputationState).doComputeTypes(XExpression) line: 121 
    ConstructorBodyComputationState(AbstractTypeComputationState).computeTypes(XExpression) line: 109   
    ConstructorBodyComputationState(AbstractRootTypeComputationState).computeTypes() line: 32   
    XtendReentrantTypeResolver(LogicalContainerAwareReentrantTypeResolver)._computeTypes(Map<JvmIdentifiableElement,ResolvedTypes>, ResolvedTypes, IFeatureScopeSession, JvmConstructor) line: 784  
    XtendReentrantTypeResolver(LogicalContainerAwareReentrantTypeResolver).computeTypes(Map<JvmIdentifiableElement,ResolvedTypes>, ResolvedTypes, IFeatureScopeSession, EObject) line: 707  
    XtendReentrantTypeResolver(LogicalContainerAwareReentrantTypeResolver).computeMemberTypes(Map<JvmIdentifiableElement,ResolvedTypes>, ResolvedTypes, IFeatureScopeSession, JvmDeclaredType) line: 897    
    XtendReentrantTypeResolver(LogicalContainerAwareReentrantTypeResolver)._computeTypes(Map<JvmIdentifiableElement,ResolvedTypes>, ResolvedTypes, IFeatureScopeSession, JvmDeclaredType) line: 886 
    XtendReentrantTypeResolver(LogicalContainerAwareReentrantTypeResolver).computeTypes(Map<JvmIdentifiableElement,ResolvedTypes>, ResolvedTypes, IFeatureScopeSession, EObject) line: 705  
    XtendReentrantTypeResolver(LogicalContainerAwareReentrantTypeResolver).computeTypes(ResolvedTypes, IFeatureScopeSession) line: 697  
    XtendReentrantTypeResolver.computeTypes(ResolvedTypes, IFeatureScopeSession) line: 382  
    XtendReentrantTypeResolver(DefaultReentrantTypeResolver).resolve(CancelIndicator) line: 163 
    XtendReentrantTypeResolver(DefaultReentrantTypeResolver).reentrantResolve(CancelIndicator) line: 139    
    CompoundReentrantTypeResolver.reentrantResolve(CancelIndicator) line: 79    
    CachingBatchTypeResolver$LazyResolvedTypes.resolveTypes(CancelIndicator) line: 80   
    CachingBatchTypeResolver$2.process(Resource) line: 57   
    CachingBatchTypeResolver$2.process(Object) line: 53 
    CachingBatchTypeResolver$2(IUnitOfWork$Void<T>).exec(T) line: 37    
    OnChangeEvictingCache.execWithoutCacheClear(Param, IUnitOfWork<Result,Param>) line: 129 
    CachingBatchTypeResolver.doResolveTypes(EObject, CancelIndicator) line: 53  
    CachingBatchTypeResolver(AbstractBatchTypeResolver).resolveTypes(EObject, CancelIndicator) line: 69 
    CachingBatchTypeResolver(AbstractBatchTypeResolver).resolveTypes(EObject) line: 55  
    InferredTypeIndicator.getTypeReference(XComputedTypeReferenceImplCustom) line: 71   
    XComputedTypeReferenceImplCustom.getEquivalent() line: 46   
    XComputedTypeReferenceImplCustom(JvmSpecializedTypeReferenceImplCustom).getIdentifier() line: 43    
    JvmDeclaredTypeSignatureHashProvider$SignatureHashBuilder.appendType(JvmTypeReference) line: 226    
    JvmDeclaredTypeSignatureHashProvider$SignatureHashBuilder.appendSignature(JvmOperation) line: 182   
    JvmDeclaredTypeSignatureHashProvider$SignatureHashBuilder.appendMemberSignatures(JvmDeclaredType, boolean) line: 142    
    JvmDeclaredTypeSignatureHashProvider$SignatureHashBuilder.appendSignature(JvmDeclaredType) line: 129    
    JvmDeclaredTypeSignatureHashProvider$1.get() line: 72   
    JvmDeclaredTypeSignatureHashProvider$1.get() line: 69   
    OnChangeEvictingCache.get(Object, Resource, Provider<T>) line: 77   
    JvmDeclaredTypeSignatureHashProvider.getHash(JvmDeclaredType) line: 69  
    XtendResourceDescriptionStrategy(JvmTypesResourceDescriptionStrategy).createUserData(EObject, Builder<String,String>) line: 78  
    XtendResourceDescriptionStrategy.createUserData(EObject, Builder<String,String>) line: 59   
    JvmTypesResourceDescriptionStrategy$1.delegate() line: 68   
    JvmTypesResourceDescriptionStrategy$1(ForwardingMap<K,V>).keySet() line: 115    
    EObjectDescription.getUserDataKeys() line: 99   
    Indexer$ResolvedResourceDescription.lambda$new$0(IEObjectDescription) line: 154 
    741527822.apply(Object) line: not available 
    FunctionDelegate<P,R>.apply(P) line: 42 
    Iterators$8.transform(F) line: 817  
    Iterators$8(TransformedIterator<F,T>).next() line: 48   
    ImmutableList<E>.copyOf(Iterator<? extends E>) line: 252    
    ImmutableList<E>.copyOf(Iterable<? extends E>) line: 209    
    Indexer$ResolvedResourceDescription.<init>(IResourceDescription) line: 170  
    Indexer.addToIndex(Resource, boolean, ResourceDescriptionsData, BuildContext) line: 327 
    Indexer.lambda$getDeltasForChangedResources$5(ResourceDescriptionsData, BuildContext, Resource) line: 310   
    1118881697.apply(Object) line: not available    
    ClusteringStorageAwareResourceLoader.lambda$executeClustered$1(Functions$Function1, Resource) line: 86  
    873380647.apply(Object) line: not available 
    FunctionDelegate<P,R>.apply(P) line: 42 
    Lists$TransformingRandomAccessList$1.transform(F) line: 640 
    Lists$TransformingRandomAccessList$1(TransformedIterator<F,T>).next() line: 48  
    Lists$TransformingRandomAccessList<F,T>(AbstractCollection<E>).toArray() line: 141  
    ArrayList<E>.addAll(Collection<? extends E>) line: 577  
    Iterables.addAll(Collection<T>, Iterable<? extends T>) line: 350    
    ClusteringStorageAwareResourceLoader.executeClustered(Iterable<URI>, Function1<Resource,? extends T>) line: 89  
    BuildContext.executeClustered(Iterable<URI>, Function1<Resource,? extends T>) line: 58  
    Indexer.getDeltasForChangedResources(Iterable<URI>, ResourceDescriptionsData, BuildContext) line: 312   
    Indexer.computeAndIndexAffected(BuildRequest, BuildContext) line: 235   
    IncrementalBuilder$InternalStatefulIncrementalBuilder.launch() line: 199    
    IncrementalBuilder.build(BuildRequest, Function1<URI,IResourceServiceProvider>, IResourceClusteringPolicy) line: 430    
    IncrementalBuilder.build(BuildRequest, Function1<URI,IResourceServiceProvider>) line: 411   
    XtextGradleBuilder.doBuild(BuildRequest, GradleBuildRequest) line: 343  
    XtextGradleBuilder.build(GradleBuildRequest) line: 227  
    XtextGenerate_Decorated(XtextGenerate).build(Collection<File>, Collection<File>) line: 345  
    XtextGenerate_Decorated(XtextGenerate).generate(IncrementalTaskInputs) line: 210    
cdietrich commented 8 years ago

the interesting points in the stack are

cdietrich commented 8 years ago

something similar can be reproduced in the incrementalbuildertest with this modification to the test lang

public class IndexTestLanguageResourceDescriptionStrategy extends DefaultResourceDescriptionStrategy {

    protected Map<String, String> createLazyUserData(final EObject eObject) { 
        return new ForwardingMap<String, String>() {
            private Map<String,String> delegate; 

            @Override
            protected Map<String, String> delegate() {
                if(delegate == null) {
                    Builder<String, String> userData = ImmutableMap.builder();
                    createUserData(eObject, userData);
                    delegate = userData.build();
                } 
                return delegate;
            }

        };
    }
    private void createUserData(EObject eObject, Builder<String, String> userData) {
        if (eObject instanceof Entity) {
            Entity entity = (Entity)eObject;
            StringBuilder b = new StringBuilder();
            for (Property p : entity.getProperties()) {
                b.append(p.getType().getName());
            }
            userData.put("dummy", b.toString());
        }

    }

    @Override
    public boolean createEObjectDescriptions(EObject eObject, IAcceptor<IEObjectDescription> acceptor) {
        if (getQualifiedNameProvider() == null)
            return false;
        try {
            QualifiedName qualifiedName = getQualifiedNameProvider().getFullyQualifiedName(eObject);
            if (qualifiedName != null) {
                acceptor.accept(EObjectDescription.create(qualifiedName, eObject, createLazyUserData(eObject)));
            }
        } catch (Exception exc) {
            exc.printStackTrace();
        }
        return true;
    }

}
    public Class<? extends IDefaultResourceDescriptionStrategy> bindIDefaultResourceDescriptionStrategy() {
        return IndexTestLanguageResourceDescriptionStrategy.class;
    }

i will try to create a small example that reproduces with xtend as well

svenefftinge commented 8 years ago

It is invalid to do cross reference resolution during eobjectdescription creation. The underlying problem here, is that the derived state (JvmTypes) already contain XcomputedTypeReference (actually that it contains typereferences at all). Seems like there was some getContents call without indexing set to true before.

Usually at this point the derived contains only contains the JvmTypes with out supertypes and members (except. default contsructors and type args again w/o bounds).

cdietrich commented 8 years ago

i tried to reproduce this with a builder test. but i am still struggeling with getting the inferrer called so that the hasher will actually find members to analyze

svenefftinge commented 8 years ago

That's the point: there should be no members at this time (during indexing).

cdietrich commented 8 years ago

i see. so ill try to find out what is differently in the xtend gradle plugin

svenefftinge commented 8 years ago

See also the documentation here : org.eclipse.xtext.xbase.jvmmodel.IJvmModelInferrer.infer(EObject, IJvmDeclaredTypeAcceptor, boolean)

cdietrich commented 8 years ago

here is the stack that causes this

Thread [Daemon worker Thread 3] (Suspended (breakpoint at line 234 in XtendJvmModelInferrer))   
    owns: BatchLinkableResource  (id=13435) 
    owns: BatchLinkableResource  (id=13434) 
    XtendJvmModelInferrer.infer(EObject, IJvmDeclaredTypeAcceptor, boolean) line: 234   
    IXtendJvmAssociations$Impl(JvmModelAssociator).installDerivedState(DerivedStateAwareResource, boolean) line: 382    
    BatchLinkableResource(DerivedStateAwareResource).installDerivedState(boolean) line: 242 
    BatchLinkableResource.getContents() line: 148   
    BatchLinkableResource(ResourceImpl).getEObjectForURIFragmentRootSegment(String) line: 721   
    BatchLinkableResource(DerivedStateAwareResource).getEObjectForURIFragmentRootSegment(String) line: 211  
    BatchLinkableResource(ResourceImpl).getEObject(List<String>) line: 763  
    BatchLinkableResource(ResourceImpl).getEObject(String) line: 742    
    XtextResource.access$101(XtextResource, String) line: 61    
    XtextResource$1.getEObject(String) line: 115    
    DefaultFragmentProvider.getEObject(Resource, String, IFragmentProvider$Fallback) line: 28   
    BatchLinkableResource(XtextResource).basicGetEObject(String) line: 346  
    BatchLinkableResource(XtextResource).getEObject(String) line: 332   
    BatchLinkableResource(LazyLinkingResource).getEObject(String) line: 232 
    BatchLinkableResource(StorageAwareResource).getEObject(String) line: 122    
    BatchLinkableResource.getEObject(String) line: 124  
    XtextResourceSet(ResourceSetImpl).getEObject(URI, boolean) line: 223    
    EcoreUtil.resolve(EObject, ResourceSet) line: 199   
    IndexedJvmTypeAccess.getAccessibleType(IEObjectDescription, String, ResourceSet) line: 132  
    IndexedJvmTypeAccess.findAccessibleType(String, ResourceSet, Iterator<IEObjectDescription>) line: 121   
    IndexedJvmTypeAccess.getIndexedJvmType(QualifiedName, String, ResourceSet, boolean) line: 100   
    IndexedJvmTypeAccess.getIndexedJvmType(QualifiedName, String, ResourceSet) line: 91 
    ClasspathTypeProvider(AbstractRuntimeJvmTypeProvider).doTryFindInIndex(String, IndexedJvmTypeAccess) line: 105  
    ClasspathTypeProvider(AbstractRuntimeJvmTypeProvider).doTryFindInIndex(String, boolean) line: 85    
    AbstractRuntimeJvmTypeProvider$TypeInResourceSetAdapter.tryFindTypeInIndex(String, AbstractRuntimeJvmTypeProvider, boolean) line: 51    
    ClasspathTypeProvider(AbstractRuntimeJvmTypeProvider).tryFindTypeInIndex(String, boolean) line: 115 
    ClasspathTypeProvider.doFindTypeByName(String) line: 232    
    ClasspathTypeProvider.findTypeByName(String, boolean) line: 213 
    ClasspathBasedTypeScope(AbstractTypeScope).getSingleElement(QualifiedName, boolean) line: 59    
    ClasspathBasedTypeScope(AbstractTypeScope).getSingleElement(QualifiedName) line: 54 
    LocalResourceFilteringTypeScope.getSingleElement(QualifiedName) line: 42    
    RecordingTypeScope.getSingleElement(QualifiedName) line: 41 
    SelectableBasedScope(AbstractScope).getSingleElement(QualifiedName) line: 108   
    DefaultLinkingService.getLinkedObjects(EObject, EReference, INode) line: 121    
    BatchLinkableResource(LazyLinkingResource).getEObject(String, Triple<EObject,EReference,INode>) line: 247   
    BatchLinkableResource.getEObject(String) line: 119  
    XtextResourceSet(ResourceSetImpl).getEObject(URI, boolean) line: 223    
    XtendImportedNamespaceScopeProvider.getImportScope(XImportSection, AbstractScope, RecordingTypeScope) line: 296 
    XtendImportedNamespaceScopeProvider.access$200(XtendImportedNamespaceScopeProvider, XImportSection, AbstractScope, RecordingTypeScope) line: 72 
    XtendImportedNamespaceScopeProvider$1.get() line: 136   
    XtendImportedNamespaceScopeProvider$1.get() line: 124   
    OnChangeEvictingCache.get(Object, Resource, Provider<T>) line: 77   
    XtendImportedNamespaceScopeProvider.getScope(EObject, EReference) line: 124 
    TypeScopes.createTypeScope(EObject, EReference) line: 59    
    XtendScopeProvider(XbaseBatchScopeProvider).getScope(EObject, EReference) line: 105 
    XtendScopeProvider(XbaseWithAnnotationsBatchScopeProvider).getScope(EObject, EReference) line: 53   
    DefaultLinkingService.getScope(EObject, EReference) line: 59    
    DefaultLinkingService.getLinkedObjects(EObject, EReference, INode) line: 119    
    XAnnotationExtensions.isProcessed(XAnnotation) line: 163    
    ActiveAnnotationContextProvider.lambda$registerMacroAnnotations$8(XAnnotation) line: 265    
    1750660032.apply(Object) line: not available    
    BooleanFunctionDelegate<T>.apply(T) line: 41    
    Iterators$7.computeNext() line: 675 
    Iterators$7(AbstractIterator<T>).tryToComputeNext() line: 143   
    Iterators$7(AbstractIterator<T>).hasNext() line: 138    
    ActiveAnnotationContextProvider.registerMacroAnnotations(XtendAnnotationTarget, IAcceptor<Pair<JvmAnnotationType,XAnnotation>>) line: 268   
    ActiveAnnotationContextProvider.searchAnnotatedElements(EObject, IAcceptor<Pair<JvmAnnotationType,XAnnotation>>) line: 257  
    ActiveAnnotationContextProvider.lambda$searchAnnotatedElements$2(IAcceptor, XtendMember) line: 194  
    2019277656.accept(Object) line: not available   
    EObjectContainmentWithInverseEList<E>(Iterable<T>).forEach(Consumer<? super T>) line: 75    
    ActiveAnnotationContextProvider.searchAnnotatedElements(EObject, IAcceptor<Pair<JvmAnnotationType,XAnnotation>>) line: 196  
    ActiveAnnotationContextProvider.lambda$searchAnnotatedElements$1(IAcceptor, XtendTypeDeclaration) line: 184 
    1945011480.accept(Object) line: not available   
    EObjectContainmentEList<E>(Iterable<T>).forEach(Consumer<? super T>) line: 75   
    ActiveAnnotationContextProvider.searchAnnotatedElements(EObject, IAcceptor<Pair<JvmAnnotationType,XAnnotation>>) line: 186  
    ActiveAnnotationContextProvider.computeContext(XtendFile) line: 147 
    XtendJvmModelInferrer.infer(EObject, IJvmDeclaredTypeAcceptor, boolean) line: 186   
    IXtendJvmAssociations$Impl(JvmModelAssociator).installDerivedState(DerivedStateAwareResource, boolean) line: 382    
    BatchLinkableResource(DerivedStateAwareResource).installDerivedState(boolean) line: 242 
    XtendResourceDescriptionManager(DerivedStateAwareResourceDescriptionManager).internalGetResourceDescription(Resource, IDefaultResourceDescriptionStrategy) line: 54 
    DefaultResourceDescriptionManager$1.get() line: 62  
    DefaultResourceDescriptionManager$1.get() line: 59  
    OnChangeEvictingCache.get(Object, Resource, Provider<T>) line: 77   
    XtendResourceDescriptionManager(DefaultResourceDescriptionManager).getResourceDescription(Resource) line: 59    
    XtendResourceDescriptionManager(StorageAwareResourceDescriptionManager).getResourceDescription(Resource) line: 36   
    Indexer.addToIndex(Resource, boolean, ResourceDescriptionsData, BuildContext) line: 326 
    Indexer.lambda$getDeltasForChangedResources$5(ResourceDescriptionsData, BuildContext, Resource) line: 310   
    1235948647.apply(Object) line: not available    
    ClusteringStorageAwareResourceLoader.lambda$executeClustered$1(Functions$Function1, Resource) line: 86  
    774888129.apply(Object) line: not available 
    FunctionDelegate<P,R>.apply(P) line: 42 
    Lists$TransformingRandomAccessList$1.transform(F) line: 640 
    Lists$TransformingRandomAccessList$1(TransformedIterator<F,T>).next() line: 48  
    Lists$TransformingRandomAccessList<F,T>(AbstractCollection<E>).toArray() line: 141  
    ArrayList<E>.addAll(Collection<? extends E>) line: 577  
    Iterables.addAll(Collection<T>, Iterable<? extends T>) line: 350    
    ClusteringStorageAwareResourceLoader.executeClustered(Iterable<URI>, Function1<Resource,? extends T>) line: 89  
    BuildContext.executeClustered(Iterable<URI>, Function1<Resource,? extends T>) line: 58  
    Indexer.getDeltasForChangedResources(Iterable<URI>, ResourceDescriptionsData, BuildContext) line: 312   
    Indexer.computeAndIndexAffected(BuildRequest, BuildContext) line: 235   
    IncrementalBuilder$InternalStatefulIncrementalBuilder.launch() line: 199    
    IncrementalBuilder.build(BuildRequest, Function1<URI,IResourceServiceProvider>, IResourceClusteringPolicy) line: 430    
    IncrementalBuilder.build(BuildRequest, Function1<URI,IResourceServiceProvider>) line: 411   
    XtextGradleBuilder.doBuild(BuildRequest, GradleBuildRequest) line: 343  
    XtextGradleBuilder.build(GradleBuildRequest) line: 227  
    XtextGenerate_Decorated(XtextGenerate).build(Collection<File>, Collection<File>) line: 345  
    XtextGenerate_Decorated(XtextGenerate).generate(IncrementalTaskInputs) line: 210    
    NativeMethodAccessorImpl.invoke0(Method, Object, Object[]) line: not available [native method]  
    NativeMethodAccessorImpl.invoke(Object, Object[]) line: 62  
    DelegatingMethodAccessorImpl.invoke(Object, Object[]) line: 43  
    Method.invoke(Object, Object...) line: 498  
    JavaMethod<T,R>.invoke(T, Object...) line: 75   
    AnnotationProcessingTaskFactory$IncrementalTaskAction.doExecute(Task, String) line: 245 
    AnnotationProcessingTaskFactory$IncrementalTaskAction(AnnotationProcessingTaskFactory$StandardTaskAction).execute(Task) line: 221   
    AnnotationProcessingTaskFactory$IncrementalTaskAction.execute(Task) line: 232   
    AnnotationProcessingTaskFactory$IncrementalTaskAction(AnnotationProcessingTaskFactory$StandardTaskAction).execute(Object) line: 210 
    ExecuteActionsTaskExecuter.executeAction(TaskInternal, ContextAwareTaskAction, TaskExecutionContext) line: 80   
    ExecuteActionsTaskExecuter.executeActions(TaskInternal, TaskStateInternal, TaskExecutionContext) line: 61   
    ExecuteActionsTaskExecuter.execute(TaskInternal, TaskStateInternal, TaskExecutionContext) line: 46  
    PostExecutionAnalysisTaskExecuter.execute(TaskInternal, TaskStateInternal, TaskExecutionContext) line: 35   
    SkipUpToDateTaskExecuter.execute(TaskInternal, TaskStateInternal, TaskExecutionContext) line: 66    
    ValidatingTaskExecuter.execute(TaskInternal, TaskStateInternal, TaskExecutionContext) line: 58  
    SkipEmptySourceFilesTaskExecuter.execute(TaskInternal, TaskStateInternal, TaskExecutionContext) line: 52    
    SkipTaskWithNoActionsExecuter.execute(TaskInternal, TaskStateInternal, TaskExecutionContext) line: 52   
    SkipOnlyIfTaskExecuter.execute(TaskInternal, TaskStateInternal, TaskExecutionContext) line: 53  
    ExecuteAtMostOnceTaskExecuter.execute(TaskInternal, TaskStateInternal, TaskExecutionContext) line: 43   
    DefaultTaskGraphExecuter$EventFiringTaskWorker.execute(TaskInternal) line: 203  
    DefaultTaskGraphExecuter$EventFiringTaskWorker.execute(Object) line: 185    
    AbstractTaskPlanExecutor$TaskExecutorWorker.processTask(TaskInfo) line: 66  
    AbstractTaskPlanExecutor$TaskExecutorWorker.run() line: 50  
    DefaultTaskPlanExecutor.process(TaskExecutionPlan, Action<TaskInternal>) line: 25   
    DefaultTaskGraphExecuter.execute() line: 110    
    SelectedTaskExecutionAction.execute(BuildExecutionContext) line: 37 
    DefaultBuildExecuter.execute(GradleInternal, int) line: 37  
    DefaultBuildExecuter.access$000(DefaultBuildExecuter, GradleInternal, int) line: 23 
    DefaultBuildExecuter$1.proceed() line: 43   
    DryRunBuildExecutionAction.execute(BuildExecutionContext) line: 32  
    DefaultBuildExecuter.execute(GradleInternal, int) line: 37  
    DefaultBuildExecuter.execute(GradleInternal) line: 30   
    DefaultGradleLauncher$4.run() line: 153 
    Factories$1.create() line: 22   
    DefaultBuildOperationExecutor.run(BuildOperationDetails, Factory<T>) line: 91   
    DefaultBuildOperationExecutor.run(String, Runnable) line: 53    
    DefaultGradleLauncher.doBuildStages(DefaultGradleLauncher$Stage) line: 150  
    DefaultGradleLauncher.access$200(DefaultGradleLauncher, DefaultGradleLauncher$Stage) line: 32   
    DefaultGradleLauncher$1.create() line: 98   
    DefaultGradleLauncher$1.create() line: 92   
    DefaultBuildOperationExecutor.run(BuildOperationDetails, Factory<T>) line: 91   
    DefaultBuildOperationExecutor.run(String, Factory<T>) line: 63  
    DefaultGradleLauncher.doBuild(DefaultGradleLauncher$Stage) line: 92 
    DefaultGradleLauncher.run() line: 83    
    InProcessBuildActionExecuter$DefaultBuildController.run() line: 99  
    ExecuteBuildActionRunner.run(BuildAction, BuildController) line: 28 
    ChainingBuildActionRunner.run(BuildAction, BuildController) line: 35    
    InProcessBuildActionExecuter.execute(BuildAction, BuildRequestContext, BuildActionParameters, ServiceRegistry) line: 48 
    InProcessBuildActionExecuter.execute(BuildAction, BuildRequestContext, Object, ServiceRegistry) line: 30    
    ContinuousBuildActionExecuter.execute(BuildAction, BuildRequestContext, BuildActionParameters, ServiceRegistry) line: 81    
    ContinuousBuildActionExecuter.execute(BuildAction, BuildRequestContext, Object, ServiceRegistry) line: 46   
    ExecuteBuild.doBuild(DaemonCommandExecution, Build) line: 52    
    ExecuteBuild(BuildCommandOnly).execute(DaemonCommandExecution) line: 36 
    DaemonCommandExecution.proceed() line: 120  
    WatchForDisconnection.execute(DaemonCommandExecution) line: 37  
    DaemonCommandExecution.proceed() line: 120  
    ResetDeprecationLogger.execute(DaemonCommandExecution) line: 26 
    DaemonCommandExecution.proceed() line: 120  
    RequestStopIfSingleUsedDaemon.execute(DaemonCommandExecution) line: 34  
    DaemonCommandExecution.proceed() line: 120  
    ForwardClientInput$2.call() line: 74    
    ForwardClientInput$2.call() line: 72    
    StdinSwapper(Swapper<T>).swap(Y, Callable<N>) line: 38  
    ForwardClientInput.execute(DaemonCommandExecution) line: 72 
    DaemonCommandExecution.proceed() line: 120  
    DaemonHealthTracker.execute(DaemonCommandExecution) line: 47    
    DaemonCommandExecution.proceed() line: 120  
    LogToClient.doBuild(DaemonCommandExecution, Build) line: 60 
    LogToClient(BuildCommandOnly).execute(DaemonCommandExecution) line: 36  
    DaemonCommandExecution.proceed() line: 120  
    EstablishBuildEnvironment.doBuild(DaemonCommandExecution, Build) line: 72   
    EstablishBuildEnvironment(BuildCommandOnly).execute(DaemonCommandExecution) line: 36    
    DaemonCommandExecution.proceed() line: 120  
    HintGCAfterBuild.execute(DaemonCommandExecution) line: 41   
    DaemonCommandExecution.proceed() line: 120  
    StartBuildOrRespondWithBusy$1.run() line: 50    
    DaemonStateCoordinator$1.run() line: 237    
    ExecutorPolicy$CatchAndRecordFailures.onExecute(Runnable) line: 54  
    StoppableExecutorImpl$1.run() line: 40  
    ThreadPoolExecutor.runWorker(ThreadPoolExecutor$Worker) line: 1142  
    ThreadPoolExecutor$Worker.run() line: 617   
    Thread.run() line: 745  
cdietrich commented 8 years ago

inside the first inferrer preindexing is true as expected. inside the second one it is false

svenefftinge commented 8 years ago

do you know what types are involved?

cdietrich commented 8 years ago

yes. from the xtend gradle plugin.

the first type (in the indexer) is xtext-gradle-plugin/src/main/java/org/xtext/gradle/tasks/internal/DefaultXtextSourceDirectorySet.xtend the second (that is resovlved from IndexedJvmTypeAccess) is xtext-gradle-plugin/src/main/java/org/xtext/gradle/tasks/XtextExtension.xtend. the typeprovider delivered a SerializableEObjectDescription there

the annotation is Accessors.

svenefftinge commented 8 years ago

are you able to extract a reduced unit test, to reproduce the problem?

cdietrich commented 8 years ago

maybe this is connected how the gradle plugin saves and restores the index

cdietrich commented 8 years ago

no in the unit test this is working

cdietrich commented 8 years ago

but i get already a state where the inferrer is called with false. maybe in this case the type computer recovers

/*******************************************************************************
 * Copyright (c) 2016 itemis AG (http://www.itemis.eu) and others.
 * All rights reserved. This program and the accompanying materials
 * are made available under the terms of the Eclipse Public License v1.0
 * which accompanies this distribution, and is available at
 * http://www.eclipse.org/legal/epl-v10.html
 *******************************************************************************/
package org.eclipse.xtend.core.tests

import org.junit.runner.RunWith
import org.eclipse.xtext.junit4.XtextRunner
import org.eclipse.xtext.junit4.InjectWith
import org.junit.Test
import org.eclipse.xtext.junit4.build.AbstractIncrementalBuilderTest
import org.eclipse.xtext.resource.IResourceServiceProvider
import javax.inject.Inject
import org.eclipse.xtext.java.JavaSourceLanguageSetup
import org.eclipse.emf.common.util.URI
import java.io.File
import java.nio.file.Files
import org.eclipse.core.internal.utils.FileUtil

/**
 * @author dietrich - Initial contribution and API
 */
@RunWith(XtextRunner)
@InjectWith(RuntimeInjectorProvider)
class XtendIncrementalBuilderTest extends AbstractIncrementalBuilderTest {

    @Inject IResourceServiceProvider.Registry resourceServiceProviderFactory

    override setUp() {
        val javaSetup = new JavaSourceLanguageSetup
        val injector = javaSetup.createInjector
        javaSetup.register(injector, 'java')
        super.setUp()
    }

    override getLanguages() {
        resourceServiceProviderFactory
    }

    @Test def void testIt() {
        build(newBuildRequest [

            dirtyFiles = #[
                'src/a/A.xtend' - '''
                    package a

                    import b.B

                    class A {

                        @Accessors String version

                        new (String x, B b) {

                        }

                        @Accessors
                        class A1 {

                            var String a

                        }
                    }
                ''',
                'src/b/B.xtend' - '''
                    package b

                    import a.A
                    import my.pack.MyDependency

                    class B {

                        @Accessors String version

                        def doSth() {
                            val a = new A
                            a.toString
                        }

                    }
                '''
            ]
        ])

        build(newBuildRequest [

            dirtyFiles = #[
                'src/a/A.xtend' - '''
                    package a

                    import b.B

                    class A {

                        @Accessors String version

                        new (String x, B b) {

                        }

                        @Accessors
                        class A1 {

                            var String a

                        }
}
                ''',
                'src/b/B.xtend' - '''
                    package b

                    import a.A
                    import my.pack.MyDependency

                    class B {

                        @Accessors String version

                        def doSth() {
                            val a = new A
                            a.toString
                        }

                    }
                '''
            ]
        ])

    }

}
svenefftinge commented 8 years ago

I think org.eclipse.xtend.core.scoping.XtendImportedNamespaceScopeProvider.getImportScope(XImportSection, AbstractScope, RecordingTypeScope) line 290 is odd.

You could check what happens if you remove that special case and simply try to resolve the cross reference? I can imagine that the reason I introduced it at that time has been superseded.

If that helps please check ActiveAnnotationsInSameProjectTest#testPropertyOfTypeInSameProject is still green.

cdietrich commented 8 years ago

here is a actually reproducing test

/*******************************************************************************
 * Copyright (c) 2016 itemis AG (http://www.itemis.eu) and others.
 * All rights reserved. This program and the accompanying materials
 * are made available under the terms of the Eclipse Public License v1.0
 * which accompanies this distribution, and is available at
 * http://www.eclipse.org/legal/epl-v10.html
 *******************************************************************************/
package org.eclipse.xtend.core.tests

import org.junit.runner.RunWith
import org.eclipse.xtext.junit4.XtextRunner
import org.eclipse.xtext.junit4.InjectWith
import org.junit.Test
import org.eclipse.xtext.junit4.build.AbstractIncrementalBuilderTest
import org.eclipse.xtext.resource.IResourceServiceProvider
import javax.inject.Inject
import org.eclipse.xtext.java.JavaSourceLanguageSetup
import org.eclipse.emf.common.util.URI
import java.io.File
import java.nio.file.Files
import org.eclipse.core.internal.utils.FileUtil
import org.eclipse.xtext.diagnostics.Severity

import static org.junit.Assert.*
import org.eclipse.xtend.core.tests.macro.Accessors

/**
 * @author dietrich - Initial contribution and API
 */
@RunWith(XtextRunner)
@InjectWith(RuntimeInjectorProvider)
class XtendIncrementalBuilderTest extends AbstractIncrementalBuilderTest {

    @Inject IResourceServiceProvider.Registry resourceServiceProviderFactory

    override setUp() {
        val javaSetup = new JavaSourceLanguageSetup
        val injector = javaSetup.createInjector
        javaSetup.register(injector, 'java')
        super.setUp()
    }

    override getLanguages() {
        resourceServiceProviderFactory
    }

    @Test def void testIt() {
        build(newBuildRequest [

            dirtyFiles = #[
                'src/a/A.xtend' - '''
                    package a

                    import b.B
                    import org.eclipse.xtend.lib.annotations.Accessors

                    class A {

                        @Accessors String version

                        new (String x, B b) {

                        }

                        new() {
                        }

                    }

                    @Accessors
                    class A1 {

                        var String a

                    }
                ''',
                'src/b/B.xtend' - '''
                    package b

                    import a.A
                    import org.eclipse.xtend.lib.annotations.Accessors

                    class B {

                        @Accessors String version

                        def doSth() {
                            val a = new A
                            a.toString
                        }

                        def doSomethingElse(String a) {
                            a.length + 1
                        }

                    }
                '''
            ]
        ])
        System.out.println(issues)
        assertEquals(0, issues.filter[severity == Severity.ERROR].size)
        build(newBuildRequest [

            dirtyFiles = #[
                'src/a/A.xtend' - '''
                    package a

                    import b.B
                    import org.eclipse.xtend.lib.annotations.Accessors

                    class A {

                        @Accessors String version

                        new (String x, B b) {

                        }

                        new() {
                        }

                    }

                    @Accessors
                    class A1 {

                        var String a

                    }
                ''',
                'src/b/B.xtend' - '''
                    package b

                    import a.A
                    import org.eclipse.xtend.lib.annotations.Accessors

                    class B {

                        @Accessors String version

                        def doSth() {
                            val a = new A
                            a.toString
                        }

                        def doSomethingElse(String a) {
                            a.length + 1
                        }

                    }
                '''
            ]
        ])
        System.out.println(issues)
        assertEquals(0, issues.filter[severity == Severity.ERROR].size)

    }

}