@Override protected void addCompletions( @NotNull CompletionParameters completionParameters, ProcessingContext processingContext, @NotNull CompletionResultSet completionResultSet) { YAMLKeyValue yamlKeyValue = PsiTreeUtil.getParentOfType( completionParameters.getOriginalPosition(), YAMLKeyValue.class); if (yamlKeyValue != null) { PsiElement compoundValue = yamlKeyValue.getParent(); if (compoundValue instanceof YAMLCompoundValue) { // path and pattern are valid String pattern = YamlHelper.getYamlKeyValueAsString((YAMLCompoundValue) compoundValue, "path", false); if (pattern == null) { pattern = YamlHelper.getYamlKeyValueAsString( (YAMLCompoundValue) compoundValue, "pattern", false); } if (pattern != null) { Matcher matcher = Pattern.compile("\\{(\\w+)}").matcher(pattern); while (matcher.find()) { completionResultSet.addElement(LookupElementBuilder.create(matcher.group(1))); } } } } }
@Override protected void addCompletions( @NotNull CompletionParameters completionParameters, ProcessingContext processingContext, @NotNull CompletionResultSet completionResultSet) { PsiElement position = completionParameters.getPosition(); if (!Symfony2ProjectComponent.isEnabled(position)) { return; } YAMLCompoundValue yamlCompoundValue = PsiTreeUtil.getParentOfType(position, YAMLCompoundValue.class); if (yamlCompoundValue == null) { return; } String className = YamlHelper.getYamlKeyValueAsString(yamlCompoundValue, "targetEntity", false); if (className == null) { return; } PhpClass phpClass = PhpElementsUtil.getClass(position.getProject(), className); if (phpClass == null) { return; } for (DoctrineModelField field : EntityHelper.getModelFields(phpClass)) { if (field.getRelation() != null) { completionResultSet.addElement(new DoctrineModelFieldLookupElement(field)); } } }
@Override protected void addCompletions( @NotNull CompletionParameters completionParameters, ProcessingContext processingContext, @NotNull CompletionResultSet completionResultSet) { if (!Symfony2ProjectComponent.isEnabled(completionParameters.getPosition())) { return; } PsiElement psiElement = completionParameters.getPosition(); YAMLCompoundValue yamlCompoundValue = PsiTreeUtil.getParentOfType(psiElement, YAMLCompoundValue.class); if (yamlCompoundValue == null) { return; } yamlCompoundValue = PsiTreeUtil.getParentOfType(yamlCompoundValue, YAMLCompoundValue.class); if (yamlCompoundValue == null) { return; } String value = YamlHelper.getYamlKeyValueAsString(yamlCompoundValue, "class", true); if (value != null) { PhpClass phpClass = ServiceUtil.getResolvedClassDefinition(psiElement.getProject(), value); if (phpClass != null) { FormUtil.attachFormAliasesCompletions(phpClass, completionResultSet); } } }
@Override protected void addCompletions( @NotNull CompletionParameters completionParameters, ProcessingContext processingContext, @NotNull CompletionResultSet completionResultSet) { PsiElement position = completionParameters.getPosition(); if (!Symfony2ProjectComponent.isEnabled(position)) { return; } PsiElement psiElement = PsiTreeUtil.findFirstParent( position, new Condition<PsiElement>() { @Override public boolean value(PsiElement psiElement) { if (psiElement instanceof YAMLKeyValue) { String s = ((YAMLKeyValue) psiElement).getKeyText().toLowerCase(); if ("joinTable".equalsIgnoreCase(s)) { return true; } } return false; } }); if (psiElement == null) { return; } PsiElement yamlCompoundValue = psiElement.getParent(); if (!(yamlCompoundValue instanceof YAMLCompoundValue)) { return; } String className = YamlHelper.getYamlKeyValueAsString( (YAMLCompoundValue) yamlCompoundValue, "targetEntity", false); if (className == null) { return; } PhpClass phpClass = ServiceUtil.getResolvedClassDefinition(psiElement.getProject(), className); if (phpClass == null) { return; } for (DoctrineModelField field : EntityHelper.getModelFields(phpClass)) { if (field.getRelation() == null) { String columnName = field.getColumn(); if (columnName == null) { completionResultSet.addElement( LookupElementBuilder.create(field.getName()).withIcon(Symfony2Icons.DOCTRINE)); } else { completionResultSet.addElement( LookupElementBuilder.create(columnName) .withTypeText(field.getName(), false) .withIcon(Symfony2Icons.DOCTRINE)); } } } }