use of com.intellij.coldFusion.model.psi.impl.CfmlFunctionImpl in project intellij-plugins by JetBrains.
the class CfmlUnitQualifiedNameLocationProvider method findElement.
@Nullable
private static PsiElement findElement(String link, Project project) {
String[] location = link.split("::");
int tokensNumber = location.length;
if (tokensNumber <= 0 || tokensNumber > 3) {
return null;
}
PsiElement result;
String filePath = location[0];
VirtualFile virtualFile = LocalFileSystem.getInstance().findFileByPath(filePath);
if (virtualFile != null) {
result = PsiManager.getInstance(project).findFile(virtualFile);
if (result == null || !(result instanceof CfmlFile)) {
return null;
}
// TODO: to move to index
final CfmlTag[] tags = PsiTreeUtil.getChildrenOfType(result, CfmlTag.class);
if (tags == null || tags.length == 0) {
return result;
}
for (CfmlTag tag : tags) {
if ("cfcomponent".equals(tag.getTagName().toLowerCase(Locale.ENGLISH))) {
result = tag;
break;
}
}
} else {
return null;
}
if (tokensNumber > 1) {
String functionName = location[1];
final CfmlTagFunctionImpl[] functions = PsiTreeUtil.getChildrenOfType(result, CfmlTagFunctionImpl.class);
if (functions != null) {
for (CfmlTagFunctionImpl function : functions) {
if (functionName.equals(function.getName())) {
result = function.getNavigationElement();
break;
}
}
}
final CfmlFunctionImpl[] scriptFunctions = PsiTreeUtil.getChildrenOfType(result, CfmlFunctionImpl.class);
if (scriptFunctions != null) {
for (CfmlFunctionImpl function : scriptFunctions) {
if (functionName.equals(function.getName())) {
result = function.getNavigationElement();
break;
}
}
}
}
return result;
}
Aggregations