1 /* This Source Code Form is subject to the terms of the Mozilla Public
2 * License, v. 2.0. If a copy of the MPL was not distributed with this
3 * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
5 #include "NoUsingNamespaceMozillaJavaChecker.h"
6 #include "CustomMatchers.h"
8 void NoUsingNamespaceMozillaJavaChecker::registerMatchers(
9 MatchFinder
*AstMatcher
) {
10 AstMatcher
->addMatcher(
11 usingDirectiveDecl(isUsingNamespaceMozillaJava()).bind("directive"),
15 void NoUsingNamespaceMozillaJavaChecker::check(
16 const MatchFinder::MatchResult
&Result
) {
17 const UsingDirectiveDecl
*Directive
=
18 Result
.Nodes
.getNodeAs
<UsingDirectiveDecl
>("directive");
19 const NamespaceDecl
*Namespace
= Directive
->getNominatedNamespace();
21 diag(Directive
->getUsingLoc(), "using namespace %0 is forbidden",
23 << Namespace
->getQualifiedNameAsString();