From f1f5ddd960633aba2f56486fbcf6d45ce073cf4b Mon Sep 17 00:00:00 2001 From: Josh Tynjala Date: Mon, 9 Dec 2024 14:06:55 -0800 Subject: [PATCH] language-server: FormattingProvider prints unexpected exception problems to stderr so that they are more likely to be reported as bugs --- .../as3mxml/vscode/providers/FormattingProvider.java | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/language-server/src/main/java/com/as3mxml/vscode/providers/FormattingProvider.java b/language-server/src/main/java/com/as3mxml/vscode/providers/FormattingProvider.java index 54f546e93..ea17f0896 100644 --- a/language-server/src/main/java/com/as3mxml/vscode/providers/FormattingProvider.java +++ b/language-server/src/main/java/com/as3mxml/vscode/providers/FormattingProvider.java @@ -7,6 +7,7 @@ import org.apache.royale.compiler.config.ConfigurationPathResolver; import org.apache.royale.compiler.problems.ICompilerProblem; +import org.apache.royale.compiler.problems.UnexpectedExceptionProblem; import org.apache.royale.formatter.ASTokenFormatter; import org.apache.royale.formatter.FormatterSettings; import org.apache.royale.formatter.FormatterUtils; @@ -69,10 +70,20 @@ public List formatting(DocumentFormattingParams params, Canc MXMLTokenFormatter formatter = new MXMLTokenFormatter(settings); List problems = new ArrayList<>(); formattedFileText = formatter.format(path.toString(), fileText, problems); + for (ICompilerProblem problem : problems) { + if (problem instanceof UnexpectedExceptionProblem) { + System.err.println(problem); + } + } } else if (path.toString().endsWith(FILE_EXTENSION_AS)) { ASTokenFormatter formatter = new ASTokenFormatter(settings); List problems = new ArrayList<>(); formattedFileText = formatter.format(path.toString(), fileText, problems); + for (ICompilerProblem problem : problems) { + if (problem instanceof UnexpectedExceptionProblem) { + System.err.println(problem); + } + } } if (fileText.equals(formattedFileText)) { return Collections.emptyList();