Browse Source

Fixed SD2-1625 - Forms Designer corrupts field declarations with inner class type references

git-svn-id: svn://svn.sharpdevelop.net/sharpdevelop/branches/3.0@5300 1ccf3a8d-04fe-1044-b7c0-cef0b8235c61
pull/1/head
Daniel Grunwald 16 years ago
parent
commit
0824719cc9
  1. 29
      src/AddIns/DisplayBindings/FormsDesigner/Project/Src/DesignerLoader/NRefactoryDesignerLoader.cs
  2. 3
      src/Libraries/NRefactory/Project/Src/Visitors/CodeDOMOutputVisitor.cs
  3. 8
      src/Main/ICSharpCode.SharpDevelop.Dom/Project/Src/Refactoring/CodeGenerator.cs

29
src/AddIns/DisplayBindings/FormsDesigner/Project/Src/DesignerLoader/NRefactoryDesignerLoader.cs

@ -19,6 +19,7 @@ using ICSharpCode.NRefactory.Ast; @@ -19,6 +19,7 @@ using ICSharpCode.NRefactory.Ast;
using ICSharpCode.NRefactory.Visitors;
using ICSharpCode.SharpDevelop;
using ICSharpCode.SharpDevelop.Dom;
using ReturnTypeOptions = ICSharpCode.SharpDevelop.Dom.NRefactoryResolver.TypeVisitor.ReturnTypeOptions;
namespace ICSharpCode.FormsDesigner
{
@ -213,8 +214,8 @@ namespace ICSharpCode.FormsDesigner @@ -213,8 +214,8 @@ namespace ICSharpCode.FormsDesigner
}
TypeDeclaration typeDecl = o as TypeDeclaration;
if (typeDecl != null) {
foreach (TypeReference tref in typeDecl.BaseTypes) {
FixTypeReference(tref, typeDecl.StartLocation, domCu);
for (int i = 0; i < typeDecl.BaseTypes.Count; i++) {
typeDecl.BaseTypes[i] = FixTypeReference(typeDecl.BaseTypes[i], typeDecl.StartLocation, domCu, ReturnTypeOptions.BaseTypeReference);
}
for (int i = 0; i < typeDecl.Children.Count; i++) {
object child = typeDecl.Children[i];
@ -242,28 +243,26 @@ namespace ICSharpCode.FormsDesigner @@ -242,28 +243,26 @@ namespace ICSharpCode.FormsDesigner
}
FieldDeclaration fieldDecl = o as FieldDeclaration;
if (fieldDecl != null) {
FixTypeReference(fieldDecl.TypeReference, fieldDecl.StartLocation, domCu);
fieldDecl.TypeReference = FixTypeReference(fieldDecl.TypeReference, fieldDecl.StartLocation, domCu, ReturnTypeOptions.None);
foreach (VariableDeclaration var in fieldDecl.Fields) {
if (var != null) {
FixTypeReference(var.TypeReference, fieldDecl.StartLocation, domCu);
var.TypeReference = FixTypeReference(var.TypeReference, fieldDecl.StartLocation, domCu, ReturnTypeOptions.None);
}
}
}
}
void FixTypeReference(TypeReference type, Location location, ICSharpCode.SharpDevelop.Dom.ICompilationUnit domCu)
TypeReference FixTypeReference(TypeReference type, Location location, ICompilationUnit domCu, ReturnTypeOptions options)
{
if (type == null)
return;
if (type.Type != type.Type)
return;
foreach (TypeReference tref in type.GenericTypes) {
FixTypeReference(tref, location, domCu);
}
if (type == null || type.IsKeyword)
return type;
ICSharpCode.SharpDevelop.Dom.IClass curType = domCu.GetInnermostClass(location.Y, location.X);
ICSharpCode.SharpDevelop.Dom.IReturnType rt = domCu.ProjectContent.SearchType(new SearchTypeRequest(type.Type, type.GenericTypes.Count, curType, domCu, location.Y, location.X)).Result;
if (rt != null) {
type.Type = rt.FullyQualifiedName;
IReturnType rt = SharpDevelop.Dom.NRefactoryResolver.TypeVisitor.CreateReturnType(
type, curType, null, location.Y, location.X, domCu.ProjectContent, options);
if (rt != null && rt.GetUnderlyingClass() != null) {
return SharpDevelop.Dom.Refactoring.CodeGenerator.ConvertType(rt, null);
} else {
return type;
}
}

3
src/Libraries/NRefactory/Project/Src/Visitors/CodeDOMOutputVisitor.cs

@ -98,9 +98,6 @@ namespace ICSharpCode.NRefactory.Visitors @@ -98,9 +98,6 @@ namespace ICSharpCode.NRefactory.Visitors
if (type == null) {
throw new ArgumentNullException("type");
}
if (string.IsNullOrEmpty(type.Type)) {
throw new InvalidOperationException("empty type");
}
CodeTypeReference t = new CodeTypeReference(GetDotNetNameFromTypeReference(type));
InnerClassTypeReference ictr = type as InnerClassTypeReference;

8
src/Main/ICSharpCode.SharpDevelop.Dom/Project/Src/Refactoring/CodeGenerator.cs

@ -72,8 +72,12 @@ namespace ICSharpCode.SharpDevelop.Dom.Refactoring @@ -72,8 +72,12 @@ namespace ICSharpCode.SharpDevelop.Dom.Refactoring
typeRef = new TypeReference(returnType.FullyQualifiedName, true);
else if (context != null && CanUseShortTypeName(returnType, context))
typeRef = new TypeReference(returnType.Name);
else
typeRef = new TypeReference(returnType.FullyQualifiedName);
else {
string fullName = returnType.FullyQualifiedName;
if (string.IsNullOrEmpty(fullName))
fullName = returnType.Name;
typeRef = new TypeReference(fullName);
}
foreach (IReturnType typeArgument in typeArguments) {
typeRef.GenericTypes.Add(ConvertType(typeArgument, context));
}

Loading…
Cancel
Save