Quellcodebibliothek Statistik Leitseite products/Sources/formale Sprachen/JAVA/Netbeans/ide/editor.autosave/   (Apache JAVA IDE Version 28©)  Datei vom 3.10.2025 mit Größe 1 kB image not shown  

Quellcode-Bibliothek resourceUriPlugin.js   Sprache: JAVA

 
/* This Source Code Form is subject to the terms of the Mozilla Public
 * License, v. 2.0. If a copy of the MPL was not distributed with this file,
 * You can obtain one at http://mozilla.org/MPL/2.0/. */


// This plugin supports finding files with particular resource:// URIs
// and translating the uri into a relative filesytem path where the file may be
// found when running within the Karma / Mocha test framework.

/* eslint-env node */
const path = require("path");

module.exports = {
  ResourceUriPlugin: class ResourceUriPlugin {
    /**
     * @typedef {RegEx} ResourceReplacement0
     *   A regular expression matching a resource:// URI substring to be
     *   replaced.
     * @typedef {string} ResourceReplacement1
     *   A string to replace the matched substring with.
     * @typedef {[ResourceReplacement0, ResourceReplacement1]} ResourceReplacement
     */


    /**
     * Maps regular expressions representing resource URIs to strings that
     * should replace matches for those regular expressions.
     *
     * @type {ResourceReplacement[]}
     */

    #resourcePathRegExes;

    /**
     * @param {object} options
     *  Object passed during the instantiation of ResourceUriPlugin
     * @param {ResourceReplacement[]} options.resourcePathRegExes
     *   An array of regex/string tuples to perform replacements on for
     *   imports involving resource:// URIs.
     */

    constructor({ resourcePathRegExes }) {
      this.#resourcePathRegExes = resourcePathRegExes;
    }

    apply(compiler) {
      compiler.hooks.compilation.tap(
        "ResourceUriPlugin",
        (compilation, { normalModuleFactory }) => {
          normalModuleFactory.hooks.resolveForScheme
            .for("resource")
            .tap("ResourceUriPlugin", resourceData => {
              const url = new URL(resourceData.resource);

              for (let [regex, replacement] of this.#resourcePathRegExes) {
                if (!url.href.match(regex)) {
                  continue;
                }
                // path.join() is necessary to normalize the path on Windows.
                // Without it, the path may contain backslashes, resulting in
                // different build output on Windows than on Unix systems.
                const pathname = path.join(
                  url.href.replace(regex, replacement)
                );
                resourceData.path = pathname;
                resourceData.query = url.search;
                resourceData.fragment = url.hash;
                resourceData.resource = pathname + url.search + url.hash;
                return true;
              }

              return true;
            });
        }
      );
    }
  },
};

Messung V0.5
C=97 H=99 G=97

¤ Die Informationen auf dieser Webseite wurden nach bestem Wissen sorgfältig zusammengestellt. Es wird jedoch weder Vollständigkeit, noch Richtigkeit, noch Qualität der bereit gestellten Informationen zugesichert.0.8Bemerkung:  (vorverarbeitet)  ¤

*Bot Zugriff






Wurzel

Suchen

Beweissystem der NASA

Beweissystem Isabelle

NIST Cobol Testsuite

Cephes Mathematical Library

Wiener Entwicklungsmethode

Haftungshinweis

Die Informationen auf dieser Webseite wurden nach bestem Wissen sorgfältig zusammengestellt. Es wird jedoch weder Vollständigkeit, noch Richtigkeit, noch Qualität der bereit gestellten Informationen zugesichert.

Bemerkung:

Die farbliche Syntaxdarstellung und die Messung sind noch experimentell.