code: public static URL getSourceUrl(SourceUnit source) {
          URL url = null;
          final String filename = source.getName();
          if(filename==null) {
              return null;
          }
  
          Resource resource = new FileSystemResource(filename);
          if (resource.exists()) {
              try {
                  url = resource.getURL();
              } catch (IOException e) {
                  // ignore
              }
          }
          return url;
      }
docs: Find URL of SourceUnit
  
  source.getSource().getURI() fails in Groovy-Eclipse compiler
  
  @param source
  @return URL of SourceUnit