For a given //# sourceMappingUrl, this locates the appropriate sourcemap on disk. This is use
for sourcemap merging (--apply_input_source_maps) and for error resolution.
767150
static SourceFile extractSourceMap(
      SourceFile jsFile, String sourceMapURL, boolean parseInlineSourceMaps) {
    // Javascript version of the compiler can only deal with inline sources.
    if (sourceMapURL.startsWith(BASE64_URL_PREFIX)) {
      byte[] data =
          BaseEncoding.base64().decode(sourceMapURL.substring(BASE64_URL_PREFIX.length()));
      String source = new String(data, StandardCharsets.UTF_8);
      return SourceFile.fromCode(jsFile.getName() + ".inline.map", source);
    }
    return null;
  }
60541
function resolveFileToURL(output, filePath) {
    // Convert /test.png -> test.png
    filePath = LocationUtils.toAbsolute(filePath, '', '');

    var page = output.getPage(filePath);

    // if file is a page, return correct .html url
    if (page) {
        filePath = fileToURL(output, filePath);
    }

    return LocationUtils.normalize(filePath);
}
6710
public URL getResourceURL(String filepath, URL urlCodeBase, String version, ClassLoader classLoader) throws RuntimeException
    {
        if (filepath == null)
            return null;
        if (File.separatorChar != '/')
            filepath = filepath.replace(File.separatorChar, '/'); // Just in case I get a window's path

        boolean isResource = true;
        if (urlCodeBase != null)
        	if ("file".equalsIgnoreCase(urlCodeBase.getProtocol()))
        		isResource = false;
        URL url = null;
        try {
        	if (isResource)
        		if (classLoader != null)
        		{
        			url = classLoader.getResource(filepath);
        			if (url == null)
        			    if (filepath.startsWith("/"))
        			        url = classLoader.getResource(filepath.substring(1));    // Classpaths shouldn't start with root
        		}
        } catch (Exception e) {
            // Keep trying
        }

        if (url == null)
        {
        	if (isResource)
        		if (this.getClassFinder(null) != null)
        			url = this.getClassFinder(null).findResourceURL(filepath, version);	// Try to find this class in the obr repos
        }

        if (url == null)
        {
            try
            {
                if (urlCodeBase != null)
                    url = new URL(urlCodeBase, filepath);
            } catch(MalformedURLException ex) {
                // Keep trying
            } catch (Exception e) {
                // Keep trying
            }
        }
        return url;
    }
829011
public URL findResourceURL(String resourcePath, String versionRange)
    {
        //if (ClassServiceBootstrap.repositoryAdmin == null)
        //    return null;

        URL url = this.getResourceFromBundle(null, resourcePath, versionRange);

        if (url == null) {
            Object resource = this.deployThisResource(ClassFinderActivator.getPackageName(resourcePath, true), versionRange, false);
            if (resource != null)
            	url = this.getResourceFromBundle(resource, resourcePath, versionRange);
        }

        return url;
    }
1344901
def link(source_path):
    """"""
    if not os.path.isfile(source_path):
        raise SourceNotFound(source_path)
    with open(source_path, 'r') as f:
        content = f.read()
    block_map = BlockMap()  # The map will be populated with the following function call.
    all_block = convert_lines_to_block(
            content.splitlines(), block_map, LinkStack(source_path), source_path)
    return all_block, block_map.get_variables()
508518
function findImportedPath(url, prev, includedFilesMap, includedPaths) {
  let candidateFromPaths;

  if(prev !== 'stdin') {
    const prevPath = path.posix.dirname(prev);
    candidateFromPaths = [prevPath, ...includedPaths];
  } else {
    candidateFromPaths = [...includedPaths];
  }

  for(let i = 0; i < candidateFromPaths.length; i++) {
    let candidatePath;
    let candidateFromPath = normalizePath(makeAbsolute(candidateFromPaths[i]));
    if (path.isAbsolute(url)) {
      candidatePath = normalizePath(url);
    } else {
      // Get normalize absolute candidate from path
      candidatePath = path.posix.join(candidateFromPath, url);
    }

    if(includedFilesMap[candidatePath]) {
      return candidatePath;
    } else {
      let urlBasename = path.posix.basename(url);
      let indexOfBasename = url.lastIndexOf(urlBasename);
      let partialUrl = `${url.substring(0, indexOfBasename)}_${urlBasename}`;

      if (path.isAbsolute(partialUrl)) {
        candidatePath = normalizePath(partialUrl);
      } else {
        candidatePath = path.posix.join(candidateFromPath, partialUrl);
      }

      if(includedFilesMap[candidatePath]) {
        return candidatePath;
      }
    }
  }

  return null;
}
1162701
public static URL findResourceBase(String baseResource, ClassLoader loader)
   {
      URL url = loader.getResource(baseResource);
      return findResourceBase(url, baseResource);
   }
641495
public static void findSourceFiles(List<SourceLocation> sourceLocations,
                                       Set<String> sourceTypes,
                                       Map<String,Source> foundFiles,
                                       Map<String, Module> foundModules,
                                       Module currentModule,
                                       boolean permitSourcesInDefaultPackage,
                                       boolean inLinksrc)
                                               throws IOException {

        for (SourceLocation source : sourceLocations) {
            source.findSourceFiles(sourceTypes,
                                   foundFiles,
                                   foundModules,
                                   currentModule,
                                   permitSourcesInDefaultPackage,
                                   inLinksrc);
        }
    }
737781
public static String locate(String className, ClassLoader classLoader) {
        String resource = new String(className);

        // format the file name into a valid resource name
        if (!resource.startsWith("/")) {
            resource = "/" + resource;
        }
        resource = resource.replace('.', '/');
        resource = resource + ".class";

        // attempt to locate the file using the class loader
        URL classUrl = classLoader.getResource(resource);
        if (classUrl == null && classLoader == ClasspathUtil.class.getClassLoader()) {
            // Apparently clazz.getResource() works sometimes when clazz.getClassLoader().getResource() does not.
            // TODO: why?
            classUrl = ClasspathUtil.class.getResource(resource);
        }

        if (classUrl == null) {
            return "\nClass not found: [" + className + "]";
        }
        else {
            return classUrl.getFile();
        }
    }
802856
function mapSources (sourceMap, mapCallback) {
  let chain = Promise.resolve()
  function pushChain (path, index, arr) {
    chain = chain
      .then(() => mapCallback(path))
      .then(replacement => {
        arr[index] = replacement || path
      })
  }
  if (sourceMap.sources) {
    sourceMap.sources.forEach(pushChain)
  }
  if (sourceMap.sections) {
    sourceMap.sections.forEach(section => {
      if (section.map && section.map.sources) {
        section.map.sources.forEach(pushChain)
      }
    })
  }
  return chain.then(() => sourceMap)
}
173911
def _context_source_file_url(path_or_url):
    
    if path_or_url.startswith('http'):
        # Remote CSV. Just return the URL
        return path_or_url

    if path_or_url.startswith('/'):
        # Absolute path
        return "file://" + path_or_url

    return "file://" + os.path.join(os.path.realpath(os.getcwd()), path_or_url)
844556
@SuppressWarnings("PMD.PreserveStackTrace")
    private Map<String, String> findParameters(URI location) throws MalformedURLException {
        final Map<String, String> params;
        try {
            params = URISupport.parseParameters(location);
        } catch (final URISyntaxException e) {
            throw new MalformedURLException(e.getMessage());
        }
        return params;
    }
1258460
public static void updateFileFromUrl(final String sourceUrl, final String destinationFilePath) throws
        UpdateException {
        updateFileFromUrl(sourceUrl, destinationFilePath, null, null);
    }
389306
function findByHash(config, hash) {
  const re = new RegExp(injectHashIntoPath(config.sourceMapPath, hash));

  return glob
    .sync('./**')
    .filter(file => re.test(file))
    .map(sourceMapPath => {
      // strip relative path characters
      const sourceMapPathMatch = sourceMapPath.match(re);

      if (sourceMapPathMatch) {
        const minifiedUrl = sourceMapPathMatch[0].replace(
          re,
          injectHashIntoPath(config.minifiedUrl, hash),
        );

        return {
          sourceMapPath,
          minifiedUrl,
        };
      }
    })
    .filter(Boolean);
}
1241896
function getSourceMapForUrl(url, onFailure, onSuccess) {
  if (!url) {
    onFailure('must provide a URL');
    return;
  }

  if (url === 'assets://default_bundle') {
    onFailure('Don\'t know how to symbolicate in-app bundle, please load from server');
    return;
  }

  const parsedUrl = urlLib.parse(url);
  const mapPath = parsedUrl.pathname.replace(/\.bundle$/, '.map');
  const options = {
    host: 'localhost',
    port: parsedUrl.port,
    path: mapPath + parsedUrl.search + '&babelSourcemap=true',
  };

  http.get(options, (res) => {
    res.setEncoding('utf8');
    let sawEnd = false;
    let resBody = '';
    res.on('data', (chunk) => {
      resBody += chunk;
    }).on('end', () => {
      sawEnd = true;
      onSuccess(new SourceMapConsumer(resBody));
    }).on('close', (err) => {
      if (!sawEnd) {
        onFailure('Connection terminated prematurely because of: '
                      + err.code + ' for url: ' + url);
      }
    });
  }).on('error', (err) => {
    onFailure('Could not get response from: ' + url + ', error: ' + err.message);
  });
}
1154629
public TranspileResult embedSourcemapUrl(String url) {
    // If there's no sourcemap, don't reference it.
    if (sourceMap.isEmpty()) {
      return this;
    }
    String embedded = transpiled + "\n//# sourceMappingURL=" + url + "\n";
    return new TranspileResult(path, original, embedded, sourceMap);
  }
894171
function sourcePath(path_request) {
    if (path_request.path) {
      path_request = path_request.path;
    }

    path_request = clean_path(path_request);
    var tmp = path_request.split('/');

    if (_.get(project, 'site.languages.' + tmp[0])) {
      tmp.shift();
    }

    return tmp.join('/');
  }