private void findRefs(
        final IErlModule theModule, final ITextSelection aSelection, final boolean hasChanged) {
      final IBackend ideBackend = BackendCore.getBackendManager().getIdeBackend();
      fRefs = null;

      if (fCanceled) {
        return;
      }
      try {
        final int offset = aSelection.getOffset();
        final OpenResult res =
            ErlideOpen.open(
                ideBackend.getRpcSite(),
                theModule,
                offset,
                ModelUtils.getImportsAsList(theModule),
                "",
                ErlModelManager.getErlangModel().getPathVars());
        final ErlangSearchPattern pattern =
            SearchUtil.getSearchPatternFromOpenResultAndLimitTo(
                theModule, offset, res, LimitTo.ALL_OCCURRENCES, false);
        if (fCanceled) {
          return;
        }
        if (pattern != null) {
          final ErlSearchScope scope = new ErlSearchScope();
          scope.addModule(theModule);
          final List<ModuleLineFunctionArityRef> findRefs = Lists.newArrayList();
          // TODO: run in background? for large files, this can take
          // seconds
          final OtpErlangObject refs =
              ErlideSearchServer.findRefs(
                  ideBackend.getRpcSite(), pattern, scope, erlangEditor.getStateDir(), true);
          if (refs != null) {
            SearchUtil.addSearchResult(findRefs, refs);
            fRefs = erlangEditor.markOccurencesHandler.getErlangRefs(theModule, findRefs);
          }
        }
      } catch (final RpcTimeoutException e) {
        if (!ideBackend.isStopped()) {
          ErlLogger.warn(e);
        }
      } catch (final RpcException e) {
        ErlLogger.debug(e);
      } catch (final ErlModelException e) {
        ErlLogger.debug(e);
      } catch (final OtpErlangRangeException e) {
        ErlLogger.debug(e);
      }
      if (fRefs == null) {
        if (!erlangEditor.markOccurencesHandler.fStickyOccurrenceAnnotations) {
          erlangEditor.markOccurencesHandler.removeOccurrenceAnnotations();
        } else if (hasChanged) {
          erlangEditor.markOccurencesHandler.removeOccurrenceAnnotations();
        }
      }
    }
 List<MarkOccurencesHandler.ErlangRef> getErlangRefs(
     final IErlModule module, final List<ModuleLineFunctionArityRef> findRefs) {
   final List<MarkOccurencesHandler.ErlangRef> result =
       new ArrayList<MarkOccurencesHandler.ErlangRef>(findRefs.size());
   for (final ModuleLineFunctionArityRef ref : findRefs) {
     result.add(
         new MarkOccurencesHandler.ErlangRef(
             SearchUtil.createSearchElement(ref, module),
             ref.getOffset(),
             ref.getLength(),
             ref.isDef()));
   }
   return result;
 }