Some Eclipse Foundation services are deprecated, or will be soon. Please ensure you've read this important communication.

Bug 322747

Summary: ITypesProposalProvider not respecting type visibility
Product: [Modeling] TMF Reporter: Alexander Nittka <alex>
Component: XtextAssignee: Project Inbox <tmf.xtext-inbox>
Status: CLOSED FIXED QA Contact:
Severity: normal    
Priority: P3 CC: sebastian.zarnekow
Version: 1.0.0Flags: sebastian.zarnekow: indigo+
Target Milestone: M3   
Hardware: All   
OS: All   
Whiteboard:

Description Alexander Nittka CLA 2010-08-16 02:57:29 EDT
Having a grammar with references to Jvm-Types, I experience the following.
In the runtime workspace I have two unrelated Java projects X and Y. X contains a model with said references, Y contains a class Z implementing the java.util.Iterator interface.

Without adaptions to the proposal provider, invoking code completion Z is not proposed, just as expected.

Now I adapt the proposals fo the references:

@Inject
ITypesProposalProvider provider;

@Inject
ITypeProvider.Factory factory;

@Override
public void completeJavaReference_Typeref(EObject model,
    Assignment assignment, ContentAssistContext context,
    ICompletionProposalAcceptor acceptor) {
  ResourceSet set = model.eResource().getResourceSet();
  ITypeProvider tp = factory.findTypeProvider(set);
  if (tp == null) {
    tp = factory.createTypeProvider(set);
  }
  if (tp == null) {
    return;
  }
  try {
    JvmType t = tp.findTypeByName("java.util.Iterator");
    provider.createSubTypeProposals(t, this, context, acceptor);
  } catch (TypeNotFoundException e) {
  }
}

that is I want only references to classes implementing the said interface.
Now, invoking code completion the list of proposals is much shorter as expected, however Z is among the proposals (as is java.lang.Object).
(Choosing Z, the reference cannot be resolved as expected.)

Further, the updated documentation suggests the use of an IScopableTypesProposalProvider providing a code example. Using that code, I do get a scope without Z in it. However the resulting proposal list does again include Z. Maybe I am using the wrong scopableProposalProvider (the snippet does not say where it is coming from, so I simply used the injeced JdtTypesProposalProvider).
Comment 1 Sebastian Zarnekow CLA 2010-10-04 17:50:35 EDT
Pushed fix to master.
Comment 2 Karsten Thoms CLA 2017-09-19 17:35:36 EDT
Closing all bugs that were set to RESOLVED before Neon.0
Comment 3 Karsten Thoms CLA 2017-09-19 17:46:33 EDT
Closing all bugs that were set to RESOLVED before Neon.0