Skip to content

Commit

Permalink
fix: rollback json translation check
Browse files Browse the repository at this point in the history
  • Loading branch information
scarf005 and olanti-p committed Aug 6, 2023
1 parent c55f645 commit 1ba874f
Show file tree
Hide file tree
Showing 5 changed files with 40 additions and 9 deletions.
2 changes: 1 addition & 1 deletion tools/clang-tidy-plugin/JsonTranslationInputCheck.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ void JsonTranslationInputCheck::registerMatchers( MatchFinder *Finder )
anyOf(
functionDecl(
hasAnyName(
"_", "translation_argument_identity", "pgettext" )
"_", "gettext", "pgettext", "vgettext", "vpgettext", "translation_argument_identity" )
).bind( "translationFunc" ),
functionDecl(
hasAnyName( "to_translation", "pl_translation" )
Expand Down
3 changes: 2 additions & 1 deletion tools/clang-tidy-plugin/NoStaticTranslationCheck.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,8 @@ void NoStaticTranslationCheck::registerMatchers( MatchFinder *Finder )
decl(
anyOf(
functionDecl(
hasAnyName( "_", "translation_argument_identity", "gettext", "pgettext" )
hasAnyName(
"_", "gettext", "pgettext", "vgettext", "vpgettext", "translation_argument_identity" )
),
cxxMethodDecl(
ofClass( hasName( "translation" ) ),
Expand Down
8 changes: 2 additions & 6 deletions tools/clang-tidy-plugin/TranslateStringLiteralCheck.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -28,12 +28,8 @@ void TranslateStringLiteralCheck::registerMatchers( MatchFinder *Finder )
callee(
functionDecl(
hasAnyName(
"_",
"translation_argument_identity",
"gettext",
"pgettext"
)
)
"_", "gettext", "pgettext", "vgettext", "vpgettext",
"translation_argument_identity" ) )
)
)
),
Expand Down
19 changes: 18 additions & 1 deletion tools/clang-tidy-plugin/TranslatorCommentsCheck.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -231,11 +231,19 @@ void TranslatorCommentsCheck::registerMatchers( MatchFinder *Finder )
);
Finder->addMatcher(
callExpr(
callee( functionDecl( hasAnyName( "_", "translation_argument_identity", "gettext" ) ) ),
callee( functionDecl( hasAnyName( "_", "gettext", "translation_argument_identity" ) ) ),
hasImmediateArgument( 0, stringLiteralArgumentBound )
),
this
);
Finder->addMatcher(
callExpr(
callee( functionDecl( hasName( "vgettext" ) ) ),
hasImmediateArgument( 0, stringLiteralArgumentBound ),
hasImmediateArgument( 1, stringLiteralArgumentUnbound )
),
this
);
Finder->addMatcher(
callExpr(
callee( functionDecl( hasName( "to_translation" ) ) ),
Expand All @@ -261,6 +269,15 @@ void TranslatorCommentsCheck::registerMatchers( MatchFinder *Finder )
),
this
);
Finder->addMatcher(
callExpr(
callee( functionDecl( hasAnyName( "vpgettext" ) ) ),
hasImmediateArgument( 0, stringLiteralArgumentUnbound ),
hasImmediateArgument( 1, stringLiteralArgumentBound ),
hasImmediateArgument( 2, stringLiteralArgumentUnbound )
),
this
);
Finder->addMatcher(
callExpr(
callee( functionDecl( hasName( "to_translation" ) ) ),
Expand Down
17 changes: 17 additions & 0 deletions tools/clang-tidy-plugin/test/translator-comments.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,13 @@ void foo()
//~ bar
_( "bar" );

vgettext( /*~ foo */ ( "bar" ), _( "baz" ), 0 );

//~ bar
gettext( "bar" );

//~bar
vgettext( "bar", "baz", 1 );

/*~ bar */ to_translation( "bar" );

Expand Down Expand Up @@ -70,6 +77,16 @@ void foo()
pgettext( ( "foo" ), "bar" );
// CHECK-MESSAGES: [[@LINE-2]]:5: warning: Translator comment without a matching raw string

/*~
barnacle */
vpgettext( "foo",
"bar", "baz", 2 );
// CHECK-MESSAGES: [[@LINE-4]]:5: warning: Translator comment without a matching raw string

//~ barn
vpgettext( "foo", "bar", ( "baz" ), 3 );
// CHECK-MESSAGES: [[@LINE-2]]:5: warning: Translator comment without a matching raw string

//~ baron
to_translation( "foo", { "bar" } );
// CHECK-MESSAGES: [[@LINE-2]]:5: warning: Translator comment without a matching raw string
Expand Down

0 comments on commit 1ba874f

Please sign in to comment.