本文整理汇总了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);
}
示例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;
};
}
示例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;
};
}
示例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;
}
示例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);
}
}
}
示例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;
}
示例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;
}
示例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;
}
示例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()]);
}
示例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);
}
}
}
示例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());
}
}
}
}
示例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;
}
示例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;
};
}
示例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;
};
}
示例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;
};
}