[svn] r6543: vs-plugin/trunk:
Nemerle.Compiler.Utils/Nemerle.Compiler.Utils.csproj
Nemerle.Compiler.Utils/...
IT
svnadmin at nemerle.org
Thu Aug 17 04:22:13 CEST 2006
Log:
Finished XML documentation in QT.
Author: IT
Date: Thu Aug 17 04:22:08 2006
New Revision: 6543
Added:
vs-plugin/trunk/Nemerle.Compiler.Utils/Nemerle.Completion2/CodeModel/XmlDocInfo.n
vs-plugin/trunk/Nemerle.Compiler.Utils/Nemerle.Completion2/CodeModel/XmlDocReader.n
Modified:
vs-plugin/trunk/Nemerle.Compiler.Utils/Nemerle.Compiler.Utils.csproj
vs-plugin/trunk/Nemerle.Compiler.Utils/Nemerle.Completion2/CodeModel/QuickTipInfo.n
vs-plugin/trunk/Nemerle.VsIntegration.Tests/ (props changed)
Modified: vs-plugin/trunk/Nemerle.Compiler.Utils/Nemerle.Compiler.Utils.csproj
==============================================================================
--- vs-plugin/trunk/Nemerle.Compiler.Utils/Nemerle.Compiler.Utils.csproj (original)
+++ vs-plugin/trunk/Nemerle.Compiler.Utils/Nemerle.Compiler.Utils.csproj Thu Aug 17 04:22:08 2006
@@ -89,6 +89,10 @@
<ItemGroup>
<Service Include="{B4F97281-0DBD-4835-9ED8-7DFB966E87FF}" />
</ItemGroup>
+ <ItemGroup>
+ <Compile Include="Nemerle.Completion2\CodeModel\XmlDocInfo.n" />
+ <Compile Include="Nemerle.Completion2\CodeModel\XmlDocReader.n" />
+ </ItemGroup>
<Import Project="$(MSBuildBinPath)\Microsoft.CSharp.targets" />
<!-- To modify your build process, add your task inside one of the targets below and uncomment it.
Other similar extension points exist, see Microsoft.Common.targets.
Modified: vs-plugin/trunk/Nemerle.Compiler.Utils/Nemerle.Completion2/CodeModel/QuickTipInfo.n
==============================================================================
--- vs-plugin/trunk/Nemerle.Compiler.Utils/Nemerle.Completion2/CodeModel/QuickTipInfo.n (original)
+++ vs-plugin/trunk/Nemerle.Compiler.Utils/Nemerle.Completion2/CodeModel/QuickTipInfo.n Thu Aug 17 04:22:08 2006
@@ -1,6 +1,4 @@
using System;
-using System.IO;
-using System.Xml;
using Nemerle.Utility;
using Nemerle.Compiler;
@@ -156,63 +154,18 @@
s
}
- private GetDocText(location : Location) : string
+ private GetDocText(mtype : MType, location : Location) : string
{
- ret :
- {
- when (!string.IsNullOrEmpty(location.File) && location.EndLine == 0)
- {
- def name = Path.ChangeExtension(location.File, ".xml");
-
- when (File.Exists(name))
- {
- using (xml = XmlReader.Create(name))
- {
- _ = xml.MoveToContent();
-
- while (xml.Read())
- {
- match (xml.NodeType)
- {
- | XmlNodeType.Element =>
+ def info = XmlDocReader.GetInfo(mtype, location);
- when (xml.Name == "member"
- && xml.MoveToAttribute("name")
- && xml.Value == "T:System.String")
- {
- def getText()
- {
- if (xml.Read())
- match (xml.NodeType)
- {
- | XmlNodeType.Text => xml.Value
- | XmlNodeType.EndElement => ""
- | _ => getText()
- }
- else
- ""
+ if (info != null) "\n" + info.GetText() else ""
}
- mutable summary = "";
-
- while (xml.Read())
- match (xml.NodeType)
+ private GetDocText(member : IMember, location : Location) : string
{
- | XmlNodeType.Element when xml.Name == "summary" => summary = getText()
- | XmlNodeType.EndElement when xml.Name == "member" => ret("\n" + summary);
- | _ => ()
- }
- }
+ def info = XmlDocReader.GetInfo(member, location);
- | _ => ()
- }
- }
- }
- }
- }
-
- ""
- }
+ if (info != null) "\n" + info.GetText() else ""
}
private GetLocationText(location : Location) : string
@@ -257,7 +210,7 @@
| _ => ()
}
- _text += GetLocationText(member.Location);
+ _text += GetDocText(member, member.Location) + GetLocationText(member.Location);
}
private SetText(value : LocalValue) : void
@@ -301,7 +254,7 @@
| Enum => "enum"
}
- _text += " " + tycon.FullName + GetDocText(tycon.Location) + GetLocationText(tycon.Location);
+ _text += " " + tycon.FullName + GetDocText(mtype, tycon.Location) + GetLocationText(tycon.Location);
| _ => _text += mtype.ToString()
}
Added: vs-plugin/trunk/Nemerle.Compiler.Utils/Nemerle.Completion2/CodeModel/XmlDocInfo.n
==============================================================================
--- (empty file)
+++ vs-plugin/trunk/Nemerle.Compiler.Utils/Nemerle.Completion2/CodeModel/XmlDocInfo.n Thu Aug 17 04:22:08 2006
@@ -0,0 +1,32 @@
+using System;
+
+using Nemerle.Utility;
+
+namespace Nemerle.Completion2
+{
+ public class XmlDocInfo
+ {
+ [Accessor(flags=WantSetter)] mutable _summary : string;
+ [Accessor(flags=WantSetter)] mutable _returns : string;
+ [Accessor(flags=WantSetter)] mutable _params : list[string * string] = [];
+ [Accessor(flags=WantSetter)] mutable _exceptions : list[string * string] = [];
+
+ public GetText() : string
+ {
+ mutable s = _summary;
+
+ def toString(list, prefix)
+ {
+ "\n\n" + prefix + ":\n " + list.Map((name, text) => { name + "\n\t" + text }).ToString("\n ");
+ }
+
+ unless (_params. IsEmpty) s += toString(_params, "Parameters");
+ unless (_exceptions.IsEmpty) s += toString(_exceptions, "Exceptions");
+
+ unless (string.IsNullOrEmpty(_returns))
+ s += "\n\nReturn Value:\n\t" + _returns;
+
+ s;
+ }
+ }
+}
Added: vs-plugin/trunk/Nemerle.Compiler.Utils/Nemerle.Completion2/CodeModel/XmlDocReader.n
==============================================================================
--- (empty file)
+++ vs-plugin/trunk/Nemerle.Compiler.Utils/Nemerle.Completion2/CodeModel/XmlDocReader.n Thu Aug 17 04:22:08 2006
@@ -0,0 +1,157 @@
+using System;
+using System.IO;
+using System.Xml;
+
+using Nemerle.Compiler;
+
+namespace Nemerle.Completion2
+{
+ public module XmlDocReader
+ {
+ public GetInfo(mtype : MType, location : Location) : XmlDocInfo
+ {
+ GetInfo("T:" + mtype.TypeInfo.FullName, location);
+ }
+
+ public GetInfo(member: IMember, location : Location) : XmlDocInfo
+ {
+ def name = member.DeclaringType.FullName + "." + member.Name;
+ def key = match (member)
+ {
+ | _ is IProperty => "P:" + name
+ | _ is IField => "F:" + name
+ | mi is IMethod =>
+
+ match (mi.GetMemType())
+ {
+ | Fun(MType.Tuple(args), _) =>
+
+ "M:" + name + "(" + args.Map((tv) =>
+ {
+ | mt is MType => mt.TypeInfo.FullName
+ | _ => ""
+ }).ToString(",") + ")"
+
+ | Fun(MType.Class(ti, _), _) => "M:" + name + "(" + ti.FullName + ")"
+ | Fun(MType.Void, _) => "M:" + name
+ | _ => null
+ }
+
+ | _ => null
+ }
+
+ if (key != null) GetInfo(key, location) else null
+ }
+
+ public GetInfo(key : string, location : Location) : XmlDocInfo
+ {
+ ret :
+ {
+ when (string.IsNullOrEmpty(location.File) || location.EndLine > 0)
+ ret(null);
+
+ def name = Path.ChangeExtension(location.File, ".xml");
+
+ unless (File.Exists(name))
+ ret(null);
+
+ using (xml = XmlReader.Create(name))
+ {
+ def reader = xml;
+ _ = reader.ToString();
+
+ _ = xml.MoveToContent();
+
+ while (xml.Read())
+ {
+ match (xml.NodeType)
+ {
+ | XmlNodeType.Element =>
+
+ when (xml.Name == "member"
+ && xml.MoveToAttribute("name")
+ && xml.Value == key)
+ {
+
+ def getText()
+ {
+ if (xml.Read())
+ {
+ match (xml.NodeType)
+ {
+ | XmlNodeType.Text => xml.Value + getText()
+ | XmlNodeType.EndElement => ""
+ | XmlNodeType.Element =>
+
+ def val = match (xml.Name)
+ {
+ | "see" =>
+
+ if (xml.MoveToAttribute("cref"))
+ {
+ def attr = xml.Value;
+ def text = getText();
+
+ if (string.IsNullOrEmpty(text)) attr.Substring(2) else text
+ }
+ else
+ getText()
+
+ | _ => ""
+ }
+
+ val + getText()
+
+ | _ => getText()
+ }
+ }
+ else
+ ""
+ }
+
+ def info = XmlDocInfo();
+
+ while (xml.Read())
+ {
+ match (xml.NodeType)
+ {
+ | XmlNodeType.Element when xml.Name == "summary" => info.Summary = getText()
+ | XmlNodeType.Element when xml.Name == "returns" => info.Returns = getText()
+ | XmlNodeType.Element when xml.Name == "param" =>
+
+ if (xml.MoveToAttribute("name"))
+ info.Params ::= (xml.Value, getText());
+ else
+ _ = getText()
+
+ | XmlNodeType.Element when xml.Name == "exception" =>
+
+ if (xml.MoveToAttribute("cref"))
+ info.Exceptions ::= (xml.Value.Substring(2), getText());
+ else
+ _ = getText()
+
+ | XmlNodeType.EndElement when xml.Name == "member" =>
+
+ info.Params = info.Params. Rev();
+ info.Exceptions = info.Exceptions.Rev();
+ ret(info);
+
+ | _ => ()
+ }
+ }
+
+ ret(null);
+
+ }
+ | _ => ()
+ }
+ }
+ }
+
+ null
+
+ }
+ }
+ }
+}
More information about the svn
mailing list