content: package at.alirezamoh.whisperer_for_laravel.translation;
  
  import at.alirezamoh.whisperer_for_laravel.support.utils.PluginUtils;
  import at.alirezamoh.whisperer_for_laravel.support.utils.PsiElementUtils;
  import at.alirezamoh.whisperer_for_laravel.translation.util.TranslationUtil;
  import com.intellij.openapi.project.Project;
  import com.intellij.openapi.util.TextRange;
  import com.intellij.patterns.PlatformPatterns;
  import com.intellij.psi.*;
  import com.intellij.util.ProcessingContext;
  import com.jetbrains.php.lang.psi.elements.ParameterList;
  import com.jetbrains.php.lang.psi.elements.StringLiteralExpression;
  import org.jetbrains.annotations.NotNull;
  
  public class TranslationReferenceContributor extends PsiReferenceContributor {
      @Override
      public void registerReferenceProviders(@NotNull PsiReferenceRegistrar psiReferenceRegistrar) {
          psiReferenceRegistrar.registerReferenceProvider(
              PlatformPatterns.psiElement(StringLiteralExpression.class).withParent(ParameterList.class),
              new PsiReferenceProvider() {
                  @Override
                  public PsiReference @NotNull [] getReferencesByElement(@NotNull PsiElement psiElement, @NotNull ProcessingContext processingContext) {
                      Project project = psiElement.getProject();
  
                      if (PluginUtils.shouldNotCompleteOrNavigate(project)) {
                          return PsiReference.EMPTY_ARRAY;
                      }
  
                      if (!(psiElement instanceof StringLiteralExpression stringLiteralExpression)) {
                          return PsiReference.EMPTY_ARRAY;
                      }
  
                      if(TranslationUtil.isInsideCorrectMethod(psiElement, project)) {
                          return new PsiReference[]{
                              new TranslationReference(
                                  stringLiteralExpression,
                                  new TextRange(
                                      PsiElementUtils.getStartOffset(stringLiteralExpression),
                                      PsiElementUtils.getEndOffset(stringLiteralExpression)
                                  )
                              )
                          };
                      }
                      return PsiReference.EMPTY_ARRAY;
                  }
              }
          );
      }
  }
  