Download
Getting Started
Members
Projects
Community
Marketplace
Events
Planet Eclipse
Newsletter
Videos
Participate
Report a Bug
Forums
Mailing Lists
Wiki
IRC
How to Contribute
Working Groups
Automotive
Internet of Things
LocationTech
Long-Term Support
PolarSys
Science
OpenMDM
More
Community
Marketplace
Events
Planet Eclipse
Newsletter
Videos
Participate
Report a Bug
Forums
Mailing Lists
Wiki
IRC
How to Contribute
Working Groups
Automotive
Internet of Things
LocationTech
Long-Term Support
PolarSys
Science
OpenMDM
Toggle navigation
Bugzilla – Attachment 260459 Details for
Bug 490118
DOT: use platform specific line separators
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Requests
|
Help
|
Log In
[x]
|
Terms of Use
|
Copyright Agent
Some Eclipse Foundation services are deprecated, or will be soon. Please ensure you've read
this important communication.
[patch]
Implementation improvement to use platform-specific line separators
DOT-use-platform-specific-line-separators.patch (text/plain), 5.56 KB, created by
Tamas Miklossy
on 2016-03-21 16:27:42 EDT
(
hide
)
Description:
Implementation improvement to use platform-specific line separators
Filename:
MIME Type:
Creator:
Tamas Miklossy
Created:
2016-03-21 16:27:42 EDT
Size:
5.56 KB
patch
obsolete
>diff --git a/org.eclipse.gef4.dot.tests/src/org/eclipse/gef4/dot/tests/DotExportTests.java b/org.eclipse.gef4.dot.tests/src/org/eclipse/gef4/dot/tests/DotExportTests.java >index 6fdcc98..326e95c 100644 >--- a/org.eclipse.gef4.dot.tests/src/org/eclipse/gef4/dot/tests/DotExportTests.java >+++ b/org.eclipse.gef4.dot.tests/src/org/eclipse/gef4/dot/tests/DotExportTests.java >@@ -1,12 +1,14 @@ > /******************************************************************************* >- * Copyright (c) 2009, 2015 Fabian Steeg and others. >+ * Copyright (c) 2009, 2016 itemis AG and others. >+ * > * All rights reserved. This program and the accompanying materials > * are made available under the terms of the Eclipse Public License v1.0 > * which accompanies this distribution, and is available at > * http://www.eclipse.org/legal/epl-v10.html > * > * Contributors: >- * Fabian Steeg - initial API and implementation (see bug #277380) >+ * Fabian Steeg - initial API and implementation (see bug #277380) >+ * Tamas Miklossy - use platform specific line separators > *******************************************************************************/ > package org.eclipse.gef4.dot.tests; > >@@ -15,7 +17,6 @@ > import static org.junit.Assert.assertTrue; > > import java.io.File; >-import java.io.FileNotFoundException; > import java.util.Scanner; > > import org.eclipse.gef4.dot.internal.DotAttributes; >@@ -63,7 +64,7 @@ > "Generated file " + new File(OUTPUT, fileName).getName() //$NON-NLS-1$ > + " must exist!", > new File(OUTPUT, fileName).exists()); >- String dotRead = read(new File(OUTPUT, fileName)); >+ String dotRead = DotFileUtils.read(new File(OUTPUT, fileName)); > Assert.assertEquals("File output and String output should be equal;", //$NON-NLS-1$ > dot, dotRead); > } >@@ -121,20 +122,4 @@ > } > scanner.close(); > } >- >- private String read(final File file) { >- try { >- Scanner scanner = new Scanner(file); >- StringBuilder builder = new StringBuilder(); >- while (scanner.hasNextLine()) { >- builder.append(scanner.nextLine() + "\n"); //$NON-NLS-1$ >- } >- scanner.close(); >- return builder.toString(); >- } catch (FileNotFoundException e) { >- e.printStackTrace(); >- } >- return null; >- } >- > } >diff --git a/org.eclipse.gef4.dot.tests/src/org/eclipse/gef4/dot/tests/DotParserTests.java b/org.eclipse.gef4.dot.tests/src/org/eclipse/gef4/dot/tests/DotParserTests.java >index edeadd2..4aba6a4 100644 >--- a/org.eclipse.gef4.dot.tests/src/org/eclipse/gef4/dot/tests/DotParserTests.java >+++ b/org.eclipse.gef4.dot.tests/src/org/eclipse/gef4/dot/tests/DotParserTests.java >@@ -16,9 +16,8 @@ > import static org.junit.Assert.fail; > > import java.io.File; >-import java.io.FileNotFoundException; >-import java.util.Scanner; > >+import org.eclipse.gef4.dot.internal.DotFileUtils; > import org.eclipse.gef4.dot.internal.parser.DotInjectorProvider; > import org.eclipse.gef4.dot.internal.parser.dot.DotAst; > import org.eclipse.xtext.junit4.InjectWith; >@@ -55,22 +54,11 @@ > testFile("arrowshapes_deprecated.dot"); > } > >- private void testFile(String path) { >- String newline = System.getProperty("line.separator"); >- String content = ""; >+ private void testFile(String fileName) { >+ String fileContents = DotFileUtils >+ .read(new File(DotTestUtils.RESOURCES_TESTS + fileName)); > try { >- Scanner scanner = new Scanner( >- new File(DotTestUtils.RESOURCES_TESTS + path)); >- while (scanner.hasNextLine()) { >- content += scanner.nextLine() + newline; >- } >- scanner.close(); >- } catch (FileNotFoundException e) { >- e.printStackTrace(); >- } >- >- try { >- DotAst dotAst = parserHelper.parse(content); >+ DotAst dotAst = parserHelper.parse(fileContents); > assertNotNull(dotAst); > validationTestHelper.assertNoErrors(dotAst); > } catch (Exception e) { >@@ -78,5 +66,4 @@ > fail(); > } > } >- > } >diff --git a/org.eclipse.gef4.dot/src/org/eclipse/gef4/dot/internal/DotFileUtils.java b/org.eclipse.gef4.dot/src/org/eclipse/gef4/dot/internal/DotFileUtils.java >index 19365e6..e297ba7 100644 >--- a/org.eclipse.gef4.dot/src/org/eclipse/gef4/dot/internal/DotFileUtils.java >+++ b/org.eclipse.gef4.dot/src/org/eclipse/gef4/dot/internal/DotFileUtils.java >@@ -1,10 +1,14 @@ > /******************************************************************************* >- * Copyright (c) 2009, 2015 Fabian Steeg. All rights reserved. This program and >- * the accompanying materials are made available under the terms of the Eclipse >- * Public License v1.0 which accompanies this distribution, and is available at >+ * Copyright (c) 2009, 2016 itemis AG and others. >+ * >+ * All rights reserved. This program and the accompanying materials >+ * are made available under the terms of the Eclipse Public License v1.0 >+ * which accompanies this distribution, and is available at > * http://www.eclipse.org/legal/epl-v10.html >- * <p/> >- * Contributors: Fabian Steeg - initial API and implementation; see bug 277380 >+ * >+ * Contributors: >+ * Fabian Steeg - initial API and implementation; see bug 277380 >+ * Tamas Miklossy - use platform specific line separators > *******************************************************************************/ > > package org.eclipse.gef4.dot.internal; >@@ -94,11 +98,12 @@ > * @return The string containing the contents of the given file > */ > public static String read(final File file) { >+ String lineSeparator = System.lineSeparator(); > StringBuilder builder = new StringBuilder(); > try { > Scanner s = new Scanner(file); > while (s.hasNextLine()) { >- builder.append(s.nextLine()).append("\n"); //$NON-NLS-1$ >+ builder.append(s.nextLine()).append(lineSeparator); > } > s.close(); > } catch (FileNotFoundException e) {
You cannot view the attachment while viewing its details because your browser does not support IFRAMEs.
View the attachment on a separate page
.
View Attachment As Diff
View Attachment As Raw
Flags:
nyssen
:
iplog+
Actions:
View
|
Diff
Attachments on
bug 490118
: 260459