[Monodevelop-patches-list] r2185 - in trunk/MonoDevelop/Core/src: AddIns/BackendBindings/CSharpBinding AddIns/BackendBindings/CSharpBinding/Parser AddIns/BackendBindings/CSharpBinding/Parser/SharpDevelopTree AddIns/BackendBindings/VBNetBinding AddIns/BackendBindings/VBNetBinding/Parser ICSharpCode.SharpRefactory ICSharpCode.SharpRefactory/src/Lexer/Specials MonoDevelop.Base MonoDevelop.Base/Internal/Parser MonoDevelop.Base/Services/ParserService
commit-watcher at mono-cvs.ximian.com
commit-watcher at mono-cvs.ximian.com
Fri Jan 28 19:13:31 EST 2005
Author: jluke
Date: 2005-01-28 19:13:31 -0500 (Fri, 28 Jan 2005)
New Revision: 2185
Added:
trunk/MonoDevelop/Core/src/AddIns/BackendBindings/CSharpBinding/Parser/SharpDevelopTree/Destructor.cs
trunk/MonoDevelop/Core/src/ICSharpCode.SharpRefactory/src/Lexer/Specials/TagComment.cs
Modified:
trunk/MonoDevelop/Core/src/AddIns/BackendBindings/CSharpBinding/ChangeLog
trunk/MonoDevelop/Core/src/AddIns/BackendBindings/CSharpBinding/Makefile.am
trunk/MonoDevelop/Core/src/AddIns/BackendBindings/CSharpBinding/Parser/CSharpVisitor.cs
trunk/MonoDevelop/Core/src/AddIns/BackendBindings/CSharpBinding/Parser/ExpressionFinder.cs
trunk/MonoDevelop/Core/src/AddIns/BackendBindings/CSharpBinding/Parser/Parser.cs
trunk/MonoDevelop/Core/src/AddIns/BackendBindings/CSharpBinding/Parser/Resolver.cs
trunk/MonoDevelop/Core/src/AddIns/BackendBindings/CSharpBinding/Parser/SharpDevelopTree/Class.cs
trunk/MonoDevelop/Core/src/AddIns/BackendBindings/CSharpBinding/Parser/TypeVisitor.cs
trunk/MonoDevelop/Core/src/AddIns/BackendBindings/VBNetBinding/ChangeLog
trunk/MonoDevelop/Core/src/AddIns/BackendBindings/VBNetBinding/Parser/Parser.cs
trunk/MonoDevelop/Core/src/ICSharpCode.SharpRefactory/Makefile.am
trunk/MonoDevelop/Core/src/MonoDevelop.Base/ChangeLog
trunk/MonoDevelop/Core/src/MonoDevelop.Base/Internal/Parser/IParser.cs
trunk/MonoDevelop/Core/src/MonoDevelop.Base/Services/ParserService/DefaultParserService.cs
Log:
more minor parser related updated from SD
Modified: trunk/MonoDevelop/Core/src/AddIns/BackendBindings/CSharpBinding/ChangeLog
===================================================================
--- trunk/MonoDevelop/Core/src/AddIns/BackendBindings/CSharpBinding/ChangeLog 2005-01-28 07:20:57 UTC (rev 2184)
+++ trunk/MonoDevelop/Core/src/AddIns/BackendBindings/CSharpBinding/ChangeLog 2005-01-29 00:13:31 UTC (rev 2185)
@@ -1,3 +1,8 @@
+2005-01-28 John Luke <john.luke at gmail.com>
+
+ * Parser/Parser.cs: update to CanParse
+ * Parser/*.cs: update some minor fixes from SD
+
2005-01-27 John Luke <john.luke at gmail.com>
* CSharpBindingCompilerManager.cs:
Modified: trunk/MonoDevelop/Core/src/AddIns/BackendBindings/CSharpBinding/Makefile.am
===================================================================
--- trunk/MonoDevelop/Core/src/AddIns/BackendBindings/CSharpBinding/Makefile.am 2005-01-28 07:20:57 UTC (rev 2184)
+++ trunk/MonoDevelop/Core/src/AddIns/BackendBindings/CSharpBinding/Makefile.am 2005-01-29 00:13:31 UTC (rev 2185)
@@ -12,6 +12,7 @@
FILES = \
Gui/ChooseRuntimePanel.cs \
Gui/CodeGenerationPanel.cs \
+Parser/SharpDevelopTree/Destructor.cs \
Parser/SharpDevelopTree/Event.cs \
Parser/SharpDevelopTree/Indexer.cs \
Parser/SharpDevelopTree/Constructor.cs \
Modified: trunk/MonoDevelop/Core/src/AddIns/BackendBindings/CSharpBinding/Parser/CSharpVisitor.cs
===================================================================
--- trunk/MonoDevelop/Core/src/AddIns/BackendBindings/CSharpBinding/Parser/CSharpVisitor.cs 2005-01-28 07:20:57 UTC (rev 2184)
+++ trunk/MonoDevelop/Core/src/AddIns/BackendBindings/CSharpBinding/Parser/CSharpVisitor.cs 2005-01-29 00:13:31 UTC (rev 2185)
@@ -105,6 +105,7 @@
{
DefaultRegion region = GetRegion(typeDeclaration.StartLocation, typeDeclaration.EndLocation);
Class c = new Class(cu, TranslateClassType(typeDeclaration.Type), typeDeclaration.Modifier, region);
+
if (currentClass.Count > 0) {
Class cur = ((Class)currentClass.Peek());
cur.InnerClasses.Add(c);
@@ -160,7 +161,6 @@
{
DefaultRegion region = GetRegion(constructorDeclaration.StartLocation, constructorDeclaration.EndLocation);
DefaultRegion bodyRegion = GetRegion(constructorDeclaration.EndLocation, constructorDeclaration.Body != null ? constructorDeclaration.Body.EndLocation : new Point(-1, -1));
-
Class c = (Class)currentClass.Peek();
Constructor constructor = new Constructor(constructorDeclaration.Modifier, region, bodyRegion);
@@ -177,7 +177,19 @@
return null;
}
+ public override object Visit(AST.DestructorDeclaration destructorDeclaration, object data)
+ {
+ DefaultRegion region = GetRegion(destructorDeclaration.StartLocation, destructorDeclaration.EndLocation);
+ DefaultRegion bodyRegion = GetRegion(destructorDeclaration.EndLocation, destructorDeclaration.Body != null ? destructorDeclaration.Body.EndLocation : new Point(-1, -1));
+
+ Class c = (Class)currentClass.Peek();
+
+ Destructor destructor = new Destructor(c.Name, destructorDeclaration.Modifier, region, bodyRegion);
+ c.Methods.Add(destructor);
+ return null;
+ }
+
public override object Visit(AST.FieldDeclaration fieldDeclaration, object data)
{
DefaultRegion region = GetRegion(fieldDeclaration.StartLocation, fieldDeclaration.EndLocation);
Modified: trunk/MonoDevelop/Core/src/AddIns/BackendBindings/CSharpBinding/Parser/ExpressionFinder.cs
===================================================================
--- trunk/MonoDevelop/Core/src/AddIns/BackendBindings/CSharpBinding/Parser/ExpressionFinder.cs 2005-01-28 07:20:57 UTC (rev 2184)
+++ trunk/MonoDevelop/Core/src/AddIns/BackendBindings/CSharpBinding/Parser/ExpressionFinder.cs 2005-01-29 00:13:31 UTC (rev 2185)
@@ -41,6 +41,7 @@
this.initialOffset = offset;
StringBuilder outText = new StringBuilder();
int curOffset = 0;
+
while (curOffset <= initialOffset) {
char ch = text[curOffset];
@@ -60,13 +61,9 @@
case '\'':
outText.Append(ch);
curOffset++;
- // to read '" and '\" ... this should work for these cases
- if (curOffset <= initialOffset) {
- outText.Append(text[curOffset++]);
+ if(! ReadChar(outText, text, ref curOffset)) {
+ return null;
}
- if (curOffset <= initialOffset) {
- outText.Append(text[curOffset++]);
- }
break;
case '"':
outText.Append(ch);
@@ -114,6 +111,24 @@
return false;
}
+ bool ReadChar(StringBuilder outText, string text, ref int curOffset)
+ {
+ char first = text[curOffset];
+
+ if (curOffset <= initialOffset) {
+ outText.Append(text[curOffset++]);
+ }
+ if (curOffset <= initialOffset) {
+ outText.Append(text[curOffset++]);
+ }
+
+ // special case: '\''
+ if(first == '\\' && curOffset <= initialOffset) {
+ outText.Append(text[curOffset++]);
+ }
+ return text[curOffset - 1] == '\'';
+ }
+
bool ReadString(StringBuilder outText, string text, ref int curOffset)
{
while (curOffset <= initialOffset) {
Modified: trunk/MonoDevelop/Core/src/AddIns/BackendBindings/CSharpBinding/Parser/Parser.cs
===================================================================
--- trunk/MonoDevelop/Core/src/AddIns/BackendBindings/CSharpBinding/Parser/Parser.cs 2005-01-28 07:20:57 UTC (rev 2184)
+++ trunk/MonoDevelop/Core/src/AddIns/BackendBindings/CSharpBinding/Parser/Parser.cs 2005-01-29 00:13:31 UTC (rev 2185)
@@ -20,6 +20,9 @@
///<summary>IParser Interface</summary>
string[] lexerTags;
public string[] LexerTags {
+ get {
+ return lexerTags;
+ }
set {
lexerTags = value;
}
@@ -29,6 +32,14 @@
return new ExpressionFinder();
}
}
+ public bool CanParse(string fileName)
+ {
+ return System.IO.Path.GetExtension(fileName).ToUpper() == ".CS";
+ }
+ public bool CanParse(Project project)
+ {
+ return project.ProjectType == "C#";
+ }
void RetrieveRegions(CompilationUnit cu, SpecialTracker tracker)
{
@@ -113,13 +124,6 @@
{
return new Resolver (project).MonodocResolver (parserService, expression, caretLineNumber, caretColumn, fileName, fileContent);
}
-
-
- public bool HandlesFileExtension(string fileExtension){
- if(fileExtension == null) return false;
- return (fileExtension.ToLower() == ".cs");
- }
-
///////// IParser Interface END
}
}
Modified: trunk/MonoDevelop/Core/src/AddIns/BackendBindings/CSharpBinding/Parser/Resolver.cs
===================================================================
--- trunk/MonoDevelop/Core/src/AddIns/BackendBindings/CSharpBinding/Parser/Resolver.cs 2005-01-28 07:20:57 UTC (rev 2184)
+++ trunk/MonoDevelop/Core/src/AddIns/BackendBindings/CSharpBinding/Parser/Resolver.cs 2005-01-29 00:13:31 UTC (rev 2185)
@@ -51,6 +51,8 @@
bool showStatic = false;
+ bool inNew = false;
+
public bool ShowStatic {
get {
return showStatic;
@@ -186,6 +188,19 @@
if (expression == "") {
return null;
}
+ // disable the code completion for numbers like 3.47
+ try {
+ int.Parse(expression);
+// Console.WriteLine(expression);
+ return null;
+ } catch (Exception) {
+ }
+ if (expression.StartsWith("new ")) {
+ inNew = true;
+ expression = expression.Substring(4);
+ } else {
+ inNew = false;
+ }
if (expression.StartsWith("using ")) {
// expression[expression.Length - 1] != '.'
// the period that causes this Resove() is not part of the expression
@@ -686,7 +701,6 @@
return name;
}
if (unit == null) {
-// Console.WriteLine("done, resultless");
return null;
}
foreach (IUsing u in unit.Usings) {
@@ -697,7 +711,6 @@
}
}
}
-// Console.WriteLine("done, resultless");
return null;
}
@@ -907,7 +920,7 @@
public ArrayList CtrlSpace(IParserService parserService, int caretLine, int caretColumn, string fileName)
{
- ArrayList result = new ArrayList();
+ ArrayList result = new ArrayList(TypeReference.PrimitiveTypes);
this.parserService = parserService;
this.caretLine = caretLine;
this.caretColumn = caretColumn;
Modified: trunk/MonoDevelop/Core/src/AddIns/BackendBindings/CSharpBinding/Parser/SharpDevelopTree/Class.cs
===================================================================
--- trunk/MonoDevelop/Core/src/AddIns/BackendBindings/CSharpBinding/Parser/SharpDevelopTree/Class.cs 2005-01-28 07:20:57 UTC (rev 2184)
+++ trunk/MonoDevelop/Core/src/AddIns/BackendBindings/CSharpBinding/Parser/SharpDevelopTree/Class.cs 2005-01-29 00:13:31 UTC (rev 2185)
@@ -1,5 +1,6 @@
// created on 06.08.2003 at 12:37
+using System;
using System.Diagnostics;
using MonoDevelop.Internal.Parser;
Added: trunk/MonoDevelop/Core/src/AddIns/BackendBindings/CSharpBinding/Parser/SharpDevelopTree/Destructor.cs
===================================================================
--- trunk/MonoDevelop/Core/src/AddIns/BackendBindings/CSharpBinding/Parser/SharpDevelopTree/Destructor.cs 2005-01-28 07:20:57 UTC (rev 2184)
+++ trunk/MonoDevelop/Core/src/AddIns/BackendBindings/CSharpBinding/Parser/SharpDevelopTree/Destructor.cs 2005-01-29 00:13:31 UTC (rev 2185)
@@ -0,0 +1,22 @@
+using System;
+using MonoDevelop.Internal.Parser;
+using ICSharpCode.SharpRefactory.Parser;
+
+namespace CSharpBinding.Parser.SharpDevelopTree
+{
+ public class Destructor : AbstractMethod
+ {
+ public void AddModifier(ModifierEnum m)
+ {
+ modifiers = modifiers | m;
+ }
+
+ public Destructor(string className, Modifier m, IRegion region, IRegion bodyRegion)
+ {
+ FullyQualifiedName = "~" + className;
+ this.region = region;
+ this.bodyRegion = bodyRegion;
+ modifiers = (ModifierEnum)m;
+ }
+ }
+}
Modified: trunk/MonoDevelop/Core/src/AddIns/BackendBindings/CSharpBinding/Parser/TypeVisitor.cs
===================================================================
--- trunk/MonoDevelop/Core/src/AddIns/BackendBindings/CSharpBinding/Parser/TypeVisitor.cs 2005-01-28 07:20:57 UTC (rev 2184)
+++ trunk/MonoDevelop/Core/src/AddIns/BackendBindings/CSharpBinding/Parser/TypeVisitor.cs 2005-01-29 00:13:31 UTC (rev 2185)
@@ -23,6 +23,7 @@
public override object Visit(PrimitiveExpression primitiveExpression, object data)
{
+// Console.WriteLine("Visiting " + primitiveExpression);
if (primitiveExpression.Value != null) {
// Console.WriteLine("Visiting " + primitiveExpression.Value);
return new ReturnType(primitiveExpression.Value.GetType().FullName);
@@ -91,7 +92,13 @@
if (fieldReferenceExpression == null) {
return null;
}
-
+ // int. generates a FieldreferenceExpression with TargetObject TypeReferenceExpression and no FieldName
+ if (fieldReferenceExpression.FieldName == null || fieldReferenceExpression.FieldName == "") {
+ if (fieldReferenceExpression.TargetObject is TypeReferenceExpression) {
+ resolver.ShowStatic = true;
+ return new ReturnType(((TypeReferenceExpression)fieldReferenceExpression.TargetObject).TypeReference);
+ }
+ }
IReturnType returnType = fieldReferenceExpression.TargetObject.AcceptVisitor(this, data) as IReturnType;
if (returnType != null) {
string name = resolver.SearchNamespace(returnType.FullyQualifiedName, resolver.CompilationUnit);
@@ -129,7 +136,7 @@
public override object Visit(IdentifierExpression identifierExpression, object data)
{
- Console.WriteLine("visiting IdentifierExpression");
+ //Console.WriteLine("visiting IdentifierExpression");
if (identifierExpression == null) {
return null;
}
@@ -224,11 +231,14 @@
public override object Visit(IndexerExpression indexerExpression, object data)
{
+ //Console.WriteLine("TypeVisiting IndexerExpression");
IReturnType type = (IReturnType)indexerExpression.TargetObject.AcceptVisitor(this, data);
+ //Console.WriteLine("Type is " + type.FullyQualifiedName);
if (type == null) {
return null;
}
if (type.ArrayDimensions == null || type.ArrayDimensions.Length == 0) {
+ //Console.WriteLine("No Array, checking indexer");
// check if ther is an indexer
if (indexerExpression.TargetObject is ThisReferenceExpression) {
if (resolver.CallingClass == null) {
@@ -246,6 +256,7 @@
// TODO: what is a[0] if a is pointer to array or array of pointer ?
if (type.ArrayDimensions[type.ArrayDimensions.Length - 1] != indexerExpression.Indices.Count) {
+ //Console.WriteLine("Number of indices do not match the Array dimension");
return null;
}
int[] newArray = new int[type.ArrayDimensions.Length - 1];
Modified: trunk/MonoDevelop/Core/src/AddIns/BackendBindings/VBNetBinding/ChangeLog
===================================================================
--- trunk/MonoDevelop/Core/src/AddIns/BackendBindings/VBNetBinding/ChangeLog 2005-01-28 07:20:57 UTC (rev 2184)
+++ trunk/MonoDevelop/Core/src/AddIns/BackendBindings/VBNetBinding/ChangeLog 2005-01-29 00:13:31 UTC (rev 2185)
@@ -1,3 +1,7 @@
+2005-01-28 John Luke <john.luke at gmail.com>
+
+ * Parser/Parser.cs: update to CanParse
+
2005-01-27 John Luke <john.luke at gmail.com>
* VB.glade: update to new glade format
Modified: trunk/MonoDevelop/Core/src/AddIns/BackendBindings/VBNetBinding/Parser/Parser.cs
===================================================================
--- trunk/MonoDevelop/Core/src/AddIns/BackendBindings/VBNetBinding/Parser/Parser.cs 2005-01-28 07:20:57 UTC (rev 2184)
+++ trunk/MonoDevelop/Core/src/AddIns/BackendBindings/VBNetBinding/Parser/Parser.cs 2005-01-29 00:13:31 UTC (rev 2185)
@@ -40,6 +40,16 @@
return new ExpressionFinder();
}
}
+
+ public bool CanParse (string fileName)
+ {
+ return System.IO.Path.GetExtension (fileName).ToLower () == ".vb";
+ }
+
+ public bool CanParse (Project project)
+ {
+ return project.ProjectType == "VBNET";
+ }
void RetrieveRegions(CompilationUnit cu, SpecialTracker tracker)
{
@@ -141,11 +151,6 @@
return new Resolver (project).MonodocResolver (parserService, expression, caretLineNumber, caretColumn, fileName, fileContent);
}
-
- public bool HandlesFileExtension(string fileExtension){
- if(fileExtension == null) return false;
- return (fileExtension.ToLower() == ".vb");
- }
///////// IParser Interface END
Modified: trunk/MonoDevelop/Core/src/ICSharpCode.SharpRefactory/Makefile.am
===================================================================
--- trunk/MonoDevelop/Core/src/ICSharpCode.SharpRefactory/Makefile.am 2005-01-28 07:20:57 UTC (rev 2184)
+++ trunk/MonoDevelop/Core/src/ICSharpCode.SharpRefactory/Makefile.am 2005-01-29 00:13:31 UTC (rev 2185)
@@ -14,6 +14,7 @@
src/Lexer/Specials/Comment.cs \
src/Lexer/Specials/SpecialTracker.cs \
src/Lexer/Specials/BlankLine.cs \
+src/Lexer/Specials/TagComment.cs \
src/Parser/AST/DebugASTVisitor.cs \
src/Parser/AST/Expressions/BaseReferenceExpression.cs \
src/Parser/AST/Expressions/ParenthesizedExpression.cs \
Added: trunk/MonoDevelop/Core/src/ICSharpCode.SharpRefactory/src/Lexer/Specials/TagComment.cs
===================================================================
--- trunk/MonoDevelop/Core/src/ICSharpCode.SharpRefactory/src/Lexer/Specials/TagComment.cs 2005-01-28 07:20:57 UTC (rev 2184)
+++ trunk/MonoDevelop/Core/src/ICSharpCode.SharpRefactory/src/Lexer/Specials/TagComment.cs 2005-01-29 00:13:31 UTC (rev 2185)
@@ -0,0 +1,30 @@
+using System;
+using System.Text;
+using System.CodeDom;
+using System.Collections;
+using System.Drawing;
+
+namespace ICSharpCode.SharpRefactory.Parser
+{
+ /// <summary>
+ /// Description of TagComment.
+ /// </summary>
+ public class TagComment : Comment
+ {
+ string tag;
+
+ public string Tag {
+ get {
+ return tag;
+ }
+ set {
+ tag = value;
+ }
+ }
+
+ public TagComment(string tag, string comment, Point startPosition) : base(CommentType.SingleLine, comment, startPosition)
+ {
+ this.tag = tag;
+ }
+ }
+}
Modified: trunk/MonoDevelop/Core/src/MonoDevelop.Base/ChangeLog
===================================================================
--- trunk/MonoDevelop/Core/src/MonoDevelop.Base/ChangeLog 2005-01-28 07:20:57 UTC (rev 2184)
+++ trunk/MonoDevelop/Core/src/MonoDevelop.Base/ChangeLog 2005-01-29 00:13:31 UTC (rev 2185)
@@ -1,3 +1,9 @@
+2005-01-28 John Luke <john.luke at gmail.com>
+
+ * Services/ParserService/DefaultParserService.cs:
+ * Parser/IParser: use CanParse () instead of HandlesFileExtension
+ to be consistent with what SD did upstream
+
2005-01-27 John Luke <john.luke at gmail.com>
* Gui/Dialogs/CommonAboutDialog.cs: use a timeout
Modified: trunk/MonoDevelop/Core/src/MonoDevelop.Base/Internal/Parser/IParser.cs
===================================================================
--- trunk/MonoDevelop/Core/src/MonoDevelop.Base/Internal/Parser/IParser.cs 2005-01-28 07:20:57 UTC (rev 2184)
+++ trunk/MonoDevelop/Core/src/MonoDevelop.Base/Internal/Parser/IParser.cs 2005-01-29 00:13:31 UTC (rev 2185)
@@ -118,16 +118,19 @@
public interface IParser {
string[] LexerTags {
+ get;
set;
}
IExpressionFinder ExpressionFinder {
get;
}
+
+ bool CanParse (string fileName);
+ bool CanParse (Project_ project);
ICompilationUnitBase Parse(string fileName);
ICompilationUnitBase Parse(string fileName, string fileContent);
- bool HandlesFileExtension(string fileExtension);
/// <summary>
/// Resolves an expression.
Modified: trunk/MonoDevelop/Core/src/MonoDevelop.Base/Services/ParserService/DefaultParserService.cs
===================================================================
--- trunk/MonoDevelop/Core/src/MonoDevelop.Base/Services/ParserService/DefaultParserService.cs 2005-01-28 07:20:57 UTC (rev 2184)
+++ trunk/MonoDevelop/Core/src/MonoDevelop.Base/Services/ParserService/DefaultParserService.cs 2005-01-29 00:13:31 UTC (rev 2185)
@@ -1167,7 +1167,7 @@
// HACK: Still a hack, but extensible
if (fileName != null) {
foreach(IParser p in parser){
- if(p.HandlesFileExtension(Path.GetExtension(fileName))){
+ if(p.CanParse(Path.GetExtension(fileName))){
return p;
}
}
More information about the Monodevelop-patches-list
mailing list