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/09/20 22:48:53 UTC

[royale-compiler] branch develop updated (9195440 -> 67b7fd6)

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 9195440  build: add formatter
     new f623b33  RELEASE_NOTES: asformat
     new 4667518  formatter: fix some defaults that should have been true
     new 09d33bf  formatter: fix wrong command line option mapping
     new 67b7fd6  formatter: fix usages with zero args

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:
 RELEASE_NOTES.md                                   |   6 +
 .../org/apache/royale/formatter/FORMATTER.java     | 152 +++++++++------------
 .../royale/formatter/config/Configuration.java     |  12 +-
 3 files changed, 77 insertions(+), 93 deletions(-)

[royale-compiler] 04/04: formatter: fix usages with zero args

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 67b7fd6247c7ec26ad7610d305f0b2fd869502d6
Author: Josh Tynjala <jo...@apache.org>
AuthorDate: Mon Sep 20 15:48:39 2021 -0700

    formatter: fix usages with zero args
---
 .../org/apache/royale/formatter/FORMATTER.java     | 152 +++++++++------------
 1 file changed, 65 insertions(+), 87 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 ad1aa94..ee6ceb8 100644
--- a/formatter/src/main/java/org/apache/royale/formatter/FORMATTER.java
+++ b/formatter/src/main/java/org/apache/royale/formatter/FORMATTER.java
@@ -65,10 +65,10 @@ import org.apache.royale.utils.FilenameNormalization;
  */
 class FORMATTER {
 	private static final int TOKEN_TYPE_EXTRA = 999999;
-    
-    private static final String NEWLINE = System.getProperty("line.separator");
-    private static final String DEFAULT_VAR = "files";
-    private static final String L10N_CONFIG_PREFIX = "org.apache.royale.compiler.internal.config.configuration";
+
+	private static final String NEWLINE = System.getProperty("line.separator");
+	private static final String DEFAULT_VAR = "files";
+	private static final String L10N_CONFIG_PREFIX = "org.apache.royale.compiler.internal.config.configuration";
 
 	static enum ExitCode {
 		SUCCESS(0), PRINT_HELP(1), FAILED_WITH_PROBLEMS(2), FAILED_WITH_EXCEPTIONS(3), FAILED_WITH_CONFIG_PROBLEMS(4);
@@ -209,67 +209,55 @@ class FORMATTER {
 	public String formatText(String text) {
 		return formatText(text, null);
 	}
-    
-    /**
-     * Get the start up message that contains the program name 
-     * with the copyright notice.
-     * 
-     * @return The startup message.
-     */
-    protected String getStartMessage()
-    {
-        // This message should not be localized.
-        String message = "Apache Royale ActionScript Formatter (asformat)" + NEWLINE +
-            VersionInfo.buildMessage() + NEWLINE;
-        return message;
-    }
-
-    /**
-     * Get my program name.
-     * 
-     * @return always "mxmlc".
-     */
-    protected String getProgramName()
-    {
-        return "asformat";
-    }
-
-    /**
-     * Print detailed help information if -help is provided.
-     */
-    private void processHelp(final List<ConfigurationValue> helpVar)
-    {
-        final Set<String> keywords = new LinkedHashSet<String>();
-        for (final ConfigurationValue val : helpVar)
-        {
-            for (final Object element : val.getArgs())
-            {
-                String keyword = (String)element;
-                while (keyword.startsWith("-"))
-                    keyword = keyword.substring(1);
-                keywords.add(keyword);
-            }
-        }
-
-        if (keywords.size() == 0)
-            keywords.add("help");
-
-        final String usages = CommandLineConfigurator.usage(
-                    getProgramName(),
-                    DEFAULT_VAR,
-                    configBuffer,
-                    keywords,
-                    LocalizationManager.get(),
-                    L10N_CONFIG_PREFIX);
-        System.out.println(getStartMessage());
-        System.out.println(usages);
-    }
 
-	private boolean configure(String[] args) {
-		if (args.length == 0) {
-			printHelp();
-			return false;
+	/**
+	 * Get the start up message that contains the program name with the copyright
+	 * notice.
+	 * 
+	 * @return The startup message.
+	 */
+	protected String getStartMessage() {
+		// This message should not be localized.
+		String message = "Apache Royale ActionScript Formatter (asformat)" + NEWLINE + VersionInfo.buildMessage()
+				+ NEWLINE;
+		return message;
+	}
+
+	/**
+	 * Get my program name.
+	 * 
+	 * @return always "mxmlc".
+	 */
+	protected String getProgramName() {
+		return "asformat";
+	}
+
+	/**
+	 * Print detailed help information if -help is provided.
+	 */
+	private void processHelp(final List<ConfigurationValue> helpVar) {
+		final Set<String> keywords = new LinkedHashSet<String>();
+		if (helpVar != null) {
+			for (final ConfigurationValue val : helpVar) {
+				for (final Object element : val.getArgs()) {
+					String keyword = (String) element;
+					while (keyword.startsWith("-"))
+						keyword = keyword.substring(1);
+					keywords.add(keyword);
+				}
+			}
 		}
+
+		if (keywords.size() == 0)
+			keywords.add("help");
+
+		final String usages = CommandLineConfigurator.usage(getProgramName(), DEFAULT_VAR, configBuffer, keywords,
+				LocalizationManager.get(), L10N_CONFIG_PREFIX);
+		System.out.println(getStartMessage());
+		System.out.println(usages);
+	}
+
+	private boolean configure(String[] args) {
 		try {
 			problems = new ProblemQuery();
 
@@ -284,14 +272,13 @@ class FORMATTER {
 				System.out.println(VersionInfo.buildMessage());
 				return false;
 			}
-            
-            // Print help if "-help" is present.
-            final List<ConfigurationValue> helpVar = configBuffer.getVar("help");
-            if (helpVar != null)
-            {
-                processHelp(helpVar);
-                return false;
-            }
+
+			// Print help if "-help" is present.
+			final List<ConfigurationValue> helpVar = configBuffer.getVar("help");
+			if (helpVar != null || args.length == 0) {
+				processHelp(helpVar);
+				return false;
+			}
 
 			if (problems.hasErrors())
 				return false;
@@ -300,8 +287,10 @@ class FORMATTER {
 			ignoreProblems = configuration.getIgnoreParsingProblems();
 			insertFinalNewLine = configuration.getInsertFinalNewLine();
 			insertSpaceAfterCommaDelimiter = configuration.getInsertSpaceAfterCommaDelimiter();
-			insertSpaceAfterFunctionKeywordForAnonymousFunctions = configuration.getInsertSpaceAfterFunctionKeywordForAnonymousFunctions();
-			insertSpaceAfterKeywordsInControlFlowStatements = configuration.getInsertSpaceAfterKeywordsInControlFlowStatements();
+			insertSpaceAfterFunctionKeywordForAnonymousFunctions = configuration
+					.getInsertSpaceAfterFunctionKeywordForAnonymousFunctions();
+			insertSpaceAfterKeywordsInControlFlowStatements = configuration
+					.getInsertSpaceAfterKeywordsInControlFlowStatements();
 			insertSpaceAfterSemicolonInForStatements = configuration.getInsertSpaceAfterSemicolonInForStatements();
 			insertSpaceBeforeAndAfterBinaryOperators = configuration.getInsertSpaceBeforeAndAfterBinaryOperators();
 			insertSpaces = configuration.getInsertSpaces();
@@ -361,17 +350,6 @@ class FORMATTER {
 		}
 	}
 
-	private void printHelp() {
-		System.err.println("Apache Royale ActionScript Formatter (asformat)");
-		System.err.println(VersionInfo.buildMessage());
-		System.err.println("");
-		System.err.println("-h, -help    Prints program usage information.");
-		System.err.println(
-				"-l, -list    Lists file names of files that are formatted, and does not print reformatted sources to standard output.");
-		System.err.println(
-				"-w, -write   Overwrites the input files that are foramtted, and does not print the reformatted sources to standard output.");
-	}
-
 	private String formatTextInternal(String filePath, String text, Collection<ICompilerProblem> problems) {
 		StringReader textReader = new StringReader(text);
 		StreamingASTokenizer tokenizer = null;
@@ -488,7 +466,7 @@ class FORMATTER {
 			tokens.add(token);
 			prevToken = token;
 		}
-		if(prevToken != null) {
+		if (prevToken != null) {
 			int start = prevToken.getAbsoluteEnd();
 			int end = text.length();
 			if (end > start) {
@@ -563,8 +541,8 @@ class FORMATTER {
 		for (int i = 0; i < tokens.size(); i++) {
 			token = tokens.get(i);
 			if (token.getType() == TOKEN_TYPE_EXTRA) {
-				if(i == (tokens.size() - 1)) {
-					//if the last token is whitespace, include new lines
+				if (i == (tokens.size() - 1)) {
+					// if the last token is whitespace, include new lines
 					numRequiredNewLines = Math.max(0, countNewLinesInExtra(token));
 					appendNewLines(builder, numRequiredNewLines);
 					break;

[royale-compiler] 02/04: formatter: fix some defaults that should have been true

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 46675187b8d141cacaa370e6ddbd8f7d4f8d9c97
Author: Josh Tynjala <jo...@apache.org>
AuthorDate: Mon Sep 20 15:10:34 2021 -0700

    formatter: fix some defaults that should have been true
---
 .../java/org/apache/royale/formatter/config/Configuration.java | 10 +++++-----
 1 file changed, 5 insertions(+), 5 deletions(-)

diff --git a/formatter/src/main/java/org/apache/royale/formatter/config/Configuration.java b/formatter/src/main/java/org/apache/royale/formatter/config/Configuration.java
index 2a7938a..216175d 100644
--- a/formatter/src/main/java/org/apache/royale/formatter/config/Configuration.java
+++ b/formatter/src/main/java/org/apache/royale/formatter/config/Configuration.java
@@ -242,7 +242,7 @@ public class Configuration {
     // 'open-brace-new-line' option
     //
 
-    private boolean placeOpenBraceOnNewLine = false;
+    private boolean placeOpenBraceOnNewLine = true;
 
     public boolean getPlaceOpenBraceOnNewLine()
     {
@@ -260,7 +260,7 @@ public class Configuration {
     // 'insert-space-for-loop-semicolon' option
     //
 
-    private boolean insertSpaceAfterSemicolonInForStatements = false;
+    private boolean insertSpaceAfterSemicolonInForStatements = true;
 
     public boolean getInsertSpaceAfterSemicolonInForStatements()
     {
@@ -278,7 +278,7 @@ public class Configuration {
     // 'insert-space-control-flow-keywords' option
     //
 
-    private boolean insertSpaceAfterKeywordsInControlFlowStatements = false;
+    private boolean insertSpaceAfterKeywordsInControlFlowStatements = true;
 
     public boolean getInsertSpaceAfterKeywordsInControlFlowStatements()
     {
@@ -314,7 +314,7 @@ public class Configuration {
     // 'insert-space-binary-operators' option
     //
 
-    private boolean insertSpaceBeforeAndAfterBinaryOperators = false;
+    private boolean insertSpaceBeforeAndAfterBinaryOperators = true;
 
     public boolean getInsertSpaceBeforeAndAfterBinaryOperators()
     {
@@ -332,7 +332,7 @@ public class Configuration {
     // 'insert-space-comma-delimiter' option
     //
 
-    private boolean insertSpaceAfterCommaDelimiter = false;
+    private boolean insertSpaceAfterCommaDelimiter = true;
 
     public boolean getInsertSpaceAfterCommaDelimiter()
     {

[royale-compiler] 01/04: RELEASE_NOTES: asformat

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 f623b337431cb3d29630cc7fc90dd5582a28aecf
Author: Josh Tynjala <jo...@apache.org>
AuthorDate: Mon Sep 20 15:06:42 2021 -0700

    RELEASE_NOTES: asformat
---
 RELEASE_NOTES.md | 6 ++++++
 1 file changed, 6 insertions(+)

diff --git a/RELEASE_NOTES.md b/RELEASE_NOTES.md
index 8e829b6..3fb23f1 100644
--- a/RELEASE_NOTES.md
+++ b/RELEASE_NOTES.md
@@ -1,5 +1,11 @@
 For additional information on recent issues that have been closed, see [Github Issues List](https://github.com/apache/royale-compiler/issues?q=is%3Aissue+is%3Aclosed)
 
+Apache Royale Compiler 0.9.9
+
+=================
+
+- **asformat** is a new formatter for ActionScript code
+
 Apache Royale Compiler 0.9.8
 =================
 

[royale-compiler] 03/04: formatter: fix wrong command line option mapping

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 09d33bf421d21cc42034914a6884ad6aca27c4b6
Author: Josh Tynjala <jo...@apache.org>
AuthorDate: Mon Sep 20 15:31:00 2021 -0700

    formatter: fix wrong command line option mapping
---
 .../src/main/java/org/apache/royale/formatter/config/Configuration.java | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/formatter/src/main/java/org/apache/royale/formatter/config/Configuration.java b/formatter/src/main/java/org/apache/royale/formatter/config/Configuration.java
index 216175d..c66c8a9 100644
--- a/formatter/src/main/java/org/apache/royale/formatter/config/Configuration.java
+++ b/formatter/src/main/java/org/apache/royale/formatter/config/Configuration.java
@@ -304,7 +304,7 @@ public class Configuration {
     }
 
     @Config
-    @Mapping("insert-space-control-flow-keywords")
+    @Mapping("insert-space-anonymous-function-keyword")
     public void setInsertSpaceAfterFunctionKeywordForAnonymousFunctions(ConfigurationValue cv, boolean b)
     {
         this.insertSpaceAfterFunctionKeywordForAnonymousFunctions = b;