/* 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; using Microsoft.VisualStudio.Language.Intellisense; using Microsoft.VisualStudio.Text; namespace dnSpy.Contracts.Language.Intellisense { /// /// Signature help classifier context. Use /// to get the instance. /// public class SignatureHelpClassifierContext { /// /// Gets the type, eg. /// public string Type { get; } /// /// Gets the signature help session /// public ISignatureHelpSession Session { get; } /// /// Constructor /// /// Context type, eg. /// Signature help session protected internal SignatureHelpClassifierContext(string type, ISignatureHelpSession session) { Type = type ?? throw new ArgumentNullException(nameof(type)); Session = session ?? throw new ArgumentNullException(nameof(session)); } } /// /// Signature documentation signature help classifier context /// public sealed class SignatureDocumentationSignatureHelpClassifierContext : SignatureHelpClassifierContext { /// /// Gets the signature to classify /// public ISignature Signature { get; } /// /// Constructor /// /// Signature help session /// Signature to classify public SignatureDocumentationSignatureHelpClassifierContext(ISignatureHelpSession session, ISignature signature) : base(SignatureHelpClassifierContextTypes.SignatureDocumentation, session) => Signature = signature ?? throw new ArgumentNullException(nameof(signature)); } /// /// Parameter name signature help classifier context /// public sealed class ParameterNameSignatureHelpClassifierContext : SignatureHelpClassifierContext { /// /// Gets the parameter to classify /// public IParameter Parameter { get; } /// /// Gets the offset of in the text buffer. /// public int NameOffset { get; } /// /// Constructor /// /// Signature help session /// Parameter to classify /// Offset of in the text buffer public ParameterNameSignatureHelpClassifierContext(ISignatureHelpSession session, IParameter parameter, int nameOffset) : base(SignatureHelpClassifierContextTypes.ParameterName, session) { if (nameOffset < 0) throw new ArgumentOutOfRangeException(nameof(nameOffset)); Parameter = parameter ?? throw new ArgumentNullException(nameof(parameter)); NameOffset = nameOffset; } } /// /// Parameter documentation signature help classifier context /// public sealed class ParameterDocumentationSignatureHelpClassifierContext : SignatureHelpClassifierContext { /// /// Gets the parameter to classify /// public IParameter Parameter { get; } /// /// Constructor /// /// Signature help session /// Parameter to classify public ParameterDocumentationSignatureHelpClassifierContext(ISignatureHelpSession session, IParameter parameter) : base(SignatureHelpClassifierContextTypes.ParameterDocumentation, session) => Parameter = parameter ?? throw new ArgumentNullException(nameof(parameter)); } /// /// Signature help context types (see ) /// public static class SignatureHelpClassifierContextTypes { /// /// Signature documentation /// public static readonly string SignatureDocumentation = nameof(SignatureDocumentation); /// /// Parameter name /// public static readonly string ParameterName = nameof(ParameterName); /// /// Parameter documentation /// public static readonly string ParameterDocumentation = nameof(ParameterDocumentation); } }