Browse Source

Add Language.GetRichTextTooltip

pull/1654/head
Siegfried Pammer 6 years ago
parent
commit
6baecf85aa
  1. 3
      ICSharpCode.Decompiler/CSharp/OutputVisitor/CSharpAmbience.cs
  2. 1
      ICSharpCode.Decompiler/CSharp/OutputVisitor/ITokenWriter.cs
  3. 122
      ICSharpCode.Decompiler/CSharp/OutputVisitor/TextWriterTokenWriter.cs
  4. 1
      ILSpy/ILSpy.csproj
  5. 2
      ILSpy/ISmartTextOutput.cs
  6. 5
      ILSpy/Languages/CSharpHighlightingTokenWriter.cs
  7. 13
      ILSpy/Languages/CSharpLanguage.cs
  8. 7
      ILSpy/Languages/Language.cs
  9. 119
      ILSpy/RichTextModelOutput.cs
  10. 12
      ILSpy/TextView/DecompilerTextView.cs
  11. 5
      ILSpy/TextView/XmlDocRenderer.cs

3
ICSharpCode.Decompiler/CSharp/OutputVisitor/CSharpAmbience.cs

@ -56,6 +56,7 @@ namespace ICSharpCode.Decompiler.CSharp.OutputVisitor @@ -56,6 +56,7 @@ namespace ICSharpCode.Decompiler.CSharp.OutputVisitor
TypeSystemAstBuilder astBuilder = CreateAstBuilder();
AstNode node = astBuilder.ConvertSymbol(symbol);
writer.StartNode(node);
EntityDeclaration entityDecl = node as EntityDeclaration;
if (entityDecl != null)
PrintModifiers(entityDecl.Modifiers, writer);
@ -167,6 +168,7 @@ namespace ICSharpCode.Decompiler.CSharp.OutputVisitor @@ -167,6 +168,7 @@ namespace ICSharpCode.Decompiler.CSharp.OutputVisitor
} else {
writer.WriteToken(Roles.Semicolon, ";");
}
writer.EndNode(node);
}
}
@ -190,6 +192,7 @@ namespace ICSharpCode.Decompiler.CSharp.OutputVisitor @@ -190,6 +192,7 @@ namespace ICSharpCode.Decompiler.CSharp.OutputVisitor
{
TypeSystemAstBuilder astBuilder = new TypeSystemAstBuilder();
astBuilder.AddTypeReferenceAnnotations = true;
astBuilder.AddResolveResultAnnotations = true;
astBuilder.ShowTypeParametersForUnboundTypes = true;
astBuilder.ShowModifiers = (ConversionFlags & ConversionFlags.ShowModifiers) == ConversionFlags.ShowModifiers;
astBuilder.ShowAccessibility = (ConversionFlags & ConversionFlags.ShowAccessibility) == ConversionFlags.ShowAccessibility;

1
ICSharpCode.Decompiler/CSharp/OutputVisitor/ITokenWriter.cs

@ -79,6 +79,7 @@ namespace ICSharpCode.Decompiler.CSharp.OutputVisitor @@ -79,6 +79,7 @@ namespace ICSharpCode.Decompiler.CSharp.OutputVisitor
public interface ILocatable
{
TextLocation Location { get; }
int Length { get; }
}
public abstract class DecoratingTokenWriter : TokenWriter

122
ICSharpCode.Decompiler/CSharp/OutputVisitor/TextWriterTokenWriter.cs

@ -30,22 +30,20 @@ namespace ICSharpCode.Decompiler.CSharp.OutputVisitor @@ -30,22 +30,20 @@ namespace ICSharpCode.Decompiler.CSharp.OutputVisitor
public class TextWriterTokenWriter : TokenWriter, ILocatable
{
readonly TextWriter textWriter;
int indentation;
bool needsIndent = true;
bool isAtStartOfLine = true;
int line, column;
public int Indentation {
get { return this.indentation; }
set { this.indentation = value; }
}
public int Indentation { get; set; }
public TextLocation Location {
get { return new TextLocation(line, column + (needsIndent ? indentation * IndentationString.Length : 0)); }
get { return new TextLocation(line, column + (needsIndent ? Indentation * IndentationString.Length : 0)); }
}
public string IndentationString { get; set; }
public int Length { get; private set; }
public TextWriterTokenWriter(TextWriter textWriter)
{
if (textWriter == null)
@ -55,73 +53,80 @@ namespace ICSharpCode.Decompiler.CSharp.OutputVisitor @@ -55,73 +53,80 @@ namespace ICSharpCode.Decompiler.CSharp.OutputVisitor
this.line = 1;
this.column = 1;
}
public override void WriteIdentifier(Identifier identifier)
{
WriteIndentation();
if (identifier.IsVerbatim || CSharpOutputVisitor.IsKeyword(identifier.Name, identifier)) {
textWriter.Write('@');
column++;
Length++;
}
string name = EscapeIdentifier(identifier.Name);
textWriter.Write(name);
column += name.Length;
Length += name.Length;
isAtStartOfLine = false;
}
public override void WriteKeyword(Role role, string keyword)
{
WriteIndentation();
column += keyword.Length;
Length += keyword.Length;
textWriter.Write(keyword);
isAtStartOfLine = false;
}
public override void WriteToken(Role role, string token)
{
WriteIndentation();
column += token.Length;
Length += token.Length;
textWriter.Write(token);
isAtStartOfLine = false;
}
public override void Space()
{
WriteIndentation();
column++;
Length++;
textWriter.Write(' ');
}
protected void WriteIndentation()
{
if (needsIndent) {
needsIndent = false;
for (int i = 0; i < indentation; i++) {
for (int i = 0; i < Indentation; i++) {
textWriter.Write(this.IndentationString);
}
column += indentation * IndentationString.Length;
column += Indentation * IndentationString.Length;
Length += Indentation * IndentationString.Length;
}
}
public override void NewLine()
{
textWriter.WriteLine();
column = 1;
line++;
Length += textWriter.NewLine.Length;
needsIndent = true;
isAtStartOfLine = true;
}
public override void Indent()
{
indentation++;
Indentation++;
}
public override void Unindent()
{
indentation--;
Indentation--;
}
public override void WriteComment(CommentType commentType, string content)
{
WriteIndentation();
@ -129,6 +134,7 @@ namespace ICSharpCode.Decompiler.CSharp.OutputVisitor @@ -129,6 +134,7 @@ namespace ICSharpCode.Decompiler.CSharp.OutputVisitor
case CommentType.SingleLine:
textWriter.Write("//");
textWriter.WriteLine(content);
Length += 2 + content.Length + textWriter.NewLine.Length;
column = 1;
line++;
needsIndent = true;
@ -138,6 +144,7 @@ namespace ICSharpCode.Decompiler.CSharp.OutputVisitor @@ -138,6 +144,7 @@ namespace ICSharpCode.Decompiler.CSharp.OutputVisitor
textWriter.Write("/*");
textWriter.Write(content);
textWriter.Write("*/");
Length += 4 + content.Length;
column += 2;
UpdateEndLocation(content, ref line, ref column);
column += 2;
@ -146,6 +153,7 @@ namespace ICSharpCode.Decompiler.CSharp.OutputVisitor @@ -146,6 +153,7 @@ namespace ICSharpCode.Decompiler.CSharp.OutputVisitor
case CommentType.Documentation:
textWriter.Write("///");
textWriter.WriteLine(content);
Length += 3 + content.Length + textWriter.NewLine.Length;
column = 1;
line++;
needsIndent = true;
@ -155,6 +163,7 @@ namespace ICSharpCode.Decompiler.CSharp.OutputVisitor @@ -155,6 +163,7 @@ namespace ICSharpCode.Decompiler.CSharp.OutputVisitor
textWriter.Write("/**");
textWriter.Write(content);
textWriter.Write("*/");
Length += 5 + content.Length;
column += 3;
UpdateEndLocation(content, ref line, ref column);
column += 2;
@ -163,10 +172,11 @@ namespace ICSharpCode.Decompiler.CSharp.OutputVisitor @@ -163,10 +172,11 @@ namespace ICSharpCode.Decompiler.CSharp.OutputVisitor
default:
textWriter.Write(content);
column += content.Length;
Length += content.Length;
break;
}
}
static void UpdateEndLocation(string content, ref int line, ref int column)
{
if (string.IsNullOrEmpty(content))
@ -186,7 +196,7 @@ namespace ICSharpCode.Decompiler.CSharp.OutputVisitor @@ -186,7 +196,7 @@ namespace ICSharpCode.Decompiler.CSharp.OutputVisitor
column++;
}
}
public override void WritePreProcessorDirective(PreProcessorDirectiveType type, string argument)
{
// pre-processor directive must start on its own line
@ -197,14 +207,16 @@ namespace ICSharpCode.Decompiler.CSharp.OutputVisitor @@ -197,14 +207,16 @@ namespace ICSharpCode.Decompiler.CSharp.OutputVisitor
string directive = type.ToString().ToLowerInvariant();
textWriter.Write(directive);
column += 1 + directive.Length;
Length += 1 + directive.Length;
if (!string.IsNullOrEmpty(argument)) {
textWriter.Write(' ');
textWriter.Write(argument);
column += 1 + argument.Length;
Length += 1 + argument.Length;
}
NewLine();
}
public static string PrintPrimitiveValue(object value)
{
TextWriter writer = new StringWriter();
@ -212,48 +224,55 @@ namespace ICSharpCode.Decompiler.CSharp.OutputVisitor @@ -212,48 +224,55 @@ namespace ICSharpCode.Decompiler.CSharp.OutputVisitor
tokenWriter.WritePrimitiveValue(value);
return writer.ToString();
}
public override void WritePrimitiveValue(object value, string literalValue = null)
{
if (literalValue != null) {
textWriter.Write(literalValue);
column += literalValue.Length;
Length += literalValue.Length;
return;
}
if (value == null) {
// usually NullReferenceExpression should be used for this, but we'll handle it anyways
textWriter.Write("null");
column += 4;
Length += 4;
return;
}
if (value is bool) {
if ((bool)value) {
textWriter.Write("true");
column += 4;
Length += 4;
} else {
textWriter.Write("false");
column += 5;
Length += 5;
}
return;
}
if (value is string) {
string tmp = ConvertString(value.ToString());
column += tmp.Length + 2;
Length += tmp.Length + 2;
textWriter.Write('"');
textWriter.Write(tmp);
textWriter.Write('"');
} else if (value is char) {
string tmp = ConvertCharLiteral((char)value);
column += tmp.Length + 2;
Length += tmp.Length + 2;
textWriter.Write('\'');
textWriter.Write(tmp);
textWriter.Write('\'');
} else if (value is decimal) {
string str = ((decimal)value).ToString(NumberFormatInfo.InvariantInfo) + "m";
column += str.Length;
Length += str.Length;
textWriter.Write(str);
} else if (value is float) {
float f = (float)value;
@ -262,16 +281,20 @@ namespace ICSharpCode.Decompiler.CSharp.OutputVisitor @@ -262,16 +281,20 @@ namespace ICSharpCode.Decompiler.CSharp.OutputVisitor
// but we still support writing these to make life easier for code generators.
textWriter.Write("float");
column += 5;
Length += 5;
WriteToken(Roles.Dot, ".");
if (float.IsPositiveInfinity(f)) {
textWriter.Write("PositiveInfinity");
column += "PositiveInfinity".Length;
Length += "PositiveInfinity".Length;
} else if (float.IsNegativeInfinity(f)) {
textWriter.Write("NegativeInfinity");
column += "NegativeInfinity".Length;
Length += "NegativeInfinity".Length;
} else {
textWriter.Write("NaN");
column += 3;
Length += 3;
}
return;
}
@ -281,9 +304,11 @@ namespace ICSharpCode.Decompiler.CSharp.OutputVisitor @@ -281,9 +304,11 @@ namespace ICSharpCode.Decompiler.CSharp.OutputVisitor
// the special case here than to do it in all code generators)
textWriter.Write("-");
column++;
Length++;
}
var str = f.ToString("R", NumberFormatInfo.InvariantInfo) + "f";
column += str.Length;
Length += str.Length;
textWriter.Write(str);
} else if (value is double) {
double f = (double)value;
@ -292,16 +317,20 @@ namespace ICSharpCode.Decompiler.CSharp.OutputVisitor @@ -292,16 +317,20 @@ namespace ICSharpCode.Decompiler.CSharp.OutputVisitor
// but we still support writing these to make life easier for code generators.
textWriter.Write("double");
column += 6;
Length += 6;
WriteToken(Roles.Dot, ".");
if (double.IsPositiveInfinity(f)) {
textWriter.Write("PositiveInfinity");
column += "PositiveInfinity".Length;
Length += "PositiveInfinity".Length;
} else if (double.IsNegativeInfinity(f)) {
textWriter.Write("NegativeInfinity");
column += "NegativeInfinity".Length;
Length += "NegativeInfinity".Length;
} else {
textWriter.Write("NaN");
column += 3;
Length += 3;
}
return;
}
@ -310,20 +339,22 @@ namespace ICSharpCode.Decompiler.CSharp.OutputVisitor @@ -310,20 +339,22 @@ namespace ICSharpCode.Decompiler.CSharp.OutputVisitor
// (again, not a primitive expression, but it's better to handle
// the special case here than to do it in all code generators)
textWriter.Write("-");
Length++;
}
string number = f.ToString("R", NumberFormatInfo.InvariantInfo);
if (number.IndexOf('.') < 0 && number.IndexOf('E') < 0) {
number += ".0";
}
textWriter.Write(number);
Length += number.Length;
} else if (value is IFormattable) {
StringBuilder b = new StringBuilder ();
// if (primitiveExpression.LiteralFormat == LiteralFormat.HexadecimalNumber) {
// b.Append("0x");
// b.Append(((IFormattable)val).ToString("x", NumberFormatInfo.InvariantInfo));
// } else {
b.Append(((IFormattable)value).ToString(null, NumberFormatInfo.InvariantInfo));
// }
StringBuilder b = new StringBuilder();
// if (primitiveExpression.LiteralFormat == LiteralFormat.HexadecimalNumber) {
// b.Append("0x");
// b.Append(((IFormattable)val).ToString("x", NumberFormatInfo.InvariantInfo));
// } else {
b.Append(((IFormattable)value).ToString(null, NumberFormatInfo.InvariantInfo));
// }
if (value is uint || value is ulong) {
b.Append("u");
}
@ -332,12 +363,15 @@ namespace ICSharpCode.Decompiler.CSharp.OutputVisitor @@ -332,12 +363,15 @@ namespace ICSharpCode.Decompiler.CSharp.OutputVisitor
}
textWriter.Write(b.ToString());
column += b.Length;
Length += b.Length;
} else {
textWriter.Write(value.ToString());
column += value.ToString().Length;
int length = value.ToString().Length;
column += length;
Length += length;
}
}
/// <summary>
/// Gets the escape sequence for the specified character within a char literal.
/// Does not include the single quotes surrounding the char literal.
@ -349,7 +383,7 @@ namespace ICSharpCode.Decompiler.CSharp.OutputVisitor @@ -349,7 +383,7 @@ namespace ICSharpCode.Decompiler.CSharp.OutputVisitor
}
return ConvertChar(ch) ?? ch.ToString();
}
/// <summary>
/// Gets the escape sequence for the specified character.
/// </summary>
@ -412,7 +446,7 @@ namespace ICSharpCode.Decompiler.CSharp.OutputVisitor @@ -412,7 +446,7 @@ namespace ICSharpCode.Decompiler.CSharp.OutputVisitor
/// </summary>
public static string ConvertString(string str)
{
StringBuilder sb = new StringBuilder ();
StringBuilder sb = new StringBuilder();
foreach (char ch in str) {
string s = ch == '"' ? "\\\"" : ConvertChar(ch);
if (s != null) sb.Append(s);
@ -477,17 +511,19 @@ namespace ICSharpCode.Decompiler.CSharp.OutputVisitor @@ -477,17 +511,19 @@ namespace ICSharpCode.Decompiler.CSharp.OutputVisitor
return true;
}
}
public override void WritePrimitiveType(string type)
{
textWriter.Write(type);
column += type.Length;
Length += type.Length;
if (type == "new") {
textWriter.Write("()");
column += 2;
Length += 2;
}
}
public override void StartNode(AstNode node)
{
// Write out the indentation, so that overrides of this method
@ -495,7 +531,7 @@ namespace ICSharpCode.Decompiler.CSharp.OutputVisitor @@ -495,7 +531,7 @@ namespace ICSharpCode.Decompiler.CSharp.OutputVisitor
// in the output.
WriteIndentation();
}
public override void EndNode(AstNode node)
{
}

1
ILSpy/ILSpy.csproj

@ -173,6 +173,7 @@ @@ -173,6 +173,7 @@
<AutoGen>True</AutoGen>
<DependentUpon>Resources.resx</DependentUpon>
</Compile>
<Compile Include="RichTextModelOutput.cs" />
<Compile Include="Search\AbstractEntitySearchStrategy.cs" />
<Compile Include="Search\AssemblySearchStrategy.cs" />
<Compile Include="Search\LiteralSearchStrategy.cs" />

2
ILSpy/ISmartTextOutput.cs

@ -39,7 +39,7 @@ namespace ICSharpCode.ILSpy @@ -39,7 +39,7 @@ namespace ICSharpCode.ILSpy
void BeginSpan(HighlightingColor highlightingColor);
void EndSpan();
}
public static class SmartTextOutputExtensions
{
/// <summary>

5
ILSpy/Languages/CSharpHighlightingTokenWriter.cs

@ -419,6 +419,9 @@ namespace ICSharpCode.ILSpy @@ -419,6 +419,9 @@ namespace ICSharpCode.ILSpy
ISymbol GetCurrentMemberReference()
{
if (nodeStack == null || nodeStack.Count == 0)
return null;
AstNode node = nodeStack.Peek();
var symbol = node.GetSymbol();
if (symbol == null && node.Role == Roles.TargetExpression && node.Parent is InvocationExpression) {
@ -435,7 +438,7 @@ namespace ICSharpCode.ILSpy @@ -435,7 +438,7 @@ namespace ICSharpCode.ILSpy
return symbol;
}
Stack<AstNode> nodeStack = new Stack<AstNode>();
readonly Stack<AstNode> nodeStack = new Stack<AstNode>();
public override void StartNode(AstNode node)
{

13
ILSpy/Languages/CSharpLanguage.cs

@ -26,7 +26,9 @@ using System.Reflection.Metadata; @@ -26,7 +26,9 @@ using System.Reflection.Metadata;
using System.Text;
using System.Windows;
using System.Windows.Controls;
using ICSharpCode.AvalonEdit.Document;
using ICSharpCode.AvalonEdit.Highlighting;
using ICSharpCode.AvalonEdit.Utils;
using ICSharpCode.Decompiler;
using ICSharpCode.Decompiler.CSharp;
using ICSharpCode.Decompiler.CSharp.OutputVisitor;
@ -625,10 +627,15 @@ namespace ICSharpCode.ILSpy @@ -625,10 +627,15 @@ namespace ICSharpCode.ILSpy
return showAllMembers || !CSharpDecompiler.MemberIsHidden(assembly, member.MetadataToken, new DecompilationOptions().DecompilerSettings);
}
public override string GetTooltip(IEntity entity)
public override RichText GetRichTextTooltip(IEntity entity)
{
var flags = ConversionFlags.All & ~(ConversionFlags.ShowBody | ConversionFlags.PlaceReturnTypeAfterParameterList);
return new CSharpAmbience() { ConversionFlags = flags }.ConvertSymbol(entity);
var output = new StringWriter();
var decoratedWriter = new TextWriterTokenWriter(output);
var richTextOutput = new RichTextModelOutput(decoratedWriter);
var writer = new CSharpHighlightingTokenWriter(decoratedWriter, richTextOutput);
new CSharpAmbience() { ConversionFlags = flags }.ConvertSymbol(entity, writer, FormattingOptionsFactory.CreateEmpty());
return new RichText(output.ToString(), richTextOutput.Model);
}
public override CodeMappingInfo GetCodeMappingInfo(PEFile module, EntityHandle member)

7
ILSpy/Languages/Language.cs

@ -21,6 +21,7 @@ using System.Collections.Generic; @@ -21,6 +21,7 @@ using System.Collections.Generic;
using System.Reflection.Metadata;
using System.Reflection.PortableExecutable;
using System.Text;
using ICSharpCode.AvalonEdit.Highlighting;
using ICSharpCode.Decompiler;
using ICSharpCode.Decompiler.Metadata;
using ICSharpCode.Decompiler.Solution;
@ -349,7 +350,11 @@ namespace ICSharpCode.ILSpy @@ -349,7 +350,11 @@ namespace ICSharpCode.ILSpy
return GetDisplayName(entity, true, true, true);
}
public virtual object GetFancyTooltip(IEntity entity)
/// <summary>
/// Converts a member signature to a string.
/// This is used for displaying the tooltip on a member reference.
/// </summary>
public virtual RichText GetRichTextTooltip(IEntity entity)
{
return GetTooltip(entity);
}

119
ILSpy/RichTextModelOutput.cs

@ -0,0 +1,119 @@ @@ -0,0 +1,119 @@
// Copyright (c) 2011 AlphaSierraPapa for the SharpDevelop Team
//
// Permission is hereby granted, free of charge, to any person obtaining a copy of this
// software and associated documentation files (the "Software"), to deal in the Software
// without restriction, including without limitation the rights to use, copy, modify, merge,
// publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons
// to whom the Software is furnished to do so, subject to the following conditions:
//
// The above copyright notice and this permission notice shall be included in all copies or
// substantial portions of the Software.
//
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED,
// INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR
// PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE
// FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR
// OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
// DEALINGS IN THE SOFTWARE.
using System;
using System.Collections.Generic;
using System.Reflection.Metadata;
using System.Text;
using System.Windows;
using ICSharpCode.AvalonEdit.Highlighting;
using ICSharpCode.Decompiler;
using ICSharpCode.Decompiler.CSharp.OutputVisitor;
using ICSharpCode.Decompiler.Disassembler;
using ICSharpCode.Decompiler.Metadata;
using ICSharpCode.Decompiler.TypeSystem;
namespace ICSharpCode.ILSpy
{
public class RichTextModelOutput : ISmartTextOutput
{
readonly Stack<HighlightingColor> colorStack = new Stack<HighlightingColor>();
HighlightingColor currentColor = new HighlightingColor();
int currentColorBegin = -1;
ILocatable textOutput;
public string IndentationString { get; set; } = "\t";
public RichTextModel Model { get; set; } = new RichTextModel();
public RichTextModelOutput(ILocatable textOutput)
{
this.textOutput = textOutput;
}
public void AddUIElement(Func<UIElement> element)
{
throw new NotSupportedException();
}
public void BeginSpan(HighlightingColor highlightingColor)
{
if (currentColorBegin > -1)
Model.SetHighlighting(currentColorBegin, textOutput.Length - currentColorBegin, currentColor);
colorStack.Push(currentColor);
currentColor = currentColor.Clone();
currentColorBegin = textOutput.Length;
currentColor.MergeWith(highlightingColor);
currentColor.Freeze();
}
public void EndSpan()
{
Model.SetHighlighting(currentColorBegin, textOutput.Length - currentColorBegin, currentColor);
currentColor = colorStack.Pop();
currentColorBegin = textOutput.Length;
}
public void Indent()
{
}
public void Unindent()
{
}
public void Write(char ch)
{
}
public void Write(string text)
{
}
public void WriteLine()
{
}
public void WriteReference(Decompiler.Disassembler.OpCodeInfo opCode, bool omitSuffix = false)
{
}
public void WriteReference(PEFile module, EntityHandle handle, string text, bool isDefinition = false)
{
}
public void WriteReference(IType type, string text, bool isDefinition = false)
{
}
public void WriteReference(IMember member, string text, bool isDefinition = false)
{
}
public void WriteLocalReference(string text, object reference, bool isDefinition = false)
{
}
public void MarkFoldStart(string collapsedText = "...", bool defaultCollapsed = false)
{
}
public void MarkFoldEnd()
{
}
}
}

12
ILSpy/TextView/DecompilerTextView.cs

@ -92,7 +92,7 @@ namespace ICSharpCode.ILSpy.TextView @@ -92,7 +92,7 @@ namespace ICSharpCode.ILSpy.TextView
}
});
/*HighlightingManager.Instance.RegisterHighlighting(
HighlightingManager.Instance.RegisterHighlighting(
"C#", new string[] { ".cs" },
delegate {
using (Stream s = typeof(DecompilerTextView).Assembly.GetManifestResourceStream(typeof(DecompilerTextView), "CSharp-Mode.xshd")) {
@ -100,7 +100,7 @@ namespace ICSharpCode.ILSpy.TextView @@ -100,7 +100,7 @@ namespace ICSharpCode.ILSpy.TextView
return HighlightingLoader.Load(reader, HighlightingManager.Instance);
}
}
});*/
});
InitializeComponent();
@ -364,7 +364,8 @@ namespace ICSharpCode.ILSpy.TextView @@ -364,7 +364,8 @@ namespace ICSharpCode.ILSpy.TextView
{
Language currentLanguage = MainWindow.Instance.CurrentLanguage;
DocumentationUIBuilder renderer = new DocumentationUIBuilder(new CSharpAmbience(), currentLanguage.SyntaxHighlighting);
renderer.AddSignatureBlock(currentLanguage.GetTooltip(resolved));
RichText richText = currentLanguage.GetRichTextTooltip(resolved);
renderer.AddSignatureBlock(richText.Text, richText.ToRichTextModel());
try {
if (resolved.ParentModule == null || resolved.ParentModule.PEFile == null)
return null;
@ -372,7 +373,6 @@ namespace ICSharpCode.ILSpy.TextView @@ -372,7 +373,6 @@ namespace ICSharpCode.ILSpy.TextView
if (docProvider != null) {
string documentation = docProvider.GetDocumentation(resolved.GetIdString());
if (documentation != null) {
//renderer.AppendText(Environment.NewLine);
renderer.AddXmlDocumentation(documentation);
}
}
@ -392,8 +392,8 @@ namespace ICSharpCode.ILSpy.TextView @@ -392,8 +392,8 @@ namespace ICSharpCode.ILSpy.TextView
viewer = new FlowDocumentScrollViewer();
viewer.Document = document;
Border border = new Border {
Background = SystemColors.InfoBrush,
BorderBrush = SystemColors.InfoTextBrush,
Background = SystemColors.ControlBrush,
BorderBrush = SystemColors.ControlDarkBrush,
BorderThickness = new Thickness(1),
MaxHeight = 400,
Child = viewer

5
ILSpy/TextView/XmlDocRenderer.cs

@ -104,11 +104,10 @@ namespace ICSharpCode.ILSpy.TextView @@ -104,11 +104,10 @@ namespace ICSharpCode.ILSpy.TextView
AddBlock(block);
}
public void AddSignatureBlock(string signature)
public void AddSignatureBlock(string signature, RichTextModel highlighting = null)
{
var document = new TextDocument(signature);
var highlighter = new DocumentHighlighter(document, highlightingDefinition);
var richText = DocumentPrinter.ConvertTextDocumentToRichText(document, highlighter).ToRichTextModel();
var richText = highlighting ?? DocumentPrinter.ConvertTextDocumentToRichText(document, new DocumentHighlighter(document, highlightingDefinition)).ToRichTextModel();
var block = new Paragraph();
block.Inlines.AddRange(richText.CreateRuns(document));
block.FontFamily = GetCodeFont();

Loading…
Cancel
Save