2020-01-22 21:47:04 +03:00
|
|
|
/* This Source Code Form is subject to the terms of the Mozilla Public
|
|
|
|
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
|
|
|
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
|
|
|
|
|
|
|
|
#include "NoUsingNamespaceMozillaJavaChecker.h"
|
|
|
|
#include "CustomMatchers.h"
|
|
|
|
|
2020-02-17 21:30:50 +03:00
|
|
|
void NoUsingNamespaceMozillaJavaChecker::registerMatchers(
|
|
|
|
MatchFinder *AstMatcher) {
|
2020-01-22 21:47:04 +03:00
|
|
|
AstMatcher->addMatcher(
|
|
|
|
usingDirectiveDecl(isUsingNamespaceMozillaJava()).bind("directive"),
|
|
|
|
this);
|
|
|
|
}
|
|
|
|
|
|
|
|
void NoUsingNamespaceMozillaJavaChecker::check(
|
|
|
|
const MatchFinder::MatchResult &Result) {
|
|
|
|
const UsingDirectiveDecl *Directive =
|
|
|
|
Result.Nodes.getNodeAs<UsingDirectiveDecl>("directive");
|
|
|
|
const NamespaceDecl *Namespace = Directive->getNominatedNamespace();
|
|
|
|
|
2020-02-17 21:30:50 +03:00
|
|
|
diag(Directive->getUsingLoc(), "using namespace %0 is forbidden",
|
2020-01-22 21:47:04 +03:00
|
|
|
DiagnosticIDs::Error)
|
|
|
|
<< Namespace->getQualifiedNameAsString();
|
|
|
|
}
|