Browse Source

Fixed SD2-1017: Generated xml comments do not use text editor line terminator

Fixed SD2-1004: Trying to add a new file to a project throws exception if the projects pad has no selected nodes.

git-svn-id: svn://svn.sharpdevelop.net/sharpdevelop/trunk@1741 1ccf3a8d-04fe-1044-b7c0-cef0b8235c61
shortcuts
Daniel Grunwald 19 years ago
parent
commit
432f63447f
  1. 13
      src/AddIns/BackendBindings/CSharpBinding/Project/Src/FormattingStrategy/CSharpFormattingStrategy.cs
  2. 14
      src/AddIns/BackendBindings/VBNetBinding/Project/Src/FormattingStrategy/VBNetFormattingStrategy.cs
  3. 2
      src/Main/Base/Project/Src/Commands/FileCommands.cs

13
src/AddIns/BackendBindings/CSharpBinding/Project/Src/FormattingStrategy/CSharpFormattingStrategy.cs

@ -311,6 +311,7 @@ namespace CSharpBinding.FormattingStrategy @@ -311,6 +311,7 @@ namespace CSharpBinding.FormattingStrategy
{
LineSegment curLine = textArea.Document.GetLineSegment(lineNr);
LineSegment lineAbove = lineNr > 0 ? textArea.Document.GetLineSegment(lineNr - 1) : null;
string terminator = textArea.TextEditorProperties.LineTerminator;
//// local string for curLine segment
string curLineText="";
@ -322,9 +323,11 @@ namespace CSharpBinding.FormattingStrategy @@ -322,9 +323,11 @@ namespace CSharpBinding.FormattingStrategy
object member = GetMemberAfter(textArea, lineNr);
if (member != null) {
StringBuilder sb = new StringBuilder();
sb.Append(" <summary>\n");
sb.Append(" <summary>");
sb.Append(terminator);
sb.Append(indentation);
sb.Append("/// \n");
sb.Append("/// ");
sb.Append(terminator);
sb.Append(indentation);
sb.Append("/// </summary>");
@ -332,7 +335,7 @@ namespace CSharpBinding.FormattingStrategy @@ -332,7 +335,7 @@ namespace CSharpBinding.FormattingStrategy
IMethod method = (IMethod)member;
if (method.Parameters != null && method.Parameters.Count > 0) {
for (int i = 0; i < method.Parameters.Count; ++i) {
sb.Append("\n");
sb.Append(terminator);
sb.Append(indentation);
sb.Append("/// <param name=\"");
sb.Append(method.Parameters[i].Name);
@ -340,7 +343,7 @@ namespace CSharpBinding.FormattingStrategy @@ -340,7 +343,7 @@ namespace CSharpBinding.FormattingStrategy
}
}
if (method.ReturnType != null && !method.IsConstructor && method.ReturnType.FullyQualifiedName != "System.Void") {
sb.Append("\n");
sb.Append(terminator);
sb.Append(indentation);
sb.Append("/// <returns></returns>");
}
@ -467,7 +470,7 @@ namespace CSharpBinding.FormattingStrategy @@ -467,7 +470,7 @@ namespace CSharpBinding.FormattingStrategy
string oldLineText = TextUtilities.GetLineAsString(textArea.Document, lineNr - 1);
if (oldLineText.EndsWith("{")) {
if (NeedCurlyBracket(textArea.Document.TextContent)) {
textArea.Document.Insert(curLine.Offset + curLine.Length, "\n}");
textArea.Document.Insert(curLine.Offset + curLine.Length, terminator + "}");
IndentLine(textArea, lineNr + 1);
}
}

14
src/AddIns/BackendBindings/VBNetBinding/Project/Src/FormattingStrategy/VBNetFormattingStrategy.cs

@ -254,7 +254,7 @@ namespace VBNetBinding.FormattingStrategy @@ -254,7 +254,7 @@ namespace VBNetBinding.FormattingStrategy
public override int FormatLine(TextArea textArea, int lineNr, int cursorOffset, char ch)
{
string terminator = textArea.TextEditorProperties.LineTerminator;
doCasing = PropertyService.Get("VBBinding.TextEditor.EnableCasing", true);
doInsertion = PropertyService.Get("VBBinding.TextEditor.EnableEndConstructs", true);
@ -274,9 +274,11 @@ namespace VBNetBinding.FormattingStrategy @@ -274,9 +274,11 @@ namespace VBNetBinding.FormattingStrategy
object member = GetMemberAfter(textArea, lineNr);
if (member != null) {
StringBuilder sb = new StringBuilder();
sb.Append(" <summary>\n");
sb.Append(" <summary>");
sb.Append(terminator);
sb.Append(indentation);
sb.Append("''' \n");
sb.Append("''' ");
sb.Append(terminator);
sb.Append(indentation);
sb.Append("''' </summary>");
@ -284,7 +286,7 @@ namespace VBNetBinding.FormattingStrategy @@ -284,7 +286,7 @@ namespace VBNetBinding.FormattingStrategy
IMethod method = (IMethod)member;
if (method.Parameters != null && method.Parameters.Count > 0) {
for (int i = 0; i < method.Parameters.Count; ++i) {
sb.Append("\n");
sb.Append(terminator);
sb.Append(indentation);
sb.Append("''' <param name=\"");
sb.Append(method.Parameters[i].Name);
@ -292,7 +294,7 @@ namespace VBNetBinding.FormattingStrategy @@ -292,7 +294,7 @@ namespace VBNetBinding.FormattingStrategy
}
}
if (method.ReturnType != null && !method.IsConstructor && method.ReturnType.FullyQualifiedName != "System.Void") {
sb.Append("\n");
sb.Append(terminator);
sb.Append(indentation);
sb.Append("''' <returns></returns>");
}
@ -348,7 +350,7 @@ namespace VBNetBinding.FormattingStrategy @@ -348,7 +350,7 @@ namespace VBNetBinding.FormattingStrategy
if (Regex.IsMatch(texttoreplace.Trim(), statement.StartRegex, RegexOptions.IgnoreCase)) {
string indentation = GetIndentation(textArea, lineNr - 1);
if (isEndStatementNeeded(textArea, statement, lineNr)) {
textArea.Document.Insert(textArea.Caret.Offset, "\n" + indentation + statement.EndStatement);
textArea.Document.Insert(textArea.Caret.Offset, terminator + indentation + statement.EndStatement);
++undoCount;
}
for (int i = 0; i < statement.IndentPlus; i++) {

2
src/Main/Base/Project/Src/Commands/FileCommands.cs

@ -25,7 +25,7 @@ namespace ICSharpCode.SharpDevelop.Commands @@ -25,7 +25,7 @@ namespace ICSharpCode.SharpDevelop.Commands
{
public override void Run()
{
if (ProjectService.CurrentProject != null) {
if (ProjectBrowserPad.Instance.CurrentProject != null) {
if (MessageService.ShowCustomDialog("${res:Dialog.NewFile.AddToProjectQuestionTitle}",
"${res:Dialog.NewFile.AddToProjectQuestion}",
"${res:Dialog.NewFile.AddToProjectQuestionProject}",

Loading…
Cancel
Save