Browse Source

Fixed SD2-483: TreeNode declarations are missing

git-svn-id: svn://svn.sharpdevelop.net/sharpdevelop/trunk@580 1ccf3a8d-04fe-1044-b7c0-cef0b8235c61
shortcuts
Daniel Grunwald 21 years ago
parent
commit
13237161a5
  1. 28
      src/AddIns/DisplayBindings/FormDesigner/Project/Src/FormDesigner/DesignerGenerator/CodeDOMGenerator.cs
  2. 1
      src/Main/Base/Project/Src/Gui/Pads/DefinitionViewPad.cs

28
src/AddIns/DisplayBindings/FormDesigner/Project/Src/FormDesigner/DesignerGenerator/CodeDOMGenerator.cs

@ -28,7 +28,6 @@ using Microsoft.VisualBasic;
using ICSharpCode.Core; using ICSharpCode.Core;
using ICSharpCode.FormDesigner.Services; using ICSharpCode.FormDesigner.Services;
namespace ICSharpCode.FormDesigner namespace ICSharpCode.FormDesigner
{ {
/// <summary> /// <summary>
@ -37,7 +36,7 @@ namespace ICSharpCode.FormDesigner
public class CodeDOMGenerator public class CodeDOMGenerator
{ {
IDesignerHost host; IDesignerHost host;
CodeDomProvider codeProvider; CodeDomProvider codeProvider;
CodeDOMGeneratorUtility codeDOMGeneratorUtility = new CodeDOMGeneratorUtility(); CodeDOMGeneratorUtility codeDOMGeneratorUtility = new CodeDOMGeneratorUtility();
List<string> addedVariables = new List<string>(); List<string> addedVariables = new List<string>();
@ -55,7 +54,7 @@ namespace ICSharpCode.FormDesigner
IDisposable session = serializationManager.CreateSession(); IDisposable session = serializationManager.CreateSession();
DesignerResourceService designerResourceService = (DesignerResourceService)host.GetService(typeof(System.ComponentModel.Design.IResourceService)); DesignerResourceService designerResourceService = (DesignerResourceService)host.GetService(typeof(System.ComponentModel.Design.IResourceService));
designerResourceService.SerializationStarted(true); designerResourceService.SerializationStarted(true);
addedVariables.Clear(); addedVariables.Clear();
foreach (IComponent component in host.Container.Components) { foreach (IComponent component in host.Container.Components) {
@ -77,6 +76,7 @@ namespace ICSharpCode.FormDesigner
void GenerateComponentCode(IComponent component, TextWriter writer, DesignerSerializationManager serializationManager) void GenerateComponentCode(IComponent component, TextWriter writer, DesignerSerializationManager serializationManager)
{ {
LoggingService.Debug("Generate code for: " + component.Site.Name);
Type componentType = component.GetType(); Type componentType = component.GetType();
ExpressionContext exprContext = new ExpressionContext(new CodeThisReferenceExpression(), componentType, component, component); ExpressionContext exprContext = new ExpressionContext(new CodeThisReferenceExpression(), componentType, component, component);
((IDesignerSerializationManager)serializationManager).Context.Append(exprContext); ((IDesignerSerializationManager)serializationManager).Context.Append(exprContext);
@ -96,23 +96,37 @@ namespace ICSharpCode.FormDesigner
foreach (CodeStatement statement in statements) { foreach (CodeStatement statement in statements) {
CodeVariableDeclarationStatement variableDecl = statement as CodeVariableDeclarationStatement; CodeVariableDeclarationStatement variableDecl = statement as CodeVariableDeclarationStatement;
if (variableDecl != null) { if (variableDecl != null) {
LoggingService.Debug("variable declaration: " + variableDecl.Name);
if (variableDecl.Name == "resources") { if (variableDecl.Name == "resources") {
FixResourcesVariableDeclarationStatement(variableDecl); FixResourcesVariableDeclarationStatement(variableDecl);
} else { } else {
addedVariables.Add(((CodeVariableDeclarationStatement)statement).Name); // skip generating the variable declaration if the component is a main
continue; // component that gets its own field
// TreeNode is an example that does NOT get its own root component!
bool foundComponent = false;
foreach (IComponent c in host.Container.Components) {
if (variableDecl.Name == c.Site.Name) {
foundComponent = true;
break;
}
}
if (foundComponent) {
addedVariables.Add(((CodeVariableDeclarationStatement)statement).Name);
continue;
}
} }
} }
// indentation isn't generated when calling GenerateCodeFromStatement // indentation isn't generated when calling GenerateCodeFromStatement
writer.Write(options.IndentString); writer.Write(options.IndentString);
try { try {
// outputGenerator.PublicGenerateCodeFromStatement(statement, Console.Out, options); // outputGenerator.PublicGenerateCodeFromStatement(statement, Console.Out, options);
codeProvider.GenerateCodeFromStatement(statement, writer, options); codeProvider.GenerateCodeFromStatement(statement, writer, options);
} catch (Exception e) { } catch (Exception e) {
codeProvider.GenerateCodeFromStatement(new CodeCommentStatement("TODO: Error while generating statement : " + e.Message), codeProvider.GenerateCodeFromStatement(new CodeCommentStatement("TODO: Error while generating statement : " + e.Message),
writer, writer,
options); options);
LoggingService.Error(e);
} }
} }
} }
@ -127,7 +141,7 @@ namespace ICSharpCode.FormDesigner
/// <summary> /// <summary>
/// HACK - Fix the resources variable declaration. The CodeDomSerializer /// HACK - Fix the resources variable declaration. The CodeDomSerializer
/// creates an incorrect code expression object. /// creates an incorrect code expression object.
/// </summary> /// </summary>
void FixResourcesVariableDeclarationStatement(CodeVariableDeclarationStatement variableDecl) void FixResourcesVariableDeclarationStatement(CodeVariableDeclarationStatement variableDecl)
{ {

1
src/Main/Base/Project/Src/Gui/Pads/DefinitionViewPad.cs

@ -40,6 +40,7 @@ namespace ICSharpCode.SharpDevelop.Gui
ctl.TextEditorProperties = new SharpDevelopTextEditorProperties(); ctl.TextEditorProperties = new SharpDevelopTextEditorProperties();
ctl.ActiveTextAreaControl.TextArea.DoubleClick += OnDoubleClick; ctl.ActiveTextAreaControl.TextArea.DoubleClick += OnDoubleClick;
ParserService.ParserUpdateStepFinished += UpdateTick; ParserService.ParserUpdateStepFinished += UpdateTick;
ctl.VisibleChanged += delegate { UpdateTick(null, null); };
} }
void OnDoubleClick(object sender, EventArgs e) void OnDoubleClick(object sender, EventArgs e)

Loading…
Cancel
Save