Browse Source

Fixed interface code generator for user defined interfaces.

git-svn-id: svn://svn.sharpdevelop.net/sharpdevelop/trunk@558 1ccf3a8d-04fe-1044-b7c0-cef0b8235c61
shortcuts
Daniel Grunwald 21 years ago
parent
commit
6bd45d019d
  1. 4
      src/Main/Base/Project/Src/Dom/NRefactoryResolver/NRefactoryASTConvertVisitor.cs
  2. 2
      src/Main/Base/Project/Src/Services/ParserService/ProjectContentRegistry.cs
  3. 1
      src/Main/Base/Project/Src/TextEditor/Commands/CodeGenerators/AbstractClassImplementorCodeGenerator.cs
  4. 10
      src/Main/Base/Project/Src/TextEditor/Commands/CodeGenerators/InterfaceImplementorCodeGenerator.cs
  5. BIN
      src/Main/StartUp/Project/Resources/StringResources.resources

4
src/Main/Base/Project/Src/Dom/NRefactoryResolver/NRefactoryASTConvertVisitor.cs

@ -520,11 +520,11 @@ namespace ICSharpCode.SharpDevelop.Dom.NRefactoryResolver
DefaultClass c = GetCurrentClass(); DefaultClass c = GetCurrentClass();
DefaultProperty property = new DefaultProperty(propertyDeclaration.Name, type, ConvertModifier(propertyDeclaration.Modifier), region, bodyRegion, GetCurrentClass()); DefaultProperty property = new DefaultProperty(propertyDeclaration.Name, type, ConvertModifier(propertyDeclaration.Modifier), region, bodyRegion, GetCurrentClass());
if (propertyDeclaration.GetRegion != null) { if (propertyDeclaration.HasGetRegion) {
property.GetterRegion = GetRegion(propertyDeclaration.GetRegion.StartLocation, propertyDeclaration.GetRegion.EndLocation); property.GetterRegion = GetRegion(propertyDeclaration.GetRegion.StartLocation, propertyDeclaration.GetRegion.EndLocation);
property.CanGet = true; property.CanGet = true;
} }
if (propertyDeclaration.SetRegion != null) { if (propertyDeclaration.HasSetRegion) {
property.SetterRegion = GetRegion(propertyDeclaration.SetRegion.StartLocation, propertyDeclaration.SetRegion.EndLocation); property.SetterRegion = GetRegion(propertyDeclaration.SetRegion.StartLocation, propertyDeclaration.SetRegion.EndLocation);
property.CanSet = true; property.CanSet = true;
} }

2
src/Main/Base/Project/Src/Services/ParserService/ProjectContentRegistry.cs

@ -160,7 +160,7 @@ namespace ICSharpCode.Core
database = loader.LoadAndCreateDatabase(filename, include); database = loader.LoadAndCreateDatabase(filename, include);
} catch (Exception e) { } catch (Exception e) {
database = null; database = null;
MessageService.ShowError(e); MessageService.ShowError(e, "Error loading " + include + " from " + filename);
} finally { } finally {
AppDomain.Unload(domain); AppDomain.Unload(domain);
} }

1
src/Main/Base/Project/Src/TextEditor/Commands/CodeGenerators/AbstractClassImplementorCodeGenerator.cs

@ -31,6 +31,7 @@ namespace ICSharpCode.SharpDevelop.DefaultEditor.Commands
public AbstractClassImplementorCodeGenerator(IClass currentClass) : base(currentClass) public AbstractClassImplementorCodeGenerator(IClass currentClass) : base(currentClass)
{ {
base.useOverrideKeyword = true; base.useOverrideKeyword = true;
base.implementOnlyAbstractMembers = true;
for (int i = 0; i < currentClass.BaseTypes.Count; i++) { for (int i = 0; i < currentClass.BaseTypes.Count; i++) {
IReturnType baseType = currentClass.GetBaseType(i); IReturnType baseType = currentClass.GetBaseType(i);
IClass baseClass = (baseType != null) ? baseType.GetUnderlyingClass() : null; IClass baseClass = (baseType != null) ? baseType.GetUnderlyingClass() : null;

10
src/Main/Base/Project/Src/TextEditor/Commands/CodeGenerators/InterfaceImplementorCodeGenerator.cs

@ -56,6 +56,7 @@ namespace ICSharpCode.SharpDevelop.DefaultEditor.Commands
} }
protected bool useOverrideKeyword = false; protected bool useOverrideKeyword = false;
protected bool implementOnlyAbstractMembers = false;
void GenerateInterface(IReturnType intf, string fileExtension) void GenerateInterface(IReturnType intf, string fileExtension)
{ {
@ -64,7 +65,7 @@ namespace ICSharpCode.SharpDevelop.DefaultEditor.Commands
editActionHandler.InsertString("#region " + intf.FullyQualifiedName + " interface implementation\n\t\t");++numOps; editActionHandler.InsertString("#region " + intf.FullyQualifiedName + " interface implementation\n\t\t");++numOps;
foreach (IProperty property in intf.GetProperties()) { foreach (IProperty property in intf.GetProperties()) {
if (!property.IsAbstract) { if (implementOnlyAbstractMembers && !property.IsAbstract) {
continue; continue;
} }
string returnType = (fileExtension == ".vb" ? vba : csa).Convert(property.ReturnType); string returnType = (fileExtension == ".vb" ? vba : csa).Convert(property.ReturnType);
@ -137,6 +138,8 @@ namespace ICSharpCode.SharpDevelop.DefaultEditor.Commands
if (fileExtension == ".vb") { if (fileExtension == ".vb") {
editActionHandler.InsertString("\tSet");++numOps; editActionHandler.InsertString("\tSet");++numOps;
Return(); Return();
editActionHandler.InsertString("Throw New NotImplementedException()");++numOps;
Return();
editActionHandler.InsertString("\tEnd Set");++numOps; editActionHandler.InsertString("\tEnd Set");++numOps;
Return(); Return();
} else { } else {
@ -147,7 +150,8 @@ namespace ICSharpCode.SharpDevelop.DefaultEditor.Commands
Return(); Return();
editActionHandler.InsertString("{");++numOps; editActionHandler.InsertString("{");++numOps;
} }
Return();
editActionHandler.InsertString("throw new NotImplementedException();");++numOps;
Return(); Return();
editActionHandler.InsertString("\t}");++numOps; editActionHandler.InsertString("\t}");++numOps;
Return(); Return();
@ -168,7 +172,7 @@ namespace ICSharpCode.SharpDevelop.DefaultEditor.Commands
foreach (IMethod method in intf.GetMethods()) { foreach (IMethod method in intf.GetMethods()) {
string parameters = String.Empty; string parameters = String.Empty;
string returnType = (fileExtension == ".vb" ? vba : csa).Convert(method.ReturnType); string returnType = (fileExtension == ".vb" ? vba : csa).Convert(method.ReturnType);
if (!method.IsAbstract) { if (implementOnlyAbstractMembers && !method.IsAbstract) {
continue; continue;
} }
for (int j = 0; j < method.Parameters.Count; ++j) { for (int j = 0; j < method.Parameters.Count; ++j) {

BIN
src/Main/StartUp/Project/Resources/StringResources.resources

Binary file not shown.
Loading…
Cancel
Save