com.jetbrains.php.lang.PhpFileType Java Examples

The following examples show how to use com.jetbrains.php.lang.PhpFileType. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: ConfigAutoCompleteTest.java    From idea-php-laravel-plugin with MIT License 6 votes vote down vote up
public void testConfigReferences() {
    assertCompletionContains(
        PhpFileType.INSTANCE,
        "<?php\n" + "config('<caret>');",
        "simple.test", "simple.folder.subKey", "sim-ple.test", "app.sub.test"
    );

    assertNavigationMatch(
        PhpFileType.INSTANCE,
        "<?php\n" + "config('simple.test');",
        PlatformPatterns.psiElement(StringLiteralExpression.class).inFile(PlatformPatterns.psiFile().withName("simple.php"))
    );

    assertNavigationMatch(
            PhpFileType.INSTANCE,
            "<?php\n" + "config('app.sub.test');",
            PlatformPatterns.psiElement(StringLiteralExpression.class).inFile(PlatformPatterns.psiFile().withName("sub.php"))
    );
}
 
Example #2
Source File: TemplateAnnotationTypeProviderTest.java    From idea-php-generics-plugin with MIT License 6 votes vote down vote up
public void testTypesForFunctionWithClassString() {
    assertPhpReferenceResolveTo(PhpFileType.INSTANCE,
        "<?php\n instantiator(\\Foobar\\Foobar::class)->get<caret>Foo();\n",
        PlatformPatterns.psiElement(Method.class).withName("getFoo")
    );

    assertPhpReferenceResolveTo(PhpFileType.INSTANCE,
        "<?php\n instantiator2('', \\Foobar\\Foobar::class, '')->get<caret>Foo();\n",
        PlatformPatterns.psiElement(Method.class).withName("getFoo")
    );

    assertPhpReferenceNotResolveTo(PhpFileType.INSTANCE,
        "<?php\n instantiator2('', '', \\Foobar\\Foobar::class)->get<caret>Foo();\n",
        PlatformPatterns.psiElement(Method.class).withName("getFoo")
    );
}
 
Example #3
Source File: ExtensionFileGenerationUtil.java    From idea-php-typo3-plugin with MIT License 6 votes vote down vote up
/**
 * @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);
}
 
Example #4
Source File: ExtensionFileGenerationUtil.java    From idea-php-typo3-plugin with MIT License 6 votes vote down vote up
/**
 * @param templateFile           Name of the generated file
 * @param destinationPath        Relative path to the target file system entry
 * @param extensionRootDirectory 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 PsiDirectory extensionRootDirectory, @NotNull Map<String, String> context, Project project) {
    String template = readTemplateToString(templateFile, context);

    VirtualFile targetDirectory = getOrCreateDestinationPath(extensionRootDirectory.getVirtualFile(), 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);
}
 
Example #5
Source File: ControllerReferencesTest.java    From idea-php-laravel-plugin with MIT License 6 votes vote down vote up
public void testRouteGroups() {
    assertCompletionContains(PhpFileType.INSTANCE, "<?php\n" +
            "Route::group(['namespace' => 'Group'], function() {\n" +
            "    Route::get('/', '<caret>');\n" +
            "});",
        "GroupController@foo"
    );

    assertNavigationMatch(PhpFileType.INSTANCE, "<?php\n" +
            "Route::group(['namespace' => 'Group'], function() {\n" +
            "    Route::get('/', 'GroupController@foo<caret>');\n" +
            "});",
        PlatformPatterns.psiElement(Method.class).withParent(
            PlatformPatterns.psiElement(PhpClass.class).withName("GroupController")
        )
    );
}
 
Example #6
Source File: PhpToolboxTypeProviderTest.java    From idea-php-toolbox with MIT License 6 votes vote down vote up
public void testPhpTypeForMethods() {
    assertPhpReferenceResolveTo(PhpFileType.INSTANCE, "<?php\n" +
        "/** @var $f \\Foo\\Bar */\n" +
        "$f->foo('datetime')->for<caret>mat()",
        PlatformPatterns.psiElement(Method.class).withName("format")
    );

    // Same method name but different class and parameter index
    assertPhpReferenceResolveTo(PhpFileType.INSTANCE, "<?php\n" +
        "/** @var $f \\Foo\\Baz */\n" +
        "$f->foo('', 'datetime')->for<caret>mat()",
        PlatformPatterns.psiElement(Method.class).withName("format")
    );

    assertPhpReferenceResolveTo(PhpFileType.INSTANCE, "<?php\n" +
        "/** @var $f \\Foo\\Bar */\n" +
        "$f->foo(\\Foo\\Bar::DATETIME)->for<caret>mat()",
        PlatformPatterns.psiElement(Method.class).withName("format")
    );
}
 
Example #7
Source File: ObjectManagerTypeProviderTest.java    From idea-php-typo3-plugin with MIT License 6 votes vote down vote up
public void testIssue305_class() {
    myFixture.copyFileToProject("classes.php");

    assertPhpReferenceResolveTo(PhpFileType.INSTANCE,
        "<?php\n" +
            "class Foo {\n" +
            "  /** @var \\TYPO3\\CMS\\Extbase\\Object\\ObjectManagerInterface */" +
            "  protected $objectManager;\n" +
            "  public function foo() {\n" +
            "    $dataMapper = $this->objectManager->get(\\TYPO3\\CMS\\Extbase\\Persistence\\Generic\\Mapper\\DataMapper::class);\n" +
            "    $dataMapper->ma<caret>p();" +
            "  }\n" +
            "}",
        PlatformPatterns.psiElement(Method.class).withName("map")
    );
}
 
Example #8
Source File: TypeHintSuggestionProviderTest.java    From idea-php-toolbox with MIT License 6 votes vote down vote up
public void testTypeHintVariableCompletionExtendsListWithStrippedWordList() {
    Collection<String[]> providers = Arrays.asList(
        new String[] {"FooBarInterface", "fooBar"},
        new String[] {"FooBarInterface", "bar"},
        new String[] {"FooBarAbstract", "fooBar"},
        new String[] {"FooAbstract", "foo"}
    );

    for (String[] provider : providers) {
        assertCompletionContains(
            PhpFileType.INSTANCE,
            String.format("<?php function f(%s $<caret>);", provider[0]),
            "$" + provider[1]
        );
    }
}
 
Example #9
Source File: DicCompletionRegistrarTest.java    From idea-php-laravel-plugin with MIT License 6 votes vote down vote up
public void testCompletion() {
    assertCompletionContains(PhpFileType.INSTANCE, "<?php\n" +
            "app('<caret>')",
        "foo"
    );

    assertCompletionContains(PhpFileType.INSTANCE, "<?php\n" +
            "\\App::make('<caret>')",
        "foo"
    );

    assertCompletionContains(PhpFileType.INSTANCE, "<?php\n" +
            "/** @var $f \\Illuminate\\Contracts\\Container\\Container */" +
            "$f->make('<caret>')",
        "foo"
    );
}
 
Example #10
Source File: RoutingGotoCompletionRegistrarTest.java    From idea-php-laravel-plugin with MIT License 6 votes vote down vote up
public void testRouteNameReferencesAsMethod() {
    Collection<String[]> providers = new ArrayList<String[]>() {{
        add(new String[] {"Illuminate\\Routing\\UrlGenerator", "route"});
        add(new String[] {"Illuminate\\Contracts\\Routing\\UrlGenerator", "route"});
        add(new String[] {"Collective\\Html\\HtmlBuilder", "linkRoute"});
        add(new String[] {"Tests\\Feature\\ExampleTest", "visitRoute"});
    }};

    for (String[] provider : providers) {
        assertCompletionContains(PhpFileType.INSTANCE, String.format("<?php\n" +
                "/** @var $r \\%s */\n" +
                "$r->%s('<caret>')"
                , provider[0], provider[1]),
            "profile"
        );

        assertNavigationMatch(PhpFileType.INSTANCE, String.format("<?php\n" +
                "/** @var $r \\%s */\n" +
                "$r->%s('profile<caret>')"
                , provider[0], provider[1]),
            PlatformPatterns.psiElement().inFile(PlatformPatterns.psiFile().withName("routes.php"))
        );
    }
}
 
Example #11
Source File: TypeHintSuggestionProviderTest.java    From idea-php-toolbox with MIT License 6 votes vote down vote up
public void testTypeHintVariableCompletionExtendsListWithStrippedWordList() {
    Collection<String[]> providers = Arrays.asList(
        new String[] {"FooBarInterface", "fooBar"},
        new String[] {"FooBarInterface", "bar"},
        new String[] {"FooBarAbstract", "fooBar"},
        new String[] {"FooAbstract", "foo"}
    );

    for (String[] provider : providers) {
        assertCompletionContains(
            PhpFileType.INSTANCE,
            String.format("<?php function f(%s $<caret>);", provider[0]),
            "$" + provider[1]
        );
    }
}
 
Example #12
Source File: PhpMatcherTest.java    From idea-php-toolbox with MIT License 6 votes vote down vote up
public void testVariadicSignatureRegistrarMatcher() {
    assertCompletionContains(PhpFileType.INSTANCE, "<?php\n _variadic('<caret>')", "foo");
    assertCompletionContains(PhpFileType.INSTANCE, "<?php\n _variadic(null, '<caret>')", "foo");
    assertNavigationMatch(PhpFileType.INSTANCE, "<?php\n _variadic('foo<caret>')", PlatformPatterns.psiElement(Method.class).withName("format"));

    assertCompletionContains(PhpFileType.INSTANCE, "<?php\n _variadic('<caret>')", "foo");
    assertNavigationMatch(PhpFileType.INSTANCE, "<?php\n _variadic('foo<caret>')", PlatformPatterns.psiElement(Method.class).withName("format"));

    assertCompletionContains(PhpFileType.INSTANCE, "<?php\n new \\Foo\\Variadic('<caret>')", "foo");
    assertCompletionContains(PhpFileType.INSTANCE, "<?php\n new \\Foo\\Variadic(null, '<caret>')", "foo");
    assertNavigationMatch(PhpFileType.INSTANCE, "<?php\n new \\Foo\\Variadic('foo<caret>')", PlatformPatterns.psiElement(Method.class).withName("format"));

    assertCompletionContains(PhpFileType.INSTANCE, "<?php\n /** @var $f \\Foo\\Variadic */\n $f->getFoo('<caret>')", "foo");
    assertCompletionContains(PhpFileType.INSTANCE, "<?php\n /** @var $f \\Foo\\Variadic */\n $f->getFoo(null, '<caret>')", "foo");
    assertNavigationMatch(PhpFileType.INSTANCE, "<?php\n /** @var $f \\Foo\\Variadic */\n $f->getFoo('foo<caret>')", PlatformPatterns.psiElement(Method.class).withName("format"));
}
 
Example #13
Source File: PhpMatcherTest.java    From idea-php-toolbox with MIT License 6 votes vote down vote up
public void testVariadicSignatureRegistrarMatcher() {
    assertCompletionContains(PhpFileType.INSTANCE, "<?php\n _variadic('<caret>')", "foo");
    assertCompletionContains(PhpFileType.INSTANCE, "<?php\n _variadic(null, '<caret>')", "foo");
    assertNavigationMatch(PhpFileType.INSTANCE, "<?php\n _variadic('foo<caret>')", PlatformPatterns.psiElement(Method.class).withName("format"));

    assertCompletionContains(PhpFileType.INSTANCE, "<?php\n _variadic('<caret>')", "foo");
    assertNavigationMatch(PhpFileType.INSTANCE, "<?php\n _variadic('foo<caret>')", PlatformPatterns.psiElement(Method.class).withName("format"));

    assertCompletionContains(PhpFileType.INSTANCE, "<?php\n new \\Foo\\Variadic('<caret>')", "foo");
    assertCompletionContains(PhpFileType.INSTANCE, "<?php\n new \\Foo\\Variadic(null, '<caret>')", "foo");
    assertNavigationMatch(PhpFileType.INSTANCE, "<?php\n new \\Foo\\Variadic('foo<caret>')", PlatformPatterns.psiElement(Method.class).withName("format"));

    assertCompletionContains(PhpFileType.INSTANCE, "<?php\n /** @var $f \\Foo\\Variadic */\n $f->getFoo('<caret>')", "foo");
    assertCompletionContains(PhpFileType.INSTANCE, "<?php\n /** @var $f \\Foo\\Variadic */\n $f->getFoo(null, '<caret>')", "foo");
    assertNavigationMatch(PhpFileType.INSTANCE, "<?php\n /** @var $f \\Foo\\Variadic */\n $f->getFoo('foo<caret>')", PlatformPatterns.psiElement(Method.class).withName("format"));
}
 
Example #14
Source File: PimplePhpTypeProviderTest.java    From silex-idea-plugin with MIT License 5 votes vote down vote up
public void testTypeForParameterFactoryMethod() throws Exception {

        assertSignatureEquals(PhpFileType.INSTANCE, com.jetbrains.php.lang.psi.elements.Parameter.class,
                "<?php " +
                        "$app = new \\Silex\\Application(); " +
                        "$app[''] = $app->factory(function ($<caret>class) {});",
                "#Š#C\\Silex\\Application"
        );
    }
 
Example #15
Source File: LaravelControllerNamespaceCutterTest.java    From idea-php-laravel-plugin with MIT License 5 votes vote down vote up
public void testGetDefaultNamespace() {
    myFixture.configureByText(PhpFileType.INSTANCE, "<?php\n" +
        "namespace App\\Providers\n" +
        "{\n" +
        "    class RouteServiceProvider implements \\Illuminate\\Foundation\\Support\\Providers\\RouteServiceProvider\n" +
        "    {\n" +
        "        protected $namespace = 'App\\Http\\Controllers\\Foo';\n" +
        "    }\n" +
        "}"
    );

    LaravelControllerNamespaceCutter instance = new LaravelControllerNamespaceCutter(getProject(), null);
    instance.cut("App\\Http\\Controllers\\Foo\\TestController", (processedClassName, prioritised)
            -> assertEquals("TestController", processedClassName));
}
 
Example #16
Source File: PimpleCompletionContributorTest.java    From silex-idea-plugin with MIT License 5 votes vote down vote up
public void testDisableOtherCompletions() throws Exception {

        assertCompletionEquals(PhpFileType.INSTANCE,
                "<?php " +
                        "$app = new \\Sorien\\Application();" +
                        "$a = $app['e'];" +
                        "$b = $app['f'];" +
                        "$c = $app['g'];" +
                        "$app['<caret>']",

                "container1", "parameter", "service", "service\\fqn"
        );
    }
 
Example #17
Source File: PhpToolboxTypeProviderTest.java    From idea-php-toolbox with MIT License 5 votes vote down vote up
public void testPhpTypeForFunctions() {
    assertPhpReferenceResolveTo(PhpFileType.INSTANCE, "<?php\n" +
        "car('', 'datetime')->for<caret>mat()",
        PlatformPatterns.psiElement(Method.class).withName("format")
    );

    assertPhpReferenceResolveTo(PhpFileType.INSTANCE, "<?php\n" +
        "car('', \\Foo\\Bar::DATETIME)->for<caret>mat()",
        PlatformPatterns.psiElement(Method.class).withName("format")
    );
}
 
Example #18
Source File: PimpleCompletionContributorTest.java    From silex-idea-plugin with MIT License 5 votes vote down vote up
public void testReferencedContainerCompletion() throws Exception {

        assertCompletionContains(PhpFileType.INSTANCE,
                "<?php " +
                        "$app = new \\Silex\\Application(); " +
                        "$a = $app['container1']; " +
                        "$a['<caret>']",
                "container2"
        );
    }
 
Example #19
Source File: PhpMatcherTest.java    From idea-php-toolbox with MIT License 5 votes vote down vote up
public void testSignatureInReturn() {
    assertCompletionContains(PhpFileType.INSTANCE,  "<?php function foo() { return '<caret>'; }", "bar", "foo");
    assertCompletionContains(PhpFileType.INSTANCE,  "<?php class Foo { function getFoo() { return '<caret>'; } }", "bar", "foo");

    assertCompletionNotContains(PhpFileType.INSTANCE, "<?php function foo1() { return '<caret>'; }", "bar", "foo");
    assertCompletionNotContains(PhpFileType.INSTANCE, "<?php class Foo1 { function getFoo() { return '<caret>'; } }", "bar", "foo");

    assertCompletionNotContains(PhpFileType.INSTANCE,  "<?php function foobar() { return '<caret>'; }", "bar");
}
 
Example #20
Source File: PimpleCompletionContributorTest.java    From silex-idea-plugin with MIT License 5 votes vote down vote up
public void testParentContainerCompletion() throws Exception {

        assertCompletionContains(PhpFileType.INSTANCE,
                "<?php " +
                        "$app = new \\Sorien\\Application(); " +
                        "$a = $app['<caret>'];",
                "container1", "parameter"
        );
    }
 
Example #21
Source File: PimplePhpTypeProviderTest.java    From silex-idea-plugin with MIT License 5 votes vote down vote up
public void testTypeForParameterPropertyKey() throws Exception {

        assertSignatureEquals(PhpFileType.INSTANCE, com.jetbrains.php.lang.psi.elements.Parameter.class,
                "<?php " +
                        "$app = new \\Silex\\Application();" +
                        "$service2 = new \\Sorien\\Service2();" +
                        "$app->extend($service2->name, function ($<caret>class) {});",
                "#Š#C\\Silex\\Application[#P#C\\Sorien\\Service2.name]"
        );
    }
 
Example #22
Source File: PimpleCompletionContributorTest.java    From silex-idea-plugin with MIT License 5 votes vote down vote up
public void testContainerFromMultiTypeTraitMethod() throws Exception {

        assertCompletionContains(PhpFileType.INSTANCE,
                "<?php " +
                        "trait TestTrait {" +
                        "" +
                        "    private $app;" +
                        "" +
                        "    protected function getApp() {" +
                        "        if (!$this->app) {" +
                        "            $this->app = $this->createApp();" +
                        "        }" +
                        "        return $this->app;" +
                        "    }" +
                        "" +
                        "    protected function createApp() {" +
                        "        return new \\Silex\\Application();" +
                        "    }" +
                        "}" +
                        "class Test {" +
                        "" +
                        "    use TestTrait;" +
                        "" +
                        "    public function foo() {" +
                        "        $app = $this->getApp();" +
                        "        $app['<caret>'];" +
                        "    }" +
                        "}",
                "container1", "parameter"
        );
    }
 
Example #23
Source File: PimpleCompletionContributorTest.java    From silex-idea-plugin with MIT License 5 votes vote down vote up
public void testClassConstantInContainerCompletion() throws Exception {

        assertCompletionContains(PhpFileType.INSTANCE,
                "<?php " +
                        "class Test {" +
                        "    const c = \"container1\";" +
                        "}" +
                        "$app = new \\Silex\\Application();" +
                        "$app[Test::c]['<caret>']",
                "container2"
        );
    }
 
Example #24
Source File: ModelReference.java    From Thinkphp5-Plugin with MIT License 5 votes vote down vote up
@NotNull
        @Override
        public Collection<PsiElement> getPsiTargets(StringLiteralExpression psiElement) {
//            return super.getPsiTargets(psiElement, offset, editor);
            final Set<PsiElement> targets = new HashSet<>();

            String contents = psiElement.getContents();
            if (StringUtils.isBlank(contents)) {
                return targets;
            }

            //判断是否有模块名
            String curTpModuleName = Util.getCurTpModuleName(getElement())+"/";
            String content2="";
            if(!contents.startsWith(curTpModuleName)){
                content2=curTpModuleName+contents;
            }

            //忽略大小写
            Collection<String> allKeys = FileBasedIndex.getInstance().getAllKeys(key, getElement().getProject());

            contents = Util.getKeyWithCase(allKeys, contents);
            if(!allKeys.contains(contents))
                contents = Util.getKeyWithCase(allKeys, content2);

            FileBasedIndex.getInstance().getFilesWithKey(key, new HashSet<>(Collections.singletonList(contents)),
                    new Processor<VirtualFile>() {
                        @Override
                        public boolean process(VirtualFile virtualFile) {
                            if (virtualFile != null) {
                                PsiFile psiFileTarget = PsiManager.getInstance(ModelReference.ModelProvider.this.getProject()).findFile(virtualFile);
                                targets.add(psiFileTarget);
                            }
                            return true;
                        }
                    }, GlobalSearchScope.getScopeRestrictedByFileTypes(GlobalSearchScope.allScope(getProject()), PhpFileType.INSTANCE));

            return targets;
        }
 
Example #25
Source File: PhpToolboxTypeProviderTest.java    From idea-php-toolbox with MIT License 5 votes vote down vote up
public void testPhpTypeForStaticMethods() {
    assertPhpReferenceResolveTo(PhpFileType.INSTANCE, "<?php\n" +
        "\\Foo\\Bar::app('datetime')->for<caret>mat()",
        PlatformPatterns.psiElement(Method.class).withName("format")
    );

    assertPhpReferenceResolveTo(PhpFileType.INSTANCE, "<?php\n" +
        "\\Foo\\Bar::app(\\Foo\\Bar::DATETIME)->for<caret>mat()",
        PlatformPatterns.psiElement(Method.class).withName("format")
    );
}
 
Example #26
Source File: PimplePhpTypeProviderTest.java    From silex-idea-plugin with MIT License 5 votes vote down vote up
public void ProperArrayValueTypeIfServiceCantBeResolved() throws Exception {

        assertTypeEquals(PhpFileType.INSTANCE, Variable.class,
                "<?php " +
                        "class Publication  {};" +
                        "class Foo {" +
                        "    /** @var Publication[] */" +
                        "    public $publications;" +
                        "    public function collect() {" +
                        "        $var<caret>a = $this->publications['test'];" +
                        "    }" +
                        "};",
                "\\Publication"
        );
    }
 
Example #27
Source File: ArrayReturnSourceContributorTest.java    From idea-php-toolbox with MIT License 5 votes vote down vote up
/**
 * @see ArrayReturnSourceContributor
 */
public void testArrayStringReturn() {
    assertCompletionContains(PhpFileType.INSTANCE,  "<?php date_2('<caret>')", "foo_array", "foo_array_1");
    assertNavigationMatch(PhpFileType.INSTANCE, "<?php date_2('foo_array_1<caret>')", PlatformPatterns.psiElement(Method.class));
    assertCompletionLookupTailEquals(PhpFileType.INSTANCE, "<?php date_2('<caret>')", "foo_array_1", "DefaultTail");

    LookupElementPresentation element = getCompletionLookupElement(PhpFileType.INSTANCE, "<?php date('<caret>')", "foo_return");
    assertEquals(element.getIcon(), PhpIcons.METHOD);
}
 
Example #28
Source File: ArrayKeyValueSignatureRegistrarMatcherTest.java    From idea-php-toolbox with MIT License 5 votes vote down vote up
public void testMethodReferences() {
    assertCompletionContains(PhpFileType.INSTANCE,  "<?php (new \\Foo\\Bar)->foo(['bar' => '<caret>'])", "car");
    assertNavigationMatch(PhpFileType.INSTANCE,  "<?php (new \\Foo\\Bar)->foo(['bar' => 'car<caret>'])", PlatformPatterns.psiElement(Method.class).withName("format"));

    assertCompletionNotContains(PhpFileType.INSTANCE,  "<?php (new \\Foo\\Bar)->foo(['bar_car' => '<caret>'])", "car");
    assertCompletionNotContains(PhpFileType.INSTANCE,  "<?php (new \\Foo\\Bar)->foo(['bar_car' => '', '<caret>''])", "car");
}
 
Example #29
Source File: ArrayReturnSourceContributorTest.java    From idea-php-toolbox with MIT License 5 votes vote down vote up
/**
 * @see ArrayReturnSourceContributor
 */
public void testArrayStringReturn() {
    assertCompletionContains(PhpFileType.INSTANCE,  "<?php date_2('<caret>')", "foo_array", "foo_array_1");
    assertNavigationMatch(PhpFileType.INSTANCE, "<?php date_2('foo_array_1<caret>')", PlatformPatterns.psiElement(Method.class));
    assertCompletionLookupTailEquals(PhpFileType.INSTANCE, "<?php date_2('<caret>')", "foo_array_1", "DefaultTail");

    LookupElementPresentation element = getCompletionLookupElement(PhpFileType.INSTANCE, "<?php date('<caret>')", "foo_return");
    assertEquals(element.getIcon(), PhpIcons.METHOD);
}
 
Example #30
Source File: PhpDocTagGotoCompletionContributorTest.java    From idea-php-toolbox with MIT License 5 votes vote down vote up
public void testDirectMethod() {
    assertCompletionContains(PhpFileType.INSTANCE,  "<?php (new \\Foo\\Car())->foo('<caret>', '');", "DateTime");
    assertCompletionContains(PhpFileType.INSTANCE,  "<?php (new \\Foo\\Car())->foo(null, '<caret>');", "Foo\\FooTrait");
    assertCompletionContains(PhpFileType.INSTANCE,  "<?php (new \\Foo\\Car())->foo(null, null, '<caret>');", "DateTime");

    assertNavigationMatch(PhpFileType.INSTANCE,  "<?php (new \\Foo\\Car())->foo('DateTime<caret>', '');", PlatformPatterns.psiElement(PhpClass.class));
    assertNavigationMatch(PhpFileType.INSTANCE,  "<?php (new \\Foo\\Car())->foo('DateTime', 'Foo\\FooTrait<caret>');", PlatformPatterns.psiElement(PhpClass.class));
}