Пример #1
0
        private void AddFile([NotNull] IProjectFile projectFile, [NotNull] PsiModuleChangeBuilder changeBuilder)
        {
            ISolution solution = projectFile.GetSolution();

            // creates a new T4PsiModule for the file
            LifetimeDefinition lifetimeDefinition = Lifetimes.Define(_lifetime, "[T4]" + projectFile.Name);
            var psiModule = new T4PsiModule(
                lifetimeDefinition.Lifetime,
                solution.GetComponent <PsiModuleManager>(),
                solution.GetComponent <DocumentManager>(),
                _changeManager,
                solution.GetComponent <IAssemblyFactory>(),
                _shellLocks,
                projectFile,
                solution.GetComponent <T4FileDataCache>(),
                _t4Environment,
                solution.GetComponent <OutputAssembliesCache>());

            _modules[projectFile] = new ModuleWrapper(psiModule, lifetimeDefinition);
            changeBuilder.AddModuleChange(psiModule, PsiModuleChange.ChangeType.ADDED);
            changeBuilder.AddFileChange(psiModule.SourceFile, PsiModuleChange.ChangeType.ADDED);

            // Invalidate files that had this specific files as an include,
            // and whose IPsiSourceFile was previously managed by T4OutsideSolutionSourceFileManager.
            // Those files will be reparsed with the new source file.
            var            fileManager = solution.GetComponent <T4OutsideSolutionSourceFileManager>();
            FileSystemPath location    = projectFile.Location;

            if (fileManager.HasSourceFile(location))
            {
                fileManager.DeleteSourceFile(location);
                InvalidateFilesHavingInclude(location, solution.GetPsiServices());
            }
        }
Пример #2
0
 private T4TreeBuilder([NotNull] T4Environment t4Environment, [NotNull] DirectiveInfoManager directiveInfoManager, [NotNull] ILexer lexer,
     [CanBeNull] IPsiSourceFile sourceFile, [NotNull] HashSet<FileSystemPath> existingIncludePaths, [CanBeNull] ISolution solution,
     [CanBeNull] T4PsiModule macroResolveModule)
 {
     _t4Environment = t4Environment;
     _directiveInfoManager = directiveInfoManager;
     _builderLexer = new PsiBuilderLexer(lexer, tnt => tnt.IsWhitespace);
     _existingIncludePaths = existingIncludePaths;
     _sourceFile = sourceFile;
     _solution = solution;
     _macroResolveModule = macroResolveModule;
 }
Пример #3
0
        internal static string ResolveMacros([NotNull] string stringWithMacros, [CanBeNull] T4PsiModule t4PsiModule)
        {
            if (String.IsNullOrEmpty(stringWithMacros) ||
                t4PsiModule == null ||
                stringWithMacros.IndexOf("$(", StringComparison.Ordinal) < 0)
            {
                return(stringWithMacros);
            }

            IDictionary <string, string> macroValues = t4PsiModule.GetResolvedMacros();

            if (macroValues.Count == 0)
            {
                return(stringWithMacros);
            }

            return(ReplaceMacros(stringWithMacros, macroValues));
        }
Пример #4
0
 internal ModuleWrapper([NotNull] T4PsiModule module, [NotNull] LifetimeDefinition lifetimeDefinition)
 {
     Module             = module;
     LifetimeDefinition = lifetimeDefinition;
 }
Пример #5
0
 internal ModuleWrapper([NotNull] T4PsiModule module, [NotNull] LifetimeDefinition lifetimeDefinition)
 {
     Module = module;
     LifetimeDefinition = lifetimeDefinition;
 }
Пример #6
0
        private void AddFile([NotNull] IProjectFile projectFile, [NotNull] PsiModuleChangeBuilder changeBuilder)
        {
            ISolution solution = projectFile.GetSolution();

            // creates a new T4PsiModule for the file
            LifetimeDefinition lifetimeDefinition = Lifetimes.Define(_lifetime, "[T4]" + projectFile.Name);
            var psiModule = new T4PsiModule(
                lifetimeDefinition.Lifetime,
                solution.GetComponent<IPsiModules>(),
                solution.GetComponent<DocumentManager>(),
                _changeManager,
                solution.GetComponent<IAssemblyFactory>(),
                _shellLocks,
                projectFile,
                solution.GetComponent<T4FileDataCache>(),
                _t4Environment,
                solution.GetComponent<OutputAssemblies>());
            _modules[projectFile] = new ModuleWrapper(psiModule, lifetimeDefinition);
            changeBuilder.AddModuleChange(psiModule, PsiModuleChange.ChangeType.Added);
            changeBuilder.AddFileChange(psiModule.SourceFile, PsiModuleChange.ChangeType.Added);

            // Invalidate files that had this specific files as an include,
            // and whose IPsiSourceFile was previously managed by T4OutsideSolutionSourceFileManager.
            // Those files will be reparsed with the new source file.
            var fileManager = solution.GetComponent<T4OutsideSolutionSourceFileManager>();
            FileSystemPath location = projectFile.Location;
            if (fileManager.HasSourceFile(location)) {
                fileManager.DeleteSourceFile(location);
                InvalidateFilesHavingInclude(location, solution.GetPsiServices());
            }
        }