|
1 | 1 | /******************************************************************************* |
2 | | - * Copyright (c) 2021, 2025 Carsten Hammer. |
| 2 | + * Copyright (c) 2021, 2022 Carsten Hammer. |
3 | 3 | * |
4 | 4 | * This program and the accompanying materials |
5 | 5 | * are made available under the terms of the Eclipse Public License 2.0 |
|
13 | 13 | *******************************************************************************/ |
14 | 14 | package org.eclipse.jdt.internal.common; |
15 | 15 |
|
16 | | -import java.util.AbstractMap; |
17 | 16 | import java.util.EnumSet; |
18 | 17 | import java.util.HashMap; |
19 | 18 | import java.util.LinkedHashMap; |
|
35 | 34 | */ |
36 | 35 | public class HelperVisitor<E extends HelperVisitorProvider<V, T, E>,V,T> { |
37 | 36 |
|
38 | | - public static final String TYPEOF = "typeof"; //$NON-NLS-1$ |
39 | | - public static final String METHODNAME = "methodname"; //$NON-NLS-1$ |
40 | | - public static final String PARAMTYPENAMES = "paramtypenames"; //$NON-NLS-1$ |
41 | 37 | ASTVisitor astvisitor; |
42 | 38 |
|
43 | 39 | public E dataholder; |
@@ -374,20 +370,6 @@ public BiPredicate<? extends ASTNode, E> addClassInstanceCreation(BiPredicate<Cl |
374 | 370 | return predicatemap.put(VisitorEnum.ClassInstanceCreation, bs); |
375 | 371 | } |
376 | 372 |
|
377 | | - /** |
378 | | - * |
379 | | - * @param typeof class to be instantiated |
380 | | - * @param bs - BiPredicate that can be assigned a lambda expression |
381 | | - * @return - previous BiPredicate registered |
382 | | - */ |
383 | | - public BiPredicate<? extends ASTNode, E> addClassInstanceCreation(Class<?> typeof, BiPredicate<ClassInstanceCreation, E> bs) { |
384 | | - Map<String, Object> map = Map.ofEntries( |
385 | | - new AbstractMap.SimpleEntry<>(TYPEOF, typeof) |
386 | | - ); |
387 | | - predicatedata.put(VisitorEnum.ClassInstanceCreation, map); |
388 | | - return predicatemap.put(VisitorEnum.ClassInstanceCreation, bs); |
389 | | - } |
390 | | - |
391 | 373 | /** |
392 | 374 | * Add BiPredicate to use for CompilationUnit visit |
393 | 375 | * |
@@ -737,27 +719,7 @@ public BiPredicate<? extends ASTNode, E> addMethodInvocation(BiPredicate<MethodI |
737 | 719 | */ |
738 | 720 | public BiPredicate<? extends ASTNode, E> addMethodInvocation(String methodname, |
739 | 721 | BiPredicate<MethodInvocation, E> bs) { |
740 | | - this.predicatedata.put(VisitorEnum.MethodInvocation, Map.ofEntries( |
741 | | - new AbstractMap.SimpleEntry<>(METHODNAME, methodname) |
742 | | - )); |
743 | | - return predicatemap.put(VisitorEnum.MethodInvocation, bs); |
744 | | - } |
745 | | - |
746 | | - /** |
747 | | - * Add BiPredicate to use for MethodInvocation visit where class and method name is specified |
748 | | - * |
749 | | - * @param typeof class whose method is called |
750 | | - * @param methodname name of the method that is called |
751 | | - * @param bs BiPredicate that can be assigned a lambda expression |
752 | | - * @return previous BiPredicate registered |
753 | | - */ |
754 | | - public BiPredicate<? extends ASTNode, E> addMethodInvocation(Class<?> typeof, String methodname, |
755 | | - BiPredicate<MethodInvocation, E> bs) { |
756 | | - Map<String, Object> map = Map.ofEntries( |
757 | | - new AbstractMap.SimpleEntry<>(METHODNAME, methodname), |
758 | | - new AbstractMap.SimpleEntry<>(TYPEOF, typeof) |
759 | | - ); |
760 | | - predicatedata.put(VisitorEnum.MethodInvocation, map); |
| 722 | + this.predicatedata.put(VisitorEnum.MethodInvocation, methodname); |
761 | 723 | return predicatemap.put(VisitorEnum.MethodInvocation, bs); |
762 | 724 | } |
763 | 725 |
|
@@ -1522,9 +1484,7 @@ public BiConsumer<? extends ASTNode, E> addMethodInvocation(BiConsumer<MethodInv |
1522 | 1484 | } |
1523 | 1485 |
|
1524 | 1486 | public BiConsumer<? extends ASTNode, E> addMethodInvocation(String methodname, BiConsumer<MethodInvocation, E> bc) { |
1525 | | - this.consumerdata.put(VisitorEnum.MethodInvocation, Map.ofEntries( |
1526 | | - new AbstractMap.SimpleEntry<>(METHODNAME, methodname) |
1527 | | - )); |
| 1487 | + this.consumerdata.put(VisitorEnum.MethodInvocation, methodname); |
1528 | 1488 | return consumermap.put(VisitorEnum.MethodInvocation, bc); |
1529 | 1489 | } |
1530 | 1490 |
|
@@ -2220,51 +2180,24 @@ public void addMethodDeclaration(BiPredicate<MethodDeclaration, E> bs, BiConsume |
2220 | 2180 |
|
2221 | 2181 | /** |
2222 | 2182 | * |
2223 | | - * @param methodname Only visit MethodInvocation with this name |
2224 | | - * @param bs - BiPredicate that is visited when a MethodInvocation is found |
2225 | | - * @param bc - BiConsumer that is visited at the end after a MethodInvocation has been found |
| 2183 | + * @param bs - BiPredicate that can be assigned a lambda expression |
2226 | 2184 | */ |
2227 | 2185 | public void addMethodInvocation(String methodname, BiPredicate<MethodInvocation, E> bs, |
2228 | 2186 | BiConsumer<MethodInvocation, E> bc) { |
2229 | | - predicatedata.put(VisitorEnum.MethodInvocation, Map.ofEntries( |
2230 | | - new AbstractMap.SimpleEntry<>(METHODNAME, methodname) |
2231 | | - )); |
2232 | | - predicatemap.put(VisitorEnum.MethodInvocation, bs); |
2233 | | - consumerdata.put(VisitorEnum.MethodInvocation, Map.ofEntries( |
2234 | | - new AbstractMap.SimpleEntry<>(METHODNAME, methodname) |
2235 | | - )); |
2236 | | - consumermap.put(VisitorEnum.MethodInvocation, bc); |
2237 | | - } |
2238 | | - |
2239 | | - /** |
2240 | | - * @param typeof Only visit MethodInvocation calling a method of this class |
2241 | | - * @param methodname Only visit MethodInvocation with this name |
2242 | | - * @param bs - BiPredicate that is visited when a MethodInvocation is found |
2243 | | - * @param bc - BiConsumer that is visited at the end after a MethodInvocation has been found |
2244 | | - */ |
2245 | | - public void addMethodInvocation(Class<?> typeof, String methodname, BiPredicate<MethodInvocation, E> bs, |
2246 | | - BiConsumer<MethodInvocation, E> bc) { |
2247 | | - Map<String, Object> map = Map.ofEntries( |
2248 | | - new AbstractMap.SimpleEntry<>(METHODNAME, methodname), |
2249 | | - new AbstractMap.SimpleEntry<>(TYPEOF, typeof) |
2250 | | - ); |
2251 | | - predicatedata.put(VisitorEnum.MethodInvocation, map); |
| 2187 | + this.predicatedata.put(VisitorEnum.MethodInvocation, methodname); |
2252 | 2188 | predicatemap.put(VisitorEnum.MethodInvocation, bs); |
2253 | | - consumerdata.put(VisitorEnum.MethodInvocation, map); |
2254 | 2189 | consumermap.put(VisitorEnum.MethodInvocation, bc); |
2255 | 2190 | } |
2256 | 2191 |
|
2257 | 2192 | /** |
2258 | 2193 | * |
2259 | 2194 | * @param bs - BiPredicate that can be assigned a lambda expression |
2260 | | - * @param bc - BiConsumer that is visited at the end after a MethodInvocation has been found |
2261 | 2195 | */ |
2262 | 2196 | public void addMethodInvocation(BiPredicate<MethodInvocation, E> bs, BiConsumer<MethodInvocation, E> bc) { |
2263 | 2197 | predicatemap.put(VisitorEnum.MethodInvocation, bs); |
2264 | 2198 | consumermap.put(VisitorEnum.MethodInvocation, bc); |
2265 | 2199 | } |
2266 | 2200 |
|
2267 | | - |
2268 | 2201 | /** |
2269 | 2202 | * |
2270 | 2203 | * @param bs - BiPredicate that can be assigned a lambda expression |
@@ -3495,13 +3428,6 @@ public static <V, T> void callMethodInvocationVisitor(String methodname, ASTNode |
3495 | 3428 | hv.build(node); |
3496 | 3429 | } |
3497 | 3430 |
|
3498 | | - public static <V, T> void callMethodInvocationVisitor(Class<?> methodof, String methodname, ASTNode node, ReferenceHolder<V, T> dataholder, Set<ASTNode> nodesprocessed, |
3499 | | - BiPredicate<MethodInvocation, ReferenceHolder<V, T>> bs) { |
3500 | | - |
3501 | | - HelperVisitor<ReferenceHolder<V, T>,V,T> hv= new HelperVisitor<>(nodesprocessed, dataholder); |
3502 | | - hv.addMethodInvocation(methodof, methodname, bs); |
3503 | | - hv.build(node); |
3504 | | - } |
3505 | 3431 | /** |
3506 | 3432 | * |
3507 | 3433 | * @param nodesprocessed - set of nodes processed |
@@ -5701,13 +5627,6 @@ public static <V, T> void callClassInstanceCreationVisitor(ASTNode node, Referen |
5701 | 5627 | hv.build(node); |
5702 | 5628 | } |
5703 | 5629 |
|
5704 | | - public static <V, T> void callClassInstanceCreationVisitor(Class<?> class1, ASTNode node, ReferenceHolder<V, T> dataholder, Set<ASTNode> nodesprocessed, |
5705 | | - BiPredicate<ClassInstanceCreation, ReferenceHolder<V, T>> bs) { |
5706 | | - |
5707 | | - HelperVisitor<ReferenceHolder<V, T>,V,T> hv= new HelperVisitor<>(nodesprocessed, dataholder); |
5708 | | - hv.addClassInstanceCreation(class1, bs); |
5709 | | - hv.build(node); |
5710 | | - } |
5711 | 5630 | /** |
5712 | 5631 | * |
5713 | 5632 | * @param nodesprocessed - set of nodes processed |
|
0 commit comments