Java Code Examples for fr.adrienbrault.idea.symfony2plugin.util.PsiElementUtils#getMethodParameterAt()
The following examples show how to use
fr.adrienbrault.idea.symfony2plugin.util.PsiElementUtils#getMethodParameterAt() .
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: FormFieldNameReference.java From idea-php-symfony2-plugin with MIT License | 6 votes |
public static LookupElement[] getFormLookups(Method method) { MethodReference[] formBuilderTypes = FormUtil.getFormBuilderTypes(method); List<LookupElement> lookupElements = new ArrayList<>(); for(MethodReference methodReference: formBuilderTypes) { String fieldName = PsiElementUtils.getMethodParameterAt(methodReference, 0); if(fieldName != null) { LookupElementBuilder lookup = LookupElementBuilder.create(fieldName).withIcon(Symfony2Icons.FORM_TYPE); String fieldType = PsiElementUtils.getMethodParameterAt(methodReference, 1); if(fieldType != null) { lookup = lookup.withTypeText(fieldType, true); } lookupElements.add(lookup); } } return lookupElements.toArray(new LookupElement[lookupElements.size()]); }
Example 2
Source File: DefaultReferenceProvider.java From idea-php-symfony2-plugin with MIT License | 6 votes |
@Override public PsiReference getPsiReference(AssistantReferenceProviderParameter parameter) { String translationDomain = "messages"; // more than self match; search for translation_domain provider if(parameter.getConfigsMethodScope().size() > 1) { // last translation domain wins for(MethodParameterSetting config: parameter.getConfigsMethodScope()) { if(config.getReferenceProviderName().equals("translation_domain")) { String parameterValue = PsiElementUtils.getMethodParameterAt(parameter.getMethodReference(), config.getIndexParameter()); if(parameterValue != null) { translationDomain = parameterValue; } } } } return new TranslationReference(parameter.getPsiElement(), translationDomain); }
Example 3
Source File: FormFieldResolver.java From idea-php-symfony2-plugin with MIT License | 6 votes |
private static List<TwigTypeContainer> getTwigTypeContainer(Method method) { MethodReference[] formBuilderTypes = FormUtil.getFormBuilderTypes(method); List<TwigTypeContainer> twigTypeContainers = new ArrayList<>(); for(MethodReference methodReference: formBuilderTypes) { String fieldName = PsiElementUtils.getMethodParameterAt(methodReference, 0); PsiElement psiElement = PsiElementUtils.getMethodParameterPsiElementAt(methodReference, 1); TwigTypeContainer twigTypeContainer = new TwigTypeContainer(fieldName); // find form field type if(psiElement != null) { PhpClass phpClass = FormUtil.getFormTypeClassOnParameter(psiElement); if(phpClass != null) { twigTypeContainer.withDataHolder(new FormDataHolder(phpClass)); } } twigTypeContainers.add(twigTypeContainer); } return twigTypeContainers; }
Example 4
Source File: QueryBuilderMethodReferenceParser.java From idea-php-symfony2-plugin with MIT License | 5 votes |
private void collectJoins(QueryBuilderScopeContext qb, MethodReference methodReference, String name) { if(!collectJoins || !Arrays.asList("join", "leftJoin", "rightJoin", "innerJoin").contains(name)) { return; } String join = PsiElementUtils.getMethodParameterAt(methodReference, 0); String alias = PsiElementUtils.getMethodParameterAt(methodReference, 1); if(join != null && alias != null) { qb.addJoin(alias, new QueryBuilderJoin(join, alias)); } }
Example 5
Source File: QueryBuilderMethodReferenceParser.java From idea-php-symfony2-plugin with MIT License | 5 votes |
private void collectParameter(QueryBuilderScopeContext qb, MethodReference methodReference, String name) { if(!collectParameter || !Arrays.asList("where", "andWhere").contains(name)) { return; } String value = PsiElementUtils.getMethodParameterAt(methodReference, 0); if(value != null) { Matcher matcher = Pattern.compile(":(\\w+)", Pattern.MULTILINE).matcher(value); while(matcher.find()){ qb.addParameter(matcher.group(1)); } } }
Example 6
Source File: FormFieldNameReference.java From idea-php-symfony2-plugin with MIT License | 5 votes |
@Nullable @Override public PsiElement resolve() { MethodReference[] formBuilderTypes = FormUtil.getFormBuilderTypes(method); for(MethodReference methodReference: formBuilderTypes) { String fieldName = PsiElementUtils.getMethodParameterAt(methodReference, 0); if(fieldName != null && fieldName.equals(this.element.getContents())) { return methodReference; } } return null; }