예제 #1
0
        private CompositeElement ResolveIncludeDirective([NotNull] IT4IncludeDirective directive)
        {
            if (LogicalSourceFile == null)
            {
                return(null);
            }
            var pathWithMacros = directive.ResolvedPath;
            var path           = IncludeResolver?.ResolvePath(pathWithMacros);

            if (path == null)
            {
                return(null);
            }
            var includeFile = T4ParsingContextHelper.ExecuteGuarded(
                path,
                directive.Once,
                () => IncludeResolver?.Resolve(pathWithMacros)
                );

            if (includeFile == null)
            {
                return(null);
            }
            return(BuildIncludedT4Tree(includeFile));
        }
예제 #2
0
 private File ParseFileWithoutCleanup()
 {
     using (Context.RegisterNextLayer(LogicalSourceFile.ToProjectFile()))
     {
         return(T4ParsingContextHelper.ExecuteGuarded(
                    LogicalSourceFile.GetLocation(),
                    false,
                    () =>
         {
             var file = (File)ParseFileInternal();
             T4MissingTokenInserter.Run(file, OriginalLexer, this, null);
             if (LogicalSourceFile != null)
             {
                 file.LogicalPsiSourceFile = LogicalSourceFile;
             }
             if (!CanResolveMacros)
             {
                 return file;
             }
             ResolveMacros(file);
             ResolveIncludes(file);
             return file;
         }
                    ).NotNull("Attempted to parse same file recursively twice"));
     }
 }
예제 #3
0
        public override TreeElement ParseFile()
        {
            var result = ParseFileWithoutCleanup();

            result.SetSourceFile(PhysicalSourceFile);
            T4ParsingContextHelper.Reset();
            return(result);
        }
예제 #4
0
        private CompositeElement ResolveIncludeDirective([NotNull] IncludeDirective directive)
        {
            var sourceFile = LogicalSourceFile;

            if (sourceFile == null)
            {
                return(null);
            }
            var pathWithMacros = directive.GetPathForParsing(sourceFile);
            var path           = pathWithMacros.ResolvePath();
            var includeFile    =
                T4ParsingContextHelper.ExecuteGuarded(path, directive.Once, () => pathWithMacros.Resolve());

            if (includeFile == null)
            {
                return(null);
            }
            return(BuildIncludedT4Tree(includeFile));
        }