fr.adrienbrault.idea.symfony2plugin.util.MethodMatcher Java Examples
The following examples show how to use
fr.adrienbrault.idea.symfony2plugin.util.MethodMatcher.
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: RoutingGotoCompletionRegistrar.java From idea-php-laravel-plugin with MIT License | 6 votes |
@Override public void register(GotoCompletionRegistrarParameter registrar) { registrar.register(PlatformPatterns.psiElement(), psiElement -> { if(psiElement == null || !LaravelProjectComponent.isEnabled(psiElement)) { return null; } PsiElement parent = psiElement.getParent(); if(parent != null && ( MethodMatcher.getMatchedSignatureWithDepth(parent, URL_GENERATOR) != null || PhpElementsUtil.isFunctionReference(parent, 0, "route") || PhpElementsUtil.isFunctionReference(parent, 0, "link_to_route") )) { return new RouteNameGotoCompletionProvider(parent); } return null; }); }
Example #2
Source File: FormFieldResolver.java From idea-php-symfony2-plugin with MIT License | 6 votes |
private static void attachFormFields(@Nullable MethodReference methodReference, @NotNull Collection<TwigTypeContainer> targets) { if(methodReference != null && PhpElementsUtil.isMethodReferenceInstanceOf( methodReference, new MethodMatcher.CallToSignature("\\Symfony\\Bundle\\FrameworkBundle\\Controller\\Controller", "createForm"), new MethodMatcher.CallToSignature("\\Symfony\\Bundle\\FrameworkBundle\\Controller\\ControllerTrait", "createForm"), new MethodMatcher.CallToSignature("\\Symfony\\Bundle\\FrameworkBundle\\Controller\\AbstractController", "createForm") )) { PsiElement formType = PsiElementUtils.getMethodParameterPsiElementAt(methodReference, 0); if(formType != null) { PhpClass phpClass = FormUtil.getFormTypeClassOnParameter(formType); if(phpClass == null) { return; } Method method = phpClass.findMethodByName("buildForm"); if(method == null) { return; } targets.addAll(getTwigTypeContainer(method)); } } }
Example #3
Source File: PhpFoldingBuilder.java From idea-php-symfony2-plugin with MIT License | 6 votes |
private void attachTemplateShortcuts(List<FoldingDescriptor> descriptors, final StringLiteralExpression stringLiteralExpression) { if (MethodMatcher.getMatchedSignatureWithDepth(stringLiteralExpression, SymfonyPhpReferenceContributor.TEMPLATE_SIGNATURES) == null) { return; } String content = stringLiteralExpression.getContents(); String templateShortcutName = TwigUtil.getFoldingTemplateName(content); if(templateShortcutName == null) { return; } final String finalTemplateShortcutName = templateShortcutName; descriptors.add(new FoldingDescriptor(stringLiteralExpression.getNode(), new TextRange(stringLiteralExpression.getTextRange().getStartOffset() + 1, stringLiteralExpression.getTextRange().getEndOffset() - 1)) { @Nullable @Override public String getPlaceholderText() { return finalTemplateShortcutName; } }); }
Example #4
Source File: FormStringToClassConstantIntention.java From idea-php-symfony2-plugin with MIT License | 6 votes |
@Override public boolean isAvailable(@NotNull Project project, Editor editor, @NotNull PsiElement psiElement) { if(!Symfony2ProjectComponent.isEnabled(psiElement.getProject())) { return false; } PsiElement parent = psiElement.getParent(); if(!(parent instanceof StringLiteralExpression)) { return false; } String contents = ((StringLiteralExpression) parent).getContents(); if(StringUtils.isBlank(contents)) { return false; } return null != new MethodMatcher.StringParameterMatcher(parent, 1) .withSignature(FormUtil.PHP_FORM_BUILDER_SIGNATURES) .match(); }
Example #5
Source File: FormTypeConstantMigrationAction.java From idea-php-symfony2-plugin with MIT License | 6 votes |
@Override public void visitElement(PsiElement element) { if (!(element instanceof StringLiteralExpression)) { super.visitElement(element); return; } String contents = ((StringLiteralExpression) element).getContents(); if (StringUtils.isBlank(contents)) { super.visitElement(element); return; } if (null == new MethodMatcher.StringParameterMatcher(element, 1) .withSignature(FormUtil.PHP_FORM_BUILDER_SIGNATURES) .match()) { super.visitElement(element); return; } formTypes.add((StringLiteralExpression) element); super.visitElement(element); }
Example #6
Source File: DoctrineRepositoryClassConstantIntention.java From idea-php-symfony2-plugin with MIT License | 6 votes |
@Override public boolean isAvailable(@NotNull Project project, Editor editor, @NotNull PsiElement psiElement) { if(!Symfony2ProjectComponent.isEnabled(psiElement.getProject())) { return false; } PsiElement parent = psiElement.getParent(); if(!(parent instanceof StringLiteralExpression)) { return false; } String contents = ((StringLiteralExpression) parent).getContents(); if(StringUtils.isBlank(contents)) { return false; } return null != new MethodMatcher.StringParameterMatcher(parent, 0) .withSignature(SymfonyPhpReferenceContributor.REPOSITORY_SIGNATURES) .withSignature("Doctrine\\Persistence\\ObjectManager", "find") .withSignature("Doctrine\\Common\\Persistence\\ObjectManager", "find") // @TODO: missing somewhere .match(); }
Example #7
Source File: MatcherUtil.java From idea-php-symfony2-plugin with MIT License | 6 votes |
@Nullable public static MethodMatcher.MethodMatchParameter matchPropertyField(PsiElement psiElement) { if (!Symfony2ProjectComponent.isEnabled(psiElement)) { return null; } MethodMatcher.MethodMatchParameter methodMatchParameter = new MethodMatcher.StringParameterAnyMatcher(psiElement) .withSignature(SELECT_FIELDS) .match(); if(methodMatchParameter == null) { methodMatchParameter = new MethodMatcher.StringParameterAnyMatcher(psiElement) .withSignature(SELECT_FIELDS_VARIADIC) .match(); } if(methodMatchParameter == null) { methodMatchParameter = new MethodMatcher.ArrayParameterMatcher(psiElement, 0) .withSignature(SELECT_FIELDS) .match(); } return methodMatchParameter; }
Example #8
Source File: DoctrineDbalQbGotoCompletionRegistrar.java From idea-php-symfony2-plugin with MIT License | 6 votes |
private boolean isTableNameRegistrar(PsiElement context) { MethodMatcher.MethodMatchParameter methodMatchParameter = new MethodMatcher.StringParameterRecursiveMatcher(context, 0) .withSignature("Doctrine\\DBAL\\Query\\QueryBuilder", "update") .withSignature("Doctrine\\DBAL\\Query\\QueryBuilder", "insert") .withSignature("Doctrine\\DBAL\\Query\\QueryBuilder", "from") .withSignature("Doctrine\\DBAL\\Query\\QueryBuilder", "delete") .withSignature("Doctrine\\DBAL\\Connection", "insert") .withSignature("Doctrine\\DBAL\\Connection", "update") .match(); if(methodMatchParameter != null) { return true; } methodMatchParameter = new MethodMatcher.StringParameterRecursiveMatcher(context, 1) .withSignature("Doctrine\\DBAL\\Query\\QueryBuilder", "innerJoin") .withSignature("Doctrine\\DBAL\\Query\\QueryBuilder", "leftJoin") .withSignature("Doctrine\\DBAL\\Query\\QueryBuilder", "join") .withSignature("Doctrine\\DBAL\\Query\\QueryBuilder", "rightJoin") .match(); return methodMatchParameter != null; }
Example #9
Source File: QueryBuilderGotoDeclarationHandler.java From idea-php-symfony2-plugin with MIT License | 6 votes |
private void attachFromIndexGoto(StringLiteralExpression psiElement, List<PsiElement> targets) { MethodMatcher.MethodMatchParameter methodMatchParameter = new MethodMatcher.StringParameterMatcher(psiElement, 2) .withSignature("\\Doctrine\\ORM\\QueryBuilder", "from") .match(); if(methodMatchParameter == null) { return; } QueryBuilderMethodReferenceParser qb = QueryBuilderCompletionContributor.getQueryBuilderParser(methodMatchParameter.getMethodReference()); if(qb == null) { return; } QueryBuilderScopeContext collect = qb.collect(); String propertyContent = psiElement.getContents(); for(Map.Entry<String, QueryBuilderPropertyAlias> entry: collect.getPropertyAliasMap().entrySet()) { if(entry.getKey().equals(propertyContent)) { targets.addAll(entry.getValue().getPsiTargets()); } } }
Example #10
Source File: QueryBuilderGotoDeclarationHandler.java From idea-php-symfony2-plugin with MIT License | 6 votes |
private void attachPropertyGoto(StringLiteralExpression psiElement, List<PsiElement> targets) { MethodMatcher.MethodMatchParameter methodMatchParameter = MatcherUtil.matchPropertyField(psiElement); if(methodMatchParameter == null) { return; } QueryBuilderMethodReferenceParser qb = QueryBuilderCompletionContributor.getQueryBuilderParser(methodMatchParameter.getMethodReference()); if(qb == null) { return; } QueryBuilderScopeContext collect = qb.collect(); String propertyContent = psiElement.getContents(); for(Map.Entry<String, QueryBuilderPropertyAlias> entry: collect.getPropertyAliasMap().entrySet()) { if(entry.getKey().equals(propertyContent)) { targets.addAll(entry.getValue().getPsiTargets()); } } }
Example #11
Source File: DicCompletionRegistrar.java From idea-php-laravel-plugin with MIT License | 6 votes |
@Override public void register(GotoCompletionRegistrarParameter registrar) { registrar.register(PlatformPatterns.psiElement(), psiElement -> { if(psiElement == null || !LaravelProjectComponent.isEnabled(psiElement)) { return null; } PsiElement parent = psiElement.getParent(); if(parent != null && ( MethodMatcher.getMatchedSignatureWithDepth(parent, DIC) != null || PhpElementsUtil.isFunctionReference(parent, 0, "app") )) { return new DicGotoCompletionProvider(parent); } return null; }); }
Example #12
Source File: ConfigUtil.java From idea-php-shopware-plugin with MIT License | 6 votes |
/** * */ @Nullable public static String getNamespaceFromConfigValueParameter(@NotNull StringLiteralExpression parent) { MethodMatcher.MethodMatchParameter match = MethodMatcher.getMatchedSignatureWithDepth(parent, ShopwarePhpCompletion.CONFIG_NAMESPACE, 1); if(match == null) { return null; } PsiElement parameterList = parent.getParent(); if(!(parameterList instanceof ParameterList)) { return null; } PsiElement[] funcParameters = ((ParameterList) parameterList).getParameters(); if(funcParameters.length == 0 || !(funcParameters[0] instanceof StringLiteralExpression)) { return null; } String namespace = ((StringLiteralExpression) funcParameters[0]).getContents(); if(StringUtils.isBlank(namespace)) { return null; } return namespace; }
Example #13
Source File: ConfigCompletionGoto.java From idea-php-drupal-symfony2-bridge with MIT License | 6 votes |
@Override public void register(GotoCompletionRegistrarParameter registrar) { registrar.register(PlatformPatterns.psiElement().withParent(StringLiteralExpression.class).withLanguage(PhpLanguage.INSTANCE), psiElement -> { if(!DrupalProjectComponent.isEnabled(psiElement)) { return null; } PsiElement parent = psiElement.getParent(); if(parent == null) { return null; } MethodMatcher.MethodMatchParameter methodMatchParameter = MethodMatcher.getMatchedSignatureWithDepth(parent, CONFIG); if(methodMatchParameter == null) { return null; } return new FormReferenceCompletionProvider(parent); }); }
Example #14
Source File: TranslationReferences.java From idea-php-laravel-plugin with MIT License | 6 votes |
@Override public void register(GotoCompletionRegistrarParameter registrar) { registrar.register(PlatformPatterns.psiElement(), psiElement -> { if(psiElement == null || !LaravelProjectComponent.isEnabled(psiElement)) { return null; } PsiElement parent = psiElement.getParent(); if(parent != null && ( MethodMatcher.getMatchedSignatureWithDepth(parent, TRANSLATION_KEY) != null || PhpElementsUtil.isFunctionReference(parent, 0, "trans", "__", "trans_choice") )) { return new TranslationKey(parent); } // for blade @lang directive if(BladePsiUtil.isDirectiveWithInstance(psiElement, "Illuminate\\Support\\Facades\\Lang", "get")) { return new TranslationKey(psiElement); } return null; }); }
Example #15
Source File: PhpRouteMissingInspection.java From idea-php-symfony2-plugin with MIT License | 5 votes |
private void invoke(@NotNull String routeName, @NotNull final PsiElement element, @NotNull ProblemsHolder holder) { MethodMatcher.MethodMatchParameter methodMatchParameter = new MethodMatcher.StringParameterMatcher(element, 0) .withSignature(PhpRouteReferenceContributor.GENERATOR_SIGNATURES) .match(); if(methodMatchParameter == null) { return; } Collection<Route> route = RouteHelper.getRoute(element.getProject(), routeName); if(route.size() == 0) { holder.registerProblem(element, "Missing Route", ProblemHighlightType.GENERIC_ERROR_OR_WARNING); } }
Example #16
Source File: PhpElementsUtilTest.java From idea-php-symfony2-plugin with MIT License | 5 votes |
/** * @see fr.adrienbrault.idea.symfony2plugin.util.PhpElementsUtil#isMethodInstanceOf */ public void testIsMethodInstanceOf() { assertTrue(PhpElementsUtil.isMethodInstanceOf( PhpElementsUtil.getClassMethod(getProject(), "FooBar\\Bar", "getBar"), new MethodMatcher.CallToSignature("FooBar\\Foo", "getBar")) ); assertTrue(PhpElementsUtil.isMethodInstanceOf( PhpElementsUtil.getClassMethod(getProject(), "FooBar\\Car", "getBar"), new MethodMatcher.CallToSignature("FooBar\\Foo", "getBar")) ); }
Example #17
Source File: TranslationPlaceholderGotoCompletionRegistrar.java From idea-php-symfony2-plugin with MIT License | 5 votes |
@Nullable @Override public GotoCompletionProvider getProvider(@NotNull PsiElement psiElement) { PsiElement context = psiElement.getContext(); if (!(context instanceof StringLiteralExpression)) { return null; } MethodMatcher.MethodMatchParameter match = new MethodMatcher.ArrayParameterMatcher(context, placeHolderParameter) .withSignature("Symfony\\Component\\Translation\\TranslatorInterface", method) .withSignature("Symfony\\Contracts\\Translation\\TranslatorInterface", method) .match(); if (match == null) { return null; } PsiElement[] parameters = match.getMethodReference().getParameters(); String key = PhpElementsUtil.getStringValue(parameters[0]); if(key == null) { return null; } String domain = "messages"; if(parameters.length > domainParameter) { domain = PhpElementsUtil.getStringValue(parameters[domainParameter]); if(domain == null) { return null; } } return new MyTranslationPlaceholderGotoCompletionProvider(psiElement, key, domain); }
Example #18
Source File: ModelsControllerRelatedGotoCollector.java From idea-php-symfony2-plugin with MIT License | 5 votes |
@Override public void collectGotoRelatedItems(ControllerActionGotoRelatedCollectorParameter parameter) { List<PsiElement> uniqueTargets = new ArrayList<>(); for(PsiElement psiElement: parameter.getParameterLists()) { MethodMatcher.MethodMatchParameter matchedSignature = MethodMatcher.getMatchedSignatureWithDepth(psiElement, SymfonyPhpReferenceContributor.REPOSITORY_SIGNATURES); if (matchedSignature != null) { String resolveString = PhpElementsUtil.getStringValue(psiElement); if(resolveString != null) { for(PsiElement templateTarget: EntityHelper.getModelPsiTargets(parameter.getProject(), resolveString)) { if(!uniqueTargets.contains(templateTarget)) { uniqueTargets.add(templateTarget); // we can provide targets to model config and direct class targets if(templateTarget instanceof PsiFile) { parameter.add(new RelatedPopupGotoLineMarker.PopupGotoRelatedItem(templateTarget, resolveString).withIcon(templateTarget.getIcon(0), Symfony2Icons.DOCTRINE_LINE_MARKER)); } else { // @TODO: we can resolve for model types and provide icons, but not for now parameter.add(new RelatedPopupGotoLineMarker.PopupGotoRelatedItem(templateTarget, resolveString).withIcon(Symfony2Icons.DOCTRINE, Symfony2Icons.DOCTRINE_LINE_MARKER)); } } } } } } }
Example #19
Source File: AppConfigReferences.java From idea-php-laravel-plugin with MIT License | 5 votes |
@Override public void register(GotoCompletionRegistrarParameter registrar) { registrar.register(PlatformPatterns.psiElement(), psiElement -> { if(psiElement == null || !LaravelProjectComponent.isEnabled(psiElement)) { return null; } PsiElement parent = psiElement.getParent(); if(parent != null && (PsiElementUtils.isFunctionReference(parent, "config", 0) || MethodMatcher.getMatchedSignatureWithDepth(parent, CONFIG) != null)) { return new ConfigKeyProvider(parent); } return null; }); }
Example #20
Source File: PhpFoldingBuilder.java From idea-php-symfony2-plugin with MIT License | 5 votes |
private void attachModelShortcuts(List<FoldingDescriptor> descriptors, final StringLiteralExpression stringLiteralExpression) { if (MethodMatcher.getMatchedSignatureWithDepth(stringLiteralExpression, SymfonyPhpReferenceContributor.REPOSITORY_SIGNATURES) == null) { return; } String content = stringLiteralExpression.getContents(); for(String lastChar: new String[] {":", "\\"}) { if(content.contains(lastChar)) { final String replace = content.substring(content.lastIndexOf(lastChar) + 1); if(replace.length() > 0) { descriptors.add(new FoldingDescriptor(stringLiteralExpression.getNode(), new TextRange(stringLiteralExpression.getTextRange().getStartOffset() + 1, stringLiteralExpression.getTextRange().getEndOffset() - 1)) { @Nullable @Override public String getPlaceholderText() { return replace; } }); } return; } } }
Example #21
Source File: PhpFoldingBuilder.java From idea-php-symfony2-plugin with MIT License | 5 votes |
private void attachRouteShortcuts(List<FoldingDescriptor> descriptors, Collection<StringLiteralExpression> stringLiteralExpressions) { Map<String,Route> routes = null; for(StringLiteralExpression stringLiteralExpression: stringLiteralExpressions) { if (MethodMatcher.getMatchedSignatureWithDepth(stringLiteralExpression, PhpRouteReferenceContributor.GENERATOR_SIGNATURES) != null) { // cache routes if we need them if(routes == null) { routes = RouteHelper.getAllRoutes(stringLiteralExpression.getProject()); } String contents = stringLiteralExpression.getContents(); if(contents.length() > 0 && routes.containsKey(contents)) { final Route route = routes.get(contents); final String url = RouteHelper.getRouteUrl(route); if(url != null) { descriptors.add(new FoldingDescriptor(stringLiteralExpression.getNode(), new TextRange(stringLiteralExpression.getTextRange().getStartOffset() + 1, stringLiteralExpression.getTextRange().getEndOffset() - 1)) { @Nullable @Override public String getPlaceholderText() { return url; } }); } } } } }
Example #22
Source File: PhpCommandGotoCompletionRegistrar.java From idea-php-symfony2-plugin with MIT License | 5 votes |
@Override public void register(@NotNull GotoCompletionRegistrarParameter registrar) { registrar.register(PlatformPatterns.psiElement().withParent(StringLiteralExpression.class).withLanguage(PhpLanguage.INSTANCE), psiElement -> { PsiElement context = psiElement.getContext(); if (!(context instanceof StringLiteralExpression)) { return null; } for(String s : new String[] {"Option", "Argument"}) { MethodMatcher.MethodMatchParameter methodMatchParameter = new MethodMatcher.StringParameterRecursiveMatcher(context, 0) .withSignature("Symfony\\Component\\Console\\Input\\InputInterface", "get" + s) .withSignature("Symfony\\Component\\Console\\Input\\InputInterface", "has" + s) .match(); if(methodMatchParameter != null) { PhpClass phpClass = PsiTreeUtil.getParentOfType(methodMatchParameter.getMethodReference(), PhpClass.class); if(phpClass != null) { return new CommandGotoCompletionProvider(phpClass, s); } } } return null; }); }
Example #23
Source File: ConsoleHelperGotoCompletionRegistrar.java From idea-php-symfony2-plugin with MIT License | 5 votes |
@Override public void register(@NotNull GotoCompletionRegistrarParameter registrar) { registrar.register(PlatformPatterns.psiElement().withParent(StringLiteralExpression.class).withLanguage(PhpLanguage.INSTANCE), psiElement -> { PsiElement context = psiElement.getContext(); if (!(context instanceof StringLiteralExpression)) { return null; } if (MethodMatcher.getMatchedSignatureWithDepth(context, CONSOLE_HELP_SET) == null) { return null; } return new MyGotoCompletionProvider(psiElement); }); }
Example #24
Source File: AssetGotoCompletionRegistrar.java From idea-php-laravel-plugin with MIT License | 5 votes |
@Override public void register(GotoCompletionRegistrarParameter registrar) { /* * view('caret'); * Factory::make('caret'); */ registrar.register(PlatformPatterns.psiElement().withParent(StringLiteralExpression.class).withLanguage(PhpLanguage.INSTANCE), psiElement -> { if(psiElement == null || !LaravelProjectComponent.isEnabled(psiElement)) { return null; } PsiElement stringLiteral = psiElement.getParent(); if(!(stringLiteral instanceof StringLiteralExpression)) { return null; } if(!( PsiElementUtils.isFunctionReference(stringLiteral, "asset", 0) || PsiElementUtils.isFunctionReference(stringLiteral, "secure_asset", 0) || PsiElementUtils.isFunctionReference(stringLiteral, "secureAsset", 0) ) && MethodMatcher.getMatchedSignatureWithDepth(stringLiteral, ASSETS) == null) { return null; } return new AssetGotoCompletionProvider(stringLiteral); }); }
Example #25
Source File: FormOptionGotoCompletionRegistrar.java From idea-php-symfony2-plugin with MIT License | 5 votes |
@Nullable @Override public GotoCompletionProvider getProvider(@NotNull PsiElement psiElement) { PsiElement context = psiElement.getContext(); if (!(context instanceof StringLiteralExpression)) { return null; } MethodMatcher.StringParameterRecursiveMatcher matcher = new MethodMatcher.StringParameterRecursiveMatcher(context, 0); String[] methods = new String[] { "setDefault", "hasDefault", "isRequired", "isMissing", "setAllowedValues", "addAllowedValues", "setAllowedTypes", "addAllowedTypes" }; // @TODO: drop too many classes, add PhpMatcher for (String method : methods) { matcher.withSignature("Symfony\\Component\\OptionsResolver\\OptionsResolver", method); // BC: Symfony < 3 matcher.withSignature("Symfony\\Component\\OptionsResolver\\OptionsResolverInterface", method); } if (matcher.match() == null) { return null; } return new FormOptionGotoCompletionProvider(psiElement); }
Example #26
Source File: Symfony2InterfacesUtil.java From idea-php-laravel-plugin with MIT License | 5 votes |
private List<Method> getCallToSignatureInterfaceMethods(PsiElement e, Collection<MethodMatcher.CallToSignature> signatures) { List<Method> methods = new ArrayList<Method>(); for(MethodMatcher.CallToSignature signature: signatures) { Method method = getInterfaceMethod(e.getProject(), signature.getInstance(), signature.getMethod()); if(method != null) { methods.add(method); } } return methods; }
Example #27
Source File: MatcherUtil.java From idea-php-symfony2-plugin with MIT License | 5 votes |
@Nullable public static MethodMatcher.MethodMatchParameter matchJoin(PsiElement psiElement) { return new MethodMatcher.StringParameterMatcher(psiElement, 0) .withSignature("\\Doctrine\\ORM\\QueryBuilder", "join") .withSignature("\\Doctrine\\ORM\\QueryBuilder", "leftJoin") .withSignature("\\Doctrine\\ORM\\QueryBuilder", "rightJoin") .withSignature("\\Doctrine\\ORM\\QueryBuilder", "innerJoin") .match(); }
Example #28
Source File: Symfony2InterfacesUtil.java From idea-php-laravel-plugin with MIT License | 5 votes |
public static Collection<MethodMatcher.CallToSignature> getFormBuilderInterface() { Collection<MethodMatcher.CallToSignature> signatures = new ArrayList<MethodMatcher.CallToSignature>(); signatures.add(new MethodMatcher.CallToSignature("\\Symfony\\Component\\Form\\FormBuilderInterface", "add")); signatures.add(new MethodMatcher.CallToSignature("\\Symfony\\Component\\Form\\FormBuilderInterface", "create")); signatures.add(new MethodMatcher.CallToSignature("\\Symfony\\Component\\Form\\FormInterface", "add")); signatures.add(new MethodMatcher.CallToSignature("\\Symfony\\Component\\Form\\FormInterface", "create")); return signatures; }
Example #29
Source File: PhpGoToHandler.java From idea-php-shopware-plugin with MIT License | 5 votes |
private void attachNamespaceNavigation(@NotNull PsiElement psiElement, @NotNull List<PsiElement> psiElements) { PsiElement parent = psiElement.getParent(); if(!(parent instanceof StringLiteralExpression)) { return; } String contents = ((StringLiteralExpression) parent).getContents(); if(StringUtils.isBlank(contents)) { return; } MethodMatcher.MethodMatchParameter match = MethodMatcher.getMatchedSignatureWithDepth(parent, ShopwarePhpCompletion.CONFIG_NAMESPACE); if(match == null) { return; } ConfigUtil.visitNamespace(psiElement.getProject(), pair -> { if(contents.equalsIgnoreCase(pair.getFirst())) { PhpClass phpClass = pair.getSecond(); PsiElement target = phpClass; // PhpClass or "Resources/config.xml" as target PsiDirectory pluginDir = phpClass.getContainingFile().getParent(); if(pluginDir != null) { VirtualFile resources = VfsUtil.findRelativeFile(pluginDir.getVirtualFile(), "Resources", "config.xml"); if(resources != null) { PsiFile file = PsiManager.getInstance(phpClass.getProject()).findFile(resources); if(file instanceof XmlFile) { target = file; } } } psiElements.add(target); } }); }
Example #30
Source File: QueryBuilderGotoDeclarationHandler.java From idea-php-symfony2-plugin with MIT License | 5 votes |
private void attachExprGoto(StringLiteralExpression psiElement, List<PsiElement> targets) { MethodMatcher.MethodMatchParameter methodMatchParameter = new MethodMatcher.StringParameterMatcher(psiElement, 0) .withSignature(QueryBuilderCompletionContributor.EXPR) .match(); if(methodMatchParameter == null) { return; } // simple resolve query inline instance usage // $qb->expr()->in('') MethodReference methodReference = methodMatchParameter.getMethodReference(); PsiElement methodReferenceChild = methodReference.getFirstChild(); if(!(methodReferenceChild instanceof MethodReference)) { return; } QueryBuilderMethodReferenceParser qb = QueryBuilderCompletionContributor.getQueryBuilderParser((MethodReference) methodReferenceChild); if(qb == null) { return; } String propertyContent = psiElement.getContents(); QueryBuilderScopeContext collect = qb.collect(); for(Map.Entry<String, QueryBuilderPropertyAlias> entry: collect.getPropertyAliasMap().entrySet()) { if(entry.getKey().equals(propertyContent)) { targets.addAll(entry.getValue().getPsiTargets()); } } }