Java 类org.mozilla.javascript.commonjs.module.ModuleScope 实例源码

项目:code404    文件:Main.java   
static Scriptable getScope(String path) {
    if (useRequire) {
        // If CommonJS modules are enabled use a module scope that resolves
        // relative ids relative to the current URL, file or working directory.
        URI uri;
        if (path == null) {
            // use current directory for shell and -e switch
            uri = new File(System.getProperty("user.dir")).toURI();
        } else {
            // find out whether this is a file path or a URL
            if (SourceReader.toUrl(path) != null) {
                try {
                    uri = new URI(path);
                } catch (URISyntaxException x) {
                    // fall back to file uri
                    uri = new File(path).toURI();
                }
            } else {
                uri = new File(path).toURI();
            }
        }
        return new ModuleScope(global, uri, null);
    } else {
        return global;
    }
}
项目:S3F    文件:Main.java   
static Scriptable getScope(String path) {
    if (useRequire) {
        // If CommonJS modules are enabled use a module scope that resolves
        // relative ids relative to the current URL, file or working directory.
        URI uri;
        if (path == null) {
            // use current directory for shell and -e switch
            uri = new File(System.getProperty("user.dir")).toURI();
        } else {
            // find out whether this is a file path or a URL
            if (SourceReader.toUrl(path) != null) {
                try {
                    uri = new URI(path);
                } catch (URISyntaxException x) {
                    // fall back to file uri
                    uri = new File(path).toURI();
                }
            } else {
                uri = new File(path).toURI();
            }
        }
        return new ModuleScope(global, uri, null);
    } else {
        return global;
    }
}
项目:rhino-jscover    文件:Main.java   
static Scriptable getScope(String path) {
    if (useRequire) {
        // If CommonJS modules are enabled use a module scope that resolves
        // relative ids relative to the current URL, file or working directory.
        URI uri;
        if (path == null) {
            // use current directory for shell and -e switch
            uri = new File(System.getProperty("user.dir")).toURI();
        } else {
            // find out whether this is a file path or a URL
            if (SourceReader.toUrl(path) != null) {
                try {
                    uri = new URI(path);
                } catch (URISyntaxException x) {
                    // fall back to file uri
                    uri = new File(path).toURI();
                }
            } else {
                uri = new File(path).toURI();
            }
        }
        return new ModuleScope(global, uri, null);
    } else {
        return global;
    }
}
项目:astor    文件:Main.java   
static Scriptable getScope(String path) {
    if (useRequire) {
        // If CommonJS modules are enabled use a module scope that resolves
        // relative ids relative to the current URL, file or working directory.
        URI uri;
        if (path == null) {
            // use current directory for shell and -e switch
            uri = new File(System.getProperty("user.dir")).toURI();
        } else {
            // find out whether this is a file path or a URL
            if (SourceReader.toUrl(path) != null) {
                try {
                    uri = new URI(path);
                } catch (URISyntaxException x) {
                    // fall back to file uri
                    uri = new File(path).toURI();
                }
            } else {
                uri = new File(path).toURI();
            }
        }
        return new ModuleScope(global, uri, null);
    } else {
        return global;
    }
}
项目:Rhino-Prov-Mod    文件:Main.java   
static Scriptable getScope(String path) {
    if (useRequire) {
        // If CommonJS modules are enabled use a module scope that resolves
        // relative ids relative to the current URL, file or working directory.
        URI uri;
        if (path == null) {
            // use current directory for shell and -e switch
            uri = new File(System.getProperty("user.dir")).toURI();
        } else {
            // find out whether this is a file path or a URL
            if (SourceReader.toUrl(path) != null) {
                try {
                    uri = new URI(path);
                } catch (URISyntaxException x) {
                    // fall back to file uri
                    uri = new File(path).toURI();
                }
            } else {
                uri = new File(path).toURI();
            }
        }
        return new ModuleScope(global, uri, null);
    } else {
        return global;
    }
}
项目:closure-compiler-old    文件:Main.java   
static Scriptable getScope(String path) {
    if (useRequire) {
        // If CommonJS modules are enabled use a module scope that resolves
        // relative ids relative to the current URL, file or working directory.
        URI uri;
        if (path == null) {
            // use current directory for shell and -e switch
            uri = new File(System.getProperty("user.dir")).toURI();
        } else {
            // find out whether this is a file path or a URL
            if (SourceReader.toUrl(path) != null) {
                try {
                    uri = new URI(path);
                } catch (URISyntaxException x) {
                    // fall back to file uri
                    uri = new File(path).toURI();
                }
            } else {
                uri = new File(path).toURI();
            }
        }
        return new ModuleScope(global, uri, null);
    } else {
        return global;
    }
}
项目:closure-compiler-copy    文件:Main.java   
static Scriptable getScope(String path) {
    if (useRequire) {
        // If CommonJS modules are enabled use a module scope that resolves
        // relative ids relative to the current URL, file or working directory.
        URI uri;
        if (path == null) {
            // use current directory for shell and -e switch
            uri = new File(System.getProperty("user.dir")).toURI();
        } else {
            // find out whether this is a file path or a URL
            if (SourceReader.toUrl(path) != null) {
                try {
                    uri = new URI(path);
                } catch (URISyntaxException x) {
                    // fall back to file uri
                    uri = new File(path).toURI();
                }
            } else {
                uri = new File(path).toURI();
            }
        }
        return new ModuleScope(global, uri, null);
    } else {
        return global;
    }
}