@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 parameters,
        ProcessingContext processingContext,
        @NotNull CompletionResultSet completionResultSet) {

      PsiElement position = parameters.getPosition();
      if (!Symfony2ProjectComponent.isEnabled(position)) {
        return;
      }

      PsiElement prevSiblingOfType =
          PsiElementUtils.getPrevSiblingOfType(
              position, YamlElementPatternHelper.getPreviousCommaSibling());
      if (prevSiblingOfType == null) {
        return;
      }

      String service = PsiElementUtils.trimQuote(prevSiblingOfType.getText());
      if (StringUtils.isBlank(service)) {
        return;
      }

      PhpClass phpClass = ServiceUtil.getServiceClass(prevSiblingOfType.getProject(), service);
      if (phpClass == null) {
        return;
      }

      for (Method method : phpClass.getMethods()) {
        if (method.getAccess().isPublic() && !(method.getName().startsWith("__"))) {
          completionResultSet.addElement(new PhpLookupElement(method));
        }
      }
    }
  protected PsiElement[] parameterGoToDeclaration(PsiElement psiElement, String psiParameterName) {

    if (!YamlHelper.isValidParameterName(psiParameterName)) {
      return new PsiElement[0];
    }

    Collection<PsiElement> targets =
        ServiceUtil.getServiceClassTargets(psiElement.getProject(), psiParameterName);
    return targets.toArray(new PsiElement[targets.size()]);
  }
  private static void addYamlClassMethods(
      @Nullable PsiElement psiElement, CompletionResultSet completionResultSet, String classTag) {

    if (psiElement == null) {
      return;
    }

    YAMLKeyValue classKeyValue =
        PsiElementUtils.getChildrenOfType(
            psiElement, PlatformPatterns.psiElement(YAMLKeyValue.class).withName(classTag));
    if (classKeyValue == null) {
      return;
    }

    PhpClass phpClass =
        ServiceUtil.getResolvedClassDefinition(
            psiElement.getProject(), classKeyValue.getValueText());
    if (phpClass != null) {
      PhpElementsUtil.addClassPublicMethodCompletion(completionResultSet, phpClass);
    }
  }
    @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));
          }
        }
      }
    }