diff options
author | Michael Hutchinson <m.j.hutchinson@gmail.com> | 2013-02-27 03:06:29 +0400 |
---|---|---|
committer | Michael Hutchinson <m.j.hutchinson@gmail.com> | 2013-02-27 03:06:29 +0400 |
commit | da7ef84fcf8a5391b862209406be69b2303b6d55 (patch) | |
tree | 15935c29cd2dd96ddb9c4c4e57f0b9f34071db53 /extras/ValaBinding | |
parent | 5275b9c408deb42761b892d7cdca38f64cffc895 (diff) | |
parent | b74f35042804180b3ca08fb68dcb17deb2878bbf (diff) |
Merge pull request #118 from severinh/master
Update Vala bindings in response to recent changes in afrodite's API (vtg 0.12.1)
Diffstat (limited to 'extras/ValaBinding')
-rw-r--r-- | extras/ValaBinding/Navigation/LanguageItemNodeBuilder.cs | 4 | ||||
-rw-r--r-- | extras/ValaBinding/Parser/Afrodite.cs | 100 | ||||
-rw-r--r-- | extras/ValaBinding/Parser/ProjectInformation.cs | 41 | ||||
-rw-r--r-- | extras/ValaBinding/Parser/ValaDocumentParser.cs | 4 |
4 files changed, 75 insertions, 74 deletions
diff --git a/extras/ValaBinding/Navigation/LanguageItemNodeBuilder.cs b/extras/ValaBinding/Navigation/LanguageItemNodeBuilder.cs index 0b6f7fc7e1..12fd10b0c1 100644 --- a/extras/ValaBinding/Navigation/LanguageItemNodeBuilder.cs +++ b/extras/ValaBinding/Navigation/LanguageItemNodeBuilder.cs @@ -102,8 +102,8 @@ namespace MonoDevelop.ValaBinding.Navigation otherCN = otherNode.DataItem as Symbol; if (null != thisCN && null != otherCN) { - return Array.IndexOf<string>(types, thisCN.SymbolType) - - Array.IndexOf<string>(types, otherCN.SymbolType); + return Array.IndexOf<string>(types, thisCN.MemberType) - + Array.IndexOf<string>(types, otherCN.MemberType); } } diff --git a/extras/ValaBinding/Parser/Afrodite.cs b/extras/ValaBinding/Parser/Afrodite.cs index dd2b8d3a94..6eaeec2d5c 100644 --- a/extras/ValaBinding/Parser/Afrodite.cs +++ b/extras/ValaBinding/Parser/Afrodite.cs @@ -38,7 +38,7 @@ using MonoDevelop.Ide.Gui; namespace MonoDevelop.ValaBinding.Parser.Afrodite { /// <summary> - /// Afrodite completion engine - interface for queueing source and getting ASTs + /// Afrodite completion engine - interface for queueing source and getting CodeDOMs /// </summary> internal class CompletionEngine { @@ -64,21 +64,21 @@ namespace MonoDevelop.ValaBinding.Parser.Afrodite } /// <summary> - /// Attempt to acquire the current AST + /// Attempt to acquire the current CodeDOM /// </summary> /// <returns> - /// A <see cref="Ast"/>: null if unable to acquire + /// A <see cref="CodeDom"/>: null if unable to acquire /// </returns> - public Ast TryAcquireAst () + public CodeDom TryAcquireCodeDom () { - IntPtr ast = afrodite_completion_engine_get_ast (instance); - return (ast == IntPtr.Zero)? null: new Ast (ast, this); + IntPtr codeDom = afrodite_completion_engine_get_codedom (instance); + return (codeDom == IntPtr.Zero)? null: new CodeDom (codeDom, this); } /// <summary> - /// Release the given AST (required for continued parsing) + /// Release the given CodeDOM (required for continued parsing) /// </summary> - public void ReleaseAst (Ast ast) + public void ReleaseCodeDom (CodeDom codeDom) { // Obsolete } @@ -95,7 +95,7 @@ namespace MonoDevelop.ValaBinding.Parser.Afrodite bool is_vapi, bool is_glib); [DllImport("afrodite")] - static extern IntPtr afrodite_completion_engine_get_ast (IntPtr instance); + static extern IntPtr afrodite_completion_engine_get_codedom (IntPtr instance); #endregion } @@ -129,10 +129,10 @@ namespace MonoDevelop.ValaBinding.Parser.Afrodite /// <summary> /// The type of this symbol /// </summary> - public DataType DataType { + public DataType SymbolType { get { - IntPtr datatype = afrodite_symbol_get_symbol_data_type (instance); - return (IntPtr.Zero == datatype)? null: new DataType (afrodite_symbol_get_symbol_data_type (instance)); + IntPtr datatype = afrodite_symbol_get_symbol_type (instance); + return (IntPtr.Zero == datatype)? null: new DataType (afrodite_symbol_get_symbol_type (instance)); } } @@ -142,7 +142,7 @@ namespace MonoDevelop.ValaBinding.Parser.Afrodite public DataType ReturnType { get { IntPtr datatype = afrodite_symbol_get_return_type (instance); - return (IntPtr.Zero == datatype)? null: new DataType (afrodite_symbol_get_symbol_data_type (instance)); + return (IntPtr.Zero == datatype)? null: new DataType (afrodite_symbol_get_return_type (instance)); } } @@ -189,8 +189,8 @@ namespace MonoDevelop.ValaBinding.Parser.Afrodite /// <summary> /// The symbol type (class, method, ...) of this symbol /// </summary> - public string SymbolType { - get{ return Utils.GetSymbolType (afrodite_symbol_get_symbol_type (instance)); } + public string MemberType { + get{ return Utils.GetMemberType (afrodite_symbol_get_member_type (instance)); } } /// <summary> @@ -220,7 +220,7 @@ namespace MonoDevelop.ValaBinding.Parser.Afrodite /// The icon to be used for this symbol /// </summary> public string Icon { - get{ return GetIconForType (SymbolType, Accessibility); } + get{ return GetIconForType (MemberType, Accessibility); } } /// <summary> @@ -352,10 +352,10 @@ namespace MonoDevelop.ValaBinding.Parser.Afrodite static extern IntPtr afrodite_symbol_get_parameters (IntPtr instance); [DllImport("afrodite")] - static extern int afrodite_symbol_get_symbol_type (IntPtr instance); + static extern int afrodite_symbol_get_member_type (IntPtr instance); [DllImport("afrodite")] - static extern IntPtr afrodite_symbol_get_symbol_data_type (IntPtr instance); + static extern IntPtr afrodite_symbol_get_symbol_type (IntPtr instance); [DllImport("afrodite")] static extern IntPtr afrodite_symbol_get_return_type (IntPtr instance); @@ -364,25 +364,25 @@ namespace MonoDevelop.ValaBinding.Parser.Afrodite } /// <summary> - /// Represents a Vala AST + /// Represents a Vala CodeDOM /// </summary> /// <remarks> /// MUST be disposed for parsing to continue /// </remarks> - internal class Ast: IDisposable + internal class CodeDom: IDisposable { CompletionEngine engine; /// <summary> - /// Create a new AST wrapper + /// Create a new CodeDOM wrapper /// </summary> /// <param name="instance"> - /// A <see cref="IntPtr"/>: The native pointer for this AST + /// A <see cref="IntPtr"/>: The native pointer for this CodeDOM /// </param> /// <param name="engine"> - /// A <see cref="CompletionEngine"/>: The completion engine to which this AST belongs + /// A <see cref="CompletionEngine"/>: The completion engine to which this CodeDOM belongs /// </param> - public Ast (IntPtr instance, CompletionEngine engine) + public CodeDom (IntPtr instance, CompletionEngine engine) { this.instance = instance; this.engine = engine; @@ -390,7 +390,7 @@ namespace MonoDevelop.ValaBinding.Parser.Afrodite public QueryResult GetSymbolsForPath (string path) { - return new QueryResult (afrodite_ast_get_symbols_for_path (instance, new QueryOptions ().Instance, path)); + return new QueryResult (afrodite_code_dom_get_symbols_for_path (instance, new QueryOptions ().Instance, path)); } /// <summary> @@ -398,7 +398,7 @@ namespace MonoDevelop.ValaBinding.Parser.Afrodite /// </summary> public Symbol LookupSymbolAt (string filename, int line, int column) { - IntPtr symbol = afrodite_ast_lookup_symbol_at (instance, filename, line, column); + IntPtr symbol = afrodite_code_dom_lookup_symbol_at (instance, filename, line, column); return (IntPtr.Zero == symbol)? null: new Symbol (symbol); } @@ -410,7 +410,7 @@ namespace MonoDevelop.ValaBinding.Parser.Afrodite IntPtr parentInstance = IntPtr.Zero, result = IntPtr.Zero; - result = afrodite_ast_lookup (instance, fully_qualified_name, out parentInstance); + result = afrodite_code_dom_lookup (instance, fully_qualified_name, out parentInstance); parent = (IntPtr.Zero == parentInstance)? null: new Symbol (parentInstance); return (IntPtr.Zero == result)? null: new Symbol (result); } @@ -420,7 +420,7 @@ namespace MonoDevelop.ValaBinding.Parser.Afrodite /// </summary> public Symbol GetSymbolForNameAndPath (string name, string path, int line, int column) { - IntPtr result = afrodite_ast_get_symbol_for_name_and_path (instance, QueryOptions.Standard ().Instance, + IntPtr result = afrodite_code_dom_get_symbol_for_name_and_path (instance, QueryOptions.Standard ().Instance, name, path, line, column); if (IntPtr.Zero != result) { QueryResult qresult = new QueryResult (result); @@ -432,12 +432,12 @@ namespace MonoDevelop.ValaBinding.Parser.Afrodite } /// <summary> - /// Get the source files used to create this AST + /// Get the source files used to create this CodeDOM /// </summary> public List<SourceFile> SourceFiles { get { List<SourceFile> files = new List<SourceFile> (); - IntPtr sourceFiles = afrodite_ast_get_source_files (instance); + IntPtr sourceFiles = afrodite_code_dom_get_source_files (instance); if (IntPtr.Zero != sourceFiles) { ValaList list = new ValaList (sourceFiles); @@ -453,7 +453,7 @@ namespace MonoDevelop.ValaBinding.Parser.Afrodite /// </summary> public SourceFile LookupSourceFile (string filename) { - IntPtr sourceFile = afrodite_ast_lookup_source_file (instance, filename); + IntPtr sourceFile = afrodite_code_dom_lookup_source_file (instance, filename); return (IntPtr.Zero == sourceFile)? null: new SourceFile (sourceFile); } @@ -466,53 +466,53 @@ namespace MonoDevelop.ValaBinding.Parser.Afrodite } [DllImport("afrodite")] - static extern IntPtr afrodite_ast_get_symbols_for_path (IntPtr instance, IntPtr options, string path); + static extern IntPtr afrodite_code_dom_get_symbols_for_path (IntPtr instance, IntPtr options, string path); [DllImport("afrodite")] - static extern IntPtr afrodite_ast_lookup_symbol_at (IntPtr instance, string filename, int line, int column); + static extern IntPtr afrodite_code_dom_lookup_symbol_at (IntPtr instance, string filename, int line, int column); [DllImport("afrodite")] - static extern IntPtr afrodite_ast_lookup (IntPtr instance, string fully_qualified_name, out IntPtr parent); + static extern IntPtr afrodite_code_dom_lookup (IntPtr instance, string fully_qualified_name, out IntPtr parent); [DllImport("afrodite")] - static extern IntPtr afrodite_ast_get_symbol_for_name_and_path (IntPtr instance, IntPtr options, + static extern IntPtr afrodite_code_dom_get_symbol_for_name_and_path (IntPtr instance, IntPtr options, string symbol_qualified_name, string path, int line, int column); [DllImport("afrodite")] - static extern IntPtr afrodite_ast_get_source_files (IntPtr instance); + static extern IntPtr afrodite_code_dom_get_source_files (IntPtr instance); [DllImport("afrodite")] - static extern IntPtr afrodite_ast_lookup_source_file (IntPtr instance, string filename); + static extern IntPtr afrodite_code_dom_lookup_source_file (IntPtr instance, string filename); #endregion #region IDisposable implementation /// <summary> - /// Release this AST for reuse + /// Release this CodeDOM for reuse /// </summary> public void Dispose () { - engine.ReleaseAst (this); + engine.ReleaseCodeDom (this); } #endregion } /// <summary> - /// Utility class for dumping an AST to Console.Out + /// Utility class for dumping a CodeDOM to Console.Out /// </summary> - internal class AstDumper + internal class CodeDomDumper { - public AstDumper () + public CodeDomDumper () { instance = afrodite_ast_dumper_new (); } - public void Dump (Ast ast, string filterSymbol) + public void Dump (CodeDom codeDom, string filterSymbol) { - afrodite_ast_dumper_dump (instance, ast.Instance, filterSymbol); + afrodite_ast_dumper_dump (instance, codeDom.Instance, filterSymbol); } #region P/Invokes @@ -523,7 +523,7 @@ namespace MonoDevelop.ValaBinding.Parser.Afrodite static extern IntPtr afrodite_ast_dumper_new (); [DllImport("afrodite")] - static extern void afrodite_ast_dumper_dump (IntPtr instance, IntPtr ast, string filterSymbol); + static extern void afrodite_ast_dumper_dump (IntPtr instance, IntPtr codeDom, string filterSymbol); #endregion } @@ -600,7 +600,7 @@ namespace MonoDevelop.ValaBinding.Parser.Afrodite } /// <summary> - /// Options for querying an AST + /// Options for querying a CodeDOM /// </summary> internal class QueryOptions { @@ -846,7 +846,7 @@ namespace MonoDevelop.ValaBinding.Parser.Afrodite } /// <summary> - /// Class to represent an AST source file + /// Class to represent a CodeDOM source file /// </summary> internal class SourceFile { @@ -1161,16 +1161,16 @@ namespace MonoDevelop.ValaBinding.Parser.Afrodite return list; } - public static string GetSymbolType (int symbolType) + public static string GetMemberType (int memberType) { - return Marshal.PtrToStringAuto (afrodite_utils_symbols_get_symbol_type_description (symbolType)); + return Marshal.PtrToStringAuto (afrodite_utils_symbols_get_symbol_type_description (memberType)); } [DllImport("afrodite")] static extern IntPtr afrodite_utils_get_package_paths (string package, IntPtr codeContext, string[] vapiDirs); [DllImport("afrodite")] - static extern IntPtr afrodite_utils_symbols_get_symbol_type_description (int symbolType); + static extern IntPtr afrodite_utils_symbols_get_symbol_type_description (int memberType); } } diff --git a/extras/ValaBinding/Parser/ProjectInformation.cs b/extras/ValaBinding/Parser/ProjectInformation.cs index c5718aeb27..31b0baee80 100644 --- a/extras/ValaBinding/Parser/ProjectInformation.cs +++ b/extras/ValaBinding/Parser/ProjectInformation.cs @@ -109,13 +109,13 @@ namespace MonoDevelop.ValaBinding.Parser List<Afrodite.Symbol> nodes = new List<Afrodite.Symbol> (); if (!DepsInstalled){ return nodes; } - using (Afrodite.Ast parseTree = engine.TryAcquireAst ()) { + using (Afrodite.CodeDom parseTree = engine.TryAcquireCodeDom ()) { if (null != parseTree) { Afrodite.Symbol symbol = parseTree.GetSymbolForNameAndPath (typename, filename, linenum, column); if (null == symbol){ LoggingService.LogDebug ("CompleteType: Unable to lookup {0} in {1} at {2}:{3}", typename, filename, linenum, column); } else{ nodes = symbol.Children; } } else { - LoggingService.LogDebug ("CompleteType: Unable to acquire ast"); + LoggingService.LogDebug ("CompleteType: Unable to acquire codedom"); } } @@ -170,7 +170,7 @@ namespace MonoDevelop.ValaBinding.Parser if (!DepsInstalled){ return nodes; } - using (Afrodite.Ast parseTree = engine.TryAcquireAst ()) { + using (Afrodite.CodeDom parseTree = engine.TryAcquireCodeDom ()) { if (null != parseTree) { LoggingService.LogDebug ("Complete: Looking up symbol at {0}:{1}:{2}", filename, line, column); Afrodite.Symbol sym = parseTree.GetSymbolForNameAndPath (symbol, filename, line, column); @@ -180,7 +180,7 @@ namespace MonoDevelop.ValaBinding.Parser AddResults (nodes, results); } } else { - LoggingService.LogDebug ("Complete: Unable to acquire ast"); + LoggingService.LogDebug ("Complete: Unable to acquire codedom"); } } @@ -191,14 +191,14 @@ namespace MonoDevelop.ValaBinding.Parser { if (!DepsInstalled){ return null; } - using (Afrodite.Ast parseTree = engine.TryAcquireAst ()) { + using (Afrodite.CodeDom parseTree = engine.TryAcquireCodeDom ()) { if (null != parseTree) { LoggingService.LogDebug ("GetFunction: Looking up symbol at {0}:{1}:{2}", filename, line, column); Afrodite.Symbol symbol = parseTree.GetSymbolForNameAndPath (name, filename, line, column); LoggingService.LogDebug ("GetFunction: Got {0}", (null == symbol)? "null": symbol.Name); return symbol; } else { - LoggingService.LogDebug ("GetFunction: Unable to acquire ast"); + LoggingService.LogDebug ("GetFunction: Unable to acquire codedom"); } } @@ -212,16 +212,16 @@ namespace MonoDevelop.ValaBinding.Parser { if (!DepsInstalled){ return symbol; } - using (Afrodite.Ast parseTree = engine.TryAcquireAst ()) { + using (Afrodite.CodeDom parseTree = engine.TryAcquireCodeDom ()) { if (null != parseTree) { LoggingService.LogDebug ("GetExpressionType: Looking up symbol at {0}:{1}:{2}", filename, line, column); Afrodite.Symbol sym = parseTree.LookupSymbolAt (filename, line, column); if (null != sym) { - LoggingService.LogDebug ("Got {0}", sym.DataType.TypeName); - return sym.DataType.TypeName; + LoggingService.LogDebug ("Got {0}", sym.SymbolType.TypeName); + return sym.SymbolType.TypeName; } } else { - LoggingService.LogDebug ("GetExpressionType: Unable to acquire ast"); + LoggingService.LogDebug ("GetExpressionType: Unable to acquire codedom"); } } @@ -236,12 +236,12 @@ namespace MonoDevelop.ValaBinding.Parser List<Afrodite.Symbol> overloads = new List<Afrodite.Symbol> (); if (!DepsInstalled){ return overloads; } - using (Afrodite.Ast parseTree = engine.TryAcquireAst ()) { + using (Afrodite.CodeDom parseTree = engine.TryAcquireCodeDom ()) { if (null != parseTree) { Afrodite.Symbol symbol = parseTree.GetSymbolForNameAndPath (name, filename, line, column); overloads = new List<Afrodite.Symbol> (){ symbol }; } else { - LoggingService.LogDebug ("GetOverloads: Unable to acquire ast"); + LoggingService.LogDebug ("GetOverloads: Unable to acquire codedom"); } } @@ -255,8 +255,8 @@ namespace MonoDevelop.ValaBinding.Parser { List<Afrodite.Symbol> functions = new List<Afrodite.Symbol> (); foreach (Afrodite.Symbol node in CompleteType (typename, filename, line, column, null)) { - if ("constructor".Equals (node.SymbolType, StringComparison.OrdinalIgnoreCase) || - "creationmethod".Equals (node.SymbolType, StringComparison.OrdinalIgnoreCase)) { + if ("constructor".Equals (node.MemberType, StringComparison.OrdinalIgnoreCase) || + "creationmethod".Equals (node.MemberType, StringComparison.OrdinalIgnoreCase)) { functions.Add (node); } } @@ -292,12 +292,12 @@ namespace MonoDevelop.ValaBinding.Parser parent = parent.Parent) { AddResults (parent.Children.FindAll (delegate (Afrodite.Symbol sym){ - return 0 <= Array.IndexOf (containerTypes, sym.SymbolType.ToLower ()); + return 0 <= Array.IndexOf (containerTypes, sym.MemberType.ToLower ()); }), results); } } - using (Afrodite.Ast parseTree = engine.TryAcquireAst ()) { + using (Afrodite.CodeDom parseTree = engine.TryAcquireCodeDom ()) { if (null == parseTree){ return; } AddResults (GetNamespacesForFile (filename), results); @@ -306,13 +306,14 @@ namespace MonoDevelop.ValaBinding.Parser if (null != file) { Afrodite.Symbol parent; foreach (Afrodite.DataType directive in file.UsingDirectives) { + if (directive.Symbol == null) { continue; } Afrodite.Symbol ns = parseTree.Lookup (directive.Symbol.FullyQualifiedName, out parent); if (null != ns) { containers = new List<Afrodite.Symbol> (); AddResults (new Afrodite.Symbol[]{ ns }, results); foreach (Afrodite.Symbol child in ns.Children) { foreach (string containerType in containerTypes) { - if (containerType.Equals (child.SymbolType, StringComparison.OrdinalIgnoreCase)) + if (containerType.Equals (child.MemberType, StringComparison.OrdinalIgnoreCase)) containers.Add (child); } } @@ -387,7 +388,7 @@ namespace MonoDevelop.ValaBinding.Parser if (!DepsInstalled){ return classes; } - using (Afrodite.Ast parseTree = engine.TryAcquireAst ()) { + using (Afrodite.CodeDom parseTree = engine.TryAcquireCodeDom ()) { if (null != parseTree){ Afrodite.SourceFile sourceFile = parseTree.LookupSourceFile (file); if (null != sourceFile) { @@ -395,7 +396,7 @@ namespace MonoDevelop.ValaBinding.Parser if (null != symbols) { foreach (Afrodite.Symbol symbol in symbols) { foreach (string containerType in desiredTypes) { - if (containerType.Equals (symbol.SymbolType, StringComparison.OrdinalIgnoreCase)) + if (containerType.Equals (symbol.MemberType, StringComparison.OrdinalIgnoreCase)) classes.Add (symbol); } } @@ -404,7 +405,7 @@ namespace MonoDevelop.ValaBinding.Parser LoggingService.LogDebug ("GetClassesForFile: Unable to lookup source file {0}", file); } } else { - LoggingService.LogDebug ("GetClassesForFile: Unable to acquire ast"); + LoggingService.LogDebug ("GetClassesForFile: Unable to acquire codedom"); } } diff --git a/extras/ValaBinding/Parser/ValaDocumentParser.cs b/extras/ValaBinding/Parser/ValaDocumentParser.cs index f5a15b8945..adae51b34a 100644 --- a/extras/ValaBinding/Parser/ValaDocumentParser.cs +++ b/extras/ValaBinding/Parser/ValaDocumentParser.cs @@ -66,7 +66,7 @@ namespace MonoDevelop.ValaBinding.Parser child.SourceReferences[0].File != node.SourceReferences[0].File){ continue; } lastLine = Math.Max (lastLine, child.SourceReferences[0].LastLine+1); - switch (child.SymbolType.ToLower ()) { + switch (child.MemberType.ToLower ()) { case "class": members.Add (new DomType (new CompilationUnit (fileName), ClassType.Class, child.Name, new DomLocation (child.SourceReferences[0].FirstLine, 1), string.Empty, new DomRegion (child.SourceReferences[0].FirstLine, int.MaxValue, child.SourceReferences[0].LastLine, int.MaxValue), new List<IMember> ())); break; @@ -103,7 +103,7 @@ namespace MonoDevelop.ValaBinding.Parser members.Add (new DomEvent (child.Name, Modifiers.None, new DomLocation (child.SourceReferences[0].FirstLine, 1), new DomReturnType ())); break; default: - MonoDevelop.Core.LoggingService.LogDebug ("ValaDocumentParser: Unsupported member type: {0}", child.SymbolType); + MonoDevelop.Core.LoggingService.LogDebug ("ValaDocumentParser: Unsupported member type: {0}", child.MemberType); break; }// Switch on node type }// Collect members |