public CppInclusionContextResult CreateInclusionContextResult(CppGlobalSymbolCache cache, CppFileLocation rootFile, FileProcessingOptions options, long cacheVersion, Lifetime lifetime) { var locationTracker = cache.Solution.GetComponent <ShaderLabCppFileLocationTracker>(); if (!locationTracker.IsValid(rootFile)) { return(CppInclusionContextResult.Fail(CppInclusionContextResult.Status.UNSUITABLE_PROJECT_FILE)); } var properties = new CppCompilationProperties() { LanguageKind = CppLanguageKind.HLSL, ClrSupport = VCXCompileAsManagedOptions.ManagedNotSet, }; var cgIncludeFolder = CgIncludeDirectoryTracker.GetCgIncludeFolderPath(cache.Solution.GetComponent <UnityVersion>()); if (!cgIncludeFolder.IsEmpty) { properties.IncludePaths.Add(cgIncludeFolder); } var shaderCache = cache.Solution.GetComponent <ShaderLabCppFileLocationTracker>(); // TODO 1) is cache ready? what will happen under document transaction? check for bad moment? // TODO 2) what will happen under psi transaction? include in cache could be out-of date. Try use include quickfix when cginclude is after cgprogram where QF is used var includeLocation = shaderCache.GetIncludes(rootFile); return(InjectInclusionContextProviderUtil.CreateInclusionContextResult(cache, rootFile, includeLocation, options, properties, null, cacheVersion, lifetime)); }
public CppInclusionContextResult CreateInclusionContextResult(CppGlobalSymbolCache cache, CppFileLocation rootFile, FileProcessingOptions options, long cacheVersion, Lifetime lifetime) { var locationTracker = cache.Solution.GetComponent <InjectedHlslFileLocationTracker>(); if (!locationTracker.IsValid(rootFile)) { return(CppInclusionContextResult.Fail(CppInclusionContextResult.Status.UNSUITABLE_PROJECT_FILE)); } var properties = new CppCompilationProperties() { LanguageKind = CppLanguageKind.HLSL, ClrSupport = VCXCompileAsManagedOptions.ManagedNotSet, }; var cgIncludeFolder = CgIncludeDirectoryTracker.GetCgIncludeFolderPath(cache.Solution.GetComponent <UnityVersion>()); if (!cgIncludeFolder.IsEmpty) { properties.IncludePaths.Add(cgIncludeFolder); } properties.IncludePaths.Add(cache.Solution.SolutionDirectory); return(CreateInclusionContextResult(cache, rootFile, options, properties, null, cacheVersion, lifetime)); }
public static CppInclusionContextResult CreateInclusionContextResult( CppGlobalSymbolCache cache, CppFileLocation rootFile, IEnumerable <CppFileLocation> includeLocations, FileProcessingOptions options, CppCompilationProperties compilationProperties, ISymbolScope symbolScope, long cacheVersion, Lifetime lifetime) { var languageDialect = CppProjectConfigurationUtil.GetLanguageDialect(compilationProperties); var randomProjectFile = rootFile.GetRandomProjectFile(cache.Solution); var inclusionContext = CppRootInclusionContext.Create(compilationProperties, randomProjectFile.GetProject(), randomProjectFile, cache, rootFile, options.File, languageDialect, cacheVersion, options.AllowPendingActions, options.CollectPPUsages, lifetime, symbolScope); var directory = randomProjectFile.Location.Directory; inclusionContext.ProcessDefine(CppPPDefineSymbol.ParsePredefinedMacro("SHADER_API_D3D11")); inclusionContext.ProcessDefine(CppPPDefineSymbol.ParsePredefinedMacro("__RESHARPER__")); inclusionContext.ProcessDefine(CppPPDefineSymbol.ParsePredefinedMacro("INTERNAL_DATA= ")); inclusionContext.ProcessDefine(CppPPDefineSymbol.ParsePredefinedMacro("WorldReflectionVector(data,normal)=data.worldRefl")); inclusionContext.ProcessDefine(CppPPDefineSymbol.ParsePredefinedMacro("WorldNormalVector(data,normal)=normal")); inclusionContext.PushInclude(rootFile, directory, false); foreach (CppFileLocation includeLocation in includeLocations) { if (includeLocation.IsValid() && !includeLocation.Equals(rootFile)) { cache.LookupAndProcessTableForFile(rootFile, includeLocation, options, inclusionContext, directory); } } inclusionContext.PopInclude(false); return(CppInclusionContextResult.Ok(inclusionContext)); }
public static CppInclusionContextResult CreateInclusionContextResult( CppGlobalSymbolCache cache, CppFileLocation rootFile, FileProcessingOptions options, CppCompilationProperties compilationProperties, ISymbolScope symbolScope, long cacheVersion, Lifetime lifetime) { var languageDialect = CppProjectConfigurationUtil.GetLanguageDialect(compilationProperties); var randomProjectFile = rootFile.GetRandomProjectFile(cache.Solution); var inclusionContext = CppRootInclusionContext.Create(compilationProperties, randomProjectFile.GetProject(), randomProjectFile, cache, rootFile, options.File, languageDialect, cacheVersion, options.AllowPendingActions, options.CollectPPUsages, lifetime, symbolScope); var directory = randomProjectFile.Location.Directory; var shaderCache = cache.Solution.GetComponent <InjectedHlslFileLocationTracker>(); var(includes, defines) = shaderCache.GetProgramInfo(rootFile); inclusionContext.ProcessDefine(CppPPDefineSymbol.ParsePredefinedMacro("SHADER_API_D3D11")); inclusionContext.ProcessDefine(CppPPDefineSymbol.ParsePredefinedMacro("__RESHARPER__")); inclusionContext.ProcessDefine(CppPPDefineSymbol.ParsePredefinedMacro("INTERNAL_DATA= ")); inclusionContext.ProcessDefine(CppPPDefineSymbol.ParsePredefinedMacro("WorldReflectionVector(data,normal)=data.worldRefl")); inclusionContext.ProcessDefine(CppPPDefineSymbol.ParsePredefinedMacro("WorldNormalVector(data,normal)=normal")); foreach (var define in defines) { inclusionContext.ProcessDefine(CppPPDefineSymbol.ParsePredefinedMacro($"{define.Key}={define.Value}")); } // TODO 1) is cache ready? what will happen under document transaction? check for bad moment? // TODO 2) what will happen under psi transaction? include in cache could be out-of date. Try use include quickfix when cginclude is after cgprogram where QF is used inclusionContext.PushInclude(rootFile, directory, false); foreach (CppFileLocation includeLocation in includes) { if (includeLocation.IsValid() && !includeLocation.Equals(rootFile)) { cache.LookupAndProcessTableForFile(rootFile, includeLocation, options, inclusionContext, directory); } } inclusionContext.PopInclude(false); return(CppInclusionContextResult.Ok(inclusionContext)); }
public CppCompilationProperties GetCompilationProperties(IProject project, IProjectFile projectFile, CppFileLocation rootFile, CppGlobalSymbolCache globalCache) { if (project.IsUnityProject() && CppProjectFileType.ALL_HLSL_EXTENSIONS.Contains(rootFile.Location.ExtensionWithDot)) { var properties = new CppCompilationProperties(); properties.LanguageKind = CppLanguageKind.HLSL; var path = CgIncludeDirectoryTracker.GetCgIncludeFolderPath(myUnityVersion); if (!path.IsEmpty) { properties.IncludePaths.Add(path); } return(properties); } return(null); }
public CppCompilationProperties GetCompilationProperties(IProject project, IProjectFile projectFile, CppFileLocation rootFile, CppGlobalSymbolCache globalCache) { if (project.IsUnityProject() && CppProjectFileType.ALL_HLSL_EXTENSIONS.Contains(rootFile.Location.ExtensionWithDot)) { var properties = new CppCompilationProperties(); properties.LanguageKind = CppLanguageKind.HLSL; var path = CgIncludeDirectoryTracker.GetCgIncludeFolderPath(myUnityVersion); if (!path.IsEmpty) { properties.IncludePaths.Add(path); } properties.ForcedIncludes.Add(globalCache.Solution.SolutionDirectory.Combine(Utils.ShaderConfigFile).FullPath); properties.PredefinedMacros.Add(CppPPDefineSymbol.ParsePredefinedMacro("SHADER_API_D3D11")); properties.IncludePaths.Add(globalCache.Solution.SolutionDirectory); return(properties); } return(null); }
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); } }); }); }
public EditorNavigator(CppGlobalSymbolCache cppSymbolNameCache, IPsiServices psiServices) { _cppSymbolNameCache = cppSymbolNameCache; _psiServices = psiServices; }