Some Eclipse Foundation services are deprecated, or will be soon. Please ensure you've read this important communication.
Bug 322747 - ITypesProposalProvider not respecting type visibility
Summary: ITypesProposalProvider not respecting type visibility
Status: CLOSED FIXED
Alias: None
Product: TMF
Classification: Modeling
Component: Xtext (show other bugs)
Version: 1.0.0   Edit
Hardware: All All
: P3 normal (vote)
Target Milestone: M3   Edit
Assignee: Project Inbox CLA
QA Contact:
URL:
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2010-08-16 02:57 EDT by Alexander Nittka CLA
Modified: 2017-09-19 17:46 EDT (History)
1 user (show)

See Also:
sebastian.zarnekow: indigo+


Attachments

Note You need to log in before you can comment on or make changes to this bug.
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