[SOLVED] Invalid modifiers for dirty types in content assist [message #1739213] |
Thu, 28 July 2016 11:27 |
|
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.
[Updated on: Thu, 28 July 2016 18:17] Report message to a moderator
|
|
|
|
|
Powered by
FUDForum. Page generated in 0.03548 seconds