use of com.jetbrains.php.lang.psi.PhpFile in project yii2support by nvlad.
the class ValidationCompletionProvider method getClassIfInRulesMethod.
@Nullable
private PhpClass getClassIfInRulesMethod(PsiElement position) {
PsiElement elem = position.getParent();
Method currentMethod = null;
PhpClass phpClass = null;
while (true) {
if (elem instanceof Method)
currentMethod = (Method) elem;
else if (elem instanceof PhpClass) {
phpClass = (PhpClass) elem;
break;
} else if (elem instanceof PhpFile)
break;
else if (elem == null) {
break;
}
elem = elem.getParent();
}
if (currentMethod != null && phpClass != null) {
if (ClassUtils.isClassInherit(phpClass, "\\yii\\base\\Model", PhpIndex.getInstance(position.getProject())) && currentMethod.getName().equals("rules")) {
return phpClass;
} else
return null;
} else {
return null;
}
}
Aggregations