Browse Source

- fixed NUnit reference in SharpRefactoring.Tests

- fixed some FxCop warnings in VBNetBinding

git-svn-id: svn://svn.sharpdevelop.net/sharpdevelop/trunk@6362 1ccf3a8d-04fe-1044-b7c0-cef0b8235c61
pull/1/head
Siegfried Pammer 15 years ago
parent
commit
bd6c8f8193
  1. 14
      src/AddIns/BackendBindings/VBNetBinding/Project/Src/CompletionDataHelper.cs
  2. 1279
      src/AddIns/BackendBindings/VBNetBinding/Project/Src/FormattingStrategy/Parser.cs
  3. 185
      src/AddIns/BackendBindings/VBNetBinding/Project/Src/FormattingStrategy/VBIndentationStrategy.atg
  4. 2
      src/AddIns/BackendBindings/VBNetBinding/Project/Src/FormattingStrategy/VBIndentationStrategy.cs
  5. 163
      src/AddIns/BackendBindings/VBNetBinding/Project/Src/FormattingStrategy/VBNetFormattingStrategy.cs
  6. 43
      src/AddIns/BackendBindings/VBNetBinding/Project/Src/FormattingStrategy/VBStatement.cs
  7. 8
      src/AddIns/BackendBindings/VBNetBinding/Project/Src/MyNamespaceBuilder.cs
  8. 4
      src/AddIns/BackendBindings/VBNetBinding/Project/Src/OptionPanels/ProjectImports.cs
  9. 12
      src/AddIns/BackendBindings/VBNetBinding/Project/Src/Parser/Parser.cs
  10. 9
      src/AddIns/BackendBindings/VBNetBinding/Project/Src/VBNetBracketSearcher.cs
  11. 31
      src/AddIns/BackendBindings/VBNetBinding/Project/Src/VBNetCompletionBinding.cs
  12. 4
      src/AddIns/BackendBindings/VBNetBinding/Project/Src/VBNetProjectBinding.cs
  13. 7
      src/AddIns/BackendBindings/VBNetBinding/Project/Src/VbcEncodingFixingLogger.cs
  14. 2
      src/AddIns/BackendBindings/VBNetBinding/Project/VBNetBinding.addin
  15. 3
      src/AddIns/BackendBindings/VBNetBinding/Test/MockTextEditor.cs
  16. 2
      src/AddIns/Misc/ResourceToolkit/Test/TestHelper.cs
  17. 4
      src/AddIns/Misc/SharpRefactoring/Test/SharpRefactoring.Tests.csproj

14
src/AddIns/BackendBindings/VBNetBinding/Project/Src/CompletionDataHelper.cs

@ -91,7 +91,7 @@ namespace ICSharpCode.VBNetBinding @@ -91,7 +91,7 @@ namespace ICSharpCode.VBNetBinding
HandleKeyword(ref result, resolvedType, word, c, m, editor, pressedKey);
AddSpecialItems(ref result, info, resolvedType, word, m, expressionResult, editor);
AddSpecialItems(ref result, info, resolvedType, m, expressionResult, editor);
if (pressedKey == '\0') { // ctrl+space
char prevChar = editor.Caret.Offset > 0 ? editor.Document.GetCharAt(editor.Caret.Offset - 1) : '\0';
@ -109,7 +109,7 @@ namespace ICSharpCode.VBNetBinding @@ -109,7 +109,7 @@ namespace ICSharpCode.VBNetBinding
static void HandleKeyword(ref VBNetCompletionItemList result, IReturnType resolvedType, string word, IClass c, IMember m, ITextEditor editor, char pressedKey)
{
if (pressedKey == ' ') {
if (word.Equals("return", StringComparison.InvariantCultureIgnoreCase) && m != null) {
if (word.Equals("return", StringComparison.OrdinalIgnoreCase) && m != null) {
c = m.ReturnType != null ? m.ReturnType.GetUnderlyingClass() : null;
if (c != null) {
foreach (CodeCompletionItem item in result.Items.OfType<CodeCompletionItem>()) {
@ -122,13 +122,13 @@ namespace ICSharpCode.VBNetBinding @@ -122,13 +122,13 @@ namespace ICSharpCode.VBNetBinding
}
}
if (word.Equals("overrides", StringComparison.InvariantCultureIgnoreCase) && c != null) {
if (word.Equals("overrides", StringComparison.OrdinalIgnoreCase) && c != null) {
result = new OverrideCompletionItemProvider().GenerateCompletionList(editor).ToVBCCList();
}
}
}
static void AddSpecialItems(ref VBNetCompletionItemList result, ParseInformation info, IReturnType resolvedType, string word, IMember m, ExpressionResult expressionResult, ITextEditor editor)
static void AddSpecialItems(ref VBNetCompletionItemList result, ParseInformation info, IReturnType resolvedType, IMember m, ExpressionResult expressionResult, ITextEditor editor)
{
if (expressionResult.Context == ExpressionContext.Type && m != null && m.BodyRegion.IsInside(editor.Caret.Line, editor.Caret.Column)) {
result.Items.Add(new DefaultCompletionItem("? =") {
@ -210,11 +210,11 @@ namespace ICSharpCode.VBNetBinding @@ -210,11 +210,11 @@ namespace ICSharpCode.VBNetBinding
static bool FitsToContext(ICompletionItem item, List<ICompletionItem> list)
{
if (!(item is ISnippetCompletionItem))
return false;
var snippetItem = item as ISnippetCompletionItem;
if (snippetItem == null)
return false;
if (string.IsNullOrEmpty(snippetItem.Keyword))
return true;

1279
src/AddIns/BackendBindings/VBNetBinding/Project/Src/FormattingStrategy/Parser.cs

File diff suppressed because it is too large Load Diff

185
src/AddIns/BackendBindings/VBNetBinding/Project/Src/FormattingStrategy/VBIndentationStrategy.atg

@ -597,190 +597,7 @@ TypeName = ( "Global" | ident | PrimitiveTypeName | "?" /* used for ? = completi @@ -597,190 +597,7 @@ TypeName = ( "Global" | ident | PrimitiveTypeName | "?" /* used for ? = completi
TypeSuffix = "(" ( "Of" [ TypeName ] { "," [ TypeName ] } | [ ArgumentList ] ) ")" .
IdentifierOrKeyword = ident
| "AddHandler"
| "AddressOf"
| "Aggregate"
| "Alias"
| "And"
| "AndAlso"
| "Ansi"
| "As"
| "Ascending"
| "Assembly"
| "Auto"
| "Binary"
| "Boolean"
| "ByRef"
| "By"
| "Byte"
| "ByVal"
| "Call"
| "Case"
| "Catch"
| "CBool"
| "CByte"
| "CChar"
| "CDate"
| "CDbl"
| "CDec"
| "Char"
| "CInt"
| "Class"
| "CLng"
| "CObj"
| "Compare"
| "Const"
| "Continue"
| "CSByte"
| "CShort"
| "CSng"
| "CStr"
| "CType"
| "CUInt"
| "CULng"
| "CUShort"
| "Custom"
| "Date"
| "Decimal"
| "Declare"
| "Default"
| "Delegate"
| "Descending"
| "Dim"
| "DirectCast"
| "Distinct"
| "Do"
| "Double"
| "Each"
| "Else"
| "ElseIf"
| "End"
| "EndIf"
| "Enum"
| "Equals"
| "Erase"
| "Error"
| "Event"
| "Exit"
| "Explicit"
| "False"
| "Finally"
| "For"
| "Friend"
| "From"
| "Function"
| "Get"
| "GetType"
| "Global"
| "GoSub"
| "GoTo"
| "Group"
| "Handles"
| "If"
| "Implements"
| "Imports"
| "In"
| "Infer"
| "Inherits"
| "Integer"
| "Interface"
| "Into"
| "Is"
| "IsNot"
| "Join"
| "Key"
| "Let"
| "Lib"
| "Like"
| "Long"
| "Loop"
| "Me"
| "Mod"
| "Module"
| "MustInherit"
| "MustOverride"
| "MyBase"
| "MyClass"
| "Namespace"
| "Narrowing"
| "New"
| "Next"
| "Not"
| "Nothing"
| "NotInheritable"
| "NotOverridable"
| "Object"
| "Of"
| "Off"
| "On"
| "Operator"
| "Option"
| "Optional"
| "Or"
| "Order"
| "OrElse"
| "Out"
| "Overloads"
| "Overridable"
| "Overrides"
| "ParamArray"
| "Partial"
| "Preserve"
| "Private"
| "Property"
| "Protected"
| "Public"
| "RaiseEvent"
| "ReadOnly"
| "ReDim"
| "Rem"
| "RemoveHandler"
| "Resume"
| "Return"
| "SByte"
| "Select"
| "Set"
| "Shadows"
| "Shared"
| "Short"
| "Single"
| "Skip"
| "Static"
| "Step"
| "Stop"
| "Strict"
| "String"
| "Structure"
| "Sub"
| "SyncLock"
| "Take"
| "Text"
| "Then"
| "Throw"
| "To"
| "True"
| "Try"
| "TryCast"
| "TypeOf"
| "UInteger"
| "ULong"
| "Unicode"
| "Until"
| "UShort"
| "Using"
| "Variant"
| "Wend"
| "When"
| "Where"
| "While"
| "Widening"
| "With"
| "WithEvents"
| "WriteOnly"
| "Xor"
| "GetXmlNamespace"
.
IdentifierOrKeyword = ANY .
Statement =
VariableDeclarationStatement

2
src/AddIns/BackendBindings/VBNetBinding/Project/Src/FormattingStrategy/VBIndentationStrategy.cs

@ -9,7 +9,7 @@ using System.Collections.Generic; @@ -9,7 +9,7 @@ using System.Collections.Generic;
using ICSharpCode.NRefactory.Parser;
using ICSharpCode.SharpDevelop.Editor;
namespace ICSharpCode.VBNetBinding.FormattingStrategy
namespace ICSharpCode.VBNetBinding
{
/// <summary>
/// Description of VBIndentationStrategy.

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

@ -33,7 +33,48 @@ namespace ICSharpCode.VBNetBinding @@ -33,7 +33,48 @@ namespace ICSharpCode.VBNetBinding
get { return statements; }
}
static readonly IList<string> keywords;
static readonly string[] keywords = new string[] {
"AddHandler", "AddressOf", "Alias", "And",
"AndAlso", "As", "Boolean", "ByRef",
"Byte", "ByVal", "Call", "Case",
"Catch", "CBool", "CByte", "CChar",
"CDate", "CDbl", "CDec", "Char",
"CInt", "Class", "CLng", "CObj",
"Const", "Continue", "CSByte", "CShort",
"CSng", "CStr", "CType", "CUInt",
"CULng", "CUShort", "Date", "Decimal",
"Declare", "Default", "Delegate", "Dim",
"DirectCast", "Do", "Double", "Each",
"Else", "ElseIf", "End", "EndIf", // EndIf special case: converted to "End If"
"Enum", "Erase", "Error", "Event",
"Exit", "False", "Finally", "For",
"Friend", "Function", "Get", "GetType",
"Global", "GoSub", "GoTo", "Handles",
"If", "Implements", "Imports", "In",
"Inherits", "Integer", "Interface", "Is",
"IsNot", "Let", "Lib", "Like",
"Long", "Loop", "Me", "Mod",
"Module", "MustInherit", "MustOverride", "MyBase",
"MyClass", "Namespace", "Narrowing", "New",
"Next", "Not", "Nothing", "NotInheritable",
"NotOverridable", "Object", "Of", "On",
"Operator", "Option", "Optional", "Or",
"OrElse", "Overloads", "Overridable", "Overrides",
"ParamArray", "Partial", "Private", "Property",
"Protected", "Public", "RaiseEvent", "ReadOnly",
"ReDim", "REM", "RemoveHandler", "Resume",
"Return", "SByte", "Select", "Set",
"Shadows", "Shared", "Short", "Single",
"Static", "Step", "Stop", "String",
"Structure", "Sub", "SyncLock", "Then",
"Throw", "To", "True", "Try",
"TryCast", "TypeOf", "UInteger", "ULong",
"UShort", "Using", "Variant", "Wend",
"When", "While", "Widening", "With",
"WithEvents", "WriteOnly", "Xor",
// these are not keywords, but context dependend
"Until", "Ansi", "Unicode", "Region", "Preserve"
};
internal static IList<string> Keywords {
get { return keywords; }
@ -79,49 +120,6 @@ namespace ICSharpCode.VBNetBinding @@ -79,49 +120,6 @@ namespace ICSharpCode.VBNetBinding
statements.Add(interfaceStatement);
statements.Add(new VBStatement(@"\busing\s+", "^end using$", "End Using", 1, Tokens.Using));
statements.Add(new VBStatement(@"^#region\s+", "^#end region$", "#End Region", 0, -1));
keywords = new string[] {
"AddHandler", "AddressOf", "Alias", "And",
"AndAlso", "As", "Boolean", "ByRef",
"Byte", "ByVal", "Call", "Case",
"Catch", "CBool", "CByte", "CChar",
"CDate", "CDbl", "CDec", "Char",
"CInt", "Class", "CLng", "CObj",
"Const", "Continue", "CSByte", "CShort",
"CSng", "CStr", "CType", "CUInt",
"CULng", "CUShort", "Date", "Decimal",
"Declare", "Default", "Delegate", "Dim",
"DirectCast", "Do", "Double", "Each",
"Else", "ElseIf", "End", "EndIf", // EndIf special case: converted to "End If"
"Enum", "Erase", "Error", "Event",
"Exit", "False", "Finally", "For",
"Friend", "Function", "Get", "GetType",
"Global", "GoSub", "GoTo", "Handles",
"If", "Implements", "Imports", "In",
"Inherits", "Integer", "Interface", "Is",
"IsNot", "Let", "Lib", "Like",
"Long", "Loop", "Me", "Mod",
"Module", "MustInherit", "MustOverride", "MyBase",
"MyClass", "Namespace", "Narrowing", "New",
"Next", "Not", "Nothing", "NotInheritable",
"NotOverridable", "Object", "Of", "On",
"Operator", "Option", "Optional", "Or",
"OrElse", "Overloads", "Overridable", "Overrides",
"ParamArray", "Partial", "Private", "Property",
"Protected", "Public", "RaiseEvent", "ReadOnly",
"ReDim", "REM", "RemoveHandler", "Resume",
"Return", "SByte", "Select", "Set",
"Shadows", "Shared", "Short", "Single",
"Static", "Step", "Stop", "String",
"Structure", "Sub", "SyncLock", "Then",
"Throw", "To", "True", "Try",
"TryCast", "TypeOf", "UInteger", "ULong",
"UShort", "Using", "Variant", "Wend",
"When", "While", "Widening", "With",
"WithEvents", "WriteOnly", "Xor",
// these are not keywords, but context dependend
"Until", "Ansi", "Unicode", "Region", "Preserve"
};
}
public override void FormatLine(ITextEditor editor, char charTyped)
@ -144,7 +142,7 @@ namespace ICSharpCode.VBNetBinding @@ -144,7 +142,7 @@ namespace ICSharpCode.VBNetBinding
string lineAboveText = lineAbove == null ? "" : lineAbove.Text;
if (ch == '\'') {
InsertDocumentationComments(editor, lineNr, cursorOffset, ch);
InsertDocumentationComments(editor, lineNr, cursorOffset);
}
if (ch == '\n' && lineAboveText != null)
@ -196,10 +194,10 @@ namespace ICSharpCode.VBNetBinding @@ -196,10 +194,10 @@ namespace ICSharpCode.VBNetBinding
commentBuilder.Append(curLineText[ i]);
}
string tag = commentBuilder.ToString().Trim();
if (!tag.EndsWith(">")) {
if (!tag.EndsWith(">", StringComparison.OrdinalIgnoreCase)) {
tag += ">";
}
if (!tag.StartsWith("/")) {
if (!tag.StartsWith("/", StringComparison.OrdinalIgnoreCase)) {
editor.Document.Insert(editor.Caret.Offset, "</" + tag.Substring(1));
}
}
@ -262,7 +260,7 @@ namespace ICSharpCode.VBNetBinding @@ -262,7 +260,7 @@ namespace ICSharpCode.VBNetBinding
}
}
void DoCasingOnLine(IDocumentLine lineAbove, string textToReplace, ITextEditor editor)
static void DoCasingOnLine(IDocumentLine lineAbove, string textToReplace, ITextEditor editor)
{
foreach (string keyword in keywords) {
string regex = "\\b" + keyword + "\\b"; // \b = word border
@ -276,7 +274,7 @@ namespace ICSharpCode.VBNetBinding @@ -276,7 +274,7 @@ namespace ICSharpCode.VBNetBinding
}
}
void InsertDocumentationComments(ITextEditor editor, int lineNr, int cursorOffset, char ch)
static void InsertDocumentationComments(ITextEditor editor, int lineNr, int cursorOffset)
{
string terminator = DocumentUtilitites.GetLineTerminator(editor.Document, lineNr);
@ -286,7 +284,7 @@ namespace ICSharpCode.VBNetBinding @@ -286,7 +284,7 @@ namespace ICSharpCode.VBNetBinding
string curLineText = currentLine.Text;
string lineAboveText = previousLine == null ? null : previousLine.Text;
if (curLineText != null && curLineText.EndsWith("'''") && (lineAboveText == null || !lineAboveText.Trim().StartsWith("'''"))) {
if (curLineText != null && curLineText.EndsWith("'''", StringComparison.OrdinalIgnoreCase) && (lineAboveText == null || !lineAboveText.Trim().StartsWith("'''", StringComparison.OrdinalIgnoreCase))) {
string indentation = DocumentUtilitites.GetWhitespaceAfter(editor.Document, currentLine.Offset);
object member = GetMemberAfter(editor, lineNr);
if (member != null) {
@ -321,7 +319,7 @@ namespace ICSharpCode.VBNetBinding @@ -321,7 +319,7 @@ namespace ICSharpCode.VBNetBinding
}
}
bool LookForEndRegion(ITextEditor editor)
static bool LookForEndRegion(ITextEditor editor)
{
string lineText = editor.Document.GetLine(1).Text;
int count = 0;
@ -339,7 +337,7 @@ namespace ICSharpCode.VBNetBinding @@ -339,7 +337,7 @@ namespace ICSharpCode.VBNetBinding
return (count > 0);
}
bool IsInsideInterface(ITextEditor editor, int lineNr)
static bool IsInsideInterface(ITextEditor editor, int lineNr)
{
ILexer lexer = ParserFactory.CreateLexer(SupportedLanguage.VBNet, new StringReader(editor.Document.Text));
@ -379,20 +377,7 @@ namespace ICSharpCode.VBNetBinding @@ -379,20 +377,7 @@ namespace ICSharpCode.VBNetBinding
return false;
}
bool IsElseConstruct(string line)
{
string t = StripComment(line);
if (t.StartsWith("case ", StringComparison.OrdinalIgnoreCase)) return true;
if (string.Compare(t, "else", true) == 0 ||
t.StartsWith("elseif ", StringComparison.OrdinalIgnoreCase)) return true;
if (string.Compare(t, "catch", true) == 0 ||
t.StartsWith("catch ", StringComparison.OrdinalIgnoreCase)) return true;
if (string.Compare(t, "finally", true) == 0) return true;
return false;
}
bool IsInString(string start)
static bool IsInString(string start)
{
bool inString = false;
for (int i = 0; i < start.Length; i++) {
@ -404,7 +389,7 @@ namespace ICSharpCode.VBNetBinding @@ -404,7 +389,7 @@ namespace ICSharpCode.VBNetBinding
return inString;
}
bool IsFinishedString(string end)
static bool IsFinishedString(string end)
{
bool inString = true;
for (int i = 0; i < end.Length; i++) {
@ -467,7 +452,7 @@ namespace ICSharpCode.VBNetBinding @@ -467,7 +452,7 @@ namespace ICSharpCode.VBNetBinding
return false;
}
Token GetClosestMissing(List<Token> missingEnds, VBStatement statement, ITextEditor editor, int lineNr)
static Token GetClosestMissing(List<Token> missingEnds, VBStatement statement, ITextEditor editor, int lineNr)
{
Token closest = null;
int diff = 0;
@ -488,7 +473,7 @@ namespace ICSharpCode.VBNetBinding @@ -488,7 +473,7 @@ namespace ICSharpCode.VBNetBinding
return closest;
}
bool IsSingleLine(int line, ITextEditor editor)
static bool IsSingleLine(int line, ITextEditor editor)
{
if (line < 1)
return false;
@ -500,7 +485,7 @@ namespace ICSharpCode.VBNetBinding @@ -500,7 +485,7 @@ namespace ICSharpCode.VBNetBinding
string text = lineSeg.Text;
if (StripComment(text).Trim(' ', '\t', '\r', '\n').EndsWith("_"))
if (StripComment(text).Trim(' ', '\t', '\r', '\n').EndsWith("_", StringComparison.OrdinalIgnoreCase))
return true;
else
return false;
@ -520,26 +505,26 @@ namespace ICSharpCode.VBNetBinding @@ -520,26 +505,26 @@ namespace ICSharpCode.VBNetBinding
return false;
}
bool IsMatchingStatement(Token token, VBStatement statement)
static bool IsMatchingStatement(Token token, VBStatement statement)
{
if (token.Kind == Tokens.For && statement.EndStatement == "Next")
return true;
if (token.Kind == Tokens.Do && statement.EndStatement.StartsWith("Loop"))
if (token.Kind == Tokens.Do && statement.EndStatement.StartsWith("Loop", StringComparison.OrdinalIgnoreCase))
return true;
bool empty = !string.IsNullOrEmpty(token.Value);
bool match = statement.EndStatement.IndexOf(token.Value, StringComparison.InvariantCultureIgnoreCase) != -1;
bool match = statement.EndStatement.IndexOf(token.Value, StringComparison.OrdinalIgnoreCase) != -1;
return empty && match;
}
string StripComment(string text)
static string StripComment(string text)
{
return Regex.Replace(text, "'.*$", "", RegexOptions.Singleline).Trim();
}
bool IsInsideDocumentationComment(ITextEditor editor, IDocumentLine curLine, int cursorOffset)
static bool IsInsideDocumentationComment(ITextEditor editor, IDocumentLine curLine, int cursorOffset)
{
for (int i = curLine.Offset; i < cursorOffset; ++i) {
char ch = editor.Document.GetCharAt(i);
@ -559,7 +544,7 @@ namespace ICSharpCode.VBNetBinding @@ -559,7 +544,7 @@ namespace ICSharpCode.VBNetBinding
SmartIndentInternal(editor, begin, end);
}
int SmartIndentInternal(ITextEditor editor, int begin, int end)
static int SmartIndentInternal(ITextEditor editor, int begin, int end)
{
ILexer lexer = ParserFactory.CreateLexer(SupportedLanguage.VBNet, new StringReader(editor.Document.Text));
@ -640,7 +625,7 @@ namespace ICSharpCode.VBNetBinding @@ -640,7 +625,7 @@ namespace ICSharpCode.VBNetBinding
return (indentation.PeekOrDefault() ?? string.Empty).Length;
}
int GetLastVisualLine(int line, ITextEditor area)
static int GetLastVisualLine(int line, ITextEditor area)
{
string text = StripComment(area.Document.GetLine(line).Text);
while (text.EndsWith("_", StringComparison.Ordinal)) {
@ -650,12 +635,12 @@ namespace ICSharpCode.VBNetBinding @@ -650,12 +635,12 @@ namespace ICSharpCode.VBNetBinding
return line;
}
void Unindent(Stack<string> indentation)
static void Unindent(Stack<string> indentation)
{
indentation.PopOrDefault();
}
void Indent(ITextEditor editor, Stack<string> indentation)
static void Indent(ITextEditor editor, Stack<string> indentation)
{
indentation.Push((indentation.PeekOrDefault() ?? string.Empty) + editor.Options.IndentationString);
}
@ -766,7 +751,7 @@ namespace ICSharpCode.VBNetBinding @@ -766,7 +751,7 @@ namespace ICSharpCode.VBNetBinding
return false;
}
void ApplyToRange(ITextEditor editor, Stack<string> indentation, int begin, int end, int selBegin, int selEnd)
static void ApplyToRange(ITextEditor editor, Stack<string> indentation, int begin, int end, int selBegin, int selEnd)
{
bool multiLine = false;
@ -781,7 +766,7 @@ namespace ICSharpCode.VBNetBinding @@ -781,7 +766,7 @@ namespace ICSharpCode.VBNetBinding
}
// change indentation before (indent this line)
if (multiLine && noComments.EndsWith("}")) {
if (multiLine && noComments.EndsWith("}", StringComparison.OrdinalIgnoreCase)) {
Unindent(indentation);
multiLine = false;
}
@ -789,32 +774,22 @@ namespace ICSharpCode.VBNetBinding @@ -789,32 +774,22 @@ namespace ICSharpCode.VBNetBinding
editor.Document.SmartReplaceLine(curLine, (indentation.PeekOrDefault() ?? string.Empty) + lineText);
// change indentation afterwards (indent next line)
if (!multiLine && noComments.EndsWith("_")) {
if (!multiLine && noComments.EndsWith("_", StringComparison.OrdinalIgnoreCase)) {
Indent(editor, indentation);
multiLine = true;
}
if (multiLine && !noComments.EndsWith("_")) {
if (multiLine && !noComments.EndsWith("_", StringComparison.OrdinalIgnoreCase)) {
multiLine = false;
Unindent(indentation);
}
}
}
static bool IsStatement(string text)
{
foreach (VBStatement s in statements) {
if (Regex.IsMatch(text, s.StartRegex, RegexOptions.IgnoreCase))
return true;
}
return false;
}
/// <summary>
/// Gets the next member after the specified caret position.
/// </summary>
object GetMemberAfter(ITextEditor editor, int caretLine)
static object GetMemberAfter(ITextEditor editor, int caretLine)
{
string fileName = editor.FileName;
object nextElement = null;

43
src/AddIns/BackendBindings/VBNetBinding/Project/Src/FormattingStrategy/VBStatement.cs

@ -13,12 +13,35 @@ namespace ICSharpCode.VBNetBinding @@ -13,12 +13,35 @@ namespace ICSharpCode.VBNetBinding
{
public class VBStatement
{
public string StartRegex = "";
public string EndRegex = "";
public string EndStatement = "";
string startRegex = "";
public int StatementToken = 0;
public int IndentPlus = 0;
public string StartRegex {
get { return startRegex; }
}
string endRegex = "";
public string EndRegex {
get { return endRegex; }
}
string endStatement = "";
public string EndStatement {
get { return endStatement; }
}
int statementToken = 0;
public int StatementToken {
get { return statementToken; }
}
int indentPlus = 0;
public int IndentPlus {
get { return indentPlus; }
}
public VBStatement()
{
@ -26,11 +49,11 @@ namespace ICSharpCode.VBNetBinding @@ -26,11 +49,11 @@ namespace ICSharpCode.VBNetBinding
public VBStatement(string startRegex, string endRegex, string endStatement, int indentPlus, int statementToken)
{
StartRegex = startRegex;
EndRegex = endRegex;
EndStatement = endStatement;
IndentPlus = indentPlus;
StatementToken = statementToken;
this.startRegex = startRegex;
this.endRegex = endRegex;
this.endStatement = endStatement;
this.indentPlus = indentPlus;
this.statementToken = statementToken;
}
}
}

8
src/AddIns/BackendBindings/VBNetBinding/Project/Src/MyNamespaceBuilder.cs

@ -27,14 +27,14 @@ namespace ICSharpCode.VBNetBinding @@ -27,14 +27,14 @@ namespace ICSharpCode.VBNetBinding
else
ns = project.RootNamespace + ".My";
IClass myApp = CreateMyApplication(cu, project, ns);
IClass myComp = CreateMyComputer(cu, project, ns);
IClass myComp = CreateMyComputer(cu, ns);
cu.Classes.Add(myApp);
cu.Classes.Add(myComp);
IClass myForms = null;
if (project.OutputType == OutputType.WinExe) {
myForms = CreateMyForms(cu, project, ns);
myForms = CreateMyForms(cu, ns);
cu.Classes.Add(myForms);
}
DefaultClass c = new DefaultClass(cu, ns + ".MyProject");
@ -105,7 +105,7 @@ namespace ICSharpCode.VBNetBinding @@ -105,7 +105,7 @@ namespace ICSharpCode.VBNetBinding
return new GetClassReturnType(cu.ProjectContent, fullName, 0);
}
static IClass CreateMyComputer(ICompilationUnit cu, IProject project, string ns)
static IClass CreateMyComputer(ICompilationUnit cu, string ns)
{
DefaultClass c = new DefaultClass(cu, ns + ".MyComputer");
c.ClassType = ClassType.Class;
@ -115,7 +115,7 @@ namespace ICSharpCode.VBNetBinding @@ -115,7 +115,7 @@ namespace ICSharpCode.VBNetBinding
return c;
}
static IClass CreateMyForms(ICompilationUnit cu, IProject project, string ns)
static IClass CreateMyForms(ICompilationUnit cu, string ns)
{
DefaultClass c = new MyFormsClass(cu, ns + ".MyForms");
c.ClassType = ClassType.Class;

4
src/AddIns/BackendBindings/VBNetBinding/Project/Src/OptionPanels/ProjectImports.cs

@ -52,7 +52,7 @@ namespace ICSharpCode.VBNetBinding.OptionPanels @@ -52,7 +52,7 @@ namespace ICSharpCode.VBNetBinding.OptionPanels
private void AddNamespaces(IProjectContent projectContent)
{
foreach(string projectNamespace in projectContent.NamespaceNames) {
if (projectNamespace != "") {
if (!string.IsNullOrEmpty(projectNamespace)) {
if (!Get<ComboBox>("namespaces").Items.Contains(projectNamespace)) {
Get<ComboBox>("namespaces").Items.Add(projectNamespace);
}
@ -62,7 +62,7 @@ namespace ICSharpCode.VBNetBinding.OptionPanels @@ -62,7 +62,7 @@ namespace ICSharpCode.VBNetBinding.OptionPanels
private void namespacesComboBox_TextCanged(object sender, EventArgs e)
{
Get<Button>("addImport").Enabled = Get<ComboBox>("namespaces").Text != "" &&
Get<Button>("addImport").Enabled = !string.IsNullOrEmpty(Get<ComboBox>("namespaces").Text) &&
! Get<ListBox>("imports").Items.Contains(Get<ComboBox>("namespaces").Text);
}

12
src/AddIns/BackendBindings/VBNetBinding/Project/Src/Parser/Parser.cs

@ -13,7 +13,7 @@ using ICSharpCode.SharpDevelop.Dom.NRefactoryResolver; @@ -13,7 +13,7 @@ using ICSharpCode.SharpDevelop.Dom.NRefactoryResolver;
using ICSharpCode.SharpDevelop.Dom.VBNet;
using ICSharpCode.SharpDevelop.Project;
namespace ICSharpCode.VBNetBinding.Parser
namespace ICSharpCode.VBNetBinding
{
public class TParser : IParser
{
@ -50,7 +50,7 @@ namespace ICSharpCode.VBNetBinding.Parser @@ -50,7 +50,7 @@ namespace ICSharpCode.VBNetBinding.Parser
return project.Language == "VBNet";
}
void RetrieveRegions(ICompilationUnit cu, ICSharpCode.NRefactory.Parser.SpecialTracker tracker)
static void RetrieveRegions(ICompilationUnit cu, ICSharpCode.NRefactory.Parser.SpecialTracker tracker)
{
for (int i = 0; i < tracker.CurrentSpecials.Count; ++i)
{
@ -65,12 +65,12 @@ namespace ICSharpCode.VBNetBinding.Parser @@ -65,12 +65,12 @@ namespace ICSharpCode.VBNetBinding.Parser
ICSharpCode.NRefactory.PreprocessingDirective nextDirective = tracker.CurrentSpecials[j] as ICSharpCode.NRefactory.PreprocessingDirective;
if (nextDirective != null)
{
switch (nextDirective.Cmd.ToLowerInvariant())
switch (nextDirective.Cmd.ToUpperInvariant())
{
case "#region":
case "#REGION":
++deep;
break;
case "#end":
case "#END":
if (nextDirective.Arg.Equals("region", StringComparison.OrdinalIgnoreCase)) {
--deep;
if (deep == 0) {
@ -115,7 +115,7 @@ namespace ICSharpCode.VBNetBinding.Parser @@ -115,7 +115,7 @@ namespace ICSharpCode.VBNetBinding.Parser
return visitor.Cu;
}
void AddCommentTags(ICompilationUnit cu, System.Collections.Generic.List<ICSharpCode.NRefactory.Parser.TagComment> tagComments)
static void AddCommentTags(ICompilationUnit cu, System.Collections.Generic.List<ICSharpCode.NRefactory.Parser.TagComment> tagComments)
{
foreach (ICSharpCode.NRefactory.Parser.TagComment tagComment in tagComments)
{

9
src/AddIns/BackendBindings/VBNetBinding/Project/Src/VBNetBracketSearcher.cs

@ -60,7 +60,7 @@ namespace ICSharpCode.VBNetBinding @@ -60,7 +60,7 @@ namespace ICSharpCode.VBNetBinding
}
#region bracket search
int SearchBracketBackward(IDocument document, int offset, char openBracket, char closingBracket)
static int SearchBracketBackward(IDocument document, int offset, char openBracket, char closingBracket)
{
bool inString = false;
char ch;
@ -110,7 +110,7 @@ namespace ICSharpCode.VBNetBinding @@ -110,7 +110,7 @@ namespace ICSharpCode.VBNetBinding
return 0;
}
int SearchBracketForward(IDocument document, int offset, char openBracket, char closingBracket)
static int SearchBracketForward(IDocument document, int offset, char openBracket, char closingBracket)
{
bool inString = false;
bool inComment = false;
@ -231,10 +231,5 @@ namespace ICSharpCode.VBNetBinding @@ -231,10 +231,5 @@ namespace ICSharpCode.VBNetBinding
return -1;
}
#endregion
static bool IsDeclaration(int kind)
{
return kind == Tokens.Sub || kind == Tokens.Function || kind == Tokens.Operator || VBNetFormattingStrategy.IsDeclaration(kind);
}
}
}

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

@ -108,7 +108,7 @@ namespace ICSharpCode.VBNetBinding @@ -108,7 +108,7 @@ namespace ICSharpCode.VBNetBinding
result = ef.FindExpression(editor.Document.Text, editor.Caret.Offset);
string word = editor.GetWordBeforeCaret().Trim();
if (word.Equals("overrides", StringComparison.InvariantCultureIgnoreCase) || word.Equals("return", StringComparison.InvariantCultureIgnoreCase) || !LiteralMayFollow((BitArray)result.Tag) && !OperatorMayFollow((BitArray)result.Tag) && ExpressionContext.IdentifierExpected != result.Context) {
if (word.Equals("overrides", StringComparison.OrdinalIgnoreCase) || word.Equals("return", StringComparison.OrdinalIgnoreCase) || !LiteralMayFollow((BitArray)result.Tag) && !OperatorMayFollow((BitArray)result.Tag) && ExpressionContext.IdentifierExpected != result.Context) {
LoggingService.Debug("CC: After space, result=" + result + ", context=" + result.Context);
ShowCompletion(result, editor, ch);
}
@ -158,7 +158,7 @@ namespace ICSharpCode.VBNetBinding @@ -158,7 +158,7 @@ namespace ICSharpCode.VBNetBinding
return ef.ActiveArgument;
}
bool IsTypeCharacter(char ch, char prevChar)
static bool IsTypeCharacter(char ch, char prevChar)
{
ch = char.ToUpperInvariant(ch);
@ -176,7 +176,7 @@ namespace ICSharpCode.VBNetBinding @@ -176,7 +176,7 @@ namespace ICSharpCode.VBNetBinding
return false;
}
void ShowCompletion(ExpressionResult result, ITextEditor editor, char ch)
static void ShowCompletion(ExpressionResult result, ITextEditor editor, char ch)
{
VBNetCompletionItemList list = CompletionDataHelper.GenerateCompletionData(result, editor, ch);
list.Editor = editor;
@ -184,7 +184,7 @@ namespace ICSharpCode.VBNetBinding @@ -184,7 +184,7 @@ namespace ICSharpCode.VBNetBinding
}
#region Helpers
bool OperatorMayFollow(BitArray array)
static bool OperatorMayFollow(BitArray array)
{
if (array == null)
return false;
@ -192,7 +192,7 @@ namespace ICSharpCode.VBNetBinding @@ -192,7 +192,7 @@ namespace ICSharpCode.VBNetBinding
return array[Tokens.Xor];
}
bool LiteralMayFollow(BitArray array)
static bool LiteralMayFollow(BitArray array)
{
if (array == null)
return false;
@ -205,20 +205,7 @@ namespace ICSharpCode.VBNetBinding @@ -205,20 +205,7 @@ namespace ICSharpCode.VBNetBinding
return false;
}
bool HasKeywordsOnly(BitArray array)
{
if (array == null)
return false;
for (int i = 0; i < array.Length; i++) {
if (array[i] && i < Tokens.AddHandler)
return false;
}
return true;
}
void GetCommentOrStringState(ITextEditor editor, out bool inString, out bool inComment)
static void GetCommentOrStringState(ITextEditor editor, out bool inString, out bool inComment)
{
ILexer lexer = ParserFactory.CreateLexer(SupportedLanguage.VBNet, editor.Document.CreateReader());
@ -256,14 +243,14 @@ namespace ICSharpCode.VBNetBinding @@ -256,14 +243,14 @@ namespace ICSharpCode.VBNetBinding
}
}
bool IsInString(ITextEditor editor)
static bool IsInString(ITextEditor editor)
{
bool inString, inComment;
GetCommentOrStringState(editor, out inString, out inComment);
return inString;
}
bool IsInComment(ITextEditor editor)
static bool IsInComment(ITextEditor editor)
{
bool inString, inComment;
GetCommentOrStringState(editor, out inString, out inComment);
@ -302,7 +289,7 @@ namespace ICSharpCode.VBNetBinding @@ -302,7 +289,7 @@ namespace ICSharpCode.VBNetBinding
return true;
}
bool TryDeclarationTypeInference(ITextEditor editor, IDocumentLine curLine)
static bool TryDeclarationTypeInference(ITextEditor editor, IDocumentLine curLine)
{
string lineText = editor.Document.GetText(curLine.Offset, curLine.Length);
ILexer lexer = ParserFactory.CreateLexer(SupportedLanguage.VBNet, new System.IO.StringReader(lineText));

4
src/AddIns/BackendBindings/VBNetBinding/Project/Src/VBNetProjectBinding.cs

@ -23,9 +23,9 @@ namespace ICSharpCode.VBNetBinding @@ -23,9 +23,9 @@ namespace ICSharpCode.VBNetBinding
}
}
public IProject LoadProject(ProjectLoadInformation loadInformation)
public IProject LoadProject(ProjectLoadInformation info)
{
return new VBNetProject(loadInformation);
return new VBNetProject(info);
}
public IProject CreateProject(ProjectCreateInformation info)

7
src/AddIns/BackendBindings/VBNetBinding/Project/Src/VbcEncodingFixingLogger.cs

@ -16,21 +16,20 @@ namespace ICSharpCode.VBNetBinding @@ -16,21 +16,20 @@ namespace ICSharpCode.VBNetBinding
/// <summary>
/// Fixes SD2-995 : Special characters not correctly encoded for languages others than English
/// </summary>
[System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Naming", "CA1704:IdentifiersShouldBeSpelledCorrectly", MessageId = "Vbc")]
public sealed class VbcEncodingFixingLogger : IMSBuildLoggerFilter
{
public IMSBuildChainedLoggerFilter CreateFilter(MSBuildEngine engine, IMSBuildChainedLoggerFilter nextFilter)
{
return new VbcLoggerImpl(engine, nextFilter);
return new VbcLoggerImpl(nextFilter);
}
sealed class VbcLoggerImpl : IMSBuildChainedLoggerFilter
{
readonly MSBuildEngine engineWorker;
readonly IMSBuildChainedLoggerFilter nextFilter;
public VbcLoggerImpl(MSBuildEngine engineWorker, IMSBuildChainedLoggerFilter nextFilter)
public VbcLoggerImpl(IMSBuildChainedLoggerFilter nextFilter)
{
this.engineWorker = engineWorker;
this.nextFilter = nextFilter;
}

2
src/AddIns/BackendBindings/VBNetBinding/Project/VBNetBinding.addin

@ -50,7 +50,7 @@ @@ -50,7 +50,7 @@
<Parser id = "VBNet"
supportedextensions = ".vb"
projectfileextension = ".vbproj"
class = "ICSharpCode.VBNetBinding.Parser.TParser"/>
class = "ICSharpCode.VBNetBinding.TParser"/>
</Path>
<Path name = "/SharpDevelop/Pads/ProjectBrowser/ContextMenu/ProjectActions/Convert">

3
src/AddIns/BackendBindings/VBNetBinding/Test/MockTextEditor.cs

@ -17,7 +17,6 @@ using ICSharpCode.SharpDevelop.Dom; @@ -17,7 +17,6 @@ using ICSharpCode.SharpDevelop.Dom;
using ICSharpCode.SharpDevelop.Editor;
using ICSharpCode.SharpDevelop.Editor.AvalonEdit;
using ICSharpCode.SharpDevelop.Editor.CodeCompletion;
using ICSharpCode.VBNetBinding.Parser;
namespace ICSharpCode.VBNetBinding.Tests
{
@ -67,7 +66,7 @@ namespace ICSharpCode.VBNetBinding.Tests @@ -67,7 +66,7 @@ namespace ICSharpCode.VBNetBinding.Tests
public void CreateParseInformation()
{
ParserService.RegisterAvailableParsers(new ParserDescriptor(typeof(TParser), "VBNet", new string[] { ".vb" }));
var parser = new VBNetBinding.Parser.TParser();
var parser = new VBNetBinding.TParser();
parser.LexerTags = new string[0];
var cu = parser.Parse(pc, this.FileName, this.Document);
ParserService.RegisterParseInformation(this.FileName, cu);

2
src/AddIns/Misc/ResourceToolkit/Test/TestHelper.cs

@ -35,7 +35,7 @@ namespace ResourceToolkit.Tests @@ -35,7 +35,7 @@ namespace ResourceToolkit.Tests
{
Dictionary<string, IParser> parsers = new Dictionary<string, IParser>();
parsers.Add(".cs", new CSharpBinding.Parser.TParser());
parsers.Add(".vb", new ICSharpCode.VBNetBinding.Parser.TParser());
parsers.Add(".vb", new ICSharpCode.VBNetBinding.TParser());
ResourceResolverService.SetParsersUnitTestOnly(parsers);
}

4
src/AddIns/Misc/SharpRefactoring/Test/SharpRefactoring.Tests.csproj

@ -37,9 +37,7 @@ @@ -37,9 +37,7 @@
<DefineConstants>TRACE</DefineConstants>
</PropertyGroup>
<ItemGroup>
<Reference Include="NUnit.Framework">
<HintPath>$(SharpDevelopBinPath)\Tools\NUnit\NUnit.Framework.dll</HintPath>
</Reference>
<Reference Include="nunit.framework" />
<Reference Include="PresentationCore">
<RequiredTargetFramework>3.0</RequiredTargetFramework>
</Reference>

Loading…
Cancel
Save