changeset 52623:abb5364fcb36 concise-method-declarations

modify the finder to consider constructor invocations too
author vromero
date Tue, 25 Sep 2018 09:40:01 -0700
parents a427ca6e455a
children cac8618a27ec
files src/jdk.compiler/share/classes/com/sun/tools/javac/comp/Analyzer.java
diffstat 1 files changed, 14 insertions(+), 1 deletions(-) [+]
line wrap: on
line diff
--- a/src/jdk.compiler/share/classes/com/sun/tools/javac/comp/Analyzer.java	Tue Sep 25 08:38:29 2018 -0700
+++ b/src/jdk.compiler/share/classes/com/sun/tools/javac/comp/Analyzer.java	Tue Sep 25 09:40:01 2018 -0700
@@ -377,8 +377,21 @@
                             treeToPosMap.put(tree, methodDec);
                         }
                     }
+                } else {
+                    JCNewClass constructor = findConstructor(stat);
+                    if (constructor != null &&
+                            constructor.def == null &&
+                            constructor.clazz.hasTag(Tag.IDENT)) {
+                        if (methodDec.params.size() == constructor.args.size()) {
+                            List<Symbol> paramsSyms = TreeInfo.symbols(methodDec.params);
+                            List<Symbol> argsSyms = TreeInfo.symbols(constructor.args);
+                            result = paramsSyms.equals(argsSyms);
+                            if (result) {
+                                treeToPosMap.put(tree, methodDec);
+                            }
+                        }
+                    }
                 }
-                // we still have to include constructor invocations
             }
             return result;
         }