How to use the @ngrx/store-devtools/schematics-core/utility/ast-utils.insertAfterLastOccurrence function in @ngrx/store-devtools

To help you get started, we’ve selected a few @ngrx/store-devtools examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github ngrx / store-devtools-builds / schematics-core / utility / route-utils.js View on Github external
return new change_1.NoopChange();
        }
        // no such import declaration exists
        var useStrict = ast_utils_1.findNodes(rootNode, ts.SyntaxKind.StringLiteral).filter(function (n) { return n.getText() === 'use strict'; });
        var fallbackPos = 0;
        if (useStrict.length > 0) {
            fallbackPos = useStrict[0].end;
        }
        var open = isDefault ? '' : '{ ';
        var close = isDefault ? '' : ' }';
        // if there are no imports or 'use strict' statement, insert import at beginning of file
        var insertAtBeginning = allImports.length === 0 && useStrict.length === 0;
        var separator = insertAtBeginning ? '' : ';\n';
        var toInsert = separator + "import " + open + symbolName + close +
            (" from '" + fileName + "'" + (insertAtBeginning ? ';\n' : ''));
        return ast_utils_1.insertAfterLastOccurrence(allImports, toInsert, fileToEdit, fallbackPos, ts.SyntaxKind.StringLiteral);
    }
    exports.insertImport = insertImport;
github ngrx / store-devtools-builds / schematics-core / utility / route-utils.js View on Github external
relevantImports.forEach(function (n) {
                Array.prototype.push.apply(imports_1, ast_utils_1.findNodes(n, ts.SyntaxKind.Identifier));
                if (ast_utils_1.findNodes(n, ts.SyntaxKind.AsteriskToken).length > 0) {
                    importsAsterisk_1 = true;
                }
            });
            // if imports * from fileName, don't add symbolName
            if (importsAsterisk_1) {
                return new change_1.NoopChange();
            }
            var importTextNodes = imports_1.filter(function (n) { return n.text === symbolName; });
            // insert import if it's not there
            if (importTextNodes.length === 0) {
                var fallbackPos_1 = ast_utils_1.findNodes(relevantImports[0], ts.SyntaxKind.CloseBraceToken)[0].getStart() ||
                    ast_utils_1.findNodes(relevantImports[0], ts.SyntaxKind.FromKeyword)[0].getStart();
                return ast_utils_1.insertAfterLastOccurrence(imports_1, ", " + symbolName, fileToEdit, fallbackPos_1);
            }
            return new change_1.NoopChange();
        }
        // no such import declaration exists
        var useStrict = ast_utils_1.findNodes(rootNode, ts.SyntaxKind.StringLiteral).filter(function (n) { return n.getText() === 'use strict'; });
        var fallbackPos = 0;
        if (useStrict.length > 0) {
            fallbackPos = useStrict[0].end;
        }
        var open = isDefault ? '' : '{ ';
        var close = isDefault ? '' : ' }';
        // if there are no imports or 'use strict' statement, insert import at beginning of file
        var insertAtBeginning = allImports.length === 0 && useStrict.length === 0;
        var separator = insertAtBeginning ? '' : ';\n';
        var toInsert = separator + "import " + open + symbolName + close +
            (" from '" + fileName + "'" + (insertAtBeginning ? ';\n' : ''));