Browse Source

NRefactory bugfixes (C#: For initializers added twice and VB: Custom event regions not stored in AST)

git-svn-id: svn://svn.sharpdevelop.net/sharpdevelop/trunk@368 1ccf3a8d-04fe-1044-b7c0-cef0b8235c61
shortcuts
Daniel Grunwald 20 years ago
parent
commit
b3ec9593b8
  1. 2
      data/ConversionStyleSheets/ShowChangeLog.xsl
  2. 12
      src/AddIns/Misc/HtmlHelp2/Project/src/BrowserScheme.cs
  3. 12
      src/AddIns/Misc/HtmlHelp2/Project/src/MsHelpProvider.cs
  4. 10
      src/AddIns/Misc/MbUnitPad/Project/Configuration/AssemblyInfo.cs
  5. 3
      src/AddIns/Misc/StartPage/Project/Src/ICSharpCodePage.cs
  6. 20
      src/Libraries/NRefactory/Project/Src/Parser/AST/General/TypeLevel/EventDeclaration.cs
  7. 3
      src/Libraries/NRefactory/Project/Src/Parser/CSharp/Parser.cs
  8. 2
      src/Libraries/NRefactory/Project/Src/Parser/CSharp/cs.ATG
  9. 1529
      src/Libraries/NRefactory/Project/Src/Parser/VBNet/Parser.cs
  10. 19
      src/Libraries/NRefactory/Project/Src/Parser/VBNet/VBNET.ATG
  11. 58
      src/Libraries/NRefactory/Project/Src/Parser/Visitors/CSharpToVBNetConvertVisitor.cs
  12. 12
      src/Main/Base/Project/Src/Dom/HelpProvider.cs
  13. 1
      src/Main/Base/Project/Src/Dom/XmlDoc.cs

2
data/ConversionStyleSheets/ShowChangeLog.xsl

@ -5,7 +5,7 @@ @@ -5,7 +5,7 @@
<HTML><HEAD></HEAD><BODY>
<TABLE CLASS="dtTABLE" cellspacing="0">
<TR>
<TH align="left" class="copy">Author</TH>
<TH align="left" class="copy" width="100">Author</TH>
<TH align="left" class="copy">Date</TH>
<TH align="left" class="copy">Change</TH>
</TR>

12
src/AddIns/Misc/HtmlHelp2/Project/src/BrowserScheme.cs

@ -1,9 +1,9 @@ @@ -1,9 +1,9 @@
/*
* Created by SharpDevelop.
* User: Daniel Grunwald
* Date: 06.08.2005
* Time: 16:13
*/
// <file>
// <copyright see="prj:///doc/copyright.txt">2002-2005 AlphaSierraPapa</copyright>
// <license see="prj:///doc/license.txt">GNU General Public License</license>
// <owner name="Daniel Grunwald" email="daniel@danielgrunwald.de"/>
// <version>$Revision$</version>
// </file>
using System;
using System.Windows.Forms;

12
src/AddIns/Misc/HtmlHelp2/Project/src/MsHelpProvider.cs

@ -1,9 +1,9 @@ @@ -1,9 +1,9 @@
/*
* Created by SharpDevelop.
* User: Daniel Grunwald
* Date: 13.08.2005
* Time: 15:36
*/
// <file>
// <copyright see="prj:///doc/copyright.txt">2002-2005 AlphaSierraPapa</copyright>
// <license see="prj:///doc/license.txt">GNU General Public License</license>
// <owner name="Daniel Grunwald" email="daniel@danielgrunwald.de"/>
// <version>$Revision$</version>
// </file>
using System;
using ICSharpCode.Core;

10
src/AddIns/Misc/MbUnitPad/Project/Configuration/AssemblyInfo.cs

@ -1,4 +1,11 @@ @@ -1,4 +1,11 @@
using System.Reflection;
// <file>
// <copyright see="prj:///doc/copyright.txt">2002-2005 AlphaSierraPapa</copyright>
// <license see="prj:///doc/license.txt">GNU General Public License</license>
// <owner name="Daniel Grunwald" email="daniel@danielgrunwald.de"/>
// <version>$Revision$</version>
// </file>
using System.Reflection;
using System.Runtime.CompilerServices;
// Information about this assembly is defined by the following
@ -24,4 +31,3 @@ using System.Runtime.CompilerServices; @@ -24,4 +31,3 @@ using System.Runtime.CompilerServices;
// numbers with the '*' character (the default):
[assembly: AssemblyVersion("2.0.0.1")]

3
src/AddIns/Misc/StartPage/Project/Src/ICSharpCodePage.cs

@ -597,8 +597,9 @@ namespace ICSharpCode.StartPage @@ -597,8 +597,9 @@ namespace ICSharpCode.StartPage
transform.Load(Path.Combine(PropertyService.DataDirectory, "ConversionStyleSheets/ShowChangeLog.xsl"));
StringWriter writer = new StringWriter();
XmlTextWriter xmlWriter = new XmlTextWriter(writer);
xmlWriter.Formatting = Formatting.None;
transform.Transform(Path.Combine(FileUtility.SharpDevelopRootPath, "doc/ChangeLog.xml"), xmlWriter);
changeLogHtml = writer.ToString();
changeLogHtml = writer.ToString().Replace("\n", "\n<br>");
}
builder.Append(changeLogHtml);
} catch (Exception e) {

20
src/Libraries/NRefactory/Project/Src/Parser/AST/General/TypeLevel/EventDeclaration.cs

@ -20,8 +20,9 @@ namespace ICSharpCode.NRefactory.Parser.AST @@ -20,8 +20,9 @@ namespace ICSharpCode.NRefactory.Parser.AST
List<VariableDeclaration> variableDeclarators = new List<VariableDeclaration>(1);
// ArrayList implementsClause = new ArrayList(); // VB only
ArrayList implementsClause = new ArrayList(); // VB only
EventAddRegion addRegion = EventAddRegion.Null; // only for C#
EventRemoveRegion removeRegion = EventRemoveRegion.Null; // only for C#
EventAddRegion addRegion = EventAddRegion.Null;
EventRemoveRegion removeRegion = EventRemoveRegion.Null;
EventRaiseRegion raiseRegion = EventRaiseRegion.Null;
Point bodyStart = new Point(-1, -1);
Point bodyEnd = new Point(-1, -1);
@ -58,18 +59,31 @@ namespace ICSharpCode.NRefactory.Parser.AST @@ -58,18 +59,31 @@ namespace ICSharpCode.NRefactory.Parser.AST
removeRegion = value == null ? EventRemoveRegion.Null : value;
}
}
public EventRaiseRegion RaiseRegion {
get {
return raiseRegion;
}
set {
raiseRegion = value == null ? EventRaiseRegion.Null : value;
}
}
public bool HasAddRegion {
get {
return !addRegion.IsNull;
}
}
public bool HasRemoveRegion {
get {
return !removeRegion.IsNull;
}
}
public bool HasRaiseRegion {
get {
return !raiseRegion.IsNull;
}
}
public Point BodyStart {
get {
return bodyStart;

3
src/Libraries/NRefactory/Project/Src/Parser/CSharp/Parser.cs

@ -3990,9 +3990,6 @@ out stmt); @@ -3990,9 +3990,6 @@ out stmt);
#line 1773 "cs.ATG"
initializer.Add(stmt);
}
#line 1773 "cs.ATG"
initializer.Add(stmt);
} else SynErr(169);
}

2
src/Libraries/NRefactory/Project/Src/Parser/CSharp/cs.ATG

@ -1770,7 +1770,7 @@ ForInitializer<out ArrayList initializer> @@ -1770,7 +1770,7 @@ ForInitializer<out ArrayList initializer>
.)
=
IF (IsLocalVarDecl()) LocalVariableDecl<out stmt> (. initializer.Add(stmt);.)
| StatementExpr<out stmt> (.initializer.Add(stmt);.) { "," StatementExpr<out stmt> (. initializer.Add(stmt);.) } (. initializer.Add(stmt);.)
| StatementExpr<out stmt> (.initializer.Add(stmt);.) { "," StatementExpr<out stmt> (. initializer.Add(stmt);.) }
.
ForIterator<out ArrayList iterator>

1529
src/Libraries/NRefactory/Project/Src/Parser/VBNet/Parser.cs

File diff suppressed because it is too large Load Diff

19
src/Libraries/NRefactory/Project/Src/Parser/VBNet/VBNET.ATG

@ -1200,9 +1200,9 @@ StructureMemberDecl<Modifiers m, List<AttributeSection> attributes> @@ -1200,9 +1200,9 @@ StructureMemberDecl<Modifiers m, List<AttributeSection> attributes>
(.
m.Check(Modifier.VBCustomEvents);
EventAddRemoveRegion eventAccessorDeclaration;
EventAddRemoveRegion addHandlerAccessorDeclaration = null;
EventAddRemoveRegion removeHandlerAccessorDeclaration = null;
EventAddRemoveRegion raiseEventAccessorDeclaration = null;
EventAddRegion addHandlerAccessorDeclaration = null;
EventRemoveRegion removeHandlerAccessorDeclaration = null;
EventRaiseRegion raiseEventAccessorDeclaration = null;
ArrayList implementsClause = null;
.)
Identifier (. string customEventName = t.val; .)
@ -1214,15 +1214,15 @@ StructureMemberDecl<Modifiers m, List<AttributeSection> attributes> @@ -1214,15 +1214,15 @@ StructureMemberDecl<Modifiers m, List<AttributeSection> attributes>
(.
if(eventAccessorDeclaration is EventAddRegion)
{
addHandlerAccessorDeclaration = eventAccessorDeclaration;
addHandlerAccessorDeclaration = (EventAddRegion)eventAccessorDeclaration;
}
else if(eventAccessorDeclaration is EventRemoveRegion)
{
removeHandlerAccessorDeclaration = eventAccessorDeclaration;
removeHandlerAccessorDeclaration = (EventRemoveRegion)eventAccessorDeclaration;
}
else if(eventAccessorDeclaration is EventRaiseRegion)
{
raiseEventAccessorDeclaration = eventAccessorDeclaration;
raiseEventAccessorDeclaration = (EventRaiseRegion)eventAccessorDeclaration;
}
.)
}
@ -1233,12 +1233,12 @@ StructureMemberDecl<Modifiers m, List<AttributeSection> attributes> @@ -1233,12 +1233,12 @@ StructureMemberDecl<Modifiers m, List<AttributeSection> attributes>
Error("Need to provide AddHandler accessor.");
}
if(addHandlerAccessorDeclaration == null)
if(removeHandlerAccessorDeclaration == null)
{
Error("Need to provide RemoveHandler accessor.");
}
if(addHandlerAccessorDeclaration == null)
if(raiseEventAccessorDeclaration == null)
{
Error("Need to provide RaiseEvent accessor.");
}
@ -1246,6 +1246,9 @@ StructureMemberDecl<Modifiers m, List<AttributeSection> attributes> @@ -1246,6 +1246,9 @@ StructureMemberDecl<Modifiers m, List<AttributeSection> attributes>
EventDeclaration decl = new EventDeclaration(type, customEventName, m.Modifier, attributes);
decl.StartLocation = m.GetDeclarationLocation(startPos);
decl.EndLocation = t.EndLocation;
decl.AddRegion = addHandlerAccessorDeclaration;
decl.RemoveRegion = removeHandlerAccessorDeclaration;
decl.RaiseRegion = raiseEventAccessorDeclaration;
compilationUnit.AddChild(decl);
.)
|

58
src/Libraries/NRefactory/Project/Src/Parser/Visitors/CSharpToVBNetConvertVisitor.cs

@ -33,6 +33,22 @@ namespace ICSharpCode.NRefactory.Parser @@ -33,6 +33,22 @@ namespace ICSharpCode.NRefactory.Parser
// The following conversions should be implemented in the future:
// if (Event != null) Event(this, bla); -> RaiseEvent Event(this, bla)
bool renameConflictingFieldNames = true;
/// <summary>
/// Gets/Sets if fields that conflict with a property name should be renamed automatically by
/// prefixing them with "m_". Default is true.
/// </summary>
public bool RenameConflictingFieldNames {
get {
return renameConflictingFieldNames;
}
set {
renameConflictingFieldNames = value;
}
}
public override object Visit(BinaryOperatorExpression binaryOperatorExpression, object data)
{
if (binaryOperatorExpression.Op == BinaryOperatorType.Equality || binaryOperatorExpression.Op == BinaryOperatorType.InEquality) {
@ -83,7 +99,9 @@ namespace ICSharpCode.NRefactory.Parser @@ -83,7 +99,9 @@ namespace ICSharpCode.NRefactory.Parser
}
}
}
if (renameConflictingFieldNames) {
new PrefixFieldsVisitor(conflicts, "m_").Run(td);
}
object result = base.Visit(td, data);
ConvertForStatements();
return result;
@ -167,20 +185,22 @@ namespace ICSharpCode.NRefactory.Parser @@ -167,20 +185,22 @@ namespace ICSharpCode.NRefactory.Parser
return;
Expression end;
if (iterator.Op == AssignmentOperatorType.Subtract) {
if (condition.Op == BinaryOperatorType.GreaterThanOrEqual)
if (condition.Op == BinaryOperatorType.GreaterThanOrEqual) {
end = condition.Right;
else if (condition.Op == BinaryOperatorType.GreaterThan)
end = new BinaryOperatorExpression(condition.Right, BinaryOperatorType.Add, new PrimitiveExpression(1, "1"));
else
} else if (condition.Op == BinaryOperatorType.GreaterThan) {
end = AddInteger(condition.Right, 1);
} else {
return;
}
} else {
if (condition.Op == BinaryOperatorType.LessThanOrEqual)
if (condition.Op == BinaryOperatorType.LessThanOrEqual) {
end = condition.Right;
else if (condition.Op == BinaryOperatorType.LessThan)
end = new BinaryOperatorExpression(condition.Right, BinaryOperatorType.Subtract, new PrimitiveExpression(1, "1"));
else
} else if (condition.Op == BinaryOperatorType.LessThan) {
end = AddInteger(condition.Right, -1);
} else {
return;
}
}
Expression start;
TypeReference typeReference = null;
@ -208,9 +228,29 @@ namespace ICSharpCode.NRefactory.Parser @@ -208,9 +228,29 @@ namespace ICSharpCode.NRefactory.Parser
ForNextStatement forNextStatement = new ForNextStatement(typeReference, iteratorIdentifier.Identifier,
start, end,
(step == 1) ? null : new PrimitiveExpression(step, step.ToString(System.Globalization.CultureInfo.InvariantCulture)),
(step == 1) ? null : new PrimitiveExpression(step, step.ToString(System.Globalization.NumberFormatInfo.InvariantInfo)),
forStatement.EmbeddedStatement, null);
forStatement.Parent.Children[forStatement.Parent.Children.IndexOf(forStatement)] = forNextStatement;
}
/// <summary>
/// Returns the existing expression plus the specified integer value.
/// WARNING: This method modifies <paramref name="expr"/> and possibly returns <paramref name="expr"/>
/// again, but it might also create a new expression around <paramref name="expr"/>.
/// </summary>
public static Expression AddInteger(Expression expr, int value)
{
PrimitiveExpression pe = expr as PrimitiveExpression;
if (pe != null && pe.Value is int) {
int newVal = (int)pe.Value + value;
return new PrimitiveExpression(newVal, newVal.ToString(System.Globalization.NumberFormatInfo.InvariantInfo));
}
BinaryOperatorExpression boe = expr as BinaryOperatorExpression;
if (boe != null) {
boe.Right = AddInteger(boe.Right, value);
return boe;
}
return new BinaryOperatorExpression(expr, BinaryOperatorType.Add, new PrimitiveExpression(value, value.ToString(System.Globalization.NumberFormatInfo.InvariantInfo)));
}
}
}

12
src/Main/Base/Project/Src/Dom/HelpProvider.cs

@ -1,9 +1,9 @@ @@ -1,9 +1,9 @@
/*
* Created by SharpDevelop.
* User: Daniel Grunwald
* Date: 13.08.2005
* Time: 15:14
*/
// <file>
// <copyright see="prj:///doc/copyright.txt">2002-2005 AlphaSierraPapa</copyright>
// <license see="prj:///doc/license.txt">GNU General Public License</license>
// <owner name="Daniel Grunwald" email="daniel@danielgrunwald.de"/>
// <version>$Revision$</version>
// </file>
using System;
using System.Collections;

1
src/Main/Base/Project/Src/Dom/XmlDoc.cs

@ -153,7 +153,6 @@ namespace ICSharpCode.SharpDevelop.Dom @@ -153,7 +153,6 @@ namespace ICSharpCode.SharpDevelop.Dom
public void Dispose()
{
LoggingService.Debug("Disposing XmlDoc object");
if (loader != null) {
loader.Close();
fs.Close();

Loading…
Cancel
Save