Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Modeling » TMF (Xtext) » [SOLVED] Invalid modifiers for dirty types in content assist
[SOLVED] Invalid modifiers for dirty types in content assist [message #1739213] Thu, 28 July 2016 11:27 Go to next message
Stephane Galland is currently offline Stephane GallandFriend
Messages: 106
Registered: July 2014
Location: Belfort, France
Senior Member
Dear all.

I have a IContentProposalProvider that is supposed to propose types that are not declared with the modifier "final". This modifier is inferred to JVM to the "final" Java keyword.

The example is the definition of one "final agent" A1, the definition of one "not-final agent" A2. Then I want to define a third agent A3 that extends another agent definition.
I putthe cursor at the | character and press <control>+<space>.
final agent A1 { }
agent A2 { }
agent A3 extends |


I have defined my content proposal provider with a specific filter:
private class ExtensionFilter extends TypeMatchFilters.AbstractFilter {

		private final ITypesProposalProvider.Filter visibilityFilter;

		private final String modelFullName;

		ExtensionFilter(ContentAssistContext context, int searchFor) {
			super(searchFor);
			this.modelFullName = SARLProposalProvider.this.qualifiedNameProvider.getFullyQualifiedName(
					context.getCurrentModel()).toString();
			this.visibilityFilter = createVisibilityFilter(context, searchFor);
		}

		@Override
		public boolean accept(int modifiers, char[] packageName, char[] simpleTypeName,
				char[][] enclosingTypeNames, String path) {
			// Avoid auto reference of type.
			final String fullName = JavaModelUtil.concatenateName(packageName, simpleTypeName);
			if (Objects.equals(this.modelFullName, fullName)) {
				return false;
			}
			//The following tests are done by the visibility filter.
			//if (TypeMatchFilters.isInternalClass(simpleTypeName, enclosingTypeNames)) {
			//	return false;
			//}
			//if (!TypeMatchFilters.isAcceptableByPreference().accept(modifiers, packageName,
			//		simpleTypeName, enclosingTypeNames, path)) {
			//	return false;
			//}
			// Final modifier test
			if (Flags.isFinal(modifiers)) {
				return false;
			}
			return this.visibilityFilter.accept(modifiers, packageName, simpleTypeName, enclosingTypeNames, path);
		}
	}


If the definitions of A1 is written in another resource (ie another file), the proposal is A2 only; that is the expected proposal.

If the definitions of A1 is written in the same resource of A3, the "modifier" argument of the accept function is always equals to Flags.AccPublic.

After debugging, I found that in this last case, the filter is called from JdtTypesPropoposalProvider.searchAndCreateProposals(), in its last part related to the dirty resources. In this case, the modifier is hard coded to Flags.AccPublic; that is not the correct list of modifiers.

Is a way to avoid dirty type proposals on the current resource? Or to retreive the edited modifiers from the original EObject?

I have tried to retrieve the modifiers from object replied by the IEObjectDescription.getEObjectOrProxy; but the flags are always false, and especially the final flag.


All the best.
Stéphane.


Dr.habil Stéphane Galland.
Belfort-Montbéliard University of Technologie, France.

http://www.multiagent.fr/People:Galland_stephane
http://www.sarl.io
http://www.arakhne.org

[Updated on: Thu, 28 July 2016 18:17]

Report message to a moderator

Re: Invalid modifiers for dirty types in content assist [message #1739221 is a reply to message #1739213] Thu, 28 July 2016 13:18 Go to previous messageGo to next message
Christian Dietrich is currently offline Christian DietrichFriend
Messages: 11502
Registered: July 2009
Senior Member
this sounds like a bug to me. can you please file a ticket at eclipse bugzilla or https://github.com/eclipse/xtext-eclipse/issues

as a workaround you may customize org.eclipse.xtext.common.types.xtext.ui.JdtTypesProposalProvider.searchAndCreateProposals(IJavaSearchScope, ICompletionProposalFactory, ContentAssistContext, EReference, Filter, IValueConverter<String>, ICompletionProposalAcceptor) at the affected place and add the final flag there as well?


Need professional support for Xtext, Xpand, EMF?
Go to: http://xtext.itemis.com
Twitter : @chrdietrich
Blog : christiandietrich.wordpress.com
Re: Invalid modifiers for dirty types in content assist [message #1739230 is a reply to message #1739221] Thu, 28 July 2016 14:59 Go to previous message
Stephane Galland is currently offline Stephane GallandFriend
Messages: 106
Registered: July 2014
Location: Belfort, France
Senior Member
Thank you for you quick reply.

To follow up: https://github.com/eclipse/xtext-eclipse/issues/28


Dr.habil Stéphane Galland.
Belfort-Montbéliard University of Technologie, France.

http://www.multiagent.fr/People:Galland_stephane
http://www.sarl.io
http://www.arakhne.org
Previous Topic:Serializing cross-references with Serializer2
Next Topic:Xtend Code generation for RichStrings (FIXED)
Goto Forum:
  


Current Time: Mon Dec 18 09:19:01 GMT 2017

Powered by FUDForum. Page generated in 0.02413 seconds
.:: Contact :: Home ::.

Powered by: FUDforum 3.0.2.
Copyright ©2001-2010 FUDforum Bulletin Board Software