[Pkg-cli-apps-commits] [SCM] monodevelop-vala branch, upstream, updated. upstream/2.1.1-2-gb2a5f35
Mirco Bauer
meebey at meebey.net
Sun Oct 25 15:11:14 UTC 2009
The following commit has been merged in the upstream branch:
commit 2f899e4815d269f2e543e8436e0ce2ade046f91d
Author: Mirco Bauer <meebey at meebey.net>
Date: Sun Oct 25 15:51:37 2009 +0100
Imported Upstream version 2.1.1
diff --git a/AssemblyInfo.cs b/AssemblyInfo.cs
index 7a3d5da..294f13e 100644
--- a/AssemblyInfo.cs
+++ b/AssemblyInfo.cs
@@ -5,5 +5,5 @@ using System.Reflection;
[assembly: AssemblyProduct ("MonoDevelop")]
[assembly: AssemblyTitle ("Vala Language Binding")]
[assembly: AssemblyDescription ("Vala Language binding")]
-[assembly: AssemblyVersion ("2.0")]
+[assembly: AssemblyVersion ("2.1.1")]
[assembly: AssemblyCopyright ("MIT/X11")]
diff --git a/ChangeLog b/ChangeLog
index 5264f25..4e43243 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,9 +1,162 @@
-2009-03-05 Lluis Sanchez Gual <lluis at novell.com>
+2009-10-07 Lluis Sanchez Gual <lluis at novell.com>
* configure.in:
* AssemblyInfo.cs:
* ValaBinding.addin.xml: Bump MD version.
+2009-09-12 Levi Bard <taktaktaktaktaktaktaktaktaktak at gmail.com>
+
+ * Gui/DataProvider.cs:
+ * Parser/ValaDocumentParser.cs:
+ * Parser/ProjectInformation.cs: Track completion window API.
+
+2009-09-11 Levi Bard <taktaktaktaktaktaktaktaktaktak at gmail.com>
+
+ * Parser/ProjectInformation.cs: Allow vala files to be edited
+ without a vsc-shell installation. Reported by Andy Selvig.
+
+2009-08-26 Lluis Sanchez Gual <lluis at novell.com>
+
+ * configure.in:
+ * ValaBinding.csproj:
+ * gtk-gui/gui.stetic: We now depend on gtk# 2.12.8, Mono 2.4,
+ and Mono.Addins 0.4.
+
+2009-07-24 Lluis Sanchez Gual <lluis at novell.com>
+
+ * Project/ValaProjectBinding.cs: Track api changes.
+
+2009-06-23 Lluis Sanchez Gual <lluis at novell.com>
+
+ * Project/ValaProject.cs: Track api changes.
+
+2009-06-17 Lluis Sanchez Gual <lluis at novell.com>
+
+ * ValaBinding.sln:
+ * ValaBinding.addin.xml:
+ * gtk-gui/MonoDevelop.ValaBinding.PackageDetails.cs: Remove
+ obsolete extension.
+
+2009-05-19 Lluis Sanchez Gual <lluis at novell.com>
+
+ * ValaBinding.sln:
+ * ValaBinding.csproj: Flush.
+
+2009-04-28 Levi Bard <taktaktaktaktaktaktaktaktaktak at gmail.com>
+
+ * Parser/CodeNode.cs:
+ * Parser/ProjectInformation.cs: Make document type extraction
+ more robust.
+
+2009-04-28 Levi Bard <taktaktaktaktaktaktaktaktaktak at gmail.com>
+
+ * Parser/ProjectInformation.cs: Force reparse on file update.
+
+2009-04-23 Levi Bard <taktaktaktaktaktaktaktaktaktak at gmail.com>
+
+ * Gui/ValaTextEditorExtension.cs:
+ * Parser/ValaDocumentParser.cs:
+ * Parser/ProjectInformation.cs: Improve completion robustness.
+
+2009-04-23 Levi Bard <taktaktaktaktaktaktaktaktaktak at gmail.com>
+
+ * Parser/ProjectInformation.cs: Keep parser from blocking project load.
+
+2009-04-20 Michael Hutchinson <mhutchinson at novell.com>
+
+ * ValaLanguageBinding.cs: Track comment tag API.
+
+2009-04-20 Lluis Sanchez Gual <lluis at novell.com>
+
+ * Project/ValaProject.cs: Track api changes done in
+ IExecutionHandler.
+
+2009-04-16 Levi Bard <taktaktaktaktaktaktaktaktaktak at gmail.com>
+
+ * Parser/ValaDocumentParser.cs: Allow non-project files
+ to be parsed.
+
+2009-04-15 Lluis Sanchez Gual <lluis at novell.com>
+
+ * configure.in:
+ * AssemblyInfo.cs:
+ * ValaBinding.addin.xml: Bump MD version.
+
+2009-04-14 Levi Bard <taktaktaktaktaktaktaktaktaktak at gmail.com>
+
+ * Parser/*: Improvements to dom interaction.
+
+2009-04-13 Levi Bard <taktaktaktaktaktaktaktaktaktak at gmail.com>
+
+ * Parser/*:
+ * Navigation/*: Make more parser communication asynchronous,
+ drop reliance on parser restarts.
+
+2009-04-13 Levi Bard <taktaktaktaktaktaktaktaktaktak at gmail.com>
+
+ * Parser/ProjectInformation.cs: Parser adjustments.
+
+2009-04-10 Levi Bard <taktaktaktaktaktaktaktaktaktak at gmail.com>
+
+ * Parser/ProjectInformation.cs: Handle it more gracefully
+ when vsc-shell is not installed.
+
+2009-04-09 Levi Bard <taktaktaktaktaktaktaktaktaktak at gmail.com>
+
+ * Project/ValaProject.cs: Auto-add C compiler options
+ when there are no package dependencies.
+
+2009-04-09 Levi Bard <taktaktaktaktaktaktaktaktaktak at gmail.com>
+
+ * *: Populate quick finder.
+
+2009-04-08 Levi Bard <taktaktaktaktaktaktaktaktaktak at gmail.com>
+
+ * Parser/ProjectInformation.cs: Increase parser robustness.
+
+2009-04-08 Levi Bard <taktaktaktaktaktaktaktaktaktak at gmail.com>
+
+ * Gui/DataProvider.cs: Increase responsiveness on
+ parameter completion.
+
+2009-04-08 Levi Bard <taktaktaktaktaktaktaktaktaktak at gmail.com>
+
+ * Gui/ValaTextEditorExtension.cs: Increase responsiveness on
+ parameter completion.
+
+2009-04-07 Levi Bard <taktaktaktaktaktaktaktaktaktak at gmail.com>
+
+ * Compiler/ValaCompiler.cs: Update for Vala 0.7.0.
+
+2009-03-25 Levi Bard <taktaktaktaktaktaktaktaktaktak at gmail.com>
+
+ * Parser/*:
+ * Navigation/LanguageItemCommandHandler.cs: Use file
+ positions from VSC.
+
+2009-03-20 Levi Bard <taktaktaktaktaktaktaktaktaktak at gmail.com>
+
+ * Gui/ValaTextEditorExtension.cs: Tweak completion
+ aggressiveness.
+
+2009-03-13 Levi Bard <taktaktaktaktaktaktaktaktaktak at gmail.com>
+
+ * Gui/ValaTextEditorExtension.cs: Make completion more
+ aggressive.
+
+2009-03-13 Levi Bard <taktaktaktaktaktaktaktaktaktak at gmail.com>
+
+ * Parser/ProjectInformation.cs: Reduce parser latency on
+ bad match.
+
+2009-03-13 Levi Bard <taktaktaktaktaktaktaktaktaktak at gmail.com>
+
+ * Parser/ProjectInformation.cs: Fix intermittent exception.
+
+2009-03-10 Levi Bard <taktaktaktaktaktaktaktaktaktak at gmail.com>
+
+ * *: Implement basic Makefile generation.
+
2009-03-04 Lluis Sanchez Gual <lluis at novell.com>
* Project/ValaProject.cs: Changed the way execution handlers
@@ -13,6 +166,10 @@
is handled by IExecutionHandler, which has a new CanExecute
method. This model is more simple and more generic.
+2009-02-27 Levi Bard <taktaktaktaktaktaktaktaktaktak at gmail.com>
+
+ * *: Change to vsc-based completion.
+
2009-02-26 Michael Hutchinson <mhutchinson at novell.com>
* ValaLanguageBinding.cs: Ordinal compare.
diff --git a/Compiler/ValaCompiler.cs b/Compiler/ValaCompiler.cs
index 0da875d..b5ae2fd 100644
--- a/Compiler/ValaCompiler.cs
+++ b/Compiler/ValaCompiler.cs
@@ -82,7 +82,7 @@ namespace MonoDevelop.ValaBinding
/// The string needed by the compiler to reference the necessary packages
/// <see cref="System.String"/>
/// </returns>
- protected string GeneratePkgCompilerArgs (ProjectPackageCollection packages)
+ public static string GeneratePkgCompilerArgs (ProjectPackageCollection packages)
{
if (packages == null || packages.Count < 1)
return string.Empty;
@@ -165,6 +165,11 @@ namespace MonoDevelop.ValaBinding
return new BuildResult (cr, "");
}
+ string ICompiler.GetCompilerFlags (ValaProjectConfiguration configuration)
+ {
+ return ValaCompiler.GetCompilerFlags (configuration);
+ }
+
/// <summary>
/// Generates compiler args for the current settings
/// </summary>
@@ -176,7 +181,7 @@ namespace MonoDevelop.ValaBinding
/// A compiler-interpretable string
/// <see cref="System.String"/>
/// </returns>
- public string GetCompilerFlags (ValaProjectConfiguration configuration)
+ public static string GetCompilerFlags (ValaProjectConfiguration configuration)
{
List<string> args = new List<string> ();
@@ -196,7 +201,7 @@ namespace MonoDevelop.ValaBinding
}
break;
case ValaBinding.CompileTarget.SharedLibrary:
- args.Add (string.Format ("--Xcc=\"-shared\" --Xcc=\"-fPIC\" --Xcc=\"-I'{0}'\" --library \"{1}\"", configuration.OutputDirectory, configuration.Output));
+ args.Add (string.Format ("--Xcc=\"-shared\" --Xcc=\"-fPIC\" --Xcc=\"-I'{0}'\" -H \"{1}.h\" --library \"{1}\"", configuration.OutputDirectory, configuration.Output));
break;
}
@@ -350,12 +355,11 @@ namespace MonoDevelop.ValaBinding
/// <returns>
/// A <see cref="System.String"/>
/// </returns>
- private string ProcessDefineSymbols (string symbols)
+ private static string ProcessDefineSymbols (string symbols)
{
- return string.Empty; // No -D in valac for now :-(
-// return ((null == symbols) || (0 == symbols.Length))?
-// string.Empty:
-// "-D " + Regex.Replace (symbols, " +", " -D ");
+ return ((null == symbols) || (0 == symbols.Length))?
+ string.Empty:
+ "-D " + Regex.Replace (symbols, " +", " -D ");
}
/// <summary>
@@ -588,7 +592,7 @@ namespace MonoDevelop.ValaBinding
/// </returns>
// TODO: Portability, although otoh, probably someone who doesn't have sh
// isn't going to put backticks in the compiler flags
- public string ExpandBacktickedParameters (string tmp)
+ public static string ExpandBacktickedParameters (string tmp)
{
string parameters = "-c \"echo -n " + tmp + "\"";
Process p = new Process ();
diff --git a/Gui/DataProvider.cs b/Gui/DataProvider.cs
index 65e8c03..92c45be 100644
--- a/Gui/DataProvider.cs
+++ b/Gui/DataProvider.cs
@@ -33,6 +33,8 @@
using System;
using System.Collections;
using System.Collections.Generic;
+using System.Text.RegularExpressions;
+using System.Threading;
using MonoDevelop.Core.Gui;
using MonoDevelop.Ide.Gui;
@@ -45,30 +47,70 @@ namespace MonoDevelop.ValaBinding
public class ParameterDataProvider : IParameterDataProvider
{
private TextEditor editor;
- private List<Function> functions = new List<Function> ();
+ private IList<Function> functions;
+ private string functionName;
+ private string returnType;
+ private ProjectInformation info;
+ private static Regex identifierRegex = new Regex(@"^[^\w\d]*(?<identifier>\w[\w\d\.<>]*)", RegexOptions.Compiled);
public ParameterDataProvider (Document document, ProjectInformation info, string functionName)
{
this.editor = document.TextEditor;
+ this.functionName = functionName;
+ this.info = info;
+
+ int lastDot = functionName.LastIndexOf (".", StringComparison.OrdinalIgnoreCase);
+ string instancename = (0 <= lastDot)? functionName.Substring (0, lastDot): "this";
+
+ Match match = identifierRegex.Match (instancename);
+ if (match.Success && match.Groups["identifier"].Success) {
+ instancename = match.Groups["identifier"].Value;
+ }
+
+ string typename = null;
+
+ ThreadPool.QueueUserWorkItem (delegate(object o) {
+ typename = info.GetExpressionType (instancename, document.FileName, editor.CursorLine, editor.CursorColumn); // bottleneck
+ info.Complete(typename, document.FileName, editor.CursorLine, editor.CursorColumn, null);
+ });
+ string functionBaseName = (0 <= lastDot)? functionName.Substring (lastDot+1): functionName;
- foreach (Function f in info.Functions) {
- if (f.Name == functionName) {
- functions.Add (f);
+ match = identifierRegex.Match (functionBaseName);
+ if (match.Success && match.Groups["identifier"].Success) {
+ functionBaseName = match.Groups["identifier"].Value;
+ }
+ IList<Function> myfunctions = info.GetOverloads (functionBaseName); // bottleneck
+
+ if (null != typename) {
+ foreach (Function function in myfunctions) {
+ if (string.Format("{0}.{1}", typename, functionBaseName).Equals (function.FullName, StringComparison.Ordinal)) {
+ functions = new List<Function>(new Function[]{function});
+ break;
+ }
}
}
- string currentFile = document.FileName;
+ if (null == functions){ functions = myfunctions; }
+ }// member function constructor
+
+ public ParameterDataProvider (Document document, ProjectInformation info, string typename, string constructorOverload)
+ {
+ this.functionName = constructorOverload;
+ this.editor = document.TextEditor;
+ this.info = info;
- if (info.IncludedFiles.ContainsKey (currentFile)) {
- foreach (FileInformation fi in info.IncludedFiles[currentFile]) {
- foreach (Function f in fi.Functions) {
- if (f.Name == functionName) {
- functions.Add (f);
- }
+ List<Function> myfunctions = info.GetConstructorsForType (typename, document.FileName, editor.CursorLine, editor.CursorColumn, null); // bottleneck
+ if (0 < myfunctions.Count) {
+ foreach (Function function in myfunctions) {
+ if (functionName.Equals (function.Name, StringComparison.Ordinal)) {
+ functions = new List<Function>(new Function[]{function});
+ return;
}
}
}
- }
+
+ functions = myfunctions;
+ }// constructor constructor
// Returns the number of methods
public int OverloadCount {
@@ -79,23 +121,23 @@ namespace MonoDevelop.ValaBinding
// -1 means the cursor is outside the method parameter list
// 0 means no parameter entered
// > 0 is the index of the parameter (1-based)
- public int GetCurrentParameterIndex (ICodeCompletionContext ctx)
+ public int GetCurrentParameterIndex (CodeCompletionContext ctx)
{
int cursor = editor.CursorPosition;
int i = ctx.TriggerOffset;
- if (editor.GetCharAt (i) == ')')
- return -1;
+// if (editor.GetCharAt (i) == ')')
+// return -1;
if (i > cursor)
return -1;
else if (i == cursor)
- return 0;
+ return 1;
int parameterIndex = 1;
while (i++ < cursor) {
- char ch = editor.GetCharAt (i);
+ char ch = editor.GetCharAt (i-1);
if (ch == ',')
parameterIndex++;
else if (ch == ')')
@@ -107,23 +149,27 @@ namespace MonoDevelop.ValaBinding
// Returns the markup to use to represent the specified method overload
// in the parameter information window.
- public string GetMethodMarkup (int overload, string[] parameterMarkup)
+ public string GetMethodMarkup (int overload, string[] parameterMarkup, int currentParameter)
{
- Function function = functions[overload];
string paramTxt = string.Join (", ", parameterMarkup);
+ Function function = functions[overload];
int len = function.FullName.LastIndexOf (".");
string prename = null;
if (len > 0)
- prename = function.FullName.Substring (0, len + 2);
+ prename = function.FullName.Substring (0, len + 1);
string cons = string.Empty;
- if (function.IsConst)
- cons = " const";
-
- return prename + "<b>" + function.Name + "</b>" + " (" + paramTxt + ")" + cons;
+// if (function.IsConst)
+// cons = " const";
+
+ return string.Format ("{2} {3}<b>{0}</b>({1})", GLib.Markup.EscapeText (function.Name),
+ paramTxt,
+ GLib.Markup.EscapeText (function.ReturnType),
+ GLib.Markup.EscapeText (prename));
+ // return prename + "<b>" + function.Name + "</b>" + " (" + paramTxt + ")" + cons;
}
// Returns the text to use to represent the specified parameter
@@ -131,7 +177,7 @@ namespace MonoDevelop.ValaBinding
{
Function function = functions[overload];
- return function.Parameters[paramIndex];
+ return GLib.Markup.EscapeText (string.Format ("{1} {0}", function.Parameters[paramIndex].Key, function.Parameters[paramIndex].Value));
}
// Returns the number of parameters of the specified method
@@ -148,36 +194,12 @@ namespace MonoDevelop.ValaBinding
private string description;
private string completion_string;
- public CompletionData (LanguageItem item)
+ public CompletionData (CodeNode item)
{
- if (item is Class)
- image = Stock.Class;
- else if (item is Structure)
- image = Stock.Struct;
- else if (item is Union)
- image = "md-union";
- else if (item is Enumeration)
- image = Stock.Enum;
- else if (item is Enumerator)
- image = Stock.Literal;
- else if (item is Function)
- image = Stock.Method;
- else if (item is Namespace)
- image = Stock.NameSpace;
- else if (item is Typedef)
- image = Stock.Interface;
- else if (item is Member)
- image = Stock.Field;
- else if (item is Variable)
- image = Stock.Field;
- else if (item is Macro)
- image = Stock.Literal;
- else
- image = Stock.Literal;
-
this.text = item.Name;
this.completion_string = item.Name;
- this.description = string.Empty;
+ this.description = item.Description;
+ this.image = item.Icon;
}
public string Icon {
@@ -201,4 +223,46 @@ namespace MonoDevelop.ValaBinding
}
}
+ /// <summary>
+ /// Mutable completion data list for asynchronous parsing
+ /// </summary>
+ public class ValaCompletionDataList: CompletionDataList, IMutableCompletionDataList
+ {
+ public ValaCompletionDataList (): base ()
+ {
+ }
+
+ #region IMutableCompletionDataList implementation
+
+ public event EventHandler Changed;
+ public event EventHandler Changing;
+
+ protected virtual void OnChanged (object sender, EventArgs args)
+ {
+ if (null != Changed){ Changed (sender, args); }
+ }// OnChanged
+
+ protected virtual void OnChanging (object sender, EventArgs args)
+ {
+ if (null != Changing){ Changing (sender, args); }
+ }// OnChanging
+
+ public virtual bool IsChanging
+ {
+ get{ return isChanging; }
+ internal set {
+ isChanging = value;
+ OnChanged (this, new EventArgs ());
+ }
+ }
+ protected bool isChanging;
+
+ public void Dispose ()
+ {
+ }
+
+ #endregion
+
+
+ }// ValaCompletionDataList
}
diff --git a/Gui/ValaTextEditorExtension.cs b/Gui/ValaTextEditorExtension.cs
index 68b5304..3dcb837 100644
--- a/Gui/ValaTextEditorExtension.cs
+++ b/Gui/ValaTextEditorExtension.cs
@@ -33,7 +33,9 @@
using System;
using System.IO;
using System.Text;
+using System.Text.RegularExpressions;
using System.Collections.Generic;
+using System.Threading;
using MonoDevelop.Ide.Gui;
using MonoDevelop.Ide.Gui.Content;
@@ -46,21 +48,27 @@ namespace MonoDevelop.ValaBinding
public class ValaTextEditorExtension : CompletionTextEditorExtension
{
// Allowed chars to be next to an identifier
- private static char[] allowedChars = new char[] {
- '.', ':', ' ', '\t', '=', '*', '+', '-', '/', '%', ',', '&',
+ private static char[] allowedChars = new char[] { ' ', '\t', '\r', '\n',
+ ':', '=', '*', '+', '-', '/', '%', ',', '&',
'|', '^', '{', '}', '[', ']', '(', ')', '\n', '!', '?', '<', '>'
};
- // Allowed Chars to be next to an identifier excluding ':' (to get the full name in '::' completion).
- private static char[] allowedCharsMinusColon = new char[] {
- '.', ' ', '\t', '=', '*', '+', '-', '/', '%', ',', '&', '|',
- '^', '{', '}', '[', ']', '(', ')', '\n', '!', '?', '<', '>'
+ private static char[] operators = new char[] {
+ '=', '+', '-', ',', '&', '|',
+ '^', '[', '!', '?', '<', '>', ':'
};
+ private ProjectInformation Parser {
+ get {
+ ValaProject project = Document.Project as ValaProject;
+ return (null == project)? null: ProjectInformationManager.Instance.Get (project);
+ }
+ }// Parser
+
public override bool ExtendsEditor (Document doc, IEditableTextBuffer editor)
{
- return (Path.GetExtension (doc.Name).ToUpper () == ".VALA" ||
- Path.GetExtension (doc.Name).ToUpper () == ".VAPI" );
+ return (Path.GetExtension (doc.FileName).ToUpper () == ".VALA" ||
+ Path.GetExtension (doc.FileName).ToUpper () == ".VAPI" );
}
public override bool KeyPress (Gdk.Key key, char keyChar, Gdk.ModifierType modifier)
@@ -89,14 +97,26 @@ namespace MonoDevelop.ValaBinding
return base.KeyPress (key, keyChar, modifier);
}
+ private static Regex initializationRegex = new Regex (@"(((?<typename>\w[\w\d\.<>]*)\s+)?(?<variable>\w[\w\d]*)\s*=\s*)?new\s*(?<constructor>\w[\w\d\.<>]*)?", RegexOptions.Compiled);
public override ICompletionDataList HandleCodeCompletion (
- ICodeCompletionContext completionContext, char completionChar)
+ CodeCompletionContext completionContext, char completionChar)
{
- string lineText = Editor.GetLineText (completionContext.TriggerLine + 1);
+ int line, column;
+ string lineText = null;
+ ProjectInformation parser = Parser;
+ // Console.WriteLine ("({0},{1}): {2}", line, column, lineText);
+
+ Editor.GetLineColumnFromPosition (completionContext.TriggerOffset, out line, out column);
- if (lineText.EndsWith (".")) {
+ switch (completionChar) {
+ case '.':
+ lineText = Editor.GetLineText (line);
+ if (column > lineText.Length){ column = lineText.Length; }
+ lineText = lineText.Substring (0, column - 1);
// remove the trailing '.'
- lineText = lineText.Substring (0, lineText.Length - 1);
+ if (lineText.EndsWith (".", StringComparison.Ordinal)) {
+ lineText = lineText.Substring (0, lineText.Length-1);
+ }
int nameStart = lineText.LastIndexOfAny (allowedChars);
@@ -107,228 +127,161 @@ namespace MonoDevelop.ValaBinding
if (string.IsNullOrEmpty (itemName))
return null;
- return GetMembersOfItem (itemName);
- }
-
- return null;
- }
-
- public override ICompletionDataList CodeCompletionCommand (
- ICodeCompletionContext completionContext)
- {
- int pos = completionContext.TriggerOffset;
- int line, column;
- Editor.GetLineColumnFromPosition (Editor.CursorPosition, out line, out column);
- string lineText = Editor.GetLineText (line);
-
- if (!lineText.Contains ("."))
- return GlobalComplete ();
-
- return HandleCodeCompletion (completionContext, Editor.GetText (pos - 1, pos)[0]);
- }
-
- private CompletionDataList GetMembersOfItem (string itemFullName)
- {
- ValaProject project = Document.Project as ValaProject;
-
- if (project == null)
- return null;
+ return GetMembersOfItem (itemName, line, column);
+ case '\t':
+ case ' ':
+ lineText = Editor.GetLineText (line);
+ if (column > lineText.Length){ column = lineText.Length; }
+ lineText = lineText.Substring (0, column-1).Trim ();
- ProjectInformation info = ProjectInformationManager.Instance.Get (project);
- CompletionDataList list = new CompletionDataList ();
-
- LanguageItem container = null;
- string containerType = null;
-
- string currentFileName = Document.FileName;
- bool in_project = false;
-
- // Try containers
- foreach (LanguageItem li in info.Containers ()) {
- if ((itemFullName == li.FullName) || (itemFullName == li.Name)){
- container = li;
- in_project = true;
- break;
- }
- }
-
- // Try included containers
- if (!in_project && info.IncludedFiles.ContainsKey (currentFileName)) {
- foreach (FileInformation fi in info.IncludedFiles[currentFileName]) {
- foreach (LanguageItem li in fi.Containers ()) {
- if ((itemFullName == li.FullName) || (itemFullName == li.Name)) {
- container = li;
- break;
- }
+ if (lineText.EndsWith ("new")) {
+ return CompleteConstructor (lineText, line, column);
+ } else if (lineText.EndsWith ("is")) {
+ ValaCompletionDataList list = new ValaCompletionDataList ();
+ parser.GetTypesVisibleFrom (Document.FileName, line, column, list);
+ return list;
+ } else if (0 < lineText.Length) {
+ char lastNonWS = lineText[lineText.Length-1];
+ if (0 <= Array.IndexOf (operators, lastNonWS) ||
+ (1 == lineText.Length && 0 > Array.IndexOf (allowedChars, lastNonWS))) {
+ return GlobalComplete (completionContext);
}
}
- }
-
- // Try instances
- // Find the typename of the instance
- foreach (Member li in info.Members ) {
- if (itemFullName == li.Name) {
- containerType = li.InstanceType;
- in_project = true;
- break;
+
+ break;
+ default:
+ if (0 <= Array.IndexOf (operators, completionChar)) {
+ return GlobalComplete (completionContext);
}
+ break;
}
- // Search included files
- if (!in_project && info.IncludedFiles.ContainsKey (currentFileName)) {
- foreach (FileInformation fi in info.IncludedFiles[currentFileName]) {
- foreach (Member li in fi.Members) {
- if (itemFullName == li.Name) {
- containerType = li.InstanceType;
- break;
- }
+ return null;
+ }
+
+ private ValaCompletionDataList CompleteConstructor (string lineText, int line, int column)
+ {
+ ProjectInformation parser = Parser;
+ Match match = initializationRegex.Match (lineText);
+ ValaCompletionDataList list = new ValaCompletionDataList ();
+ list.IsChanging = true;
+
+ if (match.Success) {
+ ThreadPool.QueueUserWorkItem (delegate{
+ // variable initialization
+ if (match.Groups["typename"].Success || "var" != match.Groups["typename"].Value) {
+ // simultaneous declaration and initialization
+ parser.GetConstructorsForType (match.Groups["typename"].Value, Document.FileName, line, column, list);
+ } else if (match.Groups["variable"].Success) {
+ // initialization of previously declared variable
+ parser.GetConstructorsForExpression (match.Groups["variable"].Value, Document.FileName, line, column, list);
}
- }
- }
-
- if (null == container) {
- // Search locals
- foreach (Local li in info.Locals ) {
- if (itemFullName == li.Name && currentFileName == li.File) {
- containerType = li.InstanceType;
- in_project = true;
- break;
+ if (0 == list.Count) {
+ // Fallback to known types
+ list.IsChanging = true;
+ parser.GetTypesVisibleFrom (Document.FileName, line, column, list);
}
- }
+ });
}
-
+ return list;
+ }// CompleteConstructor
+
+ public override ICompletionDataList CodeCompletionCommand (
+ CodeCompletionContext completionContext)
+ {
+ if (null == (Document.Project as ValaProject)){ return null; }
- if ((container == null) && (containerType == null))
- return null;
+ int pos = completionContext.TriggerOffset;
- if(null != container) {
- if (in_project) {
- foreach (LanguageItem li in info.AllItems ()) {
- if (li.Parent != null && li.Parent.Equals (container)) {
- list.Add (new CompletionData (li));
- }
- }
- } else {
- foreach (FileInformation fi in info.IncludedFiles[currentFileName]) {
- foreach (LanguageItem li in fi.AllItems ()) {
- if (li.Parent != null && li.Parent.Equals (container))
- list.Add (new CompletionData (li));
- }
- }
- }
- } else {
- if (in_project) {
- AddMembersWithParent (list, info.InstanceMembers (), containerType);
- } else {
- foreach (FileInformation fi in info.IncludedFiles[currentFileName]) {
- AddMembersWithParent (list, fi.InstanceMembers (), containerType);
- }
- }
+ ICompletionDataList list = HandleCodeCompletion(completionContext, Editor.GetText (pos - 1, pos)[0]);
+ if (null == list) {
+ list = GlobalComplete (completionContext);
}
-
return list;
}
- /// <summary>
- /// Adds completion data for children to a list
- /// </summary>
- /// <param name="list">
- /// The list to which completion data will be added
- /// <see cref="CompletionDataList"/>
- /// </param>
- /// <param name="items">
- /// A list of items to search
- /// <see cref="IEnumerable"/>
- /// </param>
- /// <param name="parentName">
- /// The name of the parent that will be matched
- /// <see cref="System.String"/>
- /// </param>
- public static void AddMembersWithParent(CompletionDataList list, IEnumerable<LanguageItem> items, string parentName) {
- foreach (LanguageItem li in items) {
- if (li.Parent != null && li.Parent.Name.EndsWith (parentName))
- list.Add (new CompletionData (li));
- }
+ private ValaCompletionDataList GetMembersOfItem (string itemFullName, int line, int column)
+ {
+ ProjectInformation info = Parser;
+ if (null == info){ return null; }
+
+ ValaCompletionDataList list = new ValaCompletionDataList ();
+ list.IsChanging = true;
+ info.Complete (itemFullName, Document.FileName, line, column, list);
+ return list;
}
-
- private ICompletionDataList GlobalComplete ()
+ private ValaCompletionDataList GlobalComplete (CodeCompletionContext context)
{
- ValaProject project = Document.Project as ValaProject;
-
- if (project == null)
- return null;
-
- ProjectInformation info = ProjectInformationManager.Instance.Get (project);
-
- CompletionDataList list = new CompletionDataList ();
-
- foreach (LanguageItem li in info.Containers ())
- if (li.Parent == null)
- list.Add (new CompletionData (li));
-
- foreach (Function f in info.Functions)
- if (f.Parent == null)
- list.Add (new CompletionData (f));
-
- foreach (Enumerator e in info.Enumerators)
- list.Add (new CompletionData (e));
-
- foreach (Macro m in info.Macros)
- list.Add (new CompletionData (m));
-
- string currentFileName = Document.FileName;
-
- if (info.IncludedFiles.ContainsKey (currentFileName)) {
- foreach (FileInformation fi in info.IncludedFiles[currentFileName]) {
- foreach (LanguageItem li in fi.Containers ())
- if (li.Parent == null)
- list.Add (new CompletionData (li));
-
- foreach (Function f in fi.Functions)
- if (f.Parent == null)
- list.Add (new CompletionData (f));
-
- foreach (Enumerator e in fi.Enumerators)
- list.Add (new CompletionData (e));
-
- foreach (Macro m in fi.Macros)
- list.Add (new CompletionData (m));
- }
- }
+ ProjectInformation info = Parser;
+ if (null == info){ return null; }
+ ValaCompletionDataList list = new ValaCompletionDataList ();
+ int line, column;
+ Editor.GetLineColumnFromPosition (context.TriggerOffset, out line, out column);
+ info.GetSymbolsVisibleFrom (Document.FileName, line, column, list);
return list;
}
public override IParameterDataProvider HandleParameterCompletion (
- ICodeCompletionContext completionContext, char completionChar)
+ CodeCompletionContext completionContext, char completionChar)
{
//System.Console.WriteLine("ValaTextEditorExtension.HandleParameterCompletion({0})", completionChar);
if (completionChar != '(')
return null;
- ValaProject project = Document.Project as ValaProject;
-
- if (project == null)
- return null;
-
- ProjectInformation info = ProjectInformationManager.Instance.Get (project);
+ ProjectInformation info = Parser;
+ if (null == info){ return null; }
int line, column;
Editor.GetLineColumnFromPosition (Editor.CursorPosition, out line, out column);
int position = Editor.GetPositionFromLineColumn (line, 1);
string lineText = Editor.GetText (position, Editor.CursorPosition - 1).TrimEnd ();
+ string functionName = string.Empty;
+
+ Match match = initializationRegex.Match (lineText);
+ if (match.Success && match.Groups["constructor"].Success) {
+ string[] tokens = match.Groups["constructor"].Value.Split('.');
+ string overload = tokens[tokens.Length-1];
+ string typename = (match.Groups["typename"].Success? match.Groups["typename"].Value: null);
+ int index = 0;
+
+ if (1 == tokens.Length || null == typename) {
+ // Ideally if typename is null and token length is longer than 1,
+ // we have an expression like: var w = new x.y.z(); and
+ // we would check whether z is the type or if y.z is an overload for type y
+ typename = overload;
+ } else if ("var".Equals (typename, StringComparison.Ordinal)) {
+ typename = match.Groups["constructor"].Value;
+ } else {
+ // Foo.Bar bar = new Foo.Bar.blah( ...
+ for (string[] typeTokens = typename.Split ('.'); 0 < typeTokens.Length && 0 < tokens.Length; ++index) {
+ if (!typeTokens[0].Equals (tokens[0], StringComparison.Ordinal)) {
+ break;
+ }
+ }
+ List<string> overloadTokens = new List<string> ();
+ for (int i=index; i<tokens.Length; ++i) {
+ overloadTokens.Add (tokens[i]);
+ }
+ overload = string.Join (".", overloadTokens.ToArray ());
+ }
+
+ // HACK: Generics
+ if (0 < (index = overload.IndexOf ("<", StringComparison.Ordinal))) {
+ overload = overload.Substring (0, index);
+ }
+ if (0 < (index = typename.IndexOf ("<", StringComparison.Ordinal))) {
+ typename = typename.Substring (0, index);
+ }
+
+ // Console.WriteLine ("Constructor: type {0}, overload {1}", typename, overload);
+ return new ParameterDataProvider (Document, info, typename, overload);
+ }
- int nameStart = lineText.LastIndexOfAny (allowedChars);
-
- nameStart++;
-
- string functionName = lineText.Substring (nameStart).Trim ();
-
- if (string.IsNullOrEmpty (functionName))
- return null;
-
- return new ParameterDataProvider (Document, info, functionName);
+ int nameStart = lineText.LastIndexOfAny (allowedChars) + 1;
+ functionName = lineText.Substring (nameStart).Trim ();
+ return (string.IsNullOrEmpty (functionName)? null: new ParameterDataProvider (Document, info, functionName));
}
private bool AllWhiteSpace (string lineText)
diff --git a/Makefile.am b/Makefile.am
index 4b77793..fef7525 100644
--- a/Makefile.am
+++ b/Makefile.am
@@ -33,40 +33,17 @@ FILES = \
Gui/OutputOptionsPanel.cs \
Gui/PackageDetails.cs \
Gui/ValaTextEditorExtension.cs \
- Navigation/ClassNodeBuilder.cs \
Navigation/ClassPadEventArgs.cs \
- Navigation/EnumerationNodeBuilder.cs \
- Navigation/EnumeratorNodeBuilder.cs \
- Navigation/FunctionNodeBuilder.cs \
- Navigation/GlobalsNodeBuilder.cs \
Navigation/LanguageItemCommandHandler.cs \
Navigation/LanguageItemEventArgs.cs \
- Navigation/MacroDefinitionsNodeBuilder.cs \
- Navigation/MacroNodeBuilder.cs \
- Navigation/MemberNodeBuilder.cs \
- Navigation/NamespaceNodeBuilder.cs \
+ Navigation/LanguageItemNodeBuilder.cs \
Navigation/ProjectNodeBuilderExtension.cs \
- Navigation/StructureNodeBuilder.cs \
- Navigation/TypedefNodeBuilder.cs \
- Navigation/UnionNodeBuilder.cs \
- Navigation/VariableNodeBuilder.cs \
- Parser/Class.cs \
- Parser/Enumeration.cs \
- Parser/Enumerator.cs \
+ Parser/CodeNode.cs \
Parser/Function.cs \
- Parser/LanguageItem.cs \
- Parser/Local.cs \
- Parser/Macro.cs \
- Parser/Member.cs \
- Parser/Namespace.cs \
Parser/ProjectInformation.cs \
Parser/ProjectInformationManager.cs \
- Parser/Structure.cs \
- Parser/Tag.cs \
- Parser/TagDatabaseManager.cs \
- Parser/Typedef.cs \
- Parser/Union.cs \
- Parser/Variable.cs \
+ Parser/ValaDocumentParser.cs \
+ Project/MakefileHandler.cs \
Project/ProjectPackage.cs \
Project/ProjectPackageCollection.cs \
Project/ProjectPackageEventArgs.cs \
@@ -98,6 +75,8 @@ RES = \
templates/EmptyValaSourceFile.xft.xml \
templates/SharedLibraryValaProject.xpt.xml \
templates/ValaTestFixture.xpt.xml \
+ templates/Makefile.am.template \
+ templates/Makefile.template \
ValaBinding.addin.xml
all: $(ASSEMBLY)
diff --git a/Makefile.in b/Makefile.in
index bf038c8..0008223 100644
--- a/Makefile.in
+++ b/Makefile.in
@@ -132,6 +132,7 @@ STRIP = @STRIP@
UNMANAGED_DEPENDENCIES_MONO_CFLAGS = @UNMANAGED_DEPENDENCIES_MONO_CFLAGS@
UNMANAGED_DEPENDENCIES_MONO_LIBS = @UNMANAGED_DEPENDENCIES_MONO_LIBS@
VERSION = @VERSION@
+VSCSHELL = @VSCSHELL@
abs_builddir = @abs_builddir@
abs_srcdir = @abs_srcdir@
abs_top_builddir = @abs_top_builddir@
@@ -204,40 +205,17 @@ FILES = \
Gui/OutputOptionsPanel.cs \
Gui/PackageDetails.cs \
Gui/ValaTextEditorExtension.cs \
- Navigation/ClassNodeBuilder.cs \
Navigation/ClassPadEventArgs.cs \
- Navigation/EnumerationNodeBuilder.cs \
- Navigation/EnumeratorNodeBuilder.cs \
- Navigation/FunctionNodeBuilder.cs \
- Navigation/GlobalsNodeBuilder.cs \
Navigation/LanguageItemCommandHandler.cs \
Navigation/LanguageItemEventArgs.cs \
- Navigation/MacroDefinitionsNodeBuilder.cs \
- Navigation/MacroNodeBuilder.cs \
- Navigation/MemberNodeBuilder.cs \
- Navigation/NamespaceNodeBuilder.cs \
+ Navigation/LanguageItemNodeBuilder.cs \
Navigation/ProjectNodeBuilderExtension.cs \
- Navigation/StructureNodeBuilder.cs \
- Navigation/TypedefNodeBuilder.cs \
- Navigation/UnionNodeBuilder.cs \
- Navigation/VariableNodeBuilder.cs \
- Parser/Class.cs \
- Parser/Enumeration.cs \
- Parser/Enumerator.cs \
+ Parser/CodeNode.cs \
Parser/Function.cs \
- Parser/LanguageItem.cs \
- Parser/Local.cs \
- Parser/Macro.cs \
- Parser/Member.cs \
- Parser/Namespace.cs \
Parser/ProjectInformation.cs \
Parser/ProjectInformationManager.cs \
- Parser/Structure.cs \
- Parser/Tag.cs \
- Parser/TagDatabaseManager.cs \
- Parser/Typedef.cs \
- Parser/Union.cs \
- Parser/Variable.cs \
+ Parser/ValaDocumentParser.cs \
+ Project/MakefileHandler.cs \
Project/ProjectPackage.cs \
Project/ProjectPackageCollection.cs \
Project/ProjectPackageEventArgs.cs \
@@ -269,6 +247,8 @@ RES = \
templates/EmptyValaSourceFile.xft.xml \
templates/SharedLibraryValaProject.xpt.xml \
templates/ValaTestFixture.xpt.xml \
+ templates/Makefile.am.template \
+ templates/Makefile.template \
ValaBinding.addin.xml
LOCAL_PKGCONFIG = PKG_CONFIG_PATH=../../local-config:$$PKG_CONFIG_PATH
diff --git a/Navigation/ClassNodeBuilder.cs b/Navigation/ClassNodeBuilder.cs
deleted file mode 100644
index 55c6f95..0000000
--- a/Navigation/ClassNodeBuilder.cs
+++ /dev/null
@@ -1,142 +0,0 @@
-//
-// ClassNodeBuilder.cs
-//
-// Authors:
-// Marcos David Marin Amador <MarcosMarin at gmail.com>
-//
-// Copyright (C) 2007 Marcos David Marin Amador
-//
-//
-// This source code is licenced under The MIT License:
-//
-// 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 Mono.Addins;
-
-using MonoDevelop.Ide.Gui;
-using MonoDevelop.Ide.Gui.Pads;
-using MonoDevelop.Core.Gui;
-using MonoDevelop.Projects;
-using MonoDevelop.Ide.Gui.Components;
-
-using MonoDevelop.ValaBinding.Parser;
-
-namespace MonoDevelop.ValaBinding.Navigation
-{
- public class ClassNodeBuilder : TypeNodeBuilder
- {
- public override Type NodeDataType {
- get { return typeof(Class); }
- }
-
- public override Type CommandHandlerType {
- get { return typeof(LanguageItemCommandHandler); }
- }
-
- public override string GetNodeName (ITreeNavigator thisNode, object dataObject)
- {
- return ((Class)dataObject).Name;
- }
-
- public override void BuildNode (ITreeBuilder treeBuilder,
- object dataObject,
- ref string label,
- ref Gdk.Pixbuf icon,
- ref Gdk.Pixbuf closedIcon)
- {
- Class c = (Class)dataObject;
-
- label = c.Name;
-
- switch (c.Access)
- {
- case AccessModifier.Public:
- icon = Context.GetIcon (Stock.Class);
- break;
- case AccessModifier.Protected:
- icon = Context.GetIcon (Stock.ProtectedClass);
- break;
- case AccessModifier.Private:
- icon = Context.GetIcon (Stock.PrivateClass);
- break;
- }
- }
-
- public override void BuildChildNodes (ITreeBuilder treeBuilder, object dataObject)
- {
- ValaProject p = treeBuilder.GetParentDataItem (typeof(ValaProject), false) as ValaProject;
-
- if (p == null) return;
-
- ProjectInformation info = ProjectInformationManager.Instance.Get (p);
-
- bool publicOnly = treeBuilder.Options["PublicApiOnly"];
- Class thisClass = (Class)dataObject;
-
- // Classes
- foreach (Class c in info.Classes)
- if (c.Parent != null && c.Parent.Equals (thisClass) && (!publicOnly || c.Access == AccessModifier.Public))
- treeBuilder.AddChild (c);
-
- // Structures
- foreach (Structure s in info.Structures)
- if (s.Parent != null && s.Parent.Equals (thisClass) && (!publicOnly || s.Access == AccessModifier.Public))
- treeBuilder.AddChild (s);
-
- // Unions
- foreach (Union u in info.Unions)
- if (u.Parent != null && u.Parent.Equals (thisClass) && (!publicOnly || u.Access == AccessModifier.Public))
- treeBuilder.AddChild (u);
-
- // Enumerations
- foreach (Enumeration e in info.Enumerations)
- if (e.Parent != null && e.Parent.Equals (thisClass) && (!publicOnly || e.Access == AccessModifier.Public))
- treeBuilder.AddChild (e);
-
- // Typedefs
- foreach (Typedef t in info.Typedefs)
- if (t.Parent != null && t.Parent.Equals (thisClass) && (!publicOnly || t.Access == AccessModifier.Public))
- treeBuilder.AddChild (t);
-
- // Functions
- foreach (Function f in info.Functions)
- if (f.Parent != null && f.Parent.Equals (thisClass) && (!publicOnly || f.Access == AccessModifier.Public))
- treeBuilder.AddChild (f);
-
- // Members
- foreach (Member m in info.Members)
- if (m.Parent != null && m.Parent.Equals (thisClass) && (!publicOnly || m.Access == AccessModifier.Public))
- treeBuilder.AddChild (m);
- }
-
- public override bool HasChildNodes (ITreeBuilder builder, object dataObject)
- {
- return true;
- }
-
- public override int CompareObjects (ITreeNavigator thisNode, ITreeNavigator otherNode)
- {
- return -1;
- }
- }
-}
diff --git a/Navigation/EnumeratorNodeBuilder.cs b/Navigation/EnumeratorNodeBuilder.cs
deleted file mode 100644
index 3fee07e..0000000
--- a/Navigation/EnumeratorNodeBuilder.cs
+++ /dev/null
@@ -1,83 +0,0 @@
-//
-// EnumeratorNodeBuilder.cs
-//
-// Authors:
-// Marcos David Marin Amador <MarcosMarin at gmail.com>
-//
-// Copyright (C) 2007 Marcos David Marin Amador
-//
-//
-// This source code is licenced under The MIT License:
-//
-// 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 Mono.Addins;
-
-using MonoDevelop.Ide.Gui;
-using MonoDevelop.Ide.Gui.Pads;
-using MonoDevelop.Core.Gui;
-using MonoDevelop.Projects;
-using MonoDevelop.Ide.Gui.Components;
-
-using MonoDevelop.ValaBinding.Parser;
-
-namespace MonoDevelop.ValaBinding.Navigation
-{
- public class EnumeratorNodeBuilder : TypeNodeBuilder
- {
- public override Type NodeDataType {
- get { return typeof(Enumerator); }
- }
-
- public override Type CommandHandlerType {
- get { return typeof(LanguageItemCommandHandler); }
- }
-
- public override string GetNodeName (ITreeNavigator thisNode, object dataObject)
- {
- return ((Enumerator)dataObject).Name;
- }
-
- public override void BuildNode (ITreeBuilder treeBuilder,
- object dataObject,
- ref string label,
- ref Gdk.Pixbuf icon,
- ref Gdk.Pixbuf closedIcon)
- {
- Enumerator e = (Enumerator)dataObject;
-
- label = e.Name;
- icon = Context.GetIcon (Stock.Literal);
- }
-
- public override bool HasChildNodes (ITreeBuilder builder, object dataObject)
- {
- return false;
- }
-
- public override int CompareObjects (ITreeNavigator thisNode, ITreeNavigator otherNode)
- {
- return DefaultSort;
- }
- }
-}
\ No newline at end of file
diff --git a/Navigation/FunctionNodeBuilder.cs b/Navigation/FunctionNodeBuilder.cs
deleted file mode 100644
index 3681c05..0000000
--- a/Navigation/FunctionNodeBuilder.cs
+++ /dev/null
@@ -1,99 +0,0 @@
-//
-// FunctionNodeBuilder.cs
-//
-// Authors:
-// Marcos David Marin Amador <MarcosMarin at gmail.com>
-//
-// Copyright (C) 2007 Marcos David Marin Amador
-//
-//
-// This source code is licenced under The MIT License:
-//
-// 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.IO;
-
-using Mono.Addins;
-
-using MonoDevelop.Ide.Gui;
-using MonoDevelop.Ide.Gui.Pads;
-using MonoDevelop.Core.Gui;
-using MonoDevelop.Projects;
-using MonoDevelop.Ide.Gui.Components;
-
-using MonoDevelop.ValaBinding.Parser;
-
-namespace MonoDevelop.ValaBinding.Navigation
-{
- public class FunctionNodeBuilder : TypeNodeBuilder
- {
- public override Type NodeDataType {
- get { return typeof(Function); }
- }
-
- public override Type CommandHandlerType {
- get { return typeof(LanguageItemCommandHandler); }
- }
-
- public override string GetNodeName (ITreeNavigator thisNode, object dataObject)
- {
- return ((Function)dataObject).Name;
- }
-
- public override void BuildNode (ITreeBuilder treeBuilder,
- object dataObject,
- ref string label,
- ref Gdk.Pixbuf icon,
- ref Gdk.Pixbuf closedIcon)
- {
- Function f = (Function)dataObject;
-
- label = f.Name;
-
- switch (f.Access)
- {
- case AccessModifier.Public:
- icon = Context.GetIcon (Stock.Method);
- break;
- case AccessModifier.Protected:
- icon = Context.GetIcon (Stock.ProtectedMethod);
- break;
- case AccessModifier.Private:
- icon = Context.GetIcon (Stock.PrivateMethod);
- break;
- }
- }
-
- public override bool HasChildNodes (ITreeBuilder builder, object dataObject)
- {
- return false;
- }
-
- public override int CompareObjects (ITreeNavigator thisNode, ITreeNavigator otherNode)
- {
- if (otherNode.DataItem is Typedef)
- return 1;
- else
- return -1;
- }
- }
-}
diff --git a/Navigation/GlobalsNodeBuilder.cs b/Navigation/GlobalsNodeBuilder.cs
deleted file mode 100644
index d1737f1..0000000
--- a/Navigation/GlobalsNodeBuilder.cs
+++ /dev/null
@@ -1,138 +0,0 @@
-//
-// GlobalsNodeBuilder.cs
-//
-// Authors:
-// Marcos David Marin Amador <MarcosMarin at gmail.com>
-//
-// Copyright (C) 2007 Marcos David Marin Amador
-//
-//
-// This source code is licenced under The MIT License:
-//
-// 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 Mono.Addins;
-
-using MonoDevelop.Ide.Gui;
-using MonoDevelop.Ide.Gui.Pads;
-using MonoDevelop.Core.Gui;
-using MonoDevelop.Projects;
-using MonoDevelop.Ide.Gui.Components;
-
-using MonoDevelop.ValaBinding.Parser;
-
-namespace MonoDevelop.ValaBinding.Navigation
-{
- public class Globals
- {
- private Project project;
-
- public Globals (Project project)
- {
- this.project = project;
- }
-
- public Project Project {
- get { return project; }
- }
- }
-
- public class GlobalsNodeBuilder : TypeNodeBuilder
- {
- public override Type NodeDataType {
- get { return typeof(Globals); }
- }
-
- public override string GetNodeName (ITreeNavigator thisNode, object dataObject)
- {
- return "Globals";
- }
-
- public override void BuildNode (ITreeBuilder treeBuilder,
- object dataObject,
- ref string label,
- ref Gdk.Pixbuf icon,
- ref Gdk.Pixbuf closedIcon)
- {
- label = "Globals";
- icon = Context.GetIcon (Stock.OpenFolder);
- closedIcon = Context.GetIcon (Stock.ClosedFolder);
- }
-
- public override void BuildChildNodes (ITreeBuilder treeBuilder, object dataObject)
- {
- ValaProject p = treeBuilder.GetParentDataItem (typeof(ValaProject), false) as ValaProject;
-
- if (p == null) return;
-
- ProjectInformation info = ProjectInformationManager.Instance.Get (p);
-
- // Classes
- foreach (Class c in info.Classes)
- if (c.Parent == null)
- treeBuilder.AddChild (c);
-
- // Structures
- foreach (Structure s in info.Structures)
- if (s.Parent == null)
- treeBuilder.AddChild (s);
-
- // Unions
- foreach (Union u in info.Unions)
- if (u.Parent == null)
- treeBuilder.AddChild (u);
-
- // Enumerations
- foreach (Enumeration e in info.Enumerations)
- if (e.Parent == null)
- treeBuilder.AddChild (e);
-
- // Typedefs
- foreach (Typedef t in info.Typedefs)
- if (t.Parent == null)
- treeBuilder.AddChild (t);
-
- // Functions
- foreach (Function f in info.Functions)
- if (f.Parent == null)
- treeBuilder.AddChild (f);
-
- // Variables
- foreach (Variable v in info.Variables)
- treeBuilder.AddChild (v);
- }
-
- public override bool HasChildNodes (ITreeBuilder builder, object dataObject)
- {
- return true;
- }
-
- public override int CompareObjects (ITreeNavigator thisNode, ITreeNavigator otherNode)
- {
- if (otherNode.DataItem is Structure)
- return 1;
- else
- return -1;
- }
- }
-}
diff --git a/Navigation/LanguageItemCommandHandler.cs b/Navigation/LanguageItemCommandHandler.cs
index dd517e4..021c12c 100644
--- a/Navigation/LanguageItemCommandHandler.cs
+++ b/Navigation/LanguageItemCommandHandler.cs
@@ -1,5 +1,5 @@
//
-// FunctionNodeBuilder.cs
+// LanguageItemCommandHandler.cs
//
// Authors:
// Marcos David Marin Amador <MarcosMarin at gmail.com>
@@ -48,25 +48,14 @@ namespace MonoDevelop.ValaBinding.Navigation
{
public override void ActivateItem ()
{
- LanguageItem item = (LanguageItem)CurrentNode.DataItem;
+ CodeNode item = (CodeNode)CurrentNode.DataItem;
- Document doc = IdeApp.Workbench.OpenDocument (item.File);
-
- int lineNum = 0;
- string line;
- bool isMacro = item is Macro;
- StringReader reader = new StringReader (doc.TextEditor.Text);
-
- while ((line = reader.ReadLine ()) != null) {
- lineNum++;
-
- if (line.Equals (item.Pattern) || (isMacro && line.StartsWith (item.Pattern))) {
- doc.TextEditor.JumpTo (lineNum, line.Length + 1);
- break;
+ if (null != item && !string.IsNullOrEmpty (item.File) && File.Exists (item.File)) {
+ Document doc = IdeApp.Workbench.OpenDocument (item.File);
+ if(null != doc && null != doc.TextEditor) {
+ doc.TextEditor.JumpTo (item.FirstLine, 0);
}
}
-
- reader.Close ();
}
}
}
diff --git a/Navigation/LanguageItemEventArgs.cs b/Navigation/LanguageItemEventArgs.cs
index 8066bd8..47995c5 100644
--- a/Navigation/LanguageItemEventArgs.cs
+++ b/Navigation/LanguageItemEventArgs.cs
@@ -39,14 +39,14 @@ namespace MonoDevelop.ValaBinding.Navigation
public class LanguageItemEventArgs : EventArgs
{
- LanguageItem item;
+ CodeNode item;
- public LanguageItemEventArgs (LanguageItem item)
+ public LanguageItemEventArgs (CodeNode item)
{
this.item = item;
}
- public LanguageItem Item {
+ public CodeNode Item {
get { return item; }
}
}
diff --git a/Navigation/EnumerationNodeBuilder.cs b/Navigation/LanguageItemNodeBuilder.cs
similarity index 57%
rename from Navigation/EnumerationNodeBuilder.cs
rename to Navigation/LanguageItemNodeBuilder.cs
index b724c02..82bb5dd 100644
--- a/Navigation/EnumerationNodeBuilder.cs
+++ b/Navigation/LanguageItemNodeBuilder.cs
@@ -1,11 +1,10 @@
//
-// EnumerationNodeBuilder.cs
+// LanguageItemNodeBuilder.cs
//
// Authors:
-// Marcos David Marin Amador <MarcosMarin at gmail.com>
-//
-// Copyright (C) 2007 Marcos David Marin Amador
+// Levi Bard <taktaktaktaktaktaktaktaktaktak at gmail.com>
//
+// Copyright (C) 2009 Levi Bard
//
// This source code is licenced under The MIT License:
//
@@ -30,6 +29,8 @@
//
using System;
+using System.Collections.Generic;
+using System.Threading;
using Mono.Addins;
@@ -43,10 +44,23 @@ using MonoDevelop.ValaBinding.Parser;
namespace MonoDevelop.ValaBinding.Navigation
{
- public class EnumerationNodeBuilder : TypeNodeBuilder
+ /// <summary>
+ /// Class pad node builder for all Vala language items
+ /// </summary>
+ public class LanguageItemNodeBuilder: TypeNodeBuilder
{
+ //// <value>
+ /// Container types
+ /// </value>
+ private static string[] containers = { "namespaces", "class", "struct", "enums" };
+
+ //// <value>
+ /// Sort order for nodes
+ /// </value>
+ private static string[] types = { "namespaces", "class", "struct", "property", "method", "signal", "field", "constants", "enums", "other" };
+
public override Type NodeDataType {
- get { return typeof(Enumeration); }
+ get { return typeof(CodeNode); }
}
public override Type CommandHandlerType {
@@ -55,7 +69,7 @@ namespace MonoDevelop.ValaBinding.Navigation
public override string GetNodeName (ITreeNavigator thisNode, object dataObject)
{
- return ((Enumeration)dataObject).Name;
+ return ((CodeNode)dataObject).Name;
}
public override void BuildNode (ITreeBuilder treeBuilder,
@@ -64,52 +78,53 @@ namespace MonoDevelop.ValaBinding.Navigation
ref Gdk.Pixbuf icon,
ref Gdk.Pixbuf closedIcon)
{
- Enumeration e = (Enumeration)dataObject;
-
- label = e.Name;
-
- switch (e.Access)
- {
- case AccessModifier.Public:
- icon = Context.GetIcon (Stock.Enum);
- break;
- case AccessModifier.Protected:
- icon = Context.GetIcon (Stock.ProtectedEnum);
- break;
- case AccessModifier.Private:
- icon = Context.GetIcon (Stock.PrivateEnum);
- break;
- }
+ CodeNode c = (CodeNode)dataObject;
+ label = c.Name;
+ icon = Context.GetIcon (c.Icon);
}
public override void BuildChildNodes (ITreeBuilder treeBuilder, object dataObject)
{
ValaProject p = treeBuilder.GetParentDataItem (typeof(ValaProject), false) as ValaProject;
-
- if (p == null) return;
+ if (p == null){ return; }
ProjectInformation info = ProjectInformationManager.Instance.Get (p);
- Enumeration thisEnumeration = (Enumeration)dataObject;
-
- // Enumerators
- foreach (Enumerator e in info.Enumerators)
- if (e.Parent != null && e.Parent.Equals (thisEnumeration))
- treeBuilder.AddChild (e);
+ bool publicOnly = treeBuilder.Options["PublicApiOnly"];
+ CodeNode thisCodeNode = (CodeNode)dataObject;
+
+ ThreadPool.QueueUserWorkItem (delegate (object o) {
+ foreach (CodeNode child in info.GetChildren (thisCodeNode)) {
+ CodeNode clone = child.Clone ();
+ Gtk.Application.Invoke (delegate (object ob, EventArgs ea) {
+ treeBuilder.AddChild (clone);
+ });
+ }
+ });
}
-
+
+ /// <summary>
+ /// Show all container types as having child nodes;
+ /// only check on expansion
+ /// </summary>
public override bool HasChildNodes (ITreeBuilder builder, object dataObject)
{
- return true;
+ return (0 <= Array.IndexOf<string> (containers, ((CodeNode)dataObject).NodeType));
}
public override int CompareObjects (ITreeNavigator thisNode, ITreeNavigator otherNode)
{
- if (otherNode.DataItem is Structure)
- return 1;
- else
- return -1;
+ if (null != thisNode && null != otherNode) {
+ CodeNode thisCN = thisNode.DataItem as CodeNode,
+ otherCN = otherNode.DataItem as CodeNode;
+
+ if (null != thisCN && null != otherCN) {
+ return Array.IndexOf<string>(types, thisCN.NodeType) -
+ Array.IndexOf<string>(types, otherCN.NodeType);
+ }
+ }
+
+ return -1;
}
}
}
-
diff --git a/Navigation/MacroDefinitionsNodeBuilder.cs b/Navigation/MacroDefinitionsNodeBuilder.cs
deleted file mode 100644
index d48f07a..0000000
--- a/Navigation/MacroDefinitionsNodeBuilder.cs
+++ /dev/null
@@ -1,107 +0,0 @@
-//
-// MacroDefinitionsNodeBuilder.cs
-//
-// Authors:
-// Marcos David Marin Amador <MarcosMarin at gmail.com>
-//
-// Copyright (C) 2007 Marcos David Marin Amador
-//
-//
-// This source code is licenced under The MIT License:
-//
-// 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 Mono.Addins;
-
-using MonoDevelop.Ide.Gui;
-using MonoDevelop.Ide.Gui.Pads;
-using MonoDevelop.Core.Gui;
-using MonoDevelop.Projects;
-using MonoDevelop.Ide.Gui.Components;
-
-using MonoDevelop.ValaBinding.Parser;
-
-namespace MonoDevelop.ValaBinding.Navigation
-{
- public class MacroDefinitions
- {
- private Project project;
-
- public MacroDefinitions (Project project)
- {
- this.project = project;
- }
-
- public Project Project {
- get { return project; }
- }
- }
-
- public class MacroDefinitionsNodeBuilder : TypeNodeBuilder
- {
- public override Type NodeDataType {
- get { return typeof(MacroDefinitions); }
- }
-
- public override string GetNodeName (ITreeNavigator thisNode, object dataObject)
- {
- return "Macro Definitions";
- }
-
- public override void BuildNode (ITreeBuilder treeBuilder,
- object dataObject,
- ref string label,
- ref Gdk.Pixbuf icon,
- ref Gdk.Pixbuf closedIcon)
- {
- label = "Macro Definitions";
- icon = Context.GetIcon (Stock.OpenFolder);
- closedIcon = Context.GetIcon (Stock.ClosedFolder);
- }
-
- public override void BuildChildNodes (ITreeBuilder treeBuilder, object dataObject)
- {
- ValaProject p = treeBuilder.GetParentDataItem (typeof(ValaProject), false) as ValaProject;
-
- if (p == null) return;
-
- ProjectInformation info = ProjectInformationManager.Instance.Get (p);
-
- foreach (Macro m in info.Macros)
- treeBuilder.AddChild (m);
- }
-
- public override bool HasChildNodes (ITreeBuilder builder, object dataObject)
- {
- return true;
- }
-
- public override int CompareObjects (ITreeNavigator thisNode, ITreeNavigator otherNode)
- {
- if (otherNode.DataItem is Globals)
- return 1;
- else
- return -1;
- }
- }
-}
\ No newline at end of file
diff --git a/Navigation/MacroNodeBuilder.cs b/Navigation/MacroNodeBuilder.cs
deleted file mode 100644
index f165742..0000000
--- a/Navigation/MacroNodeBuilder.cs
+++ /dev/null
@@ -1,79 +0,0 @@
-//
-// MacroNodeBuilder.cs
-//
-// Authors:
-// Marcos David Marin Amador <MarcosMarin at gmail.com>
-//
-// Copyright (C) 2007 Marcos David Marin Amador
-//
-//
-// This source code is licenced under The MIT License:
-//
-// 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.IO;
-
-using Mono.Addins;
-
-using MonoDevelop.Ide.Gui;
-using MonoDevelop.Ide.Gui.Pads;
-using MonoDevelop.Core.Gui;
-using MonoDevelop.Projects;
-using MonoDevelop.Ide.Gui.Components;
-
-using MonoDevelop.ValaBinding.Parser;
-
-namespace MonoDevelop.ValaBinding.Navigation
-{
- public class MacroNodeBuilder : TypeNodeBuilder
- {
- public override Type NodeDataType {
- get { return typeof(Macro); }
- }
-
- public override Type CommandHandlerType {
- get { return typeof(LanguageItemCommandHandler); }
- }
-
- public override string GetNodeName (ITreeNavigator thisNode, object dataObject)
- {
- return ((Macro)dataObject).Name;
- }
-
- public override void BuildNode (ITreeBuilder treeBuilder,
- object dataObject,
- ref string label,
- ref Gdk.Pixbuf icon,
- ref Gdk.Pixbuf closedIcon)
- {
- Macro m = (Macro)dataObject;
-
- label = m.Name;
- icon = Context.GetIcon (Stock.Literal);
- }
-
- public override bool HasChildNodes (ITreeBuilder builder, object dataObject)
- {
- return false;
- }
- }
-}
\ No newline at end of file
diff --git a/Navigation/MemberNodeBuilder.cs b/Navigation/MemberNodeBuilder.cs
deleted file mode 100644
index 7df2bf2..0000000
--- a/Navigation/MemberNodeBuilder.cs
+++ /dev/null
@@ -1,96 +0,0 @@
-//
-// FunctionNodeBuilder.cs
-//
-// Authors:
-// Marcos David Marin Amador <MarcosMarin at gmail.com>
-//
-// Copyright (C) 2007 Marcos David Marin Amador
-//
-//
-// This source code is licenced under The MIT License:
-//
-// 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.IO;
-
-using Mono.Addins;
-
-using MonoDevelop.Ide.Gui;
-using MonoDevelop.Ide.Gui.Pads;
-using MonoDevelop.Core.Gui;
-using MonoDevelop.Projects;
-using MonoDevelop.Ide.Gui.Components;
-
-using MonoDevelop.ValaBinding.Parser;
-
-namespace MonoDevelop.ValaBinding.Navigation
-{
- public class MemberNodeBuilder : TypeNodeBuilder
- {
- public override Type NodeDataType {
- get { return typeof(Member); }
- }
-
- public override Type CommandHandlerType {
- get { return typeof(LanguageItemCommandHandler); }
- }
-
- public override string GetNodeName (ITreeNavigator thisNode, object dataObject)
- {
- return ((Member)dataObject).Name;
- }
-
- public override void BuildNode (ITreeBuilder treeBuilder,
- object dataObject,
- ref string label,
- ref Gdk.Pixbuf icon,
- ref Gdk.Pixbuf closedIcon)
- {
- Member m = (Member)dataObject;
-
- label = m.Name;
-
- switch (m.Access)
- {
- case AccessModifier.Public:
- icon = Context.GetIcon (Stock.Field);
- break;
- case AccessModifier.Protected:
- icon = Context.GetIcon (Stock.ProtectedField);
- break;
- case AccessModifier.Private:
- icon = Context.GetIcon (Stock.PrivateField);
- break;
- }
- }
-
- public override bool HasChildNodes (ITreeBuilder builder, object dataObject)
- {
- return false;
- }
-
- public override int CompareObjects (ITreeNavigator thisNode, ITreeNavigator otherNode)
- {
- return 1;
- }
- }
-}
diff --git a/Navigation/NamespaceNodeBuilder.cs b/Navigation/NamespaceNodeBuilder.cs
deleted file mode 100644
index 9417816..0000000
--- a/Navigation/NamespaceNodeBuilder.cs
+++ /dev/null
@@ -1,135 +0,0 @@
-//
-// NamespaceNodeBuilder.cs
-//
-// Authors:
-// Marcos David Marin Amador <MarcosMarin at gmail.com>
-//
-// Copyright (C) 2007 Marcos David Marin Amador
-//
-//
-// This source code is licenced under The MIT License:
-//
-// 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 Mono.Addins;
-
-using MonoDevelop.Ide.Gui;
-using MonoDevelop.Ide.Gui.Pads;
-using MonoDevelop.Core.Gui;
-using MonoDevelop.Projects;
-using MonoDevelop.Ide.Gui.Components;
-
-using MonoDevelop.ValaBinding.Parser;
-
-namespace MonoDevelop.ValaBinding.Navigation
-{
- public class NamespaceNodeBuilder : TypeNodeBuilder
- {
- public override Type NodeDataType {
- get { return typeof(Namespace); }
- }
-
- public override Type CommandHandlerType {
- get { return typeof (LanguageItemCommandHandler); }
- }
-
- public override string GetNodeName (ITreeNavigator thisNode, object dataObject)
- {
- if (thisNode.Options["NestedNamespaces"])
- return ((Namespace)dataObject).Name;
- else
- return ((Namespace)dataObject).FullName;
- }
-
- public override void BuildNode (ITreeBuilder treeBuilder,
- object dataObject,
- ref string label,
- ref Gdk.Pixbuf icon,
- ref Gdk.Pixbuf closedIcon)
- {
- if (treeBuilder.Options["NestedNamespaces"])
- label = ((Namespace)dataObject).Name;
- else
- label = ((Namespace)dataObject).FullName;
-
- icon = Context.GetIcon (Stock.NameSpace);
- }
-
- public override void BuildChildNodes (ITreeBuilder treeBuilder, object dataObject)
- {
- ValaProject p = treeBuilder.GetParentDataItem (typeof(ValaProject), false) as ValaProject;
-
- if (p == null) return;
-
- ProjectInformation info = ProjectInformationManager.Instance.Get (p);
-
- Namespace thisNamespace = ((Namespace)dataObject);
-
- // Namespaces
- if (treeBuilder.Options["NestedNamespaces"])
- foreach (Namespace n in info.Namespaces)
- if (n.Parent != null && n.Parent.Equals (thisNamespace))
- treeBuilder.AddChild (n);
-
- // Classes
- foreach (Class c in info.Classes)
- if (c.Parent != null && c.Parent.Equals (thisNamespace))
- treeBuilder.AddChild (c);
-
- // Structures
- foreach (Structure s in info.Structures)
- if (s.Parent != null && s.Parent.Equals (thisNamespace))
- treeBuilder.AddChild (s);
-
- // Unions
- foreach (Union u in info.Unions)
- if (u.Parent != null && u.Parent.Equals (thisNamespace))
- treeBuilder.AddChild (u);
-
- // Enumerations
- foreach (Enumeration e in info.Enumerations)
- if (e.Parent != null && e.Parent.Equals (thisNamespace))
- treeBuilder.AddChild (e);
-
- // Typedefs
- foreach (Typedef t in info.Typedefs)
- if (t.Parent != null && t.Parent.Equals (thisNamespace))
- treeBuilder.AddChild (t);
-
- // Functions
- foreach (Function f in info.Functions)
- if (f.Parent != null && f.Parent.Equals (thisNamespace))
- treeBuilder.AddChild (f);
- }
-
- public override bool HasChildNodes (ITreeBuilder builder, object dataObject)
- {
- return true;
- }
-
- public override int CompareObjects (ITreeNavigator thisNode, ITreeNavigator otherNode)
- {
- return -1;
- }
- }
-}
diff --git a/Navigation/ProjectNodeBuilderExtension.cs b/Navigation/ProjectNodeBuilderExtension.cs
index 82486a5..cee537b 100644
--- a/Navigation/ProjectNodeBuilderExtension.cs
+++ b/Navigation/ProjectNodeBuilderExtension.cs
@@ -65,47 +65,31 @@ namespace MonoDevelop.ValaBinding.Navigation
protected override void Initialize ()
{
finishedBuildingTreeHandler = (ClassPadEventHandler)DispatchService.GuiDispatch (new ClassPadEventHandler (OnFinishedBuildingTree));
-
- TagDatabaseManager.Instance.FileUpdated += finishedBuildingTreeHandler;
}
public override void Dispose ()
{
- TagDatabaseManager.Instance.FileUpdated -= finishedBuildingTreeHandler;
}
public static void CreatePadTree (object o)
{
ValaProject p = o as ValaProject;
if (o == null) return;
+ ProjectInformation pi = ProjectInformationManager.Instance.Get (p);
- try {
- foreach (ProjectFile f in p.Files) {
- if (f.BuildAction == BuildAction.Compile)
- TagDatabaseManager.Instance.UpdateFileTags (p, f.Name);
- }
- foreach (ProjectPackage package in p.Packages) {
- TagDatabaseManager.Instance.UpdateFileTags(p, package.File);
+ ThreadPool.QueueUserWorkItem (delegate (object ob) {
+ try {
+ foreach (ProjectFile f in p.Files) {
+ if (f.BuildAction == BuildAction.Compile)
+ pi.AddFile (f.FilePath);
+ }
+ foreach (ProjectPackage package in p.Packages) {
+ if(!package.IsProject){ pi.AddPackage (p.Name); }
+ }
+ } catch (IOException) {
+ return;
}
- } catch (IOException) {
- return;
- }
- }
-
- private bool check_ctags = false;
- private bool have_ctags = false;
-
- private void CheckForCtags ()
- {
- check_ctags = true;
-
- try {
- ProcessWrapper p = Runtime.ProcessService.StartProcess ("ctags", "--version", null, null);
- p.WaitForOutput ();
- have_ctags = true;
- } catch {
- have_ctags = false;
- }
+ });
}
public override void BuildNode (ITreeBuilder treeBuilder,
@@ -114,24 +98,12 @@ namespace MonoDevelop.ValaBinding.Navigation
ref Gdk.Pixbuf icon,
ref Gdk.Pixbuf closedIcon)
{
- if (!check_ctags)
- CheckForCtags ();
-
- ValaProject p = dataObject as ValaProject;
-
- if (p == null)
- return;
-
- if (!have_ctags) {
- label = string.Format ("{0} <span foreground='red' size='small'>(CTags not installed)</span>", p.Name);
- }
}
public override void BuildChildNodes (ITreeBuilder builder, object dataObject)
{
ValaProject p = dataObject as ValaProject;
-
if (p == null) return;
bool nestedNamespaces = builder.Options["NestedNamespaces"];
@@ -139,21 +111,14 @@ namespace MonoDevelop.ValaBinding.Navigation
ProjectInformation info = ProjectInformationManager.Instance.Get (p);
// Namespaces
- foreach (Namespace n in info.Namespaces) {
- if (nestedNamespaces) {
- if (n.Parent == null) {
- builder.AddChild (n);
- }
- } else {
- builder.AddChild (n);
+ ThreadPool.QueueUserWorkItem (delegate (object o) {
+ foreach (CodeNode child in info.GetChildren (null)) {
+ CodeNode clone = child.Clone ();
+ Gtk.Application.Invoke (delegate (object ob, EventArgs ea) {
+ builder.AddChild (clone);
+ });
}
- }
-
-// // Globals
-// builder.AddChild (info.Globals);
-//
-// // Macro Definitions
-// builder.AddChild (info.MacroDefinitions);
+ });
}
public override bool HasChildNodes (ITreeBuilder builder, object dataObject)
@@ -174,17 +139,7 @@ namespace MonoDevelop.ValaBinding.Navigation
[CommandHandler (ValaProjectCommands.UpdateClassPad)]
public void UpdateClassPad ()
{
- ValaProject p = CurrentNode.DataItem as ValaProject;
-
- if (p == null) return;
-
- foreach (ProjectFile f in p.Files) {
- if (f.BuildAction == BuildAction.Compile)
- TagDatabaseManager.Instance.UpdateFileTags (p, f.Name);
- }
- foreach (ProjectPackage package in p.Packages) {
- TagDatabaseManager.Instance.UpdateFileTags(p, package.File);
- }
+ ProjectNodeBuilderExtension.CreatePadTree (CurrentNode.DataItem);
}
}
}
diff --git a/Navigation/StructureNodeBuilder.cs b/Navigation/StructureNodeBuilder.cs
deleted file mode 100644
index d806085..0000000
--- a/Navigation/StructureNodeBuilder.cs
+++ /dev/null
@@ -1,146 +0,0 @@
-//
-// StructureNodeBuilder.cs
-//
-// Authors:
-// Marcos David Marin Amador <MarcosMarin at gmail.com>
-//
-// Copyright (C) 2007 Marcos David Marin Amador
-//
-//
-// This source code is licenced under The MIT License:
-//
-// 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.IO;
-
-using Mono.Addins;
-
-using MonoDevelop.Ide.Gui;
-using MonoDevelop.Ide.Gui.Pads;
-using MonoDevelop.Core.Gui;
-using MonoDevelop.Projects;
-using MonoDevelop.Ide.Gui.Components;
-
-using MonoDevelop.ValaBinding.Parser;
-
-namespace MonoDevelop.ValaBinding.Navigation
-{
- public class StructureNodeBuilder : TypeNodeBuilder
- {
- public override Type NodeDataType {
- get { return typeof(Structure); }
- }
-
- public override Type CommandHandlerType {
- get { return typeof(LanguageItemCommandHandler); }
- }
-
- public override string GetNodeName (ITreeNavigator thisNode, object dataObject)
- {
- return ((Structure)dataObject).Name;
- }
-
- public override void BuildNode (ITreeBuilder treeBuilder,
- object dataObject,
- ref string label,
- ref Gdk.Pixbuf icon,
- ref Gdk.Pixbuf closedIcon)
- {
- Structure s = (Structure)dataObject;
-
- label = s.Name;
-
- switch (s.Access)
- {
- case AccessModifier.Public:
- icon = Context.GetIcon (Stock.Struct);
- break;
- case AccessModifier.Protected:
- icon = Context.GetIcon (Stock.ProtectedStruct);
- break;
- case AccessModifier.Private:
- icon = Context.GetIcon (Stock.PrivateStruct);
- break;
- }
- }
-
- public override void BuildChildNodes (ITreeBuilder treeBuilder, object dataObject)
- {
- ValaProject p = treeBuilder.GetParentDataItem (typeof(ValaProject), false) as ValaProject;
-
- if (p == null) return;
-
- bool publicOnly = treeBuilder.Options["PublicApiOnly"];
- ProjectInformation info = ProjectInformationManager.Instance.Get (p);
-
- Structure thisStruct = (Structure)dataObject;
-
- // Classes
- foreach (Class c in info.Classes)
- if (c.Parent != null && c.Parent.Equals (thisStruct) && (!publicOnly || c.Access == AccessModifier.Public))
- treeBuilder.AddChild (c);
-
- // Structures
- foreach (Structure s in info.Structures)
- if (s.Parent != null && s.Parent.Equals (thisStruct) && (!publicOnly || s.Access == AccessModifier.Public))
- treeBuilder.AddChild (s);
-
- // Unions
- foreach (Union u in info.Unions)
- if (u.Parent != null && u.Parent.Equals (thisStruct) && (!publicOnly || u.Access == AccessModifier.Public))
- treeBuilder.AddChild (u);
-
- // Enumerations
- foreach (Enumeration e in info.Enumerations)
- if (e.Parent != null && e.Parent.Equals (thisStruct) && (!publicOnly || e.Access == AccessModifier.Public))
- treeBuilder.AddChild (e);
-
- // Typedefs
- foreach (Typedef t in info.Typedefs)
- if (t.Parent != null && t.Parent.Equals (thisStruct) && (!publicOnly || t.Access == AccessModifier.Public))
- treeBuilder.AddChild (t);
-
- // Functions
- foreach (Function f in info.Functions)
- if (f.Parent != null && f.Parent.Equals (thisStruct) && (!publicOnly || f.Access == AccessModifier.Public))
- treeBuilder.AddChild (f);
-
- // Members
- foreach (Member m in info.Members)
- if (m.Parent != null && m.Parent.Equals (thisStruct) && (!publicOnly || m.Access == AccessModifier.Public))
- treeBuilder.AddChild (m);
- }
-
- public override bool HasChildNodes (ITreeBuilder builder, object dataObject)
- {
- return true;
- }
-
- public override int CompareObjects (ITreeNavigator thisNode, ITreeNavigator otherNode)
- {
- if (otherNode.DataItem is Class)
- return 1;
- else
- return -1;
- }
- }
-}
diff --git a/Navigation/TypedefNodeBuilder.cs b/Navigation/TypedefNodeBuilder.cs
deleted file mode 100644
index 5fc9ff4..0000000
--- a/Navigation/TypedefNodeBuilder.cs
+++ /dev/null
@@ -1,87 +0,0 @@
-//
-// TypedefNodeBuilder.cs
-//
-// Authors:
-// Marcos David Marin Amador <MarcosMarin at gmail.com>
-//
-// Copyright (C) 2007 Marcos David Marin Amador
-//
-//
-// This source code is licenced under The MIT License:
-//
-// 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.IO;
-
-using Mono.Addins;
-
-using MonoDevelop.Ide.Gui;
-using MonoDevelop.Ide.Gui.Pads;
-using MonoDevelop.Core.Gui;
-using MonoDevelop.Projects;
-using MonoDevelop.Ide.Gui.Components;
-
-using MonoDevelop.ValaBinding.Parser;
-
-namespace MonoDevelop.ValaBinding.Navigation
-{
- public class TypedefNodeBuilder : TypeNodeBuilder
- {
- public override Type NodeDataType {
- get { return typeof(Typedef); }
- }
-
- public override Type CommandHandlerType {
- get { return typeof(LanguageItemCommandHandler); }
- }
-
- public override string GetNodeName (ITreeNavigator thisNode, object dataObject)
- {
- return ((Typedef)dataObject).Name;
- }
-
- public override void BuildNode (ITreeBuilder treeBuilder,
- object dataObject,
- ref string label,
- ref Gdk.Pixbuf icon,
- ref Gdk.Pixbuf closedIcon)
- {
- Typedef t = (Typedef)dataObject;
-
- label = t.Name;
- icon = Context.GetIcon (Stock.Interface);
- }
-
- public override bool HasChildNodes (ITreeBuilder builder, object dataObject)
- {
- return false;
- }
-
- public override int CompareObjects (ITreeNavigator thisNode, ITreeNavigator otherNode)
- {
- if (otherNode.DataItem is Enumeration)
- return 1;
- else
- return -1;
- }
- }
-}
diff --git a/Navigation/UnionNodeBuilder.cs b/Navigation/UnionNodeBuilder.cs
deleted file mode 100644
index 770441f..0000000
--- a/Navigation/UnionNodeBuilder.cs
+++ /dev/null
@@ -1,146 +0,0 @@
-//
-// UnionNodeBuilder.cs
-//
-// Authors:
-// Marcos David Marin Amador <MarcosMarin at gmail.com>
-//
-// Copyright (C) 2007 Marcos David Marin Amador
-//
-//
-// This source code is licenced under The MIT License:
-//
-// 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.IO;
-using System.Reflection;
-
-using Mono.Addins;
-
-using MonoDevelop.Ide.Gui;
-using MonoDevelop.Ide.Gui.Pads;
-using MonoDevelop.Core.Gui;
-using MonoDevelop.Projects;
-using MonoDevelop.Ide.Gui.Components;
-
-using MonoDevelop.ValaBinding.Parser;
-
-namespace MonoDevelop.ValaBinding.Navigation
-{
- public class UnionNodeBuilder : TypeNodeBuilder
- {
- public override Type NodeDataType {
- get { return typeof(Union); }
- }
-
- public override Type CommandHandlerType {
- get { return typeof(LanguageItemCommandHandler); }
- }
-
- public override string GetNodeName (ITreeNavigator thisNode, object dataObject)
- {
- return ((Union)dataObject).Name;
- }
-
- public override void BuildNode (ITreeBuilder treeBuilder,
- object dataObject,
- ref string label,
- ref Gdk.Pixbuf icon,
- ref Gdk.Pixbuf closedIcon)
- {
- Union u = (Union)dataObject;
-
- label = u.Name;
-
- switch (u.Access)
- {
- case AccessModifier.Public:
- icon = Context.GetIcon ("md-union");
- break;
- case AccessModifier.Protected:
- icon = Context.GetIcon ("md-protected-union");
- break;
- case AccessModifier.Private:
- icon = Context.GetIcon ("md-private-union");
- break;
- }
- }
-
- public override void BuildChildNodes (ITreeBuilder treeBuilder, object dataObject)
- {
- ValaProject p = treeBuilder.GetParentDataItem (typeof(ValaProject), false) as ValaProject;
-
- if (p == null) return;
-
- ProjectInformation info = ProjectInformationManager.Instance.Get (p);
-
- Union thisUnion = (Union)dataObject;
-
- // Classes
- foreach (Class c in info.Classes)
- if (c.Parent != null && c.Parent.Equals (thisUnion))
- treeBuilder.AddChild (c);
-
- // Structures
- foreach (Structure s in info.Structures)
- if (s.Parent != null && s.Parent.Equals (thisUnion))
- treeBuilder.AddChild (s);
-
- // Unions
- foreach (Union u in info.Unions)
- if (u.Parent != null && u.Parent.Equals (thisUnion))
- treeBuilder.AddChild (u);
-
- // Enumerations
- foreach (Enumeration e in info.Enumerations)
- if (e.Parent != null && e.Parent.Equals (thisUnion))
- treeBuilder.AddChild (e);
-
- // Typedefs
- foreach (Typedef t in info.Typedefs)
- if (t.Parent != null && t.Parent.Equals (thisUnion))
- treeBuilder.AddChild (t);
-
- // Functions
- foreach (Function f in info.Functions)
- if (f.Parent != null && f.Parent.Equals (thisUnion))
- treeBuilder.AddChild (f);
-
- // Members
- foreach (Member m in info.Members)
- if (m.Parent != null && m.Parent.Equals (thisUnion))
- treeBuilder.AddChild (m);
- }
-
- public override bool HasChildNodes (ITreeBuilder builder, object dataObject)
- {
- return true;
- }
-
- public override int CompareObjects (ITreeNavigator thisNode, ITreeNavigator otherNode)
- {
- if (otherNode.DataItem is Structure)
- return 1;
- else
- return -1;
- }
- }
-}
diff --git a/Navigation/VariableNodeBuilder.cs b/Navigation/VariableNodeBuilder.cs
deleted file mode 100644
index 8afb78b..0000000
--- a/Navigation/VariableNodeBuilder.cs
+++ /dev/null
@@ -1,99 +0,0 @@
-//
-// VariableNodeBuilder.cs
-//
-// Authors:
-// Marcos David Marin Amador <MarcosMarin at gmail.com>
-//
-// Copyright (C) 2007 Marcos David Marin Amador
-//
-//
-// This source code is licenced under The MIT License:
-//
-// 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.IO;
-
-using Mono.Addins;
-
-using MonoDevelop.Ide.Gui;
-using MonoDevelop.Ide.Gui.Pads;
-using MonoDevelop.Core.Gui;
-using MonoDevelop.Projects;
-using MonoDevelop.Ide.Gui.Components;
-
-using MonoDevelop.ValaBinding.Parser;
-
-namespace MonoDevelop.ValaBinding.Navigation
-{
- public class VariableNodeBuilder : TypeNodeBuilder
- {
- public override Type NodeDataType {
- get { return typeof(Variable); }
- }
-
- public override Type CommandHandlerType {
- get { return typeof(LanguageItemCommandHandler); }
- }
-
- public override string GetNodeName (ITreeNavigator thisNode, object dataObject)
- {
- return ((Variable)dataObject).Name;
- }
-
- public override void BuildNode (ITreeBuilder treeBuilder,
- object dataObject,
- ref string label,
- ref Gdk.Pixbuf icon,
- ref Gdk.Pixbuf closedIcon)
- {
- Variable v = (Variable)dataObject;
-
- label = v.Name;
-
- switch (v.Access)
- {
- case AccessModifier.Public:
- icon = Context.GetIcon (Stock.Field);
- break;
- case AccessModifier.Protected:
- icon = Context.GetIcon (Stock.ProtectedField);
- break;
- case AccessModifier.Private:
- icon = Context.GetIcon (Stock.PrivateField);
- break;
- }
- }
-
- public override bool HasChildNodes (ITreeBuilder builder, object dataObject)
- {
- return false;
- }
-
- public override int CompareObjects (ITreeNavigator thisNode, ITreeNavigator otherNode)
- {
- if (otherNode.DataItem is Function)
- return 1;
- else
- return -1;
- }
- }
-}
diff --git a/Parser/Class.cs b/Parser/Class.cs
deleted file mode 100644
index c55e763..0000000
--- a/Parser/Class.cs
+++ /dev/null
@@ -1,49 +0,0 @@
-//
-// Class.cs
-//
-// Authors:
-// Levi Bard <taktaktaktaktaktaktaktaktaktak at gmail.com>
-//
-// Copyright (C) 2008 Levi Bard
-// Based on CBinding by Marcos David Marin Amador <MarcosMarin at gmail.com>
-//
-// This source code is licenced under The MIT License:
-//
-// 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 MonoDevelop.Projects;
-
-namespace MonoDevelop.ValaBinding.Parser
-{
- public class Class : LanguageItem
- {
- public Class (Tag tag, Project project, string ctags_output) : base (tag, project)
- {
- if (GetNamespace (tag, ctags_output)) return;
- if (GetClass (tag, ctags_output)) return;
- if (GetStructure (tag, ctags_output)) return;
- if (GetUnion (tag, ctags_output)) return;
- }
- }
-}
diff --git a/Parser/CodeNode.cs b/Parser/CodeNode.cs
new file mode 100644
index 0000000..0ba4667
--- /dev/null
+++ b/Parser/CodeNode.cs
@@ -0,0 +1,156 @@
+//
+// CodeNode.cs
+//
+// Authors:
+// Levi Bard <taktaktaktaktaktaktaktaktaktak at gmail.com>
+//
+// Copyright (C) 2009 Levi Bard
+//
+// This source code is licenced under The MIT License:
+//
+// 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 MonoDevelop.Core.Gui;
+
+namespace MonoDevelop.ValaBinding.Parser
+{
+ public enum AccessModifier {
+ Private,
+ Protected,
+ Public,
+ Internal
+ }
+
+ /// <summary>
+ /// Representation of a Vala code symbol
+ /// </summary>
+ public class CodeNode
+ {
+ private static Dictionary<string,string> publicIcons = new Dictionary<string, string> () {
+ { "namespaces", Stock.NameSpace },
+ { "class", Stock.Class },
+ { "struct", Stock.Struct },
+ { "enums", Stock.Enum },
+ { "field", Stock.Field },
+ { "method", Stock.Method },
+ { "property", Stock.Property },
+ { "constants", Stock.Literal },
+ { "signal", Stock.Event },
+ { "other", Stock.Delegate }
+ };
+
+ private static Dictionary<string,string> privateIcons = new Dictionary<string, string> () {
+ { "namespaces", Stock.NameSpace },
+ { "class", Stock.PrivateClass },
+ { "struct", Stock.PrivateStruct },
+ { "enums", Stock.PrivateEnum },
+ { "field", Stock.PrivateField },
+ { "method", Stock.PrivateMethod },
+ { "property", Stock.PrivateProperty },
+ { "constants", Stock.Literal },
+ { "signal", Stock.PrivateEvent },
+ { "other", Stock.PrivateDelegate }
+ };
+
+ private static Dictionary<string,string> protectedIcons = new Dictionary<string, string> () {
+ { "namespaces", Stock.NameSpace },
+ { "class", Stock.ProtectedClass },
+ { "struct", Stock.ProtectedStruct },
+ { "enums", Stock.ProtectedEnum },
+ { "field", Stock.ProtectedField },
+ { "method", Stock.ProtectedMethod },
+ { "property", Stock.ProtectedProperty },
+ { "constants", Stock.Literal },
+ { "signal", Stock.ProtectedEvent },
+ { "other", Stock.ProtectedDelegate }
+ };
+
+ private static Dictionary<AccessModifier,Dictionary<string,string>> iconTable = new Dictionary<AccessModifier, Dictionary<string, string>> () {
+ { AccessModifier.Public, publicIcons },
+ { AccessModifier.Internal, publicIcons },
+ { AccessModifier.Private, privateIcons },
+ { AccessModifier.Protected, protectedIcons }
+ };
+
+ public string Name{ get; set; }
+ public string FullName{ get; set; }
+ public AccessModifier Access{ get; set; }
+ public string NodeType{ get; set; }
+ public string Icon {
+ get{ return GetIconForType (NodeType, Access); }
+ }
+ public virtual string Description {
+ get{ return string.Format("{0} {1}", NodeType, Name); }
+ }
+ public string File{ get; set; }
+ public int FirstLine{ get; set; }
+ public int LastLine{ get; set; }
+
+ /// <value>
+ /// Whether this node is a class/struct/etc
+ /// </value>
+ public virtual bool IsContainerType
+ {
+ get {
+ return (0 <= Array.IndexOf (containerTypes, NodeType));
+ }
+ }
+ private static readonly string[] containerTypes = new string[]{ "namespaces", "class", "struct", "enums" };
+
+ public CodeNode () {}
+
+ public CodeNode (string type, string name, string parentname, string file, int first_line, int last_line)
+ {
+ Name = name;
+ NodeType = type;
+ FullName = (string.IsNullOrEmpty (parentname))? Name: string.Format ("{0}.{1}", parentname, name);
+ File = file;
+ FirstLine = first_line;
+ LastLine = (0 != last_line && last_line != first_line)? last_line-1: last_line;
+ }
+
+ public CodeNode (string type, string name, string parentname, string file, int first_line, int last_line, AccessModifier access): this (type, name, parentname, file, first_line, last_line)
+ {
+ Access = access;
+ }
+
+ public static string GetIconForType (string nodeType, AccessModifier visibility)
+ {
+ string icon = null;
+ iconTable[visibility].TryGetValue (nodeType, out icon);
+ return icon;
+ }
+
+ /// <summary>
+ /// Clone the current CodeNode
+ /// </summary>
+ public virtual CodeNode Clone ()
+ {
+ CodeNode clone = new CodeNode (NodeType, Name, string.Empty, File, FirstLine, LastLine, Access);
+ clone.FullName = FullName;
+ return clone;
+ }
+ }
+}
diff --git a/Parser/Enumeration.cs b/Parser/Enumeration.cs
deleted file mode 100644
index c916ab4..0000000
--- a/Parser/Enumeration.cs
+++ /dev/null
@@ -1,49 +0,0 @@
-//
-// Enumeration.cs
-//
-// Authors:
-// Levi Bard <taktaktaktaktaktaktaktaktaktak at gmail.com>
-//
-// Copyright (C) 2008 Levi Bard
-// Based on CBinding by Marcos David Marin Amador <MarcosMarin at gmail.com>
-//
-// This source code is licenced under The MIT License:
-//
-// 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 MonoDevelop.Projects;
-
-namespace MonoDevelop.ValaBinding.Parser
-{
- public class Enumeration : LanguageItem
- {
- public Enumeration (Tag tag, Project project, string ctags_output) : base (tag, project)
- {
- if (GetNamespace (tag, ctags_output)) return;
- if (GetClass (tag, ctags_output)) return;
- if (GetStructure (tag, ctags_output)) return;
- if (GetUnion (tag, ctags_output)) return;
- }
- }
-}
diff --git a/Parser/Enumerator.cs b/Parser/Enumerator.cs
deleted file mode 100644
index baeeb42..0000000
--- a/Parser/Enumerator.cs
+++ /dev/null
@@ -1,46 +0,0 @@
-//
-// Tag.cs
-//
-// Authors:
-// Levi Bard <taktaktaktaktaktaktaktaktaktak at gmail.com>
-//
-// Copyright (C) 2008 Levi Bard
-// Based on CBinding by Marcos David Marin Amador <MarcosMarin at gmail.com>
-//
-// This source code is licenced under The MIT License:
-//
-// 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 MonoDevelop.Projects;
-
-namespace MonoDevelop.ValaBinding.Parser
-{
- public class Enumerator : LanguageItem
- {
- public Enumerator (Tag tag, Project project, string ctags_output) : base (tag, project)
- {
- GetEnumeration (tag, ctags_output);
- }
- }
-}
diff --git a/Parser/Function.cs b/Parser/Function.cs
index 6d550de..04368f8 100644
--- a/Parser/Function.cs
+++ b/Parser/Function.cs
@@ -4,8 +4,7 @@
// Authors:
// Levi Bard <taktaktaktaktaktaktaktaktaktak at gmail.com>
//
-// Copyright (C) 2008 Levi Bard
-// Based on CBinding by Marcos David Marin Amador <MarcosMarin at gmail.com>
+// Copyright (C) 2009 Levi Bard
//
// This source code is licenced under The MIT License:
//
@@ -31,103 +30,48 @@
using System;
-
-using MonoDevelop.Projects;
+using System.Collections.Generic;
+using System.Text;
namespace MonoDevelop.ValaBinding.Parser
{
- public class Function : LanguageItem
+ /// <summary>
+ /// Representation of a Vala function
+ /// </summary>
+ public class Function: CodeNode
{
- private string[] parameters;
- private string signature;
- private bool is_const = false;
+ public string ReturnType{ get; protected set; }
+ public KeyValuePair<string,string>[] Parameters{ get; set; }
- public Function (Tag tag, Project project, string ctags_output) : base (tag, project)
- {
- signature = tag.Signature;
- ParseSignature (tag.Signature);
-
- if (tag.Kind == TagKind.Prototype) {
- Access = tag.Access;
- if (GetNamespace (tag, ctags_output)) return;
- if (GetClass (tag, ctags_output)) return;
- if (GetStructure (tag, ctags_output)) return;
- if (GetUnion (tag, ctags_output)) return;
- } else {
- // If it is not a prototype tag, we attempt to get the prototype tag
- // we need the prototype tag because the implementation tag
- // marks the belonging namespace as a if it were a class
- // and it does not have the access field.
- Tag prototypeTag = TagDatabaseManager.Instance.FindTag (Name, TagKind.Prototype, ctags_output);
-
- if (prototypeTag == null) {
- // It does not have a prototype tag which means it is inline
- // and when it is inline it does have all the info we need
-
- if (GetNamespace (tag, ctags_output)) return;
- if (GetClass (tag, ctags_output)) return;
- if (GetStructure (tag, ctags_output)) return;
- if (GetUnion (tag, ctags_output)) return;
-
- return;
+ public override string Description {
+ get {
+ StringBuilder sb = new StringBuilder ();
+ sb.AppendFormat ("{0} {1} (", ReturnType, Name);
+ foreach (KeyValuePair<string,string> param in Parameters) {
+ sb.AppendFormat ("{0} {1},", param.Value, param.Key);
}
+ if (',' == sb[sb.Length-1]){ sb = sb.Remove (sb.Length-1, 1); }
+ sb.Append(")");
- // we need to re-get the access
- Access = prototypeTag.Access;
-
- if (GetNamespace (prototypeTag, ctags_output)) return;
- if (GetClass (prototypeTag, ctags_output)) return;
- if (GetStructure (prototypeTag, ctags_output)) return;
- if (GetUnion (prototypeTag, ctags_output)) return;
- }
- }
-
- private void ParseSignature (string signature)
- {
- if (null == signature) return;
-
- string sig = signature;
-
- if (signature.EndsWith ("const")) {
- is_const = true;
- sig = signature.Substring (0, signature.Length - 6);
- sig = sig.Substring (1, sig.Length - 2);
- } else {
- sig = signature.Substring (1, signature.Length - 2);
+ return sb.ToString ();
}
-
- parameters = sig.Split (',');
-
- for (int i = 0; i < parameters.Length; i++)
- parameters[i] = parameters[i].Trim ();
- }
-
- public string[] Parameters {
- get { return parameters; }
- }
-
- public string Signature {
- get { return signature; }
- }
-
- public bool IsConst {
- get { return is_const; }
}
- public override bool Equals (object o)
+ public Function (string type, string name, string parentname, string file, int first_line, int last_line, AccessModifier access, string returnType, KeyValuePair<string,string>[] parameters):
+ base (type, name, parentname, file, first_line, last_line, access)
{
- Function other = o as Function;
-
- return (other != null &&
- FullName == other.FullName &&
- LanguageItem.Equals(Parent, other.Parent) &&
- Project.Equals(other.Project) &&
- Signature == other.Signature);
+ ReturnType = returnType;
+ Parameters = parameters;
}
- public override int GetHashCode ()
+ public override CodeNode Clone ()
{
- return base.GetHashCode () + parameters.GetHashCode ();
+ Function clone = new Function (NodeType, Name, string.Empty, File, FirstLine, LastLine, Access, ReturnType, null);
+ clone.FullName = FullName;
+ KeyValuePair<string,string>[] parameters = new KeyValuePair<string, string>[Parameters.Length];
+ Parameters.CopyTo (parameters, 0);
+ clone.Parameters = parameters;
+ return clone;
}
}
}
diff --git a/Parser/LanguageItem.cs b/Parser/LanguageItem.cs
deleted file mode 100644
index caa2e49..0000000
--- a/Parser/LanguageItem.cs
+++ /dev/null
@@ -1,255 +0,0 @@
-//
-// LanguageItem.cs
-//
-// Authors:
-// Levi Bard <taktaktaktaktaktaktaktaktaktak at gmail.com>
-//
-// Copyright (C) 2008 Levi Bard
-// Based on CBinding by Marcos David Marin Amador <MarcosMarin at gmail.com>
-//
-// This source code is licenced under The MIT License:
-//
-// 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.IO;
-
-using MonoDevelop.Core.Gui;
-using MonoDevelop.Projects;
-using MonoDevelop.Ide.Gui;
-
-namespace MonoDevelop.ValaBinding.Parser
-{
- public class LanguageItem
- {
- private Project project;
- private string name;
- private string file;
- private string pattern;
- private AccessModifier access;
- private LanguageItem parent;
-
- public LanguageItem (Tag tag, Project project)
- {
- this.project = project;
- this.name = tag.Name;
- this.file = tag.File;
- this.pattern = tag.Pattern;
- this.access = tag.Access;
- }
-
- /// <summary>
- /// Attempts to get the namespace encompassing the function
- /// <remarks>
- /// If it's a method then, even if the class it belongs to
- /// has a namespace, the method will not have a namespace, since
- /// it should be placed under the class node and not the namespace node
- /// </remarks>
- /// <returns>true on success and false if it does not have one.</returns>
- /// </summary>
- protected bool GetNamespace (Tag tag, string ctags_output)
- {
- string n;
-
- if ((n = tag.Namespace) != null) {
- int index = n.LastIndexOf (':');
-
- if (index > 0)
- n = n.Substring (index + 1);
-
- try {
- Tag namespaceTag = TagDatabaseManager.Instance.FindTag (
- n, TagKind.Namespace, ctags_output);
-
- if (namespaceTag != null)
- parent = new Namespace (namespaceTag, project, ctags_output);
-
- } catch (IOException ex) {
- MessageService.ShowException (ex);
- }
-
- return true;
- }
-
- return false;
- }
-
- protected bool GetClass (Tag tag, string ctags_output)
- {
- string c;
-
- if ((c = tag.Class) != null) {
- int index = c.LastIndexOf (':');
-
- if (index > 0)
- c = c.Substring (index + 1);
-
- try {
- Tag classTag = TagDatabaseManager.Instance.FindTag (
- c, TagKind.Class, ctags_output);
-
- if (classTag != null)
- parent = new Class (classTag, project, ctags_output);
-
- } catch (IOException ex) {
- MessageService.ShowException (ex);
- }
-
- return true;
- }
-
- return false;
- }
-
- protected bool GetStructure (Tag tag, string ctags_output)
- {
- string s;
-
- if ((s = tag.Structure) != null) {
- int index = s.LastIndexOf (':');
-
- if (index > 0)
- s = s.Substring (index + 1);
-
- try {
- Tag classTag = TagDatabaseManager.Instance.FindTag (
- s, TagKind.Structure, ctags_output);
-
- if (classTag != null)
- parent = new Structure (classTag, project, ctags_output);
-
- } catch (IOException ex) {
- MessageService.ShowException (ex);
- }
-
- return true;
- }
-
- return false;
- }
-
- protected bool GetEnumeration (Tag tag, string ctags_output)
- {
- string e;
-
- if ((e = tag.Enum) != null) {
- int index = e.LastIndexOf (':');
-
- if (index > 0)
- e = e.Substring (index + 1);
-
- try {
- Tag enumTag = TagDatabaseManager.Instance.FindTag (
- e, TagKind.Enumeration, ctags_output);
-
- if (enumTag != null)
- parent = new Enumeration (enumTag, project, ctags_output);
-
- } catch (IOException ex) {
- MessageService.ShowException (ex);
- }
-
- return true;
- }
-
- return false;
- }
-
- protected bool GetUnion (Tag tag, string ctags_output)
- {
- string u;
-
- if ((u = tag.Union) != null) {
- int index = u.LastIndexOf (':');
-
- if (index > 0)
- u = u.Substring (index + 1);
-
- try {
- Tag unionTag = TagDatabaseManager.Instance.FindTag (
- u, TagKind.Union, ctags_output);
-
- if (unionTag != null)
- parent = new Union (unionTag, project, ctags_output);
-
- } catch (IOException ex) {
- MessageService.ShowException (ex);
- }
-
- return true;
- }
-
- return false;
- }
-
- public Project Project {
- get { return project; }
- }
-
- public LanguageItem Parent {
- get { return parent; }
- set { parent = value; }
- }
-
- public string Name {
- get { return name; }
- }
-
- public string FullName {
- get {
- if (Parent != null)
- return Parent.FullName + "." + Name;
- return Name;
- }
- }
-
- public string File {
- get { return file; }
- }
-
- public string Pattern {
- get { return pattern; }
- }
-
- public AccessModifier Access {
- get { return access; }
- set { access = value; }
- }
-
- public override bool Equals (object o)
- {
- LanguageItem other = o as LanguageItem;
-
- if (other != null &&
- other.FullName.Equals (FullName) &&
- other.Project.Equals (project))
- return true;
-
- return false;
- }
-
- public override int GetHashCode ()
- {
- return (name + file + pattern + project.Name).GetHashCode ();
- }
- }
-}
diff --git a/Parser/Local.cs b/Parser/Local.cs
deleted file mode 100644
index 3b3aa6b..0000000
--- a/Parser/Local.cs
+++ /dev/null
@@ -1,48 +0,0 @@
-//
-// Local.cs
-//
-// Authors:
-// Levi Bard <taktaktaktaktaktaktaktaktaktak at gmail.com>
-//
-// Copyright (C) 2008 Levi Bard
-// Based on CBinding by Marcos David Marin Amador <MarcosMarin at gmail.com>
-//
-// This source code is licenced under The MIT License:
-//
-// 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 MonoDevelop.Projects;
-
-namespace MonoDevelop.ValaBinding.Parser
-{
- /// <summary>
- /// Class for local variables
- /// </summary>
- public class Local : Member
- {
- public Local (Tag tag, Project project, string ctags_output) : base (tag, project, ctags_output)
- {
- }
- }
-}
diff --git a/Parser/Macro.cs b/Parser/Macro.cs
deleted file mode 100644
index 750f78a..0000000
--- a/Parser/Macro.cs
+++ /dev/null
@@ -1,45 +0,0 @@
-//
-// Macro.cs
-//
-// Authors:
-// Levi Bard <taktaktaktaktaktaktaktaktaktak at gmail.com>
-//
-// Copyright (C) 2008 Levi Bard
-// Based on CBinding by Marcos David Marin Amador <MarcosMarin at gmail.com>
-//
-// This source code is licenced under The MIT License:
-//
-// 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 MonoDevelop.Projects;
-
-namespace MonoDevelop.ValaBinding.Parser
-{
- public class Macro : LanguageItem
- {
- public Macro (Tag tag, Project project) : base (tag, project)
- {
- }
- }
-}
diff --git a/Parser/Member.cs b/Parser/Member.cs
deleted file mode 100644
index 6f8ee13..0000000
--- a/Parser/Member.cs
+++ /dev/null
@@ -1,96 +0,0 @@
-//
-// Member.cs
-//
-// Authors:
-// Levi Bard <taktaktaktaktaktaktaktaktaktak at gmail.com>
-//
-// Copyright (C) 2008 Levi Bard
-// Based on CBinding by Marcos David Marin Amador <MarcosMarin at gmail.com>
-//
-// This source code is licenced under The MIT License:
-//
-// 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.Text.RegularExpressions;
-
-using MonoDevelop.Projects;
-
-namespace MonoDevelop.ValaBinding.Parser
-{
- public class Member : LanguageItem
- {
- public string InstanceType {
- get{ return instanceType; }
- }
- protected string instanceType;
-
- public bool IsPointer {
- get{ return isPointer; }
- }
- protected bool isPointer;
-
-
- public Member (Tag tag, Project project, string ctags_output) : base (tag, project)
- {
- GetInstanceType(tag);
-
- if (GetClass (tag, ctags_output)) return;
- if (GetStructure (tag, ctags_output)) return;
- if (GetUnion (tag, ctags_output)) return;
- }
-
- /// <summary>
- /// Regex for deriving the type of a variable,
- /// and whether it's a pointer,
- /// from an expression, e.g.
- /// static Foo.bar<string> *blah = NULL;
- /// </summary>
- public static Regex InstanceTypeExpression = new Regex (
- @"^\s*((public|private|protected|construct|static|friend|const|mutable|extern|struct|union|\w*\.|<[\w><:]*>)\s*)*(?<type>\w[\w\d]*)\s*(<.*>)?\s*(?<pointer>[*])?",
- RegexOptions.Compiled);
-
- /// <summary>
- /// Populates an instance's instanceType and isPointer fields
- /// by matching its pattern against InstanceTypeExpression
- /// </summary>
- /// <param name="tag">
- /// The partially-populated tag of an instance
- /// <see cref="Tag"/>
- /// </param>
- /// <returns>
- /// Whether the regex was successfully matched
- /// <see cref="System.Boolean"/>
- /// </returns>
- protected bool GetInstanceType (Tag tag) {
- Match m = InstanceTypeExpression.Match (tag.Pattern);
-
- if (null == m)
- return false;
-
- instanceType = m.Groups["type"].Value;
- isPointer = m.Groups["pointer"].Success;
-
- return true;
- }
- }
-}
diff --git a/Parser/Namespace.cs b/Parser/Namespace.cs
deleted file mode 100644
index da9c2cb..0000000
--- a/Parser/Namespace.cs
+++ /dev/null
@@ -1,46 +0,0 @@
-//
-// Namespace.cs
-//
-// Authors:
-// Levi Bard <taktaktaktaktaktaktaktaktaktak at gmail.com>
-//
-// Copyright (C) 2008 Levi Bard
-// Based on CBinding by Marcos David Marin Amador <MarcosMarin at gmail.com>
-//
-// This source code is licenced under The MIT License:
-//
-// 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 MonoDevelop.Projects;
-
-namespace MonoDevelop.ValaBinding.Parser
-{
- public class Namespace : LanguageItem
- {
- public Namespace (Tag tag, Project project, string ctags_output) : base (tag, project)
- {
- GetNamespace (tag, ctags_output);
- }
- }
-}
diff --git a/Parser/ProjectInformation.cs b/Parser/ProjectInformation.cs
index 461551d..6e00b0b 100644
--- a/Parser/ProjectInformation.cs
+++ b/Parser/ProjectInformation.cs
@@ -32,223 +32,579 @@
using System;
using System.Collections.Generic;
+using System.Diagnostics;
+using System.IO;
+using System.Threading;
+using System.Text;
+using System.Text.RegularExpressions;
using MonoDevelop.Projects;
+using MonoDevelop.Core;
+using MonoDevelop.Core.Execution;
+using MonoDevelop.Projects.Gui.Completion;
namespace MonoDevelop.ValaBinding.Parser
{
- public class FileInformation
+ /// <summary>
+ /// Class to obtain parse information for a project
+ /// </summary>
+ public class ProjectInformation
{
- protected Project project;
-
- protected List<Namespace> namespaces = new List<Namespace> ();
- protected List<Function> functions = new List<Function> ();
- protected List<Class> classes = new List<Class> ();
- protected List<Structure> structures = new List<Structure> ();
- protected List<Member> members = new List<Member> ();
- protected List<Variable> variables = new List<Variable> ();
- protected List<Macro> macros = new List<Macro> ();
- protected List<Enumeration> enumerations = new List<Enumeration> ();
- protected List<Enumerator> enumerators = new List<Enumerator> ();
- protected List<Union> unions = new List<Union> ();
- protected List<Typedef> typedefs = new List<Typedef> ();
- protected List<Local> locals = new List<Local> ();
-
- private string file_name;
- private bool is_filled = false;
-
- public FileInformation (Project project)
- {
- this.project = project;
- this.file_name = null;
- }
-
- public FileInformation (Project project, string filename)
- {
- this.project = project;
- this.file_name = filename;
- }
-
- public void Clear ()
- {
- namespaces.Clear ();
- functions.Clear ();
- classes.Clear ();
- structures.Clear ();
- members.Clear ();
- variables.Clear ();
- macros.Clear ();
- enumerations.Clear ();
- enumerators.Clear ();
- unions.Clear ();
- typedefs.Clear ();
- locals.Clear ();
- }
-
- public void RemoveFileInfo(string filename)
- {
- namespaces.RemoveAll(delegate(Namespace item){ return item.File == filename; });
- functions.RemoveAll(delegate(Function item){ return item.File == filename; });
- classes.RemoveAll(delegate(Class item){ return item.File == filename; });
- structures.RemoveAll(delegate(Structure item){ return item.File == filename; });
- members.RemoveAll(delegate(Member item){ return item.File == filename; });
- variables.RemoveAll(delegate(Variable item){ return item.File == filename; });
- macros.RemoveAll(delegate(Macro item){ return item.File == filename; });
- enumerations.RemoveAll(delegate(Enumeration item){ return item.File == filename; });
- enumerators.RemoveAll(delegate(Enumerator item){ return item.File == filename; });
- unions.RemoveAll(delegate(Union item){ return item.File == filename; });
- typedefs.RemoveAll(delegate(Typedef item){ return item.File == filename; });
- locals.RemoveAll(delegate(Local item){ return item.File == filename; });
+ private ProcessWrapper p;
+ private bool vtgInstalled = false;
+ private bool checkedVtgInstalled = false;
+ private Dictionary<string,List<Function>> methods;
+ private Dictionary<string,List<CodeNode>> cache;
+ private HashSet<string> files;
+ private HashSet<string> packages;
+ private DateTime lastRestarted;
+ string lockme = "lockme";
+
+ public Project Project{ get; set; }
+
+ //// <value>
+ /// Checks whether <see cref="http://code.google.com/p/vtg/">Vala Toys for GEdit</see>
+ /// is installed.
+ /// </value>
+ bool DepsInstalled {
+ get {
+ if (!checkedVtgInstalled) {
+ checkedVtgInstalled = true;
+ try {
+ Runtime.ProcessService.StartProcess ("vsc-shell", "--help", null, null).WaitForOutput ();
+ } catch {
+ LoggingService.LogWarning ("Cannot update Vala parser database because vsc-shell is not installed: {0}{1}",
+ Environment.NewLine, "http://code.google.com/p/vtg/");
+ return false;
+ }
+ vtgInstalled = true;
+ }
+ return vtgInstalled;
+ }
+ set {
+ //don't assume that the caller is correct :-)
+ if (value)
+ checkedVtgInstalled = false; //will re-determine on next getting
+ else
+ vtgInstalled = false;
+ }
}
-
- public IEnumerable<LanguageItem> Containers ()
+
+ private void RestartParser ()
{
- foreach (Namespace n in namespaces)
- yield return n;
+ // Don't restart more often than once/five seconds
+ lock (lockme) {
+ if (0 > DateTime.Now.AddSeconds (-5).CompareTo (lastRestarted)){ return; }
+ lastRestarted = DateTime.Now;
+ }
+
+ if (null != p) {
+ try {
+ if (!p.HasExited){ p.Kill (); }
+ p.Dispose ();
+ } catch {
+ // We don't care about anything that happens here.
+ }
+ }
- foreach (Class c in classes)
- yield return c;
+ // Don't destroy old cached results
+ // cache = new Dictionary<string,List<CodeNode>> ();
- foreach (Structure s in structures)
- yield return s;
+ if (DepsInstalled) {
+ p = Runtime.ProcessService.StartProcess ("vsc-shell", string.Empty, ".", (ProcessEventHandler)null, null, null, true);
+ p.StandardError.Close ();
+ foreach (string package in packages) {
+ AddPackage (package);
+ }
+ foreach (string file in files) {
+ AddFile (file);
+ }
+ }
- foreach (Enumeration e in enumerations)
- yield return e;
-
- foreach (Union u in unions)
- yield return u;
- }
+ lock(lockme){ lastRestarted = DateTime.Now; }
+ }// RestartParser
- // All items except macros
- public IEnumerable<LanguageItem> AllItems ()
+ private static Regex endOutputRegex = new Regex (@"^(\s*vsc-shell -\s*$|^\s*>)", RegexOptions.Compiled);
+ /// <summary>
+ /// Reads process output
+ /// </summary>
+ /// <returns>
+ /// A <see cref="System.String[]"/>: The lines output by the parser process
+ /// </returns>
+ private string[] ReadOutput ()
{
- foreach (Namespace n in namespaces)
- yield return n;
+ List<string> result = new List<string> ();
+ int count = 0;
- foreach (Class c in classes)
- yield return c;
+ DataReceivedEventHandler gotdata = delegate(object sender, DataReceivedEventArgs e) {
+ // Console.WriteLine(e.Data);
+ lock(result){ result.Add(e.Data); }
+ };
- foreach (Structure s in structures)
- yield return s;
+ p.OutputDataReceived += gotdata;
+
+ // for (int i=0; i<100; ++i) {
+ for (;;) {
+ p.BeginOutputReadLine ();
+ Thread.Sleep (50);
+ p.CancelOutputRead ();
+ lock (result) {
+ // if (count < result.Count){ i = 0; }
+ if (0 < result.Count && null != result[result.Count-1] && endOutputRegex.Match(result[result.Count-1]).Success) {
+ break;
+ }
+ count = result.Count;
+ }
+ p.StandardInput.WriteLine(string.Empty);
+ }
+ p.OutputDataReceived -= gotdata;
- foreach (Enumeration e in enumerations)
- yield return e;
+ return result.ToArray();
+ }// ReadOutput
+
+ /// <summary>
+ /// Sends a command to the parser
+ /// </summary>
+ /// <param name="command">
+ /// A <see cref="System.String"/>: The command to be sent to the parser
+ /// </param>
+ /// <param name="args">
+ /// A <see cref="System.Object[]"/>: string.Format-style arguments for command
+ /// </param>
+ /// <returns>
+ /// A <see cref="System.String[]"/>: The output from the command
+ /// </returns>
+ private string[] ParseCommand (string command, params object[] args)
+ {
+ string[] output = new string[0];
+ if (null == p){ return output; }
+
+ try {
+ lock (p) {
+ // Console.WriteLine (command, args);
+ p.StandardInput.WriteLine (string.Format (command, args));
+ output = ReadOutput ();
+ // foreach (string line in output){ Console.WriteLine (line); }
+ }
+ } catch (Exception e) {
+ Console.WriteLine("{0}{1}{2}", e.Message, Environment.NewLine, e.StackTrace);
+ }
- foreach (Union u in unions)
- yield return u;
+ if (0 == output.Length) { RestartParser (); }
- foreach (Function f in functions)
- yield return f;
+ return output;
+ }// ParseCommand
+
+ private ProjectInformation ()
+ {
+ files = new HashSet<string> ();
+ packages = new HashSet<string> ();
+ methods = new Dictionary<string,List<Function>> ();
+ cache = new Dictionary<string, List<CodeNode>> ();
+ lastRestarted = DateTime.Now.AddSeconds(-6);
+ RestartParser ();
+ }
+
+ public ProjectInformation (Project project): this ()
+ {
+ this.Project = project;
+ }
+
+ ~ProjectInformation ()
+ {
+ lock (p) {
+ try {
+ p.StandardInput.WriteLine("quit");
+ p.WaitForExit (100);
+ if (!p.HasExited) {
+ p.Kill ();
+ }
+ p.Dispose ();
+ } catch {
+ }
+ }
+ }
+
+ /// <summary>
+ /// Gets the children of a given code node
+ /// </summary>
+ public IList<CodeNode> GetChildren (CodeNode parent)
+ {
+ IList<CodeNode> children = new List<CodeNode> ();
- foreach (Member m in members)
- yield return m;
+ if (null == parent) {
+ string[] output = ParseCommand ("get-namespaces");
+ Match match;
+ CodeNode child;
+
+ foreach (string line in output) {
+ if (null != (child = ParseType (string.Empty, line))) {
+ children.Add (child);
+ }
+ }
+ } else if ("namespaces" != parent.NodeType) {
+ children = CacheCompleteType (parent.FullName, parent.File, parent.FirstLine, 0, null);
+ } else {
+ children = CacheCompleteType (parent.FullName, string.Empty, 0, 0, null);
+ }
+
+ return children;
+ }// GetChildren
+
+ private List<CodeNode> CacheCompleteType (string typename, string filename, int linenum, int column, ValaCompletionDataList results)
+ {
+ bool cached;
+ List<CodeNode> completion;
- foreach (Variable v in variables)
- yield return v;
+ lock (cache){ cached = cache.TryGetValue (typename, out completion); }
- foreach (Enumerator e in enumerators)
- yield return e;
+ if (cached) {
+ AddResults (completion, results);
+ ThreadPool.QueueUserWorkItem (delegate{
+ List<CodeNode> newcompletion = CompleteType (typename, filename, linenum, column, null);
+ if (null != newcompletion && 0 != newcompletion.Count) {
+ lock (cache){ cache[typename] = newcompletion; }
+ }
+ });
+ } else {
+ completion = CompleteType (typename, filename, linenum, column, results);
+ if (null != completion && 0 != completion.Count) {
+ lock (cache){ cache[typename] = completion; }
+ }
+ }
- foreach (Typedef t in typedefs)
- yield return t;
- }
+ return completion;
+ }// CacheCompleteType
- // Functions, fields
- public IEnumerable<LanguageItem> InstanceMembers ()
+ /// <summary>
+ /// Gets the completion list for a given type name in a given file
+ /// </summary>
+ internal List<CodeNode> CompleteType (string typename, string filename, int linenum, int column, ValaCompletionDataList results)
{
- foreach (Function f in functions)
- yield return f;
+ string[] output = ParseCommand ("complete {0} {1}", typename, filename);
+ List<CodeNode> children = new List<CodeNode> ();
+ CodeNode child;
+
+ foreach (string line in output) {
+ if (null != (child = ParseType (typename, line))) {
+ children.Add (child);
+ if (null != results) {
+ CompletionData datum = new CompletionData (child);
+ Gtk.Application.Invoke (delegate(object sender, EventArgs args){
+ results.Add (datum);
+ results.IsChanging = true;
+ });
+ }
+ }
+ }
- foreach (Member m in members)
- yield return m;
- }
-
- public Project Project {
- get { return project; }
- }
-
- public List<Namespace> Namespaces {
- get { return namespaces; }
- }
-
- public List<Function> Functions {
- get { return functions; }
- }
-
- public List<Class> Classes {
- get { return classes; }
- }
-
- public List<Structure> Structures {
- get { return structures; }
- }
-
- public List<Member> Members {
- get { return members; }
- }
-
- public List<Variable> Variables {
- get { return variables; }
- }
-
- public List<Macro> Macros {
- get { return macros; }
- }
-
- public List<Enumeration> Enumerations {
- get { return enumerations; }
- }
-
- public List<Enumerator> Enumerators {
- get { return enumerators; }
- }
-
- public List<Union> Unions {
- get { return unions; }
+ if (null != results) {
+ Gtk.Application.Invoke (delegate(object sender, EventArgs args){
+ results.IsChanging = false;
+ });
+ }
+
+ return children;
}
+
+ /// <summary>
+ /// Adds a file to be parsed
+ /// </summary>
+ public void AddFile (string filename)
+ {
+ lock (files) {
+ // if (files.Contains (filename)){ return; }
+ files.Add (filename);
+ }
+ ThreadPool.QueueUserWorkItem (delegate {
+ ParseCommand ("add-source {0}", filename);
+ });
+ }// AddFile
+
+ /// <summary>
+ /// Removes a file from the parse list
+ /// </summary>
+ public void RemoveFile (string filename)
+ {
+ lock (files) { files.Remove (filename); }
+ ThreadPool.QueueUserWorkItem (delegate {
+ ParseCommand ("remove-source {0}", filename);
+ });
+ }// RemoveFile
+
+ /// <summary>
+ /// Adds a package to be parsed
+ /// </summary>
+ public void AddPackage (string packagename)
+ {
+ lock (packages) {
+ // if (packages.Contains (packagename)){ return; }
+ packages.Add (packagename);
+ }
+ ThreadPool.QueueUserWorkItem (delegate {
+ ParseCommand ("add-package {0}", packagename);
+ });
+ }// AddPackage
+
+ /// <summary>
+ /// Tells the parser to reparse
+ /// </summary>
+ public void Reparse ()
+ {
+ //ParseCommand ("reparse");
+ RestartParser ();
+ }// Reparse
+
+ private static Regex typeNameRegex = new Regex (@"vsc-shell - typename for [^:]+: (?<type>[^\s]+)\s*$", RegexOptions.Compiled);
+ /// <summary>
+ /// Gets the completion list for a given symbol at a given location
+ /// </summary>
+ public void Complete (string symbol, string filename, int line, int column, ValaCompletionDataList results)
+ {
+ if (cache.ContainsKey (symbol)){ CacheCompleteType (symbol, filename, line, column, results); }
+ else ThreadPool.QueueUserWorkItem (delegate{
+ string expressionType = GetExpressionType (symbol, filename, line, column);
+ CacheCompleteType (expressionType, filename, line, column, results);
+ });
+ }// Complete
+
+ /// <summary>
+ /// Get the type of a given expression
+ /// </summary>
+ public string GetExpressionType (string symbol, string filename, int line, int column)
+ {
+ AddFile (filename);
+ string[] responses = ParseCommand ("type-name {0} {1} {2} {3}", symbol, filename, line, column);
+ Match match;
+
+ foreach (string response in responses) {
+ match = typeNameRegex.Match (response);
+ if (match.Success) {
+ return match.Groups["type"].Value;
+ }
+ }
+
+ return symbol;
+ }// GetExpressionType
- public List<Typedef> Typedefs {
- get { return typedefs; }
- }
+ /// <summary>
+ /// Get overloads for a method
+ /// </summary>
+ public List<Function> GetOverloads (string name)
+ {
+ lock (methods) {
+ return (methods.ContainsKey (name))? methods[name]: new List<Function> ();
+ }
+ }// GetOverloads
- public List<Local> Locals {
- get { return locals; }
- }
+ /// <summary>
+ /// Get constructors for a given type
+ /// </summary>
+ public List<Function> GetConstructorsForType (string typename, string filename, int line, int column, ValaCompletionDataList results)
+ {
+ string[] tokens = typename.Split ('.');
+ string baseTypeName = tokens[tokens.Length-1];
+ List<Function> constructors = new List<Function> ();
+ List<CodeNode> cachedNode = null;
+
+ if (cache.ContainsKey (typename)) {
+ cachedNode = cache[typename];
+ } else {
+ foreach (string cachedType in cache.Keys) {
+ if (cachedType.EndsWith (typename)) {
+ cachedNode = cache[cachedType];
+ break;
+ }
+ }
+ }
+
+ if (null != cachedNode) {
+ constructors = cachedNode.FindAll (delegate (CodeNode node){
+ return ("method" == node.NodeType &&
+ (baseTypeName == node.Name || node.Name.StartsWith (baseTypeName + ".")));
+ }).ConvertAll<Function> (delegate (CodeNode node){
+ if (null != results) {
+ CompletionData datum = new CompletionData (node);
+ Gtk.Application.Invoke (delegate (object sender, EventArgs args){
+ results.Add (datum);
+ results.IsChanging = true;
+ });
+ }
+ return node as Function;
+ });
+ } else {
+ ThreadPool.QueueUserWorkItem (delegate (object o){ CacheCompleteType (typename, filename, line, column, null); });
+ }
+
+ if (null != results) {
+ Gtk.Application.Invoke (delegate (object sender, EventArgs args){
+ results.IsChanging = false;
+ });
+ }
+
+ return constructors;
+ }// GetConstructorsForType
- public string FileName {
- get { return file_name; }
- set { file_name = value; }
- }
+ /// <summary>
+ /// Get constructors for a given expression
+ /// </summary>
+ public List<Function> GetConstructorsForExpression (string expression, string filename, int line, int column, ValaCompletionDataList results)
+ {
+ string typename = GetExpressionType (expression, filename, line, column);
+ return GetConstructorsForType (typename, filename, line, column, results);
+ }// GetConstructorsForExpression
- public bool IsFilled {
- get { return is_filled; }
- set { is_filled = value; }
- }
- }
-
- public class ProjectInformation : FileInformation
- {
-// private Globals globals;
-// private MacroDefinitions macroDefs;
+ /// <summary>
+ /// Get types visible from a given source location
+ /// </summary>
+ public void GetTypesVisibleFrom (string filename, int line, int column, ValaCompletionDataList results)
+ {
+ results.IsChanging = true;
+
+ ThreadPool.QueueUserWorkItem (delegate{
+ string[] output = ParseCommand ("visible-types {0} {1} {2}", filename, line, column);
+ CodeNode child;
+
+ foreach (string outputline in output) {
+ if (null != (child = ParseType (string.Empty, outputline))) {
+ CompletionData datum = new CompletionData (child);
+ Gtk.Application.Invoke (delegate (object sender, EventArgs args){
+ results.Add (datum);
+ results.IsChanging = true;
+ });
+ }
+ }
+ Gtk.Application.Invoke (delegate (object sender, EventArgs args){
+ results.IsChanging = false;
+ });
+ });
+ }// GetTypesVisibleFrom
- private Dictionary<string, List<FileInformation>> includedFiles = new Dictionary<string, List<FileInformation>> ();
+ /// <summary>
+ /// Get symbols visible from a given source location
+ /// </summary>
+ public void GetSymbolsVisibleFrom (string filename, int line, int column, ValaCompletionDataList results)
+ {
+ results.IsChanging = true;
+
+ ThreadPool.QueueUserWorkItem (delegate{
+ string[] output = ParseCommand ("visible-symbols {0} {1} {2}", filename, line, column);
+ CodeNode child;
+
+ foreach (string outputline in output) {
+ if (null != (child = ParseType (string.Empty, outputline))) {
+ CompletionData datum = new CompletionData (child);
+ Gtk.Application.Invoke (delegate (object sender, EventArgs args){
+ results.Add (datum);
+ results.IsChanging = true;
+ });
+ }
+ }
+ Gtk.Application.Invoke (delegate (object sender, EventArgs args){
+ results.IsChanging = false;
+ });
+ });
+ }// GetSymbolsVisibleFrom
- public ProjectInformation (Project project) : base (project)
+ private static Regex completionRegex = new Regex (@"^\s*vsc-shell - (?<type>[^:]+):(?<name>[^\s:]+)(:(?<modifier>[^;]*);(?<static>[^:]*))?(:(?<returntype>[^;]*);(?<ownership>[^:]*))?(:(?<args>[^:]*);)?((?<file>[^:]*):(?<first_line>\d+);((?<last_line>\d+);)?)?", RegexOptions.Compiled);
+ /// <summary>
+ /// Parse out a CodeNode from a vsc-shell description string
+ /// </summary>
+ private CodeNode ParseType (string typename, string typeDescription)
{
-// globals = new Globals (project);
-// macroDefs = new MacroDefinitions (project);
- }
+ Match match = completionRegex.Match (typeDescription);
+
+ if (match.Success) {
+ string childType = match.Groups["type"].Value;
+ string name = match.Groups["name"].Value;
+ AccessModifier access = AccessModifier.Public;
+ string[] argtokens = typename.Split ('.');
+ string baseTypeName = argtokens[argtokens.Length-1];
+ string file = match.Groups["file"].Success? match.Groups["file"].Value: string.Empty;
+ int first_line = match.Groups["first_line"].Success? int.Parse(match.Groups["first_line"].Value): 0;
+ int last_line = match.Groups["last_line"].Success? int.Parse(match.Groups["last_line"].Value): first_line;
+
+ switch (match.Groups["modifier"].Value) {
+ case "private":
+ access = AccessModifier.Private;
+ break;
+ case "protected":
+ access = AccessModifier.Protected;
+ break;
+ case "internal":
+ access = AccessModifier.Internal;
+ break;
+ default:
+ access = AccessModifier.Public;
+ break;
+ }
+
+ switch (childType) {
+ case "method":
+ List<KeyValuePair<string,string>> paramlist = new List<KeyValuePair<string,string>>();
+ string returnType = (match.Groups["returntype"].Success)? match.Groups["returntype"].Value: string.Empty;
+ if (name == baseTypeName || name.StartsWith (baseTypeName + ".")) {
+ returnType = string.Empty;
+ }
+
+ if (match.Groups["args"].Success) {
+ StringBuilder args = new StringBuilder ();
+ foreach (string arg in match.Groups["args"].Value.Split (';')) {
+ argtokens = arg.Split (',');
+ if (3 == argtokens.Length) {
+ paramlist.Add (new KeyValuePair<string,string> (argtokens[0], string.Format("{0} {1}", argtokens[2], argtokens[1])));
+ }
+ }
+ }
+ Function function = new Function (childType, name, typename, file, first_line, last_line, access, returnType, paramlist.ToArray ());
+ if (!methods.ContainsKey (function.Name)){ methods[function.Name] = new List<Function> (); }
+ methods[function.Name].Add (function);
+ return function;
+ break;
+ default:
+ return new CodeNode (childType, name, typename, file, first_line, last_line, access);
+ break;
+ }
+ }
+
+ return null;
+ }// ParseType
-// public Globals Globals {
-// get { return globals; }
-// }
-//
-// public MacroDefinitions MacroDefinitions {
-// get { return macroDefs; }
-// }
+ /// <summary>
+ /// Add results to a ValaCompletionDataList on the GUI thread
+ /// </summary>
+ private static void AddResults (IList<CodeNode> list, ValaCompletionDataList results)
+ {
+ if (null == results){ return; }
+
+ Gtk.Application.Invoke (delegate(object sender, EventArgs args){
+ results.IsChanging = true;
+ foreach (CodeNode node in list) {
+ results.Add (new CompletionData (node));
+ // results.IsChanging = true;
+ }
+ results.IsChanging = false;
+ });
+ }// AddResults
- public Dictionary<string, List<FileInformation>> IncludedFiles {
- get { return includedFiles; }
- }
+ public List<CodeNode> GetClassesForFile (string file)
+ {
+ List<CodeNode> classes = new List<CodeNode> ();
+ if (null != p) {
+ AddFile (file);
+ CodeNode node = null;
+
+ lock(p){ p.StandardInput.WriteLine ("reparse both"); }
+
+ foreach (string result in ParseCommand ("get-classes {0}", file)) {
+ node = ParseType (string.Empty, result);
+ if(null != node && node.IsContainerType) {
+ classes.Add (node);
+ }
+ }
+ }
+
+ return classes;
+ }// GetClassesForFile
}
}
diff --git a/Parser/ProjectInformationManager.cs b/Parser/ProjectInformationManager.cs
index a14cfa4..e4cd1be 100644
--- a/Parser/ProjectInformationManager.cs
+++ b/Parser/ProjectInformationManager.cs
@@ -48,11 +48,14 @@ namespace MonoDevelop.ValaBinding.Parser
private ProjectInformationManager ()
{
}
-
+
+ /// <summary>
+ /// Gets or creates the ProjectInformation for a given project
+ /// </summary>
public ProjectInformation Get (Project project)
{
foreach (ProjectInformation p in projects) {
- if (project.Equals (p.Project)) {
+ if (project == p.Project || (null != project && project.Equals (p.Project))) {
return p;
}
}
@@ -64,10 +67,10 @@ namespace MonoDevelop.ValaBinding.Parser
}
public static ProjectInformationManager Instance {
- get {
+ get {
if (instance == null)
instance = new ProjectInformationManager ();
-
+
return instance;
}
}
diff --git a/Parser/Structure.cs b/Parser/Structure.cs
deleted file mode 100644
index e2b0e8d..0000000
--- a/Parser/Structure.cs
+++ /dev/null
@@ -1,49 +0,0 @@
-//
-// Structure.cs
-//
-// Authors:
-// Levi Bard <taktaktaktaktaktaktaktaktaktak at gmail.com>
-//
-// Copyright (C) 2008 Levi Bard
-// Based on CBinding by Marcos David Marin Amador <MarcosMarin at gmail.com>
-//
-// This source code is licenced under The MIT License:
-//
-// 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 MonoDevelop.Projects;
-
-namespace MonoDevelop.ValaBinding.Parser
-{
- public class Structure : LanguageItem
- {
- public Structure (Tag tag, Project project, string ctags_output) : base (tag, project)
- {
- if (GetNamespace (tag, ctags_output)) return;
- if (GetClass (tag, ctags_output)) return;
- if (GetStructure (tag, ctags_output)) return;
- if (GetUnion (tag, ctags_output)) return;
- }
- }
-}
diff --git a/Parser/Tag.cs b/Parser/Tag.cs
deleted file mode 100644
index e83b549..0000000
--- a/Parser/Tag.cs
+++ /dev/null
@@ -1,145 +0,0 @@
-//
-// Tag.cs
-//
-// Authors:
-// Levi Bard <taktaktaktaktaktaktaktaktaktak at gmail.com>
-//
-// Copyright (C) 2008 Levi Bard
-// Based on CBinding by Marcos David Marin Amador <MarcosMarin at gmail.com>
-//
-// This source code is licenced under The MIT License:
-//
-// 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.IO;
-
-namespace MonoDevelop.ValaBinding.Parser
-{
- public enum TagKind {
- Class = 'c',
- Macro = 'd',
- Enumerator = 'e',
- Function = 'm',
- Enumeration = 'g',
- Local = 'l',
- Member = 'f',
- Namespace = 'n',
- Prototype = 'm',
- Structure = 's',
- Typedef = 't',
- Union = 'u',
- Variable = 'v',
- ExternalVariable = 'x',
- Unknown = ' '
- }
-
- public enum AccessModifier {
- Private,
- Protected,
- Public
- }
-
- public class Tag
- {
- private string name;
- private string file;
- private string pattern;
- private TagKind kind;
- private AccessModifier access;
- private string field_class;
- private string field_namespace;
- private string field_struct;
- private string field_union;
- private string field_enum;
- private string field_signature;
-
- public Tag (string name,
- string file,
- string pattern,
- TagKind kind,
- AccessModifier access,
- string field_class,
- string field_namespace,
- string field_struct,
- string field_union,
- string field_enum,
- string field_signature)
- {
- this.name = name;
- this.file = file;
- this.pattern = pattern;
- this.kind = kind;
- this.access = access;
- this.field_class = field_class;
- this.field_namespace = field_namespace;
- this.field_struct = field_struct;
- this.field_union = field_union;
- this.field_enum = field_enum;
- this.field_signature = field_signature;
- }
-
- public string Name {
- get { return name; }
- }
-
- public string File {
- get { return file; }
- }
-
- public string Pattern {
- get { return pattern; }
- }
-
- public TagKind Kind {
- get { return kind; }
- }
-
- public AccessModifier Access {
- get { return access; }
- }
-
- public string Class {
- get { return field_class; }
- }
-
- public string Namespace {
- get { return field_namespace; }
- }
-
- public string Structure {
- get { return field_struct; }
- }
-
- public string Union {
- get { return field_union; }
- }
-
- public string Enum {
- get { return field_enum; }
- }
-
- public string Signature {
- get { return field_signature; }
- }
- }
-}
diff --git a/Parser/TagDatabaseManager.cs b/Parser/TagDatabaseManager.cs
deleted file mode 100644
index 3a8a4cd..0000000
--- a/Parser/TagDatabaseManager.cs
+++ /dev/null
@@ -1,726 +0,0 @@
-//
-// TagDatabaseManager.cs
-//
-// Authors:
-// Levi Bard <taktaktaktaktaktaktaktaktaktak at gmail.com>
-//
-// Copyright (C) 2008 Levi Bard
-// Based on CBinding by Marcos David Marin Amador <MarcosMarin at gmail.com>
-//
-// This source code is licenced under The MIT License:
-//
-// 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.IO;
-using System.Text;
-using System.Collections.Generic;
-using System.Threading;
-
-using MonoDevelop.Projects;
-using MonoDevelop.Core;
-using MonoDevelop.Core.Execution;
-using MonoDevelop.Ide.Gui;
-
-using MonoDevelop.ValaBinding.Navigation;
-
-namespace MonoDevelop.ValaBinding.Parser
-{
- /// <summary>
- /// Singleton class to manage tag databases
- /// </summary>
- class TagDatabaseManager
- {
- private static TagDatabaseManager instance;
- private Queue<ProjectFilePair> parsingJobs = new Queue<ProjectFilePair> ();
- private Thread parsingThread;
-
- public event ClassPadEventHandler FileUpdated;
-
- bool ctagsInstalled = false;
- bool checkedCtagsInstalled = false;
-
- private TagDatabaseManager()
- {
- }
-
- public static TagDatabaseManager Instance
- {
- get {
- if (instance == null)
- instance = new TagDatabaseManager ();
-
- return instance;
- }
- }
-
- bool DepsInstalled {
- get {
- if (!checkedCtagsInstalled) {
- checkedCtagsInstalled = true;
- if (IdeApp.Services.PlatformService.Name.Equals ("OSX")) {
- return false;
- }
- try {
- Runtime.ProcessService.StartProcess ("ctags", "--version", null, null).WaitForOutput ();
- } catch {
- LoggingService.LogWarning ("Cannot update Vala tags database because exuberant ctags is not installed.");
- return false;
- }
- lock (parsingJobs) {
- ctagsInstalled = true;
- }
- }
- return ctagsInstalled;
- }
- set {
- //don't assume that the caller is correct :-)
- if (value)
- checkedCtagsInstalled = false; //will re-determine ctagsInstalled on next getting
- else
- ctagsInstalled = false;
- }
- }
-
-// private string[] Headers (Project project, string filename, bool with_system)
-// {
-// string option = (with_system ? "-M" : "-MM");
-// ProcessWrapper p;
-// try {
-// p = Runtime.ProcessService.StartProcess ("gcc", option + " -MG " + filename, null, null);
-// p.WaitForExit ();
-// } catch (Exception ex) {
-// LoggingService.LogError (ex.ToString ());
-// return new string [0];
-// }
-//
-// StringBuilder output = new StringBuilder ();
-// string line;
-//
-// while ((line = p.StandardOutput.ReadLine ()) != null)
-// output.Append (line);
-//
-// p.Close ();
-//
-// string[] lines = output.ToString ().Split ('\\');
-// List<string> headers = new List<string> ();
-//
-// for (int i = 0; i < lines.Length; i++) {
-// string[] files = lines[i].Split (' ');
-// // first line contains the rule (eg. file.o: dep1.c dep2.h ...) and we must skip it
-// // and we skip the *.cpp or *.c etc. too
-// for (int j = 0; j < files.Length; j++) {
-// if (j == 0 || j == 1) continue;
-//
-// string depfile = files[j].Trim ();
-//
-// if (!string.IsNullOrEmpty (depfile))
-// headers.Add (findFileInIncludes (project, depfile));
-// }
-// }
-//
-// return headers.ToArray ();
-// }
-
- /// <summary>
- /// Finds a file in a project's vapi include path(s)
- /// </summary>
- /// <param name="project">
- /// The project whose include path is to be searched
- /// <see cref="Project"/>
- /// </param>
- /// <param name="filename">
- /// A portion of a full file path
- /// <see cref="System.String"/>
- /// </param>
- /// <returns>
- /// The full found path, or filename if not found
- /// <see cref="System.String"/>
- /// </returns>
- private static string findFileInIncludes (Project project, string filename) {
- ValaProjectConfiguration conf = project.DefaultConfiguration as ValaProjectConfiguration;
- string fullpath = string.Empty;
-
- if (!Path.IsPathRooted (filename)) {
- foreach (string p in conf.Includes) {
- fullpath = findFileInPath (filename, p);
- if (string.Empty != fullpath) return fullpath;
- }
- }
-
- return filename;
- }
-
- /// <summary>
- /// Finds a file in a subdirectory of a given path
- /// </summary>
- /// <param name="relativeFilename">
- /// A portion of a full file path
- /// <see cref="System.String"/>
- /// </param>
- /// <param name="path">
- /// The path beneath which to look for relativeFilename
- /// <see cref="System.String"/>
- /// </param>
- /// <returns>
- /// The full path, or string.Empty if not found
- /// <see cref="System.String"/>
- /// </returns>
- private static string findFileInPath (string relativeFilename, string path) {
- string tmp = Path.Combine (path, relativeFilename);
-
- if (Path.IsPathRooted (relativeFilename))
- return relativeFilename;
- else if (File.Exists (tmp))
- return tmp;
-
- if (Directory.Exists (path)) {
- foreach (string subdir in Directory.GetDirectories (path)) {
- tmp = findFileInPath (relativeFilename, subdir);
- if (string.Empty != tmp) return tmp;
- }
- }
-
- return string.Empty;
- }
-
- private void UpdateSystemTags (Project project, string filename, string[] includedFiles)
- {
- ProjectInformation info = ProjectInformationManager.Instance.Get (project);
- List<FileInformation> files;
-
- if (!info.IncludedFiles.ContainsKey (filename)) {
- files = new List<FileInformation> ();
- info.IncludedFiles.Add (filename, files);
- } else {
- files = info.IncludedFiles[filename];
- }
-
- foreach (string includedFile in includedFiles) {
- bool contains = false;
-
- foreach (FileInformation fi in files) {
- if (fi.FileName == includedFile) {
- contains = true;
- }
- }
-
- if (!contains) {
- FileInformation newFileInfo = new FileInformation (project, includedFile);
- files.Add (newFileInfo);
- FillFileInformation (newFileInfo);
- }
-
- contains = false;
- }
- }
-
- private void FillFileInformation (FileInformation fileInfo)
- {
- if (!DepsInstalled)
- return;
-
- string confdir = PropertyService.ConfigPath;
- string tagFileName = Path.GetFileName (fileInfo.FileName) + ".tag";
- string tagdir = Path.Combine (confdir, "system-tags");
- string tagFullFileName = Path.Combine (tagdir, tagFileName);
- string ctags_options = "'--C#-kinds=+l' --fields=+a-f+S '--language-force=C#' --excmd=pattern -f '" + tagFullFileName + "' " + fileInfo.FileName;
-
- if (!Directory.Exists (tagdir))
- Directory.CreateDirectory (tagdir);
-
- if (!File.Exists (tagFullFileName) || File.GetLastWriteTimeUtc (tagFullFileName) < File.GetLastWriteTimeUtc (fileInfo.FileName)) {
- ProcessWrapper p = null;
- System.IO.StringWriter output = null;
- try {
- output = new System.IO.StringWriter ();
-
- p = Runtime.ProcessService.StartProcess ("ctags", ctags_options, null, output, output, null);
- p.WaitForOutput (10000);
- if (p.ExitCode != 0 || !File.Exists (tagFullFileName)) {
- LoggingService.LogError ("Ctags did not successfully populate the tags database '{0}' from '{1}' within ten seconds.\nOutput: {2}", tagFullFileName, output.ToString ());
- return;
- }
- } catch (Exception ex) {
- throw new IOException ("Could not create tags database (You must have exuberant ctags installed).", ex);
- } finally {
- if (output != null)
- output.Dispose ();
- if (p != null)
- p.Dispose ();
- }
- }
-
- string ctags_output;
- string tagEntry;
-
- using (StreamReader reader = new StreamReader (tagFullFileName)) {
- ctags_output = reader.ReadToEnd ();
- }
-
- using (StringReader reader = new StringReader (ctags_output)) {
- while ((tagEntry = reader.ReadLine ()) != null) {
- if (tagEntry.StartsWith ("!_")) continue;
-
- Tag tag = ParseTag (tagEntry);
-
- if (tag != null)
- AddInfo (fileInfo, tag, ctags_output);
- }
- }
-
- fileInfo.IsFilled = true;
- }
-
- private void ParsingThread ()
- {
- try {
- while (parsingJobs.Count > 0) {
- ProjectFilePair p;
-
- lock (parsingJobs) {
- p = parsingJobs.Dequeue ();
- }
-
- DoUpdateFileTags (p.Project, p.File);
- }
- } catch (Exception ex) {
- LoggingService.LogError ("Unhandled error updating parser database. Disabling Vala parsing.", ex);
- DepsInstalled = false;
- return;
- }
- }
-
- public void UpdateFileTags (Project project, string filename)
- {
- if (!DepsInstalled)
- return;
-
- ProjectFilePair p = new ProjectFilePair (project, filename);
-
- lock (parsingJobs) {
- if (!parsingJobs.Contains (p))
- parsingJobs.Enqueue (p);
- }
-
- if (parsingThread == null || !parsingThread.IsAlive) {
- parsingThread = new Thread (ParsingThread);
- parsingThread.IsBackground = true;
- parsingThread.Start();
- }
- }
-
- private void DoUpdateFileTags (Project project, string filename)
- {
- if (!DepsInstalled)
- return;
-
- //string[] headers = Headers (project, filename, false);
- string ctags_options = "'--C#-kinds=+l' --fields=+a-f+S '--language-force=C#' --excmd=pattern -f - " + filename; // + " " + string.Join (" ", headers);
-
- //string[] system_headers = diff (Headers (project, filename, true), headers);
-
- ProcessWrapper p = null;
- System.IO.StringWriter output = null, error = null;
- string ctags_output = string.Empty;
- try {
- output = new System.IO.StringWriter ();
- error = new System.IO.StringWriter ();
- p = Runtime.ProcessService.StartProcess ("ctags", ctags_options, null, output, error, null);
- p.WaitForOutput (10000);
- if (p.ExitCode != 0) {
- LoggingService.LogError ("Ctags did not successfully populate the tags database from '{0}' within ten seconds.\nError output: {1}", filename, error.ToString ());
- return;
- }
- ctags_output = output.ToString ();
- // System.Console.WriteLine(ctags_output);
- } catch (Exception ex) {
- throw new IOException ("Could not create tags database (You must have exuberant ctags installed).", ex);
- } finally {
- if (output != null)
- output.Dispose ();
- if (error != null)
- error.Dispose ();
- if (p != null)
- p.Dispose ();
- }
-
- ProjectInformation info = ProjectInformationManager.Instance.Get (project);
- string tagEntry;
-
- using (StringReader reader = new StringReader (ctags_output)) {
- while ((tagEntry = reader.ReadLine ()) != null) {
- if (tagEntry.StartsWith ("!_")) continue;
-
- Tag tag = ParseTag (tagEntry);
-
- if (tag != null)
- AddInfo (info, tag, ctags_output);
- }
- }
-
-// if (FileUpdated != null)
-// FileUpdated (new ClassPadEventArgs (project));
-
- if (PropertyService.Get<bool> ("ValaBinding.ParseSystemTags", true))
- UpdateSystemTags (project, filename, new string[0]);
-
- if (cache.Count > cache_size)
- cache.Clear ();
- }
-
- private void AddInfo (FileInformation info, Tag tag, string ctags_output)
- {
- switch (tag.Kind)
- {
- case TagKind.Class:
- Class c = new Class (tag, info.Project, ctags_output);
- if (!info.Classes.Contains (c))
- info.Classes.Add (c);
- break;
- case TagKind.Enumeration:
- Enumeration e = new Enumeration (tag, info.Project, ctags_output);
- if (!info.Enumerations.Contains (e))
- info.Enumerations.Add (e);
- break;
- case TagKind.Enumerator:
- Enumerator en= new Enumerator (tag, info.Project, ctags_output);
- if (!info.Enumerators.Contains (en))
- info.Enumerators.Add (en);
- break;
- case TagKind.ExternalVariable:
- break;
- case TagKind.Function:
- Function f = new Function (tag, info.Project, ctags_output);
- if (!info.Functions.Contains (f))
- info.Functions.Add (f);
- break;
- case TagKind.Local:
- Local lo = new Local(tag, info.Project, ctags_output);
- if (!info.Locals.Contains (lo))
- info.Locals.Add (lo);
- break;
- case TagKind.Macro:
- Macro m = new Macro (tag, info.Project);
- if (!info.Macros.Contains (m))
- info.Macros.Add (m);
- break;
- case TagKind.Member:
- Member me = new Member (tag, info.Project, ctags_output);
- if (!info.Members.Contains (me))
- info.Members.Add (me);
- break;
- case TagKind.Namespace:
- Namespace n = new Namespace (tag, info.Project, ctags_output);
- if (!info.Namespaces.Contains (n))
- info.Namespaces.Add (n);
- break;
-// case TagKind.Prototype:
-// Function fu = new Function (tag, info.Project, ctags_output);
-// if (!info.Functions.Contains (fu))
-// info.Functions.Add (fu);
-// break;
- case TagKind.Structure:
- Structure s = new Structure (tag, info.Project, ctags_output);
- if (!info.Structures.Contains (s))
- info.Structures.Add (s);
- break;
- case TagKind.Typedef:
- Typedef t = new Typedef (tag, info.Project, ctags_output);
- if (!info.Typedefs.Contains (t))
- info.Typedefs.Add (t);
- break;
- case TagKind.Union:
- Union u = new Union (tag, info.Project, ctags_output);
- if (!info.Unions.Contains (u))
- info.Unions.Add (u);
- break;
- case TagKind.Variable:
- Variable v = new Variable (tag, info.Project);
- if (!info.Variables.Contains (v))
- info.Variables.Add (v);
- break;
- default:
- break;
- }
- }
-
- private Tag ParseTag (string tagEntry)
- {
- int i1, i2;
- string file;
- string pattern;
- string name;
- string tagField;
- TagKind kind;
- AccessModifier access = AccessModifier.Public;
- string _class = null;
- string _namespace = null;
- string _struct = null;
- string _union = null;
- string _enum = null;
- string signature = null;
- char delimiter;
-
- name = tagEntry.Substring (0, tagEntry.IndexOf ('\t'));
-
- i1 = tagEntry.IndexOf ('\t') + 1;
- i2 = tagEntry.IndexOf ('\t', i1);
-
- file = tagEntry.Substring (i1, i2 - i1);
-
- delimiter = tagEntry[i2 + 1];
-
- i1 = i2 + 2;
- i2 = tagEntry.IndexOf (delimiter, i1) - 1;
-
- // apparentlty sometimes ctags will create faulty tags, make sure this is not one of them
- if (i2 < 0 || i1 < 0)
- return null;
-
- pattern = tagEntry.Substring (i1 + 1, i2 - i1 - 1);
-
- tagField = tagEntry.Substring (i2 + 5);
-
- // parse tag field
- kind = (TagKind)tagField[0];
-
- string[] fields = tagField.Split ('\t');
- int index;
-
- foreach (string field in fields) {
- index = field.IndexOf (':');
-
- // TODO: Support friend modifier
- if (index > 0) {
- string key = field.Substring (0, index);
- string val = field.Substring (index + 1);
-
- switch (key) {
- case "access":
- try {
- access = (AccessModifier)System.Enum.Parse (typeof(AccessModifier), val, true);
- } catch (ArgumentException) {
- }
- break;
- case "class":
- int dotindex = val.LastIndexOf(".");
-
- if(0 < dotindex) {
-// _namespace = val.Substring(0, dotindex);
- _class = val.Substring(dotindex + 1);
- } else {
- _class = val;
- }
- break;
- case "namespace":
- _namespace = val;
- break;
- case "struct":
- _struct = val;
- break;
- case "union":
- _union = val;
- break;
- case "enum":
- _enum = val;
- break;
- case "signature":
- signature = val;
- break;
- }
- }
- }
-
- return new Tag (name, file, pattern, kind, access, _class, _namespace, _struct, _union, _enum, signature);
- }
-
- Tag BinarySearch (string[] ctags_lines, TagKind kind, string name)
- {
- int low;
- int high = ctags_lines.Length - 2; // last element is an empty string (because of the Split)
- int mid;
- int start_index = 0;
-
- // Skip initial comment lines
- while (ctags_lines[start_index].StartsWith ("!_"))
- start_index++;
-
- low = start_index;
-
- while (low <= high) {
- mid = (low + high) / 2;
- string entry = ctags_lines[mid];
- string tag_name = entry.Substring (0, entry.IndexOf ('\t'));
- int res = string.CompareOrdinal (tag_name, name);
-
- if (res < 0) {
- low = mid + 1;
- } else if (res > 0) {
- high = mid - 1;
- } else {
- // The tag we are at has the same name than the one we are looking for
- // but not necessarily the same type, the actual tag we are looking
- // for might be higher up or down, so we try both, starting with going down.
- int save = mid;
- bool going_down = true;
- bool eof = false;
-
- while (true) {
- Tag tag = ParseTag (entry);
-
- if (tag == null)
- return null;
-
- if (tag.Kind == kind && tag_name == name)
- return tag;
-
- if (going_down) {
- mid++;
-
- if (mid >= ctags_lines.Length - 1)
- eof = true;
-
- if (!eof) {
- entry = ctags_lines[mid];
- tag_name = entry.Substring (0, entry.IndexOf ('\t'));
-
- if (tag_name != name) {
- going_down = false;
- mid = save - 1;
- }
- } else {
- going_down = false;
- mid = save - 1;
- }
- } else { // going up
- mid--;
-
- if (mid < start_index)
- return null;
-
- entry = ctags_lines[mid];
- tag_name = entry.Substring (0, entry.IndexOf ('\t'));
-
- if (tag_name != name)
- return null;
- }
- }
- }
- }
-
- return null;
- }
-
- private struct SemiTag
- {
- readonly internal string name;
- readonly internal TagKind kind;
-
- internal SemiTag (string name, TagKind kind)
- {
- this.name = name;
- this.kind = kind;
- }
-
- public override int GetHashCode ()
- {
- return (name + kind.ToString ()).GetHashCode ();
- }
- }
-
- private const int cache_size = 10000;
- private Dictionary<SemiTag, Tag> cache = new Dictionary<SemiTag, Tag> ();
-
- public Tag FindTag (string name, TagKind kind, string ctags_output)
- {
- SemiTag semiTag = new SemiTag (name, kind);
-
- if (cache.ContainsKey (semiTag))
- return cache[semiTag];
- else {
- string[] ctags_lines = ctags_output.Split ('\n');
- Tag tag = BinarySearch (ctags_lines, kind, name);
- cache.Add (semiTag, tag);
-
- return tag;
- }
- }
-
- public void RemoveFileInfo(Project project, string filename)
- {
- ProjectInformation info = ProjectInformationManager.Instance.Get (project);
- info.RemoveFileInfo(filename);
- }
-
- private static string[] diff (string[] a1, string[] a2)
- {
- List<string> res = new List<string> ();
- List<string> right = new List<string> (a2);
-
- foreach (string s in a1) {
- if (!right.Contains (s))
- res.Add (s);
- }
-
- return res.ToArray ();
- }
-
- private class ProjectFilePair
- {
- string file;
- Project project;
-
- public ProjectFilePair (Project project, string file)
- {
- this.project = project;
- this.file = file;
- }
-
- public string File {
- get { return file; }
- }
-
- public Project Project {
- get { return project; }
- }
-
- public override bool Equals (object other)
- {
- ProjectFilePair o = other as ProjectFilePair;
-
- if (o == null)
- return false;
-
- if (file == o.File && project == o.Project)
- return true;
- else
- return false;
- }
-
- public override int GetHashCode ()
- {
- return (project.ToString() + file).GetHashCode ();
- }
- }
- }
-}
diff --git a/Parser/Typedef.cs b/Parser/Typedef.cs
deleted file mode 100644
index d08d5a5..0000000
--- a/Parser/Typedef.cs
+++ /dev/null
@@ -1,49 +0,0 @@
-//
-// Typedef.cs
-//
-// Authors:
-// Levi Bard <taktaktaktaktaktaktaktaktaktak at gmail.com>
-//
-// Copyright (C) 2008 Levi Bard
-// Based on CBinding by Marcos David Marin Amador <MarcosMarin at gmail.com>
-//
-// This source code is licenced under The MIT License:
-//
-// 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 MonoDevelop.Projects;
-
-namespace MonoDevelop.ValaBinding.Parser
-{
- public class Typedef : LanguageItem
- {
- public Typedef (Tag tag, Project project, string ctags_output) : base (tag, project)
- {
- if (GetNamespace (tag, ctags_output)) return;
- if (GetClass (tag, ctags_output)) return;
- if (GetStructure (tag, ctags_output)) return;
- if (GetUnion (tag, ctags_output)) return;
- }
- }
-}
diff --git a/Parser/Union.cs b/Parser/Union.cs
deleted file mode 100644
index 168fee4..0000000
--- a/Parser/Union.cs
+++ /dev/null
@@ -1,49 +0,0 @@
-//
-// Union.cs
-//
-// Authors:
-// Levi Bard <taktaktaktaktaktaktaktaktaktak at gmail.com>
-//
-// Copyright (C) 2008 Levi Bard
-// Based on CBinding by Marcos David Marin Amador <MarcosMarin at gmail.com>
-//
-// This source code is licenced under The MIT License:
-//
-// 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 MonoDevelop.Projects;
-
-namespace MonoDevelop.ValaBinding.Parser
-{
- public class Union : LanguageItem
- {
- public Union (Tag tag, Project project, string ctags_output) : base (tag, project)
- {
- if (GetNamespace (tag, ctags_output)) return;
- if (GetClass (tag, ctags_output)) return;
- if (GetStructure (tag, ctags_output)) return;
- if (GetUnion (tag, ctags_output)) return;
- }
- }
-}
\ No newline at end of file
diff --git a/Parser/ValaDocumentParser.cs b/Parser/ValaDocumentParser.cs
new file mode 100644
index 0000000..f650172
--- /dev/null
+++ b/Parser/ValaDocumentParser.cs
@@ -0,0 +1,111 @@
+//
+// ValaDocumentParser.cs
+//
+// Author:
+// Levi Bard <taktaktaktaktaktaktaktaktaktak at gmail.com>
+//
+// Copyright (c) 2009 Levi Bard
+//
+// 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.IO;
+using System.Collections.Generic;
+using System.Threading;
+
+using MonoDevelop.Projects.Dom;
+using MonoDevelop.Projects.Dom.Parser;
+
+namespace MonoDevelop.ValaBinding.Parser
+{
+ /// <summary>
+ /// Parser for Vala source and vapi files
+ /// </summary>
+ public class ValaDocumentParser: AbstractParser
+ {
+ public ValaDocumentParser(): base("Vala", "text/x-vala")
+ {
+ }
+
+ public override bool CanParse (string fileName)
+ {
+ string extension = Path.GetExtension (fileName);
+ if(!string.IsNullOrEmpty (extension)) {
+ extension = extension.ToUpper ();
+ return (extension == ".VALA" || extension == ".VAPI");
+ }
+
+ return false;
+ }// CanParse
+
+ public override ParsedDocument Parse (ProjectDom dom, string fileName, string content)
+ {
+ ParsedDocument doc = new ParsedDocument (fileName);
+ ProjectInformation pi = ProjectInformationManager.Instance.Get ((null == dom)? null: dom.Project);
+ if(null == doc.CompilationUnit){ doc.CompilationUnit = new CompilationUnit (fileName); }
+ CompilationUnit cu = (CompilationUnit)doc.CompilationUnit;
+ int lastLine = 0;
+
+ foreach (CodeNode node in pi.GetClassesForFile (fileName)) {
+ if (null == node){ continue; }
+ List<IMember> members = new List<IMember> ();
+ lastLine = node.LastLine;
+
+ foreach (CodeNode child in pi.CompleteType (node.FullName, fileName, node.FirstLine, 0, null)) {
+ if (child.File != node.File){ continue; }
+ lastLine = Math.Max (lastLine, child.LastLine+1);
+
+ switch (child.NodeType) {
+ case "class":
+ members.Add (new DomType (new CompilationUnit (fileName), ClassType.Class, child.Name, new DomLocation (child.FirstLine, 1), string.Empty, new DomRegion (child.FirstLine+1, child.LastLine+1), new List<IMember> ()));
+ break;
+ case "delegate":
+ members.Add (new DomType (new CompilationUnit (fileName), ClassType.Delegate, child.Name, new DomLocation (child.FirstLine, 1), string.Empty, new DomRegion (child.FirstLine+1, child.LastLine+1), new List<IMember> ()));
+ break;
+ case "struct":
+ members.Add (new DomType (new CompilationUnit (fileName), ClassType.Struct, child.Name, new DomLocation (child.FirstLine, 1), string.Empty, new DomRegion (child.FirstLine+1, child.LastLine+1), new List<IMember> ()));
+ break;
+ case "enums":
+ members.Add (new DomType (new CompilationUnit (fileName), ClassType.Enum, child.Name, new DomLocation (child.FirstLine, 1), string.Empty, new DomRegion (child.FirstLine+1, child.LastLine+1), new List<IMember> ()));
+ break;
+ case "method":
+ members.Add (new DomMethod (child.Name, Modifiers.None, MethodModifier.None, new DomLocation (child.FirstLine, 1), new DomRegion (child.FirstLine+1, child.LastLine+1), new DomReturnType (((Function)child).ReturnType)));
+ break;
+ case "property":
+ members.Add (new DomProperty (child.Name, Modifiers.None, new DomLocation (child.FirstLine, 1), new DomRegion (child.FirstLine+1, child.LastLine+1), new DomReturnType ()));
+ break;
+ case "field":
+ members.Add (new DomField (child.Name, Modifiers.None, new DomLocation (child.FirstLine, 1), new DomReturnType ()));
+ break;
+ case "signal":
+ members.Add (new DomEvent (child.Name, Modifiers.None, new DomLocation (child.FirstLine, 1), new DomReturnType ()));
+ break;
+ default:
+ Console.WriteLine("Unsupported member type: {0}", child.NodeType);
+ break;
+ }// Switch on node type
+ }// Collect members
+
+ cu.Add (new DomType (new CompilationUnit (fileName), ClassType.Class, node.Name, new DomLocation (node.FirstLine, 1), string.Empty, new DomRegion (node.FirstLine+1, lastLine+1), members));
+ }// Add each class in file
+
+ return doc;
+ }// Parse
+ }// ValaDocumentParser
+}
diff --git a/Parser/Variable.cs b/Parser/Variable.cs
deleted file mode 100644
index c5c19ea..0000000
--- a/Parser/Variable.cs
+++ /dev/null
@@ -1,45 +0,0 @@
-//
-// Variable.cs
-//
-// Authors:
-// Levi Bard <taktaktaktaktaktaktaktaktaktak at gmail.com>
-//
-// Copyright (C) 2008 Levi Bard
-// Based on CBinding by Marcos David Marin Amador <MarcosMarin at gmail.com>
-//
-// This source code is licenced under The MIT License:
-//
-// 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 MonoDevelop.Projects;
-
-namespace MonoDevelop.ValaBinding.Parser
-{
- public class Variable : LanguageItem
- {
- public Variable (Tag tag, Project project) : base (tag, project)
- {
- }
- }
-}
diff --git a/Project/MakefileHandler.cs b/Project/MakefileHandler.cs
new file mode 100644
index 0000000..8b6e039
--- /dev/null
+++ b/Project/MakefileHandler.cs
@@ -0,0 +1,77 @@
+using System;
+using System.IO;
+using System.Text;
+
+using MonoDevelop.Core;
+using MonoDevelop.Autotools;
+using MonoDevelop.Projects;
+using MonoDevelop.Deployment;
+
+namespace MonoDevelop.ValaBinding
+{
+ /// <summary>
+ /// Handler for makefile generation
+ /// </summary>
+ public class MakefileHandler: IMakefileHandler
+ {
+
+ #region IMakefileHandler implementation
+ public bool CanDeploy (MonoDevelop.Projects.SolutionItem entry, MakefileType type)
+ {
+ return entry is ValaProject;
+ }
+
+ /// <summary>
+ /// Deploys a makefile to build the default configuration.
+ /// </summary>
+ /// <remarks>
+ /// TODO: Make configuration-based targets as advertised.
+ /// </remarks>
+ public Makefile Deploy (AutotoolsContext ctx, MonoDevelop.Projects.SolutionItem entry, MonoDevelop.Core.IProgressMonitor monitor)
+ {
+ Makefile mkfile = new Makefile ();
+ ValaProject project = (ValaProject) entry;
+ ValaProjectConfiguration conf = (ValaProjectConfiguration)project.DefaultConfiguration;
+
+ StringBuilder files = new StringBuilder ();
+ foreach (ProjectFile t in project.Files) {
+ if(BuildAction.Compile == t.BuildAction) {
+ files.Append ("\\\n\t" + FileService.AbsoluteToRelativePath(project.BaseDirectory, t.FilePath));
+ }
+ }
+
+ string dir = ctx.DeployContext.GetResolvedPath (TargetDirectory.ProgramFiles, FileService.AbsoluteToRelativePath(conf.OutputDirectory, ctx.TargetSolution.BaseDirectory));
+ dir = dir.Replace ("@prefix@", "$(prefix)");
+ dir = dir.Replace ("@PACKAGE@", "$(PACKAGE)");
+
+ TemplateEngine templateEngine = new TemplateEngine ();
+ templateEngine.Variables ["TOP_SRCDIR"] = FileService.AbsoluteToRelativePath (project.BaseDirectory, ctx.TargetSolution.BaseDirectory);
+ templateEngine.Variables ["FILES"] = files.ToString ();
+ templateEngine.Variables ["BUILD_DIR"] = ".";
+ templateEngine.Variables ["INSTALL_DIR"] = "$(DESTDIR)" + dir;
+ templateEngine.Variables ["ALL_TARGET"] = string.Format("all-{0}", conf.Name);
+ templateEngine.Variables ["VFLAGS"] = string.Format("{0} {1}", ValaCompiler.GetCompilerFlags(conf), ValaCompiler.GeneratePkgCompilerArgs(project.Packages));
+ templateEngine.Variables ["VTARGET"] = conf.CompiledOutputName;
+
+ StringWriter sw = new StringWriter ();
+
+ string mt;
+ if (ctx.MakefileType == MakefileType.AutotoolsMakefile)
+ mt = "Makefile.am.template";
+ else
+ mt = "Makefile.template";
+
+ using (Stream stream = GetType().Assembly.GetManifestResourceStream (mt)) {
+ StreamReader reader = new StreamReader (stream);
+
+ templateEngine.Process (reader, sw);
+ reader.Close ();
+ }
+
+ mkfile.Append (sw.ToString ());
+
+ return mkfile;
+ }
+ #endregion
+ }
+}
diff --git a/Project/ValaProject.cs b/Project/ValaProject.cs
index 0ced063..d88d850 100644
--- a/Project/ValaProject.cs
+++ b/Project/ValaProject.cs
@@ -280,12 +280,22 @@ namespace MonoDevelop.ValaBinding
pc,
monitor);
}
+
+ ExecutionCommand CreateExecutionCommand (ValaProjectConfiguration conf)
+ {
+ NativeExecutionCommand cmd = new NativeExecutionCommand ();
+ cmd.Command = Path.Combine (conf.OutputDirectory, conf.Output);
+ cmd.Arguments = conf.CommandLineParameters;
+ cmd.WorkingDirectory = Path.GetFullPath (conf.OutputDirectory);
+ return cmd;
+ }
protected override bool OnGetCanExecute (MonoDevelop.Projects.ExecutionContext context, string solutionConfiguration)
{
ValaProjectConfiguration conf = (ValaProjectConfiguration)GetConfiguration(solutionConfiguration);
+ ExecutionCommand cmd = CreateExecutionCommand (conf);
return (conf.CompileTarget == ValaBinding.CompileTarget.Bin) &&
- context.ExecutionHandler.CanExecute (Path.Combine (conf.OutputDirectory, conf.Output));
+ context.ExecutionHandler.CanExecute (cmd);
}
protected override void DoExecute (IProgressMonitor monitor,
@@ -293,10 +303,6 @@ namespace MonoDevelop.ValaBinding
string configuration)
{
ValaProjectConfiguration conf = (ValaProjectConfiguration)GetConfiguration(configuration);
- string command = conf.Output;
- string args = conf.CommandLineParameters;
- string dir = Path.GetFullPath (conf.OutputDirectory);
- string platform = "Native";
bool pause = conf.PauseConsoleOutput;
IConsole console;
@@ -305,6 +311,8 @@ namespace MonoDevelop.ValaBinding
return;
}
+ ExecutionCommand cmd = CreateExecutionCommand (conf);
+
monitor.Log.WriteLine ("Running project...");
if (conf.ExternalConsole)
@@ -315,29 +323,29 @@ namespace MonoDevelop.ValaBinding
AggregatedOperationMonitor operationMonitor = new AggregatedOperationMonitor (monitor);
try {
- if (!context.ExecutionHandler.CanExecute (Path.Combine (dir, command))) {
- monitor.ReportError ("Cannot execute \"" + command + "\". The selected execution mode is not supported for Vala projects.", null);
+ if (!context.ExecutionHandler.CanExecute (cmd)) {
+ monitor.ReportError ("Cannot execute \"" + conf.Output + "\". The selected execution mode is not supported for Vala projects.", null);
return;
}
- IProcessAsyncOperation op = context.ExecutionHandler.Execute (Path.Combine (dir, command), args, dir, null, console);
+ IProcessAsyncOperation op = context.ExecutionHandler.Execute (cmd, console);
operationMonitor.AddOperation (op);
op.WaitForCompleted ();
monitor.Log.WriteLine ("The operation exited with code: {0}", op.ExitCode);
} catch (Exception ex) {
- monitor.ReportError ("Cannot execute \"" + command + "\"", ex);
+ monitor.ReportError ("Cannot execute \"" + conf.Output + "\"", ex);
} finally {
operationMonitor.Dispose ();
console.Dispose ();
}
}
- protected override string OnGetOutputFileName (string configuration)
+ protected override FilePath OnGetOutputFileName (string configuration)
{
ValaProjectConfiguration conf = (ValaProjectConfiguration)GetConfiguration(configuration);
- return Path.Combine (conf.OutputDirectory, conf.CompiledOutputName);
+ return conf.OutputDirectory.Combine (conf.CompiledOutputName);
}
public override SolutionItemConfiguration CreateConfiguration (string name)
@@ -375,8 +383,9 @@ namespace MonoDevelop.ValaBinding
set {
packages = value;
packages.Project = this;
+ ProjectInformation pi = ProjectInformationManager.Instance.Get (this);
foreach(ProjectPackage p in packages) {
- TagDatabaseManager.Instance.UpdateFileTags(this, p.File);
+ if (!p.IsProject){ pi.AddPackage (p.Name); }
}
}
}
@@ -391,21 +400,20 @@ namespace MonoDevelop.ValaBinding
}
if (e.ProjectFile.BuildAction == BuildAction.Compile)
- TagDatabaseManager.Instance.UpdateFileTags (this, e.ProjectFile.Name);
+ ProjectInformationManager.Instance.Get (this).AddFile (e.ProjectFile.FilePath);
}
protected override void OnFileChangedInProject (ProjectFileEventArgs e)
{
base.OnFileChangedInProject (e);
-
- TagDatabaseManager.Instance.UpdateFileTags (this, e.ProjectFile.Name);
+// ProjectInformationManager.Instance.Get (this).Reparse ();
+ ProjectInformationManager.Instance.Get (this).AddFile (e.ProjectFile.FilePath);
}
protected override void OnFileRemovedFromProject (ProjectFileEventArgs e)
{
base.OnFileRemovedFromProject(e);
-
- TagDatabaseManager.Instance.RemoveFileInfo (this, e.ProjectFile.Name);
+ ProjectInformationManager.Instance.Get (this).RemoveFile (e.ProjectFile.FilePath);
}
private static void OnEntryAddedToCombine (object sender, SolutionItemEventArgs e)
@@ -415,10 +423,10 @@ namespace MonoDevelop.ValaBinding
if (p == null)
return;
- foreach (ProjectFile f in p.Files)
- TagDatabaseManager.Instance.UpdateFileTags (p, f.Name);
foreach (ProjectPackage package in p.Packages)
- TagDatabaseManager.Instance.UpdateFileTags (p, package.File);
+ if (!package.IsProject){ ProjectInformationManager.Instance.Get (p).AddPackage (package.Name); }
+ foreach (ProjectFile f in p.Files)
+ ProjectInformationManager.Instance.Get (p).AddFile (f.FilePath);
}
internal void NotifyPackageRemovedFromProject (ProjectPackage package)
@@ -426,7 +434,6 @@ namespace MonoDevelop.ValaBinding
if (null != PackageRemovedFromProject) {
PackageRemovedFromProject (this, new ProjectPackageEventArgs (this, package));
}
- TagDatabaseManager.Instance.RemoveFileInfo(this, package.File);
}
internal void NotifyPackageAddedToProject (ProjectPackage package)
@@ -434,7 +441,7 @@ namespace MonoDevelop.ValaBinding
if(null != PackageAddedToProject) {
PackageAddedToProject (this, new ProjectPackageEventArgs (this, package));
}
- TagDatabaseManager.Instance.UpdateFileTags(this, package.File);
+ if (!package.IsProject){ ProjectInformationManager.Instance.Get (this).AddPackage (package.Name); }
}
public DeployFileCollection GetDeployFiles (string configuration)
@@ -492,12 +499,14 @@ namespace MonoDevelop.ValaBinding
string depsfile = Path.ChangeExtension (package.File, ".deps");
try {
- string[] lines = File.ReadAllLines (depsfile);
- List<ProjectPackage> deps = new List<ProjectPackage>();
- foreach (string line in lines) {
- deps.Add(new ProjectPackage(Path.Combine(vapidir, line) + ".vapi"));
- }// add package for each dep
- packages.AddRange(deps);
+ if (File.Exists (depsfile)) {
+ string[] lines = File.ReadAllLines (depsfile);
+ List<ProjectPackage> deps = new List<ProjectPackage>();
+ foreach (string line in lines) {
+ deps.Add(new ProjectPackage(Path.Combine(vapidir, line) + ".vapi"));
+ }// add package for each dep
+ packages.AddRange(deps);
+ }
// Currently, we need to add include directory and linker flags - this should be obsoleted
string ccargs = string.Format (" --Xcc=\\\\\\\"-I{0}\\\\\\\" --Xcc=\\\\\\\"-L{0}\\\\\\\" --Xcc=\\\\\\\"-l{1}\\\\\\\" ", Path.GetDirectoryName (depsfile), package.Name);
diff --git a/Project/ValaProjectBinding.cs b/Project/ValaProjectBinding.cs
index eb596c0..59988b0 100644
--- a/Project/ValaProjectBinding.cs
+++ b/Project/ValaProjectBinding.cs
@@ -56,7 +56,7 @@ namespace MonoDevelop.ValaBinding
{
ProjectCreateInformation info = new ProjectCreateInformation ();
info.ProjectName = Path.GetFileNameWithoutExtension (sourceFile);
- info.CombinePath = Path.GetDirectoryName (sourceFile);
+ info.SolutionPath = Path.GetDirectoryName (sourceFile);
info.ProjectBasePath = Path.GetDirectoryName (sourceFile);
string language = "Vala";
diff --git a/README b/README
index 4eaa14d..f6e0dba 100644
--- a/README
+++ b/README
@@ -1 +1,8 @@
ValaBinding is a Vala language binding for MonoDevelop.
+
+Current features:
+ * Vala project support for executable projects, libraries, and unit test projects (using GTest).
+ * Reference other Vala libraries and projects from within the IDE.
+ * Class browser.
+ * Basic Makefile integration.
+ * Context-sensitive code completion using VTG ( http://code.google.com/p/vtg ).
diff --git a/ValaBinding.addin.xml b/ValaBinding.addin.xml
index 5673918..033bcdc 100644
--- a/ValaBinding.addin.xml
+++ b/ValaBinding.addin.xml
@@ -6,17 +6,18 @@
url = "http://www.monodevelop.com"
description = "Vala Language binding"
category = "Language bindings"
- version = "2.0">
+ version = "2.1.1">
<Dependencies>
- <Addin id = "Core" version = "2.0"/>
- <Addin id = "Core.Gui" version = "2.0"/>
- <Addin id = "Projects" version = "2.0"/>
- <Addin id = "Projects.Gui" version = "2.0"/>
- <Addin id = "Ide" version = "2.0"/>
- <Addin id = "Components" version = "2.0"/>
- <Addin id = "Deployment" version = "2.0"/>
- <Addin id = "Deployment.Linux" version = "2.0"/>
+ <Addin id = "Core" version = "2.1.1"/>
+ <Addin id = "Core.Gui" version = "2.1.1"/>
+ <Addin id = "Projects" version = "2.1.1"/>
+ <Addin id = "Projects.Gui" version = "2.1.1"/>
+ <Addin id = "Ide" version = "2.1.1"/>
+ <Addin id = "Components" version = "2.1.1"/>
+ <Addin id = "Deployment" version = "2.1.1"/>
+ <Addin id = "Deployment.Linux" version = "2.1.1"/>
+ <Addin id = "Autotools" version = "2.1.1"/>
</Dependencies>
<Extension path = "/MonoDevelop/Core/StockIcons">
@@ -52,11 +53,6 @@
</MimeType>
</Extension>
- <Extension path = "/MonoDevelop/ProjectModel/Gui/Icons">
- <Icon extensions = ".vala" icon = "res:text-x-vala.16x16.png"/>
- <Icon extensions = ".vapi" icon = "res:text-x-vala.16x16.png"/>
- </Extension>
-
<Extension path = "/MonoDevelop/ProjectModel/ProjectBindings">
<ProjectBinding id = "ValaProject" class = "MonoDevelop.ValaBinding.ValaProjectBinding"/>
</Extension>
@@ -108,19 +104,7 @@
<Extension path = "/MonoDevelop/Ide/Pads/ClassPad">
<NodeBuilder id = "MonoDevelop.ValaBinding.Navigation.ProjectNodeBuilderExtension" class = "MonoDevelop.ValaBinding.Navigation.ProjectNodeBuilderExtension"/>
- <NodeBuilder id = "MonoDevelop.ValaBinding.Navigation.NamespaceNodeBuilder" class = "MonoDevelop.ValaBinding.Navigation.NamespaceNodeBuilder"/>
- <NodeBuilder id = "MonoDevelop.ValaBinding.Navigation.FunctionNodeBuilder" class = "MonoDevelop.ValaBinding.Navigation.FunctionNodeBuilder"/>
- <NodeBuilder id = "MonoDevelop.ValaBinding.Navigation.GlobalsNodeBuilder" class = "MonoDevelop.ValaBinding.Navigation.GlobalsNodeBuilder"/>
- <NodeBuilder id = "MonoDevelop.ValaBinding.Navigation.ClassNodeBuilder" class = "MonoDevelop.ValaBinding.Navigation.ClassNodeBuilder"/>
- <NodeBuilder id = "MonoDevelop.ValaBinding.Navigation.StructureNodeBuilder" class = "MonoDevelop.ValaBinding.Navigation.StructureNodeBuilder"/>
- <NodeBuilder id = "MonoDevelop.ValaBinding.Navigation.MemberNodeBuilder" class = "MonoDevelop.ValaBinding.Navigation.MemberNodeBuilder"/>
- <NodeBuilder id = "MonoDevelop.ValaBinding.Navigation.VariableNodeBuilder" class = "MonoDevelop.ValaBinding.Navigation.VariableNodeBuilder"/>
- <NodeBuilder id = "MonoDevelop.ValaBinding.Navigation.MacroDefinitionsNodeBuilder" class = "MonoDevelop.ValaBinding.Navigation.MacroDefinitionsNodeBuilder"/>
- <NodeBuilder id = "MonoDevelop.ValaBinding.Navigation.MacroNodeBuilder" class = "MonoDevelop.ValaBinding.Navigation.MacroNodeBuilder"/>
- <NodeBuilder id = "MonoDevelop.ValaBinding.Navigation.EnumerationNodeBuilder" class = "MonoDevelop.ValaBinding.Navigation.EnumerationNodeBuilder"/>
- <NodeBuilder id = "MonoDevelop.ValaBinding.Navigation.EnumeratorNodeBuilder" class = "MonoDevelop.ValaBinding.Navigation.EnumeratorNodeBuilder"/>
- <NodeBuilder id = "MonoDevelop.ValaBinding.Navigation.UnionNodeBuilder" class = "MonoDevelop.ValaBinding.Navigation.UnionNodeBuilder"/>
- <NodeBuilder id = "MonoDevelop.ValaBinding.Navigation.TypedefNodeBuilder" class = "MonoDevelop.ValaBinding.Navigation.TypedefNodeBuilder"/>
+ <NodeBuilder id = "MonoDevelop.ValaBinding.Navigation.LanguageItemNodeBuilder" class = "MonoDevelop.ValaBinding.Navigation.LanguageItemNodeBuilder"/>
</Extension>
<Extension path = "/MonoDevelop/Ide/Commands">
@@ -162,4 +146,12 @@
<DataType class = "MonoDevelop.ValaBinding.ValaCompiler"/>
<DataType class = "MonoDevelop.ValaBinding.ProjectPackage"/>
</Extension>
+
+ <Extension path = "/MonoDevelop/Autotools/MakefileHandlers">
+ <Class class = "MonoDevelop.ValaBinding.MakefileHandler"/>
+ </Extension>
+
+ <Extension path = "/MonoDevelop/ProjectModel/DomParser">
+ <Class class = "MonoDevelop.ValaBinding.Parser.ValaDocumentParser" id = "ValaDocumentParser" />
+ </Extension>
</Addin>
diff --git a/ValaLanguageBinding.cs b/ValaLanguageBinding.cs
index 6a411bd..21dfcb1 100644
--- a/ValaLanguageBinding.cs
+++ b/ValaLanguageBinding.cs
@@ -48,9 +48,9 @@ namespace MonoDevelop.ValaBinding
get { return "Vala"; }
}
- public string CommentTag {
- get { return "//"; }
- }
+ public string SingleLineCommentTag { get { return "//"; } }
+ public string BlockCommentStartTag { get { return "/*"; } }
+ public string BlockCommentEndTag { get { return "*/"; } }
public bool IsSourceCodeFile (string fileName)
{
diff --git a/configure b/configure
index cda263a..3c619f9 100755
--- a/configure
+++ b/configure
@@ -1,6 +1,6 @@
#! /bin/sh
# Guess values for system-dependent variables and create Makefiles.
-# Generated by GNU Autoconf 2.61 for monodevelop-vala 2.0.
+# Generated by GNU Autoconf 2.61 for monodevelop-vala 2.1.1.
#
# Report bugs to <taktaktaktaktaktaktaktaktaktak at gmail.com>.
#
@@ -574,8 +574,8 @@ SHELL=${CONFIG_SHELL-/bin/sh}
# Identity of this package.
PACKAGE_NAME='monodevelop-vala'
PACKAGE_TARNAME='monodevelop-vala'
-PACKAGE_VERSION='2.0'
-PACKAGE_STRING='monodevelop-vala 2.0'
+PACKAGE_VERSION='2.1.1'
+PACKAGE_STRING='monodevelop-vala 2.1.1'
PACKAGE_BUGREPORT='taktaktaktaktaktaktaktaktaktak at gmail.com'
ac_subst_vars='SHELL
@@ -677,6 +677,7 @@ GCONF_SHARP_CFLAGS
GCONF_SHARP_LIBS
HAVE_GCONF_SHARP_TRUE
HAVE_GCONF_SHARP_FALSE
+VSCSHELL
gtksharp_prefix
LIB_SUFFIX
LIB_PREFIX
@@ -1215,7 +1216,7 @@ if test "$ac_init_help" = "long"; then
# Omit some internal or obsolete options to make the list less imposing.
# This message is too long to be a string in the A/UX 3.1 sh.
cat <<_ACEOF
-\`configure' configures monodevelop-vala 2.0 to adapt to many kinds of systems.
+\`configure' configures monodevelop-vala 2.1.1 to adapt to many kinds of systems.
Usage: $0 [OPTION]... [VAR=VALUE]...
@@ -1281,7 +1282,7 @@ fi
if test -n "$ac_init_help"; then
case $ac_init_help in
- short | recursive ) echo "Configuration of monodevelop-vala 2.0:";;
+ short | recursive ) echo "Configuration of monodevelop-vala 2.1.1:";;
esac
cat <<\_ACEOF
@@ -1409,7 +1410,7 @@ fi
test -n "$ac_init_help" && exit $ac_status
if $ac_init_version; then
cat <<\_ACEOF
-monodevelop-vala configure 2.0
+monodevelop-vala configure 2.1.1
generated by GNU Autoconf 2.61
Copyright (C) 1992, 1993, 1994, 1995, 1996, 1998, 1999, 2000, 2001,
@@ -1423,7 +1424,7 @@ cat >config.log <<_ACEOF
This file contains any messages produced by compilers while
running configure, to aid debugging if configure makes a mistake.
-It was created by monodevelop-vala $as_me 2.0, which was
+It was created by monodevelop-vala $as_me 2.1.1, which was
generated by GNU Autoconf 2.61. Invocation command line was
$ $0 $@
@@ -2114,7 +2115,7 @@ fi
# Define the identity of the package.
PACKAGE='monodevelop-vala'
- VERSION='2.0'
+ VERSION='2.1.1'
cat >>confdefs.h <<_ACEOF
@@ -2364,7 +2365,7 @@ fi
-ASSEMBLY_VERSION=2.0.0.0
+ASSEMBLY_VERSION=2.1.1.0
# Extract the first word of "mono", so it can be a program name with args.
set dummy mono; ac_word=$2
@@ -2508,7 +2509,9 @@ echo "$as_me: error: You need to install pkg-config" >&2;}
{ (exit 1); exit 1; }; }
fi
-MONO_REQUIRED_VERSION=1.1.10
+export PKG_CONFIG_PATH="${PKG_CONFIG_PATH}:../../local-config/"
+
+MONO_REQUIRED_VERSION=2.4
if test "x$ac_cv_env_PKG_CONFIG_set" != "xset"; then
@@ -2881,8 +2884,8 @@ fi
MONOADDINS_REQUIRED_VERSION=0.3
-GTKSHARP_REQUIRED_VERSION=2.8.0
-MONODEVELOP_REQUIRED_VERSION=2.0
+GTKSHARP_REQUIRED_VERSION=2.12.8
+MONODEVELOP_REQUIRED_VERSION=2.1.1
pkg_failed=no
@@ -3978,6 +3981,53 @@ else
fi
+# Extract the first word of "vsc-shell", so it can be a program name with args.
+set dummy vsc-shell; ac_word=$2
+{ echo "$as_me:$LINENO: checking for $ac_word" >&5
+echo $ECHO_N "checking for $ac_word... $ECHO_C" >&6; }
+if test "${ac_cv_prog_VSCSHELL+set}" = set; then
+ echo $ECHO_N "(cached) $ECHO_C" >&6
+else
+ if test -n "$VSCSHELL"; then
+ ac_cv_prog_VSCSHELL="$VSCSHELL" # Let the user override the test.
+else
+as_save_IFS=$IFS; IFS=$PATH_SEPARATOR
+for as_dir in $PATH
+do
+ IFS=$as_save_IFS
+ test -z "$as_dir" && as_dir=.
+ for ac_exec_ext in '' $ac_executable_extensions; do
+ if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then
+ ac_cv_prog_VSCSHELL="vsc-shell"
+ echo "$as_me:$LINENO: found $as_dir/$ac_word$ac_exec_ext" >&5
+ break 2
+ fi
+done
+done
+IFS=$as_save_IFS
+
+fi
+fi
+VSCSHELL=$ac_cv_prog_VSCSHELL
+if test -n "$VSCSHELL"; then
+ { echo "$as_me:$LINENO: result: $VSCSHELL" >&5
+echo "${ECHO_T}$VSCSHELL" >&6; }
+else
+ { echo "$as_me:$LINENO: result: no" >&5
+echo "${ECHO_T}no" >&6; }
+fi
+
+
+
+
+if test x$VSCSHELL = x; then
+ echo ""
+ echo "Vsc-shell is required for Vala code completion."
+ echo "Vsc-shell is part of the VTG package, available from: "
+ echo "http://code.google.com/p/vtg/"
+ echo ""
+fi
+
gtksharp_prefix="`$PKG_CONFIG --variable=prefix gtk-sharp-2.0`"
@@ -4446,7 +4496,7 @@ exec 6>&1
# report actual input values of CONFIG_FILES etc. instead of their
# values after options handling.
ac_log="
-This file was extended by monodevelop-vala $as_me 2.0, which was
+This file was extended by monodevelop-vala $as_me 2.1.1, which was
generated by GNU Autoconf 2.61. Invocation command line was
CONFIG_FILES = $CONFIG_FILES
@@ -4489,7 +4539,7 @@ Report bugs to <bug-autoconf at gnu.org>."
_ACEOF
cat >>$CONFIG_STATUS <<_ACEOF
ac_cs_version="\\
-monodevelop-vala config.status 2.0
+monodevelop-vala config.status 2.1.1
configured by $0, generated by GNU Autoconf 2.61,
with options \\"`echo "$ac_configure_args" | sed 's/^ //; s/[\\""\`\$]/\\\\&/g'`\\"
@@ -4790,6 +4840,7 @@ for ac_last_try in false false false false false :; do
cat >conf$$subs.sed <<_ACEOF
HAVE_GCONF_SHARP_TRUE!$HAVE_GCONF_SHARP_TRUE$ac_delim
HAVE_GCONF_SHARP_FALSE!$HAVE_GCONF_SHARP_FALSE$ac_delim
+VSCSHELL!$VSCSHELL$ac_delim
gtksharp_prefix!$gtksharp_prefix$ac_delim
LIB_SUFFIX!$LIB_SUFFIX$ac_delim
LIB_PREFIX!$LIB_PREFIX$ac_delim
@@ -4799,7 +4850,7 @@ LIBOBJS!$LIBOBJS$ac_delim
LTLIBOBJS!$LTLIBOBJS$ac_delim
_ACEOF
- if test `sed -n "s/.*$ac_delim\$/X/p" conf$$subs.sed | grep -c X` = 9; then
+ if test `sed -n "s/.*$ac_delim\$/X/p" conf$$subs.sed | grep -c X` = 10; then
break
elif $ac_last_try; then
{ { echo "$as_me:$LINENO: error: could not make $CONFIG_STATUS" >&5
diff --git a/configure.in b/configure.in
index cca038f..123c95a 100644
--- a/configure.in
+++ b/configure.in
@@ -1,9 +1,9 @@
-AC_INIT([monodevelop-vala], 2.0, [taktaktaktaktaktaktaktaktaktak at gmail.com])
+AC_INIT([monodevelop-vala], 2.1.1, [taktaktaktaktaktaktaktaktaktak at gmail.com])
AC_PREREQ(2.53)
AM_INIT_AUTOMAKE(1.9 tar-ustar)
AM_MAINTAINER_MODE
-ASSEMBLY_VERSION=2.0.0.0
+ASSEMBLY_VERSION=2.1.1.0
AC_PATH_PROG(MONO, mono)
AC_PATH_PROG(MCS, gmcs)
@@ -24,7 +24,9 @@ if test "x$PKG_CONFIG" = "xno"; then
AC_MSG_ERROR([You need to install pkg-config])
fi
-MONO_REQUIRED_VERSION=1.1.10
+export PKG_CONFIG_PATH="${PKG_CONFIG_PATH}:../../local-config/"
+
+MONO_REQUIRED_VERSION=2.4
PKG_CHECK_MODULES(UNMANAGED_DEPENDENCIES_MONO,mono >= $MONO_REQUIRED_VERSION, has_mono=true, has_mono=false)
if test "x$has_mono" = "xfalse"; then
@@ -49,8 +51,8 @@ fi
dnl hard dependencies
MONOADDINS_REQUIRED_VERSION=0.3
-GTKSHARP_REQUIRED_VERSION=2.8.0
-MONODEVELOP_REQUIRED_VERSION=2.0
+GTKSHARP_REQUIRED_VERSION=2.12.8
+MONODEVELOP_REQUIRED_VERSION=2.1.1
PKG_CHECK_MODULES(MONO_ADDINS, mono-addins >= $MONOADDINS_REQUIRED_VERSION)
AC_SUBST(MONO_ADDINS_LIBS)
@@ -80,6 +82,17 @@ PKG_CHECK_MODULES(GCONF_SHARP, gconf-sharp-2.0 >= $GTKSHARP_REQUIRED_VERSION, [g
AC_SUBST(GCONF_SHARP_LIBS)
AM_CONDITIONAL(HAVE_GCONF_SHARP, test x$gconf_sharp = xyes)
+AC_CHECK_PROG(VSCSHELL, vsc-shell, [vsc-shell])
+AC_SUBST(VSCSHELL)
+
+if test x$VSCSHELL = x; then
+ echo ""
+ echo "Vsc-shell is required for Vala code completion."
+ echo "Vsc-shell is part of the VTG package, available from: "
+ echo "http://code.google.com/p/vtg/"
+ echo ""
+fi
+
gtksharp_prefix="`$PKG_CONFIG --variable=prefix gtk-sharp-2.0`"
AC_SUBST(gtksharp_prefix)
diff --git a/gtk-gui/MonoDevelop.ValaBinding.PackageDetails.cs b/gtk-gui/MonoDevelop.ValaBinding.PackageDetails.cs
index e452898..0de6537 100644
--- a/gtk-gui/MonoDevelop.ValaBinding.PackageDetails.cs
+++ b/gtk-gui/MonoDevelop.ValaBinding.PackageDetails.cs
@@ -45,7 +45,6 @@ namespace MonoDevelop.ValaBinding {
this.Name = "MonoDevelop.ValaBinding.PackageDetails";
this.Title = Mono.Unix.Catalog.GetString("Package Details");
this.WindowPosition = ((Gtk.WindowPosition)(4));
- this.HasSeparator = false;
// Internal child MonoDevelop.ValaBinding.PackageDetails.VBox
Gtk.VBox w1 = this.VBox;
w1.Name = "dialog1_VBox";
diff --git a/gtk-gui/gui.stetic b/gtk-gui/gui.stetic
index c98bc56..7b3eecb 100644
--- a/gtk-gui/gui.stetic
+++ b/gtk-gui/gui.stetic
@@ -1,8 +1,8 @@
-<?xml version="1.0" encoding="utf-8"?>
+<?xml version="1.0" encoding="utf-8"?>
<stetic-interface>
<configuration>
<images-root-path>..</images-root-path>
- <target-gtk-version>2.8</target-gtk-version>
+ <target-gtk-version>2.12</target-gtk-version>
</configuration>
<import>
<widget-library name="MonoDevelop.Core.Gui, Version=1.9.1.0, Culture=neutral" />
diff --git a/templates/Makefile.am.template b/templates/Makefile.am.template
new file mode 100644
index 0000000..77af3a2
--- /dev/null
+++ b/templates/Makefile.am.template
@@ -0,0 +1,23 @@
+
+# Warning: This is an automatically generated file, do not edit!
+
+VTARGET = %%VTARGET%%
+CLEANFILES = $(VTARGET)
+
+include $(top_srcdir)/Makefile.include
+
+PACKAGE = @PACKAGE@
+BUILD_DIR = %%BUILD_DIR%%
+INSTALL_DIR = %%INSTALL_DIR%%
+
+FILES = %%FILES%%
+VFLAGS = %%VFLAGS%%
+
+install:
+
+uninstall:
+
+all:
+ mkdir -p $(BUILD_DIR)
+ valac $(VFLAGS) -o $(VTARGET) $(FILES)
+
diff --git a/templates/Makefile.template b/templates/Makefile.template
new file mode 100644
index 0000000..b8f2b25
--- /dev/null
+++ b/templates/Makefile.template
@@ -0,0 +1,26 @@
+
+# Warning: This is an automatically generated file, do not edit!
+
+srcdir=.
+top_srcdir=%%TOP_SRCDIR%%
+
+include $(top_srcdir)/Makefile.include
+include $(top_srcdir)/config.make
+
+BUILD_DIR = %%BUILD_DIR%%
+INSTALL_DIR = %%INSTALL_DIR%%
+
+FILES = %%FILES%%
+VFLAGS = %%VFLAGS%%
+VTARGET = %%VTARGET%%
+
+all: $(VTARGET)
+
+install:
+
+uninstall:
+
+$(VTARGET):
+ mkdir -p $(BUILD_DIR)
+ valac $(VFLAGS) -o $(VTARGET) $(FILES)
+
--
monodevelop-vala
More information about the Pkg-cli-apps-commits
mailing list