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


Java PhpFile类代码示例

本文整理汇总了Java中com.jetbrains.php.lang.psi.PhpFile的典型用法代码示例。如果您正苦于以下问题:Java PhpFile类的具体用法?Java PhpFile怎么用?Java PhpFile使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。


PhpFile类属于com.jetbrains.php.lang.psi包,在下文中一共展示了PhpFile类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: getViewVariables

import com.jetbrains.php.lang.psi.PhpFile; //导入依赖的package包/类
@NotNull
public static ArrayList<String> getViewVariables(PsiFile psiFile) {
    ArrayList<String> result = null;

    Long viewModified = psiFile.getUserData(VIEW_FILE_MODIFIED);
    if (viewModified != null && psiFile.getModificationStamp() == viewModified) {
        result = psiFile.getUserData(VIEW_VARIABLES);
    }

    if (result == null) {
        if (psiFile instanceof PhpFile) {
            result = getPhpViewVariables(psiFile);
        }

        if (result == null) {
            result = new ArrayList<>();
        }

        psiFile.putUserData(VIEW_VARIABLES, result);
        psiFile.putUserData(VIEW_FILE_MODIFIED, psiFile.getModificationStamp());
    }

    return new ArrayList<>(result);
}
 
开发者ID:nvlad,项目名称:yii2support,代码行数:25,代码来源:ViewsUtil.java

示例2: getIndexer

import com.jetbrains.php.lang.psi.PhpFile; //导入依赖的package包/类
@NotNull
@Override
public DataIndexer<String, Set<String>, FileContent> getIndexer() {

    return inputData -> {

        final Map<String, Set<String>> map = new THashMap<>();

        PsiFile psiFile = inputData.getPsiFile();

        if (psiFile instanceof PhpFile) {
            Map<String, ArrayList<TYPO3ServiceDefinition>> serviceMap = new THashMap<>();
            psiFile.accept(new CoreServiceDefinitionParserVisitor(serviceMap));

            serviceMap.forEach((serviceId, definitionList) -> {
                Set<String> implementations = new HashSet<>();
                definitionList.forEach(typo3ServiceDefinition -> implementations.add(typo3ServiceDefinition.getClassName()));
                map.put(serviceId, implementations);
            });
        }

        return map;
    };
}
 
开发者ID:cedricziel,项目名称:idea-php-typo3-plugin,代码行数:25,代码来源:CoreServiceMapStubIndex.java

示例3: getIndexer

import com.jetbrains.php.lang.psi.PhpFile; //导入依赖的package包/类
@NotNull
@Override
public DataIndexer<String, Void, FileContent> getIndexer() {
    return inputData -> {
        Map<String, Void> map = new HashMap<>();
        PsiFile psiFile = inputData.getPsiFile();

        if (!Settings.isEnabled(psiFile.getProject())) {
            return map;
        }

        if (psiFile instanceof PhpFile) {
            grabEventNamesFromPhpFile((PhpFile) psiFile, map);
        } else if (psiFile instanceof XmlFile) {
            grabEventNamesFromXmlFile((XmlFile) psiFile, map);
        }

        return map;
    };
}
 
开发者ID:magento,项目名称:magento2-phpstorm-plugin,代码行数:21,代码来源:EventNameIndex.java

示例4: getReferencesByElement

import com.jetbrains.php.lang.psi.PhpFile; //导入依赖的package包/类
@NotNull
@Override
public PsiReference[] getReferencesByElement(@NotNull PsiElement element, @NotNull ProcessingContext context) {
    String value = StringUtil.unquoteString(element.getText());
    Collection<VirtualFile> containingFiles = FileBasedIndex.getInstance()
        .getContainingFiles(EventNameIndex.KEY, value,
                GlobalSearchScope.getScopeRestrictedByFileTypes(
                        GlobalSearchScope.allScope(element.getProject()),
                        PhpFileType.INSTANCE
                )
        );

    PsiManager psiManager = PsiManager.getInstance(element.getProject());
    for (VirtualFile virtualFile: containingFiles) {
        PhpFile phpFile = (PhpFile) psiManager.findFile(virtualFile);
        if (phpFile != null) {
            List<PsiElement> psiElements = new ArrayList<>();
            recursiveFill(psiElements, phpFile, value);
            if (psiElements.size() > 0) {
                return new PsiReference[] {new PolyVariantReferenceBase(element, psiElements)};
            }
        }
    }
    return PsiReference.EMPTY_ARRAY;
}
 
开发者ID:magento,项目名称:magento2-phpstorm-plugin,代码行数:26,代码来源:EventNameReferenceProvider.java

示例5: applyFix

import com.jetbrains.php.lang.psi.PhpFile; //导入依赖的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 newName = virtualFile.getNameWithoutExtension() + ".phpt";

        try {
            virtualFile.rename(this, newName);

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

示例6: setupConfigurationFromContext

import com.jetbrains.php.lang.psi.PhpFile; //导入依赖的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

示例7: getSwitchClass

import com.jetbrains.php.lang.psi.PhpFile; //导入依赖的package包/类
@Nullable
protected PhpClass getSwitchClass(final AnActionEvent e) {
    Object psiFile = e.getData(PlatformDataKeys.PSI_FILE);

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

    if (!(psiFile instanceof PhpFile)) {
        return null;
    }
    PhpFile phpFile = ((PhpFile) psiFile);
    PhpClass testedClass = getSwitchClass(e.getProject(), phpFile);

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

    return testedClass;
}
 
开发者ID:atoum,项目名称:phpstorm-plugin,代码行数:21,代码来源:SwitchContext.java

示例8: getCurrentTestClass

import com.jetbrains.php.lang.psi.PhpFile; //导入依赖的package包/类
@Nullable
protected PhpClass getCurrentTestClass(AnActionEvent e) {
    Object psiFile = e.getData(PlatformDataKeys.PSI_FILE);

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

    if (!(psiFile instanceof PhpFile)) {
        return null;
    }
    PhpFile phpFile = ((PhpFile) psiFile);

    PhpClass currentClass = Utils.getFirstClassFromFile(phpFile);
    if (null == currentClass) {
        return null;
    }

    if (!Utils.isClassAtoumTest(currentClass)) {
        return Utils.locateTestClass(e.getProject(), currentClass);
    }

    return currentClass;
}
 
开发者ID:atoum,项目名称:phpstorm-plugin,代码行数:25,代码来源:Run.java

示例9: buildFoldRegions

import com.jetbrains.php.lang.psi.PhpFile; //导入依赖的package包/类
@NotNull
@Override
public FoldingDescriptor[] buildFoldRegions(@NotNull PsiElement psiElement, @NotNull Document document, boolean b) {
    if (!(psiElement instanceof PhpFile)) {
        return new FoldingDescriptor[0];
    }
    List<FoldingDescriptor> descriptors = new ArrayList<>();
    Collection<PhpDocCommentImpl> phpDocs = PsiTreeUtil.findChildrenOfType(psiElement, PhpDocCommentImpl.class);

    for (Object phpDoc1 : phpDocs) {
        PhpDocCommentImpl phpDoc = (PhpDocCommentImpl) phpDoc1;
        this.attachBlockShortcuts(descriptors, phpDoc);
    }

    return descriptors.toArray(new FoldingDescriptor[descriptors.size()]);
}
 
开发者ID:thanosp,项目名称:phpstorm-inheritdoc,代码行数:17,代码来源:InheritDocFoldingBuilder.java

示例10: fillResolveResults

import com.jetbrains.php.lang.psi.PhpFile; //导入依赖的package包/类
@Override
public void fillResolveResults(PsiElement psiElement, List<ResolveResult> results, String typeName) {
    Collection<VirtualFile> containingFiles = FileBasedIndex
        .getInstance()
        .getContainingFiles(
            EventsDeclarationsFileBasedIndex.NAME,
            typeName,
            GlobalSearchScope.allScope(psiElement.getProject())
        );

    PsiManager psiManager = PsiManager.getInstance(psiElement.getProject());
    for (VirtualFile virtualFile: containingFiles) {
        PhpFile phpFile = (PhpFile)psiManager.findFile(virtualFile);
        if (phpFile != null) {
            recursiveFill(results, phpFile, typeName);
        }
    }
}
 
开发者ID:dkvashninbay,项目名称:magento2plugin,代码行数:19,代码来源:EventsDeclarationsFilesResultsFiller.java

示例11: addExtendsClasses

import com.jetbrains.php.lang.psi.PhpFile; //导入依赖的package包/类
/**
 *
 * We support "extends" on module metadata
 *
 * TODO: use index, this in a performance issue
 */
private void addExtendsClasses(Project project, String parameter, Collection<PhpClass> phpClasses) {

    for (Map.Entry<String, Set<VirtualFile>> entry : ModuleUtil.getExtendsList(project).entrySet()) {

        // ignore cases, so we need an each
        if(!entry.getKey().equalsIgnoreCase(parameter)) {
            continue;
        }

        for (VirtualFile virtualFile : entry.getValue()) {

            PsiFile file = PsiManager.getInstance(project).findFile(virtualFile);
            if (!(file instanceof PhpFile)) {
                continue;
            }

            Collection<PhpClass> allClasses = PhpPsiUtil.findAllClasses((PhpFile) file);
            if (allClasses.size() > 0) {
                phpClasses.add(allClasses.iterator().next());
            }

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

示例12: getFileUseImports

import com.jetbrains.php.lang.psi.PhpFile; //导入依赖的package包/类
/**
 * Returns a map with php use imports
 *
 * @param psiFile Instance of file, should be PHP
 * @return Mapping of short names to the FQN
 */
public static Map<String, String> getFileUseImports(PsiFile psiFile) {

    // search for use alias in local file
    final Map<String, String> useImports = new HashMap<String, String>();

    if (psiFile instanceof PhpFile) {
        for (final PhpNamedElement element : ((PhpFile) psiFile).getTopLevelDefs().values()) {
            if (element instanceof PhpUse) {
                final PhpUse phpUse = (PhpUse) element;
                String alias = phpUse.getAliasName();
                if(alias != null) {
                    useImports.put(alias, phpUse.getFQN());
                } else {
                    useImports.put(phpUse.getName(), phpUse.getFQN());
                }
            }
        }
    }

    return useImports;
}
 
开发者ID:goaop,项目名称:idea-plugin,代码行数:28,代码来源:PluginUtil.java

示例13: getIndexer

import com.jetbrains.php.lang.psi.PhpFile; //导入依赖的package包/类
@NotNull
@Override
public DataIndexer<String, Void, FileContent> getIndexer() {
    return fileContent -> {

        final Map<String, Void> map = new THashMap<>();

        PsiFile psiFile = fileContent.getPsiFile();
        if(!(psiFile instanceof PhpFile)) {
            return map;
        }

        String namespace = TranslationUtil.getNamespaceFromFilePath(fileContent.getFile().getPath());
        if(namespace == null) {
            return map;
        }

        psiFile.acceptChildren(new ArrayReturnPsiRecursiveVisitor(
            namespace, (key, psiKey, isRootElement) -> map.put(key, null))
        );

        return map;
    };
}
 
开发者ID:Haehnchen,项目名称:idea-php-laravel-plugin,代码行数:25,代码来源:TranslationKeyStubIndex.java

示例14: getIndexer

import com.jetbrains.php.lang.psi.PhpFile; //导入依赖的package包/类
@NotNull
@Override
public DataIndexer<String, Void, FileContent> getIndexer() {
    return fileContent -> {
        final Map<String, Void> map = new THashMap<>();
        PsiFile psiFile = fileContent.getPsiFile();

        if(!(psiFile instanceof PhpFile)) {
            return map;
        }

        psiFile.acceptChildren(new BladeCustomDirectivesVisitor(hit -> map.put(hit.second, null)));

        return map;
    };
}
 
开发者ID:Haehnchen,项目名称:idea-php-laravel-plugin,代码行数:17,代码来源:BladeCustomDirectivesStubIndex.java

示例15: getIndexer

import com.jetbrains.php.lang.psi.PhpFile; //导入依赖的package包/类
@NotNull
@Override
public DataIndexer<String, Void, FileContent> getIndexer() {
    return fileContent -> {
        final Map<String, Void> map = new THashMap<>();

        PsiFile psiFile = fileContent.getPsiFile();
        if(!(psiFile instanceof PhpFile)) {
            return map;
        }

        ConfigFileUtil.ConfigFileMatchResult result = ConfigFileUtil.matchConfigFile(fileContent.getProject(), fileContent.getFile());

        // config/app.php
        // config/testing/app.php
        if(result.matches()) {
            psiFile.acceptChildren(new ArrayReturnPsiRecursiveVisitor(result.getKeyPrefix(), (key, psiKey, isRootElement) -> {
                if (!isRootElement) {
                    map.put(key, null);
                }
            }));
        }

        return map;
    };
}
 
开发者ID:Haehnchen,项目名称:idea-php-laravel-plugin,代码行数:27,代码来源:ConfigKeyStubIndex.java


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