Skip to content

Commit

Permalink
add missing implementation detail in LambdaASTVisitor what fixes tests
Browse files Browse the repository at this point in the history
  • Loading branch information
carstenartur committed Sep 14, 2024
1 parent 84199ae commit 0f1d64f
Show file tree
Hide file tree
Showing 8 changed files with 27 additions and 19 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -193,6 +193,16 @@ public boolean visit(CharacterLiteral node) {
@Override
public boolean visit(ClassInstanceCreation node) {
if (this.helperVisitor.predicatemap.containsKey(VisitorEnum.ClassInstanceCreation)) {
Map<String, Object> map=(Map<String, Object>) this.helperVisitor.getSupplierData().get(VisitorEnum.ClassInstanceCreation);
if(map != null) {
Class<?> typeof=(Class<?>) map.get(HelperVisitor.TYPEOF);
if(typeof!=null) {
ITypeBinding binding= node.resolveTypeBinding();
if (!typeof.getSimpleName().equals(binding.getName())) {
return true;
}
}
}
return ((BiPredicate<ClassInstanceCreation, E>) (this.helperVisitor.predicatemap
.get(VisitorEnum.ClassInstanceCreation))).test(node, this.helperVisitor.dataholder);
}
Expand Down Expand Up @@ -496,18 +506,6 @@ public boolean visit(MethodDeclaration node) {
return true;
}

// @Override
// public boolean visit(MethodInvocation node) {
// if (this.helperVisitor.predicatemap.containsKey(VisitorEnum.MethodInvocation)) {
// String data=(String) this.helperVisitor.getSupplierData().get(VisitorEnum.MethodInvocation);
// if (data!= null && !node.getName().getIdentifier().equals(data)) {
// return true;
// }
// return ((BiPredicate<MethodInvocation, E>) (this.helperVisitor.predicatemap.get(VisitorEnum.MethodInvocation))).test(node, this.helperVisitor.dataholder);
// }
// return true;
// }

@Override
public boolean visit(MethodInvocation node) {
if (this.helperVisitor.predicatemap.containsKey(VisitorEnum.MethodInvocation)) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,6 @@ private static boolean processFoundNode(UseExplicitEncodingFixCore fixcore, Set<
nd.visited=argstring3;
holder.put(visited,nd);
operations.add(fixcore.rewrite(visited, cb, holder));
nodesprocessed.add(visited);
return false;
}
if (ASTNodes.usesGivenSignature(visited, ByteArrayOutputStream.class.getCanonicalName(), METHOD_TOSTRING)) {
Expand All @@ -94,7 +93,6 @@ private static boolean processFoundNode(UseExplicitEncodingFixCore fixcore, Set<
nd2.visited=visited;
holder.put(visited,nd2);
operations.add(fixcore.rewrite(visited, cb, holder));
nodesprocessed.add(visited);
return false;
}
return false;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -87,18 +87,20 @@ private static boolean processFoundNode(UseExplicitEncodingFixCore fixcore,
nd.replace=true;
nd.visited=argstring3;
holder.put(visited,nd);
operations.add(fixcore.rewrite(visited, cb, holder));
break;
case 1:
Nodedata nd2=new Nodedata();
nd2.encoding=null;
nd2.replace=false;
nd2.visited=visited;
holder.put(visited,nd2);
operations.add(fixcore.rewrite(visited, cb, holder));
break;
default:
break;
}
operations.add(fixcore.rewrite(visited, cb, holder));

return false;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -68,18 +68,20 @@ private static boolean processFoundNode(UseExplicitEncodingFixCore fixcore,
nd.replace=true;
nd.visited=argstring3;
holder.put(visited,nd);
operations.add(fixcore.rewrite(visited, cb, holder));
break;
case 1:
Nodedata nd2=new Nodedata();
nd2.encoding=null;
nd2.replace=false;
nd2.visited=visited;
holder.put(visited,nd2);
operations.add(fixcore.rewrite(visited, cb, holder));
break;
default:
break;
}
operations.add(fixcore.rewrite(visited, cb, holder));

return false;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -80,18 +80,20 @@ private static boolean processFoundNode(UseExplicitEncodingFixCore fixcore,
nd.replace=true;
nd.visited=argstring3;
holder.put(visited,nd);
operations.add(fixcore.rewrite(visited, cb, holder));
break;
case 1:
Nodedata nd2=new Nodedata();
nd2.encoding=null;
nd2.replace=false;
nd2.visited=visited;
holder.put(visited,nd2);
operations.add(fixcore.rewrite(visited, cb, holder));
break;
default:
break;
}
operations.add(fixcore.rewrite(visited, cb, holder));

return false;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -78,6 +78,7 @@ private static boolean processFoundNode(UseExplicitEncodingFixCore fixcore, Set<
nd.replace=true;
nd.visited=argstring4;
holder.put(visited,nd);
operations.add(fixcore.rewrite(visited, cb, holder));
break;
case 2:
if(!(arguments.get(1) instanceof StringLiteral)) {
Expand All @@ -92,12 +93,13 @@ private static boolean processFoundNode(UseExplicitEncodingFixCore fixcore, Set<
nd2.replace=true;
nd2.visited=argstring3;
holder.put(visited,nd2);
operations.add(fixcore.rewrite(visited, cb, holder));
break;
case 1:
default:
break;
}
operations.add(fixcore.rewrite(visited, cb, holder));

return false;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,7 @@ private static boolean processFoundNode(UseExplicitEncodingFixCore fixcore, Set<
nd.replace=true;
nd.visited=argstring4;
holder.put(visited,nd);
operations.add(fixcore.rewrite(visited, cb, holder));
break;
case 2:
if(!(arguments.get(1) instanceof StringLiteral)) {
Expand All @@ -87,12 +88,13 @@ private static boolean processFoundNode(UseExplicitEncodingFixCore fixcore, Set<
nd2.replace=true;
nd2.visited=argstring3;
holder.put(visited,nd2);
operations.add(fixcore.rewrite(visited, cb, holder));
break;
case 1:
default:
break;
}
operations.add(fixcore.rewrite(visited, cb, holder));

return false;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -206,6 +206,7 @@ private static void setEclipseDefaultSettings(CleanUpOptions options) {
options.setOption(CONTROL_STATEMENTS_CONVERT_FOR_LOOP_ONLY_IF_LOOP_VAR_USED, CleanUpOptions.TRUE);
options.setOption(CONTROL_STATEMENTS_USE_ADD_ALL, CleanUpOptions.FALSE);
options.setOption(EXPLICITENCODING_CLEANUP, CleanUpOptions.FALSE);
options.setOption(EXPLICITENCODING_KEEP_BEHAVIOR, CleanUpOptions.TRUE);
}

private static void setSaveParticipantSettings(CleanUpOptions options) {
Expand Down Expand Up @@ -392,6 +393,7 @@ private static void setSaveParticipantSettings(CleanUpOptions options) {
options.setOption(CONTROL_STATEMENTS_CONVERT_FOR_LOOP_ONLY_IF_LOOP_VAR_USED, CleanUpOptions.FALSE);
options.setOption(CONTROL_STATEMENTS_USE_ADD_ALL, CleanUpOptions.FALSE);
options.setOption(EXPLICITENCODING_CLEANUP, CleanUpOptions.FALSE);
options.setOption(EXPLICITENCODING_KEEP_BEHAVIOR, CleanUpOptions.TRUE);
}

public static void initDefaults(IPreferenceStore store) {
Expand Down

0 comments on commit 0f1d64f

Please sign in to comment.