lahodaj commented on code in PR #7316:
URL: https://github.com/apache/netbeans/pull/7316#discussion_r1575996846
##########
enterprise/micronaut/src/org/netbeans/modules/micronaut/expression/ExpressionTree.java:
##########
@@ -564,42 +565,44 @@ public <R, D> R accept(Scanner<R, D> scanner, D data) {
@Override
protected void resolve(EvaluationContext ctx) {
- List<ExecutableElement> methods = null;
+ List<? extends Element> elements = null;
DeclaredType dt = null;
if (callee == null) {
- methods = ctx.getContextMethods();
+ elements = ctx.getContextElements();
} else {
TypeMirror calleeTM = callee.getTypeMirror(ctx);
if (calleeTM.getKind() == TypeKind.DECLARED) {
dt = (DeclaredType) calleeTM;
- methods = ElementFilter.methodsIn(((TypeElement)
dt.asElement()).getEnclosedElements());
+ elements = ElementFilter.methodsIn(((TypeElement)
dt.asElement()).getEnclosedElements());
}
}
- if (methods != null && !methods.isEmpty()) {
+ if (elements != null && !elements.isEmpty()) {
List<TypeMirror> argTypes = arguments.stream().map(arg ->
arg.getTypeMirror(ctx)).collect(Collectors.toList());
- for (ExecutableElement ee : methods) {
- TypeMirror enclType = dt != null ? dt :
ee.getEnclosingElement().asType();
- if (enclType.getKind() == TypeKind.DECLARED &&
identifier.contentEquals(ee.getSimpleName()) &&
ctx.getTrees().isAccessible(ctx.getScope(), ee, (DeclaredType) enclType)) {
- ExecutableType et = (ExecutableType)
ctx.getTypes().asMemberOf((DeclaredType) enclType, ee);
- List<? extends TypeMirror> paramTypes =
et.getParameterTypes();
- if (ee.isVarArgs() && argTypes.size() >=
paramTypes.size() || argTypes.size() == paramTypes.size()) {
- boolean match = true;
- Iterator<? extends TypeMirror> paramsIt =
paramTypes.iterator();
- TypeMirror param = paramsIt.hasNext() ?
paramsIt.next() : null;
- for (Iterator<TypeMirror> argsIt =
argTypes.iterator(); match && argsIt.hasNext();) {
- TypeMirror arg = argsIt.next();
- if (!ctx.getTypes().isAssignable(arg, param)) {
- match = false;
+ for (Element e : elements) {
Review Comment:
FWIW - might be easier to use `ElementsFilter.methodsIn`.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]
For further information about the NetBeans mailing lists, visit:
https://cwiki.apache.org/confluence/display/NETBEANS/Mailing+lists