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 2021/10/21 21:33:19 UTC

[royale-compiler] branch develop updated (1f6fc36 -> f24ff86)

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 1f6fc36  formatter: preserve minimum whitespace at end of blank lines inside asdoc <listing> tags
     new e18e4e7  formatter: ignore compiler problems that aren't errors
     new cc78bac  formatter: remove debug console output
     new 0755d8f  formatter: MXML formatting tweeaks and tests
     new f24ff86  formatter: refactor MXML script formatting and format MXML metadata

The 4 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:
 .../org/apache/royale/formatter/FORMATTER.java     | 133 +++++++++++++-------
 .../royale/formatter/BaseFormatterTests.java       |  11 +-
 .../apache/royale/formatter/TestMXMLMetadata.java  | 137 +++++++++++++++++++++
 .../apache/royale/formatter/TestMXMLScript.java    |  89 +++++++++++++
 .../royale/formatter/TestThrowStatement.java       |   6 +-
 5 files changed, 327 insertions(+), 49 deletions(-)
 create mode 100644 formatter/src/test/java/org/apache/royale/formatter/TestMXMLMetadata.java
 create mode 100644 formatter/src/test/java/org/apache/royale/formatter/TestMXMLScript.java

[royale-compiler] 03/04: formatter: MXML formatting tweeaks and tests

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 0755d8fa485b810f05fbf4a9d66be567e9f70137
Author: Josh Tynjala <jo...@apache.org>
AuthorDate: Thu Oct 21 13:39:05 2021 -0700

    formatter: MXML formatting tweeaks and tests
---
 .../org/apache/royale/formatter/FORMATTER.java     | 18 +++--
 .../apache/royale/formatter/TestMXMLScript.java    | 89 ++++++++++++++++++++++
 2 files changed, 100 insertions(+), 7 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 2c33869..c4506cf 100644
--- a/formatter/src/main/java/org/apache/royale/formatter/FORMATTER.java
+++ b/formatter/src/main/java/org/apache/royale/formatter/FORMATTER.java
@@ -401,12 +401,14 @@ public class FORMATTER {
 			if (!ignoreProblems && hasErrors(problems)) {
 				return text;
 			}
-			String[] formattedLines = formattedScriptText.split("\n");
-			String lineIndent = indent + indent + indent;
-			for (int i = 0; i < formattedLines.length; i++) {
-				formattedLines[i] = lineIndent + formattedLines[i];
+			if (formattedScriptText.length() > 0) {
+				String[] formattedLines = formattedScriptText.split("\n");
+				String lineIndent = indent + indent + indent;
+				for (int i = 0; i < formattedLines.length; i++) {
+					formattedLines[i] = lineIndent + formattedLines[i];
+				}
+				formattedScriptText = String.join("\n", formattedLines);
 			}
-			formattedScriptText = String.join("\n", formattedLines);
 			builder.append(text.substring(lastIndex, start));
 			builder.append(indent);
 			builder.append("<");
@@ -415,8 +417,10 @@ public class FORMATTER {
 			builder.append(indent);
 			builder.append(indent);
 			builder.append("<![CDATA[\n");
-			builder.append(formattedScriptText);
-			builder.append("\n");
+			if (formattedScriptText.length() > 0) {
+				builder.append(formattedScriptText);
+				builder.append("\n");
+			}
 			builder.append(indent);
 			builder.append(indent);
 			builder.append("]]>\n");
diff --git a/formatter/src/test/java/org/apache/royale/formatter/TestMXMLScript.java b/formatter/src/test/java/org/apache/royale/formatter/TestMXMLScript.java
new file mode 100644
index 0000000..c485e65
--- /dev/null
+++ b/formatter/src/test/java/org/apache/royale/formatter/TestMXMLScript.java
@@ -0,0 +1,89 @@
+package org.apache.royale.formatter;
+
+import static org.junit.Assert.assertEquals;
+
+import org.junit.Test;
+
+public class TestMXMLScript extends BaseFormatterTests {
+	@Test
+	public void testEmptyScriptNoCdata() {
+		FORMATTER formatter = new FORMATTER();
+		formatter.insertSpaces = false;
+		String result = formatter.formatMXMLText(
+		// @formatter:off
+			"<s:Application>\n" +
+			"<fx:Script>\n" +
+			"</fx:Script>\n" +
+			"</s:Application>",
+			// @formatter:on
+			problems
+		);
+		assertEquals(
+		// @formatter:off
+				"<s:Application>\n" +
+				"\t<fx:Script>\n" +
+				"\t\t<![CDATA[\n" +
+				"\t\t]]>\n" +
+				"\t</fx:Script>\n" +
+				"</s:Application>",
+				// @formatter:on
+				result);
+	}
+
+	@Test
+	public void testEmptyScriptWithCdata() {
+		FORMATTER formatter = new FORMATTER();
+		formatter.insertSpaces = false;
+		String result = formatter.formatMXMLText(
+		// @formatter:off
+			"<s:Application>\n" +
+			"<fx:Script>\n" +
+			"<![CDATA[\n" +
+			"]]>\n" +
+			"</fx:Script>\n" +
+			"</s:Application>",
+			// @formatter:on
+			problems
+		);
+		assertEquals(
+		// @formatter:off
+				"<s:Application>\n" +
+				"\t<fx:Script>\n" +
+				"\t\t<![CDATA[\n" +
+				"\t\t]]>\n" +
+				"\t</fx:Script>\n" +
+				"</s:Application>",
+				// @formatter:on
+				result);
+	}
+
+	@Test
+	public void testScriptWithActionScript() {
+		FORMATTER formatter = new FORMATTER();
+		formatter.insertSpaces = false;
+		String result = formatter.formatMXMLText(
+		// @formatter:off
+			"<s:Application>\n" +
+			"<fx:Script>\n" +
+			"<![CDATA[\n" +
+			"public var a: Number=123.4;\n" +
+			"]]>\n" +
+			"</fx:Script>\n" +
+			"</s:Application>",
+			// @formatter:on
+			problems
+		);
+		assertEquals(
+		// @formatter:off
+				"<s:Application>\n" +
+				"\t<fx:Script>\n" +
+				"\t\t<![CDATA[\n" +
+				"\t\t\tpublic var a:Number = 123.4;\n" +
+				"\t\t]]>\n" +
+				"\t</fx:Script>\n" +
+				"</s:Application>",
+				// @formatter:on
+				result);
+	}
+	
+}

[royale-compiler] 01/04: formatter: ignore compiler problems that aren't errors

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 e18e4e7eff876a8ff9349d4c60ec837b4cfb1777
Author: Josh Tynjala <jo...@apache.org>
AuthorDate: Thu Oct 21 13:23:59 2021 -0700

    formatter: ignore compiler problems that aren't errors
---
 .../org/apache/royale/formatter/FORMATTER.java     | 48 ++++++++++++++--------
 .../royale/formatter/TestThrowStatement.java       |  6 +--
 2 files changed, 34 insertions(+), 20 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 9686eb0..8e632e1 100644
--- a/formatter/src/main/java/org/apache/royale/formatter/FORMATTER.java
+++ b/formatter/src/main/java/org/apache/royale/formatter/FORMATTER.java
@@ -33,6 +33,7 @@ import java.util.regex.Matcher;
 import java.util.regex.Pattern;
 
 import org.apache.commons.io.FileUtils;
+import org.apache.royale.compiler.clients.problems.CompilerProblemCategorizer;
 import org.apache.royale.compiler.clients.problems.ProblemFormatter;
 import org.apache.royale.compiler.clients.problems.ProblemPrinter;
 import org.apache.royale.compiler.clients.problems.ProblemQuery;
@@ -51,6 +52,7 @@ import org.apache.royale.compiler.internal.parsing.as.StreamingASTokenizer;
 import org.apache.royale.compiler.internal.tree.as.FileNode;
 import org.apache.royale.compiler.internal.workspaces.Workspace;
 import org.apache.royale.compiler.parsing.IASToken;
+import org.apache.royale.compiler.problems.CompilerProblemSeverity;
 import org.apache.royale.compiler.problems.ConfigurationProblem;
 import org.apache.royale.compiler.problems.ICompilerProblem;
 import org.apache.royale.compiler.problems.UnexpectedExceptionProblem;
@@ -396,7 +398,7 @@ public class FORMATTER {
 			String scriptTagText = scriptMatcher.group(1);
 			String scriptText = scriptMatcher.group(2);
 			String formattedScriptText = formatAS3TextInternal(filePath, scriptText, problems);
-			if (problems.size() > 0) {
+			if (!ignoreProblems && hasErrors(problems)) {
 				return text;
 			}
 			String[] formattedLines = formattedScriptText.split("\n");
@@ -431,6 +433,10 @@ public class FORMATTER {
 	}
 
 	private String formatAS3TextInternal(String filePath, String text, Collection<ICompilerProblem> problems) {
+		if(problems == null) {
+			problems = new ArrayList<ICompilerProblem>();
+		}
+
 		StringReader textReader = new StringReader(text);
 		StreamingASTokenizer tokenizer = null;
 		ASToken[] streamingTokens = null;
@@ -448,10 +454,11 @@ public class FORMATTER {
 			}
 		}
 
-		if (!ignoreProblems && tokenizer.hasTokenizationProblems()) {
-			if (problems != null) {
-				problems.addAll(tokenizer.getTokenizationProblems());
-			}
+		if (tokenizer.hasTokenizationProblems()) {
+			problems.addAll(tokenizer.getTokenizationProblems());
+		}
+
+		if(!ignoreProblems && hasErrors(problems)) {
 			return text;
 		}
 
@@ -477,23 +484,19 @@ public class FORMATTER {
 			parser.file(node);
 		} catch (Exception e) {
 			parser = null;
-			if (problems != null) {
-				problems.add(new UnexpectedExceptionProblem(e));
-			}
+			problems.add(new UnexpectedExceptionProblem(e));
 			return text;
 		}
 
-		if (!ignoreProblems && tokenizer.hasTokenizationProblems()) {
-			if (problems != null) {
-				problems.addAll(tokenizer.getTokenizationProblems());
-			}
-			return text;
+		if (tokenizer.hasTokenizationProblems()) {
+			problems.addAll(tokenizer.getTokenizationProblems());
 		}
 
-		if (!ignoreProblems && parser.getSyntaxProblems().size() > 0) {
-			if (problems != null) {
-				problems.addAll(parser.getSyntaxProblems());
-			}
+		if (parser.getSyntaxProblems().size() > 0) {
+			problems.addAll(parser.getSyntaxProblems());
+		}
+
+		if(!ignoreProblems && hasErrors(problems)) {
 			return text;
 		}
 
@@ -1550,6 +1553,17 @@ public class FORMATTER {
 		}
 	}
 
+	private boolean hasErrors(Collection<ICompilerProblem> problems) {
+		CompilerProblemCategorizer categorizer = new CompilerProblemCategorizer(null);
+		for(ICompilerProblem problem : problems) {
+			CompilerProblemSeverity severity = categorizer.getProblemSeverity(problem);
+			if(CompilerProblemSeverity.ERROR.equals(severity)) {
+				return true;
+			}
+		}
+		return false;
+	}
+
 	private static class BlockStackItem {
 		public BlockStackItem(IASToken token) {
 			this.token = token;
diff --git a/formatter/src/test/java/org/apache/royale/formatter/TestThrowStatement.java b/formatter/src/test/java/org/apache/royale/formatter/TestThrowStatement.java
index 7c380a9..d6c21f1 100644
--- a/formatter/src/test/java/org/apache/royale/formatter/TestThrowStatement.java
+++ b/formatter/src/test/java/org/apache/royale/formatter/TestThrowStatement.java
@@ -36,7 +36,7 @@ public class TestThrowStatement extends BaseFormatterTests {
 		// @formatter:off
 			"throw;",
 			// @formatter:on
-			problems
+			null
 		);
 		assertEquals(
 		// @formatter:off
@@ -57,7 +57,7 @@ public class TestThrowStatement extends BaseFormatterTests {
 		// @formatter:off
 			"throw",
 			// @formatter:on
-			problems
+			null
 		);
 		assertEquals(
 		// @formatter:off
@@ -116,7 +116,7 @@ public class TestThrowStatement extends BaseFormatterTests {
 			"throw\n" +
 			"new Error();",
 			// @formatter:on
-			problems
+			null
 		);
 		assertEquals(
 		// @formatter:off

[royale-compiler] 04/04: formatter: refactor MXML script formatting and format MXML metadata

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 f24ff86b7b711278a313f1ba76e09fab9a90e4ed
Author: Josh Tynjala <jo...@apache.org>
AuthorDate: Thu Oct 21 14:14:49 2021 -0700

    formatter: refactor MXML script formatting and format MXML metadata
---
 .../org/apache/royale/formatter/FORMATTER.java     | 102 +++++++++------
 .../royale/formatter/BaseFormatterTests.java       |  11 +-
 .../apache/royale/formatter/TestMXMLMetadata.java  | 137 +++++++++++++++++++++
 3 files changed, 211 insertions(+), 39 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 c4506cf..a55af2f 100644
--- a/formatter/src/main/java/org/apache/royale/formatter/FORMATTER.java
+++ b/formatter/src/main/java/org/apache/royale/formatter/FORMATTER.java
@@ -175,6 +175,7 @@ public class FORMATTER {
 				exitCode = ExitCode.PRINT_HELP;
 			}
 		} catch (Exception e) {
+			problems.add(new UnexpectedExceptionProblem(e));
 			System.err.println(e.getMessage());
 			exitCode = ExitCode.FAILED_WITH_EXCEPTIONS;
 		} finally {
@@ -375,6 +376,36 @@ public class FORMATTER {
 	}
 
 	private String formatMXMLTextInternal(String filePath, String text, Collection<ICompilerProblem> problems) {
+		StringBuilder builder = new StringBuilder();
+		Pattern scriptPattern = Pattern.compile(
+				"[\t ]*<((?:mx|fx):(?:Script|Metadata))>\\s*(?:<!\\[CDATA\\[)?(?:.|\\n)*?(?:\\]\\]>)?\\s*<\\/(?:mx|fx):(?:Script|Metadata)>");
+		Matcher scriptMatcher = scriptPattern.matcher(text);
+		if (problems == null) {
+			// we need to know if there were problems because it means that we
+			// need to return the original, unformatted text
+			problems = new ArrayList<ICompilerProblem>();
+		}
+		int lastIndex = 0;
+		while (scriptMatcher.find()) {
+			int start = scriptMatcher.start();
+			int end = scriptMatcher.end();
+			String scriptText = scriptMatcher.group().trim();
+
+			builder.append(text.substring(lastIndex, start));
+			String formattedText = formatMXMLScriptElement(scriptText, problems);
+			if (!ignoreProblems && hasErrors(problems)) {
+				return text;
+			}
+			builder.append(formattedText);
+			lastIndex = end;
+		}
+		if (lastIndex < text.length()) {
+			builder.append(text.substring(lastIndex));
+		}
+		return builder.toString();
+	}
+
+	private String formatMXMLScriptElement(String text, Collection<ICompilerProblem> problems) {
 		String indent = "\t";
 		if (insertSpaces) {
 			indent = "";
@@ -382,57 +413,58 @@ public class FORMATTER {
 				indent += " ";
 			}
 		}
-		int lastIndex = 0;
 		StringBuilder builder = new StringBuilder();
 		Pattern scriptPattern = Pattern.compile(
-				"[\t ]*<((?:mx|fx):Script)>\\s*(?:<!\\[CDATA\\[)?((?:.|\\n)*?)(?:\\]\\]>)?\\s*<\\/(?:mx|fx):Script>");
+				"^<((?:mx|fx):(\\w+))>\\s*(<!\\[CDATA\\[)?((?:.|\\n)*?)(?:\\]\\]>)?\\s*<\\/(?:mx|fx):(?:\\w+)>$");
 		Matcher scriptMatcher = scriptPattern.matcher(text);
+		if (!scriptMatcher.matches()) {
+			return text;
+		}
 		if (problems == null) {
 			// we need to know if there were problems because it means that we
 			// need to return the original, unformatted text
 			problems = new ArrayList<ICompilerProblem>();
 		}
-		while (scriptMatcher.find()) {
-			int start = scriptMatcher.start();
-			int end = scriptMatcher.end();
-			String scriptTagText = scriptMatcher.group(1);
-			String scriptText = scriptMatcher.group(2);
-			String formattedScriptText = formatAS3TextInternal(filePath, scriptText, problems);
-			if (!ignoreProblems && hasErrors(problems)) {
-				return text;
-			}
-			if (formattedScriptText.length() > 0) {
-				String[] formattedLines = formattedScriptText.split("\n");
-				String lineIndent = indent + indent + indent;
-				for (int i = 0; i < formattedLines.length; i++) {
-					formattedLines[i] = lineIndent + formattedLines[i];
-				}
-				formattedScriptText = String.join("\n", formattedLines);
+		String scriptTagText = scriptMatcher.group(1);
+		String scriptTagName = scriptMatcher.group(2);
+		String cdataText = scriptMatcher.group(3);
+		String scriptText = scriptMatcher.group(4);
+		boolean requireCdata = cdataText != null || "Script".equals(scriptTagName);
+		String formattedScriptText = formatAS3TextInternal("script.as", scriptText, problems);
+		if (!ignoreProblems && hasErrors(problems)) {
+			return text;
+		}
+		if (formattedScriptText.length() > 0) {
+			String[] formattedLines = formattedScriptText.split("\n");
+			String lineIndent = requireCdata ? (indent + indent + indent) : (indent + indent);
+			for (int i = 0; i < formattedLines.length; i++) {
+				formattedLines[i] = lineIndent + formattedLines[i];
 			}
-			builder.append(text.substring(lastIndex, start));
-			builder.append(indent);
-			builder.append("<");
-			builder.append(scriptTagText);
-			builder.append(">\n");
+			formattedScriptText = String.join("\n", formattedLines);
+		}
+		builder.append(indent);
+		builder.append("<");
+		builder.append(scriptTagText);
+		builder.append(">\n");
+		if (requireCdata) {
 			builder.append(indent);
 			builder.append(indent);
 			builder.append("<![CDATA[\n");
-			if (formattedScriptText.length() > 0) {
-				builder.append(formattedScriptText);
-				builder.append("\n");
-			}
+		}
+		if (formattedScriptText.length() > 0) {
+			builder.append(formattedScriptText);
+			builder.append("\n");
+		}
+		if (requireCdata) {
 			builder.append(indent);
 			builder.append(indent);
 			builder.append("]]>\n");
-			builder.append(indent);
-			builder.append("</");
-			builder.append(scriptTagText);
-			builder.append(">");
-			lastIndex = end;
-		}
-		if (lastIndex < text.length()) {
-			builder.append(text.substring(lastIndex));
 		}
+		builder.append(indent);
+		builder.append("</");
+		builder.append(scriptTagText);
+		builder.append(">");
+
 		return builder.toString();
 	}
 
diff --git a/formatter/src/test/java/org/apache/royale/formatter/BaseFormatterTests.java b/formatter/src/test/java/org/apache/royale/formatter/BaseFormatterTests.java
index acc7792..db1cc7d 100644
--- a/formatter/src/test/java/org/apache/royale/formatter/BaseFormatterTests.java
+++ b/formatter/src/test/java/org/apache/royale/formatter/BaseFormatterTests.java
@@ -24,6 +24,8 @@ import static org.junit.Assert.fail;
 
 import java.util.ArrayList;
 
+import org.apache.royale.compiler.clients.problems.CompilerProblemCategorizer;
+import org.apache.royale.compiler.problems.CompilerProblemSeverity;
 import org.apache.royale.compiler.problems.ICompilerProblem;
 import org.junit.After;
 import org.junit.Before;
@@ -38,10 +40,11 @@ public class BaseFormatterTests {
 
 	@After
 	public void teardown() {
-		int numProblems = problems.size();
-		if (numProblems > 0) {
-			for (ICompilerProblem problem : problems) {
-				fail(problem.toString() + " (" + problem.getLine() +", " + problem.getColumn() + ")");
+		CompilerProblemCategorizer categorizer = new CompilerProblemCategorizer(null);
+		for (ICompilerProblem problem : problems) {
+			CompilerProblemSeverity severity = categorizer.getProblemSeverity(problem);
+			if(CompilerProblemSeverity.ERROR.equals(severity)) {
+				fail(problem.toString() + " (" + problem.getLine() + ", " + problem.getColumn() + ")");
 			}
 		}
 		problems = null;
diff --git a/formatter/src/test/java/org/apache/royale/formatter/TestMXMLMetadata.java b/formatter/src/test/java/org/apache/royale/formatter/TestMXMLMetadata.java
new file mode 100644
index 0000000..497f111
--- /dev/null
+++ b/formatter/src/test/java/org/apache/royale/formatter/TestMXMLMetadata.java
@@ -0,0 +1,137 @@
+package org.apache.royale.formatter;
+
+import static org.junit.Assert.assertEquals;
+
+import org.junit.Test;
+
+public class TestMXMLMetadata extends BaseFormatterTests {
+	@Test
+	public void testEmptyMetadataNoCdata() {
+		FORMATTER formatter = new FORMATTER();
+		formatter.insertSpaces = false;
+		String result = formatter.formatMXMLText(
+		// @formatter:off
+			"<s:Application>\n" +
+			"<fx:Metadata>\n" +
+			"</fx:Metadata>\n" +
+			"</s:Application>",
+			// @formatter:on
+			problems
+		);
+		assertEquals(
+		// @formatter:off
+				"<s:Application>\n" +
+				"\t<fx:Metadata>\n" +
+				"\t</fx:Metadata>\n" +
+				"</s:Application>",
+				// @formatter:on
+				result);
+	}
+
+	@Test
+	public void testEmptyMetadataWithCdata() {
+		FORMATTER formatter = new FORMATTER();
+		formatter.insertSpaces = false;
+		String result = formatter.formatMXMLText(
+		// @formatter:off
+			"<s:Application>\n" +
+			"<fx:Metadata>\n" +
+			"<![CDATA[\n" +
+			"]]>\n" +
+			"</fx:Metadata>\n" +
+			"</s:Application>",
+			// @formatter:on
+			problems
+		);
+		assertEquals(
+		// @formatter:off
+				"<s:Application>\n" +
+				"\t<fx:Metadata>\n" +
+				"\t\t<![CDATA[\n" +
+				"\t\t]]>\n" +
+				"\t</fx:Metadata>\n" +
+				"</s:Application>",
+				// @formatter:on
+				result);
+	}
+
+	@Test
+	public void testSingleMetadata() {
+		FORMATTER formatter = new FORMATTER();
+		formatter.insertSpaces = false;
+		String result = formatter.formatMXMLText(
+		// @formatter:off
+			"<s:Application>\n" +
+			"<fx:Metadata>\n" +
+			"[UnknownMetaTag]\n" +
+			"</fx:Metadata>\n" +
+			"</s:Application>",
+			// @formatter:on
+			problems
+		);
+		assertEquals(
+		// @formatter:off
+				"<s:Application>\n" +
+				"\t<fx:Metadata>\n" +
+				"\t\t[UnknownMetaTag]\n" +
+				"\t</fx:Metadata>\n" +
+				"</s:Application>",
+				// @formatter:on
+				result);
+	}
+
+	@Test
+	public void testMultipleMetadata() {
+		FORMATTER formatter = new FORMATTER();
+		formatter.insertSpaces = false;
+		String result = formatter.formatMXMLText(
+		// @formatter:off
+			"<s:Application>\n" +
+			"<fx:Metadata>\n" +
+			"[UnknownMetaTag1]\n" +
+			"[UnknownMetaTag2]\n" +
+			"</fx:Metadata>\n" +
+			"</s:Application>",
+			// @formatter:on
+			problems
+		);
+		assertEquals(
+		// @formatter:off
+				"<s:Application>\n" +
+				"\t<fx:Metadata>\n" +
+				"\t\t[UnknownMetaTag1]\n" +
+				"\t\t[UnknownMetaTag2]\n" +
+				"\t</fx:Metadata>\n" +
+				"</s:Application>",
+				// @formatter:on
+				result);
+	}
+
+	@Test
+	public void testMultipleMetadataWithAttributes() {
+		FORMATTER formatter = new FORMATTER();
+		formatter.insertSpaces = false;
+		String result = formatter.formatMXMLText(
+		// @formatter:off
+			"<s:Application>\n" +
+			"<fx:Metadata>\n" +
+			"[UnknownMetaTag1(attr1=\"one\", attr2=\"two\")]\n" +
+			"[UnknownMetaTag2(attr1=\"one\")]\n" +
+			"</fx:Metadata>\n" +
+			"</s:Application>",
+			// @formatter:on
+			problems
+		);
+		assertEquals(
+		// @formatter:off
+				"<s:Application>\n" +
+				"\t<fx:Metadata>\n" +
+				"\t\t[UnknownMetaTag1(attr1=\"one\", attr2=\"two\")]\n" +
+				"\t\t[UnknownMetaTag2(attr1=\"one\")]\n" +
+				"\t</fx:Metadata>\n" +
+				"</s:Application>",
+				// @formatter:on
+				result);
+	}
+	
+}

[royale-compiler] 02/04: formatter: remove debug console output

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 cc78bac8f3446d8c96eba9def14e803285612d6c
Author: Josh Tynjala <jo...@apache.org>
AuthorDate: Thu Oct 21 13:24:14 2021 -0700

    formatter: remove debug console output
---
 formatter/src/main/java/org/apache/royale/formatter/FORMATTER.java | 1 -
 1 file changed, 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 8e632e1..2c33869 100644
--- a/formatter/src/main/java/org/apache/royale/formatter/FORMATTER.java
+++ b/formatter/src/main/java/org/apache/royale/formatter/FORMATTER.java
@@ -1354,7 +1354,6 @@ public class FORMATTER {
 		int searchIndex = 0;
 		boolean inListing = alreadyInListing;
 		while (searchIndex < lineText.length()) {
-			System.err.println(searchIndex + " " + lineText.length() + " " + inListing);
 			if (!inListing) {
 				searchIndex = lineText.indexOf("<listing", searchIndex);
 				if (searchIndex == -1) {