/*
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.Collections.Immutable;
using Microsoft.CodeAnalysis;
using Microsoft.CodeAnalysis.Text;
namespace dnSpy.Roslyn.Internal.QuickInfo {
abstract class QuickInfoContent {
public abstract string Type { get; }
}
sealed class InformationQuickInfoContent : QuickInfoContent {
public override string Type => PredefinedQuickInfoContentTypes.Information;
public Glyph? SymbolGlyph { get; }
public Glyph? WarningGlyph { get; }
public ImmutableArray MainDescription { get; }
public ImmutableArray Documentation { get; }
public ImmutableArray TypeParameterMap { get; }
public ImmutableArray AnonymousTypes { get; }
public ImmutableArray UsageText { get; }
public ImmutableArray ExceptionText { get; }
public InformationQuickInfoContent(Glyph? symbolGlyph, Glyph? warningGlyph, ImmutableArray mainDescription, ImmutableArray documentation, ImmutableArray typeParameterMap, ImmutableArray anonymousTypes, ImmutableArray usageText, ImmutableArray exceptionText) {
SymbolGlyph = symbolGlyph;
WarningGlyph = warningGlyph;
MainDescription = mainDescription.IsDefault ? ImmutableArray.Empty : mainDescription;
Documentation = documentation.IsDefault ? ImmutableArray.Empty : documentation;
TypeParameterMap = typeParameterMap.IsDefault ? ImmutableArray.Empty : typeParameterMap;
AnonymousTypes = anonymousTypes.IsDefault ? ImmutableArray.Empty : anonymousTypes;
UsageText = usageText.IsDefault ? ImmutableArray.Empty : usageText;
ExceptionText = exceptionText.IsDefault ? ImmutableArray.Empty : exceptionText;
}
}
sealed class CodeSpanQuickInfoContent : QuickInfoContent {
public override string Type => PredefinedQuickInfoContentTypes.CodeSpan;
public TextSpan Span { get; }
public CodeSpanQuickInfoContent(TextSpan span) {
Span = span;
}
}
static class PredefinedQuickInfoContentTypes {
///
/// Normal quick info tooltip content: information about a type, member, local, etc...
///
public const string Information = nameof(Information);
///
/// Some span of text from the document should be shown to the user, eg. the tooltip shown when hovering over the closing curly brace (})
///
public const string CodeSpan = nameof(CodeSpan);
}
}