/// <summary>
        /// Creates image list and image monikers for project icons.
        /// Must be called on UI thread.
        /// </summary>
        public static void LoadProjectImages()
        {
            if (_monikerImageList == null)
            {
                IVsImageService2 imageService = VisualRustPackage.GetGlobalService(typeof(SVsImageService)) as IVsImageService2;

                if (_imageList == null)
                {
                    _imageList = new ImageList();
                }

                _imageList.Images.Add(Resources.RustProjectNode);
                _imageList.Images.Add(Resources.RustFileNode);
                _imageList.Images.Add(Resources.CargoManifestNode);

                _monikerImageList = imageService.CreateMonikerImageListFromHIMAGELIST(_imageList.Handle);
                imageService.AddCustomImageList(_monikerImageList);

                ImageMoniker[] monikers = new ImageMoniker[3];
                _monikerImageList.GetImageMonikers(0, 3, monikers);

                ProjectNodeImage       = monikers[0];
                RustFileNodeImage      = monikers[1];
                CargoManifestNodeImage = monikers[2];
            }
        }
Beispiel #2
0
        private void ReinitializeRacerPaths()
        {
            DTE env = (DTE)VisualRustPackage.GetGlobalService(typeof(DTE));

            // If path to racer.exe is specifed, use it
            if (GetVisualRustProperty <bool>(env, nameof(RustOptionsPage.UseCustomRacer)))
            {
                racerPathForExecution = GetVisualRustProperty <string>(env, nameof(RustOptionsPage.CustomRacerPath));
            }
            else
            {
                racerPathForExecution = Path.Combine(Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location), "Racer", BundledRacerExecutable);
            }
            // Same for custom RUST_SRC_PATH
            var type = GetVisualRustProperty <RustOptionsPage.RustSource>(env, nameof(RustOptionsPage.SourceType));

            switch (type)
            {
            case RustOptionsPage.RustSource.EnvVariable:
                racerSourcesLocation = null;
                break;

            case RustOptionsPage.RustSource.Custom:
                racerSourcesLocation = GetVisualRustProperty <string>(env, nameof(RustOptionsPage.CustomSourcesPath));
                break;

            default:
                racerSourcesLocation = GetRustcSysroot();
                if (racerSourcesLocation != null && !Directory.Exists(racerSourcesLocation))
                {
                    racerSourcesLocation = null;
                }
                break;
            }
        }
Beispiel #3
0
        public static IVsPackage EnsurePackageLoaded(Guid guidPackage)
        {
            var        shell = (IVsShell)VisualRustPackage.GetGlobalService(typeof(IVsShell));
            var        guid  = guidPackage;
            IVsPackage package;
            int        hr = ErrorHandler.ThrowOnFailure(shell.IsPackageLoaded(ref guid, out package), VSConstants.E_FAIL);

            guid = guidPackage;
            if (hr != VSConstants.S_OK)
            {
                ErrorHandler.ThrowOnFailure(shell.LoadPackage(ref guid, out package), VSConstants.E_FAIL);
            }

            return(package);
        }
Beispiel #4
0
        public async Task <DebugLaunchSettings> GetLaunchSettingsAsync(string executable, string arguments, string workingDirectory,
                                                                       DebugLaunchOptions options, Cargo cargo, TargetTriple triple)
        {
            EnvDTE.DTE env    = (EnvDTE.DTE)VisualRustPackage.GetGlobalService(typeof(EnvDTE.DTE));
            var        target = new DebugLaunchSettings(options)
            {
                LaunchOperation       = DebugLaunchOperation.CreateProcess,
                LaunchDebugEngineGuid = MIDebugEngineGuid,
                Executable            = executable,
                Arguments             = arguments,
                CurrentDirectory      = workingDirectory,
                Options = ToXmlString(await BuildLaunchOptionsAsync(executable, arguments, workingDirectory, env, cargo, triple))
            };

            return(target);
        }
Beispiel #5
0
        private void ReinitializeRacerPaths()
        {
            DTE env = (DTE)VisualRustPackage.GetGlobalService(typeof(DTE));

            // If path to racer.exe is specifed, use it
            if (GetVisualRustProperty <bool>(env, nameof(RustOptionsPage.UseCustomRacer)))
            {
                racerPathForExecution = GetVisualRustProperty <string>(env, nameof(RustOptionsPage.CustomRacerPath));
            }
            else
            {
                racerPathForExecution = Path.Combine(Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location), "Racer", BundledRacerExecutable);
            }
            // Same for custom RUST_SRC_PATH
            if (GetVisualRustProperty <bool>(env, nameof(RustOptionsPage.UseCustomSources)))
            {
                racerSourcesLocation = GetVisualRustProperty <string>(env, nameof(RustOptionsPage.CustomSourcesPath));
            }
            else
            {
                racerSourcesLocation = null;
            }
        }