@Nullable
 public static DuplicatesProfile findDuplicatesProfile(FileType fileType) {
   if (!(fileType instanceof LanguageFileType)) return null;
   Language language = ((LanguageFileType) fileType).getLanguage();
   DuplicatesProfile profile = DuplicatesProfile.findProfileForLanguage(language);
   return profile != null
           && (ourEnabledOldProfiles && profile.supportDuplicatesIndex()
               || profile instanceof LightDuplicateProfile)
       ? profile
       : null;
 }
        @Override
        @NotNull
        public Map<Integer, TIntArrayList> map(@NotNull final FileContent inputData) {
          FileType type = inputData.getFileType();

          DuplicatesProfile profile = findDuplicatesProfile(type);
          if (profile == null || !profile.acceptsContentForIndexing(inputData))
            return Collections.emptyMap();

          try {
            FileContentImpl fileContent = (FileContentImpl) inputData;

            if (profile instanceof LightDuplicateProfile && ourEnabledLightProfiles) {
              final THashMap<Integer, TIntArrayList> result = new THashMap<>();
              LighterAST ast = fileContent.getLighterASTForPsiDependentIndex();

              ((LightDuplicateProfile) profile)
                  .process(
                      ast,
                      new LightDuplicateProfile.Callback() {
                        @Override
                        public void process(
                            int hash,
                            int hash2,
                            @NotNull LighterAST ast,
                            @NotNull LighterASTNode... nodes) {
                          TIntArrayList list = result.get(hash);
                          if (list == null) {
                            result.put(hash, list = new TIntArrayList(2));
                          }
                          list.add(nodes[0].getStartOffset());
                          list.add(hash2);
                        }
                      });
              return result;
            }
            MyFragmentsCollector collector =
                new MyFragmentsCollector(profile, ((LanguageFileType) type).getLanguage());
            DuplocateVisitor visitor = profile.createVisitor(collector, true);

            visitor.visitNode(fileContent.getPsiFileForPsiDependentIndex());

            return collector.getMap();
          } catch (StackOverflowError ae) {
            return Collections.emptyMap(); // todo Maksim
          }
        }
 static boolean isIndexedFragment(
     @Nullable PsiFragment frag,
     int cost,
     DuplicatesProfile profile,
     DuplocatorState duplocatorState) {
   if (frag == null) return false;
   return profile.shouldPutInIndex(frag, cost, duplocatorState);
 }
 public MyFragmentsCollector(DuplicatesProfile profile, Language language) {
   myProfile = profile;
   myDuplocatorState = profile.getDuplocatorState(language);
 }