use of com.perl5.lang.perl.psi.PerlVariableDeclarationElement 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"));
}
}
use of com.perl5.lang.perl.psi.PerlVariableDeclarationElement in project Perl5-IDEA by Camelcade.
the class PerlVariableCompletionUtil method fillWithBuiltInVariables.
public static void fillWithBuiltInVariables(@NotNull PsiElement variableNameElement, @NotNull CompletionResultSet resultSet) {
PsiElement perlVariable = variableNameElement.getParent();
PerlBuiltInVariablesService perlBuiltInVariablesService = PerlBuiltInVariablesService.getInstance(variableNameElement.getProject());
if (perlVariable instanceof PsiPerlScalarVariable) {
perlBuiltInVariablesService.processScalars((element, state) -> {
// noinspection ConstantConditions
resultSet.addElement(getScalarLookupElement(((PerlVariableDeclarationElement) element).getName()).withBoldness(true));
return true;
});
perlBuiltInVariablesService.processArrays((element, state) -> {
// noinspection ConstantConditions
resultSet.addElement(getArrayElementLookupElement(((PerlVariableDeclarationElement) element).getName()).withBoldness(true));
return true;
});
perlBuiltInVariablesService.processHashes((element, state) -> {
// noinspection ConstantConditions
resultSet.addElement(getHashElementLookupElement(((PerlVariableDeclarationElement) element).getName()).withBoldness(true));
return true;
});
} else if (perlVariable instanceof PsiPerlArrayVariable) {
perlBuiltInVariablesService.processArrays((element, state) -> {
// noinspection ConstantConditions
resultSet.addElement(getArrayLookupElement(((PerlVariableDeclarationElement) element).getName()).withBoldness(true));
// noinspection ConstantConditions
resultSet.addElement(getArraySliceLookupElement(((PerlVariableDeclarationElement) element).getName()).withBoldness(true));
return true;
});
perlBuiltInVariablesService.processHashes((element, state) -> {
// noinspection ConstantConditions
resultSet.addElement(getHashSliceLookupElement(((PerlVariableDeclarationElement) element).getName()).withBoldness(true));
return true;
});
} else if (perlVariable instanceof PsiPerlArrayIndexVariable) {
perlBuiltInVariablesService.processArrays((element, state) -> {
// noinspection ConstantConditions
resultSet.addElement(getArrayLookupElement(((PerlVariableDeclarationElement) element).getName()).withBoldness(true));
return true;
});
} else if (perlVariable instanceof PsiPerlHashVariable) {
perlBuiltInVariablesService.processHashes((element, state) -> {
// noinspection ConstantConditions
resultSet.addElement(getHashLookupElement(((PerlVariableDeclarationElement) element).getName()).withBoldness(true));
return true;
});
} else if (perlVariable instanceof PsiPerlGlobVariable) {
perlBuiltInVariablesService.processGlobs((element, state) -> {
// noinspection ConstantConditions
resultSet.addElement(getGlobLookupElement(((PerlVariableDeclarationElement) element).getName()).withBoldness(true));
return true;
});
}
}
use of com.perl5.lang.perl.psi.PerlVariableDeclarationElement in project Perl5-IDEA by Camelcade.
the class PerlVariableCompletionUtil method fillWithLExicalVariables.
public static void fillWithLExicalVariables(@NotNull PsiElement variableNameElement, @NotNull final CompletionResultSet resultSet) {
final PsiElement perlVariable = variableNameElement.getParent();
PsiScopeProcessor processor = (element, state) -> {
if (element instanceof PerlVariableDeclarationElement) {
PerlVariableDeclarationElement variable = (PerlVariableDeclarationElement) element;
PsiElement declarationStatement = PsiTreeUtil.getParentOfType(variable, PerlStatement.class);
if (PsiTreeUtil.isAncestor(declarationStatement, perlVariable, false)) {
return true;
}
if (perlVariable instanceof PsiPerlScalarVariable) {
String variableName = variable.getName();
if (variableName != null) {
if (variable.getActualType() == PerlVariableType.SCALAR) {
resultSet.addElement(setLexical(getScalarLookupElement(variableName)));
} else if (variable.getActualType() == PerlVariableType.ARRAY) {
resultSet.addElement(setLexical(getArrayElementLookupElement(variableName)));
} else if (variable.getActualType() == PerlVariableType.HASH) {
resultSet.addElement(setLexical(getHashElementLookupElement(variableName)));
}
}
} else if (perlVariable instanceof PsiPerlArrayVariable) {
String variableName = variable.getName();
if (variableName != null) {
if (variable.getActualType() == PerlVariableType.ARRAY) {
resultSet.addElement(setLexical(getArrayLookupElement(variableName)));
resultSet.addElement(setLexical(getArraySliceLookupElement(variableName)));
} else if (variable.getActualType() == PerlVariableType.HASH) {
resultSet.addElement(setLexical(getHashSliceLookupElement(variableName)));
}
}
} else if (perlVariable instanceof PsiPerlArrayIndexVariable) {
String variableName = variable.getName();
if (variableName != null) {
if (variable.getActualType() == PerlVariableType.ARRAY) {
resultSet.addElement(setLexical(getArrayLookupElement(variableName)));
}
}
} else if (perlVariable instanceof PsiPerlHashVariable) {
String variableName = variable.getName();
if (variableName != null) {
if (variable.getActualType() == PerlVariableType.HASH) {
resultSet.addElement(setLexical(getHashLookupElement(variableName)));
}
}
}
}
return true;
};
PerlResolveUtil.treeWalkUp(variableNameElement, processor);
PerlBuiltInVariablesService.getInstance(variableNameElement.getProject()).processVariables(processor);
}
use of com.perl5.lang.perl.psi.PerlVariableDeclarationElement in project Perl5-IDEA by Camelcade.
the class HTMLMasonFileImpl method getImplicitVariables.
@NotNull
@Override
public List<PerlVariableDeclarationElement> getImplicitVariables() {
HTMLMasonSettings settings = HTMLMasonSettings.getInstance(getProject());
if (myImplicitVariables == null || myMasonChangeCounter != settings.getChangeCounter()) {
myImplicitVariables = buildImplicitVariables(settings);
myMasonChangeCounter = settings.getChangeCounter();
}
return myImplicitVariables;
}
use of com.perl5.lang.perl.psi.PerlVariableDeclarationElement in project Perl5-IDEA by Camelcade.
the class HTMLMasonArgsBlockImpl method getArgumentsListHeavy.
@NotNull
protected List<PerlSubArgument> getArgumentsListHeavy() {
List<PerlSubArgument> result = new ArrayList<>();
PsiElement run = getFirstChild();
while (run != null) {
if (run instanceof PerlVariableDeclarationElement) {
PerlVariable variable = ((PerlVariableDeclarationElement) run).getVariable();
if (variable != null) {
PsiElement nextSibling = PerlPsiUtil.getNextSignificantSibling(run);
result.add(PerlSubArgument.create(variable.getActualType(), variable.getName(), nextSibling != null && nextSibling.getNode().getElementType() == FAT_COMMA));
}
}
run = run.getNextSibling();
}
return result;
}
Aggregations