@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)));
            }
          }
        }
      }
    }
  public static boolean isPathPackageDefinition(@NotNull final YAMLKeyValue element) {
    if (!PubspecYamlUtil.PUBSPEC_YAML.equals(element.getContainingFile().getName())) return false;
    if (!PubspecYamlUtil.PATH.equals(element.getKeyText())) return false;

    final PsiElement parent1 = element.getParent();
    final PsiElement parent2 = parent1 instanceof YAMLCompoundValue ? parent1.getParent() : null;
    final String packageName =
        parent2 instanceof YAMLKeyValue ? ((YAMLKeyValue) parent2).getKeyText() : null;
    if (packageName == null) return false;

    final PsiElement parent3 = parent2.getParent();
    final PsiElement parent4 = parent3 instanceof YAMLCompoundValue ? parent3.getParent() : null;
    return parent4 instanceof YAMLKeyValue
        && parent4.getParent() instanceof YAMLDocument
        && ((PubspecYamlUtil.DEPENDENCIES.equals(((YAMLKeyValue) parent4).getKeyText())
            || PubspecYamlUtil.DEV_DEPENDENCIES.equals(((YAMLKeyValue) parent4).getKeyText())));
  }
 private static void addBasePathCompletionsIfNeeded(
     @NotNull CompletionParameters parameters,
     @NotNull CompletionResultSet result,
     @NotNull BipartiteString caretBipartiteElementText) {
   YAMLKeyValue keyValue =
       ObjectUtils.tryCast(parameters.getPosition().getParent(), YAMLKeyValue.class);
   if (keyValue != null) {
     if (keyValue.getParent() instanceof YAMLDocument && BasePathInfo.isBasePathKey(keyValue)) {
       BasePathInfo basePathInfo = newBasePathInfo(parameters);
       if (basePathInfo != null) {
         VirtualFile configDir = basePathInfo.getConfigDir();
         if (configDir != null) {
           addPathCompletions(result, caretBipartiteElementText, configDir, true);
         }
       }
     }
   }
 }
 private static void addInnerSequencePathCompletionsIfNeeded(
     @NotNull CompletionParameters parameters,
     @NotNull CompletionResultSet result,
     @NotNull BipartiteString caretBipartiteElementText) {
   PsiElement element = parameters.getPosition();
   YAMLKeyValue keyValue =
       JstdConfigFileUtils.getVerifiedHierarchyHead(
           element.getParent(),
           new Class[] {YAMLSequence.class, YAMLCompoundValue.class},
           YAMLKeyValue.class);
   BasePathInfo basePathInfo = newBasePathInfo(parameters);
   boolean keyMatched =
       keyValue != null && JstdConfigFileUtils.isTopLevelKeyWithInnerFileSequence(keyValue);
   if (basePathInfo != null && keyMatched) {
     VirtualFile basePath = basePathInfo.getBasePath();
     if (basePath != null && keyValue.getParent() instanceof YAMLDocument) {
       addPathCompletions(result, caretBipartiteElementText, basePath, false);
     }
   }
 }
  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);
    }
  }
    protected void addCompletions(
        @NotNull CompletionParameters completionParameters,
        ProcessingContext processingContext,
        @NotNull CompletionResultSet completionResultSet) {

      if (!Symfony2ProjectComponent.isEnabled(completionParameters.getPosition())) {
        return;
      }

      // TODO: move this to pattern; filters match on parameter array
      // - [ setContainer, [ @service_container ] ]
      PsiElement psiElement = completionParameters.getPosition();
      if (psiElement.getParent() == null
          || !(psiElement.getParent().getContext() instanceof YAMLSequence)) {
        return;
      }

      YAMLKeyValue callYamlKeyValue = PsiTreeUtil.getParentOfType(psiElement, YAMLKeyValue.class);
      if (callYamlKeyValue == null) {
        return;
      }

      addYamlClassMethods(callYamlKeyValue.getContext(), completionResultSet, "class");
    }