本文整理匯總了Java中com.intellij.psi.PsiDirectory.equals方法的典型用法代碼示例。如果您正苦於以下問題:Java PsiDirectory.equals方法的具體用法?Java PsiDirectory.equals怎麽用?Java PsiDirectory.equals使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類com.intellij.psi.PsiDirectory
的用法示例。
在下文中一共展示了PsiDirectory.equals方法的1個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。
示例1: bindToElement
import com.intellij.psi.PsiDirectory; //導入方法依賴的package包/類
@Override
public PsiElement bindToElement(@NotNull PsiElement element) throws IncorrectOperationException {
final StringLiteralExpression string = (StringLiteralExpression) this.getElement();
final PsiDirectory context = ViewsUtil.getContextDirectory(string);
final PsiFile file = (PsiFile) element;
final PsiElement newValue;
String fileName = string.getContents();
if (fileName.contains("/")) {
fileName = fileName.substring(fileName.lastIndexOf('/') + 1);
}
if (!file.getContainingDirectory().equals(context)) {
final PsiDirectory root = ViewsUtil.getRootDirectory(string);
if (root == null) {
return null;
}
PsiDirectory dir = file.getContainingDirectory();
while (dir != null && !(dir.equals(root) || dir.equals(context))) {
fileName = dir.getName() + "/" + fileName;
dir = dir.getParent();
}
if (dir == null) {
return null;
}
if (dir.equals(root)) {
fileName = "/" + fileName;
}
}
fileName = string.isSingleQuote() ? "'" + fileName + "'" : "\"" + fileName + "\"";
newValue = PhpPsiElementFactory.createFromText(element.getProject(), StringLiteralExpression.class, fileName);
if (newValue != null) {
string.replace(newValue);
}
for (MethodReference reference : PsiTreeUtil.findChildrenOfType(file, MethodReference.class)) {
if (reference.getName() != null && ArrayUtil.contains(reference.getName(), ViewsUtil.renderMethods)) {
reference.putUserData(ViewsUtil.RENDER_VIEW_FILE, null);
}
}
return newValue;
}