@@ -325,10 +325,6 @@ protected InstanceKey computeInstanceKey(Collection<InstanceKey> trackedInstance
325325 "Can't find instance key for: " + this .getCreation () + " using tracked instances: " + trackedInstances );
326326 }
327327
328- protected void convertToParallel (CompilationUnitRewrite rewrite ) {
329- convert ("sequential" , "parallel" , "stream" , "parallelStream" , rewrite );
330- }
331-
332328 private void convert (String source , String target , String sourceGenerator , String targetGenerator ,
333329 CompilationUnitRewrite rewrite ) {
334330 MethodInvocation creation = this .getCreation ();
@@ -348,36 +344,38 @@ private void convert(String source, String target, String sourceGenerator, Strin
348344
349345 String identifier = inv .getName ().getIdentifier ();
350346
351- if (identifier .equals (source )) {
347+ if (identifier .equals (source ))
352348 // remove it.
353349 astRewrite .replace (inv , inv .getExpression (), null );
354- } else if (identifier .equals (target )) {
350+ else if (identifier .equals (target ))
355351 done = true ;
356- } else if (identifier .equals (sourceGenerator )) {
352+ else if (identifier .equals (sourceGenerator )) {
357353 // Replace with parallelStream().
358354 SimpleName newMethodName = ast .newSimpleName (targetGenerator );
359355 astRewrite .replace (creation .getName (), newMethodName , null );
360- } else if (identifier .equals (targetGenerator )) {
356+ } else if (identifier .equals (targetGenerator ))
361357 done = true ;
362- } else {
363- // if we're at the end.
364- if (inv .getExpression ().getNodeType () != ASTNode .METHOD_INVOCATION
365- || inv .getExpression ().getNodeType () == ASTNode .METHOD_INVOCATION
366- && !implementsBaseStream (inv .getExpression ().resolveTypeBinding ())) {
367- MethodInvocation newMethodInvocation = ast .newMethodInvocation ();
368- newMethodInvocation .setName (ast .newSimpleName (target ));
369- MethodInvocation invCopy = (MethodInvocation ) ASTNode .copySubtree (ast , inv );
370- newMethodInvocation .setExpression (invCopy );
371- astRewrite .replace (inv , newMethodInvocation , null );
372- }
358+ else // if we're at the end.
359+ if (inv .getExpression ().getNodeType () != ASTNode .METHOD_INVOCATION
360+ || inv .getExpression ().getNodeType () == ASTNode .METHOD_INVOCATION
361+ && !implementsBaseStream (inv .getExpression ().resolveTypeBinding ())) {
362+ MethodInvocation newMethodInvocation = ast .newMethodInvocation ();
363+ newMethodInvocation .setName (ast .newSimpleName (target ));
364+ MethodInvocation invCopy = (MethodInvocation ) ASTNode .copySubtree (ast , inv );
365+ newMethodInvocation .setExpression (invCopy );
366+ astRewrite .replace (inv , newMethodInvocation , null );
373367 }
374368 expression = inv .getExpression ();
375369 } else
376370 done = true ;
377371 }
378372
373+ protected void convertToParallel (CompilationUnitRewrite rewrite ) {
374+ this .convert ("sequential" , "parallel" , "stream" , "parallelStream" , rewrite );
375+ }
376+
379377 protected void convertToSequential (CompilationUnitRewrite rewrite ) {
380- convert ("parallel" , "sequential" , "parallelStream" , "stream" , rewrite );
378+ this . convert ("parallel" , "sequential" , "parallelStream" , "stream" , rewrite );
381379 }
382380
383381 public Set <TransformationAction > getActions () {
0 commit comments