/* Copyright (C) 2014-2019 de4dot@gmail.com This file is part of dnSpy dnSpy is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. dnSpy is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with dnSpy. If not, see . */ using System.Diagnostics; using Microsoft.VisualStudio.Language.Intellisense; using Microsoft.VisualStudio.Text; using Microsoft.VisualStudio.Utilities; namespace dnSpy.Contracts.Language.Intellisense { /// /// Signature help constants /// public static class SignatureHelpConstants { /// /// Suffix added to the current signature's content type name () /// to get the name of the content type for the signature help text. /// This content type is created if it doesn't exist. /// public const string SignatureHelpContentTypeSuffix = " Signature Help"; /// /// Suffix added to the current signature's content type name () /// to get the name of the content type for the signature help documentation and parameter text and /// documentation. /// This feature is only enabled if this content type has been defined, it's not created by /// the signature help code. The classifier should use /// to get the information it needs. /// /// /// is used by VS and dnSpy supports it but it can't /// be extended to also support other text. /// public const string ExtendedSignatureHelpContentTypeSuffix = " Signature Help Ex"; /// /// property key of a that indicates whether /// the pretty printed content should be used ( /// vs and vs /// ) /// public const string UsePrettyPrintedContentBufferKey = "UsePrettyPrintedContent"; /// /// property key to get the instance. /// It's used by the signature help classifiers to get the session to classify. /// public static readonly object SessionBufferKey = typeof(ISignatureHelpSession); /// /// property key to get the instance. /// public static readonly object SignatureHelpClassifierContextBufferKey = typeof(SignatureHelpClassifierContext); /// /// Returns the signature help session or null if is not a signature help buffer /// /// Text buffer /// public static ISignatureHelpSession? TryGetSignatureHelpSession(this ITextBuffer buffer) { if (buffer.Properties.TryGetProperty(SessionBufferKey, out ISignatureHelpSession session)) return session; return null; } /// /// Gets the UsePrettyPrintedContent value /// /// Signature help text buffer /// public static bool GetUsePrettyPrintedContent(this ITextBuffer buffer) { if (buffer.Properties.TryGetProperty(UsePrettyPrintedContentBufferKey, out bool usePrettyPrintedContent)) return usePrettyPrintedContent; Debug.Fail(nameof(UsePrettyPrintedContentBufferKey) + " hasn't been initialized yet"); return false; } /// /// Returns the signature help classifier context or null if is not a signature help buffer /// /// Text buffer /// public static SignatureHelpClassifierContext? TryGetSignatureHelpClassifierContext(this ITextBuffer buffer) { if (buffer.Properties.TryGetProperty(SignatureHelpClassifierContextBufferKey, out SignatureHelpClassifierContext context)) return context; return null; } } }