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

Loading…
Cancel
Save