****************************************
执行文件
****************************************
170205
function executeFile(src, { context, babelOptions } = {}) {
    let filename = resolvePath(context)(src);

    // 不存在文件
    if (!filename) {
        throw new Error(`Error: ENOENT: no such file, open '${src}'`);
    }

    // 解析【json】
    if (filename.endsWith('.json')) {
        return require(filename);
    }

    // 解析对象
    return execute(
        fs.readFileSync(filename, 'utf-8'), { filename, babelOptions }
    );
}
210673
public static void writeTo(Object object, String path) throws IOException, NoSuchMethodException,
            IllegalAccessException, InvocationTargetException {
        OutputStream os = new FileOutputStream(path);
        ReflectUtils.invokeMethod(object, "write", new Class<?>[]{OutputStream.class}, new Object[]{os});
        os.close();
        logger.info("文件已输出：" + path);
    }
1173354
async function copy(src, dist) {
    let stats = await stat(src),
        files;

    // 处理文件
    if (!stats.isDirectory()) {
        return await copyFile(src, dist);
    }

    // 生成目标路径
    if (!await stat(dist)) {
        await local.mkdir(dist);
    }

    // 读取文件夹
    files = await local.readdir(src);

    // 处理文件
    await Promise.all(files.map(file => (
        file === 'node_modules' ? Promise.resolve() : copy(path.resolve(src, file), path.resolve(dist, file))
    )));
}
156356
function walker (patterns, options = {}) {
  debug(`input glob patterns: ${patterns}`)
  debug('input options: %o', options)

  const fileTree = getFileTree()
  const noIgnore = typeof options.noIgnore === 'boolean'
    ? options.noIgnore
    : false // 默认不禁用 ignore 规则

  if (!patterns || (Array.isArray(patterns) && !patterns.length)) {
    return Promise.resolve(fileTree)
  }

  return co(function * () {
    const isGit = yield isGitHooks()

    debug(`run in git hooks: ${isGit}`)

    /**
     * 根据运行环境执行不同的文件遍历策略
     */
    let fileList
    let ignorePatterns = []

    if (!noIgnore) {
      debug('ignore rules: %j', defaultIgnore)
      ignorePatterns = defaultIgnore
    }

    if (isGit) {
      fileList = yield stage(patterns, ignorePatterns)
    } else {
      fileList = yield local(patterns, ignorePatterns)
    }

    // 转为绝对路径
    const baseDir = getBaseDir()
    fileList = fileList.map(p => {
      return path.join(baseDir, p)
    })

    fillFileTree(fileTree, fileList)

    debug('fileList: %o', fileList)
    debug('fileTree: %o', fileTree)

    return fileTree
  })
}
153232
function appendReporter (file, errors, buf) {
	buf = buf || file.contents;

	// 在buffer中的代码中注入报错语句
	let contentReporter;

	if (file.postcss || file.csslint) {
		contentReporter = cssBrowserReporter(errors);
	} else if (file.jshint || file.eslint || file.jscs) {
		contentReporter = `\n;\n(${jsBrowserReporter})(${JSON.stringify(errors, circular())});`;
	}

	if (contentReporter) {
		return Buffer.concat([buf, Buffer.from(contentReporter)]);
	} else {
		return buf;
	}
}
354689
async function transform(src, dist) {
    if (!src.endsWith('node_modules')) {
        let stats = await fs.stat(src);

        // 查看状态
        if (stats) {

            // 处理目录
            if (stats.isDirectory()) {

                // 判断是否指定目录`
                if (!dist) {
                    return stdout.error('Error: The output dir is must!');
                }

                // 获取目标文件夹信息
                stats = await fs.stat(dist);

                // 不存在文件
                if (stats) {
                    if (!stats.isDirectory()) {
                        return stdout.error('Error: The output dir is not a Directory!');
                    }
                } else {
                    await fs.mkdir(dist);
                }

                // 处理子文件
                return await Promise.all((await fs.readdir(src)).map(
                    name => transform(path.resolve(src, name), path.resolve(dist, name))
                ));
            }

            // 生成目录文件
            if (!dist) {
                dist = src.replace(/\.?(\w+)$/, '.min.$1');
            }

            // 打印信息
            stdout.info(`copy: ${relative(src)} --> ${relative(dist)}`);

            // 转码文件
            if (src.endsWith('.js')) {
                let code = await fs.readFile(src, 'utf-8');

                // 判断是否需要转码
                if (code.indexOf('\nimport ') !== -1 || code.indexOf('\nexport ') !== -1) {
                    code = transformCode(code).code;
                }

                // 写入文件
                return await fs.writeFile(dist, code);
            }

            // 拷贝文件
            await fs.copyFile(src, dist);
        }
    }
}
80313
async function some(...args) {
    for (let argv of args) {
        let stats = await stat(argv);

        // 存在路径
        if (stats) {
            return { file: argv, fullpath: path.cwd(argv), stats };
        }
    }
}
648153
private void scanFile(File file, String rootDir) {
		if (file.isFile()) {
			final String fileName = file.getAbsolutePath();
			if (fileName.endsWith(FileUtil.CLASS_EXT)) {
				final String className = fileName//
						// 8为classes长度，fileName.length() - 6为".class"的长度
						.substring(rootDir.length(), fileName.length() - 6)//
						.replace(File.separatorChar, CharUtil.DOT);//
				//加入满足条件的类
				addIfAccept(className);
			} else if (fileName.endsWith(FileUtil.JAR_FILE_EXT)) {
				try {
					scanJar(new JarFile(file));
				} catch (IOException e) {
					throw new IORuntimeException(e);
				}
			}
		} else if (file.isDirectory()) {
			for (File subFile : file.listFiles()) {
				scanFile(subFile, (null == rootDir) ? subPathBeforePackage(file) : rootDir);
			}
		}
	}
370874
public static void main(String... args) throws Exception {

        String string = "SELECT :expr1, #($expr2.class),"
                + " WHERE #if(:expr3) {e = $expr3} #else {e IS NULL}"
                + "#for(variant in $expr4.bytes) { AND c = :variant}" // NL
                + " {AND d = :expr-5}? {AND f = $expr6}?" // NL
                + " BY #!(:expr7) ASC";

        // 在输入中查找  PREFIX 字符
        Matcher matcher = PATTERN_KEYWORD.matcher(string);

        int position = 0;

        while (matcher.find(position)) {

            System.out.println("===============================");
            System.out.println("group 0: " + matcher.group(0));
            System.out.println("group 1: " + matcher.group(1));
            System.out.println("group 2: " + matcher.group(2));
            System.out.println("group 3: " + matcher.group(3));

            position = matcher.end();
        }

        // 在循环表达式中查找
        matcher = PATTERN_IN.matcher("variant in :expr5");

        if (matcher.matches()) {

            System.out.println("===============================");
            System.out.println("group 0: " + matcher.group(0));
            System.out.println("group 1: " + matcher.group(1));
            System.out.println("group 2: " + matcher.group(2));
        }

        // 编译下列语句
        ExqlPattern pattern = new ExqlCompiler(string).compile();

        ExqlContext context = new ExqlContextImpl();

        HashMap<String, Object> map = new HashMap<String, Object>();

        map.put("expr1", "expr1");
        map.put("expr2", "expr2");
        map.put("expr3", "expr3");
        map.put("expr4", "expr4");
        map.put("expr5", "expr5");
        // map.put("expr6", "expr6");
        map.put("expr7", "expr7");

        pattern.execute(context, map, map);
        System.out.println(context.flushOut());
        System.out.println(Arrays.toString(context.getArgs()));
    }
577646
function zip(source, target, options, fn) {
    var zip = new Zip;

    // 检查是否存在filter
    if(typeof filter == 'function'){
        fn = filter;
        filter = null;
    }
    // 检查是否存在回调
    fn = fn || function(){};

    // 查找文件准备执行压缩
    glob(source + '/**', options, function(err, files){
        if(err) throw err;

        // 添加文件到待压缩数据中
        files.forEach(function(item){
            if(fs.statSync(item).isFile()){
                zip.addFile(path.relative(source, item), item);
            }
        })

        // 执行压缩
        zip.saveAs(target, function(err){
            fn(err, target)
        })
    })
}
105025
def build_and_run_file(filename):
    ''' 
    '''
    (directory, name, extension) = get_file_tuple(filename)
    if extension == 'c':
        print(" = = = = = = ", YELLOW, "GCC: Compiling " + filename + " file", \
              RESET, " = = = = = =\n")
        compiler = Compiler(filename)
        out = compiler.compile()
        if out != 0:
            print('Error while compiling. Code:', out, 'Please retry.')
            return out
        print("")

        out = compiler.run()
        return out

    elif extension == 'cpp':
        print(" = = = = = = ", YELLOW, "GPP: Compiling " + filename + " file", \
              RESET, " = = = = = =\n")
        compiler = Compiler(filename)
        out = compiler.compile()
        if out != 0:
            print('Error while compiling. Code:', out, 'Please retry.')
            return out
        print("")

        out = compiler.run()
        return out

    elif extension == 'py':
        print(" = = = = = = ", YELLOW, "PYTHON: Executing " + filename + " file", \
              RESET, " = = = = = =\n")
        compiler = Compiler(filename)
        out = compiler.run()
        return out
    elif extension == 'java':
        command = EXECUTABLE_JAVAC + ' ' + filename
        perform_system_command(command)
        command_run = EXECUTABLE_JAVA + ' ' + name
        test_file = directory + "/" + name + ".input"
        if os.path.exists(test_file):
            command_run += " < " + test_file
        return perform_system_command(command_run)
    else:
        print("Language yet not supported")
        return -1
998532
async function mapdir(src, callback) {
    let stats = await stat(src),
        result = [];

    // 判断是否存在文件夹
    if (stats) {
        let fullpath = path.cwd(src),
            data = assign(stats, { path: fullpath });


        // 执行回调
        result.push(callback ? callback(data) : data);

        // 处理文件夹
        if (stats.isDirectory() && !fullpath.endsWith('node_modules')) {
            let files = await readdir(src);

            // 遍历下级文件
            for (let file of files) {
                result = result.concat(await mapdir(path.join(src, file), callback));
            }
        }
    }

    // 返回结果
    return result;
}
1250926
function(str) {
            var root, error = null;

            i = j = current = 0;
            chunks = [];
            input = str.replace(/\r\n/g, '\n');
            if (env.filename) {
                that.env.inputs[env.filename] = input;
            }

            // Split the input into chunks.
            chunks = (function (chunks) {
                var j = 0,
                    skip = /(?:@\{[\w-]+\}|[^"'`\{\}\/\(\)\\])+/g,
                    comment = /\/\*(?:[^*]|\*+[^\/*])*\*+\/|\/\/.*/g,
                    string = /"((?:[^"\\\r\n]|\\.)*)"|'((?:[^'\\\r\n]|\\.)*)'|`((?:[^`]|\\.)*)`/g,
                    level = 0,
                    match,
                    chunk = chunks[0],
                    inParam;

                for (var i = 0, c, cc; i < input.length;) {
                    skip.lastIndex = i;
                    match = skip.exec(input);
                    if (match) {
                        if (match.index === i) {
                            i += match[0].length;
                            chunk.push(match[0]);
                        }
                    }
                    c = input.charAt(i);
                    comment.lastIndex = string.lastIndex = i;

                    match = string.exec(input)
                    if (match) {
                        if (match.index === i) {
                            i += match[0].length;
                            chunk.push(match[0]);
                            continue;
                        }
                    }

                    if (!inParam && c === '/') {
                        cc = input.charAt(i + 1);
                        if (cc === '/' || cc === '*') {
                            match = comment.exec(input);
                            if (match) {
                                if (match.index === i) {
                                    i += match[0].length;
                                    chunk.push(match[0]);
                                    continue;
                                }
                            }
                        }
                    }

                    switch (c) {
                        case '{':
                            if (!inParam) {
                                level ++;
                            }
                            else {
                                inParam = false;
                            }
                            chunk.push(c);
                            break;
                        case '}':
                            if (!inParam) {
                                level --;
                                chunk.push(c);
                                chunks[++j] = chunk = [];
                            }
                            else {
                                inParam = false;
                                chunk.push(c);
                            }
                            break;
                        case '(':
                            if (!inParam) {
                                inParam = true;
                            }
                            else {
                                inParam = false;
                            }
                            chunk.push(c);
                            break;
                        case ')':
                            if (inParam) {
                                inParam = false;
                            }
                            chunk.push(c);
                            break;
                        default:
                            chunk.push(c);
                    }

                    i++;
                }
                if (level !== 0) {
                    error = {
                        index: i - 1,
                        message: (level > 0) ? "missing closing `}`" : "missing opening `{`",
                        filename: env.filename
                    };
                }

                return chunks.map(function (c) { return c.join(''); });
            })([[]]);

            if (error) {
                util.error(env, error);
                throw new Error('N/A');
            }

            // Start with the primary rule.
            // The whole syntax tree is held under a Ruleset node,
            // with the `root` property set to true, so no `{}` are
            // output.
            root = new tree.Ruleset([], $(this.parsers.primary));
            root.root = true;

            // Get an array of Ruleset objects, flattened
            // and sorted according to specificitySort
            root.toList = (function() {
                return function(env) {
                    env.frames = env.frames || [];


                    // call populates Invalid-caused errors
                    var definitions = this.flatten([], [], env);
                    definitions.sort(specificitySort);
                    return definitions;
                };
            })();

            // Sort rules by specificity: this function expects selectors to be
            // split already.
            //
            // Written to be used as a .sort(Function);
            // argument.
            //
            // [1, 0, 0, 467] > [0, 0, 1, 520]
            var specificitySort = function(a, b) {
                var as = a.specificity;
                var bs = b.specificity;

                if (as[0] != bs[0]) return bs[0] - as[0];
                if (as[1] != bs[1]) return bs[1] - as[1];
                if (as[2] != bs[2]) return bs[2] - as[2];
                return bs[3] - as[3];
            };

            return root;
        }
482333
private static void analyzeCorpus(String zipFile, String output, final String separator, final boolean includePhrase) throws IOException{
        File outputFile = new File(output);
        //准备输出目录
        if(!outputFile.getParentFile().exists()){
            outputFile.getParentFile().mkdirs();
        }
        try (FileSystem fs = FileSystems.newFileSystem(Paths.get(zipFile), ExtractText.class.getClassLoader());
                BufferedWriter writer = new BufferedWriter(new OutputStreamWriter(new FileOutputStream(outputFile),"utf-8"));) {
            for(Path path : fs.getRootDirectories()){                
                LOGGER.info("处理目录："+path);
                Files.walkFileTree(path, new SimpleFileVisitor<Path>(){

                    @Override
                    public FileVisitResult visitFile(Path file, BasicFileAttributes attrs) throws IOException {
                        LOGGER.info("处理文件："+file);
                        // 拷贝到本地文件系统
                        Path temp = Paths.get("target/corpus-"+System.currentTimeMillis()+".txt");
                        Files.copy(file, temp, StandardCopyOption.REPLACE_EXISTING);
                        extractText(temp, writer, separator, includePhrase);
                        return FileVisitResult.CONTINUE;
                    }
                    
                });
            }
        }
    }
466101
function copyFile(src, dist, callback) {
    let rs = fs.createReadStream(src),
        ws = fs.createWriteStream(dist);

    // 监听事件
    rs.on('error', callback);
    ws.on('error', callback);
    ws.on('close', callback);

    // 传输文件
    rs.pipe(ws);
}
1035958
function run(files, options) {
        // If translations or templates are not supplied then error
        if (options.translations.length === 0) {
            grunt.fail.fatal('Please supply translations');
        }

        // If a missing translation regex has been supplied report the missing count
        if (options.missingTranslationRegex !== null) {
            linter.setMissingTranslationRegex(options.missingTranslationRegex);
        }

        // Add the translation keys to the linter
        options.translations.forEach(function(file) {
            var files = grunt.file.expand(file);

            files.forEach(function(file) {
                if (!grunt.file.exists(file)) {
                    grunt.fail.fatal('File ' + file + ' does not exist');
                }
                linter.addKeys(grunt.file.readJSON(file));
            });
        });

        // Iterate through files and run them through the linter
        files.forEach(function(file) {
            if (!grunt.file.exists(file)) {
                grunt.fail.fatal('File ' + file + ' does not exist');
            }
            linter.check(grunt.file.read(file));
        });
    }
191576
function gotoLoadLanguageFile (langsFiles, ext, successCallback) {
    /**
     * [_tryLoad 尝试加载]
     * @param  {[string]} file        [文件路径]
     * @param  {[string]} langKey     [关键KEY]
     * @param  {[string]} ext         [扩展名：只支持两种: .josn 和 .js]
     * @param  {[function]} fnNext     [出错下一步执行函数]
     * @param  {[function]} fnCallback [成功加载回调函数]
     * @return {[type]}             [description]
     */
    function _tryLoad (file, langKey, ext, fnNext, fnCallback) {
      try {
        $.ajax({
          url: file,
          dataType: (ext === '.js' ? 'script' : 'json'),
          success: function (data, status) {
            console.log('[x] ' + status + ' =' + file);
            var obj = {
              data: data,
              status: status,
              info: {
                file: file,
                langKey: langKey,
                langID: googleLangIDMaps.getGoogleLangID(langKey),
                ext: ext
              }
            };

            t$.loadedLanguage.insert(obj.info, ext);
            fnCallback && fnCallback(obj);
          },
          error: function (req, status, err) {
            console.log(err);
            try {
              throw new Error('[x]no found... continue.. = ' + file)
            } catch (error) {
              console.warn(error);
              fnNext && fnNext(fnCallback);
            }
          }
        });
      } catch (error) {
        console.error(error);
        fnNext && fnNext();
      }
    }

    /**
     * [gotoTry 尝试]
     * @param  {[type]}   list     [文件对象列表]
     * @param  {[type]}   ext      [扩展名]
     * @param  {Function} callback [成功回调]
     * @return {[type]}            [description]
     */
    function _gotoTry (list, ext, callback) {
      if (Tool.isArray(list) && list.length > 0) {
        var ele = list[0];
        _tryLoad(ele.path, ele.key, ext, function (cb) {
          var newLangFileList = list.splice(1);
          _gotoTry(newLangFileList, ext, cb);
        }, callback);
      } else {
        console.warn('[x] language list length is 0 or not a array. TYPE=' + Tool.getType(list));
      }
    }

    // Try start
    _gotoTry(langsFiles, ext, successCallback);
  }