diff options
author | Mike Krüger <mkrueger@novell.com> | 2011-06-16 21:27:11 +0400 |
---|---|---|
committer | Mike Krüger <mkrueger@novell.com> | 2011-06-17 17:04:19 +0400 |
commit | 6282d20c4f5d3f3c75937c32debc1dfef41b7e8c (patch) | |
tree | 4d84a753aeb9b16dd15eb153dfa2da4ec5034d2b /main/src/addins/CBinding | |
parent | 27c71f0005849a491911fa879a0405ccdb3975b9 (diff) |
Translated c binding to new type system.
Diffstat (limited to 'main/src/addins/CBinding')
-rw-r--r-- | main/src/addins/CBinding/CBinding.addin.xml | 10 | ||||
-rw-r--r-- | main/src/addins/CBinding/CBinding.csproj | 4 | ||||
-rw-r--r-- | main/src/addins/CBinding/CLanguageBinding.cs | 17 | ||||
-rw-r--r-- | main/src/addins/CBinding/CppLanguageBinding.cs | 17 | ||||
-rw-r--r-- | main/src/addins/CBinding/Gui/CTextEditorExtension.cs | 108 | ||||
-rw-r--r-- | main/src/addins/CBinding/Makefile.am | 1 | ||||
-rw-r--r-- | main/src/addins/CBinding/ObjCLanguageBinding.cs | 17 | ||||
-rw-r--r-- | main/src/addins/CBinding/ObjCppLanguageBinding.cs | 19 | ||||
-rw-r--r-- | main/src/addins/CBinding/Parser/CDocumentParser.cs | 130 | ||||
-rw-r--r-- | main/src/addins/CBinding/Parser/CompilationUnitDataProvider.cs | 13 | ||||
-rw-r--r-- | main/src/addins/CBinding/Parser/DataProvider.cs | 64 |
11 files changed, 184 insertions, 216 deletions
diff --git a/main/src/addins/CBinding/CBinding.addin.xml b/main/src/addins/CBinding/CBinding.addin.xml index 12125e4da2..29ec2a9aa5 100644 --- a/main/src/addins/CBinding/CBinding.addin.xml +++ b/main/src/addins/CBinding/CBinding.addin.xml @@ -250,9 +250,13 @@ </Module> --> - <Extension path = "/MonoDevelop/ProjectModel/DomParser"> - <Parser class = "CBinding.Parser.CDocumentParser" id = "CDocumentParser" - fileExtensions=".c,.cpp,.cxx,.cc,.h,.hpp,.hh,.hxx,.m,.mm,.M" /> + <Extension path = "/MonoDevelop/Ide/TypeSystemProvider"> + <Provider class="CBinding.Parser.CDocumentParser" mimeType = "text/x-csrc" /> + <Provider class="CBinding.Parser.CDocumentParser" mimeType = "text/x-chdr" /> + <Provider class="CBinding.Parser.CDocumentParser" mimeType = "text/x-c++src" /> + <Provider class="CBinding.Parser.CDocumentParser" mimeType = "text/x-c++hdr" /> + <Provider class="CBinding.Parser.CDocumentParser" mimeType = "text/x-objcsrc" /> + <Provider class="CBinding.Parser.CDocumentParser" mimeType = "text/x-objc++src" /> </Extension> <Extension path="/MonoDevelop/SourceEditor2/ContextMenu/Editor"> diff --git a/main/src/addins/CBinding/CBinding.csproj b/main/src/addins/CBinding/CBinding.csproj index c06fcfb5e4..035fecc2ac 100644 --- a/main/src/addins/CBinding/CBinding.csproj +++ b/main/src/addins/CBinding/CBinding.csproj @@ -100,6 +100,10 @@ <Project>{100568FC-F4E8-439B-94AD-41D11724E45B}</Project> <Name>MonoDevelop.Refactoring</Name> </ProjectReference> + <ProjectReference Include="..\..\..\contrib\ICSharpCode.NRefactory\ICSharpCode.NRefactory.csproj"> + <Project>{3B2A5653-EC97-4001-BB9B-D90F1AF2C371}</Project> + <Name>ICSharpCode.NRefactory</Name> + </ProjectReference> </ItemGroup> <ItemGroup> <None Include="Makefile.am" /> diff --git a/main/src/addins/CBinding/CLanguageBinding.cs b/main/src/addins/CBinding/CLanguageBinding.cs index f84a59665e..ca0c3d91ac 100644 --- a/main/src/addins/CBinding/CLanguageBinding.cs +++ b/main/src/addins/CBinding/CLanguageBinding.cs @@ -36,9 +36,6 @@ using Mono.Addins; using MonoDevelop.Projects; using MonoDevelop.Core; -using MonoDevelop.Projects.Dom; -using MonoDevelop.Projects.Dom.Parser; -using MonoDevelop.Projects.CodeGeneration; namespace CBinding { @@ -52,20 +49,12 @@ namespace CBinding public string BlockCommentStartTag { get { return "/*"; } } public string BlockCommentEndTag { get { return "*/"; } } - public bool IsSourceCodeFile (string fileName) + public bool IsSourceCodeFile (FilePath fileName) { - return fileName.EndsWith (".c", StringComparison.OrdinalIgnoreCase); + return fileName.ToString ().EndsWith (".c", StringComparison.OrdinalIgnoreCase); } - public IParser Parser { - get { return null; } - } - - public IRefactorer Refactorer { - get { return null; } - } - - public string GetFileName (string baseName) + public FilePath GetFileName (FilePath baseName) { return baseName + ".c"; } diff --git a/main/src/addins/CBinding/CppLanguageBinding.cs b/main/src/addins/CBinding/CppLanguageBinding.cs index bf3557523b..3054db393c 100644 --- a/main/src/addins/CBinding/CppLanguageBinding.cs +++ b/main/src/addins/CBinding/CppLanguageBinding.cs @@ -33,9 +33,6 @@ using Mono.Addins; using MonoDevelop.Projects; using MonoDevelop.Core; -using MonoDevelop.Projects.Dom; -using MonoDevelop.Projects.Dom.Parser; -using MonoDevelop.Projects.CodeGeneration; namespace CBinding { @@ -49,20 +46,12 @@ namespace CBinding public string BlockCommentStartTag { get { return "/*"; } } public string BlockCommentEndTag { get { return "*/"; } } - public bool IsSourceCodeFile (string fileName) + public bool IsSourceCodeFile (FilePath fileName) { - return fileName.EndsWith (".cpp", StringComparison.OrdinalIgnoreCase); + return fileName.ToString ().EndsWith (".cpp", StringComparison.OrdinalIgnoreCase); } - public IParser Parser { - get { return null; } - } - - public IRefactorer Refactorer { - get { return null; } - } - - public string GetFileName (string baseName) + public FilePath GetFileName (FilePath baseName) { return baseName + ".cpp"; } diff --git a/main/src/addins/CBinding/Gui/CTextEditorExtension.cs b/main/src/addins/CBinding/Gui/CTextEditorExtension.cs index 406e9ea1f4..5f9a2b349c 100644 --- a/main/src/addins/CBinding/Gui/CTextEditorExtension.cs +++ b/main/src/addins/CBinding/Gui/CTextEditorExtension.cs @@ -40,13 +40,13 @@ using MonoDevelop.Ide; using MonoDevelop.Ide.Gui; using MonoDevelop.Ide.Gui.Content; using MonoDevelop.Ide.CodeCompletion; -using MonoDevelop.Projects.Dom; -using MonoDevelop.Projects.Dom.Output; using MonoDevelop.Components; using MonoDevelop.Components.Commands; using CBinding.Parser; using Mono.TextEditor; +using MonoDevelop.TypeSystem; +using ICSharpCode.NRefactory.TypeSystem; namespace CBinding { @@ -647,7 +647,7 @@ namespace CBinding object tag = path[index].Tag; DropDownBoxListWindow.IListDataProvider provider = null; - if (tag is ICompilationUnit) { + if (tag is ParsedDocument) { provider = new CompilationUnitDataProvider (Document); } else { provider = new DataProvider (Document, tag, GetAmbience ()); @@ -674,56 +674,38 @@ namespace CBinding // Yoinked from C# binding void UpdatePath (object sender, Mono.TextEditor.DocumentLocationEventArgs e) { - var unit = Document.CompilationUnit; + var unit = Document.ParsedFile; if (unit == null) return; - - var loc = textEditorData.Caret.Location; - IType type = unit.GetTypeAt (loc.Line, loc.Column); - List<PathEntry> result = new List<PathEntry> (); - Ambience amb = GetAmbience (); - IMember member = null; - INode node = (INode)unit; - - if (type != null && type.ClassType != ClassType.Delegate) { - member = type.GetMemberAt (loc.Line, loc.Column); - } - if (null != member) { - node = member; - } else if (null != type) { - node = type; + var loc = Document.Editor.Caret.Location; + + var result = new List<PathEntry> (); + var amb = GetAmbience (); + + var type = unit.GetTypeDefinition (loc.Line, loc.Column) ?? unit.TopLevelTypeDefinitions.FirstOrDefault (); + var curType = type; + object lastTag = unit; + while (curType != null) { + var markup = amb.GetString (curType, OutputFlags.IncludeGenerics | OutputFlags.IncludeParameters | OutputFlags.ReformatDelegates | OutputFlags.IncludeMarkup); + result.Insert (0, new PathEntry (ImageService.GetPixbuf (type.GetStockIcon (), Gtk.IconSize.Menu), curType.IsObsolete () ? "<s>" + markup + "</s>" : markup) { Tag = lastTag }); + lastTag = curType; + curType = curType.DeclaringTypeDefinition; } - while (node != null) { - PathEntry entry; - if (node is ICompilationUnit) { - if (!Document.ParsedDocument.UserRegions.Any ()) - break; - FoldingRegion reg = Document.ParsedDocument.UserRegions.Where (r => r.Region.Contains (loc.Line, loc.Column)).LastOrDefault (); - if (reg == null) { - entry = new PathEntry (GettextCatalog.GetString ("No region")); - } else { - entry = new PathEntry (CompilationUnitDataProvider.Pixbuf, GLib.Markup.EscapeText (reg.Name)); - } - entry.Position = EntryPosition.Right; - } else { - entry = new PathEntry (ImageService.GetPixbuf (((IMember)node).StockIcon, Gtk.IconSize.Menu), amb.GetString ((IMember)node, OutputFlags.IncludeGenerics | OutputFlags.IncludeParameters | OutputFlags.ReformatDelegates | OutputFlags.IncludeMarkup)); - } - entry.Tag = node; - result.Insert (0, entry); - node = node.Parent; + var member = type.Members.FirstOrDefault (m => m.Region.IsInside (loc.Line, loc.Column)); + if (member != null) { + var markup = amb.GetString (member, OutputFlags.IncludeGenerics | OutputFlags.IncludeParameters | OutputFlags.ReformatDelegates | OutputFlags.IncludeMarkup); + result.Add (new PathEntry (ImageService.GetPixbuf (member.GetStockIcon (), Gtk.IconSize.Menu), member.IsObsolete () ? "<s>" + markup + "</s>" : markup) { Tag = lastTag }); } PathEntry noSelection = null; if (type == null) { - noSelection = new PathEntry (GettextCatalog.GetString ("No selection")) { Tag = new CustomNode (Document.CompilationUnit) }; - } else if (member == null && type.ClassType != ClassType.Delegate) - noSelection = new PathEntry (GettextCatalog.GetString ("No selection")) { Tag = new CustomNode (type) }; - if (noSelection != null) { + noSelection = new PathEntry (GettextCatalog.GetString ("No selection")) { Tag = unit }; + } else if (member == null && !type.IsDelegate ()) + noSelection = new PathEntry (GettextCatalog.GetString ("No selection")) { Tag = type }; + if (noSelection != null) result.Add (noSelection); - } - var prev = CurrentPath; CurrentPath = result.ToArray (); OnPathChanged (new DocumentPathChangedEventArgs (prev)); @@ -738,15 +720,6 @@ namespace CBinding Document.DocumentParsed += delegate { UpdatePath (null, null); }; } - // Yoinked from C# binding - class CustomNode : MonoDevelop.Projects.Dom.AbstractNode - { - public CustomNode (INode parent) - { - this.Parent = parent; - } - } - /// <summary> /// Move the completion trigger offset to the beginning of the current token /// </summary> @@ -761,21 +734,22 @@ namespace CBinding completionContext.TriggerOffset = i-1; return accumulator+1; }// ResetTriggerOffset - - [CommandHandler (MonoDevelop.Refactoring.RefactoryCommands.GotoDeclaration)] - public void GotoDeclaration () - { - LanguageItem item = GetLanguageItemAt (Editor.Caret.Location); - if (item != null) - IdeApp.Workbench.OpenDocument ((FilePath)item.File, (int)item.Line, 1); - } - - [CommandUpdateHandler (MonoDevelop.Refactoring.RefactoryCommands.GotoDeclaration)] - public void CanGotoDeclaration (CommandInfo item) - { - item.Visible = (GetLanguageItemAt (Editor.Caret.Location) != null); - item.Bypass = !item.Visible; - } + +// TODO: Type system conversion +// [CommandHandler (MonoDevelop.Refactoring.RefactoryCommands.GotoDeclaration)] +// public void GotoDeclaration () +// { +// LanguageItem item = GetLanguageItemAt (Editor.Caret.Location); +// if (item != null) +// IdeApp.Workbench.OpenDocument ((FilePath)item.File, (int)item.Line, 1); +// } +// +// [CommandUpdateHandler (MonoDevelop.Refactoring.RefactoryCommands.GotoDeclaration)] +// public void CanGotoDeclaration (CommandInfo item) +// { +// item.Visible = (GetLanguageItemAt (Editor.Caret.Location) != null); +// item.Bypass = !item.Visible; +// } private LanguageItem GetLanguageItemAt (DocumentLocation location) { diff --git a/main/src/addins/CBinding/Makefile.am b/main/src/addins/CBinding/Makefile.am index 45811c41fc..82b5caa4d9 100644 --- a/main/src/addins/CBinding/Makefile.am +++ b/main/src/addins/CBinding/Makefile.am @@ -8,6 +8,7 @@ DEPS = \ $(top_builddir)/build/AddIns/MonoDevelop.DesignerSupport/MonoDevelop.DesignerSupport.dll \ $(top_builddir)/build/AddIns/MonoDevelop.Refactoring/MonoDevelop.Refactoring.dll \ $(top_builddir)/build/AddIns/MonoDevelop.SourceEditor2.dll \ + $(top_builddir)/build/bin/ICSharpCode.NRefactory.dll \ $(top_builddir)/build/bin/Mono.TextEditor.dll \ $(top_builddir)/build/bin/MonoDevelop.Core.dll \ $(top_builddir)/build/bin/MonoDevelop.Ide.dll diff --git a/main/src/addins/CBinding/ObjCLanguageBinding.cs b/main/src/addins/CBinding/ObjCLanguageBinding.cs index 696752eac7..13bb348c35 100644 --- a/main/src/addins/CBinding/ObjCLanguageBinding.cs +++ b/main/src/addins/CBinding/ObjCLanguageBinding.cs @@ -36,9 +36,6 @@ using Mono.Addins; using MonoDevelop.Projects; using MonoDevelop.Core; -using MonoDevelop.Projects.Dom; -using MonoDevelop.Projects.Dom.Parser; -using MonoDevelop.Projects.CodeGeneration; namespace CBinding { @@ -52,20 +49,12 @@ namespace CBinding public string BlockCommentStartTag { get { return "/*"; } } public string BlockCommentEndTag { get { return "*/"; } } - public bool IsSourceCodeFile (string fileName) + public bool IsSourceCodeFile (FilePath fileName) { - return fileName.EndsWith (".m", StringComparison.Ordinal); + return fileName.ToString ().EndsWith (".m", StringComparison.Ordinal); } - public IParser Parser { - get { return null; } - } - - public IRefactorer Refactorer { - get { return null; } - } - - public string GetFileName (string baseName) + public FilePath GetFileName (FilePath baseName) { return baseName + ".m"; } diff --git a/main/src/addins/CBinding/ObjCppLanguageBinding.cs b/main/src/addins/CBinding/ObjCppLanguageBinding.cs index 0f29f530d1..7581260bcb 100644 --- a/main/src/addins/CBinding/ObjCppLanguageBinding.cs +++ b/main/src/addins/CBinding/ObjCppLanguageBinding.cs @@ -36,9 +36,6 @@ using Mono.Addins; using MonoDevelop.Projects; using MonoDevelop.Core; -using MonoDevelop.Projects.Dom; -using MonoDevelop.Projects.Dom.Parser; -using MonoDevelop.Projects.CodeGeneration; namespace CBinding { @@ -52,21 +49,13 @@ namespace CBinding public string BlockCommentStartTag { get { return "/*"; } } public string BlockCommentEndTag { get { return "*/"; } } - public bool IsSourceCodeFile (string fileName) + public bool IsSourceCodeFile (FilePath fileName) { - return fileName.EndsWith (".mm", StringComparison.OrdinalIgnoreCase) || - fileName.EndsWith (".M", StringComparison.Ordinal); + return fileName.ToString ().EndsWith (".mm", StringComparison.OrdinalIgnoreCase) || + fileName.ToString ().EndsWith (".M", StringComparison.Ordinal); } - public IParser Parser { - get { return null; } - } - - public IRefactorer Refactorer { - get { return null; } - } - - public string GetFileName (string baseName) + public FilePath GetFileName (FilePath baseName) { return baseName + ".mm"; } diff --git a/main/src/addins/CBinding/Parser/CDocumentParser.cs b/main/src/addins/CBinding/Parser/CDocumentParser.cs index ecf46233d3..9bc86da6e9 100644 --- a/main/src/addins/CBinding/Parser/CDocumentParser.cs +++ b/main/src/addins/CBinding/Parser/CDocumentParser.cs @@ -31,54 +31,50 @@ using System.Text.RegularExpressions; using MonoDevelop.Core; using MonoDevelop.Projects; -using MonoDevelop.Projects.Dom; -using MonoDevelop.Projects.Dom.Parser; using MonoDevelop.Ide; +using MonoDevelop.TypeSystem; +using ICSharpCode.NRefactory.TypeSystem; +using ICSharpCode.NRefactory.TypeSystem.Implementation; namespace CBinding.Parser { /// <summary> /// Ctags-based document parser helper /// </summary> - public class CDocumentParser: AbstractParser + public class CDocumentParser: AbstractTypeSystemProvider { - public override ParsedDocument Parse (ProjectDom dom, string fileName, string content) + public override ParsedDocument Parse (IProjectContent dom, bool storeAst, string fileName, TextReader reader) { - ParsedDocument doc = new ParsedDocument (fileName); - doc.Flags |= ParsedDocumentFlags.NonSerializable; - Project p = (null == dom || null == dom.Project)? + var doc = new DefaultParsedDocument (fileName); +// doc.Flags |= ParsedDocumentFlags.NonSerializable; + Project p = (null == dom || null == dom.GetProject ())? IdeApp.Workspace.GetProjectContainingFile (fileName): - dom.Project; + dom.GetProject (); ProjectInformation pi = ProjectInformationManager.Instance.Get (p); - CompilationUnit cu; - doc.CompilationUnit = cu = new CompilationUnit (fileName); - IType tmp; - IMember member; + + string content = reader.ReadToEnd (); string[] contentLines = content.Split (new string[]{Environment.NewLine}, StringSplitOptions.None); - DomType globals = new DomType (cu, ClassType.Unknown, GettextCatalog.GetString ("(Global Scope)"), new DomLocation (1, 1), string.Empty, new DomRegion (1, int.MaxValue), new List<IMember> ()); + var globals = new DefaultTypeDefinition (dom, "", GettextCatalog.GetString ("(Global Scope)")); lock (pi) { // Add containers to type list foreach (LanguageItem li in pi.Containers ()) { if (null == li.Parent && FilePath.Equals (li.File, fileName)) { - tmp = LanguageItemToIMember (pi, li, contentLines) as IType; - if (null != tmp){ cu.Add (tmp); } + var tmp = AddLanguageItem (dom, pi, globals, li, contentLines) as ITypeDefinition; + if (null != tmp){ doc.TopLevelTypeDefinitions.Add (tmp); } } } // Add global category for unscoped symbols foreach (LanguageItem li in pi.InstanceMembers ()) { if (null == li.Parent && FilePath.Equals (li.File, fileName)) { - member = LanguageItemToIMember (pi, li, contentLines); - if (null != member) { - globals.Add (member); - } + AddLanguageItem (dom, pi, globals, li, contentLines); } } } - cu.Add (globals); - + doc.TopLevelTypeDefinitions.Add (globals); + Console.WriteLine (doc.TopLevelTypeDefinitions.Count); return doc; } @@ -150,6 +146,26 @@ namespace CBinding.Parser static readonly Regex paramExpression = new Regex (@"(?<type>[^\s]+)\s+(?<subtype>[*&]*)(?<name>[^\s[]+)(?<array>\[.*)?", RegexOptions.Compiled); + static object AddLanguageItem (IProjectContent dom, ProjectInformation pi, DefaultTypeDefinition klass, LanguageItem li, string[] contentLines) + { + + if (li is Class || li is Structure || li is Enumeration) { + var type = LanguageItemToIType (dom, pi, li, contentLines); + klass.InnerClasses.Add (type); + return type; + } + + if (li is Function) { + var method = FunctionToIMethod (pi, klass, (Function)li, contentLines); + klass.Methods.Add (method); + return method; + } + + var field = LanguageItemToIField (klass, li, contentLines); + klass.Fields.Add (field); + return field; + } + /// <summary> /// Create an IMember from a LanguageItem, /// using the source document to locate declaration bounds. @@ -163,46 +179,54 @@ namespace CBinding.Parser /// <param name="contentLines"> /// A <see cref="System.String[]"/>: The document in which item is defined. /// </param> - static IMember LanguageItemToIMember (ProjectInformation pi, LanguageItem item, string[] contentLines) + static DefaultTypeDefinition LanguageItemToIType (IProjectContent content, ProjectInformation pi, LanguageItem item, string[] contentLines) { + var klass = new DefaultTypeDefinition (content, "", item.File); if (item is Class || item is Structure) { - DomType klass = new DomType (new CompilationUnit (item.File), ClassType.Class, item.Name, new DomLocation ((int)item.Line, 1), string.Empty, new DomRegion ((int)item.Line+1, FindFunctionEnd (contentLines, (int)item.Line-1)+2), new List<IMember> ()); - + klass.Region = new DomRegion ((int)item.Line, 1, FindFunctionEnd (contentLines, (int)item.Line-1) + 2, 1); + klass.ClassType = item is Class ? ClassType.Class : ClassType.Struct; foreach (LanguageItem li in pi.AllItems ()) { - if (klass.Equals (li.Parent) && FilePath.Equals (li.File, item.File)) { - klass.Add (LanguageItemToIMember (pi, li, contentLines)); - } + if (klass.Equals (li.Parent) && FilePath.Equals (li.File, item.File)) + AddLanguageItem (content, pi, klass, li, contentLines); } return klass; } - if (item is Enumeration) { - return new DomType (new CompilationUnit (item.File), ClassType.Enum, item.Name, new DomLocation ((int)item.Line, 1), string.Empty, new DomRegion ((int)item.Line+1, (int)item.Line+1), new List<IMember> ()); - } - if (item is Function) { - DomMethod method = new DomMethod (item.Name, Modifiers.None, MethodModifier.None, new DomLocation ((int)item.Line, 1), new DomRegion ((int)item.Line+1, FindFunctionEnd (contentLines, (int)item.Line-1)+2), new DomReturnType ()); - Function function = (Function)item; - Match match; - bool abort = false; - List<IParameter> parameters = new List<IParameter> (); - - foreach (string parameter in function.Parameters) { - match = paramExpression.Match (parameter); - if (null == match) { - abort = true; - break; - } - DomParameter p = (new DomParameter (method, match.Groups["name"].Value, - new DomReturnType (string.Format ("{0}{1}{2}", match.Groups["type"].Value, match.Groups["subtype"].Value, match.Groups["array"].Value)))); - parameters.Add (p); + + klass.Region = new DomRegion ((int)item.Line, 1, (int)item.Line + 1, 1); + klass.ClassType = ClassType.Enum; + return klass; + } + + static IField LanguageItemToIField (ITypeDefinition type, LanguageItem item, string[] contentLines) + { + var result = new DefaultField (type, item.Name); + result.Region = new DomRegion ((int)item.Line, 1, (int)item.Line + 1, 1); + return result; + } + + static IMethod FunctionToIMethod (ProjectInformation pi, ITypeDefinition type, Function function, string[] contentLines) + { + var method = new DefaultMethod (type, function.Name); + method.Region = new DomRegion ((int)function.Line, 1, FindFunctionEnd (contentLines, (int)function.Line-1)+2, 1); + + Match match; + bool abort = false; + var parameters = new List<IParameter> (); + foreach (string parameter in function.Parameters) { + match = paramExpression.Match (parameter); + if (null == match) { + abort = true; + break; } - if (!abort) - method.Add (parameters); - return method; + var typeRef = new GetClassTypeReference (string.Format ("{0}{1}{2}", match.Groups["type"].Value, match.Groups["subtype"].Value, match.Groups["array"].Value), 0); + var p = new DefaultParameter (typeRef, match.Groups["name"].Value); + parameters.Add (p); } - if (item is Member) { - return new DomField (item.Name, Modifiers.None, new DomLocation ((int)item.Line, 1), new DomReturnType ()); - } - return null; + if (!abort) + parameters.ForEach (p => method.Parameters.Add (p)); + return method; } + + } } diff --git a/main/src/addins/CBinding/Parser/CompilationUnitDataProvider.cs b/main/src/addins/CBinding/Parser/CompilationUnitDataProvider.cs index 8aa03d35e0..69d22e8ad6 100644 --- a/main/src/addins/CBinding/Parser/CompilationUnitDataProvider.cs +++ b/main/src/addins/CBinding/Parser/CompilationUnitDataProvider.cs @@ -35,7 +35,6 @@ using MonoDevelop.Ide.Gui; using MonoDevelop.Ide.Gui.Content; using MonoDevelop.Ide.CodeCompletion; using MonoDevelop.Components; -using MonoDevelop.Projects.Dom; using Gtk; @@ -56,7 +55,7 @@ namespace CBinding.Parser public string GetMarkup (int n) { - return GLib.Markup.EscapeText (Document.ParsedDocument.UserRegions.ElementAt (n).Name); + return GLib.Markup.EscapeText (Document.ParsedFile.UserRegions.ElementAt (n).Name); } internal static Gdk.Pixbuf Pixbuf @@ -71,24 +70,24 @@ namespace CBinding.Parser public object GetTag (int n) { - return Document.ParsedDocument.UserRegions.ElementAt (n); + return Document.ParsedFile.UserRegions.ElementAt (n); } public void ActivateItem (int n) { - var reg = Document.ParsedDocument.UserRegions.ElementAt (n); + var reg = Document.ParsedFile.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.Start.Line), reg.Region.Start.Column); + extEditor.SetCaretTo (Math.Max (1, reg.Region.BeginLine), reg.Region.BeginColumn); } public int IconCount { get { - if (Document.ParsedDocument == null) + if (Document.ParsedFile == null) return 0; - return Document.ParsedDocument.UserRegions.Count (); + return Document.ParsedFile.UserRegions.Count (); } } diff --git a/main/src/addins/CBinding/Parser/DataProvider.cs b/main/src/addins/CBinding/Parser/DataProvider.cs index e102a39302..dd9bd8e43e 100644 --- a/main/src/addins/CBinding/Parser/DataProvider.cs +++ b/main/src/addins/CBinding/Parser/DataProvider.cs @@ -35,10 +35,10 @@ using MonoDevelop.Ide.Gui; using MonoDevelop.Ide.Gui.Content; using MonoDevelop.Ide.CodeCompletion; using MonoDevelop.Components; -using MonoDevelop.Projects.Dom; -using MonoDevelop.Projects.Dom.Output; using Gtk; +using MonoDevelop.TypeSystem; +using ICSharpCode.NRefactory.TypeSystem; namespace CBinding.Parser { @@ -47,72 +47,78 @@ namespace CBinding.Parser { object tag; Ambience amb; - List<IMember> memberList = new List<IMember> (); + List<IEntity> memberList = new List<IEntity> (); - Document Document { get; set; } + Document Document { + get; + set; + } public DataProvider (Document doc, object tag, Ambience amb) { this.Document = doc; - this.tag = ((INode)tag).Parent; + this.tag = tag; this.amb = amb; Reset (); - }// constructor + } #region IListDataProvider implementation public void Reset () { memberList.Clear (); - if (tag is ICompilationUnit) { - Stack<IType> types = new Stack<IType> (((ICompilationUnit)tag).Types); + if (tag is IParsedFile) { + var types = new Stack<ITypeDefinition> (((IParsedFile)tag).TopLevelTypeDefinitions); while (types.Count > 0) { - IType type = types.Pop (); + var type = types.Pop (); memberList.Add (type); - foreach (IType innerType in type.InnerTypes) + foreach (var innerType in type.InnerClasses) types.Push (innerType); } - } else if (tag is IType) { - memberList.AddRange (((IType)tag).Members); + } else if (tag is ITypeDefinition) { + memberList.AddRange (((ITypeDefinition)tag).Members); } memberList.Sort ((x, y) => String.Compare (GetString (amb, x), GetString (amb, y), StringComparison.OrdinalIgnoreCase)); - }// Reset + } - string GetString (Ambience amb, IMember x) + string GetString (Ambience amb, IEntity x) { - if (tag is ICompilationUnit) + if (tag is IParsedFile) return amb.GetString (x, OutputFlags.IncludeGenerics | OutputFlags.IncludeParameters | OutputFlags.UseFullInnerTypeName | OutputFlags.ReformatDelegates); return amb.GetString (x, OutputFlags.IncludeGenerics | OutputFlags.IncludeParameters | OutputFlags.ReformatDelegates); - }// GetString + } public string GetMarkup (int n) { - return GLib.Markup.EscapeText (GetString (amb, memberList[n])); - }// GetText - + var m = memberList[n]; + if (m.IsObsolete ()) + return "<s>" + GLib.Markup.EscapeText (GetString (amb, m)) + "</s>"; + return GLib.Markup.EscapeText (GetString (amb, m)); + } + public Gdk.Pixbuf GetIcon (int n) { - return ImageService.GetPixbuf (memberList[n].StockIcon, IconSize.Menu); - }// GetIcon - + return ImageService.GetPixbuf (memberList[n].GetStockIcon (), Gtk.IconSize.Menu); + } + public object GetTag (int n) { return memberList[n]; - }// GetTag - + } + 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.Location.Line), member.Location.Column); - }// ActivateItem - + extEditor.SetCaretTo (Math.Max (1, member.Region.BeginLine), Math.Max (1, member.Region.BeginColumn)); + } + public int IconCount { get { return memberList.Count; } - }// IconCount + } #endregion - }// DataProvider + } } |