diff options
Diffstat (limited to 'main/src/addins/CBinding/Parser')
-rwxr-xr-x | main/src/addins/CBinding/Parser/CDocumentParser.cs | 13 | ||||
-rw-r--r-- | main/src/addins/CBinding/Parser/CompilationUnitDataProvider.cs | 28 | ||||
-rwxr-xr-x | main/src/addins/CBinding/Parser/DataProvider.cs | 172 | ||||
-rw-r--r-- | main/src/addins/CBinding/Parser/Function.cs | 30 |
4 files changed, 143 insertions, 100 deletions
diff --git a/main/src/addins/CBinding/Parser/CDocumentParser.cs b/main/src/addins/CBinding/Parser/CDocumentParser.cs index 0d13cfbbe7..82cea2c6a8 100755 --- a/main/src/addins/CBinding/Parser/CDocumentParser.cs +++ b/main/src/addins/CBinding/Parser/CDocumentParser.cs @@ -35,6 +35,7 @@ using MonoDevelop.Ide; using MonoDevelop.Ide.TypeSystem; using ICSharpCode.NRefactory.TypeSystem; using ICSharpCode.NRefactory.TypeSystem.Implementation; +using MonoDevelop.Core.Text; namespace CBinding.Parser { @@ -43,13 +44,15 @@ namespace CBinding.Parser /// </summary> public class CDocumentParser: TypeSystemParser { - public override ParsedDocument Parse (bool storeAst, string fileName, TextReader reader, Project project = null) + public override System.Threading.Tasks.Task<ParsedDocument> Parse (ParseOptions options, System.Threading.CancellationToken cancellationToken) { + var fileName = options.FileName; + var project = options.Project; var doc = new DefaultParsedDocument (fileName); doc.Flags |= ParsedDocumentFlags.NonSerializable; ProjectInformation pi = ProjectInformationManager.Instance.Get (project); - string content = reader.ReadToEnd (); + string content = options.Content.Text; string[] contentLines = content.Split (new string[]{Environment.NewLine}, StringSplitOptions.None); var globals = new DefaultUnresolvedTypeDefinition ("", GettextCatalog.GetString ("(Global Scope)")); @@ -58,7 +61,7 @@ namespace CBinding.Parser foreach (LanguageItem li in pi.Containers ()) { if (null == li.Parent && FilePath.Equals (li.File, fileName)) { var tmp = AddLanguageItem (pi, globals, li, contentLines) as IUnresolvedTypeDefinition; - if (null != tmp){ doc.TopLevelTypeDefinitions.Add (tmp); } + if (null != tmp){ /*doc.TopLevelTypeDefinitions.Add (tmp);*/ } } } @@ -70,8 +73,8 @@ namespace CBinding.Parser } } - doc.TopLevelTypeDefinitions.Add (globals); - return doc; + //doc.TopLevelTypeDefinitions.Add (globals); + return System.Threading.Tasks.Task.FromResult((ParsedDocument)doc); } /// <summary> diff --git a/main/src/addins/CBinding/Parser/CompilationUnitDataProvider.cs b/main/src/addins/CBinding/Parser/CompilationUnitDataProvider.cs index 70c59b68ec..fb9109f3bc 100644 --- a/main/src/addins/CBinding/Parser/CompilationUnitDataProvider.cs +++ b/main/src/addins/CBinding/Parser/CompilationUnitDataProvider.cs @@ -37,17 +37,21 @@ using MonoDevelop.Ide.CodeCompletion; using MonoDevelop.Components; using Gtk; +using MonoDevelop.Ide.Editor; namespace CBinding.Parser { // Yoinked from C# binding public class CompilationUnitDataProvider : DropDownBoxListWindow.IListDataProvider { - Document Document { get; set; } + TextEditor editor; + + DocumentContext DocumentContext { get; set; } - public CompilationUnitDataProvider (Document document) + public CompilationUnitDataProvider (TextEditor editor, DocumentContext documentContext) { - this.Document = document; + this.editor = editor; + this.DocumentContext = documentContext; } #region IListDataProvider implementation @@ -55,7 +59,7 @@ namespace CBinding.Parser public string GetMarkup (int n) { - return GLib.Markup.EscapeText (Document.ParsedDocument.UserRegions.ElementAt (n).Name); + return GLib.Markup.EscapeText (DocumentContext.ParsedDocument.GetUserRegionsAsync().Result.ElementAt (n).Name); } internal static Xwt.Drawing.Image Pixbuf @@ -70,24 +74,26 @@ namespace CBinding.Parser public object GetTag (int n) { - return Document.ParsedDocument.UserRegions.ElementAt (n); + return DocumentContext.ParsedDocument.GetUserRegionsAsync().Result.ElementAt (n); } public void ActivateItem (int n) { - var reg = Document.ParsedDocument.UserRegions.ElementAt (n); - MonoDevelop.Ide.Gui.Content.IExtensibleTextEditor extEditor = Document.GetContent<MonoDevelop.Ide.Gui.Content.IExtensibleTextEditor> (); - if (extEditor != null) - extEditor.SetCaretTo (Math.Max (1, reg.Region.BeginLine), reg.Region.BeginColumn); + var reg = DocumentContext.ParsedDocument.GetUserRegionsAsync().Result.ElementAt (n); + var extEditor = editor; + if (extEditor != null) { + extEditor.CaretLocation = new DocumentLocation (Math.Max (1, reg.Region.BeginLine), reg.Region.BeginColumn); + extEditor.StartCaretPulseAnimation (); + } } public int IconCount { get { - if (Document.ParsedDocument == null) + if (DocumentContext.ParsedDocument == null) return 0; - return Document.ParsedDocument.UserRegions.Count (); + return DocumentContext.ParsedDocument.GetUserRegionsAsync().Result.Count (); } } diff --git a/main/src/addins/CBinding/Parser/DataProvider.cs b/main/src/addins/CBinding/Parser/DataProvider.cs index 201f06ac4c..ce5e817c74 100755 --- a/main/src/addins/CBinding/Parser/DataProvider.cs +++ b/main/src/addins/CBinding/Parser/DataProvider.cs @@ -39,91 +39,97 @@ using MonoDevelop.Components; using Gtk; using MonoDevelop.Ide.TypeSystem; using ICSharpCode.NRefactory.TypeSystem; +using MonoDevelop.Ide.Editor; namespace CBinding.Parser { - // Yoinked from C# binding - public class DataProvider : DropDownBoxListWindow.IListDataProvider - { - object tag; - Ambience amb; - List<IUnresolvedEntity> memberList = new List<IUnresolvedEntity> (); - - Document Document { - get; - set; - } - - public DataProvider (Document doc, object tag, Ambience amb) - { - this.Document = doc; - this.tag = tag; - this.amb = amb; - Reset (); - } - - #region IListDataProvider implementation - public void Reset () - { - memberList.Clear (); - if (tag is IUnresolvedFile) { - var types = new Stack<IUnresolvedTypeDefinition> (((IUnresolvedFile)tag).TopLevelTypeDefinitions); - while (types.Count > 0) { - var type = types.Pop (); - memberList.Add (type); - foreach (var innerType in type.NestedTypes) - types.Push (innerType); - } - } else if (tag is IUnresolvedTypeDefinition) { - memberList.AddRange (((IUnresolvedTypeDefinition)tag).Members); - } - memberList.Sort ((x, y) => String.Compare (GetString (amb, x), GetString (amb, y), StringComparison.OrdinalIgnoreCase)); - } - - string GetString (Ambience amb, IUnresolvedEntity x) - { - var ctx = new SimpleTypeResolveContext (Document.Compilation.MainAssembly); - IEntity rx = null; - if (x is IUnresolvedMember) - rx = ((IUnresolvedMember)x).CreateResolved (ctx); - - if (tag is IUnresolvedFile) - return amb.GetString (rx, OutputFlags.IncludeGenerics | OutputFlags.IncludeParameters | OutputFlags.UseFullInnerTypeName | OutputFlags.ReformatDelegates); - return amb.GetString (rx, OutputFlags.IncludeGenerics | OutputFlags.IncludeParameters | OutputFlags.ReformatDelegates); - } - - public string GetMarkup (int n) - { - var m = memberList[n]; -// if (m.IsObsolete ()) -// return "<s>" + GLib.Markup.EscapeText (GetString (amb, m)) + "</s>"; - return GLib.Markup.EscapeText (GetString (amb, m)); - } - - public Xwt.Drawing.Image GetIcon (int n) - { - return ImageService.GetIcon (memberList[n].GetStockIcon (), Gtk.IconSize.Menu); - } - - public object GetTag (int n) - { - return memberList[n]; - } - - public void ActivateItem (int n) - { - var member = memberList[n]; - MonoDevelop.Ide.Gui.Content.IExtensibleTextEditor extEditor = Document.GetContent<MonoDevelop.Ide.Gui.Content.IExtensibleTextEditor> (); - if (extEditor != null) - extEditor.SetCaretTo (Math.Max (1, member.Region.BeginLine), Math.Max (1, member.Region.BeginColumn)); - } - - public int IconCount { - get { - return memberList.Count; - } - } - #endregion - } + // TODO: Roslyn port. +// // Yoinked from C# binding +// public class DataProvider : DropDownBoxListWindow.IListDataProvider +// { +// object tag; +// Ambience amb; +// List<IUnresolvedEntity> memberList = new List<IUnresolvedEntity> (); +// +// TextEditor editor; +// +// DocumentContext DocumentContext { +// get; +// set; +// } +// +// public DataProvider (TextEditor editor, DocumentContext documentContext, object tag, Ambience amb) +// { +// this.editor = editor; +// this.DocumentContext = documentContext; +// this.tag = tag; +// this.amb = amb; +// Reset (); +// } +// +// #region IListDataProvider implementation +// public void Reset () +// { +// memberList.Clear (); +// if (tag is IUnresolvedFile) { +// var types = new Stack<IUnresolvedTypeDefinition> (((IUnresolvedFile)tag).TopLevelTypeDefinitions); +// while (types.Count > 0) { +// var type = types.Pop (); +// memberList.Add (type); +// foreach (var innerType in type.NestedTypes) +// types.Push (innerType); +// } +// } else if (tag is IUnresolvedTypeDefinition) { +// memberList.AddRange (((IUnresolvedTypeDefinition)tag).Members); +// } +// memberList.Sort ((x, y) => String.Compare (GetString (amb, x), GetString (amb, y), StringComparison.OrdinalIgnoreCase)); +// } +// +// string GetString (Ambience amb, IUnresolvedEntity x) +// { +// var ctx = new SimpleTypeResolveContext (DocumentContext.Compilation.MainAssembly); +// IEntity rx = null; +// if (x is IUnresolvedMember) +// rx = ((IUnresolvedMember)x).CreateResolved (ctx); +// +// if (tag is IUnresolvedFile) +// return amb.GetString (rx, OutputFlags.IncludeGenerics | OutputFlags.IncludeParameters | OutputFlags.UseFullInnerTypeName | OutputFlags.ReformatDelegates); +// return amb.GetString (rx, OutputFlags.IncludeGenerics | OutputFlags.IncludeParameters | OutputFlags.ReformatDelegates); +// } +// +// public string GetMarkup (int n) +// { +// var m = memberList[n]; +//// if (m.IsObsolete ()) +//// return "<s>" + GLib.Markup.EscapeText (GetString (amb, m)) + "</s>"; +// return GLib.Markup.EscapeText (GetString (amb, m)); +// } +// +// public Xwt.Drawing.Image GetIcon (int n) +// { +// return ImageService.GetIcon (memberList[n].GetStockIcon (), Gtk.IconSize.Menu); +// } +// +// public object GetTag (int n) +// { +// return memberList[n]; +// } +// +// public void ActivateItem (int n) +// { +// var member = memberList[n]; +// var extEditor = editor; +// if (extEditor != null) { +// extEditor.SetCaretLocation (Math.Max (1, member.Region.BeginLine), Math.Max (1, member.Region.BeginColumn), true); +// } +// } +// +// public int IconCount { +// get { +// return memberList.Count; +// } +// } +// #endregion +// } } diff --git a/main/src/addins/CBinding/Parser/Function.cs b/main/src/addins/CBinding/Parser/Function.cs index 09d12dbd21..bae2d94577 100644 --- a/main/src/addins/CBinding/Parser/Function.cs +++ b/main/src/addins/CBinding/Parser/Function.cs @@ -32,11 +32,39 @@ using System; using MonoDevelop.Projects; +using ICSharpCode.NRefactory6.CSharp.Completion; namespace CBinding.Parser { - public class Function : LanguageItem + public class Function : LanguageItem, IParameterHintingData { + #region IParameterHintingData implementation + + public string GetParameterName (int currentParameter) + { + return parameters [currentParameter]; + } + + public Microsoft.CodeAnalysis.ISymbol Symbol { + get { + return null; + } + } + + public int ParameterCount { + get { + return parameters.Length; + } + } + + public bool IsParameterListAllowed { + get { + return false; + } + } + + #endregion + private string[] parameters; private string signature; private bool is_const = false; |