You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@royale.apache.org by jo...@apache.org on 2022/07/28 21:59:46 UTC

[royale-compiler] branch develop updated (6085daac2 -> 5a0042801)

This is an automated email from the ASF dual-hosted git repository.

joshtynjala pushed a change to branch develop
in repository https://gitbox.apache.org/repos/asf/royale-compiler.git


    from 6085daac2 royaleunit-ant-tasks: <royaleunit player=""/> attribute may be set to chromium, webkit, or firefox to test JS using Playwright
     new d76804aae formatter: fix detection of opening mx|fx:Script element when document contains CRLF newlines
     new 5a0042801 formatter: preserve one new line at most at the end of the file

The 2 revisions listed above as "new" are entirely new to this
repository and will be described in separate emails.  The revisions
listed as "add" were already present in the repository and have only
been added to this reference.


Summary of changes:
 .../main/java/org/apache/royale/formatter/FORMATTER.java | 16 ++++++++++------
 1 file changed, 10 insertions(+), 6 deletions(-)


[royale-compiler] 02/02: formatter: preserve one new line at most at the end of the file

Posted by jo...@apache.org.
This is an automated email from the ASF dual-hosted git repository.

joshtynjala pushed a commit to branch develop
in repository https://gitbox.apache.org/repos/asf/royale-compiler.git

commit 5a0042801626de146f2a3a8ff7a3816cc5376cce
Author: Josh Tynjala <jo...@apache.org>
AuthorDate: Thu Jul 28 14:09:54 2022 -0700

    formatter: preserve one new line at most at the end of the file
    
    Other new lines are subject to maxPreserveNewLines
---
 .../main/java/org/apache/royale/formatter/FORMATTER.java   | 14 +++++++++-----
 1 file changed, 9 insertions(+), 5 deletions(-)

diff --git a/formatter/src/main/java/org/apache/royale/formatter/FORMATTER.java b/formatter/src/main/java/org/apache/royale/formatter/FORMATTER.java
index f73dc03bb..a0f71dcb2 100644
--- a/formatter/src/main/java/org/apache/royale/formatter/FORMATTER.java
+++ b/formatter/src/main/java/org/apache/royale/formatter/FORMATTER.java
@@ -694,8 +694,9 @@ public class FORMATTER {
 					builder.append(token.getText());
 				} else {
 					if (i == (tokens.size() - 1)) {
-						// if the last token is whitespace, include new lines
-						numRequiredNewLines = Math.max(0, countNewLinesInExtra(token));
+						// if the last token is whitespace, include at most one
+						// new line, but strip the rest
+						numRequiredNewLines = Math.min(1, Math.max(0, countNewLinesInExtra(token)));
 						appendNewLines(builder, numRequiredNewLines);
 						break;
 					}
@@ -1853,8 +1854,9 @@ public class FORMATTER {
 					builder.append(token.getText());
 				} else {
 					if (i == (tokens.size() - 1)) {
-						// if the last token is whitespace, include new lines
-						numRequiredNewLines = Math.max(0, countNewLinesInExtra(token));
+						// if the last token is whitespace, include at most one
+						// new line, but strip the rest
+						numRequiredNewLines = Math.min(1, Math.max(0, countNewLinesInExtra(token)));
 						appendNewLines(builder, numRequiredNewLines);
 						break;
 					}
@@ -1878,7 +1880,9 @@ public class FORMATTER {
 						builder.append(token.getText());
 					}
 					if (i == (tokens.size() - 1)) {
-						// if the last token is whitespace, append new lines
+						// if the last token is whitespace, include at most one
+						// new line, but strip the rest
+						numRequiredNewLines = Math.min(1, numRequiredNewLines);
 						appendNewLines(builder, numRequiredNewLines);
 					}
 				}


[royale-compiler] 01/02: formatter: fix detection of opening mx|fx:Script element when document contains CRLF newlines

Posted by jo...@apache.org.
This is an automated email from the ASF dual-hosted git repository.

joshtynjala pushed a commit to branch develop
in repository https://gitbox.apache.org/repos/asf/royale-compiler.git

commit d76804aae02115dbb76c09eb3b39ab183281da5f
Author: Josh Tynjala <jo...@apache.org>
AuthorDate: Thu Jul 28 13:17:29 2022 -0700

    formatter: fix detection of opening mx|fx:Script element when document contains CRLF newlines
---
 formatter/src/main/java/org/apache/royale/formatter/FORMATTER.java | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/formatter/src/main/java/org/apache/royale/formatter/FORMATTER.java b/formatter/src/main/java/org/apache/royale/formatter/FORMATTER.java
index a512c0987..f73dc03bb 100644
--- a/formatter/src/main/java/org/apache/royale/formatter/FORMATTER.java
+++ b/formatter/src/main/java/org/apache/royale/formatter/FORMATTER.java
@@ -408,7 +408,7 @@ public class FORMATTER {
 		}
 		StringBuilder builder = new StringBuilder();
 		Pattern scriptPattern = Pattern.compile(
-				"^<((?:mx|fx):(\\w+))>\\s*(<!\\[CDATA\\[)?((?:.|\\n)*?)(?:\\]\\]>)?\\s*<\\/(?:mx|fx):(?:\\w+)>$");
+				"^<((?:mx|fx):(\\w+))>\\s*(<!\\[CDATA\\[)?((?:.|(?:\\r?\\n))*?)(?:\\]\\]>)?\\s*<\\/(?:mx|fx):(?:\\w+)>$");
 		Matcher scriptMatcher = scriptPattern.matcher(text);
 		if (!scriptMatcher.matches()) {
 			return text;