public void ProcessBeforeInterior(ITreeNode element) { AppendRemainingMessage(element); if (!(element is IT4IncludeDirective include)) return; var file = (IT4File) element.GetContainingFile().NotNull(); Results.Push(new T4CSharpCodeGenerationIntermediateResult(file, Interrupter)); var sourceFile = IncludeResolver.Resolve(include.ResolvedPath); if (sourceFile == null) { var target = include.GetFirstAttribute(T4DirectiveInfoManager.Include.FileAttribute)?.Value ?? element; var data = T4FailureRawData.FromElement(target, $"Unresolved include: {target.GetText()}"); Interrupter.InterruptAfterProblem(data); Guard.StartProcessing(file.LogicalPsiSourceFile.GetLocation()); return; } if (include.Once && Guard.HasSeenFile(sourceFile.GetLocation())) return; if (!Guard.CanProcess(sourceFile.GetLocation())) { var target = include.GetFirstAttribute(T4DirectiveInfoManager.Include.FileAttribute)?.Value ?? element; var data = T4FailureRawData.FromElement(target, "Recursion in includes"); Interrupter.InterruptAfterProblem(data); Guard.StartProcessing(sourceFile.GetLocation()); return; } var resolved = include.IncludedFile; Guard.StartProcessing(sourceFile.GetLocation()); resolved?.ProcessDescendants(this); }
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)); }
public override void VisitIncludeDirectiveNode(IT4IncludeDirective includeDirectiveParam) { string suffix = Result.State.ProduceBeforeEof(); if (!string.IsNullOrEmpty(suffix)) AppendTransformation(suffix, Result.State.FirstNode); Guard.TryEndProcessing(IncludeResolver.Resolve(includeDirectiveParam.ResolvedPath).GetLocation()); var intermediateResults = Results.Pop(); Result.Append(intermediateResults); }
private void ProcessInclude([NotNull] IT4IncludeDirective include) { var sourceFile = IncludeResolver.Resolve(include.ResolvedPath); if (sourceFile == null) { ReportUnresolvedPath(include); return; } if (!Guard.CanProcess(sourceFile.GetLocation())) { return; } if (include.Once && Guard.HasSeenFile(sourceFile.GetLocation())) { ReportRedundantInclude(include); } }