Browse Source

SD2-534: Quick XML Doc menu option does nothing; added vb.net support

git-svn-id: svn://svn.sharpdevelop.net/sharpdevelop/trunk@708 1ccf3a8d-04fe-1044-b7c0-cef0b8235c61
shortcuts
Markus Palme 20 years ago
parent
commit
85a90c9cee
  1. 131
      src/Main/Base/Project/Src/TextEditor/Commands/ToolCommands.cs

131
src/Main/Base/Project/Src/TextEditor/Commands/ToolCommands.cs

@ -17,6 +17,7 @@ using System.Diagnostics; @@ -17,6 +17,7 @@ using System.Diagnostics;
using System.Text;
using System.Xml;
using System.Xml.Xsl;
using System.Xml.XPath;
using ICSharpCode.Core;
@ -74,67 +75,77 @@ namespace ICSharpCode.SharpDevelop.DefaultEditor.Commands @@ -74,67 +75,77 @@ namespace ICSharpCode.SharpDevelop.DefaultEditor.Commands
{
public override void Run()
{
// TODO: New Projectfile system.
IWorkbenchWindow window = WorkbenchSingleton.Workbench.ActiveWorkbenchWindow;
if (window == null || !(window.ViewContent is ITextEditorControlProvider)) {
return;
}
TextEditorControl textAreaControl = ((ITextEditorControlProvider)window.ViewContent).TextEditorControl;
int startLine = textAreaControl.Document.GetLineNumberForOffset(textAreaControl.ActiveTextAreaControl.Caret.Offset);
int endLine = startLine;
LineSegment line = textAreaControl.Document.GetLineSegment(startLine);
string curLine = textAreaControl.Document.GetText(line.Offset, line.Length).Trim();
if (!curLine.StartsWith("///") && ! curLine.StartsWith("'@")) {
return;
}
while (startLine > 0) {
line = textAreaControl.Document.GetLineSegment(startLine);
curLine = textAreaControl.Document.GetText(line.Offset, line.Length).Trim();
if (curLine.StartsWith("///") || curLine.StartsWith("'@")) {
--startLine;
} else {
break;
}
}
// IWorkbenchWindow window = WorkbenchSingleton.Workbench.ActiveWorkbenchWindow;
//
// if (window == null || !(window.ViewContent is ITextEditorControlProvider)) {
// return;
// }
// TextEditorControl textAreaControl = ((ITextEditorControlProvider)window.ViewContent).TextEditorControl;
//
// int startLine = textAreaControl.Document.GetLineNumberForOffset(textAreaControl.ActiveTextAreaControl.Caret.Offset);
// int endLine = startLine;
//
// LineSegment line = textAreaControl.Document.GetLineSegment(startLine);
// string curLine = textAreaControl.Document.GetText(line.Offset, line.Length).Trim();
// if (!curLine.StartsWith("///")) {
// return;
// }
//
// while (startLine > 0) {
// line = textAreaControl.Document.GetLineSegment(startLine);
// curLine = textAreaControl.Document.GetText(line.Offset, line.Length).Trim();
// if (curLine.StartsWith("///")) {
// --startLine;
// } else {
// break;
// }
// }
//
// while (endLine < textAreaControl.Document.TotalNumberOfLines - 1) {
// line = textAreaControl.Document.GetLineSegment(endLine);
// curLine = textAreaControl.Document.GetText(line.Offset, line.Length).Trim();
// if (curLine.StartsWith("///")) {
// ++endLine;
// } else {
// break;
// }
// }
//
// StringBuilder documentation = new StringBuilder();
// for (int lineNr = startLine + 1; lineNr < endLine; ++lineNr) {
// line = textAreaControl.Document.GetLineSegment(lineNr);
// curLine = textAreaControl.Document.GetText(line.Offset, line.Length).Trim();
// documentation.Append(curLine.Substring(3));
// documentation.Append('\n');
// }
// string xml = "<member>" + documentation.ToString() + "</member>";
//
// string html = String.Empty;
//
// try {
//
//
// html = ICSharpCode.SharpDevelop.Internal.Project.ConvertXml.ConvertData(xml,
// PropertyService.DataDirectory +
// Path.DirectorySeparatorChar + "ConversionStyleSheets" +
// Path.DirectorySeparatorChar + "ShowXmlDocumentation.xsl",
// null);
// } catch (Exception e) {
// MessageBox.Show(e.ToString());
// }
// new ToolWindowForm(textAreaControl, html).Show();
while (endLine < textAreaControl.Document.TotalNumberOfLines - 1) {
line = textAreaControl.Document.GetLineSegment(endLine);
curLine = textAreaControl.Document.GetText(line.Offset, line.Length).Trim();
if (curLine.StartsWith("///") || curLine.StartsWith("'@")) {
++endLine;
} else {
break;
}
}
StringBuilder documentation = new StringBuilder();
for (int lineNr = startLine + 1; lineNr < endLine; ++lineNr) {
line = textAreaControl.Document.GetLineSegment(lineNr);
curLine = textAreaControl.Document.GetText(line.Offset, line.Length).Trim();
if(curLine.StartsWith("///")) {
documentation.Append(curLine.Substring(3));
}
else
{
documentation.Append(curLine.Substring(2));
}
documentation.Append('\n');
}
string xml = "<member>" + documentation.ToString() + "</member>";
string html = String.Empty;
try
{
XslCompiledTransform t = new XslCompiledTransform();
t.Load(Path.Combine(Path.Combine(PropertyService.DataDirectory, "ConversionStyleSheets"), "ShowXmlDocumentation.xsl"));
XmlDocument doc = new XmlDocument();
doc.LoadXml(xml);
StringBuilder sb = new StringBuilder();
TextWriter textWriter = new StringWriter(sb);
XmlWriter writer = new XmlTextWriter(textWriter);
t.Transform(doc, writer);
html = sb.ToString();
textWriter.Close();
writer.Close();
}
catch (Exception e)
{
MessageBox.Show(e.ToString());
}
new ToolWindowForm(textAreaControl, html).Show();
}
class ToolWindowForm : Form

Loading…
Cancel
Save