public void registerReferenceProviders()

in src/main/java/lt/martynassateika/idea/codeigniter/language/LanguageReferenceContributor.java [47:79]


  public void registerReferenceProviders(@NotNull PsiReferenceRegistrar psiReferenceRegistrar) {
    psiReferenceRegistrar.registerReferenceProvider(PlatformPatterns.psiElement(),
        new PsiReferenceProvider() {
          @NotNull
          @Override
          public PsiReference[] getReferencesByElement(@NotNull PsiElement psiElement,
              @NotNull ProcessingContext processingContext) {
            Project project = psiElement.getProject();
            if (CodeIgniterProjectSettings.getInstance(project).isEnabled()) {
              if (psiElement instanceof StringLiteralExpression) {
                StringLiteralExpression stringLiteralExpression = (StringLiteralExpression) psiElement;
                if (CiLanguageUtil.isLanguageLineKeyElement(stringLiteralExpression)) {
                  List<AssignmentExpression> translations = CiLanguageUtil.findTranslationsFor(
                      project,
                      stringLiteralExpression
                  );
                  List<PsiReference> references = new ArrayList<>(translations.size());
                  for (AssignmentExpression translation : translations) {
                    ArrayAccessExpression arrayAccessExpression = (ArrayAccessExpression) translation
                        .getVariable();
                    if (arrayAccessExpression != null) {
                      ArrayIndex index = arrayAccessExpression.getIndex();
                      references.add(new MyPsiReference(index, stringLiteralExpression));
                    }
                  }
                  return references.toArray(PsiReference.EMPTY_ARRAY);
                }
              }
            }
            return PsiReference.EMPTY_ARRAY;
          }
        });
  }