本文整理汇总了Java中com.jetbrains.php.lang.PhpFileType类的典型用法代码示例。如果您正苦于以下问题:Java PhpFileType类的具体用法?Java PhpFileType怎么用?Java PhpFileType使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
PhpFileType类属于com.jetbrains.php.lang包,在下文中一共展示了PhpFileType类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: testCompletionField
import com.jetbrains.php.lang.PhpFileType; //导入依赖的package包/类
public void testCompletionField() {
myFixture.configureByText(PhpFileType.INSTANCE, "<?php \n" +
" use yii\\base\\Model; \n" +
" class ContactForm extends Model {\n" +
" public $name;\n" +
" public $email;\n" +
" public $address;\n" +
" public function rules() {\n" +
" return [\n" +
" [\n" +
" ['name', 'email', 'subject', 'body'], 'required'],\n" +
" ['<caret>']\n" +
" ];\n" +
" }\n" +
" }");
myFixture.completeBasic();
assertEquals(3, myFixture.getLookupElementStrings().size());
}
示例2: testCompletionField2
import com.jetbrains.php.lang.PhpFileType; //导入依赖的package包/类
public void testCompletionField2() {
myFixture.configureByText(PhpFileType.INSTANCE, "<?php \n" +
" use yii\\base\\Model; \n" +
" class ContactForm extends Model {\n" +
" public $name;\n" +
" public $email;\n" +
" public $address;\n" +
" public function rules() {\n" +
" return [\n" +
" [\n" +
" ['name', 'email', 'subject', 'body'], 'required'],\n" +
" [['name', '<caret>']]\n" +
" ];\n" +
" }\n" +
" }");
myFixture.completeBasic();
assertEquals(3, myFixture.getLookupElementStrings().size());
}
示例3: testCompletionValidators
import com.jetbrains.php.lang.PhpFileType; //导入依赖的package包/类
public void testCompletionValidators() {
myFixture.configureByText(PhpFileType.INSTANCE, "<?php \n" +
" use yii\\base\\Model; \n" +
" class ContactForm extends Model {\n" +
" public $name;\n" +
" public $email;\n" +
" public function rules() {\n" +
" return [\n" +
" [\n" +
" ['name', 'email', 'subject', 'body'], 'required'],\n" +
" [['name'], '<caret>']\n" +
" ];\n" +
" }\n" +
" function validateCompany() {" +
"}" +
" }");
myFixture.completeBasic();
assertEquals(2, myFixture.getLookupElementStrings().size());
}
示例4: testCompletionValidatorParams
import com.jetbrains.php.lang.PhpFileType; //导入依赖的package包/类
public void testCompletionValidatorParams() {
myFixture.configureByText(PhpFileType.INSTANCE, "<?php \n" +
" use yii\\base\\Model; \n" +
" class ContactForm extends Model {\n" +
" public $name;\n" +
" public $email;\n" +
" public function rules() {\n" +
" return [\n" +
" [\n" +
" ['name', 'email', 'subject', 'body'], 'required'],\n" +
" [['name'], 'test', '<caret>']\n" +
" ];\n" +
" }\n" +
" function validateCompany() {" +
"}" +
" }");
myFixture.completeBasic();
assertEquals(5, myFixture.getLookupElementStrings().size());
}
示例5: fromTemplate
import com.jetbrains.php.lang.PhpFileType; //导入依赖的package包/类
/**
* @param templateFile Name of the generated file
* @param destinationPath Relative path to the target file system entry
* @param extensionDefinition Extension definition containing all relevant metadata
* @param context Template Context variables
* @param project Project in context
*/
public static PsiElement fromTemplate(@NotNull String templateFile, @NotNull String destinationPath, @NotNull String destinationFileName, @NotNull TYPO3ExtensionDefinition extensionDefinition, @NotNull Map<String, String> context, Project project) {
String template = readTemplateToString(templateFile, context);
VirtualFile targetDirectory = getOrCreateDestinationPath(extensionDefinition.getRootDirectory(), destinationPath);
LanguageFileType fileType = FileTypes.PLAIN_TEXT;
if (templateFile.endsWith(".php")) {
fileType = PhpFileType.INSTANCE;
}
PsiFile fileFromText = PsiFileFactory.getInstance(project).createFileFromText(destinationFileName, fileType, template);
CodeStyleManager.getInstance(project).reformat(fileFromText);
return PsiDirectoryFactory
.getInstance(project)
.createDirectory(targetDirectory)
.add(fileFromText);
}
示例6: collectServices
import com.jetbrains.php.lang.PhpFileType; //导入依赖的package包/类
private void collectServices(Project project) {
FileBasedIndex index = FileBasedIndex.getInstance();
Collection<VirtualFile> containingFiles = index.getContainingFiles(
FileTypeIndex.NAME,
PhpFileType.INSTANCE,
GlobalSearchScope.allScope(project)
);
containingFiles.removeIf(virtualFile -> !(virtualFile.getName().contains("ext_localconf.php")));
for (VirtualFile projectFile : containingFiles) {
PsiFile psiFile = PsiManager.getInstance(project).findFile(projectFile);
if (psiFile != null) {
psiFile.accept(new CoreServiceDefinitionParserVisitor(serviceMap));
}
}
}
示例7: testReferenceCanResolveDefinition
import com.jetbrains.php.lang.PhpFileType; //导入依赖的package包/类
public void testReferenceCanResolveDefinition() {
PsiFile file = myFixture.configureByText(PhpFileType.INSTANCE, "<?php \n" +
"class ActionController {" +
"public function action() {" +
" $this->forward('<caret>baz');" +
"}" +
"}"
);
PsiElement elementAtCaret = file.findElementAt(myFixture.getCaretOffset()).getParent();
PsiReference[] references = elementAtCaret.getReferences();
for (PsiReference reference : references) {
if (reference instanceof ControllerActionReference) {
ResolveResult[] resolveResults = ((ControllerActionReference) reference).multiResolve(false);
for (ResolveResult resolveResult : resolveResults) {
assertInstanceOf(resolveResult.getElement(), Method.class);
return;
}
}
}
fail("No TranslationReference found");
}
示例8: testCanCreateTranslationReferencesOnPhpStrings
import com.jetbrains.php.lang.PhpFileType; //导入依赖的package包/类
public void testCanCreateTranslationReferencesOnPhpStrings() {
PsiFile file = myFixture.configureByText(PhpFileType.INSTANCE, "<?php \n" +
"class ActionController {" +
"public function action() {" +
" $this->forward('<caret>baz');" +
"}" +
"}"
);
PsiElement elementAtCaret = file.findElementAt(myFixture.getCaretOffset()).getParent();
PsiReference[] references = elementAtCaret.getReferences();
for (PsiReference reference : references) {
if (reference instanceof ControllerActionReference) {
return;
}
}
fail("No ControllerActionReference found");
}
示例9: testResourcesAreIndexed
import com.jetbrains.php.lang.PhpFileType; //导入依赖的package包/类
public void testResourcesAreIndexed() {
myFixture.addFileToProject("typo3conf/ext/foo/bar.php", "");
myFixture.addFileToProject("typo3/sysext/baz/bar.png", "");
myFixture.configureByText(PhpFileType.INSTANCE, "<?php \n" +
"echo 'EXT:<caret>';");
myFixture.completeBasic();
List<String> lookupElementStrings = myFixture.getLookupElementStrings();
if (lookupElementStrings == null) {
fail("Could not complete");
}
assertContainsElements(lookupElementStrings, "EXT:foo/bar.php");
assertContainsElements(lookupElementStrings, "EXT:baz/bar.png");
}
示例10: testResourceReferencesAreCreated
import com.jetbrains.php.lang.PhpFileType; //导入依赖的package包/类
public void testResourceReferencesAreCreated() {
myFixture.addFileToProject("foo/ext_emconf.php", "");
myFixture.configureByText(PhpFileType.INSTANCE, "<?php \n" +
"'EXT:foo/ext_emconf.php<caret>';");
PsiElement elementAtCaret = myFixture.getFile().findElementAt(myFixture.getCaretOffset()).getParent();
PsiReference[] references = elementAtCaret.getReferences();
for (PsiReference ref : references) {
if (ref instanceof ResourceReference) {
return;
}
}
fail("No resource reference.");
}
示例11: testReferenceCanResolveDefinition
import com.jetbrains.php.lang.PhpFileType; //导入依赖的package包/类
public void testReferenceCanResolveDefinition() {
PsiFile file = myFixture.configureByText(PhpFileType.INSTANCE, "<?php \n" +
"\"LLL:EXT:foo/sample.xlf:sys_<caret>language.language_isocode.ab\";");
PsiElement elementAtCaret = file.findElementAt(myFixture.getCaretOffset()).getParent();
PsiReference[] references = elementAtCaret.getReferences();
for (PsiReference reference : references) {
if (reference instanceof TranslationReference) {
ResolveResult[] resolveResults = ((TranslationReference) reference).multiResolve(false);
for (ResolveResult resolveResult : resolveResults) {
assertInstanceOf(resolveResult.getElement(), XmlTag.class);
return;
}
}
}
fail("No TranslationReference found");
}
示例12: testReferenceCanResolveVariants
import com.jetbrains.php.lang.PhpFileType; //导入依赖的package包/类
public void testReferenceCanResolveVariants() {
PsiFile file = myFixture.configureByText(PhpFileType.INSTANCE, "<?php \n" +
"\"LLL:EXT:foo/sample.xlf:sys_<caret>language.language_isocode.ab\";");
PsiElement elementAtCaret = file.findElementAt(myFixture.getCaretOffset()).getParent();
PsiReference[] references = elementAtCaret.getReferences();
for (PsiReference reference : references) {
if (reference instanceof TranslationReference) {
Object[] variants = reference.getVariants();
for (Object variant : variants) {
if (variant instanceof LookupElement) {
String lookupString = ((LookupElement) variant).getLookupString();
assertEquals("LLL:EXT:foo/sample.xlf:sys_language.language_isocode.ab", lookupString);
return;
}
}
}
}
fail("No TranslationReference found");
}
示例13: findViewVfsByModuleName
import com.jetbrains.php.lang.PhpFileType; //导入依赖的package包/类
public static Collection<VirtualFile> findViewVfsByModuleName(String moduleName, Project project)
{
Collection<VirtualFile> viewVfs = new ArrayList<>();
Pattern pattern = Pattern.compile(RegExUtil.Magento.MODULE_NAME);
Matcher matcher = pattern.matcher(moduleName);
if (!matcher.find()) {
return viewVfs;
}
Collection<VirtualFile> moduleVfs =
FileBasedIndex.getInstance().getContainingFiles(ModuleNameIndex.KEY, moduleName,
GlobalSearchScope.getScopeRestrictedByFileTypes(
GlobalSearchScope.allScope(project),
PhpFileType.INSTANCE
)
);
for (VirtualFile moduleVf : moduleVfs) {
viewVfs.addAll(getValues(moduleName, moduleVf, project));
}
return viewVfs;
}
示例14: getReferencesByElement
import com.jetbrains.php.lang.PhpFileType; //导入依赖的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;
}
示例15: attachMetadataExtends
import com.jetbrains.php.lang.PhpFileType; //导入依赖的package包/类
public static void attachMetadataExtends(@NotNull final StringLiteralExpression psiElement, final @NotNull Collection<PsiElement> psiElements) {
final String contents = getPathFormattedString(psiElement);
if (contents == null) {
return;
}
ModuleUtil.visitModuleFile(psiElement.getContainingFile(), new ModuleUtil.ModuleFileVisitor() {
@Override
public void visit(@NotNull VirtualFile virtualFile, @NotNull String relativePath) {
if (virtualFile.getFileType() != PhpFileType.INSTANCE || !relativePath.toLowerCase().endsWith(".php") || !contents.equalsIgnoreCase(relativePath.substring(0, relativePath.length() - 4))) {
return;
}
PsiFile file = PsiManager.getInstance(psiElement.getProject()).findFile(virtualFile);
if(file != null) {
psiElements.add(file);
}
}
});
}