コード例 #1
0
        /// <summary>
        /// Create a new CodeLens instance around a given editor session
        /// from the component registry.
        /// </summary>
        /// <param name="components">
        /// The component registry to provider other components and to register the CodeLens provider in.
        /// </param>
        /// <param name="editorSession">The editor session context of the CodeLens provider.</param>
        /// <returns>A new CodeLens provider for the given editor session.</returns>
        public static CodeLensFeature Create(
            IComponentRegistry components,
            EditorSession editorSession)
        {
            var codeLenses =
                new CodeLensFeature(
                    editorSession,
                    JsonSerializer.Create(Constants.JsonSerializerSettings),
                    components.Get <ILogger>());

            var messageHandlers = components.Get <IMessageHandlers>();

            messageHandlers.SetRequestHandler(
                CodeLensRequest.Type,
                codeLenses.HandleCodeLensRequest);

            messageHandlers.SetRequestHandler(
                CodeLensResolveRequest.Type,
                codeLenses.HandleCodeLensResolveRequest);

            codeLenses.Providers.Add(
                new ReferencesCodeLensProvider(
                    editorSession));

            codeLenses.Providers.Add(
                new PesterCodeLensProvider(
                    editorSession));

            editorSession.Components.Register <ICodeLenses>(codeLenses);

            return(codeLenses);
        }
コード例 #2
0
        public static CodeLensFeature Create(
            IComponentRegistry components,
            EditorSession editorSession)
        {
            var codeLenses =
                new CodeLensFeature(
                    editorSession,
                    components.Get <IMessageHandlers>(),
                    components.Get <ILogger>());

            codeLenses.Providers.Add(
                new ReferencesCodeLensProvider(
                    editorSession));

            codeLenses.Providers.Add(
                new PesterCodeLensProvider(
                    editorSession));

            editorSession.Components.Register <ICodeLenses>(codeLenses);

            return(codeLenses);
        }