FIX: this is a bit silly, refactor out
6804
function good(args, err, cb) {
    if (err) {
      cb(error('entity_error', { store: name, error: err, args: args }))
      return false
    } else return true
  }
95697
def refactor(source, fixer_names, ignore=None, filename=''):
    
    check_lib2to3()
    from lib2to3 import pgen2
    try:
        new_text = refactor_with_2to3(source,
                                      fixer_names=fixer_names,
                                      filename=filename)
    except (pgen2.parse.ParseError,
            SyntaxError,
            UnicodeDecodeError,
            UnicodeEncodeError):
        return source

    if ignore:
        if ignore in new_text and ignore not in source:
            return source

    return new_text
218180
def fix_builtins(override_debug=False):
    """"""
    override_dict = {}
    orig_print = None
    used_print = None

    if(__builtins__.__class__ is dict):
        builtins_dict = __builtins__
    else:
        try:
            import builtins
        except ImportError:
            import __builtin__ as builtins
        builtins_dict = builtins.__dict__

    def _deprecated(*args, **kwargs):
        """Report the fact that the called function is deprecated."""
        import traceback
        raise DeprecationWarning("the called function is deprecated => " +
                                 traceback.extract_stack(None, 2)[0][3])

    def _print_wrapper(*args, **kwargs):
        flush = kwargs.get("flush", False)
        if "flush" in kwargs:
            del kwargs["flush"]
        orig_print(*args, **kwargs)
        if flush:
            kwargs.get("file", sys.stdout).flush()

    def _print_full(*args, **kwargs):
        opt = {"sep": " ", "end": "\n", "file": sys.stdout, "flush": False}
        for key in kwargs:
            if(key in opt):
                opt[key] = kwargs[key]
            else:
                raise TypeError("'"+key+"' is an invalid keyword argument "
                                "for this function")
        opt["file"].write(opt["sep"].join(str(val) for val in args)+opt["end"])
        if opt["flush"]:
            opt["file"].flush()

    def _sorted(my_list):
        my_list = list(my_list)
        my_list.sort()
        return my_list

    def _format(value, format_spec):
        return value.__format__(format_spec)

    if builtins_dict.get(__name__, False):
        raise RuntimeError(__name__+" already loaded")

    # Exceptions
    if builtins_dict.get("BaseException") is None:
        override_dict["BaseException"] = Exception

    # basestring
    if builtins_dict.get("basestring") is None:
        if builtins_dict.get("bytes") is None:
            import types
            override_dict["basestring"] = types.StringType
        else:
            override_dict["basestring"] = (str, bytes)  # It works only when used in isinstance
    # IntType
    if getattr(int, "__str__", None) is None:
        import types
        override_dict["IntType"] = types.IntType
    else:
        override_dict["IntType"] = int  # Python >= 2.2

    if 'format' not in str.__dict__:
        override_dict["str"] = _Internal.ExtStr
    # Function 'input'
    if builtins_dict.get("raw_input") is not None:
        override_dict["input"] = builtins_dict.get("raw_input")
    override_dict["raw_input"] = _deprecated
    # Function 'print' (also aliased as print_)
    if sys.version_info >= (3, 3):
        used_print = builtins_dict.get("print")
    else:
        orig_print = builtins_dict.get("print")
        if orig_print is not None:
            used_print = _print_wrapper
        else:
            used_print = _print_full
        override_dict["print"] = used_print
    override_dict["print_"] = used_print
    # Function 'sorted'
    if builtins_dict.get("sorted") is None:
        override_dict["sorted"] = _sorted
    # Function 'format'
    if builtins_dict.get("format") is None:
        override_dict["format"] = _format

    override_dict[__name__] = True
    builtins_dict.update(override_dict)
    del override_dict
163893
function compileSourcePreCode() {
    var $version = '##version##';

    var componentRenderers = {};

    function extend(target, source) {
        if (source) {
            Object.keys(source).forEach(function (key) {
                var value = source[key];
                if (typeof value !== 'undefined') {
                    target[key] = value;
                }
            });
        }

        return target;
    }

    function each(array, iterator) {
        if (array && array.length > 0) {
            for (var i = 0, l = array.length; i < l; i++) {
                if (iterator(array[i], i) === false) {
                    break;
                }
            }
        }
    }

    function contains(array, value) {
        var result;
        each(array, function (item) {
            result = item === value;
            return !result;
        });

        return result;
    }

    var HTML_ENTITY = {
        /* jshint ignore:start */
        '&': '&amp;',
        '<': '&lt;',
        '>': '&gt;',
        '"': '&quot;',
        /* eslint-disable quotes */
        "'": '&#39;'
        /* eslint-enable quotes */
        /* jshint ignore:end */
    };

    function htmlFilterReplacer(c) {
        return HTML_ENTITY[c];
    }

    function escapeHTML(source) {
        if (source == null) {
            return '';
        }

        if (typeof source === 'string') {
            return source ? source.replace(/[&<>"']/g, htmlFilterReplacer) : '';
        }

        return '' + source;
    }

    function _classFilter(source) {
        if (source instanceof Array) {
            return source.join(' ');
        }

        return source;
    }

    function _styleFilter(source) {
        if (typeof source === 'object') {
            var result = '';
            if (source) {
                Object.keys(source).forEach(function (key) {
                    result += key + ':' + source[key] + ';';
                });
            }

            return result;
        }

        return source;
    }

    function _xclassFilter(source) {
        if (source instanceof Array) {
            source = source.join(' ');
        }

        return source ? ' ' + source : '';
    }

    function _xstyleFilter(source) {
        var result;
        if (typeof source === 'object') {
            result = '';
            if (source) {
                Object.keys(source).forEach(function (key) {
                    result += key + ':' + source[key] + ';';
                });
            }
        }
        else {
            result = source;
        }

        return result ? ';' + result : '';
    }

    function attrFilter(name, value) {
        if (value) {
            return ' ' + name + '="' + value + '"';
        }

        return '';
    }

    function boolAttrFilter(name, value) {
        if (value && value !== 'false' && value !== '0') {
            return ' ' + name;
        }

        return '';
    }

    function callFilter(ctx, name, args) {
        var filter = ctx.proto.filters[name];
        if (typeof filter === 'function') {
            return filter.apply(ctx, args);
        }
    }
}
724031
function fixParamsWithParenthesis(fixer) {
                const paramToken = sourceCode.getTokenAfter(firstTokenOfParam);

                /*
                 * ES8 allows Trailing commas in function parameter lists and calls
                 * https://github.com/eslint/eslint/issues/8834
                 */
                const closingParenToken = sourceCode.getTokenAfter(paramToken, astUtils.isClosingParenToken);
                const asyncToken = isAsync ? sourceCode.getTokenBefore(firstTokenOfParam) : null;
                const shouldAddSpaceForAsync = asyncToken && (asyncToken.range[1] === firstTokenOfParam.range[0]);

                return fixer.replaceTextRange([
                    firstTokenOfParam.range[0],
                    closingParenToken.range[1]
                ], `${shouldAddSpaceForAsync ? " " : ""}${paramToken.value}`);
            }
1120403
def needs_fixing(raw_params, kwargs_default=_kwargs_default_name):
    
    """
    found_kwargs = False
    needs_fix = False

    for t in raw_params[2:]:
        if t.type == token.COMMA:
            # Commas are irrelevant at this stage.
            continue
        elif t.type == token.NAME and not found_kwargs:
            # Keyword-only argument: definitely need to fix.
            needs_fix = True
        elif t.type == token.NAME and found_kwargs:
            # Return 'foobar' of **foobar, if needed.
            return t.value if needs_fix else u''
        elif t.type == token.DOUBLESTAR:
            # Found either '*' from **foobar.
            found_kwargs = True
    else:
        # Never found **foobar.  Return a synthetic name, if needed.
        return kwargs_default if needs_fix else u''
915398
function simplified(js) {
	var is = false;
	var go = false;
	var here = 'out.html += '; // hardcoced
	var gone = '            '; // hardcoded to equal length
	var fixes = [];
	var lines = js.split('\n').map(function(line, index) {
		go = line.trim().startsWith(here);
		if (is && go) {
			line = line.replace(here, gone);
			fixes.push(index - 1);
		}
		is = go;
		return line;
	});
	fixes.forEach(function(index) {
		if (index > -1) {
			var line = lines[index];
			lines[index] = line.replace(/;$/, ' +');
		}
	});
	return lines.join('\n');
}
231987
function fixTableCaretPos() {
        editor.on('KeyDown SetContent VisualAid', function () {
          var last;

          // Skip empty text nodes from the end
          for (last = editor.getBody().lastChild; last; last = last.previousSibling) {
            if (last.nodeType == 3) {
              if (last.nodeValue.length > 0) {
                break;
              }
            } else if (last.nodeType == 1 && (last.tagName == 'BR' || !last.getAttribute('data-mce-bogus'))) {
              break;
            }
          }

          if (last && last.nodeName == 'TABLE') {
            if (editor.settings.forced_root_block) {
              editor.dom.add(
                editor.getBody(),
                editor.settings.forced_root_block,
                editor.settings.forced_root_block_attrs,
                Env.ie && Env.ie < 10 ? '&nbsp;' : '<br data-mce-bogus="1" />'
              );
            } else {
              editor.dom.add(editor.getBody(), 'br', { 'data-mce-bogus': '1' });
            }
          }
        });

        editor.on('PreProcess', function (o) {
          var last = o.node.lastChild;

          if (last && (last.nodeName == "BR" || (last.childNodes.length == 1 &&
            (last.firstChild.nodeName == 'BR' || last.firstChild.nodeValue == '\u00a0'))) &&
            last.previousSibling && last.previousSibling.nodeName == "TABLE") {
            editor.dom.remove(last);
          }
        });
      }
603899
def refactor_rename_at_point(self, offset, new_name, in_hierarchy, docs):
        """"""
        try:
            refactor = Rename(self.project, self.resource, offset)
        except RefactoringError as e:
            raise Fault(str(e), code=400)
        return self._get_changes(refactor, new_name,
                                 in_hierarchy=in_hierarchy, docs=docs)
1267906
def apply_refactor(self, call_id, payload):
        """"""
        supported_refactorings = ["Rename", "InlineLocal", "AddImport", "OrganizeImports"]

        if payload["refactorType"]["typehint"] in supported_refactorings:
            diff_filepath = payload["diff"]
            path = self.editor.path()
            bname = os.path.basename(path)
            target = os.path.join(self.tmp_diff_folder, bname)
            reject_arg = "--reject-file={}.rej".format(target)
            backup_pref = "--prefix={}".format(self.tmp_diff_folder)
            # Patch utility is prepackaged or installed with vim
            cmd = ["patch", reject_arg, backup_pref, path, diff_filepath]
            failed = Popen(cmd, stdout=PIPE, stderr=PIPE).wait()
            if failed:
                self.editor.message("failed_refactoring")
            # Update file and reload highlighting
            self.editor.edit(self.editor.path())
            self.editor.doautocmd('BufReadPre', 'BufRead', 'BufEnter')
1334089
function mixin(rework, declarations, mixins) {
  for (var i = 0; i < declarations.length; ++i) {
    var decl = declarations[i];
    if ('comment' == decl.type) continue;

    var key = decl.property;
    var val = decl.value;
    var fn = mixins[key];
    if (!fn) continue;

    // invoke mixin
    var ret = fn.call(rework, val);

    // apply properties
    for (var key in ret) {
      var val = ret[key];
      if (Array.isArray(val)) {
        val.forEach(function(val){
          declarations.splice(i++, 0, {
            type: 'declaration',
            property: key,
            value: val
          });
        });
      } else {
        declarations.splice(i++, 0, {
          type: 'declaration',
          property: key,
          value: val
        });
      }
    }

    // remove original
    declarations.splice(i--, 1);
  }
}
610694
public void fixRowsAndCols() {
        rows = (int) Math.round((n - s) / ns_res);
        if (rows < 1)
            rows = 1;
        cols = (int) Math.round((e - w) / we_res);
        if (cols < 1)
            cols = 1;
    }
908434
function fixMarkup(value, tabReplace, useBR) {
    if (tabReplace) {
      value = value.replace(/^((<[^>]+>|\t)+)/gm, function(match, p1, offset, s) {
        return p1.replace(/\t/g, tabReplace);
      })
    }
    if (useBR) {
      value = value.replace(/\n/g, '<br>');
    }
    return value;
  }
1199712
private void refineUpperBound() {
        for (final Integer lit : new ArrayList<>(this.candidates)) {
            final int var = var(lit);
            if (isUPZeroLit(var)) {
                this.candidates.remove(lit);
                addBackboneLiteral(lit);
            } else if (this.config.isCheckForComplementModelLiterals() && this.model.get(var) == sign(lit)) {
                this.candidates.remove(lit);
            } else if (this.config.isCheckForRotatableLiterals() && isRotatable(lit)) {
                this.candidates.remove(lit);
            }
        }
    }
494390
function(_hook, _fun) {
      if(this.$$cb && this.$$cb[_hook]) {
        var idx = Utils.indexWhere(this.$$cb[_hook], function(e) { return e === _fun; });
        if(idx !== -1) this.$$cb[_hook].splice(idx, 1);
      }
      return this;
    }
669408
function fixDefaultChecked( elem ) {
	if ( manipulation_rcheckableType.test( elem.type ) ) {
		elem.defaultChecked = elem.checked;
	}
}
910161
def fix_return_value(v, method_name, method=None, checker=None):
    
    # remove common check prefix
    method_name = (method_name or method.__func__.__name__).replace("check_","")
    if v is None or not isinstance(v, Result):
        v = Result(value=v, name=method_name)

    v.name         = v.name or method_name

    v.checker      = checker
    v.check_method = method

    return v