private static String findAliasedName(Map<GroovyFile, String> map, GroovyFile containingFile, PsiElement elementToResolve) {
    final String s = map.get(containingFile);
    if (s != null) return s;

    final PsiManager manager = elementToResolve.getManager();
    final ResolverProcessor processor = getProcessor(elementToResolve, containingFile);
    final GroovyFileImports fileImports = containingFile.getImports();
    for (GroovyNamedImport anImport : fileImports.getAllNamedImports()) {
      if (!anImport.isAliased()) continue;
      anImport.processDeclarations(processor, ResolveState.initial(), containingFile, containingFile);
      final GroovyResolveResult[] results = processor.getCandidates();
      for (GroovyResolveResult result : results) {
        if (manager.areElementsEquivalent(elementToResolve, result.getElement())) {
          final String importedName = anImport.getName();
          map.put(containingFile, importedName);
          return importedName;
        }
      }
    }
    map.put(containingFile, EMPTY_ALIAS);
    return EMPTY_ALIAS;
  }
private static String findAliasedName(Map<GroovyFile, String> map, GroovyFile containingFile, PsiElement elementToResolve)