initialization macro to suppress the unused case warning

This commit is contained in:
2022-02-23 14:17:35 -07:00
parent dd5fbc2f66
commit 1433c78144
5 changed files with 36 additions and 18 deletions

View File

@@ -5,3 +5,4 @@
-cp kiss/src
-cp cloner/src
-D analyzer-optimize
--macro kiss.Kiss.setup()

View File

@@ -161,6 +161,23 @@ class Kiss {
#end
}
/**
* Initializer macro: suppress some compiler warnings that Kiss code commonly generates
* Source: https://try.haxe.org/#10F18962 by @kLabz
*/
public static macro function setup() {
haxe.macro.Context.onAfterTyping(function(_) {
haxe.macro.Context.filterMessages(function(msg) {
return switch (msg) {
case Warning("This case is unused", _): false;
case _: true;
};
});
});
return macro {};
}
/**
Build macro: add fields to a class from a corresponding .kiss file
**/

View File

@@ -5,5 +5,6 @@ args.hxml
-lib kiss-vscode
-lib kiss-tools
-lib re-flex
--macro kiss.Kiss.setup()
KissConfig
-js config.js

View File

@@ -134,20 +134,19 @@
null)))))
(function :Void showCompileError [errorMessage]
(ifLet [errorMessage (.join (filter (errorMessage.split "\n") ->[:String l] (= -1 (l.indexOf "This case is unused"))) "\n")
compileErrors (R.distinctMatches
(R.group
(R.namedGroup "file"
(R.repeat (R.oneOf R.anyLetter R.anyDigit (R.escape "/")) 1) // filename
(R.escape ".kiss:")
(R.repeat R.anyDigit 1) // line
(R.escape ":")
(R.optional
(R.group
(R.repeat R.anyDigit 1) // column
(R.escape ":"))))
(R.repeat R.anyChar 1))
errorMessage)]
(ifLet [compileErrors (R.distinctMatches
(R.group
(R.namedGroup "file"
(R.repeat (R.oneOf R.anyLetter R.anyDigit (R.escape "/")) 1) // filename
(R.escape ".kiss:")
(R.repeat R.anyDigit 1) // line
(R.escape ":")
(R.optional
(R.group
(R.repeat R.anyDigit 1) // column
(R.escape ":"))))
(R.repeat R.anyChar 1))
errorMessage)]
{
(Vscode.window.showErrorMessage errorMessage)
(awaitLet [chosen (quickPickMap (for match compileErrors =>match.match match))]

View File

@@ -15,12 +15,12 @@ fi
# Test projects with test-project.sh
if [ ! -z "$KISS_PROJECT" ]
then
./test-project.sh 2>&1 | grep -v "This case is unused"
./test-project.sh
# Test Kiss with utest cases in kiss/src/test/cases
else
if [ ! -z "$2" ]; then
haxe -D cases=$2 kiss/build-scripts/common-args.hxml kiss/build-scripts/common-test-args.hxml kiss/build-scripts/$KISS_TARGET/test.hxml 2>&1 | grep -v "This case is unused"
haxe -D cases=$2 kiss/build-scripts/common-args.hxml kiss/build-scripts/common-test-args.hxml kiss/build-scripts/$KISS_TARGET/test.hxml
else
haxe kiss/build-scripts/common-args.hxml kiss/build-scripts/common-test-args.hxml kiss/build-scripts/$KISS_TARGET/test.hxml 2>&1 | grep -v "This case is unused"
haxe kiss/build-scripts/common-args.hxml kiss/build-scripts/common-test-args.hxml kiss/build-scripts/$KISS_TARGET/test.hxml
fi
fi