private static void processJavaMethodCompletionProposal(List<ICompletionProposal> list,
boolean settersOnly,
final Collection<ICompletionProposal> set,
ICompletionProposal o) {
LazyJavaCompletionProposal javaProposal = (LazyJavaCompletionProposal) o;
//TODO: FIXME: this is very fragile as it uses reflection to access the private completion field.
//Yet this is needed to do mvel filtering based on the method signtures, IF we use the richer JDT completion
Object field = ReflectionUtils.getField(o, "fProposal");
if ( field != null && field instanceof CompletionProposal ) {
CompletionProposal proposal = (CompletionProposal) field;
String completion = new String( proposal.getCompletion() );
String propertyOrMethodName = null;
boolean isSetter = false;
boolean isAccessor = false;
if ( settersOnly ) {
// get the eventual writable property name for that method name and signature
propertyOrMethodName = CompletionUtil.getWritablePropertyName( completion,
proposal.getSignature() );
// if we got a property name that differs from the orginal method name
//then this is a bean accessor
isSetter = !completion.equals( propertyOrMethodName );
} else {
// get the eventual property name for that method name and signature
propertyOrMethodName = CompletionUtil.getPropertyName( completion,
proposal.getSignature() );
//if we got a property name that differs from the orginal method name
//then this is a bean accessor
isAccessor = !completion.equals( propertyOrMethodName );
}
// is the completion for a bean accessor? and do we have already some relevant completion?
boolean doesNotContainFieldCompletion = DefaultCompletionProcessor.doesNotContainFieldCompletion( propertyOrMethodName,
list );
if ( ((settersOnly && isSetter) || (!settersOnly && isAccessor)) && doesNotContainFieldCompletion ) {
//TODO: craft a better JDTish display name than just the property name
RuleCompletionProposal prop = new RuleCompletionProposal( javaProposal.getReplacementOffset(),
javaProposal.getReplacementLength(),
propertyOrMethodName );
prop.setImage( DefaultCompletionProcessor.VARIABLE_ICON );
//set high priority such that the completion for accessors shows up first
prop.setPriority( 1000 );
set.add( prop );