当前位置: 首页>>代码示例>>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;未经允许,请勿转载。