use of com.jetbrains.php.lang.psi.elements.PhpContinue in project phpinspectionsea by kalessil.
the class SwitchContinuationInLoopInspector method buildVisitor.
@Override
@NotNull
public PsiElementVisitor buildVisitor(@NotNull final ProblemsHolder holder, boolean isOnTheFly) {
return new BasePhpElementVisitor() {
@Override
public void visitPhpContinue(@NotNull PhpContinue continueStatement) {
/* check if continue already defined with desired level */
if (null != continueStatement.getFirstPsiChild()) {
return;
}
boolean isSwitch = false;
PsiElement objParent = continueStatement.getParent();
while (null != objParent) {
/* reached file or callable */
if (objParent instanceof PhpFile || objParent instanceof Function) {
return;
}
/* check if should operate on loop-switch-continue analysis */
if (!isSwitch && objParent instanceof PhpSwitch) {
isSwitch = true;
}
/* when met a loop, complete analysis */
if (OpenapiTypesUtil.isLoop(objParent)) {
if (isSwitch) {
holder.registerProblem(continueStatement, MessagesPresentationUtil.prefixWithEa(message), ProblemHighlightType.GENERIC_ERROR, new UseContinue2LocalFix());
}
return;
}
objParent = objParent.getParent();
}
}
};
}
Aggregations