Search in sources :

Example 1 with Declare

use of com.jetbrains.php.lang.psi.elements.Declare in project phpinspectionsea by kalessil.

the class DeclareDirectiveCorrectnessInspector method buildVisitor.

@Override
@NotNull
public PsiElementVisitor buildVisitor(@NotNull final ProblemsHolder holder, boolean isOnTheFly) {
    return new BasePhpElementVisitor() {

        @Override
        public void visitPhpDeclare(@NotNull Declare declare) {
            final PsiElement declaration = declare.getFirstPsiChild();
            final String declarationText = declaration == null ? null : declaration.getText();
            if (declarationText != null && declarationText.indexOf('=') != -1) {
                final String directive = declarationText.split("=")[0];
                if (!directives.contains(directive.trim())) {
                    final String message = messagePattern.replace("%d%", directive);
                    holder.registerProblem(declare, message);
                }
            }
        }
    };
}
Also used : BasePhpElementVisitor(com.kalessil.phpStorm.phpInspectionsEA.openApi.BasePhpElementVisitor) Declare(com.jetbrains.php.lang.psi.elements.Declare) NotNull(org.jetbrains.annotations.NotNull) PsiElement(com.intellij.psi.PsiElement) NotNull(org.jetbrains.annotations.NotNull)

Aggregations

PsiElement (com.intellij.psi.PsiElement)1 Declare (com.jetbrains.php.lang.psi.elements.Declare)1 BasePhpElementVisitor (com.kalessil.phpStorm.phpInspectionsEA.openApi.BasePhpElementVisitor)1 NotNull (org.jetbrains.annotations.NotNull)1