Browse Source

fixed SD2-1551

git-svn-id: svn://svn.sharpdevelop.net/sharpdevelop/branches/3.0@4469 1ccf3a8d-04fe-1044-b7c0-cef0b8235c61
shortcuts
Siegfried Pammer 16 years ago
parent
commit
1abebe579b
  1. 31
      src/AddIns/BackendBindings/VBNetBinding/Project/Src/Extensions.cs
  2. 10
      src/AddIns/BackendBindings/VBNetBinding/Project/Src/FormattingStrategy/VBNetFormattingStrategy.cs
  3. 1
      src/AddIns/BackendBindings/VBNetBinding/Project/VBNetBinding.csproj

31
src/AddIns/BackendBindings/VBNetBinding/Project/Src/Extensions.cs

@ -0,0 +1,31 @@ @@ -0,0 +1,31 @@
// <file>
// <copyright see="prj:///doc/copyright.txt"/>
// <license see="prj:///doc/license.txt"/>
// <owner name="Markus Palme" email="MarkusPalme@gmx.de"/>
// <version>$Revision: 4094 $</version>
// </file>
using System;
using System.Collections.Generic;
namespace VBNetBinding
{
public static class Extensions
{
public static T PeekOrDefault<T>(this Stack<T> stack)
{
if (stack.Count > 0)
return stack.Peek();
return default(T);
}
public static T PopOrDefault<T>(this Stack<T> stack)
{
if (stack.Count > 0)
return stack.Pop();
return default(T);
}
}
}

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

@ -637,7 +637,7 @@ namespace VBNetBinding.FormattingStrategy @@ -637,7 +637,7 @@ namespace VBNetBinding.FormattingStrategy
ApplyToRange(textArea, indentation, oldLine, newLine, begin, end);
return indentation.Peek().Length;
return (indentation.PeekOrDefault() ?? string.Empty).Length;
}
int GetLastVisualLine(int line, TextArea area)
@ -652,7 +652,7 @@ namespace VBNetBinding.FormattingStrategy @@ -652,7 +652,7 @@ namespace VBNetBinding.FormattingStrategy
void Unindent(Stack<string> indentation)
{
indentation.Pop();
indentation.PopOrDefault();
}
void Indent(TextArea textArea, Stack<string> indentation)
@ -662,7 +662,7 @@ namespace VBNetBinding.FormattingStrategy @@ -662,7 +662,7 @@ namespace VBNetBinding.FormattingStrategy
string addIndent = (useSpaces) ? new string(' ', indentationSize) : "\t";
indentation.Push(indentation.Peek() + addIndent);
indentation.Push((indentation.PeekOrDefault() ?? string.Empty) + addIndent);
}
bool IsBlockStart(ILexer lexer, Token current, Token prev)
@ -781,7 +781,7 @@ namespace VBNetBinding.FormattingStrategy @@ -781,7 +781,7 @@ namespace VBNetBinding.FormattingStrategy
string noComments = StripComment(lineText).TrimEnd(' ', '\t', '\r', '\n');
if (i < selBegin || i > selEnd) {
indentation.Pop();
indentation.PopOrDefault();
indentation.Push(GetIndentation(textArea, i));
}
@ -791,7 +791,7 @@ namespace VBNetBinding.FormattingStrategy @@ -791,7 +791,7 @@ namespace VBNetBinding.FormattingStrategy
multiLine = false;
}
SmartReplaceLine(textArea.Document, curLine, indentation.Peek() + lineText);
SmartReplaceLine(textArea.Document, curLine, (indentation.PeekOrDefault() ?? string.Empty) + lineText);
// change indentation afterwards (indent next line)
if (!multiLine && noComments.EndsWith("_")) {

1
src/AddIns/BackendBindings/VBNetBinding/Project/VBNetBinding.csproj

@ -50,6 +50,7 @@ @@ -50,6 +50,7 @@
<ItemGroup>
<Compile Include="Configuration\AssemblyInfo.cs" />
<EmbeddedResource Include="Resources\BuildOptions.xfrm" />
<Compile Include="Src\Extensions.cs" />
<Compile Include="Src\FormattingStrategy\VBStatement.cs" />
<Compile Include="Src\VBNetLanguageBinding.cs" />
<Compile Include="Src\FormattingStrategy\VBNetFormattingStrategy.cs" />

Loading…
Cancel
Save