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
The following commit(s) were added to refs/heads/develop by this push: new d8b873aa4 ASTokenFormatter: avoid null being returned for getTokenText() d8b873aa4 is described below commit d8b873aa4a353af01a0e3246941eed6f1127c9c7 Author: Josh Tynjala <joshtynj...@apache.org> AuthorDate: Thu Feb 15 08:50:36 2024 -0800 ASTokenFormatter: avoid null being returned for getTokenText() --- .../apache/royale/formatter/ASTokenFormatter.java | 38 ++++++++++++++++++---- 1 file changed, 32 insertions(+), 6 deletions(-) diff --git a/formatter/src/main/java/org/apache/royale/formatter/ASTokenFormatter.java b/formatter/src/main/java/org/apache/royale/formatter/ASTokenFormatter.java index 30fa3c9f4..91b8504d4 100644 --- a/formatter/src/main/java/org/apache/royale/formatter/ASTokenFormatter.java +++ b/formatter/src/main/java/org/apache/royale/formatter/ASTokenFormatter.java @@ -1225,19 +1225,31 @@ public class ASTokenFormatter extends BaseTokenFormatter { switch (token.getType()) { case ASTokenTypes.TOKEN_ASDOC_COMMENT: { if (skipFormatting) { - return token.getText(); + String tokenText = token.getText(); + if (tokenText != null) { + return tokenText; + } + return ""; } return formatASDocComment(token.getText(), indent); } case ASTokenTypes.HIDDEN_TOKEN_SINGLE_LINE_COMMENT: { if (skipFormatting) { - return token.getText(); + String tokenText = token.getText(); + if (tokenText != null) { + return tokenText; + } + return ""; } return formatSingleLineComment(token.getText()); } case ASTokenTypes.HIDDEN_TOKEN_MULTI_LINE_COMMENT: { if (skipFormatting) { - return token.getText(); + String tokenText = token.getText(); + if (tokenText != null) { + return tokenText; + } + return ""; } return formatMultiLineComment(token.getText()); } @@ -1246,17 +1258,31 @@ public class ASTokenFormatter extends BaseTokenFormatter { } case ASTokenTypes.TOKEN_SEMICOLON: { if (skipFormatting) { - return token.isImplicit() ? "" : token.getText(); + if (token.isImplicit()) { + return ""; + } + String tokenText = token.getText(); + if (tokenText != null) { + return tokenText; + } + return ""; } boolean skipSemicolon = Semicolons.REMOVE.equals(settings.semicolons) || (Semicolons.IGNORE.equals(settings.semicolons) && token.isImplicit()); if (!skipSemicolon) { - return token.getText(); + String tokenText = token.getText(); + if (tokenText != null) { + return tokenText; + } } return ""; } default: { - return token.getText(); + String tokenText = token.getText(); + if (tokenText != null) { + return tokenText; + } + return ""; } } }