use of com.perl5.lang.perl.psi.PerlVariableDeclarationElement in project Perl5-IDEA by Camelcade.
the class MasonNamespaceDefinitionImpl method getImplicitVariables.
@NotNull
@Override
public List<PerlVariableDeclarationElement> getImplicitVariables() {
MasonSettings settings = MasonSettings.getInstance(getProject());
if (myImplicitVariables == null || mySettingsChangeCounter != settings.getChangeCounter()) {
myImplicitVariables = buildImplicitVariables(settings);
mySettingsChangeCounter = settings.getChangeCounter();
}
return myImplicitVariables;
}
use of com.perl5.lang.perl.psi.PerlVariableDeclarationElement in project Perl5-IDEA by Camelcade.
the class PerlResolveUtil method processChildren.
public static boolean processChildren(@NotNull PsiElement element, @NotNull PsiScopeProcessor processor, @NotNull ResolveState resolveState, @Nullable PsiElement lastParent, @NotNull PsiElement place) {
PsiElement run = lastParent == null ? element.getLastChild() : lastParent.getPrevSibling();
while (run != null) {
ProgressManager.checkCanceled();
if (run instanceof PerlCompositeElement && // fixme this should be in composite
!(run instanceof PerlLexicalScope) && !run.processDeclarations(processor, resolveState, null, place)) {
return false;
}
run = run.getPrevSibling();
}
// checking implicit variables fixme: decide, move processchildren to here or move this one to processDeclarations?
if (element instanceof PerlImplicitVariablesProvider) {
for (PerlVariableDeclarationElement wrapper : ((PerlImplicitVariablesProvider) element).getImplicitVariables()) {
ProgressManager.checkCanceled();
if (!processor.execute(wrapper, resolveState)) {
return false;
}
}
}
return true;
}
use of com.perl5.lang.perl.psi.PerlVariableDeclarationElement 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()));
}
}
}
use of com.perl5.lang.perl.psi.PerlVariableDeclarationElement in project Perl5-IDEA by Camelcade.
the class HTMLMasonFileImpl method processDeclarations.
@Override
public boolean processDeclarations(@NotNull PsiScopeProcessor processor, @NotNull ResolveState state, PsiElement lastParent, @NotNull PsiElement place) {
boolean checkShared = false;
boolean checkArgs = false;
boolean checkInit = false;
boolean checkCode = false;
boolean checkCleanup = false;
PsiElement onceAnchor = null;
PsiElement sharedAnchor = null;
PsiElement argsAnchor = null;
PsiElement initAnchor = null;
PsiElement cleanupAnchor = null;
if (lastParent instanceof HTMLMasonSharedBlockImpl) {
checkShared = true;
sharedAnchor = lastParent;
} else if (lastParent instanceof HTMLMasonArgsBlockImpl) {
checkShared = true;
checkArgs = true;
argsAnchor = lastParent;
} else if (lastParent instanceof HTMLMasonInitBlockImpl) {
checkArgs = true;
checkShared = true;
checkInit = true;
initAnchor = lastParent;
} else if (lastParent instanceof HTMLMasonFilterBlockImpl) {
checkArgs = true;
checkShared = true;
} else if (lastParent instanceof HTMLMasonOnceBlock) {
onceAnchor = lastParent;
} else if (!(lastParent instanceof HTMLMasonSubcomponentDefitnitionImpl || lastParent instanceof HTMLMasonMethodDefinitionImpl)) {
checkArgs = true;
checkShared = true;
checkInit = true;
checkCode = true;
if (// change nature flow
lastParent instanceof HTMLMasonCleanupBlockImpl) {
checkCleanup = true;
cleanupAnchor = lastParent;
lastParent = null;
}
}
if (checkCode) {
if (!processChildren(this, processor, state, lastParent, place)) {
return false;
}
}
if (checkCleanup) {
if (!checkSubblocks(processor, state, place, HTMLMasonCleanupBlock.class, cleanupAnchor)) {
return false;
}
}
if (checkInit) {
if (!checkSubblocks(processor, state, place, HTMLMasonInitBlock.class, initAnchor)) {
return false;
}
}
if (checkArgs) {
if (!checkSubblocks(processor, state, place, HTMLMasonArgsBlock.class, argsAnchor)) {
return false;
}
}
if (checkShared) {
if (!checkSubblocks(processor, state, place, HTMLMasonSharedBlock.class, sharedAnchor)) {
return false;
}
}
if (!checkSubblocks(processor, state, place, HTMLMasonOnceBlock.class, onceAnchor)) {
return false;
}
// implicit variables
for (PerlVariableDeclarationElement wrapper : getImplicitVariables()) {
if (!processor.execute(wrapper, state)) {
return false;
}
}
return false;
}
use of com.perl5.lang.perl.psi.PerlVariableDeclarationElement in project Perl5-IDEA by Camelcade.
the class PerlVariableNameCompletionProvider method fillWithFullQualifiedVariables.
private void fillWithFullQualifiedVariables(@NotNull PsiElement variableNameElement, @NotNull CompletionResultSet resultSet) {
PsiElement perlVariable = variableNameElement.getParent();
Project project = variableNameElement.getProject();
GlobalSearchScope resolveScope = variableNameElement.getResolveScope();
String variableName = variableNameElement.getText();
boolean forceShortMain = StringUtil.startsWith(variableName, PerlPackageUtil.PACKAGE_SEPARATOR);
final CompletionResultSet finalResultSet = resultSet;
Processor<PerlVariableDeclarationElement> scalarDefaultProcessor = wrapper -> {
String fullQualifiedName = wrapper.getFullQualifiedName();
if (fullQualifiedName != null) {
finalResultSet.addElement(PerlVariableCompletionUtil.getScalarLookupElement(adjustName(fullQualifiedName, forceShortMain)));
}
return true;
};
Processor<PerlVariableDeclarationElement> arrayDefaultProcessor = wrapper -> {
String fullQualifiedName = wrapper.getFullQualifiedName();
if (fullQualifiedName != null) {
finalResultSet.addElement(PerlVariableCompletionUtil.getArrayLookupElement(adjustName(fullQualifiedName, forceShortMain)));
}
return true;
};
Processor<PerlVariableDeclarationElement> hashDefaultProcessor = wrapper -> {
String fullQualifiedName = wrapper.getFullQualifiedName();
if (fullQualifiedName != null) {
finalResultSet.addElement(PerlVariableCompletionUtil.getHashLookupElement(adjustName(fullQualifiedName, forceShortMain)));
}
return true;
};
if (perlVariable instanceof PsiPerlScalarVariable) {
PerlScalarUtil.processDefinedGlobalScalars(project, resolveScope, scalarDefaultProcessor);
PerlArrayUtil.processDefinedGlobalArrays(project, resolveScope, wrapper -> {
String fullQualifiedName = wrapper.getFullQualifiedName();
if (fullQualifiedName != null) {
finalResultSet.addElement(PerlVariableCompletionUtil.getArrayElementLookupElement(adjustName(fullQualifiedName, forceShortMain)));
}
return true;
});
PerlHashUtil.processDefinedGlobalHashes(project, resolveScope, wrapper -> {
String fullQualifiedName = wrapper.getFullQualifiedName();
if (fullQualifiedName != null) {
finalResultSet.addElement(PerlVariableCompletionUtil.getHashElementLookupElement(adjustName(fullQualifiedName, forceShortMain)));
}
return true;
});
} else if (perlVariable instanceof PerlGlobVariable) {
PerlScalarUtil.processDefinedGlobalScalars(project, resolveScope, scalarDefaultProcessor);
PerlArrayUtil.processDefinedGlobalArrays(project, resolveScope, arrayDefaultProcessor);
PerlHashUtil.processDefinedGlobalHashes(project, resolveScope, hashDefaultProcessor);
// globs
PerlGlobUtil.processDefinedGlobsNames(project, resolveScope, typeglob -> {
String adjustedName = adjustName(typeglob.getCanonicalName(), forceShortMain);
if (adjustedName != null) {
finalResultSet.addElement(PerlVariableCompletionUtil.getGlobLookupElement(adjustedName));
}
return true;
});
} else if (perlVariable instanceof PsiPerlArrayVariable) {
PerlArrayUtil.processDefinedGlobalArrays(project, resolveScope, arrayDefaultProcessor);
PerlHashUtil.processDefinedGlobalHashes(project, resolveScope, wrapper -> {
String fullQualifiedName = wrapper.getFullQualifiedName();
if (fullQualifiedName != null) {
finalResultSet.addElement(PerlVariableCompletionUtil.getHashSliceLookupElement(adjustName(fullQualifiedName, forceShortMain)));
}
return true;
});
} else if (perlVariable instanceof PsiPerlArrayIndexVariable) {
// global arrays
PerlArrayUtil.processDefinedGlobalArrays(project, resolveScope, arrayDefaultProcessor);
} else if (perlVariable instanceof PsiPerlHashVariable) {
// global hashes
PerlHashUtil.processDefinedGlobalHashes(project, resolveScope, hashDefaultProcessor);
}
}
Aggregations