private CodeLens GetModuleReference(ParsedModule module, ISourceFile spec) { var moduleVersion = string.IsNullOrEmpty(module.Descriptor.Version) ? null : $" (version: {module.Descriptor.Version})"; // Ideally we want to navigate to the module declaration, but unfortunately we don't keep proper track of that. // Therefore we do a quick file existence check, try to find the common name and then fall back to the current spec file. var moduleConfigFile = module.Definition.ModuleConfigFile.ToString(PathTable); if (!File.Exists(moduleConfigFile)) { moduleConfigFile = Path.Combine(Path.GetDirectoryName(moduleConfigFile), "module.config.dsc"); } else if (!File.Exists(moduleConfigFile)) { // Fall back to the current spec.... moduleConfigFile = spec.FileName; } return (new CodeLens { Range = spec.ToRange(), Command = new Command { Title = FormattableStringEx.I($"Module: {module.Descriptor.Name}{moduleVersion} - {module.Definition.Root.ToString(PathTable)}"), CommandIdentifier = "DScript.openDocument", Arguments = new object[] { UriExtensions.GetUriFromPath(moduleConfigFile) }, }, }); }