當前位置: 首頁>>代碼示例>>Java>>正文


Java PsiDirectory.findFile方法代碼示例

本文整理匯總了Java中com.intellij.psi.PsiDirectory.findFile方法的典型用法代碼示例。如果您正苦於以下問題:Java PsiDirectory.findFile方法的具體用法?Java PsiDirectory.findFile怎麽用?Java PsiDirectory.findFile使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在com.intellij.psi.PsiDirectory的用法示例。


在下文中一共展示了PsiDirectory.findFile方法的7個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: getMagentoName

import com.intellij.psi.PsiDirectory; //導入方法依賴的package包/類
@Override
public String getMagentoName() {
    if (moduleName != null) {
        return moduleName;
    }

    PsiDirectory configurationDir = directory.findSubdirectory(CONFIGURATION_PATH);
    if (configurationDir != null) {
        PsiFile configurationFile = configurationDir.findFile("module.xml");

        if (configurationFile != null && configurationFile instanceof XmlFile) {
            XmlTag rootTag = ((XmlFile) configurationFile).getRootTag();
            if (rootTag != null) {
                XmlTag module = rootTag.findFirstSubTag("module");
                if (module != null && module.getAttributeValue("name") != null) {
                    moduleName = module.getAttributeValue("name");
                    return moduleName;
                }
            }
        }
    }

    return DEFAULT_MODULE_NAME;
}
 
開發者ID:magento,項目名稱:magento2-phpstorm-plugin,代碼行數:25,代碼來源:MagentoComponentManager.java

示例2: resolveImportReference

import com.intellij.psi.PsiDirectory; //導入方法依賴的package包/類
@Nullable
public PsiElement resolveImportReference(QualifiedName name, PyQualifiedNameResolveContext context, boolean withRoots) {
  if (StudyTaskManager.getInstance(context.getProject()).getCourse() == null) {
    return null;
  }
  final String nameString = name.toString();
  PsiFile containingFile = context.getFootholdFile();
  if (containingFile == null) return null;

  final PsiDirectory directory = containingFile.getContainingDirectory();
  if (directory == null) return null;
  final PsiFile file = directory.findFile(nameString + ".py");
  if (file != null) {
    return file;
  }

  return null;
}
 
開發者ID:medvector,項目名稱:educational-plugin,代碼行數:19,代碼來源:PyStudyImportResolver.java

示例3: getMessages

import com.intellij.psi.PsiDirectory; //導入方法依賴的package包/類
@NotNull
static ArrayHashElement[] getMessages(PhpPsiElement element, String category) {
    ArrayList<ArrayHashElement> messages = new ArrayList<>();

    PsiDirectory directory = getDirectory(element);
    if (directory != null) {
        PsiFile file = directory.findFile(category.concat(".php"));
        if (file != null) {
            messages.addAll(loadMessagesFromFile(file));
        }
    }

    return messages.toArray(new ArrayHashElement[messages.size()]);
}
 
開發者ID:nvlad,項目名稱:yii2support,代碼行數:15,代碼來源:Util.java

示例4: findExtEmConf

import com.intellij.psi.PsiDirectory; //導入方法依賴的package包/類
private static VirtualFile findExtEmConf(@NotNull PsiDirectory extensionRootDirectory) {
    PsiFile file = extensionRootDirectory.findFile("ext_emconf.php");
    if (file == null) {
        return null;
    }

    return file.getVirtualFile();
}
 
開發者ID:cedricziel,項目名稱:idea-php-typo3-plugin,代碼行數:9,代碼來源:ExtensionUtility.java

示例5: findComposerManifest

import com.intellij.psi.PsiDirectory; //導入方法依賴的package包/類
private static VirtualFile findComposerManifest(@NotNull PsiDirectory extensionRootDirectory) {
    PsiFile file = extensionRootDirectory.findFile("composer.json");
    if (file == null) {
        return null;
    }

    return file.getVirtualFile();
}
 
開發者ID:cedricziel,項目名稱:idea-php-typo3-plugin,代碼行數:9,代碼來源:ExtensionUtility.java

示例6: getViewFile

import com.intellij.psi.PsiDirectory; //導入方法依賴的package包/類
@Nullable
public static PsiFile getViewFile(PsiElement element) {
    final MethodReference reference = PsiTreeUtil.getParentOfType(element, MethodReference.class);
    if (reference == null) {
        return null;
    }

    final PsiElement[] parameters = reference.getParameters();
    if (parameters.length == 0 || !(parameters[0] instanceof StringLiteralExpression)) {
        return null;
    }

    String view = reference.getUserData(RENDER_VIEW);
    if (!((StringLiteralExpression) parameters[0]).getContents().equals(view)) {
        view = ((StringLiteralExpression) parameters[0]).getContents();
        reference.putUserData(RENDER_VIEW, view);
        reference.putUserData(RENDER_VIEW_FILE, null);
        reference.putUserData(RENDER_VIEW_PATH, null);
    }

    PsiFile file = reference.getUserData(RENDER_VIEW_FILE);
    if (file != null && file.isValid()) {
        if (!file.getVirtualFile().getPath().equals(reference.getUserData(RENDER_VIEW_PATH))) {
            reference.putUserData(RENDER_VIEW_FILE, null);
            reference.putUserData(RENDER_VIEW_PATH, null);
            file = null;
        }
    }

    if (file == null || !file.isValid()) {
        if (reference.getParameters()[0] instanceof StringLiteralExpression) {
            PsiDirectory directory;

            String path = ((StringLiteralExpression) reference.getParameters()[0]).getContents();
            if (path.startsWith("/")) {
                directory = ViewsUtil.getRootDirectory(element);
                path = path.substring(1);
            } else {
                directory = ViewsUtil.getContextDirectory(element);
            }

            String filename;
            if (path.contains("/")) {
                filename = path.substring(path.lastIndexOf('/') + 1);
                path = path.substring(0, path.lastIndexOf('/') + 1);
            } else {
                filename = path;
                path = "";
            }

            while (path.contains("/") && directory != null) {
                final String dirName = path.substring(0, path.indexOf('/'));
                directory = dirName.equals("..") ? directory.getParent() : directory.findSubdirectory(dirName);
                path = path.substring(path.indexOf('/') + 1);
            }

            if (directory == null) {
                return null;
            }

            if (filename.contains(".")) {
                file = directory.findFile(filename);
            } else {
                file = directory.findFile(filename + ".php");
                if (file == null) {
                    file = directory.findFile(filename + ".twig");
                }
                if (file == null) {
                    file = directory.findFile(filename + ".tpl");
                }
            }

            if (file != null) {
                reference.putUserData(RENDER_VIEW_FILE, file);
                reference.putUserData(RENDER_VIEW_PATH, file.getVirtualFile().getPath());
            }
        }
    }

    return file;
}
 
開發者ID:nvlad,項目名稱:yii2support,代碼行數:82,代碼來源:ViewsUtil.java

示例7: findExtEmConfPsiFile

import com.intellij.psi.PsiDirectory; //導入方法依賴的package包/類
private static PsiFile findExtEmConfPsiFile(@NotNull PsiDirectory extensionRootDirectory) {
    return extensionRootDirectory.findFile("ext_emconf.php");
}
 
開發者ID:cedricziel,項目名稱:idea-php-typo3-plugin,代碼行數:4,代碼來源:ExtensionUtility.java


注:本文中的com.intellij.psi.PsiDirectory.findFile方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。