Make use of StringUtils.collectLines

Change-Id: If9db88182614e0da770802ac850738466e4267d7
diff --git a/r/org.eclipse.statet.nico.ui/META-INF/MANIFEST.MF b/r/org.eclipse.statet.nico.ui/META-INF/MANIFEST.MF
index d803c96..caf77d9 100644
--- a/r/org.eclipse.statet.nico.ui/META-INF/MANIFEST.MF
+++ b/r/org.eclipse.statet.nico.ui/META-INF/MANIFEST.MF
@@ -44,7 +44,8 @@
  org.eclipse.statet.jcommons.status;version="4.5.0",
  org.eclipse.statet.jcommons.status.eplatform;version="4.5.0",
  org.eclipse.statet.jcommons.text.core;version="4.5.0",
- org.eclipse.statet.jcommons.ts.core;version="4.5.0"
+ org.eclipse.statet.jcommons.ts.core;version="4.5.0",
+ org.eclipse.statet.jcommons.util;version="4.5.0"
 Export-Package: org.eclipse.statet.nico.ui,
  org.eclipse.statet.nico.ui.actions,
  org.eclipse.statet.nico.ui.console,
diff --git a/r/org.eclipse.statet.nico.ui/src/org/eclipse/statet/nico/ui/console/SubmitPasteAction.java b/r/org.eclipse.statet.nico.ui/src/org/eclipse/statet/nico/ui/console/SubmitPasteAction.java
index 0888b21..d6a2711 100644
--- a/r/org.eclipse.statet.nico.ui/src/org/eclipse/statet/nico/ui/console/SubmitPasteAction.java
+++ b/r/org.eclipse.statet.nico.ui/src/org/eclipse/statet/nico/ui/console/SubmitPasteAction.java
@@ -15,7 +15,6 @@
 package org.eclipse.statet.nico.ui.console;
 
 import java.lang.reflect.InvocationTargetException;
-import java.util.List;
 
 import org.eclipse.core.runtime.CoreException;
 import org.eclipse.core.runtime.IProgressMonitor;
@@ -28,9 +27,9 @@
 import org.eclipse.ui.actions.ActionFactory;
 
 import org.eclipse.statet.jcommons.status.Status;
+import org.eclipse.statet.jcommons.util.StringUtils;
 
 import org.eclipse.statet.ecommons.runtime.core.util.StatusUtils;
-import org.eclipse.statet.ecommons.text.TextUtil;
 
 import org.eclipse.statet.nico.core.runtime.SubmitType;
 import org.eclipse.statet.nico.core.runtime.ToolController;
@@ -79,7 +78,7 @@
 				try {
 					m.beginTask(NicoUITools.createSubmitMessage(controller.getTool()), 2 + 8);
 					
-					final List<String> lines= TextUtil.toLines(text);
+					final var lines= StringUtils.linesToList(text);
 					m.worked(2);
 					
 					final Status status= controller.submit(lines, SubmitType.CONSOLE,
diff --git a/r/org.eclipse.statet.r.console.ui/src/org/eclipse/statet/internal/r/console/ui/snippets/RSnippets.java b/r/org.eclipse.statet.r.console.ui/src/org/eclipse/statet/internal/r/console/ui/snippets/RSnippets.java
index 72b7475..ee87f4b 100644
--- a/r/org.eclipse.statet.r.console.ui/src/org/eclipse/statet/internal/r/console/ui/snippets/RSnippets.java
+++ b/r/org.eclipse.statet.r.console.ui/src/org/eclipse/statet/internal/r/console/ui/snippets/RSnippets.java
@@ -36,7 +36,8 @@
 import org.eclipse.ui.editors.text.templates.ContributionTemplateStore;
 import org.eclipse.ui.statushandlers.StatusManager;
 
-import org.eclipse.statet.ecommons.text.TextUtil;
+import org.eclipse.statet.jcommons.util.StringUtils;
+
 import org.eclipse.statet.ecommons.ui.util.UIAccess;
 import org.eclipse.statet.ecommons.ui.workbench.WorkbenchUIUtils;
 import org.eclipse.statet.ecommons.ui.workbench.workspace.ResourceVariableUtil;
@@ -251,7 +252,7 @@
 		setLastSnippet(template.getName());
 		try {
 			final String snippet= resolve(template);
-			final List<String> lines= TextUtil.toLines(snippet);
+			final var lines= StringUtils.linesToList(snippet);
 			
 			RCodeLaunching.runRCodeDirect(lines, false, null);
 			
diff --git a/r/org.eclipse.statet.r.ui/src/org/eclipse/statet/internal/r/ui/rhelp/RHelpView.java b/r/org.eclipse.statet.r.ui/src/org/eclipse/statet/internal/r/ui/rhelp/RHelpView.java
index 1aa13cb..2bd1ce4 100644
--- a/r/org.eclipse.statet.r.ui/src/org/eclipse/statet/internal/r/ui/rhelp/RHelpView.java
+++ b/r/org.eclipse.statet.r.ui/src/org/eclipse/statet/internal/r/ui/rhelp/RHelpView.java
@@ -62,10 +62,10 @@
 import org.eclipse.statet.jcommons.status.ProgressMonitor;
 import org.eclipse.statet.jcommons.status.StatusException;
 import org.eclipse.statet.jcommons.status.eplatform.EStatusUtils;
+import org.eclipse.statet.jcommons.util.StringUtils;
 
 import org.eclipse.statet.ecommons.commands.core.HandlerCollection;
 import org.eclipse.statet.ecommons.preferences.core.EPreferences;
-import org.eclipse.statet.ecommons.text.TextUtil;
 import org.eclipse.statet.ecommons.ui.SharedUIResources;
 import org.eclipse.statet.ecommons.ui.actions.HandlerContributionItem;
 import org.eclipse.statet.ecommons.ui.actions.SimpleContributionItem;
@@ -127,7 +127,7 @@
 				final String selectedText= browserPage.getSelectedText();
 				if (selectedText != null && selectedText.length() > 0) {
 					try {
-						final List<String> lines= TextUtil.toLines(selectedText);
+						final var lines= StringUtils.linesToList(selectedText);
 						RCodeLaunching.runRCodeDirect(lines, this.gotoConsole, null);
 					}
 					catch (final CoreException e) {
diff --git a/r/org.eclipse.statet.r.ui/srcDebug/org/eclipse/statet/internal/r/debug/ui/launcher/LaunchShortcutUtil.java b/r/org.eclipse.statet.r.ui/srcDebug/org/eclipse/statet/internal/r/debug/ui/launcher/LaunchShortcutUtil.java
index 841066f..9dbed2b 100644
--- a/r/org.eclipse.statet.r.ui/srcDebug/org/eclipse/statet/internal/r/debug/ui/launcher/LaunchShortcutUtil.java
+++ b/r/org.eclipse.statet.r.ui/srcDebug/org/eclipse/statet/internal/r/debug/ui/launcher/LaunchShortcutUtil.java
@@ -46,6 +46,8 @@
 import org.eclipse.ui.texteditor.IDocumentProvider;
 import org.eclipse.ui.texteditor.ITextEditor;
 
+import org.eclipse.statet.jcommons.util.StringUtils;
+
 import org.eclipse.statet.ecommons.text.TextUtil;
 import org.eclipse.statet.ecommons.ui.workbench.WorkbenchUIUtils;
 
@@ -130,9 +132,7 @@
 				if (textSelection.getLength() > 0) {
 					final String code = textSelection.getText();
 					if (code != null) {
-						final ArrayList<String> lines= new ArrayList<>(2 + code.length()/30);
-						TextUtil.addLines(code, lines);
-						return lines;
+						return StringUtils.linesToList(code);
 					}
 				}
 				IDocument document = null;
diff --git a/r/org.eclipse.statet.r.ui/srcDebug/org/eclipse/statet/internal/r/debug/ui/launcher/SubmitSelectionHandler.java b/r/org.eclipse.statet.r.ui/srcDebug/org/eclipse/statet/internal/r/debug/ui/launcher/SubmitSelectionHandler.java
index d2eae5d..289494f 100644
--- a/r/org.eclipse.statet.r.ui/srcDebug/org/eclipse/statet/internal/r/debug/ui/launcher/SubmitSelectionHandler.java
+++ b/r/org.eclipse.statet.r.ui/srcDebug/org/eclipse/statet/internal/r/debug/ui/launcher/SubmitSelectionHandler.java
@@ -25,6 +25,8 @@
 import org.eclipse.jface.viewers.ISelection;
 import org.eclipse.jface.viewers.IStructuredSelection;
 
+import org.eclipse.statet.jcommons.util.StringUtils;
+
 import org.eclipse.statet.ecommons.text.TextUtil;
 import org.eclipse.statet.ecommons.ui.workbench.WorkbenchUIUtils;
 
@@ -90,7 +92,7 @@
 					if (fModelUtil == null) {
 						fModelUtil = new RSourceCodeAdapter();
 					}
-					final List<String> lines = TextUtil.toLines(
+					final var lines= StringUtils.linesToList(
 							fModelUtil.getSourceCodeStringedTogether(elements, null) );
 					
 					RCodeLaunching.runRCodeDirect(lines, fGotoConsole, null);
diff --git a/r/org.eclipse.statet.r.ui/srcDebug/org/eclipse/statet/r/launching/RCodeLaunching.java b/r/org.eclipse.statet.r.ui/srcDebug/org/eclipse/statet/r/launching/RCodeLaunching.java
index e63a6c9..cf5986d 100644
--- a/r/org.eclipse.statet.r.ui/srcDebug/org/eclipse/statet/r/launching/RCodeLaunching.java
+++ b/r/org.eclipse.statet.r.ui/srcDebug/org/eclipse/statet/r/launching/RCodeLaunching.java
@@ -47,6 +47,7 @@
 import org.eclipse.statet.jcommons.status.StatusException;
 import org.eclipse.statet.jcommons.status.eplatform.EStatusUtils;
 import org.eclipse.statet.jcommons.ts.core.ToolRunnable;
+import org.eclipse.statet.jcommons.util.StringUtils;
 
 import org.eclipse.statet.ecommons.preferences.core.EPreferences;
 import org.eclipse.statet.ecommons.preferences.core.Preference.BooleanPref;
@@ -460,7 +461,7 @@
 					for (int i = 0; i < runnables.length; i++) {
 						final SourceRegion region = codeRegions.get(i);
 						lines.clear();
-						TextUtil.addLines(region.fCode, lines);
+						StringUtils.collectLines(region.fCode, lines);
 						runnables[i] = new SubmitEntireCommandRunnable(
 								lines.toArray(new String[lines.size()]), region);
 					}
@@ -477,7 +478,7 @@
 		}
 		final List<String> lines = new ArrayList<>(codeRegions.size()*2);
 		for (int i = 0; i < codeRegions.size(); i++) {
-			TextUtil.addLines(codeRegions.get(i).fCode, lines);
+			StringUtils.collectLines(codeRegions.get(i).fCode, lines);
 		}
 		return runRCodeDirect(lines, gotoConsole, null);
 	}