[svn] r7648: vs-plugin/trunk:
Nemerle.Compiler.Utils/Nemerle.Completion2/CodeModel/Project.n
Nemerle.Compi...
pbludov
svnadmin at nemerle.org
Fri May 4 13:32:12 CEST 2007
Log:
Target Hightlighting in the generated source.
Author: pbludov
Date: Fri May 4 13:32:06 2007
New Revision: 7648
Modified:
vs-plugin/trunk/Nemerle.Compiler.Utils/Nemerle.Completion2/CodeModel/Project.n
vs-plugin/trunk/Nemerle.Compiler.Utils/Nemerle.Completion2/CodeModel/SourceGenerator.n
vs-plugin/trunk/Nemerle.VsIntegration/LanguageService/NemerleAuthoringScope.cs
vs-plugin/trunk/Nemerle.VsIntegration/Nemerle.VisualStudio.csproj
Modified: vs-plugin/trunk/Nemerle.Compiler.Utils/Nemerle.Completion2/CodeModel/Project.n
==============================================================================
--- vs-plugin/trunk/Nemerle.Compiler.Utils/Nemerle.Completion2/CodeModel/Project.n (original)
+++ vs-plugin/trunk/Nemerle.Compiler.Utils/Nemerle.Completion2/CodeModel/Project.n Fri May 4 13:32:06 2007
@@ -244,7 +244,7 @@
}
}
- public GenerateCode(ty : System.Type, writer : System.IO.TextWriter) : void
+ public GenerateCode(ty : System.Type, member : SR.MemberInfo, writer : System.IO.TextWriter) : GotoInfo
{
def nameAndGenericArgs =
if (ty.IsGenericType)
@@ -255,7 +255,9 @@
def typeInfo = Engine.Lookup(nameAndGenericArgs);
Debug.Assert(null != typeInfo, $"type $(ty.FullName) not found");
- SourceGenerator(writer).WriteTypeDeclaration(typeInfo);
+ def generator = SourceGenerator(writer, member);
+ generator.WriteTypeDeclaration(typeInfo);
+ GotoInfo(generator.Location);
}
public GetTypes(fileIndex : int) : List[TypeBuilder]
Modified: vs-plugin/trunk/Nemerle.Compiler.Utils/Nemerle.Completion2/CodeModel/SourceGenerator.n
==============================================================================
--- vs-plugin/trunk/Nemerle.Compiler.Utils/Nemerle.Completion2/CodeModel/SourceGenerator.n (original)
+++ vs-plugin/trunk/Nemerle.Compiler.Utils/Nemerle.Completion2/CodeModel/SourceGenerator.n Fri May 4 13:32:06 2007
@@ -13,13 +13,22 @@
// Description of SourceGenerator
public class SourceGenerator
{
+ [Accessor] mutable _location : Location;
+
+ mutable _line : int;
+ mutable _column : int;
mutable _indentSize : int;
mutable _applyIndent : bool;
mutable _ns : NamespaceTree.Node;
private _writer : TextWriter;
+ private _target : SR.MemberInfo;
- public this(writer : TextWriter)
+ public this(writer : TextWriter, target : SR.MemberInfo)
{
+ _line = 1;
+ _column = 1;
+ _location = Location.Default;
+ _target = target;
_writer = writer;
_ns = null;
}
@@ -34,7 +43,7 @@
Write("event");
Write(" ");
- WriteName(value.Name);
+ WriteName(value);
Write(" : ");
WriteType(value.GetMemType());
Write(";");
@@ -48,7 +57,7 @@
WriteDocumentation(value);
WriteAttributes(value);
- WriteName(value.Name);
+ WriteName(value);
Write(" : ");
WriteType(value.GetMemType());
Write(";");
@@ -61,7 +70,7 @@
WriteDocumentation(value);
- Write("this");
+ WriteName(value);
Write("(");
WriteList(value.GetParameters(), WriteParameterDeclaration);
Write(");");
@@ -75,7 +84,7 @@
WriteDocumentation(value);
WriteAttributes(value);
- WriteName(value.Name);
+ WriteName(value);
Write("(");
when (value.IsExtension)
@@ -103,7 +112,7 @@
WriteAttributes(value);
- WriteName(value.Name);
+ WriteName(value);
// WriteList(value.GetParameters(), "[", "]", WriteParameterDeclaration);
Write(" : ");
@@ -150,7 +159,11 @@
}
Write(" ");
+ when (_target.Equals(value.SystemType))
+ _location = Location(0, _line, _column);
WriteType(value);
+ when (_target.Equals(value.SystemType))
+ _location = Location(0, _location.Line, _location.Column, _line, _column);
Write(" ");
match (value.GetTydecl())
@@ -173,16 +186,20 @@
{
repeat (_indentSize)
_writer.Write('\t');
+ _column += _indentSize;
_applyIndent = false;
}
_writer.Write(value);
+ _column += value.Length;
}
private WriteLine() : void
{
Write(Environment.NewLine);
_applyIndent = true;
+ _line++;
+ _column = 1;
}
private BeginBlock() : void
@@ -233,9 +250,17 @@
}
}
- private WriteName(name : string) : void
+ private WriteName(value : IMember) : void
{
+ def name = if (value.MemberKind == MemberKinds.Constructor) "this" else value.Name;
+
+ when (_target.Equals(value.GetHandle()))
+ _location = Location(0, _line, _column);
+
Write(name.Replace('.', '\'').Replace('<', '_').Replace('>', '_'));
+
+ when (_target.Equals(value.GetHandle()))
+ _location = Location(0, _location.Line, _location.Column, _line, _column);
}
private WriteType(ty : TypeInfo) : void
Modified: vs-plugin/trunk/Nemerle.VsIntegration/LanguageService/NemerleAuthoringScope.cs
==============================================================================
--- vs-plugin/trunk/Nemerle.VsIntegration/LanguageService/NemerleAuthoringScope.cs (original)
+++ vs-plugin/trunk/Nemerle.VsIntegration/LanguageService/NemerleAuthoringScope.cs Fri May 4 13:32:06 2007
@@ -232,7 +232,7 @@
using (TextWriter w = new StreamWriter(tempFileName))
{
- _project.Project.GenerateCode(type, w);
+ SetTextSpan(ref span, _project.Project.GenerateCode(type, info.Member, w));
}
// Made this file 'DeleteOnClose'.
Modified: vs-plugin/trunk/Nemerle.VsIntegration/Nemerle.VisualStudio.csproj
==============================================================================
--- vs-plugin/trunk/Nemerle.VsIntegration/Nemerle.VisualStudio.csproj (original)
+++ vs-plugin/trunk/Nemerle.VsIntegration/Nemerle.VisualStudio.csproj Fri May 4 13:32:06 2007
@@ -205,13 +205,17 @@
<Content Include="CodeSnippets\Snippets\match.snippet">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</Content>
- <Content Include="Templates\ProjectItems\UserControl\UserControl.ico" />
- <Content Include="Templates\ProjectItems\UserControl\UserControl.vstemplate" />
<None Include="CtcComponents\Guids.h" />
<None Include="CtcComponents\PkgCmdID.h" />
<None Include="nemerle.snk" />
<ZipItem Include="Templates\ProjectItems\Form\Form.Designer.n" />
<ZipItem Include="Templates\ProjectItems\Form\Form.n" />
+
+ <ZipItem Include="Templates\ProjectItems\UserControl\UserControl.ico" />
+ <ZipItem Include="Templates\ProjectItems\UserControl\UserControl.vstemplate" />
+ <ZipItem Include="Templates\ProjectItems\UserControl\UserControl.Designer.n" />
+ <ZipItem Include="Templates\ProjectItems\UserControl\UserControl.n" />
+
<ZipProject Include="Templates\Projects\WindowsApplication\AssemblyInfo.n" />
<ZipProject Include="Templates\Projects\MacroLibrary\AssemblyInfo.n" />
<ZipProject Include="Templates\Projects\ConsoleApplication\AssemblyInfo.n" />
@@ -298,8 +302,6 @@
<LastGenOutput>Settings.Designer.cs</LastGenOutput>
</None>
<None Include="Resources\Nemerle.ico" />
- <None Include="Templates\ProjectItems\UserControl\UserControl.Designer.n" />
- <None Include="Templates\ProjectItems\UserControl\UserControl.n" />
<EmbeddedResource Include="GUI\AstToolControl.resx">
<SubType>Designer</SubType>
<DependentUpon>AstToolControl.cs</DependentUpon>
More information about the svn
mailing list