Example #1
0
        private void ResolveMacros([NotNull] IT4File file)
        {
            var context           = Context.MostSuitableProjectFile.NotNull();
            var logicalSourceFile = LogicalSourceFile.NotNull();
            var macros            = new List <string>();

            foreach (var directive in file.BlocksEnumerable.OfType <IT4DirectiveWithPath>())
            {
                macros.AddRange(directive.RawMacros);
            }

            IReadOnlyDictionary <string, string> resolvedMacros;

            if (macros.IsEmpty())
            {
                resolvedMacros = EmptyDictionary <string, string> .Instance;
            }
            else
            {
                resolvedMacros = MacroResolver.NotNull().ResolveHeavyMacros(macros, context);
            }
            foreach (var directive in file.BlocksEnumerable.OfType <IT4DirectiveWithPath>())
            {
                directive.InitializeResolvedPath(resolvedMacros, logicalSourceFile, context);
            }
        }
Example #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"));
     }
 }