Author: mkrueger
Date: 2008-02-02 19:27:35 -0500 (Sat, 02 Feb 2008)
New Revision: 94659
Added:
trunk/monodevelop/main/src/core/MonoDevelop.Ide/MonoDevelop.Dom.Output/
trunk/monodevelop/main/src/core/MonoDevelop.Ide/MonoDevelop.Dom.Output/Ambience.cs
trunk/monodevelop/main/src/core/MonoDevelop.Ide/MonoDevelop.Dom.Output/NetAmbience.cs
trunk/monodevelop/main/src/core/MonoDevelop.Ide/MonoDevelop.Dom.Parser/
trunk/monodevelop/main/src/core/MonoDevelop.Ide/MonoDevelop.Dom.Parser/AbstractParser.cs
trunk/monodevelop/main/src/core/MonoDevelop.Ide/MonoDevelop.Dom.Parser/IParser.cs
trunk/monodevelop/main/src/core/MonoDevelop.Ide/MonoDevelop.Dom.Parser/ProjectDom.cs
trunk/monodevelop/main/src/core/MonoDevelop.Ide/MonoDevelop.Dom.Parser/ProjectParserService.cs
trunk/monodevelop/main/src/core/MonoDevelop.Ide/MonoDevelop.Dom/ClassType.cs
Modified:
trunk/monodevelop/main/src/core/MonoDevelop.Ide/ChangeLog
trunk/monodevelop/main/src/core/MonoDevelop.Ide/Makefile.am
trunk/monodevelop/main/src/core/MonoDevelop.Ide/MonoDevelop.Dom/DomType.cs
trunk/monodevelop/main/src/core/MonoDevelop.Ide/MonoDevelop.Dom/ICompilationUnit.cs
trunk/monodevelop/main/src/core/MonoDevelop.Ide/MonoDevelop.Dom/IType.cs
trunk/monodevelop/main/src/core/MonoDevelop.Ide/MonoDevelop.Ide.Gui/ProjectOperations.cs
trunk/monodevelop/main/src/core/MonoDevelop.Ide/MonoDevelop.Ide.mdp
Log:
* MonoDevelop.Dom.Parser, MonoDevelop.Dom.Parser/AbstractParser.cs,
MonoDevelop.Dom.Parser/ProjectParserService.cs,
MonoDevelop.Dom.Parser/IParser.cs,
MonoDevelop.Dom.Parser/ProjectDom.cs, MonoDevelop.Dom.Output,
MonoDevelop.Dom.Output/Ambience.cs,
MonoDevelop.Dom.Output/NetAmbience.cs, MonoDevelop.Dom/DomType.cs,
MonoDevelop.Dom/ClassType.cs, MonoDevelop.Dom/ICompilationUnit.cs,
MonoDevelop.Dom/IType.cs: Added simple dom parser infrastructure.
* MonoDevelop.Ide.Gui/ProjectOperations.cs: Parser database is now
loaded on demand (slightly improving startup speed).
Modified: trunk/monodevelop/main/src/core/MonoDevelop.Ide/ChangeLog
===================================================================
--- trunk/monodevelop/main/src/core/MonoDevelop.Ide/ChangeLog 2008-02-02
23:09:32 UTC (rev 94658)
+++ trunk/monodevelop/main/src/core/MonoDevelop.Ide/ChangeLog 2008-02-03
00:27:35 UTC (rev 94659)
@@ -1,3 +1,15 @@
+2008-02-03 Mike Krüger <[EMAIL PROTECTED]>
+
+ * MonoDevelop.Dom.Parser, MonoDevelop.Dom.Parser/AbstractParser.cs,
+ MonoDevelop.Dom.Parser/ProjectParserService.cs,
+ MonoDevelop.Dom.Parser/IParser.cs,
MonoDevelop.Dom.Parser/ProjectDom.cs,
+ MonoDevelop.Dom.Output, MonoDevelop.Dom.Output/Ambience.cs,
+ MonoDevelop.Dom.Output/NetAmbience.cs, MonoDevelop.Dom/DomType.cs,
+ MonoDevelop.Dom/ClassType.cs, MonoDevelop.Dom/ICompilationUnit.cs,
+ MonoDevelop.Dom/IType.cs: Added simple dom parser infrastructure.
+ * MonoDevelop.Ide.Gui/ProjectOperations.cs: Parser database is now
loaded on
+ demand (slightly improving startup speed).
+
2008-02-02 Mike Krüger <[EMAIL PROTECTED]>
* MonoDevelop.Dom: Added a new dom layer (currently unused - will be
for a
Modified: trunk/monodevelop/main/src/core/MonoDevelop.Ide/Makefile.am
===================================================================
--- trunk/monodevelop/main/src/core/MonoDevelop.Ide/Makefile.am 2008-02-02
23:09:32 UTC (rev 94658)
+++ trunk/monodevelop/main/src/core/MonoDevelop.Ide/Makefile.am 2008-02-03
00:27:35 UTC (rev 94659)
@@ -56,9 +56,16 @@
gtk-gui/MonoDevelop.Ide.SelectEncodingsDialog.cs \
gtk-gui/MonoDevelop.Ide.StandardHeaders.NewHeaderTemplateDialog.cs \
gtk-gui/MonoDevelop.Ide.StandardHeaders.StandardHeaderPanel.cs \
+ MonoDevelop.Dom.Output/Ambience.cs \
+ MonoDevelop.Dom.Output/NetAmbience.cs \
+ MonoDevelop.Dom.Parser/AbstractParser.cs \
+ MonoDevelop.Dom.Parser/IParser.cs \
+ MonoDevelop.Dom.Parser/ProjectDom.cs \
+ MonoDevelop.Dom.Parser/ProjectParserService.cs \
MonoDevelop.Dom/AbstractDomItem.cs \
MonoDevelop.Dom/AbstractMember.cs \
MonoDevelop.Dom/AttributeTarget.cs \
+ MonoDevelop.Dom/ClassType.cs \
MonoDevelop.Dom/Comment.cs \
MonoDevelop.Dom/CommentType.cs \
MonoDevelop.Dom/DomAttribute.cs \
Added:
trunk/monodevelop/main/src/core/MonoDevelop.Ide/MonoDevelop.Dom/ClassType.cs
===================================================================
---
trunk/monodevelop/main/src/core/MonoDevelop.Ide/MonoDevelop.Dom/ClassType.cs
2008-02-02 23:09:32 UTC (rev 94658)
+++
trunk/monodevelop/main/src/core/MonoDevelop.Ide/MonoDevelop.Dom/ClassType.cs
2008-02-03 00:27:35 UTC (rev 94659)
@@ -0,0 +1,41 @@
+//
+// ClassType.cs
+//
+// Author:
+// Mike Krüger <[EMAIL PROTECTED]>
+//
+// Copyright (C) 2008 Novell, Inc (http://www.novell.com)
+//
+// 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;
+
+namespace MonoDevelop.Dom
+{
+ public enum ClassType {
+ Unknown,
+ Class,
+ Enum,
+ Interface,
+ Struct,
+ Delegate
+ }
+}
Modified:
trunk/monodevelop/main/src/core/MonoDevelop.Ide/MonoDevelop.Dom/DomType.cs
===================================================================
--- trunk/monodevelop/main/src/core/MonoDevelop.Ide/MonoDevelop.Dom/DomType.cs
2008-02-02 23:09:32 UTC (rev 94658)
+++ trunk/monodevelop/main/src/core/MonoDevelop.Ide/MonoDevelop.Dom/DomType.cs
2008-02-03 00:27:35 UTC (rev 94659)
@@ -38,6 +38,7 @@
protected IType baseType;
protected List<TypeParameter> typeParameters = new
List<TypeParameter> ();
protected List<IDomItem> members = new List<IDomItem> ();
+ protected ClassType classType = ClassType.Unknown;
public object SourceProject {
get {
@@ -51,6 +52,12 @@
}
}
+ public ClassType ClassType {
+ get {
+ return classType;
+ }
+ }
+
public IType BaseType {
get {
return baseType;
Modified:
trunk/monodevelop/main/src/core/MonoDevelop.Ide/MonoDevelop.Dom/ICompilationUnit.cs
===================================================================
---
trunk/monodevelop/main/src/core/MonoDevelop.Ide/MonoDevelop.Dom/ICompilationUnit.cs
2008-02-02 23:09:32 UTC (rev 94658)
+++
trunk/monodevelop/main/src/core/MonoDevelop.Ide/MonoDevelop.Dom/ICompilationUnit.cs
2008-02-03 00:27:35 UTC (rev 94659)
@@ -31,7 +31,7 @@
namespace MonoDevelop.Dom
{
- public interface ICompilationUnit
+ public interface ICompilationUnit : IDisposable
{
string FileName {
get;
Modified:
trunk/monodevelop/main/src/core/MonoDevelop.Ide/MonoDevelop.Dom/IType.cs
===================================================================
--- trunk/monodevelop/main/src/core/MonoDevelop.Ide/MonoDevelop.Dom/IType.cs
2008-02-02 23:09:32 UTC (rev 94658)
+++ trunk/monodevelop/main/src/core/MonoDevelop.Ide/MonoDevelop.Dom/IType.cs
2008-02-03 00:27:35 UTC (rev 94659)
@@ -41,6 +41,10 @@
get;
}
+ ClassType ClassType {
+ get;
+ }
+
IType BaseType {
get;
}
Added:
trunk/monodevelop/main/src/core/MonoDevelop.Ide/MonoDevelop.Dom.Output/Ambience.cs
===================================================================
---
trunk/monodevelop/main/src/core/MonoDevelop.Ide/MonoDevelop.Dom.Output/Ambience.cs
2008-02-02 23:09:32 UTC (rev 94658)
+++
trunk/monodevelop/main/src/core/MonoDevelop.Ide/MonoDevelop.Dom.Output/Ambience.cs
2008-02-03 00:27:35 UTC (rev 94659)
@@ -0,0 +1,156 @@
+//
+// Ambience.cs
+//
+// Author:
+// Mike Krüger <[EMAIL PROTECTED]>
+//
+// Copyright (C) 2008 Novell, Inc (http://www.novell.com)
+//
+// 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;
+using System.Collections.Generic;
+using MonoDevelop.Core;
+
+namespace MonoDevelop.Dom.Output
+{
+ public class Ambience : IDomVisitor
+ {
+ string name;
+ protected Dictionary<Modifiers, string> modifiers = new
Dictionary<Modifiers, string> ();
+ protected Dictionary<ClassType, string> classTypes = new
Dictionary<ClassType, string> ();
+ protected Dictionary<ParameterModifiers, string>
parameterModifiers = new Dictionary<ParameterModifiers, string> ();
+ protected Dictionary<string, string> constructs = new
Dictionary<string, string> ();
+
+ public Ambience (string name)
+ {
+ this.name = name;
+ }
+
+ protected string GetString (Modifiers m)
+ {
+ if ((m & Modifiers.ProtectedAndInternal) ==
Modifiers.ProtectedAndInternal)
+ return GetString (m &
~Modifiers.ProtectedAndInternal) + " " +
modifiers[Modifiers.ProtectedAndInternal];
+ if ((m & Modifiers.ProtectedOrInternal) ==
Modifiers.ProtectedOrInternal)
+ return GetString (m &
~Modifiers.ProtectedOrInternal) + " " +
modifiers[Modifiers.ProtectedOrInternal];
+
+ StringBuilder result = new StringBuilder ();
+ foreach (Modifiers singleModifier in Enum.GetValues
(typeof(Modifiers))) {
+ if ((m & singleModifier) == singleModifier &&
modifiers.ContainsKey (singleModifier)) {
+ if (result.Length > 0)
+ result.Append (' ');
+ result.Append
(modifiers[singleModifier]);
+ }
+ }
+ return result.ToString ();
+ }
+
+ protected string GetString (ClassType classType)
+ {
+ return classTypes.ContainsKey(classType) ?
classTypes[classType] : "";
+ }
+
+ protected string GetString (ParameterModifiers m)
+ {
+ StringBuilder result = new StringBuilder ();
+ foreach (ParameterModifiers singleModifier in
Enum.GetValues (typeof(ParameterModifiers))) {
+ if ((m & singleModifier) == singleModifier &&
parameterModifiers.ContainsKey (singleModifier)) {
+ if (result.Length > 0)
+ result.Append (' ');
+ result.Append
(parameterModifiers[singleModifier]);
+ }
+ }
+ return result.ToString ();
+ }
+
+
+ public virtual object Visit (MonoDevelop.Dom.ICompilationUnit
unit, object data)
+ {
+ return "";
+ }
+
+ public virtual object Visit (MonoDevelop.Dom.IAttribute attr,
object data)
+ {
+ return "";
+// StringBuilder arguments = new StringBuilder ();
+// arguments.Append ('(');
+// foreach (object o in attr.PositionalArguments) {
+// if (arguments.Length > 1)
+// arguments.Append (',');
+// arguments.Append (o.ToString ());
+// }
+// foreach (KeyValuePair<string, object> pair in
attr.PositionalArguments) {
+// if (arguments.Length > 1)
+// arguments.Append (',');
+// arguments.Append (pair.Key.ToString ());
+// arguments.Append ('=');
+// arguments.Append (pair.Value.ToString ());
+// }
+//
+// arguments.Append (')');
+// return StringParserService.Parse
(constructs[Attribute], new string[,] {
+// {"Type", Visit (attr.AttributeType,
data).ToString ()},
+// {"ArgumentList", arguments.ToString}
+// });
+ }
+
+ public virtual object Visit (MonoDevelop.Dom.IType type, object
data)
+ {
+ return "";
+ }
+
+ public virtual object Visit (MonoDevelop.Dom.IField field,
object data)
+ {
+ return "";
+ }
+
+ public virtual object Visit (MonoDevelop.Dom.IMethod method,
object data)
+ {
+ return "";
+ }
+
+ public virtual object Visit (MonoDevelop.Dom.IProperty
property, object data)
+ {
+ return "";
+ }
+
+ public virtual object Visit (MonoDevelop.Dom.IEvent e, object
data)
+ {
+ return "";
+ }
+
+ public virtual object Visit (MonoDevelop.Dom.IReturnType type,
object data)
+ {
+ return "";
+ }
+
+ public virtual object Visit (MonoDevelop.Dom.IParameter
parameter, object data)
+ {
+ return "";
+ }
+
+ public virtual object Visit (MonoDevelop.Dom.IUsing u, object
data)
+ {
+ return "";
+ }
+ }
+}
Added:
trunk/monodevelop/main/src/core/MonoDevelop.Ide/MonoDevelop.Dom.Output/NetAmbience.cs
===================================================================
---
trunk/monodevelop/main/src/core/MonoDevelop.Ide/MonoDevelop.Dom.Output/NetAmbience.cs
2008-02-02 23:09:32 UTC (rev 94658)
+++
trunk/monodevelop/main/src/core/MonoDevelop.Ide/MonoDevelop.Dom.Output/NetAmbience.cs
2008-02-03 00:27:35 UTC (rev 94659)
@@ -0,0 +1,72 @@
+//
+// NetAmbience.cs
+//
+// Author:
+// Mike Krüger <[EMAIL PROTECTED]>
+//
+// Copyright (C) 2008 Novell, Inc (http://www.novell.com)
+//
+// 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;
+
+namespace MonoDevelop.Dom.Output
+{
+ public class NetAmbience : Ambience
+ {
+ public NetAmbience () : base ("NET")
+ {
+ classTypes[ClassType.Class] = "Class";
+ classTypes[ClassType.Enum] = "Enumeration";
+ classTypes[ClassType.Interface] = "Interface";
+ classTypes[ClassType.Struct] = "Structure";
+ classTypes[ClassType.Delegate] = "Delegate";
+
+ parameterModifiers[ParameterModifiers.In] = "In";
+ parameterModifiers[ParameterModifiers.Out] = "Out";
+ parameterModifiers[ParameterModifiers.Ref] = "Ref";
+ parameterModifiers[ParameterModifiers.Params] =
"Params";
+ parameterModifiers[ParameterModifiers.Optional] =
"Optional";
+
+ modifiers[Modifiers.Private] = "Private";
+ modifiers[Modifiers.Internal] = "Internal";
+ modifiers[Modifiers.Protected] = "Protected";
+ modifiers[Modifiers.Public] = "Public";
+ modifiers[Modifiers.Abstract] = "Abstract";
+ modifiers[Modifiers.Virtual] = "Virtual";
+ modifiers[Modifiers.Sealed] = "Sealed";
+ modifiers[Modifiers.Static] = "Static";
+ modifiers[Modifiers.Override] = "Override";
+ modifiers[Modifiers.Readonly] = "Readonly";
+ modifiers[Modifiers.Const] = "Const";
+ modifiers[Modifiers.Partial] = "Partial";
+ modifiers[Modifiers.Extern] = "Extern";
+ modifiers[Modifiers.Volatile] = "Volatile";
+ modifiers[Modifiers.Unsafe] = "Unsafe";
+ modifiers[Modifiers.Overloads] = "Overloads";
+ modifiers[Modifiers.WithEvents] =
"WithEvents";
+ modifiers[Modifiers.Default] = "Default";
+ modifiers[Modifiers.Fixed] = "Fixed";
+ modifiers[Modifiers.ProtectedAndInternal] = "Protected
Internal";
+ modifiers[Modifiers.ProtectedOrInternal] = "Internal
Protected";
+ }
+ }
+}
Added:
trunk/monodevelop/main/src/core/MonoDevelop.Ide/MonoDevelop.Dom.Parser/AbstractParser.cs
===================================================================
---
trunk/monodevelop/main/src/core/MonoDevelop.Ide/MonoDevelop.Dom.Parser/AbstractParser.cs
2008-02-02 23:09:32 UTC (rev 94658)
+++
trunk/monodevelop/main/src/core/MonoDevelop.Ide/MonoDevelop.Dom.Parser/AbstractParser.cs
2008-02-03 00:27:35 UTC (rev 94659)
@@ -0,0 +1,73 @@
+//
+// AbstractParser.cs
+//
+// Author:
+// Mike Krüger <[EMAIL PROTECTED]>
+//
+// Copyright (C) 2008 Novell, Inc (http://www.novell.com)
+//
+// 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.Ide.Gui;
+
+namespace MonoDevelop.Dom.Parser
+{
+ public abstract class AbstractParser : IParser
+ {
+ string projectType;
+ string[] mimeTypes;
+
+ protected AbstractParser (string projectType, params string[]
mimeTypes)
+ {
+ this.projectType = projectType;
+ this.mimeTypes = mimeTypes;
+ }
+
+ public ICompilationUnit Parse (string fileName)
+ {
+ return Parse (fileName, System.IO.File.ReadAllText
(fileName));
+ }
+
+ public abstract ICompilationUnit Parse (string fileName, string
content);
+
+ public virtual bool CanParseMimeType (string mimeType)
+ {
+ if (mimeTypes == null)
+ return false;
+ foreach (string canParseType in mimeTypes) {
+ if (canParseType == mimeType)
+ return true;
+ }
+ return false;
+ }
+
+ public virtual bool CanParseProjectType (string projectType)
+ {
+ return this.projectType == projectType;
+ }
+
+ public virtual bool CanParse (string fileName)
+ {
+ return CanParseMimeType
(IdeApp.Services.PlatformService.GetMimeTypeForUri (fileName));
+ }
+ }
+}
Added:
trunk/monodevelop/main/src/core/MonoDevelop.Ide/MonoDevelop.Dom.Parser/IParser.cs
===================================================================
---
trunk/monodevelop/main/src/core/MonoDevelop.Ide/MonoDevelop.Dom.Parser/IParser.cs
2008-02-02 23:09:32 UTC (rev 94658)
+++
trunk/monodevelop/main/src/core/MonoDevelop.Ide/MonoDevelop.Dom.Parser/IParser.cs
2008-02-03 00:27:35 UTC (rev 94659)
@@ -0,0 +1,42 @@
+//
+// IParser.cs
+//
+// Author:
+// Mike Krüger <[EMAIL PROTECTED]>
+//
+// Copyright (C) 2008 Novell, Inc (http://www.novell.com)
+//
+// 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;
+
+namespace MonoDevelop.Dom.Parser
+{
+ public interface IParser
+ {
+ ICompilationUnit Parse (string fileName, string content);
+ ICompilationUnit Parse (string fileName);
+
+ bool CanParseMimeType (string mimeType);
+ bool CanParseProjectType (string projectType);
+ bool CanParse (string fileName);
+ }
+}
Added:
trunk/monodevelop/main/src/core/MonoDevelop.Ide/MonoDevelop.Dom.Parser/ProjectDom.cs
===================================================================
---
trunk/monodevelop/main/src/core/MonoDevelop.Ide/MonoDevelop.Dom.Parser/ProjectDom.cs
2008-02-02 23:09:32 UTC (rev 94658)
+++
trunk/monodevelop/main/src/core/MonoDevelop.Ide/MonoDevelop.Dom.Parser/ProjectDom.cs
2008-02-03 00:27:35 UTC (rev 94659)
@@ -0,0 +1,60 @@
+//
+// ProjectDom.cs
+//
+// Author:
+// Mike Krüger <[EMAIL PROTECTED]>
+//
+// Copyright (C) 2008 Novell, Inc (http://www.novell.com)
+//
+// 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;
+
+namespace MonoDevelop.Dom.Parser
+{
+ public class ProjectDom
+ {
+ Dictionary<string, ICompilationUnit> compilationUnits = new
Dictionary<string, ICompilationUnit> ();
+
+ public IEnumerable<ICompilationUnit> CompilationUnits {
+ get {
+ return compilationUnits.Values;
+ }
+ }
+
+ public void RemoveCompilationUnit (string fileName)
+ {
+ if (compilationUnits.ContainsKey (fileName)) {
+ compilationUnits[fileName].Dispose ();
+ compilationUnits.Remove (fileName);
+ }
+ }
+
+ public void UpdateCompilationUnit (ICompilationUnit
compilationUnit)
+ {
+ if (compilationUnits.ContainsKey
(compilationUnit.FileName)) {
+
compilationUnits[compilationUnit.FileName].Dispose ();
+ }
+ compilationUnits[compilationUnit.FileName] =
compilationUnit;
+ }
+ }
+}
Added:
trunk/monodevelop/main/src/core/MonoDevelop.Ide/MonoDevelop.Dom.Parser/ProjectParserService.cs
===================================================================
---
trunk/monodevelop/main/src/core/MonoDevelop.Ide/MonoDevelop.Dom.Parser/ProjectParserService.cs
2008-02-02 23:09:32 UTC (rev 94658)
+++
trunk/monodevelop/main/src/core/MonoDevelop.Ide/MonoDevelop.Dom.Parser/ProjectParserService.cs
2008-02-03 00:27:35 UTC (rev 94659)
@@ -0,0 +1,92 @@
+//
+// ProjectDomService.cs
+//
+// Author:
+// Mike Krüger <[EMAIL PROTECTED]>
+//
+// Copyright (C) 2008 Novell, Inc (http://www.novell.com)
+//
+// 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 System.Diagnostics;
+using MonoDevelop.Projects;
+
+namespace MonoDevelop.Dom.Parser
+{
+ public static class ProjectDomService
+ {
+ static Dictionary<string, ProjectDom> doms = new
Dictionary<string, ProjectDom> ();
+ static List<IParser> parsers = new List<IParser>();
+
+ public static List<IParser> Parsers {
+ get {
+ return parsers;
+ }
+ }
+
+ public static void Init ()
+ {
+
MonoDevelop.Ide.Gui.IdeApp.ProjectOperations.CombineOpened += delegate {
+ LoadWholeSolution ();
+ };
+ }
+
+ static IParser GetParser (string projectType)
+ {
+ foreach (IParser parser in parsers) {
+ if (parser.CanParseProjectType (projectType))
+ return parser;
+ }
+ return null;
+ }
+
+ static ProjectDom GetDom (Project project)
+ {
+ Debug.Assert (project != null);
+ return GetDom (project.FileName);
+ }
+
+ static ProjectDom GetDom (string fileName)
+ {
+ Debug.Assert (!String.IsNullOrEmpty (fileName));
+ if (!doms.ContainsKey (fileName))
+ doms [fileName] = new ProjectDom ();
+ return doms [fileName];
+ }
+
+ static void LoadWholeSolution ()
+ {
+ foreach (CombineEntry entry in
MonoDevelop.Ide.Gui.IdeApp.ProjectOperations.CurrentOpenCombine.GetAllProjects
()) {
+ Project project = (Project)entry;
+ IParser parser = GetParser
(project.ProjectType);
+ if (parser == null)
+ continue;
+
+ ProjectDom dom = GetDom (project);
+ foreach (ProjectFile file in
project.ProjectFiles) {
+ dom.UpdateCompilationUnit (parser.Parse
(file.FilePath));
+ }
+ }
+ }
+ }
+}
Modified:
trunk/monodevelop/main/src/core/MonoDevelop.Ide/MonoDevelop.Ide.Gui/ProjectOperations.cs
===================================================================
---
trunk/monodevelop/main/src/core/MonoDevelop.Ide/MonoDevelop.Ide.Gui/ProjectOperations.cs
2008-02-02 23:09:32 UTC (rev 94658)
+++
trunk/monodevelop/main/src/core/MonoDevelop.Ide/MonoDevelop.Ide.Gui/ProjectOperations.cs
2008-02-03 00:27:35 UTC (rev 94659)
@@ -102,21 +102,24 @@
FileService.FileRemoved +=
(EventHandler<FileEventArgs>) DispatchService.GuiDispatch (new
EventHandler<FileEventArgs> (CheckFileRemove));
FileService.FileRenamed +=
(EventHandler<FileCopyEventArgs>) DispatchService.GuiDispatch (new
EventHandler<FileCopyEventArgs> (CheckFileRename));
- parserDatabase =
Services.ParserService.CreateParserDatabase ();
- parserDatabase.TrackFileChanges = true;
- parserDatabase.ParseProgressMonitorFactory = new
ParseProgressMonitorFactory ();
-
GLib.Timeout.Add (2000, OnRunProjectChecks);
}
public IParserDatabase ParserDatabase {
- get { return parserDatabase; }
+ get {
+ if (parserDatabase == null) {
+ parserDatabase =
Services.ParserService.CreateParserDatabase ();
+ parserDatabase.TrackFileChanges = true;
+
parserDatabase.ParseProgressMonitorFactory = new ParseProgressMonitorFactory
();
+ }
+ return parserDatabase;
+ }
}
public CodeRefactorer CodeRefactorer {
get {
if (refactorer == null) {
- refactorer = new CodeRefactorer
(openCombine, parserDatabase);
+ refactorer = new CodeRefactorer
(openCombine, ParserDatabase);
refactorer.TextFileProvider = new
OpenDocumentFileProvider ();
}
@@ -326,7 +329,7 @@
doc.Close ();
}
- parserDatabase.Unload (closedCombine);
+ ParserDatabase.Unload (closedCombine);
OnCombineClosed(new
CombineEventArgs(closedCombine));
OnEntryUnloaded (closedCombine);
@@ -398,7 +401,7 @@
SearchForNewFiles ();
- parserDatabase.Load (openCombine);
+ ParserDatabase.Load (openCombine);
} catch (Exception ex) {
monitor.ReportError ("Load operation failed.",
ex);
Modified: trunk/monodevelop/main/src/core/MonoDevelop.Ide/MonoDevelop.Ide.mdp
===================================================================
--- trunk/monodevelop/main/src/core/MonoDevelop.Ide/MonoDevelop.Ide.mdp
2008-02-02 23:09:32 UTC (rev 94658)
+++ trunk/monodevelop/main/src/core/MonoDevelop.Ide/MonoDevelop.Ide.mdp
2008-02-03 00:27:35 UTC (rev 94659)
@@ -367,6 +367,13 @@
<File name="MonoDevelop.Dom/DomReturnType.cs" subtype="Code"
buildaction="Compile" />
<File name="MonoDevelop.Dom/DomUsing.cs" subtype="Code"
buildaction="Compile" />
<File name="MonoDevelop.Dom/DomType.cs" subtype="Code"
buildaction="Compile" />
+ <File name="MonoDevelop.Dom.Output/Ambience.cs" subtype="Code"
buildaction="Compile" />
+ <File name="MonoDevelop.Dom/ClassType.cs" subtype="Code"
buildaction="Compile" />
+ <File name="MonoDevelop.Dom.Output/NetAmbience.cs" subtype="Code"
buildaction="Compile" />
+ <File name="MonoDevelop.Dom.Parser/ProjectDom.cs" subtype="Code"
buildaction="Compile" />
+ <File name="MonoDevelop.Dom.Parser/ProjectParserService.cs" subtype="Code"
buildaction="Compile" />
+ <File name="MonoDevelop.Dom.Parser/IParser.cs" subtype="Code"
buildaction="Compile" />
+ <File name="MonoDevelop.Dom.Parser/AbstractParser.cs" subtype="Code"
buildaction="Compile" />
</Contents>
<References>
<ProjectReference type="Gac" localcopy="False" refto="System,
Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" />
_______________________________________________
Mono-patches maillist - [email protected]
http://lists.ximian.com/mailman/listinfo/mono-patches