diff --git a/ide/org.codehaus.groovy.eclipse.codeassist.completion/src/org/codehaus/groovy/eclipse/codeassist/processors/StatementAndExpressionCompletionProcessor.java b/ide/org.codehaus.groovy.eclipse.codeassist.completion/src/org/codehaus/groovy/eclipse/codeassist/processors/StatementAndExpressionCompletionProcessor.java index 977cd1672c..a6cdd5acd2 100644 --- a/ide/org.codehaus.groovy.eclipse.codeassist.completion/src/org/codehaus/groovy/eclipse/codeassist/processors/StatementAndExpressionCompletionProcessor.java +++ b/ide/org.codehaus.groovy.eclipse.codeassist.completion/src/org/codehaus/groovy/eclipse/codeassist/processors/StatementAndExpressionCompletionProcessor.java @@ -1,5 +1,5 @@ /* - * Copyright 2009-2018 the original author or authors. + * Copyright 2009-2019 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -359,8 +359,8 @@ private List createJavaProposals(Collection delegateProposals, Collection ownerProposals, int resolveStrategy) { - Function toName = (IGroovyProposal proposal) -> { - AnnotatedNode node = ((AbstractGroovyProposal) proposal).getAssociatedNode(); + Function toName = p -> { + AnnotatedNode node = ((AbstractGroovyProposal) p).getAssociatedNode(); if (node instanceof FieldNode) { return ((FieldNode) node).getName(); } @@ -373,6 +373,11 @@ private static void setClosureQualifiers(Collection delegatePro throw new IllegalStateException("unexpected node type: " + node.getClass()); }; + Consumer reduceRelevance = p -> { + AbstractGroovyProposal agp = (AbstractGroovyProposal) p; + agp.setRelevanceMultiplier(agp.getRelevanceMultiplier() * 0.9f); + }; + if (!delegateProposals.isEmpty()) { Consumer addDelegateQualifier = p -> ((AbstractGroovyProposal) p).setRequiredQualifier("delegate"); @@ -380,7 +385,7 @@ private static void setClosureQualifiers(Collection delegatePro Set names = ownerProposals.stream().map(toName).collect(Collectors.toSet()); delegateProposals.stream().filter(p -> names.contains(toName.apply(p))).forEach(addDelegateQualifier); } else if (resolveStrategy == Closure.TO_SELF) { - delegateProposals.forEach(addDelegateQualifier); + delegateProposals.forEach(addDelegateQualifier.andThen(reduceRelevance)); } } @@ -391,7 +396,7 @@ private static void setClosureQualifiers(Collection delegatePro Set names = delegateProposals.stream().map(toName).collect(Collectors.toSet()); ownerProposals.stream().filter(p -> names.contains(toName.apply(p))).forEach(addOwnerQualifier); } else if (resolveStrategy == Closure.TO_SELF) { - ownerProposals.forEach(addOwnerQualifier); + ownerProposals.forEach(addOwnerQualifier.andThen(reduceRelevance)); } } }