private List <FileSystemPath> ExtractReferenceLocations([NotNull] IT4File file) { file.AssertContainsNoIncludeContext(); var directives = file.GetThisAndIncludedFilesRecursive() .SelectMany(it => it.Blocks) .OfType <IT4AssemblyDirective>(); var errors = new FrugalLocalList <T4FailureRawData>(); var directDependencies = directives.SelectNotNull( directive => { var resolved = AssemblyReferenceResolver.Resolve(directive); if (resolved == null) { errors.Add(CreateError(directive)); } return(resolved); } ).AsList(); if (!errors.IsEmpty) { throw new T4OutputGenerationException(errors); } AddBaseReferences(directDependencies, file); return(directDependencies); }
public IEnumerable <T4AssemblyReferenceInfo> ExtractReferenceLocationsTransitive(IT4File file) { file.AssertContainsNoIncludeContext(); var sourceFile = file.PhysicalPsiSourceFile.NotNull(); var projectFile = sourceFile.ToProjectFile().NotNull(); var directives = file.GetThisAndIncludedFilesRecursive() .SelectMany(it => it.Blocks) .OfType <IT4AssemblyDirective>(); var errors = new FrugalLocalList <T4FailureRawData>(); var directDependencies = directives.SelectNotNull( directive => { var resolved = AssemblyReferenceResolver.Resolve(directive); if (resolved == null) { errors.Add(T4FailureRawData.FromElement(directive, "Unresolved assembly reference")); } return(resolved); } ).AsList(); if (!errors.IsEmpty) { throw new T4OutputGenerationException(errors); } AddBaseReferences(directDependencies, file); return(LowLevelReferenceExtractionManager.ResolveTransitiveDependencies( directDependencies, projectFile.SelectResolveContext() )); }
public T4CSharpExecutableIntermediateConverter( [NotNull] IT4File file, [NotNull] IT4ReferenceExtractionManager referenceExtractionManager ) : base(file, new T4ExecutableClassNameProvider()) { file.AssertContainsNoIncludeContext(); ReferenceExtractionManager = referenceExtractionManager; }
public T4CSharpExecutableIntermediateConverter( [NotNull] T4CSharpCodeGenerationIntermediateResult intermediateResult, [NotNull] IT4File file, [NotNull] IT4ReferenceExtractionManager referenceExtractionManager ) : base(intermediateResult, file) { file.AssertContainsNoIncludeContext(); ReferenceExtractionManager = referenceExtractionManager; }
public static T4CSharpCodeGenerationResult GeneratePreprocessedCode([NotNull] IT4File file) { var solution = file.GetSolution(); var collector = new T4CSharpPreprocessedCodeGenerationInfoCollector(solution); file.AssertContainsNoIncludeContext(); var nameProvider = new T4PreprocessedClassNameProvider(file.PhysicalPsiSourceFile.NotNull()); var converter = new T4CSharpRealIntermediateConverter(file, nameProvider); return(converter.Convert(collector.Collect(file))); }
public static string GetEncoding([NotNull] IT4File file) { file.AssertContainsNoIncludeContext(); var sourceFile = file.PhysicalPsiSourceFile; if (sourceFile == null) { return(Encoding.UTF8.CodePage.ToString()); } return(sourceFile.Document.Encoding.CodePage.ToString()); }
public IEnumerable <IProject> GetProjectDependencies(IT4File file) { file.AssertContainsNoIncludeContext(); var sourceFile = file.LogicalPsiSourceFile.NotNull(); var projectFile = sourceFile.ToProjectFile().NotNull(); var psiModule = sourceFile.PsiModule; var resolveContext = projectFile.SelectResolveContext(); using (CompilationContextCookie.GetOrCreate(resolveContext)) { return(PsiModules .GetModuleReferences(psiModule) .Select(it => it.Module) .OfType <IProjectPsiModule>() .Select(it => it.Project) .AsList()); } }