Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorAlexander Kurtakov2020-01-07 20:53:31 +0000
committerAlexander Kurtakov2020-01-10 21:24:59 +0000
commitefd906be3deb58abf491eaa3f327f29cb1656a46 (patch)
treec23cc6fcc854cfa3aaa1576b7b9f180d24680905
parentf966653a8a33bdef6afe64e52b7cd7da4c054d16 (diff)
downloadeclipse.platform.swt-efd906be3deb58abf491eaa3f327f29cb1656a46.tar.gz
eclipse.platform.swt-efd906be3deb58abf491eaa3f327f29cb1656a46.tar.xz
eclipse.platform.swt-efd906be3deb58abf491eaa3f327f29cb1656a46.zip
Use System.lineSeparator()
Benefit of this way rather than System.getProperty("line.separator") is that there are no security checks. Change-Id: I89bc3b8490f47498e161736a9ab5756fd88835a9 Signed-off-by: Alexander Kurtakov <akurtako@redhat.com>
-rw-r--r--bundles/org.eclipse.swt.tools/JNI Generation/org/eclipse/swt/tools/internal/JNIGenerator.java6
-rw-r--r--bundles/org.eclipse.swt.tools/Mac Generation/org/eclipse/swt/tools/internal/MacGenerator.java6
-rw-r--r--bundles/org.eclipse.swt/Eclipse SWT Custom Widgets/common/org/eclipse/swt/custom/DefaultContent.java4
-rw-r--r--bundles/org.eclipse.swt/Eclipse SWT Custom Widgets/common/org/eclipse/swt/custom/StyledText.java2
-rw-r--r--bundles/org.eclipse.swt/Eclipse SWT Custom Widgets/common/org/eclipse/swt/custom/StyledTextContent.java4
-rw-r--r--bundles/org.eclipse.swt/Eclipse SWT PI/common/org/eclipse/swt/internal/Library.java4
-rw-r--r--examples/org.eclipse.swt.examples/src/org/eclipse/swt/examples/texteditor/text.txt2
-rw-r--r--tests/org.eclipse.swt.tests.gtk/ManualTests/org/eclipse/swt/tests/gtk/snippets/Bug221240_AWTJVMCrash.java4
-rw-r--r--tests/org.eclipse.swt.tests/JUnit Tests/org/eclipse/swt/tests/junit/Test_org_eclipse_swt_custom_StyledText.java46
9 files changed, 39 insertions, 39 deletions
diff --git a/bundles/org.eclipse.swt.tools/JNI Generation/org/eclipse/swt/tools/internal/JNIGenerator.java b/bundles/org.eclipse.swt.tools/JNI Generation/org/eclipse/swt/tools/internal/JNIGenerator.java
index 2e39530635..8a91368fc9 100644
--- a/bundles/org.eclipse.swt.tools/JNI Generation/org/eclipse/swt/tools/internal/JNIGenerator.java
+++ b/bundles/org.eclipse.swt.tools/JNI Generation/org/eclipse/swt/tools/internal/JNIGenerator.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2004, 2018 IBM Corporation and others.
+ * Copyright (c) 2004, 2020 IBM Corporation and others.
*
* This program and the accompanying materials
* are made available under the terms of the Eclipse Public License 2.0
@@ -29,7 +29,7 @@ public abstract class JNIGenerator implements Flags {
static final String JNI64 = "JNI64";
public JNIGenerator() {
- delimiter = System.getProperty("line.separator");
+ delimiter = System.lineSeparator();
output = System.out;
metaData = new MetaData(new Properties());
}
@@ -102,7 +102,7 @@ public static String getDelimiter(String fileName) {
}
} catch (IOException e) {
}
- return System.getProperty("line.separator");
+ return System.lineSeparator();
}
String fixDelimiter(String str) {
diff --git a/bundles/org.eclipse.swt.tools/Mac Generation/org/eclipse/swt/tools/internal/MacGenerator.java b/bundles/org.eclipse.swt.tools/Mac Generation/org/eclipse/swt/tools/internal/MacGenerator.java
index 3ee4c0ce39..c0bb0dd5d4 100644
--- a/bundles/org.eclipse.swt.tools/Mac Generation/org/eclipse/swt/tools/internal/MacGenerator.java
+++ b/bundles/org.eclipse.swt.tools/Mac Generation/org/eclipse/swt/tools/internal/MacGenerator.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2008, 2017 IBM Corporation and others.
+ * Copyright (c) 2008, 2020 IBM Corporation and others.
*
* This program and the accompanying materials
* are made available under the terms of the Eclipse Public License 2.0
@@ -27,7 +27,7 @@ public class MacGenerator {
String[] xmls;
Document[] documents;
String outputDir, outputLibDir, extrasDir, mainClassName, selectorEnumName;
- String delimiter = System.getProperty("line.separator");
+ String delimiter = System.lineSeparator();
PrintWriter out;
HashSet<String> knownConstTypes = new HashSet<>();
@@ -102,7 +102,7 @@ void merge(Document document, Document extraDocument) {
}
return compare;
});
- String delimiter = System.getProperty("line.separator");
+ String delimiter = System.lineSeparator();
for (Node node : sortedNodes) {
String name = node.getNodeName();
if ("arg".equals(name) || "retval".equals(name)) {
diff --git a/bundles/org.eclipse.swt/Eclipse SWT Custom Widgets/common/org/eclipse/swt/custom/DefaultContent.java b/bundles/org.eclipse.swt/Eclipse SWT Custom Widgets/common/org/eclipse/swt/custom/DefaultContent.java
index c49936e7ef..35450894ba 100644
--- a/bundles/org.eclipse.swt/Eclipse SWT Custom Widgets/common/org/eclipse/swt/custom/DefaultContent.java
+++ b/bundles/org.eclipse.swt/Eclipse SWT Custom Widgets/common/org/eclipse/swt/custom/DefaultContent.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2000, 2018 IBM Corporation and others.
+ * Copyright (c) 2000, 2020 IBM Corporation and others.
*
* This program and the accompanying materials
* are made available under the terms of the Eclipse Public License 2.0
@@ -21,7 +21,7 @@ import org.eclipse.swt.internal.*;
import org.eclipse.swt.widgets.*;
class DefaultContent implements StyledTextContent {
- private final static String LineDelimiter = System.getProperty("line.separator");
+ private final static String LineDelimiter = System.lineSeparator();
List<StyledTextListener> textListeners = new ArrayList<>(); // stores text listeners for event sending
char[] textStore = new char[0]; // stores the actual text
diff --git a/bundles/org.eclipse.swt/Eclipse SWT Custom Widgets/common/org/eclipse/swt/custom/StyledText.java b/bundles/org.eclipse.swt/Eclipse SWT Custom Widgets/common/org/eclipse/swt/custom/StyledText.java
index 9aa983a379..fdae53a114 100644
--- a/bundles/org.eclipse.swt/Eclipse SWT Custom Widgets/common/org/eclipse/swt/custom/StyledText.java
+++ b/bundles/org.eclipse.swt/Eclipse SWT Custom Widgets/common/org/eclipse/swt/custom/StyledText.java
@@ -89,7 +89,7 @@ import org.eclipse.swt.widgets.*;
*/
public class StyledText extends Canvas {
static final char TAB = '\t';
- static final String PlatformLineDelimiter = System.getProperty("line.separator");
+ static final String PlatformLineDelimiter = System.lineSeparator();
static final int BIDI_CARET_WIDTH = 3;
static final int DEFAULT_WIDTH = 64;
static final int DEFAULT_HEIGHT = 64;
diff --git a/bundles/org.eclipse.swt/Eclipse SWT Custom Widgets/common/org/eclipse/swt/custom/StyledTextContent.java b/bundles/org.eclipse.swt/Eclipse SWT Custom Widgets/common/org/eclipse/swt/custom/StyledTextContent.java
index 72a12b0ac2..cd3330cf3f 100644
--- a/bundles/org.eclipse.swt/Eclipse SWT Custom Widgets/common/org/eclipse/swt/custom/StyledTextContent.java
+++ b/bundles/org.eclipse.swt/Eclipse SWT Custom Widgets/common/org/eclipse/swt/custom/StyledTextContent.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2000, 2019 IBM Corporation and others.
+ * Copyright (c) 2000, 2020 IBM Corporation and others.
*
* This program and the accompanying materials
* are made available under the terms of the Eclipse Public License 2.0
@@ -119,7 +119,7 @@ public int getLineCount();
* Return the line delimiter that should be used by the StyledText
* widget when inserting new lines. New lines entered using key strokes
* and paste operations use this line delimiter.
- * Implementors may use System.getProperty("line.separator") to return
+ * Implementors may use System.lineSeparator() to return
* the platform line delimiter.
* <p>
*
diff --git a/bundles/org.eclipse.swt/Eclipse SWT PI/common/org/eclipse/swt/internal/Library.java b/bundles/org.eclipse.swt/Eclipse SWT PI/common/org/eclipse/swt/internal/Library.java
index 8d8deb5d20..5885c931d2 100644
--- a/bundles/org.eclipse.swt/Eclipse SWT PI/common/org/eclipse/swt/internal/Library.java
+++ b/bundles/org.eclipse.swt/Eclipse SWT PI/common/org/eclipse/swt/internal/Library.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2000, 2019 IBM Corporation and others.
+ * Copyright (c) 2000, 2020 IBM Corporation and others.
*
* This program and the accompanying materials
* are made available under the terms of the Eclipse Public License 2.0
@@ -58,7 +58,7 @@ public class Library {
static final String SWT_LIB_DIR;
static {
- DELIMITER = System.getProperty("line.separator"); //$NON-NLS-1$
+ DELIMITER = System.lineSeparator(); //$NON-NLS-1$
SEPARATOR = File.separator;
USER_HOME = System.getProperty ("user.home");
SWT_LIB_DIR = ".swt" + SEPARATOR + "lib" + SEPARATOR + os() + SEPARATOR + arch(); //$NON-NLS-1$ $NON-NLS-2$
diff --git a/examples/org.eclipse.swt.examples/src/org/eclipse/swt/examples/texteditor/text.txt b/examples/org.eclipse.swt.examples/src/org/eclipse/swt/examples/texteditor/text.txt
index cc317cf6e1..0f871d800f 100644
--- a/examples/org.eclipse.swt.examples/src/org/eclipse/swt/examples/texteditor/text.txt
+++ b/examples/org.eclipse.swt.examples/src/org/eclipse/swt/examples/texteditor/text.txt
@@ -82,7 +82,7 @@ import org.eclipse.swt.widgets.*;
*/
public class StyledText extends Canvas {
static final char TAB = '\t';
- static final String PlatformLineDelimiter = System.getProperty("line.separator");
+ static final String PlatformLineDelimiter = System.lineSeparator();
static final int BIDI_CARET_WIDTH = 3;
static final int DEFAULT_WIDTH = 64;
static final int DEFAULT_HEIGHT = 64;
diff --git a/tests/org.eclipse.swt.tests.gtk/ManualTests/org/eclipse/swt/tests/gtk/snippets/Bug221240_AWTJVMCrash.java b/tests/org.eclipse.swt.tests.gtk/ManualTests/org/eclipse/swt/tests/gtk/snippets/Bug221240_AWTJVMCrash.java
index 0a5ef7ce73..286a03fc90 100644
--- a/tests/org.eclipse.swt.tests.gtk/ManualTests/org/eclipse/swt/tests/gtk/snippets/Bug221240_AWTJVMCrash.java
+++ b/tests/org.eclipse.swt.tests.gtk/ManualTests/org/eclipse/swt/tests/gtk/snippets/Bug221240_AWTJVMCrash.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2018 Red Hat and others. All rights reserved.
+ * Copyright (c) 2018, 2020 Red Hat and others. All rights reserved.
* The contents of this file are made available under the terms
* of the GNU Lesser General Public License (LGPL) Version 2.1 that
* accompanies this distribution (lgpl-v21.txt). The LGPL is also
@@ -43,7 +43,7 @@ public class Bug221240_AWTJVMCrash extends JFrame {
private static final long serialVersionUID = -248424300520098295L;
-protected static final String LS = System.getProperty("line.separator");
+protected static final String LS = System.lineSeparator();
public Bug221240_AWTJVMCrash() {
setDefaultCloseOperation(EXIT_ON_CLOSE);
diff --git a/tests/org.eclipse.swt.tests/JUnit Tests/org/eclipse/swt/tests/junit/Test_org_eclipse_swt_custom_StyledText.java b/tests/org.eclipse.swt.tests/JUnit Tests/org/eclipse/swt/tests/junit/Test_org_eclipse_swt_custom_StyledText.java
index 1e043912a6..286617bfa1 100644
--- a/tests/org.eclipse.swt.tests/JUnit Tests/org/eclipse/swt/tests/junit/Test_org_eclipse_swt_custom_StyledText.java
+++ b/tests/org.eclipse.swt.tests/JUnit Tests/org/eclipse/swt/tests/junit/Test_org_eclipse_swt_custom_StyledText.java
@@ -95,7 +95,7 @@ final static RGB GREEN = new RGB(0,255,0);
final static RGB YELLOW = new RGB(255,255,0);
final static RGB CYAN = new RGB(0,255,255);
final static RGB PURPLE = new RGB(255,0,255);
-final static String PLATFORM_LINE_DELIMITER = System.getProperty("line.separator");
+final static String PLATFORM_LINE_DELIMITER = System.lineSeparator();
Map<RGB, Color> colors = new HashMap<>();
private boolean listenerCalled;
private boolean listener2Called;
@@ -4968,7 +4968,7 @@ public void test_isTextSelected() {
// Set block selection
StringBuilder buffer = new StringBuilder();
for (int i = 0; i < 500; i++) {
- buffer.append("Sample Test Selection" + System.getProperty("line.separator"));
+ buffer.append("Sample Test Selection" + System.lineSeparator());
}
text.setText(buffer.toString());
text.setSize(100, 10000);
@@ -4977,7 +4977,7 @@ public void test_isTextSelected() {
assertTrue(text.isTextSelected());
// Set block selection on new line
- text.setText(System.getProperty("line.separator"));
+ text.setText(System.lineSeparator());
text.setSize(100, 100);
text.setBlockSelection(true);
text.setBlockSelectionBounds(0, 0, 100, 100);
@@ -5130,13 +5130,13 @@ public void test_isTextSelectedInBlockSelection() {
Point lowerRight = text.getLocationAtOffset(blockSelectionTestTextOneLine().length() * 2 + 6);
text.setBlockSelectionBounds(0, 0, lowerRight.x, lowerRight.y + 1);
assertTrue(text.isTextSelected());
- assertEquals("Sample" + System.getProperty("line.separator") + "Sample" + System.getProperty("line.separator")
+ assertEquals("Sample" + System.lineSeparator() + "Sample" + System.lineSeparator()
+ "Sample", text.getSelectionText());
}
@Test
public void test_isTextSelectedInBlockSelectionForLingleEmptyLine() {
- text.setText(System.getProperty("line.separator"));
+ text.setText(System.lineSeparator());
text.setSize(100, 100);
text.setBlockSelection(true);
text.setBlockSelectionBounds(0, 0, 100, 100);
@@ -5145,7 +5145,7 @@ public void test_isTextSelectedInBlockSelectionForLingleEmptyLine() {
@Test
public void test_selectionIsClearedOnCaretMoveWhenInBlockSelection() {
- text.setText("Test" + System.getProperty("line.separator"));
+ text.setText("Test" + System.lineSeparator());
text.setSize(100, 100);
text.setBlockSelection(true);
text.setBlockSelectionBounds(0, 0, 100, 100);
@@ -5168,7 +5168,7 @@ public void test_setBlockSelectionBounds_updatesNormalSelectionIfNotInBlockMode(
@Test
public void test_selectionIsMaintainedOnDisableOfBlockSelection() {
- text.setText("Test" + System.getProperty("line.separator"));
+ text.setText("Test" + System.lineSeparator());
text.setSize(100, 100);
text.setBlockSelection(true);
text.setBlockSelectionBounds(0, 0, 100, 100);
@@ -5180,12 +5180,12 @@ public void test_selectionIsMaintainedOnDisableOfBlockSelection() {
@Test
public void test_selectAllInBlockSelectionMode() {
- text.setText("Test" + System.getProperty("line.separator"));
+ text.setText("Test" + System.lineSeparator());
text.setSize(100, 100);
text.setBlockSelection(true);
text.selectAll();
assertTrue(text.isTextSelected());
- assertEquals("Test" + System.getProperty("line.separator"), text.getSelectionText());
+ assertEquals("Test" + System.lineSeparator(), text.getSelectionText());
}
@Test
@@ -5199,10 +5199,10 @@ public void test_cutTextInBlockSelection() {
assertTrue(text.getText(),
text.getText()
- .startsWith(" Test Selection" + System.getProperty("line.separator")
- + " Test Selection" + System.getProperty("line.separator")
- + " Test Selection" + System.getProperty("line.separator")
- + "Sample Test Selection" + System.getProperty("line.separator")));
+ .startsWith(" Test Selection" + System.lineSeparator()
+ + " Test Selection" + System.lineSeparator()
+ + " Test Selection" + System.lineSeparator()
+ + "Sample Test Selection" + System.lineSeparator()));
}
@Test
@@ -5245,8 +5245,8 @@ public void test_cutAndPasteInBlockSelection() {
@Test
public void test_trippleClickInBlockSelectionSelectsLine() {
- text.setText(" Sample Test Selection " + System.getProperty("line.separator") + " Sample Test Selection "
- + System.getProperty("line.separator"));
+ text.setText(" Sample Test Selection " + System.lineSeparator() + " Sample Test Selection "
+ + System.lineSeparator());
text.setSize(1000, 1000);
text.setBlockSelection(true);
Point lowerRight = text.getLocationAtOffset(3);
@@ -5268,8 +5268,8 @@ public void test_getSelectionRangesInBlockSelection() {
text.setBlockSelection(true);
Point lowerRight = text.getLocationAtOffset(blockSelectionTestTextOneLine().length() * 2 + 6);
text.setBlockSelectionBounds(0, 0, lowerRight.x, lowerRight.y + 1);
- assertArrayEquals(new int[] { 0, 6, 21 + System.getProperty("line.separator").length(), 6,
- 42 + System.getProperty("line.separator").length() * 2, 6 }, text.getSelectionRanges());
+ assertArrayEquals(new int[] { 0, 6, 21 + System.lineSeparator().length(), 6,
+ 42 + System.lineSeparator().length() * 2, 6 }, text.getSelectionRanges());
}
@Test
@@ -5280,7 +5280,7 @@ public void test_getSelectionCountInBlockSelection() {
Point lowerRight = text
.getLocationAtOffset(blockSelectionTestTextOneLine().length() * 2 + 6);
text.setBlockSelectionBounds(0, 0, lowerRight.x, lowerRight.y + 1);
- assertEquals(18 + System.getProperty("line.separator").length() * 2, text.getSelectionCount());
+ assertEquals(18 + System.lineSeparator().length() * 2, text.getSelectionCount());
}
@Test
@@ -5301,12 +5301,12 @@ public void test_insertInBlockSelection() {
text.setBlockSelection(true);
text.setSelection(6, 6 + blockSelectionTestTextOneLine().length());
- text.insert("Foo" + System.getProperty("line.separator") + "Foo" + System.getProperty("line.separator"));
+ text.insert("Foo" + System.lineSeparator() + "Foo" + System.lineSeparator());
assertTrue(text.getText(), text.getText()
- .startsWith("SampleFoo Test Selection" + System.getProperty("line.separator")
- + "SampleFoo Test Selection" + System.getProperty("line.separator") + "Sample Test Selection"
- + System.getProperty("line.separator")));
+ .startsWith("SampleFoo Test Selection" + System.lineSeparator()
+ + "SampleFoo Test Selection" + System.lineSeparator() + "Sample Test Selection"
+ + System.lineSeparator()));
}
@Test
@@ -5525,7 +5525,7 @@ private String blockSelectionTestText() {
}
private String blockSelectionTestTextOneLine() {
- return "Sample Test Selection" + System.getProperty("line.separator");
+ return "Sample Test Selection" + System.lineSeparator();
}
/**

Back to the top