[svn] r7601: vs-plugin/trunk:
Nemerle.Compiler.Utils/FormCodeDomGenerator.n
Nemerle.Compiler.Utils/Nemerle...
VladD2
svnadmin at nemerle.org
Thu Apr 19 10:10:50 CEST 2007
Log:
Work on CodeDomParser (WinForms designer).
1. Fix open form for editing.
2. Change CodeDomeParser.
3. Refactoring of templates.
Author: VladD2
Date: Thu Apr 19 10:10:46 2007
New Revision: 7601
Modified:
vs-plugin/trunk/Nemerle.Compiler.Utils/FormCodeDomGenerator.n
vs-plugin/trunk/Nemerle.Compiler.Utils/NemerleCodeParser.n
vs-plugin/trunk/Nemerle.VsIntegration/NemerleConstants.cs
vs-plugin/trunk/Nemerle.VsIntegration/NemerlePackage.cs
vs-plugin/trunk/Nemerle.VsIntegration/Project/NemerleFileNodeCodeDomProvider.cs
vs-plugin/trunk/Nemerle.VsIntegration/Templates/ProjectItems/Form/Form.Designer.n
vs-plugin/trunk/Nemerle.VsIntegration/Templates/ProjectItems/UserControl/UserControl.Designer.n
vs-plugin/trunk/Nemerle.VsIntegration/Templates/Projects/WindowsApplication/MainForm.Designer.n
Modified: vs-plugin/trunk/Nemerle.Compiler.Utils/FormCodeDomGenerator.n
==============================================================================
--- vs-plugin/trunk/Nemerle.Compiler.Utils/FormCodeDomGenerator.n (original)
+++ vs-plugin/trunk/Nemerle.Compiler.Utils/FormCodeDomGenerator.n Thu Apr 19 10:10:46 2007
@@ -111,7 +111,7 @@
// TODO : Check for form class
MergeClassDecl(e.Namespaces[0].Types[0],
- match(nsDecl.Decls.Find( _ is Decl.Type ))
+ match(nsDecl.Decls.Find(_ is Decl.Type ))
{ | Some(typeBuilder) => (typeBuilder :> Decl.Type)
| _ => throw ApplicationException("Can't find typeBuilder for the Form class in CodeDom")
}.Builder);
@@ -149,17 +149,17 @@
protected MergeFields() : void
{
- //classDecl.Members.Filter( _ is CodeMemberField).Map( _ : CodeMemberField);
+ //classDecl.Members.Filter(_ is CodeMemberField).Map(_ : CodeMemberField);
// DEBUG
Debug.Print("oldFields:\n");
- _oldFields.Iter( f => Debug.Print($" field $(f.Name)") );
+ _oldFields.Iter(f => Debug.Print($" field $(f.Name)") );
//Debug.Print("allFields:\n");
- //typeBuilder.GetFields().Iter( f => Debug.Print($" field $(f.Name)\n") );
+ //typeBuilder.GetFields().Iter(f => Debug.Print($" field $(f.Name)\n") );
Debug.Print("codedomFields:\n");
- _codeDomFields.Iter( f => Debug.Print($" field $(f.Name)") );
+ _codeDomFields.Iter(f => Debug.Print($" field $(f.Name)") );
def isAddLine = Options.BlankLinesBetweenMembers;
@@ -176,7 +176,7 @@
GenerateIndent();
GenerateField(cdf);
- def linesList = CodeDomHelper.StringToListOfLines( sw.ToString() );
+ def linesList = CodeDomHelper.StringToListOfLines(sw.ToString() );
_designerFileMerger.AddLines(_formCodeInfo.newFieldInsertionLine,
linesList);
@@ -190,7 +190,7 @@
{
def loc = of.Location;
def line = if (Options.BlankLinesBetweenMembers) loc.Line-1 else loc.Line;
- _designerFileMerger.RemoveLines( line, loc.EndLine );
+ _designerFileMerger.RemoveLines(line, loc.EndLine );
def lineOffset = line - loc.EndLine - 1;
Relocate(_designerFileIndex,line,lineOffset);
@@ -210,7 +210,7 @@
GenerateIndent();
GenerateField(cdf);
- def linesList = CodeDomHelper.StringToListOfLines( sw.ToString() );
+ def linesList = CodeDomHelper.StringToListOfLines(sw.ToString() );
def oldLoc = of.Location;
_designerFileMerger.ReplaceLines(oldLoc.Line, oldLoc.EndLine,
@@ -256,9 +256,9 @@
);
Debug.Print("codedomFields (after Sort):\n");
- sortedCodedomFields.Iter( f => Debug.Print($" field $(f.Name)\n") );
+ sortedCodedomFields.Iter(f => Debug.Print($" field $(f.Name)\n") );
- AddRemoveRenameDispatcher( _oldFields, sortedCodedomFields,
+ AddRemoveRenameDispatcher(_oldFields, sortedCodedomFields,
GetChangeStatus,
AddField, RemoveField, RenameField );
}
@@ -267,18 +267,18 @@
{
// DEBUG
Debug.Print("oldMethods:\n");
- _oldMethods.Iter( m => Debug.Print($" method $(m.Name)") );
+ _oldMethods.Iter(m => Debug.Print($" method $(m.Name)") );
//Debug.Print("allMethods:\n");
- //typeBuilder.GetMethods().Iter( m => Debug.Print($" method $(m.Name)\n") );
+ //typeBuilder.GetMethods().Iter(m => Debug.Print($" method $(m.Name)\n") );
Debug.Print("codedomMethods:\n");
- _codeDomMethods.Iter( m => Debug.Print($" method $(m.Name)") );
+ _codeDomMethods.Iter(m => Debug.Print($" method $(m.Name)") );
// Process InitializeComponent
- match( (_oldMethods.Find( m => m.Name == "InitializeComponent" ),
- _codeDomMethods.Find( m => m.Name == "InitializeComponent" )) )
+ match((_oldMethods.Find(m => m.Name == "InitializeComponent" ),
+ _codeDomMethods.Find(m => m.Name == "InitializeComponent" )) )
{
| (om,Some(cdm)) =>
using(def sw = StringWriter())
@@ -289,7 +289,7 @@
GenerateIndent();
GenerateMethod(cdm,classDecl);
- def linesList = CodeDomHelper.StringToListOfLines( sw.ToString() );
+ def linesList = CodeDomHelper.StringToListOfLines(sw.ToString() );
match(om)
{
@@ -326,9 +326,9 @@
def isMethodBodyEmpty = (statements.Count == 0);
when (isMethodBodyEmpty)
// insert ';' for generation reverse this change later
- _ = statements.Add( CodeMethodReturnStatement() );
+ _ = statements.Add(CodeMethodReturnStatement() );
- // if( Options.BlankLinesBetweenMembers )
+ // if(Options.BlankLinesBetweenMembers )
Output.WriteLine(); // TODO : blank lines should be regulated?
GenerateMethod(cdm,classDecl);
@@ -337,7 +337,7 @@
when (isMethodBodyEmpty)
statements.Clear();
- def linesList = CodeDomHelper.StringToListOfLines( sw.ToString() );
+ def linesList = CodeDomHelper.StringToListOfLines(sw.ToString() );
_mainFileMerger.AddLines(_formCodeInfo.newMethodInsertionLine,
linesList);
@@ -379,7 +379,7 @@
GenerateIndent();
GenerateMethod(cdm,classDecl);
- def linesList = CodeDomHelper.StringToListOfLines( sw.ToString() );
+ def linesList = CodeDomHelper.StringToListOfLines(sw.ToString() );
def oldLoc = om.Location;
_designerFileMerger.ReplaceLines(oldLoc.Line, oldLoc.EndLine,
@@ -393,7 +393,7 @@
}
}
- AddRemoveRenameDispatcher( _oldMethods, _codeDomMethods,
+ AddRemoveRenameDispatcher(_oldMethods, _codeDomMethods,
GetChangeStatus,
AddMethod, RemoveMethod, RenameMethod );
}
@@ -411,14 +411,14 @@
{
if (fileIndex == _mainFileIndex)
{
- _oldMethods.Iter( m =>
+ _oldMethods.Iter(m =>
{
def loc = m.Location;
when (loc.FileIndex == _mainFileIndex)
- m.Location = Completion.Relocate( loc, line, 0, lineOffset, 0)
+ m.Location = Completion.Relocate(loc, line, 0, lineOffset, 0)
} );
- _codeDomMethods.Iter( m =>
+ _codeDomMethods.Iter(m =>
{
def locRef = m.UserData[typeof(Location)];
when (locRef != null)
@@ -438,21 +438,21 @@
}
else // fileIndex == _designerFileIndex
{
- _oldFields.Iter( f =>
+ _oldFields.Iter(f =>
{
def loc = f.Location;
when (loc.FileIndex == fileIndex)
- f.Location = Completion.Relocate( loc, line, 0, lineOffset, 0)
+ f.Location = Completion.Relocate(loc, line, 0, lineOffset, 0)
} );
}
}
// Removes can be everywhere, Adds only at the end
- static protected AddRemoveRenameDispatcher[T1,T2]( old_list: list[T1], new_list: list[T2],
+ static protected AddRemoveRenameDispatcher[T1,T2](old_list: list[T1], new_list: list[T2],
status: T1*T2->ChangeStatus,
addFunc : T2->void, removeFunc : T1->void, renameFunc : T1*T2->void ) : void
{
- def dispatcher( old_l, new_l )
+ def dispatcher(old_l, new_l )
{
| (h1 :: t1, h2 :: t2) =>
match (status(h1,h2)) {
@@ -460,13 +460,13 @@
| NonEqual => { removeFunc(h1); dispatcher(t1,new_l) }
| Renamed => { renameFunc(h1,h2); dispatcher(t1,t2) }
}
- | (_, []) => old_l.Iter( removeFunc(_) )
- | ([], _) => new_l.Iter( addFunc(_) )
+ | (_, []) => old_l.Iter(removeFunc(_) )
+ | ([], _) => new_l.Iter(addFunc(_) )
}
- dispatcher( old_list, new_list )
+ dispatcher(old_list, new_list )
}
- static protected GetChangeStatus[T1,T2]( oldMember: T1, codeDomMember: T2 ) : ChangeStatus
+ static protected GetChangeStatus[T1,T2](oldMember: T1, codeDomMember: T2 ) : ChangeStatus
where T1 : MemberBuilder where T2 : CodeTypeMember
{
//Debug.Print($"Comparing $(oldMember.Name) and $(codeDomMember.Name)\n");
Modified: vs-plugin/trunk/Nemerle.Compiler.Utils/NemerleCodeParser.n
==============================================================================
--- vs-plugin/trunk/Nemerle.Compiler.Utils/NemerleCodeParser.n (original)
+++ vs-plugin/trunk/Nemerle.Compiler.Utils/NemerleCodeParser.n Thu Apr 19 10:10:46 2007
@@ -251,6 +251,22 @@
methodDecl
}
+ ToTypeRefExpression(typeInfo : Nemerle.Compiler.TypeInfo, typeParaams : list[TyVar]) : CodeTypeReferenceExpression
+ {
+ CodeTypeReferenceExpression(ToTypeRef(typeInfo, typeParaams))
+ }
+
+ ToTypeRef(typeInfo : Nemerle.Compiler.TypeInfo, typeParaams : list[TyVar]) : CodeTypeReference
+ {
+ Trace.Assert(typeInfo.TyparmsCount == 0); // TODO: Add support for type parametrs!
+ Trace.Assert(typeParaams.IsEmpty);
+
+ if (typeInfo.SystemType != null)
+ CodeTypeReference(typeInfo.SystemType);
+ else
+ CodeTypeReference(typeInfo.FullName);
+ }
+
protected virtual ToExpression(expr : PExpr) : CodeExpression
{
def createBinOper(expr1, op, expr2)
@@ -278,18 +294,7 @@
| TExpr.StaticRef(from, mem, type_parms) when mem.MemberKind == MemberTypes.Constructor =>
def codeParams = parms.MapToArray(ToExpression);
- def ctor = if (from.tycon.SystemType != null)
- CodeObjectCreateExpression(from.tycon.SystemType, codeParams);
- else
- CodeObjectCreateExpression(from.tycon.FullName, codeParams);
-
- unless (type_parms.IsEmpty)
- {
- //ctor.TypeArguments.AddRange(type_parms.MapToArray());
- Trace.Assert(false);
- }
-
- ctor
+ CodeObjectCreateExpression(ToTypeRef(from.tycon, type_parms), codeParams);
| _ =>
CodeMethodInvokeExpression(
@@ -308,6 +313,16 @@
| <[ $obj.$prop ]> when prop.TypedObject is IProperty =>
CodePropertyReferenceExpression(ToExpression(obj), prop.TypedObject.Name);
+ | <[ $_.$_ ]> as mem when mem.TypedObject is TExpr =>
+ match (mem.TypedObject)
+ {
+ | TExpr.StaticRef(_from, mem, type_parms) when mem.IsStatic =>
+ CodeFieldReferenceExpression(
+ ToTypeRefExpression(mem.DeclaringType, type_parms), mem.Name)
+
+ | _ => NotSuportedExpression(expr)
+ }
+
| PExpr.Ref(name) => CodeVariableReferenceExpression(name.ToString())
| PExpr.Literal(literal) =>
@@ -329,8 +344,14 @@
| <[ base ]> => CodeBaseReferenceExpression()
| <[ this ]> => CodeThisReferenceExpression()
| null => CodeSnippetExpression("");
- | _ => CodeSnippetExpression(expr.ToString())
+ | _ => NotSuportedExpression(expr)
+ }
}
+
+ NotSuportedExpression(expr : PExpr) : CodeExpression
+ {
+ Debug.Assert(false, $"Not suported expression: '$expr' ($(expr.GetType().Name))");
+ CodeSnippetExpression(expr.ToString())
}
protected ToStatements(expr : PExpr) : SCG.IEnumerable[CodeStatement]
Modified: vs-plugin/trunk/Nemerle.VsIntegration/NemerleConstants.cs
==============================================================================
--- vs-plugin/trunk/Nemerle.VsIntegration/NemerleConstants.cs (original)
+++ vs-plugin/trunk/Nemerle.VsIntegration/NemerleConstants.cs Thu Apr 19 10:10:46 2007
@@ -44,7 +44,6 @@
public const string LibraryGuidString = "EDCC3B81-0BAD-11DB-BC1A-00112FDE8B61";
public const string ProjectCmdSetGuidString = "D6DDF8E8-9A9E-425C-AB18-7BBCC70A6489";
public const string LanguageIntellisenseProviderGuidString = "EDCC3B83-0BAD-11DB-BC1A-00112FDE8B61";
- public const string EditorLogicalViewGuidString = "EDCC3B84-0BAD-11DB-BC1A-00112FDE8B61";
public const string ProjectFactoryGuidString = "EDCC3B85-0BAD-11DB-BC1A-00112FDE8B61";
public const string FolderNodePropertiesGuidString = "EDCC3B86-0BAD-11DB-BC1A-00112FDE8B61";
public const string ProjectNodePropertiesGuidString = "EDCC3B87-0BAD-11DB-BC1A-00112FDE8B61";
Modified: vs-plugin/trunk/Nemerle.VsIntegration/NemerlePackage.cs
==============================================================================
--- vs-plugin/trunk/Nemerle.VsIntegration/NemerlePackage.cs (original)
+++ vs-plugin/trunk/Nemerle.VsIntegration/NemerlePackage.cs Thu Apr 19 10:10:46 2007
@@ -79,8 +79,11 @@
[ProvideObject (typeof(DebugPropertyPage))]
[ProvideObject (typeof(NemerleBuildPropertyPage))]
[ProvideEditorExtension (typeof(NemerleEditorFactory), NemerleConstants.FileExtension, 32)]
- [ProvideEditorLogicalView(typeof(NemerleEditorFactory), NemerleConstants.EditorLogicalViewGuidString)] //LOGVIEWID_Designer
- [ProvideEditorLogicalView(typeof(NemerleEditorFactory), NemerleConstants.EditorLogicalViewGuidString)] //LOGVIEWID_Code
+
+ // Attention! This guids is a magic numbers provide by Microsoft. Don't change it.
+ [ProvideEditorLogicalView(typeof(NemerleEditorFactory), "{7651a702-06e5-11d1-8ebd-00a0c90f26ea}")] //LOGVIEWID_Designer
+ [ProvideEditorLogicalView(typeof(NemerleEditorFactory), "{7651a701-06e5-11d1-8ebd-00a0c90f26ea}")] //LOGVIEWID_Code
+
// Showing the splash screen requires "devenv /rootsuffix Exp /setup" during the installation.
// For more information please see: http://blogs.msdn.com/jim_glass/archive/2005/05/23/421152.aspx
[InstalledProductRegistration(
Modified: vs-plugin/trunk/Nemerle.VsIntegration/Project/NemerleFileNodeCodeDomProvider.cs
==============================================================================
--- vs-plugin/trunk/Nemerle.VsIntegration/Project/NemerleFileNodeCodeDomProvider.cs (original)
+++ vs-plugin/trunk/Nemerle.VsIntegration/Project/NemerleFileNodeCodeDomProvider.cs Thu Apr 19 10:10:46 2007
@@ -234,8 +234,12 @@
using (RDTFileTextMerger designerMerger = new RDTFileTextMerger(designerFileNode))
{
//ProjectInfo.FindProject(designerFilePath).Project.CompileUnits.
+ ProjectInfo projectInfo = ProjectInfo.FindProject(mainFilePath);
+ if (projectInfo == null)
+ throw new ApplicationException("The component not in project!");
+
_codeDomGenerator.MergeFormCodeFromCompileUnit(
- ProjectInfo.FindProject(mainFilePath).Project,
+ projectInfo.Project,
mainFilePath, designerFilePath,
e, mainMerger, designerMerger, o);
}
Modified: vs-plugin/trunk/Nemerle.VsIntegration/Templates/ProjectItems/Form/Form.Designer.n
==============================================================================
--- vs-plugin/trunk/Nemerle.VsIntegration/Templates/ProjectItems/Form/Form.Designer.n (original)
+++ vs-plugin/trunk/Nemerle.VsIntegration/Templates/ProjectItems/Form/Form.Designer.n Thu Apr 19 10:10:46 2007
@@ -11,12 +11,10 @@
/// Clean up any resources being used.
/// </summary>
/// <param name="disposing">true if managed resources should be disposed; otherwise, false.</param>
- protected override Dispose( disposing : bool) : void
- {
- when (disposing && (components != null))
+ protected override Dispose(disposing : bool) : void
{
+ when (disposing && components != null)
components.Dispose();
- }
base.Dispose(disposing);
}
Modified: vs-plugin/trunk/Nemerle.VsIntegration/Templates/ProjectItems/UserControl/UserControl.Designer.n
==============================================================================
--- vs-plugin/trunk/Nemerle.VsIntegration/Templates/ProjectItems/UserControl/UserControl.Designer.n (original)
+++ vs-plugin/trunk/Nemerle.VsIntegration/Templates/ProjectItems/UserControl/UserControl.Designer.n Thu Apr 19 10:10:46 2007
@@ -13,10 +13,8 @@
/// <param name="disposing">true if managed resources should be disposed; otherwise, false.</param>
protected override Dispose(disposing : bool) : void
{
- when (disposing && (components != null))
- {
+ when (disposing && components != null)
components.Dispose();
- }
base.Dispose(disposing);
}
Modified: vs-plugin/trunk/Nemerle.VsIntegration/Templates/Projects/WindowsApplication/MainForm.Designer.n
==============================================================================
--- vs-plugin/trunk/Nemerle.VsIntegration/Templates/Projects/WindowsApplication/MainForm.Designer.n (original)
+++ vs-plugin/trunk/Nemerle.VsIntegration/Templates/Projects/WindowsApplication/MainForm.Designer.n Thu Apr 19 10:10:46 2007
@@ -10,13 +10,13 @@
/// <summary>
/// Clean up any resources being used.
/// </summary>
- /// <param name="disposing">true if managed resources should be disposed; otherwise, false.</param>
- protected override Dispose( disposing : bool) : void
- {
- when (disposing && (components != null))
+ /// <param name="disposing">
+ /// true if managed resources should be disposed; otherwise, false.
+ /// </param>
+ protected override Dispose(disposing : bool) : void
{
+ when (disposing && components != null)
components.Dispose();
- }
base.Dispose(disposing);
}
More information about the svn
mailing list