| Newsgroups |
gmane.comp.gnome.mono.patches |
| Message-ID |
<000001426a3887fc-96a350d5-a723-469f-af63-596f7a3b850b-000000@email.amazonses.com> |
Branch: refs/heads/master
Home: https://github.com/mono/monodevelop
Compare: https://github.com/mono/monodevelop/compare/75816451c377...b335181ca159
Commit: b335181ca159dbb78098cc634d6f8f4a546b23e4
Author: Mike Krüger <[email protected]> (mkrueger)
Date: 2013-11-18 07:58:04 GMT
URL: https://github.com/mono/monodevelop/commit/b335181ca159dbb78098cc634d6f8f4a546b23e4
Implemented 'Bug 16228 - Namespaces in tooltips'.
Changed paths:
M main/src/addins/CSharpBinding/MonoDevelop.CSharp.Completion/MemberCompletionData.cs
M main/src/addins/CSharpBinding/MonoDevelop.CSharp.Tooltips/LanguageItemTooltipProvider.cs
M main/src/addins/CSharpBinding/MonoDevelop.CSharp/SignatureMarkupCreator.cs
Modified: main/src/addins/CSharpBinding/MonoDevelop.CSharp.Completion/MemberCompletionData.cs
===================================================================
@@ -682,30 +682,7 @@ public static TooltipInformation CreateTooltipInformation (ICompilation compilat
}
}
if (createFooter) {
- if (entity is IType) {
- var type = entity as IType;
- var def = type.GetDefinition ();
- if (def != null) {
- if (!string.IsNullOrEmpty (def.ParentAssembly.AssemblyName)) {
- var project = def.GetSourceProject ();
- if (project != null) {
- var relPath = FileService.AbsoluteToRelativePath (project.BaseDirectory, def.Region.FileName);
- tooltipInfo.FooterMarkup = "<small>" + GettextCatalog.GetString ("Project:\t{0}", AmbienceService.EscapeText (def.ParentAssembly.AssemblyName)) + "</small>" + Environment.NewLine +
- "<small>" + GettextCatalog.GetString ("File:\t\t{0} (line {1})", AmbienceService.EscapeText (relPath), def.Region.Begin.Line) + "</small>";
- }
- }
- }
-
- } else if (entity.DeclaringTypeDefinition != null) {
- var project = entity.DeclaringTypeDefinition.GetSourceProject ();
- if (project != null) {
- var relPath = FileService.AbsoluteToRelativePath (project.BaseDirectory, entity.Region.FileName);
- tooltipInfo.FooterMarkup =
- "<small>" + GettextCatalog.GetString ("Project:\t{0}", AmbienceService.EscapeText (project.Name)) + "</small>" + Environment.NewLine +
- "<small>" + GettextCatalog.GetString ("From:\t{0}", AmbienceService.EscapeText (entity.DeclaringType.FullName)) + "</small>" + Environment.NewLine +
- "<small>" + GettextCatalog.GetString ("File:\t\t{0} (line {1})", AmbienceService.EscapeText (relPath), entity.Region.Begin.Line) + "</small>";
- }
- }
+ tooltipInfo.FooterMarkup = sig.CreateFooter (entity);
}
return tooltipInfo;
}
@@ -732,8 +709,8 @@ public static TooltipInformation CreateTooltipInformation (ICompilation compilat
var def = type.GetDefinition ();
if (def != null) {
- if (createFooter && !string.IsNullOrEmpty (def.ParentAssembly.AssemblyName))
- tooltipInfo.FooterMarkup = "<small> From " + AmbienceService.EscapeText (def.ParentAssembly.AssemblyName) + "</small>";
+ if (createFooter)
+ tooltipInfo.FooterMarkup = sig.CreateFooter (def);
tooltipInfo.SummaryMarkup = AmbienceService.GetSummaryMarkup (def) ?? "";
}
return tooltipInfo;
Modified: main/src/addins/CSharpBinding/MonoDevelop.CSharp.Tooltips/LanguageItemTooltipProvider.cs
===================================================================
@@ -141,7 +141,7 @@ protected override Gtk.Window CreateTooltipWindow (Mono.TextEditor.TextEditor ed
var titem = (ToolTipData)item.Item;
- var tooltipInformation = CreateTooltip (titem, offset, null);
+ var tooltipInformation = CreateTooltip (titem, offset, null, modifierState);
if (tooltipInformation == null || string.IsNullOrEmpty (tooltipInformation.SignatureMarkup))
return null;
@@ -179,12 +179,13 @@ public override Gtk.Window ShowTooltipWindow (TextEditor editor, int offset, Gdk
return tipWindow;
}
- TooltipInformation CreateTooltip (ToolTipData data, int offset, Ambience ambience)
+ TooltipInformation CreateTooltip (ToolTipData data, int offset, Ambience ambience, Gdk.ModifierType modifierState)
{
ResolveResult result = data.Result;
var doc = IdeApp.Workbench.ActiveDocument;
if (doc == null)
return null;
+ bool createFooter = (modifierState & Gdk.ModifierType.Mod1Mask) != 0;
try {
if (result is AliasNamespaceResolveResult) {
@@ -276,12 +277,13 @@ TooltipInformation CreateTooltip (ToolTipData data, int offset, Ambience ambienc
var method = allMethods.FirstOrDefault ();
if (method != null) {
return MemberCompletionData.CreateTooltipInformation (
- doc.Compilation,
- doc.ParsedDocument.ParsedFile as CSharpUnresolvedFile,
- doc.Editor,
- doc.GetFormattingPolicy (),
- method,
- false);
+ doc.Compilation,
+ doc.ParsedDocument.ParsedFile as CSharpUnresolvedFile,
+ doc.Editor,
+ doc.GetFormattingPolicy (),
+ method,
+ false,
+ createFooter);
}
} else if (result is CSharpInvocationResolveResult) {
var invocationResult = (CSharpInvocationResolveResult)result;
@@ -292,16 +294,18 @@ TooltipInformation CreateTooltip (ToolTipData data, int offset, Ambience ambienc
doc.Editor,
doc.GetFormattingPolicy (),
member,
- false);
+ false,
+ createFooter);
} else if (result is MemberResolveResult) {
var member = ((MemberResolveResult)result).Member;
return MemberCompletionData.CreateTooltipInformation (
- doc.Compilation,
- doc.ParsedDocument.ParsedFile as CSharpUnresolvedFile,
- doc.Editor,
- doc.GetFormattingPolicy (),
- member,
- false);
+ doc.Compilation,
+ doc.ParsedDocument.ParsedFile as CSharpUnresolvedFile,
+ doc.Editor,
+ doc.GetFormattingPolicy (),
+ member,
+ false,
+ createFooter);
} else if (result is NamespaceResolveResult) {
var tooltipInfo = new TooltipInformation ();
var resolver = (doc.ParsedDocument.ParsedFile as CSharpUnresolvedFile).GetResolver (doc.Compilation, doc.Editor.Caret.Location);
@@ -329,12 +333,13 @@ TooltipInformation CreateTooltip (ToolTipData data, int offset, Ambience ambienc
return tooltipInfo;
} else {
return MemberCompletionData.CreateTooltipInformation (
- doc.Compilation,
- doc.ParsedDocument.ParsedFile as CSharpUnresolvedFile,
- doc.Editor,
- doc.GetFormattingPolicy (),
- result.Type,
- false);
+ doc.Compilation,
+ doc.ParsedDocument.ParsedFile as CSharpUnresolvedFile,
+ doc.Editor,
+ doc.GetFormattingPolicy (),
+ result.Type,
+ false,
+ createFooter);
}
} catch (Exception e) {
LoggingService.LogError ("Error while creating tooltip.", e);
Modified: main/src/addins/CSharpBinding/MonoDevelop.CSharp/SignatureMarkupCreator.cs
===================================================================
@@ -1611,5 +1611,46 @@ string HighlightSemantically (string str, ChunkStyle style)
return str;
return Highlight (str, style);
}
+
+ public string CreateFooter (IEntity entity)
+ {
+ var type = entity as IType;
+ if (type != null) {
+ var def = type.GetDefinition ();
+ if (def != null) {
+ if (!def.Region.IsEmpty) {
+ var project = def.GetSourceProject ();
+ if (project != null) {
+ var relPath = FileService.AbsoluteToRelativePath (project.BaseDirectory, def.Region.FileName);
+ return
+ (string.IsNullOrEmpty (def.Namespace) ? "" : "<small>" + GettextCatalog.GetString ("Namespace:\t{0}", AmbienceService.EscapeText (def.Namespace)) + "</small>" + Environment.NewLine) +
+ "<small>" + GettextCatalog.GetString ("Project:\t{0}", AmbienceService.EscapeText (def.ParentAssembly.AssemblyName)) + "</small>" + Environment.NewLine +
+ "<small>" + GettextCatalog.GetString ("File:\t\t{0} (line {1})", AmbienceService.EscapeText (relPath), def.Region.Begin.Line) + "</small>";
+ }
+ }
+ return
+ (string.IsNullOrEmpty (def.Namespace) ? "" : "<small>" + GettextCatalog.GetString ("Namespace:\t{0}", AmbienceService.EscapeText (def.Namespace)) + "</small>" + Environment.NewLine) +
+ "<small>" + GettextCatalog.GetString ("Assembly:\t{0}", AmbienceService.EscapeText (def.ParentAssembly.AssemblyName)) + "</small>";
+ }
+ return null;
+ }
+
+ if (entity.DeclaringTypeDefinition != null) {
+ if (!entity.Region.IsEmpty) {
+ var project = entity.DeclaringTypeDefinition.GetSourceProject ();
+ if (project != null) {
+ var relPath = FileService.AbsoluteToRelativePath (project.BaseDirectory, entity.Region.FileName);
+ return
+ "<small>" + GettextCatalog.GetString ("Project:\t{0}", AmbienceService.EscapeText (project.Name)) + "</small>" + Environment.NewLine +
+ "<small>" + GettextCatalog.GetString ("From type:\t{0}", AmbienceService.EscapeText (entity.DeclaringTypeDefinition.FullName)) + "</small>" + Environment.NewLine +
+ "<small>" + GettextCatalog.GetString ("File:\t\t{0} (line {1})", AmbienceService.EscapeText (relPath), entity.Region.Begin.Line) + "</small>";
+ }
+ }
+ return
+ "<small>" + GettextCatalog.GetString ("From type:\t{0}", AmbienceService.EscapeText (entity.DeclaringTypeDefinition.FullName)) + "</small>" + Environment.NewLine +
+ "<small>" + GettextCatalog.GetString ("Assembly:\t{0}", AmbienceService.EscapeText (entity.DeclaringTypeDefinition.ParentAssembly.AssemblyName)) + "</small>";
+ }
+ return null;
+ }
}
}
_______________________________________________
Mono-patches maillist - [email protected]
http://lists.ximian.com/mailman/listinfo/mono-patches