@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) {

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

    XmlEventParser xmlEventParser =
        ServiceXmlParserFactory.getInstance(
            completionParameters.getPosition().getProject(), XmlEventParser.class);
    for (Map.Entry<String, String> event : xmlEventParser.get().entrySet()) {
      completionResultSet.addElement(
          LookupElementBuilder.create(event.getKey())
              .withTypeText(event.getValue(), true)
              .withIcon(Symfony2Icons.EVENT));
    }

    for (EventDispatcherSubscribedEvent event :
        EventDispatcherSubscriberUtil.getSubscribedEvents(
            completionParameters.getPosition().getProject())) {
      completionResultSet.addElement(
          LookupElementBuilder.create(event.getStringValue())
              .withTypeText("EventSubscriber", true)
              .withIcon(Symfony2Icons.EVENT));
    }
  }
 public TypeCompletionHandler(
     @NotNull CompletionParameters parameters, @NotNull CompletionResultSet result, int weight) {
   super(parameters, result);
   _filter = getDefaultFilter(parameters.getPosition());
   _weight = weight;
   _prefixMatcher = result.getPrefixMatcher();
   _javaCtx = parameters.getPosition() instanceof PsiIdentifier;
 }
  @Override
  public void fillCompletionVariants(CompletionParameters parameters, CompletionResultSet result) {
    PsiFile file = parameters.getOriginalFile();
    final Consumer<Task> consumer = file.getUserData(KEY);

    if (CompletionService.getCompletionService().getAdvertisementText() == null) {
      final String shortcut = getActionShortcut(IdeActions.ACTION_QUICK_JAVADOC);
      if (shortcut != null) {
        CompletionService.getCompletionService()
            .setAdvertisementText(
                "Pressing " + shortcut + " would show task description and comments");
      }
    }

    if (consumer != null) {
      result.stopHere();

      String text = parameters.getOriginalFile().getText();
      int i = text.lastIndexOf(' ', parameters.getOffset() - 1) + 1;
      final String prefix = text.substring(i, parameters.getOffset());
      if (parameters.getInvocationCount() == 0
          && !file.getUserData(AUTO_POPUP_KEY)) { // is autopopup
        return;
      }
      result = result.withPrefixMatcher(new PlainPrefixMatcher(prefix));

      final TaskSearchSupport searchSupport = new TaskSearchSupport(file.getProject());
      List<Task> items = searchSupport.getItems(prefix, true);
      addCompletionElements(result, consumer, items, -10000);

      Future<List<Task>> future =
          ApplicationManager.getApplication()
              .executeOnPooledThread(
                  new Callable<List<Task>>() {
                    @Override
                    public List<Task> call() {
                      return searchSupport.getItems(prefix, false);
                    }
                  });

      while (true) {
        try {
          List<Task> tasks = future.get(100, TimeUnit.MILLISECONDS);
          if (tasks != null) {
            addCompletionElements(result, consumer, tasks, 0);
            return;
          }
        } catch (ProcessCanceledException e) {
          throw e;
        } catch (Exception ignore) {

        }
        ProgressManager.checkCanceled();
      }
    }
  }
 private static boolean isTopLevelKeyCompletion(@NotNull CompletionParameters parameters) {
   PsiElement psiElement = parameters.getPosition();
   Document document = JsPsiUtils.getDocument(parameters.getOriginalFile());
   if (document != null) {
     TextRange textRange = psiElement.getTextRange();
     int startLine = document.getLineNumber(textRange.getStartOffset());
     int startOffset = document.getLineStartOffset(startLine);
     return startOffset == textRange.getStartOffset();
   }
   return false;
 }
  @Override
  public AutoCompletionDecision handleAutoCompletionPossibility(
      @NotNull AutoCompletionContext context) {
    final CompletionParameters parameters = context.getParameters();

    if (parameters.getCompletionType() != CompletionType.SMART
        && parameters.getCompletionType() != CompletionType.BASIC) {
      return null;
    }

    boolean needInsertBrace = false;
    boolean needInsertParenth = false;

    final LookupElement[] items = context.getItems();
    if (items.length > 1) {
      String commonName = null;
      final ArrayList<PsiMethod> allMethods = new ArrayList<PsiMethod>();
      for (LookupElement item : items) {
        Object o = item.getPsiElement();
        if (item.getUserData(LookupItem.FORCE_SHOW_SIGNATURE_ATTR) != null
            || !(o instanceof PsiMethod)) {
          return AutoCompletionDecision.SHOW_LOOKUP;
        }

        final PsiMethod method = (PsiMethod) o;
        final JavaChainLookupElement chain = item.as(JavaChainLookupElement.CLASS_CONDITION_KEY);
        final String name =
            method.getName() + "#" + (chain == null ? "" : chain.getQualifier().getLookupString());

        if (commonName != null && !commonName.equals(name)) {
          return AutoCompletionDecision.SHOW_LOOKUP;
        }

        if (hasOnlyClosureParams(method)) {
          needInsertBrace = true;
        } else {
          needInsertParenth = true;
        }

        if (needInsertBrace && needInsertParenth) {
          return AutoCompletionDecision.SHOW_LOOKUP;
        }

        commonName = name;
        allMethods.add(method);
        item.putUserData(JavaCompletionUtil.ALL_METHODS_ATTRIBUTE, allMethods);
      }
      return AutoCompletionDecision.insertItem(
          JavaMethodMergingContributor.findBestOverload(items));
    }

    return super.handleAutoCompletionPossibility(context);
  }
 protected void createFollowElementBasedProposals(
     final CompletionParameters parameters, final CompletionResultSet result) {
   boolean _or = false;
   boolean _isEmpty = this.myFollowElementBasedContributors.isEmpty();
   if (_isEmpty) {
     _or = true;
   } else {
     CompletionType _completionType = parameters.getCompletionType();
     boolean _containsKey = this.myFollowElementBasedContributors.containsKey(_completionType);
     boolean _not = (!_containsKey);
     _or = _not;
   }
   if (_or) {
     return;
   }
   Editor _editor = parameters.getEditor();
   int _offset = parameters.getOffset();
   final TokenSet tokenSet = this._tokenSetProvider.getTokenSet(((EditorEx) _editor), _offset);
   CompletionType _completionType_1 = parameters.getCompletionType();
   Map<TokenSet, Multimap<AbstractElement, CompletionProvider<CompletionParameters>>> _get =
       this.myFollowElementBasedContributors.get(_completionType_1);
   final Multimap<AbstractElement, CompletionProvider<CompletionParameters>> element2provider =
       _get.get(tokenSet);
   boolean _equals = Objects.equal(element2provider, null);
   if (_equals) {
     return;
   }
   final Set<AbstractElement> followElements = this.computeFollowElements(parameters);
   final HashSet<CompletionProvider<CompletionParameters>> calledProviders =
       CollectionLiterals.<CompletionProvider<CompletionParameters>>newHashSet();
   Set<AbstractElement> _keySet = element2provider.keySet();
   for (final AbstractElement followElement : _keySet) {
     {
       final ProcessingContext context = new ProcessingContext();
       boolean _contains = followElements.contains(followElement);
       if (_contains) {
         final Collection<CompletionProvider<CompletionParameters>> providers =
             element2provider.get(followElement);
         for (final CompletionProvider<CompletionParameters> provider : providers) {
           boolean _add = calledProviders.add(provider);
           if (_add) {
             provider.addCompletionVariants(parameters, context, result);
             boolean _isStopped = result.isStopped();
             if (_isStopped) {
               return;
             }
           }
         }
       }
     }
   }
 }
 protected Set<AbstractElement> computeFollowElements(final CompletionParameters parameters) {
   Editor _editor = parameters.getEditor();
   Document _document = _editor.getDocument();
   PsiElement _position = parameters.getPosition();
   ASTNode _node = _position.getNode();
   int _startOffset = _node.getStartOffset();
   TextRange _textRange = new TextRange(0, _startOffset);
   final String text = _document.getText(_textRange);
   final Collection<FollowElement> followElements =
       this.contentAssistParser.getFollowElements(text, false);
   final HashSet<AbstractElement> allElements = CollectionLiterals.<AbstractElement>newHashSet();
   this.followElementComputer.computeFollowElements(followElements, allElements);
   return allElements;
 }
  @Override
  public void fillCompletionVariants(
      @NotNull CompletionParameters parameters, @NotNull CompletionResultSet result) {
    Project project = parameters.getEditor().getProject();
    assert project != null;

    JsonSchemaService service = JsonSchemaService.Impl.get(project);
    assert service != null;

    CompletionContributor delegate =
        service.getCompletionContributor(parameters.getOriginalFile().getVirtualFile());
    if (delegate != null) {
      delegate.fillCompletionVariants(parameters, result);
    }
  }
 @Override
 public void fillCompletionVariants(
     CompletionParameters parameters, final CompletionResultSet result) {
   if (parameters.isExtendedCompletion()) {
     CompletionService.getCompletionService()
         .getVariantsFromContributors(
             parameters.delegateToClassName(),
             null,
             new Consumer<CompletionResult>() {
               public void consume(final CompletionResult completionResult) {
                 result.passResult(completionResult);
               }
             });
   }
 }
    @Override
    protected void addCompletions(
        @NotNull CompletionParameters completionParameters,
        final ProcessingContext processingContext,
        @NotNull final CompletionResultSet completionResultSet) {

      PsiFile originalFile = completionParameters.getOriginalFile();
      final PsiDirectory containingDirectory = originalFile.getContainingDirectory();
      if (containingDirectory == null) {
        return;
      }

      final VirtualFile containingDirectoryFiles = containingDirectory.getVirtualFile();
      VfsUtil.visitChildrenRecursively(
          containingDirectoryFiles,
          new VirtualFileVisitor() {
            @Override
            public boolean visitFile(@NotNull VirtualFile file) {

              String relativePath = VfsUtil.getRelativePath(file, containingDirectoryFiles, '/');
              if (relativePath == null) {
                return super.visitFile(file);
              }

              completionResultSet.addElement(
                  LookupElementBuilder.create(relativePath).withIcon(file.getFileType().getIcon()));

              return super.visitFile(file);
            }
          });
    }
    @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));
        }
      }
    }
    @Override
    protected void addCompletions(
        @NotNull CompletionParameters parameters,
        ProcessingContext context,
        @NotNull CompletionResultSet result) {

      for (String[] completion :
          RegExpLanguageHosts.getInstance().getPosixCharacterClasses(parameters.getPosition())) {
        result.addElement(
            LookupElementBuilder.create(completion[0])
                .withTypeText((completion.length > 1) ? completion[1] : null)
                .withIcon(emptyIcon)
                .withInsertHandler(
                    new InsertHandler<LookupElement>() {
                      @Override
                      public void handleInsert(InsertionContext context, LookupElement item) {
                        context.setAddCompletionChar(false);
                        final Editor editor = context.getEditor();
                        final Document document = editor.getDocument();
                        final int tailOffset = context.getTailOffset();
                        if (document.getTextLength() < tailOffset + 2
                            || !document
                                .getText(new TextRange(tailOffset, tailOffset + 2))
                                .equals(":]")) {
                          document.insertString(tailOffset, ":]");
                        }
                        editor.getCaretModel().moveCaretRelatively(2, 0, false, false, true);
                      }
                    }));
      }
    }
    public void addCompletions(
        @NotNull CompletionParameters parameters,
        ProcessingContext context,
        @NotNull CompletionResultSet resultSet) {

      PsiElement element = parameters.getPosition().getParent();
      Project project = element.getProject();

      if (!SilexProjectComponent.isEnabled(project)) {
        return;
      }

      if (!(element instanceof StringLiteralExpression)) {
        return;
      }

      Container container =
          Utils.findContainerForFirstParameterOfPimpleMethod((StringLiteralExpression) element);
      if (container == null) {
        return;
      }

      for (Service service : container.getServices().values()) {
        resultSet.addElement(new ServiceLookupElement(service, project));
      }

      for (Parameter parameter : container.getParameters().values()) {
        resultSet.addElement(new ParameterLookupElement(parameter));
      }

      resultSet.stopHere();
    }
    @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)));
            }
          }
        }
      }
    }
  /**
   * this will try to autocomplete subroutines from package in block like this: use PACKAGE qw( sub1
   * sub2 ... )
   *
   * <p>returns true if contributed some results, false otherwise
   *
   * @return
   */
  public boolean tryAutocompletePackageSubImportBlock(
      PerlElement currentElement,
      @NotNull CompletionParameters parameters,
      @NotNull CompletionResultSet resultSet) {
    if (currentElement.isAny(PerlTypes.WHITESPACE, PerlTypes.BRACES, PerlTypes.PROPERTY)) {
      PerlElement maybeBrace = currentElement;
      if (!maybeBrace.is(
          PerlTypes.BRACES)) { // if we are not already on brace go back permitting only vars and
        // whitespace
        maybeBrace =
            maybeBrace.previousIgnoring(
                PerlTypes.WHITESPACE, PerlTypes.VARIABLE, PerlTypes.PROPERTY);
      }

      if (maybeBrace.is(
          PerlTypes.BRACES)) { // after going back check once more if it is brace already
        PerlElement tmp = maybeBrace.previousIgnoringWhitespace();
        if (tmp.is(PerlTypes.LANG_SYNTAX) && tmp.getText().equals("qw")) {
          PerlElement potentialPackage = tmp.previousIgnoringWhitespace();
          if (potentialPackage.is(PerlTypes.PACKAGE)) {
            tmp = potentialPackage.previousIgnoringWhitespace();
            if (tmp.is(PerlTypes.LANG_FUNCTION) && tmp.getText().equals("use")) {
              addAllSubsInPackage(resultSet, potentialPackage, false, parameters.isAutoPopup());
              return true;
            }
          }
        }
      }
    }
    return false;
  }
  private void addAllSubsInFile(
      CompletionParameters parameters, CompletionResultSet resultSet, boolean limitResults) {
    ArrayList<Package> packageList =
        ModulesContainer.getPackageListFromFile(
            parameters.getOriginalFile().getVirtualFile().getCanonicalPath());

    for (int i = 0; i < packageList.size(); i++) {
      ArrayList<Sub> subs = packageList.get(i).getAllSubs();
      int amount =
          (false)
              ? Math.min(AUTO_POPUP_SUBS_ITEMS_LIMIT, subs.size())
              : subs.size(); // get all results only if users press ctrl+space
      for (int j = 0; j < amount; j++) {
        addCachedSub(resultSet, subs.get(j));
      }
      ArrayList<ImportedSub> importedSubs = packageList.get(i).getImportedSubs();
      amount =
          (false)
              ? Math.min(AUTO_POPUP_SUBS_ITEMS_LIMIT, importedSubs.size())
              : importedSubs.size(); // get all results only if users press ctrl+space

      for (int j = 0; j < amount; j++) {
        ArrayList<Package> packages =
            ModulesContainer.getPackageList(
                importedSubs.get(j).getContainingPackage()); // TODO: handle more than 1 package
        if (packages.size() > 0) {
          Sub sub = packages.get(0).getSubByName(importedSubs.get(j).getImportSub());
          if (sub != null) {
            addCachedSub(resultSet, sub);
          }
        }
      }
    }
  }
    @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));
        }
      }
    }
    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;
      }

      addYamlClassMethods(yamlCompoundValue, completionResultSet, this.yamlArrayKeyName);
    }
 private void addAllVariablesInFile(
     CompletionParameters parameters, CompletionResultSet resultSet, boolean limitResults) {
   HashSet<String> rs =
       findAllVariables(
           parameters.getOriginalFile().getNode().getChildren(null), PerlTypes.VARIABLE, false);
   for (String str : rs) {
     addCachedVariables(resultSet, str);
   }
 }
    @Override
    public void addCompletions(
        @NotNull final CompletionParameters parameters,
        final ProcessingContext context,
        @NotNull final CompletionResultSet result) {
      for (final String[] completion :
          RegExpLanguageHosts.getInstance().getKnownCharacterClasses(parameters.getPosition())) {
        addLookupElement(result, completion[0], completion[1], emptyIcon);
      }

      for (String[] stringArray :
          RegExpLanguageHosts.getInstance().getAllKnownProperties(parameters.getPosition())) {
        addLookupElement(
            result,
            "p{" + stringArray[0] + "}",
            stringArray.length > 1 ? stringArray[1] : null,
            PlatformIcons.PROPERTY_ICON);
      }
    }
  public void addCompletions(
      @NotNull final CompletionParameters parameters,
      final ProcessingContext context,
      @NotNull final CompletionResultSet result) {
    PsiElement element = parameters.getPosition();
    while (element != null && !(element instanceof CfmlAttributeImpl)) {
      element = element.getParent();
    }
    if (element == null) {
      return;
    }
    CfmlAttributeImpl attribute = (CfmlAttributeImpl) element;
    String attributeName = attribute.getFirstChild().getText();
    while (element != null && !(element instanceof CfmlTag)) {
      element = element.getParent();
    }
    if (element == null) {
      return;
    }
    CfmlTag tag = (CfmlTag) element;
    String tagName = tag.getTagName();

    String[] attributeValue =
        CfmlUtil.getAttributeValues(tagName, attributeName, parameters.getPosition().getProject());

    if ("type".equalsIgnoreCase(attributeName) && "cfargument".equalsIgnoreCase(tagName)
        || "returntype".equalsIgnoreCase(attributeName) && "cffunction".equalsIgnoreCase(tagName)) {
      Object[] objects =
          CfmlComponentReference.buildVariants(
              attribute.getPureAttributeValue(),
              element.getContainingFile(),
              element.getProject(),
              null,
              true);
      for (Object o : objects) {
        result.addElement((LookupElement) o);
      }
    }
    for (String s : attributeValue) {
      result.addElement(LookupElementBuilder.create(s).withCaseSensitivity(false));
    }
  }
    public void addCompletions(
        @NotNull CompletionParameters parameters,
        ProcessingContext context,
        @NotNull CompletionResultSet resultSet) {

      if (!YamlHelper.isRoutingFile(parameters.getOriginalFile())) {
        return;
      }

      super.addCompletions(parameters, context, resultSet);
    }
 @Nullable
 private static BasePathInfo newBasePathInfo(@NotNull CompletionParameters parameters) {
   YAMLFile yamlFile = ObjectUtils.tryCast(parameters.getOriginalFile(), YAMLFile.class);
   if (yamlFile != null) {
     List<YAMLDocument> yamlDocuments = yamlFile.getDocuments();
     if (!yamlDocuments.isEmpty()) {
       return new BasePathInfo(yamlDocuments.get(0));
     }
   }
   return null;
 }
    @Override
    protected void addCompletions(
        @NotNull CompletionParameters parameters,
        ProcessingContext processingContext,
        @NotNull CompletionResultSet completionResultSet) {

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

      PhpIndex phpIndex = PhpIndex.getInstance(parameters.getOriginalFile().getProject());
      for (PhpClass phpClass : phpIndex.getAllSubclasses("\\Doctrine\\ORM\\EntityRepository")) {
        String presentableFQN = phpClass.getPresentableFQN();
        if (presentableFQN != null) {
          completionResultSet.addElement(
              LookupElementBuilder.create(phpClass.getName())
                  .withTypeText(phpClass.getPresentableFQN(), true)
                  .withIcon(phpClass.getIcon()));
        }
      }
    }
 protected void createParserBasedProposals(
     final CompletionParameters parameters, final CompletionResultSet result) {
   Editor _editor = parameters.getEditor();
   int _offset = parameters.getOffset();
   final TokenSet tokenSet = this._tokenSetProvider.getTokenSet(((EditorEx) _editor), _offset);
   boolean _supportParserBasedProposals = this.supportParserBasedProposals(tokenSet);
   boolean _not = (!_supportParserBasedProposals);
   if (_not) {
     return;
   }
   final ContentAssistContextFactory delegate = this.getParserBasedDelegate();
   boolean _equals = Objects.equal(delegate, null);
   if (_equals) {
     return;
   }
   String _text = this.getText(parameters);
   TextRegion _selection = this.getSelection(parameters);
   int _offset_1 = parameters.getOffset();
   XtextResource _resource = this.getResource(parameters);
   final ContentAssistContext[] contexts =
       delegate.create(_text, _selection, _offset_1, _resource);
   final Procedure1<ContentAssistContext> _function =
       new Procedure1<ContentAssistContext>() {
         @Override
         public void apply(final ContentAssistContext c) {
           ImmutableList<AbstractElement> _firstSetGrammarElements =
               c.getFirstSetGrammarElements();
           final Procedure1<AbstractElement> _function =
               new Procedure1<AbstractElement>() {
                 @Override
                 public void apply(final AbstractElement e) {
                   AbstractCompletionContributor.this.createProposal(e, c, parameters, result);
                 }
               };
           IterableExtensions.<AbstractElement>forEach(_firstSetGrammarElements, _function);
         }
       };
   IterableExtensions.<ContentAssistContext>forEach(
       ((Iterable<ContentAssistContext>) Conversions.doWrapArray(contexts)), _function);
 }
 @Override
 public void addCompletions(
     @NotNull final CompletionParameters parameters,
     final ProcessingContext context,
     @NotNull final CompletionResultSet result) {
   for (String[] stringArray :
       RegExpLanguageHosts.getInstance().getAllKnownProperties(parameters.getPosition())) {
     result.addElement(
         TailTypeDecorator.withTail(
             createLookupElement(stringArray[0], null, emptyIcon),
             TailType.createSimpleTailType('}')));
   }
 }
  @NotNull
  @Override
  public ThreeState shouldFocusLookup(@NotNull CompletionParameters parameters) {
    final PsiElement position = parameters.getPosition();

    if (position.getParent() instanceof GrReferenceElement
        && psiElement()
            .afterLeaf(psiElement().withText("(").withParent(GrForStatement.class))
            .accepts(position)) {
      return ThreeState.NO;
    }

    if (position.getParent() instanceof GrReferenceExpression) {
      final GrReferenceExpression ref = (GrReferenceExpression) position.getParent();
      final GrExpression qualifier = ref.getQualifierExpression();
      if (qualifier == null) {
        if (isPossibleClosureParameter(ref)) return ThreeState.NO;
        if (parameters.getOriginalFile().getUserData(GroovyShellAction.GROOVY_SHELL_FILE)
            == Boolean.TRUE) {
          return ThreeState.NO;
        }

        GrExpression runtimeQualifier = PsiImplUtil.getRuntimeQualifier(ref);
        if (runtimeQualifier != null && runtimeQualifier.getType() == null) {
          return ThreeState.NO;
        }

        return ThreeState.YES;
      }

      if (qualifier.getType() == null) {
        return ThreeState.NO;
      }
      return ThreeState.YES;
    }
    return ThreeState.UNSURE;
  }
    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");
    }
 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);
         }
       }
     }
   }
 }