xxxxx.xxxxx.creative.add
        ===================================
        创建一个创意
353615
def add(self, adgroup_id, title, img_url, nick=None):
        ''''''
        request = TOPRequest('xxxxx.xxxxx.creative.add')
        request['adgroup_id'] = adgroup_id
        request['title'] = title
        request['img_url'] = img_url
        if nick!=None: request['nick'] = nick
        self.create(self.execute(request), fields=['success','result','success','result_code','result_message'], models = {'result':Creative})
        return self.result
355081
function (string, userConfig) {
        // 空文件会导致错误
        if (string.trim() === '') {
            return '';
        }

        userConfig = userConfig || {};

        overwriteConfig(_config, userConfig); // overwrite codeStyle with user config

        // deal with indent (new Array(indent + 1)).join(' ')
        var INDENT = (function () {
            var indentStr = '';
            var space = _config.useTabIndent ? '\t' : ' ';
            var indent = _config.indent ? Number(_config.indent) : 4;
            while (indent--) {
                indentStr += space;
            }
            return indentStr;
        })();

        /**
         * create a LineBreak token
         *
         * @returns {{type: string, value: string, formatter: boolean}}
         */
        var nextLineFactory = function () {
            return {
                type: 'LineBreak',
                value: _config.lineSeparator,
                formatter: true
            };
        };

        /**
         * create a indent token with indent level
         *
         * @returns {Object}
         */
        var indentFactory = function () {
            var indentStr = '';
            for (var i = 0; i < indentLevel; i++) {
                indentStr += INDENT;
            }
            return {
                type: 'WhiteSpace',
                value: indentStr
            };
        };

        /**
         * create a indent token with only one indent
         *
         * @returns {Object}
         */
        var singleIndentFactory = function () {
            return {
                type: 'WhiteSpace',
                value: INDENT
            };
        };

        /**
         * create a single space token
         *
         * @returns {Object}
         */
        var whiteSpaceFactory = function () {
            return {
                type: 'WhiteSpace',
                value: ' '
            };
        };

        /**
         * check if a token is comment
         *
         * @param {Object} token - the token to check
         * @returns {boolean}
         */
        var isComment = function (token) {
            return token.type === 'LineComment' || token.type === 'BlockComment';
        };

        /**
         * check if a token is comment LineComment
         *
         * @param {Object} token - the token to check
         * @returns {boolean}
         */
        var isLineComment = function (token) {
            return token.type === 'LineComment';
        };

        /**
         * check if a token is comment BlockComment
         *
         * @param {Object} token - the token to check
         * @returns {boolean}
         */
        var isBlockComment = function (token) {
            return token.type === 'BlockComment';
        };

        /**
         * check if a token is white space
         *
         * @param {Object} token - the token to check
         * @returns {boolean}
         */
        var isWhiteSpace = function (token) {
            return token.type === 'WhiteSpace';
        };

        /**
         * check if a token is line break
         *
         * @param {Object} token - the token to check
         * @returns {boolean}
         */
        var isLineBreak = function (token) {
            return token.type === 'LineBreak';
        };

        /**
         * check if a token is comment in one line
         *
         * @param {Object} token - the token to check
         * @returns {boolean}
         */
        var isInlineComment = function (token) {
            var inline = false;
            if (token) {
                if (token.type === 'LineComment') {
                    inline = true;
                } else if (token.type === 'BlockComment') {
                    inline = (token.value.indexOf('\n') === -1);
                }
            }
            return inline;
        };

        /**
         * check if only types between startToken and endToken
         *
         * @param {Object} startToken - the token to start check
         * @param {Object} endToken - the token to end check
         * @param {Array} types - allow types array
         * @returns {boolean}
         */
        var isTypeBetween = function (startToken, endToken, types) {
            var is = true;
            var token = startToken;
            while (token.next && token.next !== endToken) {
                token = token.next;
                if (types.indexOf(token.type) === -1) {
                    is = false;
                    break;
                }
            }
            return is;
        };

        /**
         * 保证一个语句节点是在新起一行
         *
         * @param {Object} node - target node
         */
        var guaranteeNewLine = function (node) {
            if (node.startToken.prev && node.startToken.prev.type !== 'LineBreak') {
                insertBefore(node.startToken, nextLineFactory());
            }
        };

        /**
         * 保证一个token两侧是空白符
         *
         * @param {Object} token - target token
         */
        var guaranteeWhiteSpaceAround = function (token) {
            if (token.prev.type !== 'WhiteSpace') {
                insertBefore(token, whiteSpaceFactory());
            }
            if (token.next.type !== 'WhiteSpace' && token.next.type !== 'LineBreak') {
                insertAfter(token, whiteSpaceFactory());
            }
        };

        /**
         * insert token before a token
         *
         * @param {Object} token - target token
         * @param {Object} insertion - a token to insert
         */
        var insertBefore = function (token, insertion) {
            if (!token.prev) { // insert at first
                token.prev = insertion;
                insertion.next = token;
            } else {
                token.prev.next = insertion;
                insertion.prev = token.prev;
                insertion.next = token;
                token.prev = insertion;
            }
        };

        /**
         * insert token after a token
         *
         * @param {Object} token - target token
         * @param {Object} insertion - a token to insert
         */
        var insertAfter = function (token, insertion) {
            if (!token.next) { // insert at last
                token.next = insertion;
                insertion.prev = token;
            } else {
                token.next.prev = insertion;
                insertion.next = token.next;
                insertion.prev = token;
                token.next = insertion;
            }
        };

        /**
         * remove token in tokens
         *
         * @param {Object} token - target token
         */
        var removeToken = function (token) {
            if (token.prev && token.next) {
                token.prev.next = token.next;
                token.next.prev = token.prev;
            } else if (token.prev) {
                token.prev.next = undefined;
            } else if (token.next) {
                token.next.prev = undefined;
            }
        };

        /**
         * 这堆操作符前后是要有空白的
         *
         * @type {string[]}
         */
        var SPACE_AROUND_PUNCTUATOR = [
            '=', '+=', '-=', '*=', '/=', '%=', '<<=', '>>=', '>>>=', '&=', '^=', '|=',
            '==', '!=', '===', '!==', '>', '>=', '<', '<=',
            '+', '-', '*', '/', '%',
            '&', '|', '^', '~', '<<', '>>', '>>>',
            '&&', '||'
        ];

        var _rocambole = require('rocambole');

        // 先fix再format
        string = require('./lib/fix').fix(string, _config.fix);

        try {
            var _ast = _rocambole.parse(string);
        } catch (e) {
            return string;
        }

        // start clear
        // 先去除空白
        var clearWhiteSpace = function (token) {
            if (isWhiteSpace(token)) {
                // 默认都要删除空白
                var remove = true;

                // 空白前面是换行 && 后面是注释的不删除
                if (token.prev && token.next && isLineBreak(token.prev) && isComment(token.next)) {
                    remove = false;
                }

                if (remove) {
                    removeToken(token);
                }
            }

            if (isLineComment(token)) {
                token.raw = token.raw.trimRight();
            }

            if (isBlockComment(token)) {
                var rawArray = token.raw.split(_config.lineSeparator);
                rawArray.forEach(function (line, i) {
                    rawArray[i] = line.trimRight();
                });
                token.raw = rawArray.join(_config.lineSeparator);
            }
        };
        var token = _ast.startToken;
        while (token !== _ast.endToken.next) {
            clearWhiteSpace(token);
            token = token.next;
        }

        if (_config.blankLines.keepMaxBlankLines > 0) {
            _rocambole.recursive(_ast, function (node) {
                var keep = 0;
                var t;
                if (/Declaration|Statement/.test(node.type) && node.type !== 'BlockStatement' && !(node.type === 'VariableDeclaration' && node.parent.type === 'ForStatement')) {
                    keep = Number(_config.blankLines.keepMaxBlankLines);
                    if (node.endToken.next && isLineBreak(node.endToken.next)) {
                        t = node.endToken.next;
                        t.removeAble = false;
                        while (keep--) {
                            if (t.next && isLineBreak(t.next)) {
                                t.next.removeAble = false;
                                t = t.next;
                            }
                        }
                    }
                }
                if (node.type === 'Property') {
                    keep = Number(_config.blankLines.keepMaxBlankLines);
                    if (node.startToken.prev && isLineBreak(node.startToken.prev)) {
                        t = node.startToken.prev;
                        t.removeAble = false;
                        while (keep--) {
                            if (t.prev && isLineBreak(t.prev)) {
                                t.prev.removeAble = false;
                                t = t.prev;
                            }
                        }
                    }
                }
            });
        }
        var clearLineBreak = function (token) {
            // 注释前后的换行一律保留，其他一律删除
            if (isLineBreak(token)) {
                // 默认都要删除换行
                var remove = true;

                // 注释前面的
                if (token.next && isComment(token.next)) {
                    remove = false;
                }
                // 注释后面的
                if (token.prev && isComment(token.prev)) {
                    remove = false;
                }
                // 注释前面空白再前面的，这种是有缩进且占整行的注释
                if (token.next && token.next.next && isWhiteSpace(token.next) && isComment(token.next.next)) {
                    remove = false;
                }

                if (token.prev && !token.prev.prev && Number(_config.blankLines.keepMaxBlankLines) > 0 && isComment(token.prev) && token.prev.value.charAt(0) === '*') {
                    if (token.next && isLineBreak(token.next)) {
                        token.next.removeAble = false;
                        token.next.next.removeAble = false;
                    }
                }
                if (token.removeAble === false) {
                    remove = false;
                }

                if (remove) {
                    removeToken(token);
                }
            }
        };
        token = _ast.startToken;
        while (token !== _ast.endToken.next) {
            clearLineBreak(token);
            token = token.next;
        }
        // end clear

        // start process
        // 这些关键词之后，必须无脑保证空白，其实return,delete等并不是必须要空白，但是应该没有傻逼这么写吧return(a);忽略这种情况
        // 如果这些关键词后面都不加空白，那就傻逼鉴定完毕 shit 所以不提供这种配置
        var INSERT_SPACE_AFTER_KEYWORD = ['throw', 'return', 'delete', 'new', 'in', 'typeof', 'instanceof', 'case', 'void'];
        // 这几个关键词属于同一类型，在它们后边可以加空白也可以不加，都不会出先语法错误
        var INSERT_SPACE_AFTER_KEYWORD_WITH_CONFIG = ['if', 'for', 'while', 'switch', 'catch'];
        var processToken = function (token) {
            // 必须加空白的地方
            if (token.type === 'Keyword' && INSERT_SPACE_AFTER_KEYWORD.indexOf(token.value) !== -1) {
                insertAfter(token, whiteSpaceFactory());
            }
            // 坑：var后面可以是换行，这时候就不需要空白
            if (
                token.type === 'Keyword'
                && (token.value === 'var' || token.value === 'let' || token.value === 'const')
                && !isLineBreak(token.next)
            ) {
                insertAfter(token, whiteSpaceFactory());
            }

            if (_config.spaces.before.parentheses && token.type === 'Keyword' && INSERT_SPACE_AFTER_KEYWORD_WITH_CONFIG.indexOf(token.value) !== -1) {
                insertAfter(token, whiteSpaceFactory());
            }

            // check around = WhiteSpace
            if (_config.spaces.around.binaryOperators && token.type === 'Punctuator' && SPACE_AROUND_PUNCTUATOR.indexOf(token.value) !== -1) {
                guaranteeWhiteSpaceAround(token);
            }
            // 特殊处理in/instanceof，这货两边必须保证空白
            if (token.type === 'Keyword' && ['in', 'instanceof'].indexOf(token.value) !== -1) {
                guaranteeWhiteSpaceAround(token);
            }

            // 特殊处理finally，这货在ast里不是一个独立type节点
            if (token.type === 'Keyword' && token.value === 'finally') {
                if (_config.spaces.before.keywords && !isWhiteSpace(token.prev)) {
                    insertBefore(token, whiteSpaceFactory());
                }
            }
        };
        token = _ast.startToken;
        while (token !== _ast.endToken.next) {
            processToken(token);
            token = token.next;
        }
        // end process

        // loop node
        _rocambole.recursive(_ast, function (node) {
            switch (node.type) {
                case 'ArrayExpression':
                    node.startToken.indentIncrease = true;
                    node.endToken.indentDecrease = true;
                    node.elements.forEach(function (el) {
                        el && guaranteeNewLine(el);
                    });
                    if (node.elements.length > 0 && !isLineBreak(node.endToken.prev)) {
                        insertBefore(node.endToken, nextLineFactory());
                    }
                    break;
                case 'BreakStatement':
                    guaranteeNewLine(node);
                    break;
                case 'ConditionalExpression':
                    if (_config.spaces.around.ternaryOperators && node.test) {
                        (function () {
                            var token = node.test.endToken;
                            // TODO 这样做到底安全不？
                            while (!(token.value === '?' && token.type === 'Punctuator')) {
                                token = token.next;
                            }
                            if (!isWhiteSpace(token.prev)) {
                                insertBefore(token, whiteSpaceFactory());
                            }
                            if (!isWhiteSpace(token.next)) {
                                insertAfter(token, whiteSpaceFactory());
                            }
                        })();
                    }
                    if (_config.spaces.around.ternaryOperators && node.consequent) {
                        (function () {
                            var token = node.consequent.endToken;
                            while (!(token.value === ':' && token.type === 'Punctuator')) {
                                token = token.next;
                            }
                            if (!isWhiteSpace(token.prev)) {
                                insertBefore(token, whiteSpaceFactory());
                            }
                            if (!isWhiteSpace(token.next)) {
                                insertAfter(token, whiteSpaceFactory());
                            }
                        })();
                    }
                    break;
                case 'ContinueStatement':
                    guaranteeNewLine(node);
                    break;
                case 'DoWhileStatement':
                    guaranteeNewLine(node);
                    if (node.body.type === 'BlockStatement') {
                        if (!isWhiteSpace(node.body.endToken.next)) {
                            _config.spaces.before.keywords && insertAfter(node.body.endToken, whiteSpaceFactory());
                        }
                    } else {
                        if (isWhiteSpace(node.startToken.next)) {
                            removeToken(node.startToken.next);
                        }
                        node.body.startToken.indentSelf = true;
                        if (!isWhiteSpace(node.test.startToken.prev.prev)) {
                            if (!isLineBreak(node.test.startToken.prev.prev.prev)) {
                                insertBefore(node.test.startToken.prev.prev, nextLineFactory());
                            }
                            insertBefore(node.test.startToken.prev, whiteSpaceFactory());
                        } else {
                            if (!isLineBreak(node.test.startToken.prev.prev.prev.prev)) {
                                insertBefore(node.test.startToken.prev.prev.prev, nextLineFactory());
                            }
                        }
                    }
                    break;
                case 'ForStatement':
                    guaranteeNewLine(node);
                    if (node.test && !isWhiteSpace(node.test.startToken.prev)) {
                        insertBefore(node.test.startToken, whiteSpaceFactory());
                    }
                    if (node.update && !isWhiteSpace(node.update.startToken.prev)) {
                        insertBefore(node.update.startToken, whiteSpaceFactory());
                    }
                    if (_config.spaces.within.parentheses) {
                        if (node.init && !isWhiteSpace(node.init.startToken.prev)) {
                            insertBefore(node.init.startToken, whiteSpaceFactory());
                        } else {}
                        if (node.update && !isWhiteSpace(node.update.endToken.next)) {
                            insertAfter(node.update.endToken, whiteSpaceFactory());
                        }
                    }
                    break;
                case 'ForInStatement':
                    guaranteeNewLine(node);
                    break;
                case 'VariableDeclaration':
                    if (node.parent.type !== 'ForStatement' && node.parent.type !== 'ForInStatement') {
                        guaranteeNewLine(node);
                    }
                    break;
                case 'VariableDeclarator':
                    if (node.endToken.next && node.endToken.next.type === 'Punctuator' && node.endToken.next.value === ',' && !isLineBreak(node.endToken.next.next)) {
                        insertAfter(node.endToken.next, whiteSpaceFactory());
                    }
                    break;
                case 'ExpressionStatement':
                    guaranteeNewLine(node);
                    break;
                case 'FunctionDeclaration':
                    guaranteeNewLine(node);
                    insertAfter(node.startToken, whiteSpaceFactory());
                    if (node.id) {
                        _config.spaces.before.functionDeclarationParentheses && insertAfter(node.id.endToken, whiteSpaceFactory());
                    }
                    node.params.forEach(function (param, i) {
                        if (i > 0) {
                            insertBefore(param.startToken, whiteSpaceFactory());
                        }
                    });
                    if (_config.spaces.within.parentheses && node.params.length > 0) {
                        if (!isWhiteSpace(node.params[0].startToken.prev)) {
                            insertBefore(node.params[0].startToken, whiteSpaceFactory());
                        }
                        if (!isWhiteSpace(node.params[node.params.length - 1].endToken.next)) {
                            insertAfter(node.params[node.params.length - 1].endToken, whiteSpaceFactory());
                        }
                    }
                    break;
                case 'IfStatement':
                    // 坑：if statement 的 consequent 和 alternate 都是有可能不存在的
                    if (node.parent.type !== 'IfStatement') {
                        guaranteeNewLine(node);
                    } else {
                        insertBefore(node.startToken, whiteSpaceFactory());
                    }
                    if (node.consequent && node.consequent.type !== 'BlockStatement') {
                        node.consequent.startToken.indentSelf = true;
                        if (node.alternate && node.consequent.endToken.next && !isLineBreak(node.consequent.endToken.next)) {
                            insertAfter(node.consequent.endToken, nextLineFactory());
                        }
                    } else {
                        if (node.alternate) {
                            _config.spaces.before.keywords && insertAfter(node.consequent.endToken, whiteSpaceFactory());
                        }
                    }
                    if (node.alternate && node.alternate.type !== 'BlockStatement' && node.alternate.type !== 'IfStatement') {
                        node.alternate.startToken.indentSelf = true;
                    }
                    if (_config.spaces.within.parentheses && node.test) {
                        if (!isWhiteSpace(node.test.startToken.prev)) {
                            insertBefore(node.test.startToken, whiteSpaceFactory());
                        }
                        if (!isWhiteSpace(node.test.endToken.next)) {
                            insertAfter(node.test.endToken, whiteSpaceFactory());
                        }
                    }
                    break;
                case 'ReturnStatement':
                    guaranteeNewLine(node);
                    break;
                case 'BlockStatement':
                    node.startToken.indentIncrease = true;
                    node.endToken.indentDecrease = true;
                    if (node.startToken.prev && !isWhiteSpace(node.startToken.prev) && !isLineBreak(node.startToken.prev)) {
                        _config.spaces.before.leftBrace && insertBefore(node.startToken, whiteSpaceFactory());
                    }
                    if (!isLineBreak(node.endToken.prev)) {
                        insertBefore(node.endToken, nextLineFactory());
                    }
                    break;
                case 'ObjectExpression':
                    if (!isTypeBetween(node.startToken, node.endToken, ['WhiteSpace', 'LineBreak'])) {
                        node.startToken.indentIncrease = true;
                        node.endToken.indentDecrease = true;
                        if (!isLineBreak(node.endToken.prev)) {
                            insertBefore(node.endToken, nextLineFactory());
                        }
                    }
                    break;
                case 'Property':
                    guaranteeNewLine(node);
                    if (_config.spaces.other.beforePropertyNameValueSeparator) {
                        !isWhiteSpace(node.key.endToken.next) && insertAfter(node.key.endToken, whiteSpaceFactory());
                    }
                    if (_config.spaces.other.afterPropertyNameValueSeparator) {
                        !isWhiteSpace(node.value.startToken.prev) && insertBefore(node.value.startToken, whiteSpaceFactory());
                    }
                    break;
                case 'CallExpression':
                    node.arguments.forEach(function (arg, i) {
                        if (i !== 0) {
                            insertBefore(arg.startToken, whiteSpaceFactory());
                        }
                    });
                    if (_config.spaces.within.parentheses && node.arguments.length > 0) {
                        if (!isWhiteSpace(node.arguments[0].startToken.prev)) {
                            insertBefore(node.arguments[0].startToken, whiteSpaceFactory());
                        }
                        if (!isWhiteSpace(node.arguments[node.arguments.length - 1].endToken.next)) {
                            insertAfter(node.arguments[node.arguments.length - 1].endToken, whiteSpaceFactory());
                        }
                    }
                    break;
                case 'FunctionExpression':
                    if (_config.spaces.before.functionExpressionParentheses || node.id) {
                        insertAfter(node.startToken, whiteSpaceFactory());
                    }
                    node.params.forEach(function (param, i, array) {
                        if (param.endToken.next && param.endToken.next.type === 'Punctuator' && param.endToken.next.value === ',') {
                            insertAfter(param.endToken.next, whiteSpaceFactory());
                        }
                    });
                    if (_config.spaces.within.parentheses && node.params.length > 0) {
                        if (!isWhiteSpace(node.params[0].startToken.prev)) {
                            insertBefore(node.params[0].startToken, whiteSpaceFactory());
                        }
                        if (!isWhiteSpace(node.params[node.params.length - 1].endToken.next)) {
                            insertAfter(node.params[node.params.length - 1].endToken, whiteSpaceFactory());
                        }
                    }
                    break;
                case 'SequenceExpression':
                    node.expressions.forEach(function (exp) {
                        if (exp.endToken.next && exp.endToken.next.type === 'Punctuator' && exp.endToken.next.value === ',') {
                            insertAfter(exp.endToken.next, whiteSpaceFactory());
                        }
                    });
                    break;
                case 'UnaryExpression':
                    if (['+', '-', '!'].indexOf(node.startToken.value) !== -1) {
                        if (node.startToken.next.type === 'WhiteSpace') {
                            removeToken(node.startToken.next);
                        }
                    }
                    if (node.operator === 'void') {
                        if (node.startToken.next.type !== 'WhiteSpace') {
                            insertAfter(node.startToken, whiteSpaceFactory());
                        }
                    }
                    break;
                case 'WhileStatement':
                    guaranteeNewLine(node);
                    if (_config.spaces.within.parentheses && node.test) {
                        if (!isWhiteSpace(node.test.startToken.prev)) {
                            insertBefore(node.test.startToken, whiteSpaceFactory());
                        }
                        if (!isWhiteSpace(node.test.endToken.next)) {
                            insertAfter(node.test.endToken, whiteSpaceFactory());
                        }
                    }
                    break;
                case 'SwitchStatement':
                    guaranteeNewLine(node);
                    node.discriminant.endToken.next.indentIncrease = true;
                    _config.spaces.before.leftBrace && insertAfter(node.discriminant.endToken.next, whiteSpaceFactory());
                    node.endToken.indentDecrease = true;
                    if (!isLineBreak(node.endToken.prev)) {
                        insertBefore(node.endToken, nextLineFactory());
                    }
                    if (_config.spaces.within.parentheses && node.discriminant) {
                        if (!isWhiteSpace(node.discriminant.startToken.prev)) {
                            insertBefore(node.discriminant.startToken, whiteSpaceFactory());
                        }
                        if (!isWhiteSpace(node.discriminant.endToken.next)) {
                            insertAfter(node.discriminant.endToken, whiteSpaceFactory());
                        }
                    }
                    break;
                case 'SwitchCase':
                    guaranteeNewLine(node);
                    node.startToken.indentIncrease = true;
                    node.endToken.indentDecrease = true;
                    break;
                case 'ThrowStatement':
                    guaranteeNewLine(node);
                    break;
                case 'TryStatement':
                    guaranteeNewLine(node);
                    break;
                case 'CatchClause':
                    if (_config.spaces.before.keywords && !isWhiteSpace(node.startToken.prev)) {
                        insertBefore(node.startToken, whiteSpaceFactory());
                    }
                    if (_config.spaces.within.parentheses && node.param) {
                        if (!isWhiteSpace(node.param.startToken.prev)) {
                            insertBefore(node.param.startToken, whiteSpaceFactory());
                        }
                        if (!isWhiteSpace(node.param.endToken.next)) {
                            insertAfter(node.param.endToken, whiteSpaceFactory());
                        }
                    }
                    break;
                case 'EmptyStatement':
                    guaranteeNewLine(node);
                    break;
                default:
                    break;
            }
        });

        // process indent start
        // 缩进这块要单独拿出来处理，不然很容易混乱
        var indentLevel = 0;
        var processIndent = function (token) {
            if (token.indentIncrease) {
                indentLevel++;
            }
            if (token.type === 'LineBreak') {
                if (token.next && !isWhiteSpace(token.next) && !isLineBreak(token.next)) {
                    // 如果下一个token是要减小缩进的，那它本身就是要减少缩进的
                    if (token.next.indentDecrease) {
                        indentLevel--;
                        token.next.indentDecrease = false;
                    }
                    insertAfter(token, indentFactory());
                }
            }
            if (token.indentDecrease) {
                indentLevel--;
            }
            if (token.indentSelf) {
                indentLevel++;
                insertBefore(token, singleIndentFactory());
                indentLevel--;
            }
        };
        token = _ast.startToken;
        while (token !== _ast.endToken.next) {
            processIndent(token);
            token = token.next;
        }
        // process indent end

        // 单独的处理注释的逻辑
        var processComment = function (token) {
            // 行尾注释保持跟前面的代码一个空格的距离
            if (isLineComment(token) && token.prev && !isWhiteSpace(token.prev)) {
                insertBefore(token, whiteSpaceFactory());
            }
        };
        token = _ast.startToken;
        while (token !== _ast.endToken.next) {
            processComment(token);
            token = token.next;
        }


        var formattedString = _ast.toString();
        if (_config.blankLines.atEndOfFile) {
            if (formattedString.charAt(formattedString.length - 1) !== _config.lineSeparator) {
                formattedString += _config.lineSeparator;
            }
        } else {
            formattedString = formattedString.trim();
        }
        return formattedString;
    }
174023
function (uri, fromUri, source) {
        if (!/^\./.test(uri) || EXTNAME_RE.test(uri)) {

            var line;

            // 如果只出现一次这个字符串，很容易确认模板错误行
            if (source.split(uri).length === 2) {
                source.split(/\n/).forEach(function (code, index) {
                    if (code.indexOf(uri) !== -1) {
                        line = index + 1;
                        source = code.trim();
                    }
                });
            }

            var error = {
                name: 'Syntax Error',
                line: line,
                source: source,
                message: 'Template must be a relative path, and can not have a suffix.'
            };

            if (fromUri) {
                error.filename = fromUri;
            }

            throw error;
        }
    }
418892
function attachConsole(options) {
    var appender = {
        type: 'console',
        layout: extend({}, options.layout)
    };

    if (appender.layout.type === 'pattern' && options.layout.pattern) {
        // 给终端的level加个颜色～
        appender.layout.pattern = options.layout.pattern.replace(/\[%p\]/g, '[%[%p%]]');
    }

    config.appenders.push(appender);
}
349579
function enhance(Component, ...args) {
	let oComp = new Component(...args);

	// 添加字段
	enhanceFields(oComp);	// 组件对象ID等

	// 添加方法
	enhanceRender(oComp);	// 组件渲染
	enhanceState(oComp);	// 组件状态存取
	enhanceRef(oComp);		// 按引用名取DOM节点或组件对象
	enhanceRoot(oComp);		// 取组件根节点DOM元素

	return oComp;
}
574121
function () {
        const editor = this.editor
        const $textElem = editor.$textElem

        $textElem.on('keydown', e => {
            if (e.keyCode !== 8) {
                return
            }
            const txtHtml = $textElem.html().toLowerCase().trim()
            if (txtHtml === '<p><br></p>') {
                // 最后剩下一个空行，就不再删除了
                e.preventDefault()
                return
            }
        })

        $textElem.on('keyup', e => {
            if (e.keyCode !== 8) {
                return
            }
            let $p
            const txtHtml = $textElem.html().toLowerCase().trim()

            // firefox 时用 txtHtml === '<br>' 判断，其他用 !txtHtml 判断
            if (!txtHtml || txtHtml === '<br>') {
                // 内容空了
                $p = $('<p><br/></p>')
                $textElem.html('') // 一定要先清空，否则在 firefox 下有问题
                $textElem.append($p)
                editor.selection.createRangeByElem($p, false, true)
                editor.selection.restoreSelection()
            }
        })

    }
167943
function (ctx) {
        var d = this.data;
        var x0, y0;
        var xi, yi;
        var x, y;
        var ux = this._ux;
        var uy = this._uy;
        var len = this._len;
        for (var i = 0; i < len;) {
            var cmd = d[i++];

            if (i === 1) {
                // 如果第一个命令是 L, C, Q
                // 则 previous point 同绘制命令的第一个 point
                //
                // 第一个命令为 Arc 的情况下会在后面特殊处理
                xi = d[i];
                yi = d[i + 1];

                x0 = xi;
                y0 = yi;
            }
            switch (cmd) {
                case CMD.M:
                    x0 = xi = d[i++];
                    y0 = yi = d[i++];
                    ctx.moveTo(xi, yi);
                    break;
                case CMD.L:
                    x = d[i++];
                    y = d[i++];
                    // Not draw too small seg between
                    if (mathAbs(x - xi) > ux || mathAbs(y - yi) > uy || i === len - 1) {
                        ctx.lineTo(x, y);
                        xi = x;
                        yi = y;
                    }
                    break;
                case CMD.C:
                    ctx.bezierCurveTo(
                        d[i++], d[i++], d[i++], d[i++], d[i++], d[i++]
                    );
                    xi = d[i - 2];
                    yi = d[i - 1];
                    break;
                case CMD.Q:
                    ctx.quadraticCurveTo(d[i++], d[i++], d[i++], d[i++]);
                    xi = d[i - 2];
                    yi = d[i - 1];
                    break;
                case CMD.A:
                    var cx = d[i++];
                    var cy = d[i++];
                    var rx = d[i++];
                    var ry = d[i++];
                    var theta = d[i++];
                    var dTheta = d[i++];
                    var psi = d[i++];
                    var fs = d[i++];
                    var r = (rx > ry) ? rx : ry;
                    var scaleX = (rx > ry) ? 1 : rx / ry;
                    var scaleY = (rx > ry) ? ry / rx : 1;
                    var isEllipse = Math.abs(rx - ry) > 1e-3;
                    var endAngle = theta + dTheta;
                    if (isEllipse) {
                        ctx.translate(cx, cy);
                        ctx.rotate(psi);
                        ctx.scale(scaleX, scaleY);
                        ctx.arc(0, 0, r, theta, endAngle, 1 - fs);
                        ctx.scale(1 / scaleX, 1 / scaleY);
                        ctx.rotate(-psi);
                        ctx.translate(-cx, -cy);
                    }
                    else {
                        ctx.arc(cx, cy, r, theta, endAngle, 1 - fs);
                    }

                    if (i === 1) {
                        // 直接使用 arc 命令
                        // 第一个命令起点还未定义
                        x0 = mathCos(theta) * rx + cx;
                        y0 = mathSin(theta) * ry + cy;
                    }
                    xi = mathCos(endAngle) * rx + cx;
                    yi = mathSin(endAngle) * ry + cy;
                    break;
                case CMD.R:
                    x0 = xi = d[i];
                    y0 = yi = d[i + 1];
                    ctx.rect(d[i++], d[i++], d[i++], d[i++]);
                    break;
                case CMD.Z:
                    ctx.closePath();
                    xi = x0;
                    yi = y0;
            }
        }
    }
42346
function (runtime, mod) {
            if (mod.status != LOADED) {
                return;
            }

            var fn = mod.fn;

            if (typeof fn === 'function') {
                // 需要解开 index，相对路径
                // 但是需要保留 alias，防止值不对应
                mod.value = fn.apply(mod, Utils.getModules(runtime, mod.getRequiresWithAlias()));
            } else {
                mod.value = fn;
            }

            mod.status = ATTACHED;
        }
512610
Expr assign() {
		Tok idTok = peek();
		if (idTok.sym != Sym.ID) {
			return ternary();
		}
		
		int begin = forward;
		// ID = expr
		if (move().sym == Sym.ASSIGN) {
			move();
			return new Assign(idTok.value(), expr(), location);
		}
		
		// array、map 赋值：ID [ expr ] = expr
		if (peek().sym == Sym.LBRACK) {
			move();
			Expr index = expr();
			match(Sym.RBRACK);
			if (peek().sym == Sym.ASSIGN) {
				move();
				return new Assign(idTok.value(), index, expr(), location);	// 右结合无限连
			}
		}
		
		resetForward(begin);
		return ternary();
	}
41743
function bind(from, node, comPrefix, valPrefix, clsPrefix, ignores) {
  ignores = Object.assign({
    true: true,
    false: true,
    null: true,
    undefined: true
  }, ignores);

  let hasPath = false;

  //处理节点属性
  let attributes = node.attributes;
  for (let i in attributes) {
    if (!/^\d+$/.test(i)) continue;
    let attr = attributes[i];

    //处理属性值
    if (attr.value.indexOf('{') > -1) {
      attr.value = replaceString(from, attr.value, valPrefix, ignores);
    }

    //绑定事件
    if (/^(bind|catch)\w+/.test(attr.name)) {
      node.setAttribute('data-' + attr.name, attr.value);
      attr.value = '_dispatch';
      if (!hasPath && comPrefix) {
        node.setAttribute('data-path', comPrefix);
      }
    }

    //如果是循环标签,则在子标签中忽略循环索引和值变量
    if (attr.name === 'wx:for') {
      let index = node.getAttribute('wx:for-index') || 'index';
      let item = node.getAttribute('wx:for-item') || 'item';
      ignores[index] = true;
      ignores[item] = true;
    }

    if (clsPrefix && attr.name === 'class') {
      const matchArr = [];
      // "xxx {{a ? 'b' : 'c'}}"
      // => "xxx $"
      attr.value = attr.value.replace(/\{\{([^}]+)\}\}/ig, function (match) {
        matchArr.push(match);
        matchArr.push(match);
        return '$';
      });

      // => "xxx prefix-xxx $ prefix-$"
      attr.value = attr.value.split(' ').map(cls => `${cls} ${clsPrefix}-${cls}`).join(' ');

      // => "xxx prefix-xxx {{a ? 'b' : 'c'}} prefix-{{a ? 'b' : 'c'}}"
      attr.value = attr.value.replace(/\$/g, function () {
        const matchItem = matchArr.shift();
        return matchItem;
      });
    }
  }

  //如果节点为文本
  if (node.nodeName === '#text') {
    let data = node.data;
    if (data) {
      node.replaceData(0, data.length, replaceString(from, data, valPrefix, ignores));
    }
  }

  //递归处理子节点
  for (let i in node.childNodes) {
    if (!/^\d+$/.test(i)) continue;
    let n = node.childNodes[i];
    // 不转换template 定义
    if (n.nodeName === 'template' && n.getAttribute('name')) {
      bindTemplateEvents(n);
      continue;
    }
    bind(from, n, comPrefix, valPrefix, clsPrefix, ignores);
  }
}
1092341
protected function writeCurve() 
    {        
        $px = $py = 0;
        
        // 曲线前部分
        $A = mt_rand(1, $this->cfg['height']/2);                  // 振幅
        $b = mt_rand(-$this->cfg['height']/4, $this->cfg['height']/4);   // Y轴方向偏移量
        $f = mt_rand(-$this->cfg['height']/4, $this->cfg['height']/4);   // X轴方向偏移量
        $T = mt_rand($this->cfg['height'], $this->cfg['width']*2);      // 周期
        $w = (2* M_PI)/$T;
                        
        $px1 = 0;  // 曲线横坐标起始位置
        $px2 = mt_rand($this->cfg['width']/2, $this->cfg['width'] * 0.8);  // 曲线横坐标结束位置

        for ($px = $px1; $px <= $px2; $px ++) {
            if ($w == 0) {
                break;
            }
            
            $py = $A * sin($w*$px + $f)+ $b + $this->cfg['height']/2;  // y = Asin(ωx+φ) + b
            $i = (int) ($this->cfg['fontSize']/6);
            while ($i > 0) {    
                imagesetpixel($this->image, $px, $py + $i, $this->color);  // 这里(while)循环画像素点比imagettftext和imagestring用字体大小一次画出（不用这while循环）性能要好很多                    
                $i--;
            }
        }
        
        // 曲线后部分
        $A = mt_rand(1, $this->cfg['height']/2);                  // 振幅        
        $f = mt_rand(-$this->cfg['height']/4, $this->cfg['height']/4);   // X轴方向偏移量
        $T = mt_rand($this->cfg['height'], $this->cfg['width']*2);      // 周期
        $w = (2* M_PI)/$T;        
        $b = $py - $A * sin($w*$px + $f) - $this->cfg['height']/2;
        $px1 = $px2;
        $px2 = $this->cfg['width'];

        for ($px = $px1; $px <= $px2; $px ++) {
            if ($w == 0) {
                break;
            }
            
            $py = $A * sin($w*$px + $f)+ $b + $this->cfg['height']/2;  // y = Asin(ωx+φ) + b
            $i = (int) ($this->cfg['fontSize']/6);
            while ($i > 0) {            
                imagesetpixel($this->image, $px, $py + $i, $this->color);
                $i--;
            }
        }
    }
1189743
function(){
      var src = this.installArray.shift(); 

      if(typeof src !== 'undefined'){
        var parts = src.split('/'); 
        var resourcePath = this.getResourcePath(parts[parts.length-2]); 
        var dest = this.basePath + resourcePath + '/' + parts[parts.length-1]; 
        
        if(typeof resourcePath !== 'undefined'){
          this._install(src, dest); 
        }else{
          this.triggerNext(); 
        }
         
      }else{
        this.log('all done, get ready to rock!  (╯°□°）╯︵ ┻━┻');
        rl.close(); 
      }
    }
1146428
function removeFormpart(TPL,ctx)
{
    let files = ctx.files;
    for(let f in files) {
        fs.unlink(files[f].path, (err)=> {
            err && TPL.params[f] && console.error('删除文件失败', files[f])
        });//异步清除临时目录中的上传文件
    }
}
1195883
function initText(elem, parsed, extra){
  var param = extra.param;
  var throttle, lazy = param.lazy

  if('throttle' in param){
    // <input throttle r-model>
    if(param.throttle === true){
      throttle = 400;
    }else{
      throttle = parseInt(param.throttle, 10)
    }
  }

  var self = this;
  var wc = this.$watch(parsed, function(newValue){
    if(elem.value !== newValue) elem.value = newValue == null? "": "" + newValue;
  }, STABLE);

  // @TODO to fixed event
  var isCompositing = false;
  var handler = function (ev){

    if(isCompositing) return;

    isCompositing = false;

    var that = this;
    if(ev.type==='cut' || ev.type==='paste'){
      _.nextTick(function(){
        var value = that.value
        parsed.set(self, value);
        wc.last = value;
        self.$update();
      })
    }else{
        var value = that.value
        parsed.set(self, value);
        wc.last = value;
        self.$update();
    }
  };

  function onCompositionStart(){
    isCompositing = true;
  }

  function onCompositionEnd(ev){
    isCompositing = false;
    handler.call(this,ev)
  }

  if(throttle && !lazy){
    var preHandle = handler, tid;
    handler = _.throttle(handler, throttle);
  }

  if(hasInput === undefined){
    hasInput = dom.msie !== 9 && "oninput" in document.createElement('input')
  }

  if(lazy){
    dom.on(elem, 'change', handler)
  }else{

    if(typeof CompositionEvent === 'function' ){ //lazy的情况不需要compositionend
      elem.addEventListener("compositionstart", onCompositionStart );
      elem.addEventListener("compositionend", onCompositionEnd );
    }

    if( hasInput){
      elem.addEventListener("input", handler );
    }else{
      dom.on(elem, "paste keyup cut change", handler)
    }
  }
  if(parsed.get(self) === undefined && elem.value){
     parsed.set(self, elem.value);
  }
  return function (){
    if(lazy) return dom.off(elem, "change", handler);
    if( hasInput ){
      elem.removeEventListener("input", handler );
    }else{
      dom.off(elem, "paste keyup cut change", handler)
    }
  }
}
1264017
private void buildNode(Node parent, List<String>[] sequence, int from, List<Node> leaf){
        //递归退出条件：二维数组遍历完毕
        if(from >= sequence.length){
            //记住叶子节点
            leaf.add(parent);
            return;
        }
        for(String item : sequence[from]){
            Node child = new Node(item, parent);
            buildNode(child, sequence, from+item.length(), leaf);
        }
    }
362958
function () {
        var me = this
        var options = me._options
        me.loading = false
        if (me.direction == 'up') {

          fnTransition(options.domUp.dom, 300)
          options.domUp.dom.style.height = '0px'
          options.domUp.loadEndCall()
          // 下拉刷新后，加载更多的数据状态需要更新

        } else {
        }
        if (me.isData) {
          // 加载区修改样式
          options.domDown.initialCall()
        } else {
          // 如果没数据
          options.domDown.domNoData()
        }
      }
323830
function(ctx, frame, cb) {
                // ... 如果是 .render(function () {})
                if (typeof ctx === 'function') {
                    cb = ctx;
                    ctx = {};
                } 
                // ...? 什么场景使用了frame
                else if (typeof frame === 'function') {
                    cb = frame;
                    frame = null;
                }

                return lib.withPrettyErrors(this.path, this.env.dev, function() {
                    // debugger;
                    this.compile();

                    // ... 当前作用域不是简单的Object对象，是Context类的实例，并且整合了blocks对象
                    // ...todo 整合了blocks对象的情景分析
                    var context = new Context(ctx || {}, this.blocks);
                    var syncResult = null;

                    frame = frame || new Frame()

                    this.rootRenderFunc(this.env, context, frame, runtime, cb || function(err, res) {
                        if (err) {
                            throw err;
                        }
                        syncResult = res;
                    });

                    return syncResult;
                }.bind(this));
            }