Program: 15481
Project: 15481
Buggy source:
public TwigTemplateCompletionContributor(){
  extend(CompletionType.BASIC,TwigHelper.getTemplateFileReferenceTagPattern(),new TemplateCompletionProvider());
  extend(CompletionType.BASIC,TwigHelper.getPrintBlockFunctionPattern("String_Node_Str","String_Node_Str"),new TemplateCompletionProvider());
  extend(CompletionType.BASIC,TwigHelper.getTranslationPattern("String_Node_Str","String_Node_Str"),new CompletionProvider<CompletionParameters>(){
    public void addCompletions(    @NotNull CompletionParameters parameters,    ProcessingContext context,    @NotNull CompletionResultSet resultSet){
      if (!Symfony2ProjectComponent.isEnabled(parameters.getPosition())) {
        return;
      }
      TranslationStringMap map=TranslationIndex.getInstance(parameters.getPosition().getProject()).getTranslationMap();
      if (map == null) {
        return;
      }
      PsiElement psiElement=parameters.getPosition();
      String domainName=TwigUtil.getPsiElementTranslationDomain(psiElement);
      resultSet.addAllElements(TranslationUtil.getTranslationLookupElementsOnDomain(psiElement.getProject(),domainName));
    }
  }
);
  extend(CompletionType.BASIC,TwigHelper.getTransDomainPattern(),new CompletionProvider<CompletionParameters>(){
    public void addCompletions(    @NotNull CompletionParameters parameters,    ProcessingContext context,    @NotNull CompletionResultSet resultSet){
      if (!Symfony2ProjectComponent.isEnabled(parameters.getPosition())) {
        return;
      }
      if (PsiElementUtils.getPrevSiblingOfType(parameters.getPosition(),PlatformPatterns.psiElement(TwigTokenTypes.IDENTIFIER).withText(PlatformPatterns.string().oneOf("String_Node_Str","String_Node_Str"))) == null) {
        return;
      }
      resultSet.addAllElements(TranslationUtil.getTranslationDomainLookupElements(parameters.getPosition().getProject()));
    }
  }
);
  extend(CompletionType.BASIC,TwigHelper.getBlockTagPattern(),new BlockCompletionProvider());
  extend(CompletionType.BASIC,TwigHelper.getTemplateImportFileReferenceTagPattern(),new CompletionProvider<CompletionParameters>(){
    public void addCompletions(    @NotNull CompletionParameters parameters,    ProcessingContext context,    @NotNull CompletionResultSet resultSet){
      if (!Symfony2ProjectComponent.isEnabled(parameters.getPosition())) {
        return;
      }
      PsiElement psiElement=PsiElementUtils.getPrevSiblingOfType(parameters.getPosition(),getFromTemplateElement());
      if (psiElement == null) {
        return;
      }
      String templateName=psiElement.getText();
      Map<String,VirtualFile> twigFilesByName=TwigHelper.getTwigFilesByName(parameters.getPosition().getProject());
      if (!twigFilesByName.containsKey(templateName)) {
        return;
      }
      VirtualFile virtualFile=twigFilesByName.get(templateName);
      PsiFile psiFile=PsiManager.getInstance(psiElement.getProject()).findFile(virtualFile);
      if (psiFile != null) {
        for (        Map.Entry<String,String> entry : new TwigMarcoParser().getMacros(psiFile).entrySet()) {
          resultSet.addElement(LookupElementBuilder.create(entry.getKey()).withTypeText(entry.getValue(),true).withIcon(TwigIcons.TwigFileIcon));
        }
      }
    }
    private PsiElementPattern.Capture<PsiElement> getFromTemplateElement(){
      return PlatformPatterns.psiElement(TwigTokenTypes.STRING_TEXT).afterLeafSkipping(PlatformPatterns.or(PlatformPatterns.psiElement(PsiWhiteSpace.class),PlatformPatterns.psiElement(TwigTokenTypes.WHITE_SPACE),PlatformPatterns.psiElement(TwigTokenTypes.SINGLE_QUOTE),PlatformPatterns.psiElement(TwigTokenTypes.DOUBLE_QUOTE)),PlatformPatterns.psiElement(TwigTokenTypes.TAG_NAME).withText(PlatformPatterns.string().oneOf("String_Node_Str"))).withLanguage(TwigLanguage.INSTANCE);
    }
  }
);
  extend(CompletionType.SMART,PlatformPatterns.psiElement().withParent(PlatformPatterns.psiElement().withLanguage(TwigLanguage.INSTANCE)),new FilterCompletionProvider());
  extend(CompletionType.BASIC,PlatformPatterns.psiElement().withParent(PlatformPatterns.psiElement().withLanguage(TwigLanguage.INSTANCE)),new FilterCompletionProvider());
  extend(CompletionType.BASIC,TwigHelper.getCompletablePattern(),new CompletionProvider<CompletionParameters>(){
    public void addCompletions(    @NotNull CompletionParameters parameters,    ProcessingContext context,    @NotNull CompletionResultSet resultSet){
      if (!Symfony2ProjectComponent.isEnabled(parameters.getPosition())) {
        return;
      }
      PsiElement psiElement=parameters.getPosition().getOriginalElement();
      for (      Map.Entry<String,TwigExtension> entry : new TwigExtensionParser(parameters.getPosition().getProject()).getFunctions().entrySet()) {
        resultSet.addElement(new TwigExtensionLookupElement(psiElement.getProject(),entry.getKey(),entry.getValue()));
      }
      for (      TwigMacro twigMacro : TwigUtil.getImportedMacros(psiElement.getContainingFile())) {
        resultSet.addElement(LookupElementBuilder.create(twigMacro.getName()).withTypeText(twigMacro.getTemplate(),true).withIcon(TwigIcons.TwigFileIcon).withInsertHandler(FunctionInsertHandler.getInstance()));
      }
      for (      TwigMacro twigMacro : TwigUtil.getImportedMacrosNamespaces(psiElement.getContainingFile())) {
        resultSet.addElement(LookupElementBuilder.create(twigMacro.getName()).withTypeText(twigMacro.getTemplate(),true).withIcon(TwigIcons.TwigFileIcon).withInsertHandler(FunctionInsertHandler.getInstance()));
      }
      for (      TwigSet twigSet : TwigUtil.getSetDeclaration(psiElement.getContainingFile())) {
        resultSet.addElement(LookupElementBuilder.create(twigSet.getName()).withTypeText("String_Node_Str",true));
      }
      for (      Map.Entry<String,PsiVariable> entry : TwigTypeResolveUtil.collectScopeVariables(parameters.getOriginalPosition()).entrySet()) {
        resultSet.addElement(LookupElementBuilder.create(entry.getKey()).withTypeText(TwigTypeResolveUtil.getTypeDisplayName(psiElement.getProject(),entry.getValue().getTypes()),true).withIcon(PhpIcons.CLASS));
      }
      for (      Map.Entry<String,TwigGlobalVariable> entry : ServiceXmlParserFactory.getInstance(psiElement.getProject(),TwigGlobalsServiceParser.class).getTwigGlobals().entrySet()) {
        if (entry.getValue().getTwigGlobalEnum() == TwigGlobalEnum.TEXT) {
          resultSet.addElement(LookupElementBuilder.create(entry.getKey()).withTypeText(entry.getValue().getValue(),true).withIcon(PhpIcons.CONSTANT));
        }
      }
    }
  }
);
  extend(CompletionType.BASIC,TwigHelper.getVariableTypePattern(),new CompletionProvider<CompletionParameters>(){
    public void addCompletions(    @NotNull CompletionParameters parameters,    ProcessingContext context,    @NotNull CompletionResultSet resultSet){
      if (!Symfony2ProjectComponent.isEnabled(parameters.getPosition())) {
        return;
      }
      PsiElement psiElement=parameters.getOriginalPosition();
      if (psiElement == null) {
        return;
      }
      for (      Map.Entry<String,PsiVariable> entry : TwigTypeResolveUtil.collectScopeVariables(parameters.getOriginalPosition()).entrySet()) {
        resultSet.addElement(LookupElementBuilder.create(entry.getKey()).withTypeText(TwigTypeResolveUtil.getTypeDisplayName(psiElement.getProject(),entry.getValue().getTypes())).withIcon(PhpIcons.CLASS));
      }
    }
  }
);
  extend(CompletionType.BASIC,TwigHelper.getTransDefaultDomain(),new CompletionProvider<CompletionParameters>(){
    public void addCompletions(    @NotNull CompletionParameters parameters,    ProcessingContext context,    @NotNull CompletionResultSet resultSet){
      if (!Symfony2ProjectComponent.isEnabled(parameters.getPosition())) {
        return;
      }
      TranslationStringMap map=TranslationIndex.getInstance(parameters.getPosition().getProject()).getTranslationMap();
      for (      String domainKey : map.getDomainList()) {
        resultSet.addElement(new TranslatorLookupElement(domainKey,domainKey));
      }
    }
  }
);
  extend(CompletionType.BASIC,TwigHelper.getPrintBlockFunctionPattern("String_Node_Str"),new ControllerCompletionProvider());
  extend(CompletionType.BASIC,TwigHelper.getAutocompletableAssetPattern(),new AssetCompletionProvider().setAssetParser(new AssetDirectoryReader()));
  extend(CompletionType.BASIC,TwigHelper.getAutocompletableAssetTag("String_Node_Str"),new AssetCompletionProvider().setAssetParser(new AssetDirectoryReader().setFilterExtension(TwigHelper.CSS_FILES_EXTENSIONS).setIncludeBundleDir(true)));
  extend(CompletionType.BASIC,TwigHelper.getAutocompletableAssetTag("String_Node_Str"),new AssetCompletionProvider().setAssetParser(new AssetDirectoryReader().setFilterExtension(TwigHelper.JS_FILES_EXTENSIONS).setIncludeBundleDir(true)));
  extend(CompletionType.BASIC,TwigHelper.getAutocompletableRoutePattern(),new CompletionProvider<CompletionParameters>(){
    public void addCompletions(    @NotNull CompletionParameters parameters,    ProcessingContext context,    @NotNull CompletionResultSet resultSet){
      if (!Symfony2ProjectComponent.isEnabled(parameters.getPosition())) {
        return;
      }
      resultSet.addAllElements(RouteHelper.getRoutesLookupElements(parameters.getPosition().getProject()));
    }
  }
);
  extend(CompletionType.BASIC,TwigHelper.getPathAfterLeafPattern(),new PathParameterCompletionProvider());
  extend(CompletionType.BASIC,TwigHelper.getTypeCompletionPattern(),new TypeCompletionProvider());
  extend(CompletionType.BASIC,TwigHelper.getTwigTypeDocBlock(),new TwigDocBlockTypeClassCompletionProvider());
  extend(CompletionType.BASIC,TwigHelper.getTwigDocBlockMatchPattern(ControllerDocVariableCollector.DOC_PATTERN_COMPLETION),new ControllerCompletionProvider());
  extend(CompletionType.BASIC,TwigHelper.getFormThemeFileTag(),new FormThemeCompletionProvider());
  extend(CompletionType.BASIC,TwigHelper.getPrintBlockFunctionPattern("String_Node_Str"),new CompletionProvider<CompletionParameters>(){
    public void addCompletions(    @NotNull CompletionParameters parameters,    ProcessingContext context,    @NotNull CompletionResultSet resultSet){
      PsiElement position=parameters.getPosition();
      if (!Symfony2ProjectComponent.isEnabled(position)) {
        return;
      }
      PhpIndex instance=PhpIndex.getInstance(position.getProject());
      for (      String constant : instance.getAllConstantNames(PrefixMatcher.ALWAYS_TRUE)) {
        resultSet.addElement(LookupElementBuilder.create(constant).withIcon(PhpIcons.CONSTANT));
      }
      int foo=parameters.getOffset() - position.getTextRange().getStartOffset();
      String before=position.getText().substring(0,foo);
      String[] parts=before.split("String_Node_Str");
      if (parts.length >= 1) {
        PhpClass phpClass=PhpElementsUtil.getClassInterface(position.getProject(),parts[0]);
        if (phpClass != null && phpClass.getPresentableFQN() != null) {
          for (          Field field : phpClass.getFields()) {
            if (field.isConstant()) {
              resultSet.addElement(LookupElementBuilder.create(phpClass.getPresentableFQN() + "String_Node_Str" + field.getName()).withIcon(PhpIcons.CONSTANT));
            }
          }
        }
      }
    }
  }
);
}

Fixed version (ground truth):
public TwigTemplateCompletionContributor(){
  extend(CompletionType.BASIC,TwigHelper.getTemplateFileReferenceTagPattern(),new TemplateCompletionProvider());
  extend(CompletionType.BASIC,TwigHelper.getPrintBlockFunctionPattern("String_Node_Str","String_Node_Str"),new TemplateCompletionProvider());
  extend(CompletionType.BASIC,TwigHelper.getTranslationPattern("String_Node_Str","String_Node_Str"),new CompletionProvider<CompletionParameters>(){
    public void addCompletions(    @NotNull CompletionParameters parameters,    ProcessingContext context,    @NotNull CompletionResultSet resultSet){
      if (!Symfony2ProjectComponent.isEnabled(parameters.getPosition())) {
        return;
      }
      TranslationStringMap map=TranslationIndex.getInstance(parameters.getPosition().getProject()).getTranslationMap();
      if (map == null) {
        return;
      }
      PsiElement psiElement=parameters.getPosition();
      String domainName=TwigUtil.getPsiElementTranslationDomain(psiElement);
      resultSet.addAllElements(TranslationUtil.getTranslationLookupElementsOnDomain(psiElement.getProject(),domainName));
    }
  }
);
  extend(CompletionType.BASIC,TwigHelper.getTransDomainPattern(),new CompletionProvider<CompletionParameters>(){
    public void addCompletions(    @NotNull CompletionParameters parameters,    ProcessingContext context,    @NotNull CompletionResultSet resultSet){
      if (!Symfony2ProjectComponent.isEnabled(parameters.getPosition())) {
        return;
      }
      if (PsiElementUtils.getPrevSiblingOfType(parameters.getPosition(),PlatformPatterns.psiElement(TwigTokenTypes.IDENTIFIER).withText(PlatformPatterns.string().oneOf("String_Node_Str","String_Node_Str"))) == null) {
        return;
      }
      resultSet.addAllElements(TranslationUtil.getTranslationDomainLookupElements(parameters.getPosition().getProject()));
    }
  }
);
  extend(CompletionType.BASIC,TwigHelper.getBlockTagPattern(),new BlockCompletionProvider());
  extend(CompletionType.BASIC,TwigHelper.getTemplateImportFileReferenceTagPattern(),new CompletionProvider<CompletionParameters>(){
    public void addCompletions(    @NotNull CompletionParameters parameters,    ProcessingContext context,    @NotNull CompletionResultSet resultSet){
      if (!Symfony2ProjectComponent.isEnabled(parameters.getPosition())) {
        return;
      }
      PsiElement psiElement=PsiElementUtils.getPrevSiblingOfType(parameters.getPosition(),getFromTemplateElement());
      if (psiElement == null) {
        return;
      }
      String templateName=psiElement.getText();
      Map<String,VirtualFile> twigFilesByName=TwigHelper.getTwigFilesByName(parameters.getPosition().getProject());
      if (!twigFilesByName.containsKey(templateName)) {
        return;
      }
      VirtualFile virtualFile=twigFilesByName.get(templateName);
      PsiFile psiFile=PsiManager.getInstance(psiElement.getProject()).findFile(virtualFile);
      if (psiFile != null) {
        for (        Map.Entry<String,String> entry : new TwigMarcoParser().getMacros(psiFile).entrySet()) {
          resultSet.addElement(LookupElementBuilder.create(entry.getKey()).withTypeText(entry.getValue(),true).withIcon(TwigIcons.TwigFileIcon));
        }
      }
    }
    private PsiElementPattern.Capture<PsiElement> getFromTemplateElement(){
      return PlatformPatterns.psiElement(TwigTokenTypes.STRING_TEXT).afterLeafSkipping(PlatformPatterns.or(PlatformPatterns.psiElement(PsiWhiteSpace.class),PlatformPatterns.psiElement(TwigTokenTypes.WHITE_SPACE),PlatformPatterns.psiElement(TwigTokenTypes.SINGLE_QUOTE),PlatformPatterns.psiElement(TwigTokenTypes.DOUBLE_QUOTE)),PlatformPatterns.psiElement(TwigTokenTypes.TAG_NAME).withText(PlatformPatterns.string().oneOf("String_Node_Str"))).withLanguage(TwigLanguage.INSTANCE);
    }
  }
);
  extend(CompletionType.SMART,PlatformPatterns.psiElement().withParent(PlatformPatterns.psiElement().withLanguage(TwigLanguage.INSTANCE)),new FilterCompletionProvider());
  extend(CompletionType.BASIC,PlatformPatterns.psiElement().withParent(PlatformPatterns.psiElement().withLanguage(TwigLanguage.INSTANCE)),new FilterCompletionProvider());
  extend(CompletionType.BASIC,TwigHelper.getCompletablePattern(),new CompletionProvider<CompletionParameters>(){
    public void addCompletions(    @NotNull CompletionParameters parameters,    ProcessingContext context,    @NotNull CompletionResultSet resultSet){
      if (!Symfony2ProjectComponent.isEnabled(parameters.getPosition())) {
        return;
      }
      PsiElement psiElement=parameters.getPosition().getOriginalElement();
      for (      Map.Entry<String,TwigExtension> entry : new TwigExtensionParser(parameters.getPosition().getProject()).getFunctions().entrySet()) {
        resultSet.addElement(new TwigExtensionLookupElement(psiElement.getProject(),entry.getKey(),entry.getValue()));
      }
      for (      TwigMacro twigMacro : TwigUtil.getImportedMacros(psiElement.getContainingFile())) {
        resultSet.addElement(LookupElementBuilder.create(twigMacro.getName()).withTypeText(twigMacro.getTemplate(),true).withIcon(TwigIcons.TwigFileIcon).withInsertHandler(FunctionInsertHandler.getInstance()));
      }
      for (      TwigMacro twigMacro : TwigUtil.getImportedMacrosNamespaces(psiElement.getContainingFile())) {
        resultSet.addElement(LookupElementBuilder.create(twigMacro.getName()).withTypeText(twigMacro.getTemplate(),true).withIcon(TwigIcons.TwigFileIcon).withInsertHandler(FunctionInsertHandler.getInstance()));
      }
      for (      TwigSet twigSet : TwigUtil.getSetDeclaration(psiElement.getContainingFile())) {
        resultSet.addElement(LookupElementBuilder.create(twigSet.getName()).withTypeText("String_Node_Str",true));
      }
      for (      Map.Entry<String,PsiVariable> entry : TwigTypeResolveUtil.collectScopeVariables(parameters.getOriginalPosition()).entrySet()) {
        resultSet.addElement(LookupElementBuilder.create(entry.getKey()).withTypeText(TwigTypeResolveUtil.getTypeDisplayName(psiElement.getProject(),entry.getValue().getTypes()),true).withIcon(PhpIcons.CLASS));
      }
      for (      Map.Entry<String,TwigGlobalVariable> entry : ServiceXmlParserFactory.getInstance(psiElement.getProject(),TwigGlobalsServiceParser.class).getTwigGlobals().entrySet()) {
        if (entry.getValue().getTwigGlobalEnum() == TwigGlobalEnum.TEXT) {
          resultSet.addElement(LookupElementBuilder.create(entry.getKey()).withTypeText(entry.getValue().getValue(),true).withIcon(PhpIcons.CONSTANT));
        }
      }
    }
  }
);
  extend(CompletionType.BASIC,TwigHelper.getVariableTypePattern(),new CompletionProvider<CompletionParameters>(){
    public void addCompletions(    @NotNull CompletionParameters parameters,    ProcessingContext context,    @NotNull CompletionResultSet resultSet){
      if (!Symfony2ProjectComponent.isEnabled(parameters.getPosition())) {
        return;
      }
      PsiElement psiElement=parameters.getOriginalPosition();
      if (psiElement == null) {
        return;
      }
      for (      Map.Entry<String,PsiVariable> entry : TwigTypeResolveUtil.collectScopeVariables(parameters.getOriginalPosition()).entrySet()) {
        resultSet.addElement(LookupElementBuilder.create(entry.getKey()).withTypeText(TwigTypeResolveUtil.getTypeDisplayName(psiElement.getProject(),entry.getValue().getTypes())).withIcon(PhpIcons.CLASS));
      }
    }
  }
);
  extend(CompletionType.BASIC,TwigHelper.getTransDefaultDomain(),new CompletionProvider<CompletionParameters>(){
    public void addCompletions(    @NotNull CompletionParameters parameters,    ProcessingContext context,    @NotNull CompletionResultSet resultSet){
      if (!Symfony2ProjectComponent.isEnabled(parameters.getPosition())) {
        return;
      }
      TranslationStringMap map=TranslationIndex.getInstance(parameters.getPosition().getProject()).getTranslationMap();
      for (      String domainKey : map.getDomainList()) {
        resultSet.addElement(new TranslatorLookupElement(domainKey,domainKey));
      }
    }
  }
);
  extend(CompletionType.BASIC,TwigHelper.getPrintBlockFunctionPattern("String_Node_Str"),new ControllerCompletionProvider());
  extend(CompletionType.BASIC,TwigHelper.getAutocompletableAssetPattern(),new AssetCompletionProvider().setAssetParser(new AssetDirectoryReader()));
  extend(CompletionType.BASIC,TwigHelper.getAutocompletableAssetTag("String_Node_Str"),new AssetCompletionProvider().setAssetParser(new AssetDirectoryReader().setFilterExtension(TwigHelper.CSS_FILES_EXTENSIONS).setIncludeBundleDir(true)));
  extend(CompletionType.BASIC,TwigHelper.getAutocompletableAssetTag("String_Node_Str"),new AssetCompletionProvider().setAssetParser(new AssetDirectoryReader().setFilterExtension(TwigHelper.JS_FILES_EXTENSIONS).setIncludeBundleDir(true)));
  extend(CompletionType.BASIC,TwigHelper.getAutocompletableRoutePattern(),new CompletionProvider<CompletionParameters>(){
    public void addCompletions(    @NotNull CompletionParameters parameters,    ProcessingContext context,    @NotNull CompletionResultSet resultSet){
      if (!Symfony2ProjectComponent.isEnabled(parameters.getPosition())) {
        return;
      }
      resultSet.addAllElements(RouteHelper.getRoutesLookupElements(parameters.getPosition().getProject()));
    }
  }
);
  extend(CompletionType.BASIC,TwigHelper.getPathAfterLeafPattern(),new PathParameterCompletionProvider());
  extend(CompletionType.BASIC,TwigHelper.getTypeCompletionPattern(),new TypeCompletionProvider());
  extend(CompletionType.BASIC,TwigHelper.getTwigTypeDocBlock(),new PhpClassCompletionProvider(true));
  extend(CompletionType.BASIC,TwigHelper.getTwigDocBlockMatchPattern(ControllerDocVariableCollector.DOC_PATTERN_COMPLETION),new ControllerCompletionProvider());
  extend(CompletionType.BASIC,TwigHelper.getFormThemeFileTag(),new FormThemeCompletionProvider());
  extend(CompletionType.BASIC,TwigHelper.getPrintBlockFunctionPattern("String_Node_Str"),new CompletionProvider<CompletionParameters>(){
    public void addCompletions(    @NotNull CompletionParameters parameters,    ProcessingContext context,    @NotNull CompletionResultSet resultSet){
      PsiElement position=parameters.getPosition();
      if (!Symfony2ProjectComponent.isEnabled(position)) {
        return;
      }
      PhpIndex instance=PhpIndex.getInstance(position.getProject());
      for (      String constant : instance.getAllConstantNames(PrefixMatcher.ALWAYS_TRUE)) {
        resultSet.addElement(LookupElementBuilder.create(constant).withIcon(PhpIcons.CONSTANT));
      }
      int foo=parameters.getOffset() - position.getTextRange().getStartOffset();
      String before=position.getText().substring(0,foo);
      String[] parts=before.split("String_Node_Str");
      if (parts.length >= 1) {
        PhpClass phpClass=PhpElementsUtil.getClassInterface(position.getProject(),parts[0]);
        if (phpClass != null && phpClass.getPresentableFQN() != null) {
          for (          Field field : phpClass.getFields()) {
            if (field.isConstant()) {
              resultSet.addElement(LookupElementBuilder.create(phpClass.getPresentableFQN() + "String_Node_Str" + field.getName()).withIcon(PhpIcons.CONSTANT));
            }
          }
        }
      }
    }
  }
);
}