Example #1
0
 public T4RiderSyntaxHighlightingHost(
     Lifetime lifetime,
     [NotNull] ILogger logger,
     [NotNull] T4OutputExtensionFrontendNotifier notifier,
     [NotNull] ISolution solution,
     [NotNull] IPsiCachesState state,
     [NotNull] IPsiFiles files,
     [NotNull] RiderDocumentHost host
     )
 {
     Logger   = logger;
     Notifier = notifier;
     Solution = solution;
     State    = state;
     Files    = files;
     Host     = host;
     host.ViewHostDocuments(lifetime, CreateHandler);
 }
 public T4HostOutputFileRefresher(ISolution solution, [NotNull] RiderDocumentHost host) : base(solution) =>
Example #3
0
        public ShaderContextHost(Lifetime lifetime, ISolution solution, IPsiFiles psiFiles,
                                 CppGlobalSymbolCache cppGlobalSymbolCache,
                                 ShaderContextCache shaderContextCache,
                                 ShaderContextDataPresentationCache shaderContextDataPresentationCache, ILogger logger,
                                 [CanBeNull] FrontendBackendHost frontendBackendHost = null,
                                 [CanBeNull] RiderDocumentHost documentHost          = null)
        {
            mySolution             = solution;
            myPsiFiles             = psiFiles;
            myCppGlobalSymbolCache = cppGlobalSymbolCache;
            myDocumentHost         = documentHost;
            myShaderContextCache   = shaderContextCache;
            myShaderContextDataPresentationCache = shaderContextDataPresentationCache;

            if (frontendBackendHost == null || documentHost == null)
            {
                return;
            }

            frontendBackendHost.Do(t =>
            {
                t.RequestShaderContexts.Set((lt, id) =>
                {
                    logger.Verbose("Requesting all shader context for file");
                    using (ReadLockCookie.Create())
                    {
                        var sourceFile = GetSourceFile(id);
                        if (sourceFile == null)
                        {
                            return(Rd.Tasks.RdTask <List <ShaderContextDataBase> > .Successful(
                                       new List <ShaderContextDataBase>()));
                        }
                        var task = new Rd.Tasks.RdTask <List <ShaderContextDataBase> >();
                        RequestShaderContexts(lt, sourceFile, task);

                        return(task);
                    }
                });

                t.ChangeContext.Advise(lifetime, c =>
                {
                    logger.Verbose("Setting new shader context for file");
                    using (ReadLockCookie.Create())
                    {
                        IPsiSourceFile sourceFile = GetSourceFile(c.Target);
                        if (sourceFile == null)
                        {
                            return;
                        }

                        var cppFileLocation = new CppFileLocation(
                            new FileSystemPathWithRange(FileSystemPath.Parse(c.Path), new TextRange(c.Start, c.End)));
                        shaderContextCache.SetContext(sourceFile, cppFileLocation);
                    }
                });

                t.SetAutoShaderContext.Advise(lifetime, id =>
                {
                    using (ReadLockCookie.Create())
                    {
                        IPsiSourceFile sourceFile = GetSourceFile(id);
                        if (sourceFile == null)
                        {
                            return;
                        }
                        shaderContextCache.SetContext(sourceFile, null);
                    }
                });

                t.RequestCurrentContext.Set((lt, id) =>
                {
                    logger.Verbose("Setting current context for file");
                    using (ReadLockCookie.Create())
                    {
                        var sourceFile = GetSourceFile(id);
                        if (sourceFile == null)
                        {
                            return(Rd.Tasks.RdTask <ShaderContextDataBase> .Successful(new AutoShaderContextData()));
                        }

                        var task = new Rd.Tasks.RdTask <ShaderContextDataBase>();
                        RequestCurrentContext(lt, sourceFile, task);
                        return(task);
                    }
                });
            });
        }