How to use the @angular/compiler.DomElementSchemaRegistry function in @angular/compiler

To help you get started, we’ve selected a few @angular/compiler 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 angular / angular / packages / language-service / src / typescript_host.ts View on Github external
getTemplateAst(template: TemplateSource): AstResult|undefined {
    const {type: classSymbol, fileName} = template;
    const data = this.resolver.getNonNormalizedDirectiveMetadata(classSymbol);
    if (!data) {
      return;
    }
    const htmlParser = new I18NHtmlParser(new HtmlParser());
    const expressionParser = new Parser(new Lexer());
    const parser = new TemplateParser(
        new CompilerConfig(), this.reflector, expressionParser, new DomElementSchemaRegistry(),
        htmlParser,
        null !,  // console
        []       // tranforms
        );
    const htmlResult = htmlParser.parse(template.source, fileName, {
      tokenizeExpansionForms: true,
      preserveLineEndings: true,  // do not convert CRLF to LF
    });
    const {directives, pipes, schemas} = this.getModuleMetadataForDirective(classSymbol);
    const parseResult = parser.tryParseHtml(htmlResult, data.metadata, directives, pipes, schemas);
    if (!parseResult.templateAst) {
      return;
    }
    return {
      htmlAst: htmlResult.rootNodes,
      templateAst: parseResult.templateAst,
github johandb / svg-drawing-tool / node_modules / @angular / language-service / src / language_service.js View on Github external
LanguageServiceImpl.prototype.getTemplateAst = function (template, contextFile) {
            var _this = this;
            var result = undefined;
            try {
                var resolvedMetadata = this.metadataResolver.getNonNormalizedDirectiveMetadata(template.type);
                var metadata = resolvedMetadata && resolvedMetadata.metadata;
                if (metadata) {
                    var rawHtmlParser = new compiler_1.HtmlParser();
                    var htmlParser = new compiler_1.I18NHtmlParser(rawHtmlParser);
                    var expressionParser = new compiler_1.Parser(new compiler_1.Lexer());
                    var config = new compiler_1.CompilerConfig();
                    var parser = new compiler_1.TemplateParser(config, this.host.resolver.getReflector(), expressionParser, new compiler_1.DomElementSchemaRegistry(), htmlParser, null, []);
                    var htmlResult = htmlParser.parse(template.source, '', true);
                    var analyzedModules = this.host.getAnalyzedModules();
                    var errors = undefined;
                    var ngModule = analyzedModules.ngModuleByPipeOrDirective.get(template.type);
                    if (!ngModule) {
                        // Reported by the the declaration diagnostics.
                        ngModule = findSuitableDefaultModule(analyzedModules);
                    }
                    if (ngModule) {
                        var resolvedDirectives = ngModule.transitiveModule.directives.map(function (d) { return _this.host.resolver.getNonNormalizedDirectiveMetadata(d.reference); });
                        var directives = removeMissing(resolvedDirectives).map(function (d) { return d.metadata.toSummary(); });
                        var pipes = ngModule.transitiveModule.pipes.map(function (p) { return _this.host.resolver.getOrLoadPipeMetadata(p.reference).toSummary(); });
                        var schemas = ngModule.schemas;
                        var parseResult = parser.tryParseHtml(htmlResult, metadata, directives, pipes, schemas);
                        result = {
                            htmlAst: htmlResult.rootNodes,
github angular / angular / modules / @angular / language-service / src / language_service.ts View on Github external
getTemplateAst(template: TemplateSource, contextFile: string): AstResult {
    let result: AstResult;
    try {
      const resolvedMetadata =
          this.metadataResolver.getNonNormalizedDirectiveMetadata(template.type as any);
      const metadata = resolvedMetadata && resolvedMetadata.metadata;
      if (metadata) {
        const rawHtmlParser = new HtmlParser();
        const htmlParser = new I18NHtmlParser(rawHtmlParser);
        const expressionParser = new Parser(new Lexer());
        const config = new CompilerConfig();
        const parser = new TemplateParser(
            config, expressionParser, new DomElementSchemaRegistry(), htmlParser, null, []);
        const htmlResult = htmlParser.parse(template.source, '');
        const analyzedModules = this.host.getAnalyzedModules();
        let errors: Diagnostic[] = undefined;
        let ngModule = analyzedModules.ngModuleByPipeOrDirective.get(template.type);
        if (!ngModule) {
          // Reported by the the declaration diagnostics.
          ngModule = findSuitableDefaultModule(analyzedModules);
        }
        if (ngModule) {
          const resolvedDirectives = ngModule.transitiveModule.directives.map(
              d => this.host.resolver.getNonNormalizedDirectiveMetadata(d.reference));
          const directives =
              resolvedDirectives.filter(d => d !== null).map(d => d.metadata.toSummary());
          const pipes = ngModule.transitiveModule.pipes.map(
              p => this.host.resolver.getOrLoadPipeMetadata(p.reference).toSummary());
          const schemas = ngModule.schemas;
github albertnadal / ng2-daterange-picker / node_modules / @angular / platform-server / @angular / platform-server.js View on Github external
constructor(ngZone, document, sharedStylesHost) {
        this.ngZone = ngZone;
        this.document = document;
        this.sharedStylesHost = sharedStylesHost;
        this.rendererByCompId = new Map();
        this.schema = new DomElementSchemaRegistry();
        this.defaultRenderer = new DefaultServerRenderer2(document, ngZone, this.schema);
    }
    /**
github albertnadal / ng2-daterange-picker / node_modules / @angular / platform-server / @angular / platform-server.es5.js View on Github external
function ServerRendererFactory2(ngZone, document, sharedStylesHost) {
        this.ngZone = ngZone;
        this.document = document;
        this.sharedStylesHost = sharedStylesHost;
        this.rendererByCompId = new Map();
        this.schema = new DomElementSchemaRegistry();
        this.defaultRenderer = new DefaultServerRenderer2(document, ngZone, this.schema);
    }
    /**
github mgechev / codelyzer / src / angular / templates / templateParser.ts View on Github external
export const parseTemplate = (template: string, directives: DirectiveDeclaration[] = []) => {
  defaultDirectives = directives.map(d => dummyMetadataFactory(d));

  const TemplateParser = compiler.TemplateParser as any;
  const expressionParser = new compiler.Parser(new compiler.Lexer());
  const elementSchemaRegistry = new compiler.DomElementSchemaRegistry();
  const ngConsole = new Console();
  const htmlParser = new compiler.HtmlParser();

  let tmplParser: any;

  SemVerDSL.gte('4.0.0-beta.8', () => {
    const config = new compiler.CompilerConfig({});
    tmplParser = new TemplateParser(config, expressionParser, elementSchemaRegistry, htmlParser, ngConsole, []);
  })
    .elseIf.lt('4.1.0', () => {
      tmplParser = new TemplateParser(expressionParser, elementSchemaRegistry, htmlParser, ngConsole, []);
    })
    .elseIf.lt('5.0.0-rc.0', () => {
      const config = new compiler.CompilerConfig({});
      tmplParser = new TemplateParser(
        config,
github mgechev / ngast / lib / project-symbols.ts View on Github external
defaultEncapsulation: ViewEncapsulation.Emulated,
      useJit: false
    });
    this.pipeResolver = new PipeResolver(this.reflector);
    this.directiveResolver = new DirectiveResolver(this.reflector);
    this.directiveNormalizer = new DirectiveNormalizer(
      {
        get: (url) => {
          return this.staticResolverHost.loadResource(url);
        }
      },
      this.urlResolver,
      htmlParser,
      config
    );
    const registry = new DomElementSchemaRegistry();
    this.metadataResolver = new CompileMetadataResolver(
      config,
      htmlParser,
      new NgModuleResolver(this.reflector),
      this.directiveResolver,
      this.pipeResolver,
      this.summaryResolver,
      registry,
      this.directiveNormalizer,
      console,
      symbolCache,
      this.reflector
    );
    const viewCompiler = new ViewCompiler(this.reflector);
    const typeCheckCompiler = new TypeCheckCompiler(options, this.reflector);
    var expressionParser = new Parser(new Lexer());
github mgechev / codelyzer / docs / dist / src / angular / templates / templateParser.js View on Github external
exports.parseTemplate = function (template, directives) {
    if (directives === void 0) { directives = []; }
    defaultDirectives = directives.map(function (d) { return dummyMetadataFactory(d); });
    var TemplateParser = compiler.TemplateParser;
    var expressionParser = new compiler.Parser(new compiler.Lexer());
    var elementSchemaRegistry = new compiler.DomElementSchemaRegistry();
    var ngConsole = new Console();
    var htmlParser = new compiler.I18NHtmlParser(new compiler.HtmlParser());
    var tmplParser;
    ngVersion_1.SemVerDSL
        .gte('4.0.0-beta.8', function () {
        var config = new compiler.CompilerConfig({});
        tmplParser =
            new TemplateParser(config, expressionParser, elementSchemaRegistry, htmlParser, ngConsole, []);
    })
        .elseIf.lt('4.1.0', function () {
        tmplParser =
            new TemplateParser(expressionParser, elementSchemaRegistry, htmlParser, ngConsole, []);
    }).else(function () {
        var config = new compiler.CompilerConfig({});
        tmplParser =
            new TemplateParser(config, new compiler.JitReflector(), expressionParser, elementSchemaRegistry, htmlParser, ngConsole, []);
github johandb / svg-drawing-tool / node_modules / @angular / compiler-cli / src / ngtsc / annotations / src / component.js View on Github external
function ComponentDecoratorHandler(checker, reflector, scopeRegistry, isCore, resourceLoader, rootDirs, defaultPreserveWhitespaces, i18nUseExternalIds) {
            this.checker = checker;
            this.reflector = reflector;
            this.scopeRegistry = scopeRegistry;
            this.isCore = isCore;
            this.resourceLoader = resourceLoader;
            this.rootDirs = rootDirs;
            this.defaultPreserveWhitespaces = defaultPreserveWhitespaces;
            this.i18nUseExternalIds = i18nUseExternalIds;
            this.literalCache = new Map();
            this.elementSchemaRegistry = new compiler_1.DomElementSchemaRegistry();
        }
        ComponentDecoratorHandler.prototype.detect = function (node, decorators) {