/*
Creates a view of a file (.brackets.json)
@param {!File} file - the file to create a view for
@param {!Pane} pane - the pane where to create the view
@private
8516
function _createConfigViewOf(file, pane) {
        var result = new $.Deferred(),
            view = pane.findViewOfFile(file.fullPath);

        if (view) {
            // existing view, then just show it
            pane.showView(view);
            result.resolve(view.getFile());
        } else {
            DocumentManager.getDocumentForPath(file.fullPath)
                .done(function (doc) {
                    var view = new ConfigView(doc, pane.$el);
                    pane.addView(view, true);
                    result.resolve(doc.file);
                })
                .fail(function (fileError) {
                    result.reject(fileError);
                });
        }
        return result.promise();
    }
629371
function _makeFileMostRecent(paneId, file) {
        var index,
            entry,
            pane = _getPane(paneId);

        if (!_traversingFileList) {
            pane.makeViewMostRecent(file);

            index = _findFileInMRUList(pane.id, file);

            entry = _makeMRUListEntry(file, pane.id);

            if (index !== -1) {
                _mruList.splice(index, 1);
            }

            if (_findFileInMRUList(pane.id, file) !== -1) {
                console.log(file.fullPath + " duplicated in mru list");
            }

            // add it to the front of the list
            _mruList.unshift(entry);
        }
    }
672435
function addFile(file) {
                var $li = $('<li id="' + file.id + '">' +
                        '<p class="title">' + file.name + '</p>' +
                        '<p class="imgWrap"></p>' +
                        '<p class="progress"><span></span></p>' +
                        '</li>'),

                    $btns = $('<div class="file-panel">' +
                        '<span class="cancel">' + lang.uploadDelete + '</span>' +
                        '<span class="rotateRight">' + lang.uploadTurnRight + '</span>' +
                        '<span class="rotateLeft">' + lang.uploadTurnLeft + '</span></div>').appendTo($li),
                    $prgress = $li.find('p.progress span'),
                    $wrap = $li.find('p.imgWrap'),
                    $info = $('<p class="error"></p>').hide().appendTo($li),

                    showError = function (code) {
                        switch (code) {
                            case 'exceed_size':
                                text = lang.errorExceedSize;
                                break;
                            case 'interrupt':
                                text = lang.errorInterrupt;
                                break;
                            case 'http':
                                text = lang.errorHttp;
                                break;
                            case 'not_allow_type':
                                text = lang.errorFileType;
                                break;
                            default:
                                text = lang.errorUploadRetry;
                                break;
                        }
                        $info.text(text).show();
                    };

                if (file.getStatus() === 'invalid') {
                    showError(file.statusText);
                } else {
                    $wrap.text(lang.uploadPreview);
                    if ('|png|jpg|jpeg|bmp|gif|'.indexOf('|'+file.ext.toLowerCase()+'|') == -1) {
                        $wrap.empty().addClass('notimage').append('<i class="file-preview file-type-' + file.ext.toLowerCase() + '"></i>' +
                            '<span class="file-title">' + file.name + '</span>');
                    } else {
                        if (browser.ie && browser.version <= 7) {
                            $wrap.text(lang.uploadNoPreview);
                        } else {
                            uploader.makeThumb(file, function (error, src) {
                                if (error || !src || (/^data:/.test(src) && browser.ie && browser.version <= 7)) {
                                    $wrap.text(lang.uploadNoPreview);
                                } else {
                                    var $img = $('<img src="' + src + '">');
                                    $wrap.empty().append($img);
                                    $img.on('error', function () {
                                        $wrap.text(lang.uploadNoPreview);
                                    });
                                }
                            }, thumbnailWidth, thumbnailHeight);
                        }
                    }
                    percentages[ file.id ] = [ file.size, 0 ];
                    file.rotation = 0;

                    /* 检查文件格式 */
                    if (!file.ext || acceptExtensions.indexOf(file.ext.toLowerCase()) == -1) {
                        showError('not_allow_type');
                        uploader.removeFile(file);
                    }
                }

                file.on('statuschange', function (cur, prev) {
                    if (prev === 'progress') {
                        $prgress.hide().width(0);
                    } else if (prev === 'queued') {
                        $li.off('mouseenter mouseleave');
                        $btns.remove();
                    }
                    // 成功
                    if (cur === 'error' || cur === 'invalid') {
                        showError(file.statusText);
                        percentages[ file.id ][ 1 ] = 1;
                    } else if (cur === 'interrupt') {
                        showError('interrupt');
                    } else if (cur === 'queued') {
                        percentages[ file.id ][ 1 ] = 0;
                    } else if (cur === 'progress') {
                        $info.hide();
                        $prgress.css('display', 'block');
                    } else if (cur === 'complete') {
                    }

                    $li.removeClass('state-' + prev).addClass('state-' + cur);
                });

                $li.on('mouseenter', function () {
                    $btns.stop().animate({height: 30});
                });
                $li.on('mouseleave', function () {
                    $btns.stop().animate({height: 0});
                });

                $btns.on('click', 'span', function () {
                    var index = $(this).index(),
                        deg;

                    switch (index) {
                        case 0:
                            uploader.removeFile(file);
                            return;
                        case 1:
                            file.rotation += 90;
                            break;
                        case 2:
                            file.rotation -= 90;
                            break;
                    }

                    if (supportTransition) {
                        deg = 'rotate(' + file.rotation + 'deg)';
                        $wrap.css({
                            '-webkit-transform': deg,
                            '-mos-transform': deg,
                            '-o-transform': deg,
                            'transform': deg
                        });
                    } else {
                        $wrap.css('filter', 'progid:DXImageTransform.Microsoft.BasicImage(rotation=' + (~~((file.rotation / 90) % 4 + 4) % 4) + ')');
                    }

                });

                $li.insertBefore($filePickerBlock);
            }
960114
function (file) {
        if (!this.ignore(file)) {
            file = this.map(file);
            file = utils.normalize(file);
            return file;
        }
    }
111613
function Doc(text, file, line, options) {
  if (typeof text == 'object') {
    for ( var key in text) {
      this[key] = text[key];
    }
  } else {
    this.text = text;
    this.file = file;
    this.line = line;
  }
  this.options = options || {};
  this.scenarios = this.scenarios || [];
  this.requires = this.requires || [];
  this.param = this.param || [];
  this.properties = this.properties || [];
  this.methods = this.methods || [];
  this.events = this.events || [];
  this.links = this.links || [];
  this.anchors = this.anchors || [];
}
234365
function(file, asObject) {
		var self = this,
			template = {
				'background' : 'url(\'{url}\') 0 0 no-repeat',
				'background-size' : 'contain'
			},
			style = '',
			cssObj = {},
			i = 0;
		if (file.icon) {
			style = 'style="';
			$.each(template, function(k, v) {
				if (i++ === 0) {
					v = v.replace('{url}', self.escape(file.icon));
				}
				if (asObject) {
					cssObj[k] = v;
				} else {
					style += k+':'+v+';';
				}
			});
			style += '"';
		}
		return asObject? cssObj : style;
	}
783516
function bundle (file, options) {
  api.bundle(file, options)
    .then((bundled) => {
      if (options.outfile) {
        console.log("Created %s from %s", options.outfile, file);
      }
      else {
        // Write the bundled API to stdout
        console.log(bundled);
      }
    })
    .catch(errorHandler);
}
964333
function(file) {
    return fs.openAsync(file, 'r').then((fileDescriptor) => {
      return lzma.parseFileIndexFDAsync(fileDescriptor).tap(() => {
        return fs.closeAsync(fileDescriptor);
      });
    }).then((metadata) => {
      return {
        stream: fs.createReadStream(file)
          .pipe(lzma.createDecompressor()),
        size: metadata.uncompressedSize,
        transform: new PassThroughStream()
      };
    });
  }
326843
function load(file) {
    if (path.extname(file) === ".yaml" || path.extname(file) === ".yml") {
      return yaml.safeLoad(fs.readFileSync(file));

    } else if (path.extname(file) === ".json") {
      var r = JSON.parse(fs.readFileSync(file));
      return r;

    } else if (path.extname(file) === ".js") {
      var obj = require(file);
      
      if (typeof(obj) !== "object") {
        throw {error: "needs to export object, not "+typeof(obj), file: file};

      } else {
        return clone(obj);
      }
    } else {
      throw {error: path+" has invalid extension: "+path.extname(file)};
    }
  }
503708
function watchFile( file )
        {
            // make sure file is at least something
            if ( !file || '' === file )
            {
                return
            }

            // make sure it's a string
            file = file.toString()

            if ( watchers.hasOwnProperty( file ) )
            {
                return // already exists
            }

            // watch it
            watchers[ file ] = chokidar.watch( file, { ignored:  /[\/\\]\./, persistent: true } )

            var that = this

            // setup event listeners
            watchers[ file ]
                // listener for when the file has been removed
                .on( 'unlink', function ( path )
                    {
                        that.opts.storageMethod.remove( path, function ( err )
                            {
                                if ( err )
                                {
                                    if ( that.opts.logging )
                                    {
                                        console.log( err )
                                    }

                                    return 
                                }

                                // success
                                
                            }
                        )
                    }
                )

                // listener for when the file has been changed
                .on( 'change', function ( path )
                    {
                        // add to main file processing queue
                        mainQueue.add( function ( mainDone )
                            {
                                // attempt to read the file
                                fs.readFile( path, function ( err, fileContents )
                                    {
                                        // notify nbqueue that the async function has finished,
                                        // regardless of success
                                        mainDone()

                                        // check for errors
                                        if ( err )
                                        {
                                            // see if LocalJson instance logging is enabled
                                            if ( that.opts.logging )
                                            {
                                                console.log( err )
                                            }

                                            return 
                                        }

                                        var parsed = LocalJson.TryParse.call( that, JSON.parse, fileContents )

                                        // cache new json
                                        that.opts.storageMethod.set( path, parsed, function ( err )
                                            {
                                                if ( err )
                                                {
                                                    if ( that.opts.logging )
                                                    {
                                                        console.log( err )
                                                    }

                                                    return
                                                }

                                                // success
                                                
                                            }
                                        )
                                    }
                                )
                            }
                        )
                    }
                )
        }
156367
@Override
    public synchronized void onFileCreate(File file) {
        final Set<DetectedWebJar> listOfDetectedWebJarLib = isWebJar(file);
        if (listOfDetectedWebJarLib != null) {
            JarFile jar = null;
            try {
                jar = new JarFile(file);
                List<FileWebJarLib> installed = new ArrayList<>();
                for (DetectedWebJar detected : listOfDetectedWebJarLib) {
                    FileWebJarLib lib = expand(detected, jar);
                    if (lib != null) {
                        libs.add(lib);
                        installed.add(lib);
                        LOGGER.info("{} unpacked to {}", lib.name, lib.root.getAbsolutePath());
                    }
                }
                controller.addWebJarLibs(installed);
            } catch (IOException e) {
                LOGGER.error("Cannot open the jar file {}", file.getAbsolutePath(), e);
            } finally {
                IOUtils.closeQuietly(jar);
            }

        }
    }
1012984
function Environment(file) {
  if (!(this instanceof Environment))
    return new Environment(file);

  this.path = file && path.resolve(file);
  try {
    this.raw = this.path && fs.readFileSync(this.path);
  } catch (e) {
    this.raw = '';
  }
  try {
    this.env = this.raw ? JSON.parse(this.raw) : Object.create(null);
  } catch (e) {
    this.env = Object.create(null);
  }
}
396629
function writeFile(file, content) {
    fs.writeFileSync(file, content);
    files.push(path.relative(app.components.get('path'), file));
}
709496
function (file, writeOptions) {
  writeOptions = writeOptions || {};
  function toBuffer(ab) {
    var buffer = new Buffer(ab.byteLength);
    var view = new Uint8Array(ab);
    for (var i = 0; i < buffer.length; ++i) {
      buffer[i] = view[i];
    }
    return buffer;
  }
  var buf = index$14.structure(file);
  return toBuffer(buf.buffer);
}
30276
function parseFile(file, done) {

    // create stream
    var saxStream = sax.createStream(options.strict, options);

    saxStream.on('error', function(e) {
      // unhandled errors will throw, since this is a proper node
      // event emitter.
      console.error('error!', e);
      // clear the error
      this._parser.error = null;
      this._parser.resume();

      // TODO: send to error callback
    });

    saxStream.on('opentag', function(node) {
      var name = node.name,
          value;

      if (parsedTags.indexOf(name) !== -1) {
        var parser = parsers[name];

        if (!parser) {
          throw new Error('[modelgen] no parser for tag <' + name + '>');
        }

        value = parser(node, this);
      }

      if (value) {
        stack.push(value);
      }
    });

    saxStream.on('closetag', function(nodeName) {
      if (parsedTags.indexOf(nodeName) !== -1) {
        stack.pop();
      }
    });

    saxStream.on('end', function() {

      var result = { byId: elementsById, byType: elementsByType };

      postProcess(result);
      done(null, result);
    });

    // pipe is supported, and it's readable/writable
    // same chunks coming in also go out.
    fs.createReadStream(file).pipe(saxStream);
  }
350449
function buildStructureForFile(file) {
  var names = [];
  var targetLink;

  if (file.dox.length === 0) { return false; }

  file.dox.forEach(function(method){
    if (method.ctx && !method.ignore) { names.push(method.ctx.name); }
  });

  // How deep is your love?
  // If the splitted currentFile (the file we are currently rendering) path got one folder
  // in the path or more, add ../ for each level found
  if(file.currentFile && file.currentFile.split(path.sep).length > 1 ){
    // Depth of current file
    var depth = file.currentFile.split(path.sep).length,
    // Create a prefix with n "../"
    prefix = new Array(depth).join('../');
    // Set up target link with prefix
    targetLink = prefix + file.targetFile;
  } else {
    // Link does not have to be altered
    targetLink = file.targetFile;
  }

  return {
    source: {
      full: file.sourceFile,
      dir: path.dirname(file.sourceFile),
      file: path.basename(file.sourceFile)
    },
    target: file.targetFile,
    methods: names,
    link : targetLink
  };
}
457563
function File(file) {
  this.cache = new Map();
  this.history = [];
  this.pattern = file.pattern;
  this.recurse = file.recurse;
  this.dirname = file.dirname;
  this.segment = file.segment;
  this.path = file.path;
  this.orig = file.path;
}