How to use ngast - 10 common examples

To help you get started, we’ve selected a few ngast 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 irustm / ng-app-counter / src / counter.ts View on Github external
` ${count1 ? chalk.default.blue(count1) : ''}` +
        ` ${count2 ? '/ ' + chalk.default.yellowBright(count2) : ''}`
    );
  };

  let projectPath = (minimist(process.argv.slice(2)) as any).p;
  if (!projectPath) {
    projectPath = './tsconfig.json';
  }
  if (!existsSync(projectPath)) {
    error('Cannot find tsconfig at "' + projectPath + '".');
    process.exit(1);
  }
  console.log('Parsing...');
  let parseError: any = null;
  const projectSymbols = new ProjectSymbols(
    projectPath,
    resourceResolver,
    e => (parseError = e)
  );

  const allModules: ModuleSymbol[] = projectSymbols.getModules();
  const allPipes: PipeSymbol[] = projectSymbols.getPipes();
  const allProviders: ProviderSymbol[] = projectSymbols.getProviders();
  const allDirectives: DirectiveSymbol[] = projectSymbols.getDirectives();
  const treeMod = new ModuleTree();

  if (!parseError) {
    console.log('');
    console.log('Results:');
    console.log('');
    // Count modules
github compodoc / ngd / src / modules / compiler / src / compiler / ngast.ts View on Github external
getDependencies(): Dependencies[] {
    const contextSymbols = new ContextSymbols(this.program, this.resourceResolver);
    // console.log('getModules::', contextSymbols.getModules().pop());
    fs.writeFileSync(
      './xxxxxxxxx.json', 
      JSON.stringify(contextSymbols.getContextSummary() /*.map( d => d._symbol.name )*/, null, 2)
    );

    // @todo we should return this type
    // {
    //   name,
    //   file: srcFile.fileName.split('/').splice(-3).join('/'),
    //   providers: this.getModuleProviders(props),
    //   declarations: this.getModuleDeclations(props),
    //   imports: this.getModuleImports(props),
    //   exports: this.getModuleExports(props),
    //   bootstrap: this.getModuleBootstrap(props),
    //   __raw: props
github compodoc / ngd / src / modules / compiler / dist / compiler / ngast.js View on Github external
NgAst.prototype.getDependencies = function () {
        var contextSymbols = new ngast_1.ContextSymbols(this.program, this.resourceResolver);
        // console.log('getModules::', contextSymbols.getModules().pop());
        fs.writeFileSync('./xxxxxxxxx.json', JSON.stringify(contextSymbols.getContextSummary() /*.map( d => d._symbol.name )*/, null, 2));
        // @todo we should return this type
        // {
        //   name,
        //   file: srcFile.fileName.split('/').splice(-3).join('/'),
        //   providers: this.getModuleProviders(props),
        //   declarations: this.getModuleDeclations(props),
        //   imports: this.getModuleImports(props),
        //   exports: this.getModuleExports(props),
        //   bootstrap: this.getModuleBootstrap(props),
        //   __raw: props
        // };
        return [];
    };
    NgAst.prototype.getFileName = function (contextSymbols) {
github mgechev / ngworld / parser / index.ts View on Github external
export const parse = (projectPath: string) => {
  const project = new ProjectSymbols(
    createProgramFromTsConfig(projectPath),
    {
      getSync: (path: string) => readFileSync(path).toString(),
      get: (path: string) =>
        new Promise((resolve, reject) =>
          readFile(path, (error, content) => (error ? reject(error) : resolve(content.toString())))
        )
    },
    (error: string, path: string) => console.error(error, path)
  );

  return formatContext(project);
};
github mgechev / ngrev / app / processor.js View on Github external
Project.prototype.load = function (tsconfig, reporter) {
        this.projectSymbols = new ngast.ProjectSymbols(tsconfig, {
            get: function (name) {
                return new Promise(function (resolve, reject) {
                    fs.readFile(name, function (e, data) {
                        if (e)
                            reject(e);
                        else
                            resolve(data.toString());
                    });
                });
            },
            getSync: function (name) {
                return fs.readFileSync(name, { encoding: 'utf-8' });
            }
        }, reporter);
        return Promise.resolve(this.projectSymbols);
    };
github mgechev / ngrev / src / background / model / project.ts View on Github external
load(tsconfig: string, reporter: ErrorReporter) {
    this.projectSymbols = new ProjectSymbols(
      tsconfig,
      {
        get(name: string) {
          return new Promise((resolve: any, reject: any) => {
            readFile(name, (e, data) => {
              if (e) reject(e);
              else resolve(data.toString());
            });
          });
        },
        getSync(name: string) {
          return readFileSync(name, { encoding: 'utf-8' });
        }
      },
      reporter
    );
github mgechev / ngrev / app / processor.js View on Github external
TemplateState.prototype.getMetadata = function (id) {
        var s = this.symbols[id];
        if (s) {
            if (s instanceof _angular_compiler.ElementAst) {
                return getElementMetadata(s);
            }
            else if (s instanceof ngast.DirectiveSymbol) {
                return getDirectiveMetadata(s);
            }
        }
        return null;
    };
    TemplateState.prototype.nextState = function (id) {
github mgechev / ngrev / app / processor.js View on Github external
ModuleState.prototype.nextState = function (nodeId) {
        if (nodeId === this.symbolId) {
            return null;
        }
        var data = this.symbols[nodeId].data;
        if (!data) {
            return null;
        }
        if (data.symbol instanceof ngast.DirectiveSymbol) {
            return new DirectiveState(this.context, data.symbol);
        }
        else if (data.symbol instanceof ngast.ProviderSymbol) {
            return new ProviderState(this.context, data.symbol);
        }
        else if (data.symbol instanceof ngast.PipeSymbol) {
            return new PipeState(this.context, data.symbol);
        }
        return null;
    };
    ModuleState.prototype.getData = function () {
github mgechev / ngrev / app / processor.js View on Github external
ModuleState.prototype.getMetadata = function (id) {
        var data = this.symbols[id].data;
        if (!data) {
            return null;
        }
        if (data.symbol instanceof ngast.DirectiveSymbol) {
            return getDirectiveMetadata(data.symbol);
        }
        else if (data.symbol instanceof ngast.ProviderSymbol) {
            return getProviderMetadata(data.symbol);
        }
        else if (data.symbol instanceof ngast.PipeSymbol) {
            return getPipeMetadata(data.symbol);
        }
        return null;
    };
    ModuleState.prototype.nextState = function (nodeId) {
github mgechev / ngrev / app / processor.js View on Github external
id = getProviderId(node.getMetadata());
            name = getProviderName(node.getMetadata());
        }
        else {
            id = getId(node.symbol);
            name = node.symbol.name;
        }
        nodes[id] = {
            id: id,
            label: name,
            data: {
                symbol: node,
                metadata: null
            },
            type: {
                angular: node instanceof ngast.Symbol ? isAngularSymbol(node.symbol) : isAngularSymbol(node.getMetadata()),
                type: symbolType
            }
        };
        edges.push({
            from: parentSet,
            to: id
        });
    };
    return ModuleState;

ngast

Parsing tools for Angular. The project is an abstraction over the Angular compiler which provides friendly interface.

MIT
Latest version published 4 years ago

Package Health Score

54 / 100
Full package analysis