当前位置: 首页>>代码示例>>Java>>正文


Java PhpPsiUtil.findClass方法代码示例

本文整理汇总了Java中com.jetbrains.php.lang.psi.PhpPsiUtil.findClass方法的典型用法代码示例。如果您正苦于以下问题:Java PhpPsiUtil.findClass方法的具体用法?Java PhpPsiUtil.findClass怎么用?Java PhpPsiUtil.findClass使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在com.jetbrains.php.lang.psi.PhpPsiUtil的用法示例。


在下文中一共展示了PhpPsiUtil.findClass方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: applyFix

import com.jetbrains.php.lang.psi.PhpPsiUtil; //导入方法依赖的package包/类
@Override
public void applyFix(@NotNull Project project, @NotNull ProblemDescriptor problemDescriptor) {
    PsiElement element = problemDescriptor.getPsiElement();
    if (element instanceof PhpFile) {
        PhpFile phpFile = (PhpFile) element;
        VirtualFile virtualFile = phpFile.getVirtualFile();
        String oldName = virtualFile.getNameWithoutExtension();
        String newName = oldName + "Test";

        PhpClass phpClass = PhpPsiUtil.findClass(phpFile, checkedClass -> checkedClass.getName().equals(oldName));
        if (phpClass != null) {
            phpClass.setName(newName);
        }

        try {
            virtualFile.rename(this, newName + "." + virtualFile.getExtension());

        } catch (IOException e) {
            LOG.error(e);
        }
    }
}
 
开发者ID:jiripudil,项目名称:intellij-nette-tester,代码行数:23,代码来源:TestFileNameInspection.java

示例2: setupConfigurationFromContext

import com.jetbrains.php.lang.psi.PhpPsiUtil; //导入方法依赖的package包/类
@Override
protected boolean setupConfigurationFromContext(TesterRunConfiguration runConfiguration, ConfigurationContext configurationContext, Ref<PsiElement> ref) {
    PsiElement location = configurationContext.getPsiLocation();
    if (location instanceof PsiDirectory) {
        PsiDirectory directory = (PsiDirectory) location;
        runConfiguration.getSettings().setTestScope(directory.getVirtualFile().getPresentableUrl());
        runConfiguration.setGeneratedName(runConfiguration.suggestedName());
        ref.set(directory);
        return true;
    }

    if (location instanceof PhpFile) {
        PhpFile phpFile = (PhpFile) location;
        PhpClass testClass = PhpPsiUtil.findClass(phpFile, TesterUtil::isTestClass);
        if (testClass == null) {
            return false;
        }

        runConfiguration.getSettings().setTestScope(phpFile.getVirtualFile().getPresentableUrl());
        runConfiguration.setGeneratedName(runConfiguration.suggestedName());
        ref.set(phpFile);
        return true;
    }

    return false;
}
 
开发者ID:jiripudil,项目名称:intellij-nette-tester,代码行数:27,代码来源:TesterRunConfigurationProducer.java

示例3: getBundleClassInDirectory

import com.jetbrains.php.lang.psi.PhpPsiUtil; //导入方法依赖的package包/类
@Nullable
public static PhpClass getBundleClassInDirectory(@NotNull PsiDirectory bundleDirContext) {

    for (PsiFile psiFile : bundleDirContext.getFiles()) {

        if(!(psiFile instanceof PhpFile)) {
            continue;
        }

        PhpClass aClass = PhpPsiUtil.findClass((PhpFile) psiFile, phpClass ->
            PhpElementsUtil.isInstanceOf(phpClass, "\\Symfony\\Component\\HttpKernel\\Bundle\\BundleInterface")
        );

        if(aClass != null) {
            return aClass;
        }

    }

    return null;
}
 
开发者ID:Haehnchen,项目名称:idea-php-symfony2-plugin,代码行数:22,代码来源:BundleClassGeneratorUtil.java

示例4: buildVisitor

import com.jetbrains.php.lang.psi.PhpPsiUtil; //导入方法依赖的package包/类
@NotNull
@Override
public PsiElementVisitor buildVisitor(@NotNull ProblemsHolder holder, boolean isOnTheFly) {
    return new PhpElementVisitor() {
        @Override
        public void visitPhpFile(PhpFile phpFile) {
            PhpClass testClass = PhpPsiUtil.findClass(phpFile, TesterUtil::isTestClass);
            if (testClass != null && ! hasValidName(phpFile.getVirtualFile())) {
                holder.registerProblem(phpFile, TesterBundle.message("inspections.fileName.description"), CHANGE_EXTENSION_TO_PHPT_QUICK_FIX, ADD_TEST_SUFFIX_QUICK_FIX);
            }
        }
    };
}
 
开发者ID:jiripudil,项目名称:intellij-nette-tester,代码行数:14,代码来源:TestFileNameInspection.java

示例5: findClass

import com.jetbrains.php.lang.psi.PhpPsiUtil; //导入方法依赖的package包/类
@Nullable
static PhpClass findClass(PsiFile psiFile) {
    if (psiFile instanceof PhpFile) {
        PhpClass phpClass = PhpPsiUtil.findClass((PhpFile) psiFile, Conditions.alwaysTrue());
        if (phpClass != null && !TesterUtil.isTestClass(phpClass)) {
            return phpClass;
        }
    }

    return null;
}
 
开发者ID:jiripudil,项目名称:intellij-nette-tester,代码行数:12,代码来源:TesterTestCreator.java

示例6: actionPerformed

import com.jetbrains.php.lang.psi.PhpPsiUtil; //导入方法依赖的package包/类
@Override
public void actionPerformed(AnActionEvent event) {
    Project project = getEventProject(event);
    if(project == null) {
        return;
    }

    PsiDirectory bundleDirContext = BundleClassGeneratorUtil.getBundleDirContext(event);
    if(bundleDirContext == null) {
        return;
    }

    PsiFile data = CommonDataKeys.PSI_FILE.getData(event.getDataContext());
    if(!(data instanceof PhpFile)) {
        return;
    }

    String relativePath = VfsUtil.getRelativePath(data.getVirtualFile(), bundleDirContext.getVirtualFile());
    if(relativePath == null) {
        return;
    }

    PhpClass aClass = PhpPsiUtil.findClass((PhpFile) data, Conditions.alwaysTrue());
    if(aClass == null) {
        return;
    }

    int i = relativePath.lastIndexOf(".");
    final String className = "Tests\\" + relativePath.substring(0, i).replace("/", "\\") + "Test";

    final PhpClass phpClass = BundleClassGeneratorUtil.getBundleClassInDirectory(bundleDirContext);
    if(phpClass == null) {
        return;
    }


    new WriteCommandAction(project) {
        @Override
        protected void run(@NotNull Result result) throws Throwable {
            PsiElement file = null;
            try {
                file = PhpBundleFileFactory.createBundleFile(phpClass, "web_test_case", className, new HashMap<>());
            } catch (Exception e) {
                JOptionPane.showMessageDialog(null, "Error:" + e.getMessage());
            }

            if(file != null) {
                new OpenFileDescriptor(getProject(), file.getContainingFile().getVirtualFile(), 0).navigate(true);
            }
        }

        @Override
        public String getGroupID() {
            return "Create Symfony WebTestFile";
        }
    }.execute();

}
 
开发者ID:Haehnchen,项目名称:idea-php-symfony2-plugin,代码行数:59,代码来源:WebTestCaseGeneratorAction.java


注:本文中的com.jetbrains.php.lang.psi.PhpPsiUtil.findClass方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。