Search in sources :

Example 1 with PsiPerlVariableDeclarationLocal

use of com.perl5.lang.perl.psi.PsiPerlVariableDeclarationLocal in project Perl5-IDEA by Camelcade.

the class PerlVariableShadowingInspection method checkDeclaration.

@Override
public void checkDeclaration(ProblemsHolder holder, PerlVariableDeclarationElement variableDeclarationWrapper) {
    PerlVariable variable = variableDeclarationWrapper.getVariable();
    PsiElement declarationContainer = variableDeclarationWrapper.getParent();
    if (variable != null && !(declarationContainer instanceof PsiPerlVariableDeclarationLocal)) {
        PerlVariableDeclarationElement lexicalDeclaration = PerlResolveUtil.getLexicalDeclaration(variable);
        if (lexicalDeclaration instanceof PerlBuiltInVariable) {
            registerProblem(holder, variable, PerlBundle.message("perl.inspection.shadows.builtin", lexicalDeclaration.getVariable().getLineNumber()));
        } else if (lexicalDeclaration instanceof PerlImplicitVariableDeclaration) {
            registerProblem(holder, variable, PerlBundle.message("perl.inspection.shadows.implicit", lexicalDeclaration.getVariable().getLineNumber()));
        } else if (lexicalDeclaration != null) {
            registerProblem(holder, variable, PerlBundle.message("perl.inspection.shadows.other", lexicalDeclaration.getVariable().getLineNumber()));
        }
    }
}
Also used : PsiPerlVariableDeclarationLocal(com.perl5.lang.perl.psi.PsiPerlVariableDeclarationLocal) PerlBuiltInVariable(com.perl5.lang.perl.psi.impl.PerlBuiltInVariable) PerlVariableDeclarationElement(com.perl5.lang.perl.psi.PerlVariableDeclarationElement) PerlVariable(com.perl5.lang.perl.psi.PerlVariable) PerlImplicitVariableDeclaration(com.perl5.lang.perl.psi.impl.PerlImplicitVariableDeclaration) PsiElement(com.intellij.psi.PsiElement)

Example 2 with PsiPerlVariableDeclarationLocal

use of com.perl5.lang.perl.psi.PsiPerlVariableDeclarationLocal in project Perl5-IDEA by Camelcade.

the class PerlBuiltinVariableRedeclarationInspection method checkDeclaration.

public void checkDeclaration(ProblemsHolder holder, PerlVariableDeclarationElement variableDeclarationWrapper) {
    PerlVariable variable = variableDeclarationWrapper.getVariable();
    PsiElement declarationContainer = variableDeclarationWrapper.getParent();
    if (variable != null && PerlBuiltInVariablesService.getInstance(variableDeclarationWrapper.getProject()).getVariableDeclaration(variable.getActualType(), variable.getName()) != null && !(declarationContainer instanceof PsiPerlVariableDeclarationLocal)) {
        registerProblem(holder, variable, PerlBundle.message("perl.inspection.builtin.shadowing"));
    }
}
Also used : PsiPerlVariableDeclarationLocal(com.perl5.lang.perl.psi.PsiPerlVariableDeclarationLocal) PerlVariable(com.perl5.lang.perl.psi.PerlVariable) PsiElement(com.intellij.psi.PsiElement)

Aggregations

PsiElement (com.intellij.psi.PsiElement)2 PerlVariable (com.perl5.lang.perl.psi.PerlVariable)2 PsiPerlVariableDeclarationLocal (com.perl5.lang.perl.psi.PsiPerlVariableDeclarationLocal)2 PerlVariableDeclarationElement (com.perl5.lang.perl.psi.PerlVariableDeclarationElement)1 PerlBuiltInVariable (com.perl5.lang.perl.psi.impl.PerlBuiltInVariable)1 PerlImplicitVariableDeclaration (com.perl5.lang.perl.psi.impl.PerlImplicitVariableDeclaration)1