20 changed files with 688 additions and 114 deletions
@ -0,0 +1,139 @@ |
|||||||
|
// Copyright (c) AlphaSierraPapa for the SharpDevelop Team (for details please see \doc\copyright.txt)
|
||||||
|
// This code is distributed under the GNU LGPL (for details please see \doc\license.txt)
|
||||||
|
|
||||||
|
using System; |
||||||
|
using System.CodeDom; |
||||||
|
using System.CodeDom.Compiler; |
||||||
|
using System.Diagnostics; |
||||||
|
using System.Linq; |
||||||
|
using System.Windows.Forms; |
||||||
|
using ICSharpCode.Core; |
||||||
|
using ICSharpCode.FormsDesigner; |
||||||
|
using ICSharpCode.NRefactory.CSharp; |
||||||
|
using ICSharpCode.NRefactory.CSharp.Resolver; |
||||||
|
using ICSharpCode.NRefactory.Editor; |
||||||
|
using ICSharpCode.NRefactory.TypeSystem; |
||||||
|
using ICSharpCode.SharpDevelop; |
||||||
|
using Microsoft.CSharp; |
||||||
|
using CSharpBinding.Parser; |
||||||
|
|
||||||
|
namespace CSharpBinding.FormsDesigner |
||||||
|
{ |
||||||
|
public class CSharpDesignerLoader : AbstractCodeDomDesignerLoader |
||||||
|
{ |
||||||
|
readonly CodeDomProvider codeDomProvider = new CSharpCodeProvider(); |
||||||
|
readonly ICSharpDesignerLoaderContext context; |
||||||
|
|
||||||
|
public CSharpDesignerLoader(ICSharpDesignerLoaderContext context) |
||||||
|
{ |
||||||
|
this.context = context; |
||||||
|
} |
||||||
|
|
||||||
|
protected override void Write(CodeCompileUnit unit) |
||||||
|
{ |
||||||
|
throw new NotImplementedException(); |
||||||
|
} |
||||||
|
|
||||||
|
protected override CodeDomProvider CodeDomProvider { |
||||||
|
get { |
||||||
|
return codeDomProvider; |
||||||
|
} |
||||||
|
} |
||||||
|
|
||||||
|
ITextSourceVersion lastTextContentVersion; |
||||||
|
|
||||||
|
protected override bool IsReloadNeeded() |
||||||
|
{ |
||||||
|
return base.IsReloadNeeded() || context.DesignerCodeFileDocument.Version.Equals(lastTextContentVersion); |
||||||
|
} |
||||||
|
|
||||||
|
IUnresolvedTypeDefinition primaryPart; |
||||||
|
|
||||||
|
// Steps to load the designer:
|
||||||
|
// - Parse main file
|
||||||
|
// - Find other files containing parts of the form
|
||||||
|
// - Parse all files and look for fields (for controls) and InitializeComponents method
|
||||||
|
// - Create CodeDom objects for fields and InitializeComponents statements
|
||||||
|
// - If debug build and Ctrl pressed, output CodeDom to console
|
||||||
|
// - Return CodeDom objects to the .NET designer
|
||||||
|
protected override CodeCompileUnit Parse() |
||||||
|
{ |
||||||
|
SD.Log.Debug("CSharpDesignerLoader.Parse()"); |
||||||
|
|
||||||
|
lastTextContentVersion = context.DesignerCodeFileDocument.Version; |
||||||
|
var primaryParseInfo = context.GetPrimaryFileParseInformation(); |
||||||
|
var compilation = context.GetCompilation(); |
||||||
|
|
||||||
|
// Find designer class
|
||||||
|
ITypeDefinition designerClass = null; |
||||||
|
IMethod initializeComponents = null; |
||||||
|
foreach (var utd in primaryParseInfo.UnresolvedFile.TopLevelTypeDefinitions) { |
||||||
|
var td = utd.Resolve(new SimpleTypeResolveContext(compilation.MainAssembly)).GetDefinition(); |
||||||
|
if (td != null && FormsDesignerSecondaryDisplayBinding.IsDesignable(td)) { |
||||||
|
primaryPart = utd; |
||||||
|
designerClass = td; |
||||||
|
initializeComponents = FormsDesignerSecondaryDisplayBinding.GetInitializeComponents(td); |
||||||
|
break; |
||||||
|
} |
||||||
|
} |
||||||
|
|
||||||
|
if (initializeComponents == null) { |
||||||
|
throw new FormsDesignerLoadException("The InitializeComponent method was not found. Designer cannot be loaded."); |
||||||
|
} |
||||||
|
Debug.Assert(primaryPart != null); |
||||||
|
Debug.Assert(designerClass != null); |
||||||
|
|
||||||
|
bool isFirstClassInFile = primaryParseInfo.UnresolvedFile.TopLevelTypeDefinitions[0] == primaryPart; |
||||||
|
|
||||||
|
// TODO: translate
|
||||||
|
const string missingReferenceMessage = "Your project is missing a reference to '${Name}' - please add it using 'Project > Add Reference'."; |
||||||
|
if (compilation.FindType(typeof(System.Drawing.Point)).Kind == TypeKind.Unknown) { |
||||||
|
throw new FormsDesignerLoadException(StringParser.Parse(missingReferenceMessage, new StringTagPair("Name", "System.Drawing"))); |
||||||
|
} |
||||||
|
if (compilation.FindType(typeof(System.Windows.Forms.Form)).Kind == TypeKind.Unknown) { |
||||||
|
throw new FormsDesignerLoadException(StringParser.Parse(missingReferenceMessage, new StringTagPair("Name" , "System.Windows.Forms"))); |
||||||
|
} |
||||||
|
|
||||||
|
CodeDomConvertVisitor cv = new CodeDomConvertVisitor(); |
||||||
|
cv.UseFullyQualifiedTypeNames = true; |
||||||
|
|
||||||
|
CSharpFullParseInformation designerParseInfo; |
||||||
|
MethodDeclaration initializeComponentsDeclaration = initializeComponents.GetDeclaration(out designerParseInfo) as MethodDeclaration; |
||||||
|
if (initializeComponentsDeclaration == null) |
||||||
|
throw new FormsDesignerLoadException("Could not find source code for InitializeComponents"); |
||||||
|
var resolver = designerParseInfo.GetResolver(compilation); |
||||||
|
var codeMethod = (CodeMemberMethod) cv.Convert(initializeComponentsDeclaration, resolver); |
||||||
|
var codeClass = new CodeTypeDeclaration(designerClass.Name); |
||||||
|
codeClass.Attributes = MemberAttributes.Public; |
||||||
|
codeClass.BaseTypes.AddRange(designerClass.DirectBaseTypes.Select(cv.Convert).ToArray()); |
||||||
|
codeClass.Members.Add(codeMethod); |
||||||
|
|
||||||
|
foreach (var field in designerClass.Fields) { |
||||||
|
var codeField = new CodeMemberField(cv.Convert(field.Type), field.Name); |
||||||
|
codeClass.Members.Add(codeField); |
||||||
|
} |
||||||
|
var codeNamespace = new CodeNamespace(designerClass.Namespace); |
||||||
|
codeNamespace.Types.Add(codeClass); |
||||||
|
var codeUnit = new CodeCompileUnit(); |
||||||
|
codeUnit.Namespaces.Add(codeNamespace); |
||||||
|
|
||||||
|
// output generated CodeDOM to the console :
|
||||||
|
#if DEBUG
|
||||||
|
if ((Control.ModifierKeys & Keys.Control) == Keys.Control) { |
||||||
|
CodeDomVerboseOutputGenerator outputGenerator = new CodeDomVerboseOutputGenerator(); |
||||||
|
outputGenerator.GenerateCodeFromMember(codeMethod, Console.Out, null); |
||||||
|
this.CodeDomProvider.GenerateCodeFromCompileUnit(codeUnit, Console.Out, null); |
||||||
|
} |
||||||
|
#endif
|
||||||
|
|
||||||
|
LoggingService.Debug("NRefactoryDesignerLoader.Parse() finished"); |
||||||
|
|
||||||
|
if (!isFirstClassInFile) { |
||||||
|
MessageService.ShowWarning("The form must be the first class in the file in order for form resources be compiled correctly.\n" + |
||||||
|
"Please move other classes below the form class definition or move them to other files."); |
||||||
|
} |
||||||
|
|
||||||
|
return codeUnit; |
||||||
|
} |
||||||
|
} |
||||||
|
} |
@ -0,0 +1,47 @@ |
|||||||
|
// Copyright (c) AlphaSierraPapa for the SharpDevelop Team (for details please see \doc\copyright.txt)
|
||||||
|
// This code is distributed under the GNU LGPL (for details please see \doc\license.txt)
|
||||||
|
|
||||||
|
using System; |
||||||
|
using System.Collections.Generic; |
||||||
|
using System.ComponentModel.Design.Serialization; |
||||||
|
using System.Linq; |
||||||
|
using ICSharpCode.FormsDesigner; |
||||||
|
using ICSharpCode.NRefactory.TypeSystem; |
||||||
|
using ICSharpCode.SharpDevelop; |
||||||
|
using ICSharpCode.SharpDevelop.Workbench; |
||||||
|
using CSharpBinding.Parser; |
||||||
|
|
||||||
|
namespace CSharpBinding.FormsDesigner |
||||||
|
{ |
||||||
|
public class CSharpDesignerLoaderProvider : IDesignerLoaderProvider |
||||||
|
{ |
||||||
|
public DesignerLoader CreateLoader(FormsDesignerViewContent viewContent) |
||||||
|
{ |
||||||
|
return new CSharpDesignerLoader(new CSharpFormsDesignerLoaderContext(viewContent)); |
||||||
|
} |
||||||
|
|
||||||
|
public IReadOnlyList<OpenedFile> GetSourceFiles(FormsDesignerViewContent viewContent, out OpenedFile designerCodeFile) |
||||||
|
{ |
||||||
|
// get new initialize components
|
||||||
|
var parsedFile = SD.ParserService.ParseFile(viewContent.PrimaryFileName, viewContent.PrimaryFileContent); |
||||||
|
var compilation = SD.ParserService.GetCompilationForFile(viewContent.PrimaryFileName); |
||||||
|
foreach (var utd in parsedFile.TopLevelTypeDefinitions) { |
||||||
|
var td = utd.Resolve(new SimpleTypeResolveContext(compilation.MainAssembly)).GetDefinition(); |
||||||
|
if (FormsDesignerSecondaryDisplayBinding.IsDesignable(td)) { |
||||||
|
var initializeComponents = FormsDesignerSecondaryDisplayBinding.GetInitializeComponents(td); |
||||||
|
if (initializeComponents != null) { |
||||||
|
string designerFileName = initializeComponents.Region.FileName; |
||||||
|
if (designerFileName != null) { |
||||||
|
designerCodeFile = SD.FileService.GetOrCreateOpenedFile(designerFileName); |
||||||
|
return td.Parts |
||||||
|
.Select(p => SD.FileService.GetOrCreateOpenedFile(p.UnresolvedFile.FileName)) |
||||||
|
.Distinct().ToList(); |
||||||
|
} |
||||||
|
} |
||||||
|
} |
||||||
|
} |
||||||
|
|
||||||
|
throw new FormsDesignerLoadException("Could not find InitializeComponent method in any part of the open class."); |
||||||
|
} |
||||||
|
} |
||||||
|
} |
@ -0,0 +1,47 @@ |
|||||||
|
// Copyright (c) AlphaSierraPapa for the SharpDevelop Team (for details please see \doc\copyright.txt)
|
||||||
|
// This code is distributed under the GNU LGPL (for details please see \doc\license.txt)
|
||||||
|
|
||||||
|
using System; |
||||||
|
using ICSharpCode.FormsDesigner; |
||||||
|
using ICSharpCode.NRefactory.Editor; |
||||||
|
using ICSharpCode.NRefactory.TypeSystem; |
||||||
|
using ICSharpCode.SharpDevelop; |
||||||
|
using CSharpBinding.Parser; |
||||||
|
|
||||||
|
namespace CSharpBinding.FormsDesigner |
||||||
|
{ |
||||||
|
class CSharpFormsDesignerLoaderContext : ICSharpDesignerLoaderContext |
||||||
|
{ |
||||||
|
readonly FormsDesignerViewContent viewContent; |
||||||
|
|
||||||
|
public CSharpFormsDesignerLoaderContext(FormsDesignerViewContent viewContent) |
||||||
|
{ |
||||||
|
this.viewContent = viewContent; |
||||||
|
} |
||||||
|
|
||||||
|
public IDocument PrimaryFileDocument { |
||||||
|
get { |
||||||
|
return viewContent.PrimaryFileDocument; |
||||||
|
} |
||||||
|
} |
||||||
|
|
||||||
|
public IDocument DesignerCodeFileDocument { |
||||||
|
get { |
||||||
|
return viewContent.DesignerCodeFileDocument; |
||||||
|
} |
||||||
|
} |
||||||
|
|
||||||
|
public CSharpFullParseInformation GetPrimaryFileParseInformation() |
||||||
|
{ |
||||||
|
return SD.ParserService.Parse(viewContent.PrimaryFileName, viewContent.PrimaryFileDocument) |
||||||
|
as CSharpFullParseInformation; |
||||||
|
} |
||||||
|
|
||||||
|
public ICompilation GetCompilation() |
||||||
|
{ |
||||||
|
return SD.ParserService.GetCompilationForFile(viewContent.PrimaryFileName); |
||||||
|
} |
||||||
|
} |
||||||
|
} |
||||||
|
|
||||||
|
|
@ -0,0 +1,21 @@ |
|||||||
|
// Copyright (c) AlphaSierraPapa for the SharpDevelop Team (for details please see \doc\copyright.txt)
|
||||||
|
// This code is distributed under the GNU LGPL (for details please see \doc\license.txt)
|
||||||
|
|
||||||
|
using System; |
||||||
|
using ICSharpCode.NRefactory.Editor; |
||||||
|
using ICSharpCode.NRefactory.TypeSystem; |
||||||
|
using CSharpBinding.Parser; |
||||||
|
|
||||||
|
namespace CSharpBinding.FormsDesigner |
||||||
|
{ |
||||||
|
/// <summary>
|
||||||
|
/// Description of ICSharpDesignerLoaderContext.
|
||||||
|
/// </summary>
|
||||||
|
public interface ICSharpDesignerLoaderContext |
||||||
|
{ |
||||||
|
//IDocument PrimaryFileDocument { get; }
|
||||||
|
IDocument DesignerCodeFileDocument { get; } |
||||||
|
CSharpFullParseInformation GetPrimaryFileParseInformation(); |
||||||
|
ICompilation GetCompilation(); |
||||||
|
} |
||||||
|
} |
@ -0,0 +1,356 @@ |
|||||||
|
// Copyright (c) AlphaSierraPapa for the SharpDevelop Team (for details please see \doc\copyright.txt)
|
||||||
|
// This code is distributed under the GNU LGPL (for details please see \doc\license.txt)
|
||||||
|
|
||||||
|
using System; |
||||||
|
using System.CodeDom; |
||||||
|
using System.CodeDom.Compiler; |
||||||
|
using System.IO; |
||||||
|
using System.Security.Permissions; |
||||||
|
|
||||||
|
namespace ICSharpCode.FormsDesigner |
||||||
|
{ |
||||||
|
[PermissionSet(SecurityAction.InheritanceDemand, Name = "FullTrust")] |
||||||
|
[PermissionSet(SecurityAction.LinkDemand, Name = "FullTrust")] |
||||||
|
public class CodeDomVerboseOutputGenerator : System.CodeDom.Compiler.CodeGenerator |
||||||
|
{ |
||||||
|
#region System.CodeDom.Compiler.CodeGenerator abstract class implementation
|
||||||
|
protected override string NullToken { |
||||||
|
get { |
||||||
|
return "[NULL]"; |
||||||
|
} |
||||||
|
} |
||||||
|
|
||||||
|
protected override void OutputType(CodeTypeReference typeRef) |
||||||
|
{ |
||||||
|
Output.Write("[CodeTypeReference: {0}", typeRef.BaseType); |
||||||
|
if (typeRef.ArrayRank > 0) { |
||||||
|
Output.Write(" Rank:" + typeRef.ArrayRank); |
||||||
|
} |
||||||
|
Output.Write("]"); |
||||||
|
} |
||||||
|
|
||||||
|
protected override void GenerateArrayCreateExpression(CodeArrayCreateExpression e) |
||||||
|
{ |
||||||
|
Output.Write("[CodeArrayCreateExpression: {0}]", e.ToString()); |
||||||
|
} |
||||||
|
|
||||||
|
protected override void GenerateBaseReferenceExpression(CodeBaseReferenceExpression e) |
||||||
|
{ |
||||||
|
Output.Write("[CodeBaseReferenceExpression: {0}]", e.ToString()); |
||||||
|
} |
||||||
|
|
||||||
|
protected override void GenerateCastExpression(CodeCastExpression e) |
||||||
|
{ |
||||||
|
Output.Write("[CodeCastExpression: {0}]", e.ToString()); |
||||||
|
} |
||||||
|
|
||||||
|
protected override void GenerateDelegateCreateExpression(CodeDelegateCreateExpression e) |
||||||
|
{ |
||||||
|
Output.Write("[CodeDelegateCreateExpression: {0}]", e.ToString()); |
||||||
|
} |
||||||
|
|
||||||
|
protected override void GenerateFieldReferenceExpression(CodeFieldReferenceExpression e) |
||||||
|
{ |
||||||
|
Output.Write("[CodeFieldReferenceExpression: Name={0}, Target=", e.FieldName); |
||||||
|
this.GenerateExpression(e.TargetObject); |
||||||
|
Output.Write("]"); |
||||||
|
} |
||||||
|
|
||||||
|
protected override void GenerateMethodReferenceExpression(CodeMethodReferenceExpression e) |
||||||
|
{ |
||||||
|
Output.Write("[CodeMethodReferenceExpression: Name={0}, Target=", e.MethodName); |
||||||
|
this.GenerateExpression(e.TargetObject); |
||||||
|
Output.Write("]"); |
||||||
|
} |
||||||
|
|
||||||
|
protected override void GenerateEventReferenceExpression(CodeEventReferenceExpression e) |
||||||
|
{ |
||||||
|
Output.Write("[CodeEventReferenceExpression: Name={0}, Target=", e.EventName); |
||||||
|
this.GenerateExpression(e.TargetObject); |
||||||
|
Output.Write("]"); |
||||||
|
} |
||||||
|
|
||||||
|
protected override void GenerateArgumentReferenceExpression(CodeArgumentReferenceExpression e) |
||||||
|
{ |
||||||
|
Output.Write("[CodeArgumentReferenceExpression: {0}]", e.ToString()); |
||||||
|
} |
||||||
|
|
||||||
|
protected override void GenerateVariableReferenceExpression(CodeVariableReferenceExpression e) |
||||||
|
{ |
||||||
|
Output.Write("[CodeVariableReferenceExpression: Name={0}]", e.VariableName); |
||||||
|
} |
||||||
|
|
||||||
|
protected override void GenerateIndexerExpression(CodeIndexerExpression e) |
||||||
|
{ |
||||||
|
Output.Write("[CodeIndexerExpression: {0}]", e.ToString()); |
||||||
|
} |
||||||
|
|
||||||
|
protected override void GenerateArrayIndexerExpression(CodeArrayIndexerExpression e) |
||||||
|
{ |
||||||
|
Output.Write("[CodeArrayIndexerExpression: {0}]", e.ToString()); |
||||||
|
} |
||||||
|
|
||||||
|
protected override void GenerateSnippetExpression(CodeSnippetExpression e) |
||||||
|
{ |
||||||
|
Output.Write("[CodeSnippetExpression: {0}]", e.ToString()); |
||||||
|
} |
||||||
|
|
||||||
|
protected override void GenerateMethodInvokeExpression(CodeMethodInvokeExpression e) |
||||||
|
{ |
||||||
|
Output.Write("[CodeMethodInvokeExpression: Method="); |
||||||
|
GenerateMethodReferenceExpression(e.Method); |
||||||
|
Output.Write(", Parameters="); |
||||||
|
bool first = true; |
||||||
|
foreach (CodeExpression expr in e.Parameters) { |
||||||
|
if (first) first = false; else Output.Write(", "); |
||||||
|
this.GenerateExpression(expr); |
||||||
|
} |
||||||
|
Output.Write("]"); |
||||||
|
} |
||||||
|
|
||||||
|
protected override void GenerateDelegateInvokeExpression(CodeDelegateInvokeExpression e) |
||||||
|
{ |
||||||
|
Output.Write("[CodeDelegateInvokeExpression: {0}]", e.ToString()); |
||||||
|
} |
||||||
|
|
||||||
|
protected override void GenerateObjectCreateExpression(CodeObjectCreateExpression e) |
||||||
|
{ |
||||||
|
Output.Write("[CodeObjectCreateExpression: Type={0}, Parameters=", e.CreateType.BaseType); |
||||||
|
bool first = true; |
||||||
|
foreach (CodeExpression expr in e.Parameters) { |
||||||
|
if (first) first = false; else Output.Write(", "); |
||||||
|
this.GenerateExpression(expr); |
||||||
|
} |
||||||
|
Output.Write("]"); |
||||||
|
} |
||||||
|
|
||||||
|
protected override void GeneratePropertyReferenceExpression(CodePropertyReferenceExpression e) |
||||||
|
{ |
||||||
|
Output.Write("[CodePropertyReferenceExpression: Name={0}, Target=", e.PropertyName); |
||||||
|
this.GenerateExpression(e.TargetObject); |
||||||
|
Output.Write("]"); |
||||||
|
} |
||||||
|
|
||||||
|
protected override void GeneratePropertySetValueReferenceExpression(CodePropertySetValueReferenceExpression e) |
||||||
|
{ |
||||||
|
Output.Write("[CodePropertySetValueReferenceExpression: {0}]", e.ToString()); |
||||||
|
} |
||||||
|
|
||||||
|
protected override void GenerateThisReferenceExpression(CodeThisReferenceExpression e) |
||||||
|
{ |
||||||
|
Output.Write("[CodeThisReferenceExpression]"); |
||||||
|
} |
||||||
|
|
||||||
|
protected override void GenerateExpressionStatement(CodeExpressionStatement e) |
||||||
|
{ |
||||||
|
Output.Write("[CodeExpressionStatement:"); |
||||||
|
base.GenerateExpression(e.Expression); |
||||||
|
Output.WriteLine("]"); |
||||||
|
} |
||||||
|
|
||||||
|
protected override void GenerateIterationStatement(CodeIterationStatement e) |
||||||
|
{ |
||||||
|
Output.WriteLine("[CodeIterationStatement: {0}]", e.ToString()); |
||||||
|
} |
||||||
|
|
||||||
|
protected override void GenerateThrowExceptionStatement(CodeThrowExceptionStatement e) |
||||||
|
{ |
||||||
|
Output.WriteLine("[CodeThrowExceptionStatement: {0}]", e.ToString()); |
||||||
|
} |
||||||
|
|
||||||
|
protected override void GenerateComment(CodeComment e) |
||||||
|
{ |
||||||
|
Output.WriteLine("[CodeComment: {0}]", e.ToString()); |
||||||
|
} |
||||||
|
|
||||||
|
protected override void GenerateMethodReturnStatement(CodeMethodReturnStatement e) |
||||||
|
{ |
||||||
|
Output.WriteLine("[CodeMethodReturnStatement: {0}]", e.ToString()); |
||||||
|
} |
||||||
|
|
||||||
|
protected override void GenerateConditionStatement(CodeConditionStatement e) |
||||||
|
{ |
||||||
|
Output.WriteLine("[GenerateConditionStatement: {0}]", e.ToString()); |
||||||
|
} |
||||||
|
|
||||||
|
protected override void GenerateTryCatchFinallyStatement(CodeTryCatchFinallyStatement e) |
||||||
|
{ |
||||||
|
Output.WriteLine("[CodeTryCatchFinallyStatement: {0}]", e.ToString()); |
||||||
|
} |
||||||
|
|
||||||
|
protected override void GenerateAssignStatement(CodeAssignStatement e) |
||||||
|
{ |
||||||
|
Output.Write("[CodeAssignStatement: Left="); |
||||||
|
base.GenerateExpression(e.Left); |
||||||
|
Output.Write(", Right="); |
||||||
|
base.GenerateExpression(e.Right); |
||||||
|
Output.WriteLine("]"); |
||||||
|
} |
||||||
|
|
||||||
|
protected override void GenerateAttachEventStatement(CodeAttachEventStatement e) |
||||||
|
{ |
||||||
|
Output.WriteLine("[CodeAttachEventStatement: {0}]", e.ToString()); |
||||||
|
} |
||||||
|
|
||||||
|
protected override void GenerateRemoveEventStatement(CodeRemoveEventStatement e) |
||||||
|
{ |
||||||
|
Output.WriteLine("[CodeRemoveEventStatement: {0}]", e.ToString()); |
||||||
|
} |
||||||
|
|
||||||
|
protected override void GenerateGotoStatement(CodeGotoStatement e) |
||||||
|
{ |
||||||
|
Output.WriteLine("[CodeGotoStatement: {0}]", e.ToString()); |
||||||
|
} |
||||||
|
|
||||||
|
protected override void GenerateLabeledStatement(CodeLabeledStatement e) |
||||||
|
{ |
||||||
|
Output.WriteLine("[CodeLabeledStatement: {0}]", e.ToString()); |
||||||
|
} |
||||||
|
|
||||||
|
protected override void GenerateVariableDeclarationStatement(CodeVariableDeclarationStatement e) |
||||||
|
{ |
||||||
|
Output.WriteLine("[CodeVariableDeclarationStatement: {0}]", e.ToString()); |
||||||
|
} |
||||||
|
|
||||||
|
protected override void GenerateLinePragmaStart(CodeLinePragma e) |
||||||
|
{ |
||||||
|
Output.WriteLine("[CodeLinePragma: {0}]", e.ToString()); |
||||||
|
} |
||||||
|
|
||||||
|
protected override void GenerateLinePragmaEnd(CodeLinePragma e) |
||||||
|
{ |
||||||
|
Output.WriteLine("[CodeLinePragma: {0}]", e.ToString()); |
||||||
|
} |
||||||
|
|
||||||
|
protected override void GenerateEvent(CodeMemberEvent e, CodeTypeDeclaration c) |
||||||
|
{ |
||||||
|
Output.WriteLine("[CodeMemberEvent: {0}]", e.ToString()); |
||||||
|
} |
||||||
|
|
||||||
|
protected override void GenerateField(CodeMemberField e) |
||||||
|
{ |
||||||
|
Output.Write("[CodeMemberField: Name={0}, Type=", e.Name); |
||||||
|
Output.Write(e.Type.BaseType); |
||||||
|
Output.WriteLine("]"); |
||||||
|
} |
||||||
|
|
||||||
|
protected override void GenerateSnippetMember(CodeSnippetTypeMember e) |
||||||
|
{ |
||||||
|
Output.WriteLine("[CodeSnippetTypeMember: {0}]", e.ToString()); |
||||||
|
} |
||||||
|
|
||||||
|
protected override void GenerateEntryPointMethod(CodeEntryPointMethod e, CodeTypeDeclaration c) |
||||||
|
{ |
||||||
|
Output.WriteLine("[CodeEntryPointMethod: {0}]", e.ToString()); |
||||||
|
} |
||||||
|
|
||||||
|
public void PublicGenerateCodeFromStatement(CodeStatement e, TextWriter w, CodeGeneratorOptions o) |
||||||
|
{ |
||||||
|
((ICodeGenerator)this).GenerateCodeFromStatement(e, w, o); |
||||||
|
} |
||||||
|
|
||||||
|
protected override void GenerateMethod(CodeMemberMethod e, CodeTypeDeclaration c) |
||||||
|
{ |
||||||
|
Output.WriteLine("[CodeMemberMethod: Name={0}, Parameterns={1}]", e.Name, e.Parameters.Count); |
||||||
|
++Indent; |
||||||
|
GenerateStatements(e.Statements); |
||||||
|
--Indent; |
||||||
|
} |
||||||
|
|
||||||
|
protected override void GenerateProperty(CodeMemberProperty e, CodeTypeDeclaration c) |
||||||
|
{ |
||||||
|
Output.WriteLine("[CodeMemberProperty : {0}]", e.ToString()); |
||||||
|
} |
||||||
|
|
||||||
|
protected override void GenerateConstructor(CodeConstructor e, CodeTypeDeclaration c) |
||||||
|
{ |
||||||
|
Output.WriteLine("[CodeConstructor : {0}]", e.ToString()); |
||||||
|
++Indent; |
||||||
|
GenerateStatements(e.Statements); |
||||||
|
--Indent; |
||||||
|
} |
||||||
|
|
||||||
|
protected override void GenerateTypeConstructor(CodeTypeConstructor e) |
||||||
|
{ |
||||||
|
Output.WriteLine("[CodeTypeConstructor : {0}]", e.ToString()); |
||||||
|
} |
||||||
|
|
||||||
|
protected override void GenerateTypeStart(CodeTypeDeclaration e) |
||||||
|
{ |
||||||
|
Output.WriteLine("[CodeTypeDeclaration : {0}]", e.ToString()); |
||||||
|
} |
||||||
|
|
||||||
|
protected override void GenerateTypeEnd(CodeTypeDeclaration e) |
||||||
|
{ |
||||||
|
Output.WriteLine("[CodeTypeDeclaration: {0}]", e.ToString()); |
||||||
|
} |
||||||
|
|
||||||
|
protected override void GenerateNamespaceStart(CodeNamespace e) |
||||||
|
{ |
||||||
|
Output.WriteLine("[CodeNamespaceStart: {0}]", e.ToString()); |
||||||
|
} |
||||||
|
|
||||||
|
protected override void GenerateNamespaceEnd(CodeNamespace e) |
||||||
|
{ |
||||||
|
Output.WriteLine("[CodeNamespaceEnd: {0}]", e.ToString()); |
||||||
|
} |
||||||
|
|
||||||
|
protected override void GenerateNamespaceImport(CodeNamespaceImport e) |
||||||
|
{ |
||||||
|
Output.WriteLine("[CodeNamespaceImport: {0}]", e.ToString()); |
||||||
|
} |
||||||
|
|
||||||
|
protected override void GenerateAttributeDeclarationsStart(CodeAttributeDeclarationCollection attributes) |
||||||
|
{ |
||||||
|
Output.WriteLine("[CodeAttributeDeclarationCollection: {0}]", attributes.ToString()); |
||||||
|
} |
||||||
|
|
||||||
|
protected override void GenerateAttributeDeclarationsEnd(CodeAttributeDeclarationCollection attributes) |
||||||
|
{ |
||||||
|
Output.WriteLine("[CodeAttributeDeclarationCollection: {0}]", attributes.ToString()); |
||||||
|
} |
||||||
|
|
||||||
|
protected override void GeneratePrimitiveExpression(CodePrimitiveExpression e) |
||||||
|
{ |
||||||
|
if (e.Value == null) { |
||||||
|
Output.WriteLine("[CodePrimitiveExpression: null]"); |
||||||
|
} else { |
||||||
|
Output.Write("[CodePrimitiveExpression: "); |
||||||
|
base.GeneratePrimitiveExpression(e); |
||||||
|
Output.WriteLine(" (" + e.Value.GetType().Name + ")]"); |
||||||
|
} |
||||||
|
} |
||||||
|
|
||||||
|
protected override bool Supports(GeneratorSupport support) |
||||||
|
{ |
||||||
|
return true; |
||||||
|
} |
||||||
|
|
||||||
|
protected override bool IsValidIdentifier(string value) |
||||||
|
{ |
||||||
|
return true; |
||||||
|
} |
||||||
|
|
||||||
|
protected override string CreateEscapedIdentifier(string value) |
||||||
|
{ |
||||||
|
return value; |
||||||
|
} |
||||||
|
|
||||||
|
protected override string CreateValidIdentifier(string value) |
||||||
|
{ |
||||||
|
return value; |
||||||
|
} |
||||||
|
|
||||||
|
protected override string GetTypeOutput(CodeTypeReference value) |
||||||
|
{ |
||||||
|
return value.ToString(); |
||||||
|
} |
||||||
|
|
||||||
|
protected override string QuoteSnippetString(string value) |
||||||
|
{ |
||||||
|
return "\"" + value + "\""; |
||||||
|
} |
||||||
|
|
||||||
|
#endregion
|
||||||
|
} |
||||||
|
} |
Loading…
Reference in new issue