Browse Source

recreated branch for VB.NET 9 and 10

git-svn-id: svn://svn.sharpdevelop.net/sharpdevelop/branches/vbnet@5782 1ccf3a8d-04fe-1044-b7c0-cef0b8235c61
pull/1/head
Siegfried Pammer 15 years ago
parent
commit
85381fae41
  1. 187
      src/AddIns/BackendBindings/VBNetBinding/Project/Src/FormattingStrategy/VBNetFormattingStrategy.cs
  2. 6
      src/AddIns/BackendBindings/VBNetBinding/Project/Src/FormattingStrategy/VBStatement.cs
  3. 246
      src/AddIns/BackendBindings/VBNetBinding/Project/Src/VBNetBracketSearcher.cs
  4. 31
      src/AddIns/BackendBindings/VBNetBinding/Project/Src/VBNetCompletionBinding.cs
  5. 4
      src/AddIns/BackendBindings/VBNetBinding/Project/Src/VBNetLanguageBinding.cs
  6. 4
      src/AddIns/BackendBindings/VBNetBinding/Project/VBNetBinding.csproj
  7. 77
      src/AddIns/DisplayBindings/WpfDesign/WpfDesign.Designer/Project/Controls/GridAdorner.cs
  8. 10
      src/Libraries/AvalonEdit/ICSharpCode.AvalonEdit/Highlighting/Resources/VBNET-Mode.xshd
  9. 5
      src/Libraries/NRefactory/NRefactoryASTGenerator/AST/Expressions.cs
  10. 2
      src/Libraries/NRefactory/NRefactoryASTGenerator/AST/TypeLevel.cs
  11. 38
      src/Libraries/NRefactory/Project/Src/Ast/Generated.cs
  12. 2
      src/Libraries/NRefactory/Project/Src/Lexer/VBNet/Tokens.cs
  13. 2554
      src/Libraries/NRefactory/Project/Src/Parser/VBNet/Parser.cs
  14. 62
      src/Libraries/NRefactory/Project/Src/Parser/VBNet/VBNET.ATG
  15. 53
      src/Libraries/NRefactory/Project/Src/Parser/VBNet/VBNetParser.cs
  16. 9
      src/Libraries/NRefactory/Project/Src/Visitors/AbstractASTVisitor.cs
  17. 16
      src/Libraries/NRefactory/Project/Src/Visitors/AbstractAstTransformer.cs
  18. 74
      src/Libraries/NRefactory/Test/Parser/TypeLevel/PropertyDeclarationTests.cs
  19. 2
      src/Main/Base/Project/Src/Editor/IBracketSearcher.cs
  20. 1
      src/Main/Base/Test/ICSharpCode.SharpDevelop.Tests.csproj
  21. 1
      src/Main/ICSharpCode.SharpDevelop.Dom/Project/ICSharpCode.SharpDevelop.Dom.csproj
  22. 36
      src/Main/ICSharpCode.SharpDevelop.Dom/Project/Src/NRefactoryResolver/NRefactoryResolver.cs

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

@ -27,21 +27,11 @@ namespace VBNetBinding @@ -27,21 +27,11 @@ namespace VBNetBinding
/// </summary>
public class VBNetFormattingStrategy : DefaultFormattingStrategy
{
static readonly List<VBStatement> statements;
List<VBStatement> statements;
IList<string> keywords;
VBStatement interfaceStatement;
internal static List<VBStatement> Statements {
get { return statements; }
}
static readonly IList<string> keywords;
internal static IList<string> Keywords {
get { return keywords; }
}
static VBStatement interfaceStatement;
static List<int> blockTokens = new List<int>(
List<int> blockTokens = new List<int>(
new int[] {
Tokens.Class, Tokens.Module, Tokens.Namespace, Tokens.Interface, Tokens.Structure,
Tokens.Sub, Tokens.Function, Tokens.Operator,
@ -52,33 +42,33 @@ namespace VBNetBinding @@ -52,33 +42,33 @@ namespace VBNetBinding
bool doCasing;
bool doInsertion;
static VBNetFormattingStrategy()
public VBNetFormattingStrategy()
{
statements = new List<VBStatement>();
statements.Add(new VBStatement(@"^if.*?(then|\s+_)$", "^end ?if$", "End If", 1, Tokens.If));
statements.Add(new VBStatement(@"\bclass\s+\w+\s*($|\(\s*Of)", "^end class$", "End Class", 1, Tokens.Class));
statements.Add(new VBStatement(@"\bnamespace\s+\w+(\.\w+)*$", "^end namespace$", "End Namespace", 1, Tokens.Namespace));
statements.Add(new VBStatement(@"\bmodule\s+\w+$", "^end module$", "End Module", 1, Tokens.Module));
statements.Add(new VBStatement(@"\bstructure\s+\w+\s*($|\(\s*Of)", "^end structure$", "End Structure", 1, Tokens.Structure));
statements.Add(new VBStatement(@"^while\s+", "^end while$", "End While", 1, Tokens.While));
statements.Add(new VBStatement(@"^select case", "^end select$", "End Select", 1, Tokens.Select));
statements.Add(new VBStatement(@"(?<!\b(delegate|mustoverride|declare(\s+(unicode|ansi|auto))?)\s+)\bsub\s+\w+", @"^end\s+sub$", "End Sub", 1, Tokens.Sub));
statements.Add(new VBStatement(@"(?<!\bmustoverride (readonly |writeonly )?)\bproperty\s+\w+", @"^end\s+property$", "End Property", 1, Tokens.Property));
statements.Add(new VBStatement(@"(?<!\b(delegate|mustoverride|declare(\s+(unicode|ansi|auto))?)\s+)\bfunction\s+\w+", @"^end\s+function$", "End Function", 1, Tokens.Function));
statements.Add(new VBStatement(@"\boperator(\s*[\+\-\*\/\&\^\>\<\=\\]+\s*|\s+\w+\s*)\(", @"^end\s+operator$", "End Operator", 1, Tokens.Operator));
statements.Add(new VBStatement(@"\bfor\s+.*?$", "^next( \\w+)?$", "Next", 1, Tokens.For));
statements.Add(new VBStatement(@"^synclock\s+.*?$", "^end synclock$", "End SyncLock", 1, Tokens.SyncLock));
statements.Add(new VBStatement(@"^get$", "^end get$", "End Get", 1, Tokens.Get));
statements.Add(new VBStatement(@"^with\s+.*?$", "^end with$", "End With", 1, Tokens.With));
statements.Add(new VBStatement(@"^set(\s*\(.*?\))?$", "^end set$", "End Set", 1, Tokens.Set));
statements.Add(new VBStatement(@"^try$", "^end try$", "End Try", 1, Tokens.Try));
statements.Add(new VBStatement(@"^do\s+.+?$", "^loop$", "Loop", 1, Tokens.Do));
statements.Add(new VBStatement(@"^do$", "^loop .+?$", "Loop While ", 1, Tokens.Do));
statements.Add(new VBStatement(@"\benum\s+\w+$", "^end enum$", "End Enum", 1, Tokens.Enum));
interfaceStatement = new VBStatement(@"\binterface\s+\w+\s*($|\(\s*Of)", "^end interface$", "End Interface", 1, Tokens.Interface);
statements.Add(new VBStatement(@"^if.*?(then|\s+_)$", "^end ?if$", "End If", 1));
statements.Add(new VBStatement(@"\bclass\s+\w+\s*($|\(\s*Of)", "^end class$", "End Class", 1));
statements.Add(new VBStatement(@"\bnamespace\s+\w+(\.\w+)*$", "^end namespace$", "End Namespace", 1));
statements.Add(new VBStatement(@"\bmodule\s+\w+$", "^end module$", "End Module", 1));
statements.Add(new VBStatement(@"\bstructure\s+\w+\s*($|\(\s*Of)", "^end structure$", "End Structure", 1));
statements.Add(new VBStatement(@"^while\s+", "^end while$", "End While", 1));
statements.Add(new VBStatement(@"^select case", "^end select$", "End Select", 1));
statements.Add(new VBStatement(@"(?<!\b(delegate|mustoverride|declare(\s+(unicode|ansi|auto))?)\s+)\bsub\s+\w+", @"^end\s+sub$", "End Sub", 1));
statements.Add(new VBStatement(@"(?<!\bmustoverride (readonly |writeonly )?)\bproperty\s+\w+", @"^end\s+property$", "End Property", 1));
statements.Add(new VBStatement(@"(?<!\b(delegate|mustoverride|declare(\s+(unicode|ansi|auto))?)\s+)\bfunction\s+\w+", @"^end\s+function$", "End Function", 1));
statements.Add(new VBStatement(@"\boperator(\s*[\+\-\*\/\&\^\>\<\=\\]+\s*|\s+\w+\s*)\(", @"^end\s+operator$", "End Operator", 1));
statements.Add(new VBStatement(@"\bfor\s+.*?$", "^next( \\w+)?$", "Next", 1));
statements.Add(new VBStatement(@"^synclock\s+.*?$", "^end synclock$", "End SyncLock", 1));
statements.Add(new VBStatement(@"^get$", "^end get$", "End Get", 1));
statements.Add(new VBStatement(@"^with\s+.*?$", "^end with$", "End With", 1));
statements.Add(new VBStatement(@"^set(\s*\(.*?\))?$", "^end set$", "End Set", 1));
statements.Add(new VBStatement(@"^try$", "^end try$", "End Try", 1));
statements.Add(new VBStatement(@"^do\s+.+?$", "^loop$", "Loop", 1));
statements.Add(new VBStatement(@"^do$", "^loop .+?$", "Loop While ", 1));
statements.Add(new VBStatement(@"\benum\s+\w+$", "^end enum$", "End Enum", 1));
interfaceStatement = new VBStatement(@"\binterface\s+\w+\s*($|\(\s*Of)", "^end interface$", "End Interface", 1);
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));
statements.Add(new VBStatement(@"\busing\s+", "^end using$", "End Using", 1));
statements.Add(new VBStatement(@"^#region\s+", "^#end region$", "#End Region", 0));
keywords = new string[] {
"AddHandler", "AddressOf", "Alias", "And",
@ -149,7 +139,15 @@ namespace VBNetBinding @@ -149,7 +139,15 @@ namespace VBNetBinding
if (ch == '\n' && lineAboveText != null)
{
string textToReplace = TrimLine(lineAboveText);
string textToReplace = lineAboveText;
// remove string content
MatchCollection strmatches = Regex.Matches(textToReplace, "\"[^\"]*?\"", RegexOptions.Singleline);
foreach (Match match in strmatches)
{
textToReplace = textToReplace.Remove(match.Index, match.Length).Insert(match.Index, new String('-', match.Length));
}
// remove comments
textToReplace = Regex.Replace(textToReplace, "'.*$", "", RegexOptions.Singleline);
if (doCasing)
DoCasingOnLine(lineAbove, textToReplace, editor);
@ -160,11 +158,11 @@ namespace VBNetBinding @@ -160,11 +158,11 @@ namespace VBNetBinding
if (IsInString(lineAboveText)) {
if (IsFinishedString(curLineText)) {
editor.Document.Insert(lineAbove.Offset + lineAbove.Length,
"\" & _");
"\" & _");
editor.Document.Insert(currentLine.Offset, "\"");
} else {
editor.Document.Insert(lineAbove.Offset + lineAbove.Length,
"\"");
"\"");
}
} else {
string indent = DocumentUtilitites.GetWhitespaceAfter(editor.Document, lineAbove.Offset);
@ -207,18 +205,6 @@ namespace VBNetBinding @@ -207,18 +205,6 @@ namespace VBNetBinding
}
}
internal static string TrimLine(string lineText)
{
string textToReplace = lineText;
// remove string content
MatchCollection strmatches = Regex.Matches(lineText, "\"[^\"]*?\"", RegexOptions.Singleline);
foreach (Match match in strmatches) {
textToReplace = textToReplace.Remove(match.Index, match.Length).Insert(match.Index, new String('-', match.Length));
}
// remove comments
return Regex.Replace(textToReplace, "'.*$", "", RegexOptions.Singleline);
}
void DoInsertionOnLine(string terminator, IDocumentLine currentLine, IDocumentLine lineAbove, string textToReplace, ITextEditor editor, int lineNr)
{
string curLineText = currentLine.Text;
@ -369,8 +355,6 @@ namespace VBNetBinding @@ -369,8 +355,6 @@ namespace VBNetBinding
if (currentToken.EndLocation.Line > lineNr)
break;
prevToken = currentToken;
}
if (tokens.Count > 0)
@ -416,7 +400,7 @@ namespace VBNetBinding @@ -416,7 +400,7 @@ namespace VBNetBinding
return !inString;
}
internal static bool IsDeclaration(int type)
bool IsDeclaration(int type)
{
return (type == Tokens.Class) ||
(type == Tokens.Module) ||
@ -505,7 +489,7 @@ namespace VBNetBinding @@ -505,7 +489,7 @@ namespace VBNetBinding
return false;
}
internal static bool IsMatchingEnd(Token begin, Token end)
bool IsMatchingEnd(Token begin, Token end)
{
if (begin.Kind == end.Kind)
return true;
@ -664,7 +648,7 @@ namespace VBNetBinding @@ -664,7 +648,7 @@ namespace VBNetBinding
indentation.Push((indentation.PeekOrDefault() ?? string.Empty) + addIndent);
}
internal static bool IsBlockStart(ILexer lexer, Token current, Token prev)
bool IsBlockStart(ILexer lexer, Token current, Token prev)
{
if (blockTokens.Contains(current.Kind)) {
if (current.Kind == Tokens.If) {
@ -730,7 +714,7 @@ namespace VBNetBinding @@ -730,7 +714,7 @@ namespace VBNetBinding
return IsSpecialCase(current, prev);
}
internal static bool IsBlockEnd(Token current, Token prev)
bool IsBlockEnd(Token current, Token prev)
{
if (current.Kind == Tokens.Next) {
if (prev.Kind == Tokens.Resume)
@ -752,7 +736,7 @@ namespace VBNetBinding @@ -752,7 +736,7 @@ namespace VBNetBinding
return IsSpecialCase(current, prev);
}
static bool IsSpecialCase(Token current, Token prev)
bool IsSpecialCase(Token current, Token prev)
{
switch (current.Kind) {
case Tokens.Else:
@ -805,9 +789,9 @@ namespace VBNetBinding @@ -805,9 +789,9 @@ namespace VBNetBinding
}
}
static bool IsStatement(string text)
bool IsStatement(string text)
{
foreach (VBStatement s in statements) {
foreach (VBStatement s in this.statements) {
if (Regex.IsMatch(text, s.StartRegex, RegexOptions.IgnoreCase))
return true;
}
@ -865,5 +849,84 @@ namespace VBNetBinding @@ -865,5 +849,84 @@ namespace VBNetBinding
{
SurroundSelectionWithSingleLineComment(editor, "'");
}
#region SearchBracket
/*
public override int SearchBracketBackward(IDocument document, int offset, char openBracket, char closingBracket)
{
bool inString = false;
char ch;
int brackets = -1;
for (int i = offset; i > 0; --i) {
ch = document.GetCharAt(i);
if (ch == openBracket && !inString) {
++brackets;
if (brackets == 0) return i;
} else if (ch == closingBracket && !inString) {
--brackets;
} else if (ch == '"') {
inString = !inString;
} else if (ch == '\n') {
int lineStart = ScanLineStart(document, i);
if (lineStart >= 0) { // line could have a comment
inString = false;
for (int j = lineStart; j < i; ++j) {
ch = document.GetCharAt(j);
if (ch == '"') inString = !inString;
if (ch == '\'' && !inString) {
// comment found!
// Skip searching in the comment:
i = j;
break;
}
}
}
inString = false;
}
}
return -1;
}
static int ScanLineStart(IDocument document, int offset)
{
bool hasComment = false;
for (int i = offset - 1; i > 0; --i) {
char ch = document.GetCharAt(i);
if (ch == '\n') {
if (!hasComment) return -1;
return i + 1;
} else if (ch == '\'') {
hasComment = true;
}
}
return 0;
}
public override int SearchBracketForward(IDocument document, int offset, char openBracket, char closingBracket)
{
bool inString = false;
bool inComment = false;
int brackets = 1;
for (int i = offset; i < document.TextLength; ++i) {
char ch = document.GetCharAt(i);
if (ch == '\n') {
inString = false;
inComment = false;
}
if (inComment) continue;
if (ch == '"') inString = !inString;
if (inString) continue;
if (ch == '\'') {
inComment = true;
} else if (ch == openBracket) {
++brackets;
} else if (ch == closingBracket) {
--brackets;
if (brackets == 0) return i;
}
}
return -1;
}*/
#endregion
}
}

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

@ -6,8 +6,6 @@ @@ -6,8 +6,6 @@
// </file>
using System;
using ICSharpCode.NRefactory.Parser;
using ICSharpCode.NRefactory.Parser.VB;
namespace VBNetBinding
{
@ -17,20 +15,18 @@ namespace VBNetBinding @@ -17,20 +15,18 @@ namespace VBNetBinding
public string EndRegex = "";
public string EndStatement = "";
public int StatementToken = 0;
public int IndentPlus = 0;
public VBStatement()
{
}
public VBStatement(string startRegex, string endRegex, string endStatement, int indentPlus, int statementToken)
public VBStatement(string startRegex, string endRegex, string endStatement, int indentPlus)
{
StartRegex = startRegex;
EndRegex = endRegex;
EndStatement = endStatement;
IndentPlus = indentPlus;
StatementToken = statementToken;
}
}
}

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

@ -1,246 +0,0 @@ @@ -1,246 +0,0 @@
// <file>
// <copyright see="prj:///doc/copyright.txt"/>
// <license see="prj:///doc/license.txt"/>
// <owner name="Siegfried Pammer" email="siegfriedpammer@gmail.com" />
// <version>$Revision$</version>
// </file>
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text.RegularExpressions;
using ICSharpCode.Core;
using ICSharpCode.NRefactory;
using ICSharpCode.NRefactory.Parser;
using ICSharpCode.NRefactory.Parser.VB;
using ICSharpCode.SharpDevelop.Editor;
namespace VBNetBinding
{
public class VBNetBracketSearcher : IBracketSearcher
{
string openingBrackets = "([{";
string closingBrackets = ")]}";
public BracketSearchResult SearchBracket(IDocument document, int offset)
{
if (offset > 0) {
char c = document.GetCharAt(offset - 1);
int index = openingBrackets.IndexOf(c);
int otherOffset = -1;
if (index > -1)
otherOffset = SearchBracketForward(document, offset, openingBrackets[index], closingBrackets[index]);
index = closingBrackets.IndexOf(c);
if (index > -1)
otherOffset = SearchBracketBackward(document, offset - 2, openingBrackets[index], closingBrackets[index]);
if (otherOffset > -1)
return new BracketSearchResult(Math.Min(offset - 1, otherOffset), 1, Math.Max(offset - 1, otherOffset), 1);
int length;
VBStatement statement;
int startIndex = FindBeginStatementAroundOffset(document, offset, out statement, out length);
int endIndex = 0;
if (statement != null)
endIndex = FindEndStatement(document, statement);
else {
endIndex = FindEndStatementAroundOffset(document, offset, out statement);
if (statement != null)
startIndex = FindBeginStatement(document, statement, document.OffsetToPosition(endIndex), out length);
}
if (startIndex > -1 && endIndex > -1)
return new BracketSearchResult(startIndex, length, endIndex, statement.EndStatement.Length);
}
return null;
}
#region bracket search
int SearchBracketBackward(IDocument document, int offset, char openBracket, char closingBracket)
{
bool inString = false;
char ch;
int brackets = -1;
for (int i = offset; i > 0; --i) {
ch = document.GetCharAt(i);
if (ch == openBracket && !inString) {
++brackets;
if (brackets == 0) return i;
} else if (ch == closingBracket && !inString) {
--brackets;
} else if (ch == '"') {
inString = !inString;
} else if (ch == '\n') {
int lineStart = ScanLineStart(document, i);
if (lineStart >= 0) { // line could have a comment
inString = false;
for (int j = lineStart; j < i; ++j) {
ch = document.GetCharAt(j);
if (ch == '"') inString = !inString;
if (ch == '\'' && !inString) {
// comment found!
// Skip searching in the comment:
i = j;
break;
}
}
}
inString = false;
}
}
return -1;
}
static int ScanLineStart(IDocument document, int offset)
{
bool hasComment = false;
for (int i = offset - 1; i > 0; --i) {
char ch = document.GetCharAt(i);
if (ch == '\n') {
if (!hasComment) return -1;
return i + 1;
} else if (ch == '\'') {
hasComment = true;
}
}
return 0;
}
int SearchBracketForward(IDocument document, int offset, char openBracket, char closingBracket)
{
bool inString = false;
bool inComment = false;
int brackets = 1;
for (int i = offset; i < document.TextLength; ++i) {
char ch = document.GetCharAt(i);
if (ch == '\n') {
inString = false;
inComment = false;
}
if (inComment) continue;
if (ch == '"') inString = !inString;
if (inString) continue;
if (ch == '\'') {
inComment = true;
} else if (ch == openBracket) {
++brackets;
} else if (ch == closingBracket) {
--brackets;
if (brackets == 0) return i;
}
}
return -1;
}
#endregion
#region statement search
int FindBeginStatementAroundOffset(IDocument document, int offset, out VBStatement statement, out int length)
{
length = 0;
statement = null;
return -1;
}
int FindEndStatementAroundOffset(IDocument document, int offset, out VBStatement statement)
{
IDocumentLine line = document.GetLineForOffset(offset);
string interestingText = VBNetFormattingStrategy.TrimLine(line.Text).Trim(' ', '\t');
//LoggingService.Debug("text: '" + interestingText + "'");
foreach (VBStatement s in VBNetFormattingStrategy.Statements) {
Match match = Regex.Matches(interestingText, s.EndRegex, RegexOptions.Singleline | RegexOptions.IgnoreCase).OfType<Match>().FirstOrDefault();
if (match != null) {
//LoggingService.DebugFormatted("Found end statement at offset {1}: {0}", s, offset);
statement = s;
int result = match.Index + (line.Length - line.Text.TrimStart(' ', '\t').Length) + line.Offset;
if (offset >= result && offset <= (result + match.Length))
return result;
}
}
statement = null;
return -1;
}
int FindBeginStatement(IDocument document, VBStatement statement, Location endLocation, out int length)
{
ILexer lexer = ParserFactory.CreateLexer(SupportedLanguage.VBNet, document.CreateReader());
Token currentToken = null;
Token prevToken = null;
int lookFor = statement.StatementToken;
Stack<Token> tokens = new Stack<Token>();
if (statement.EndStatement == "Next") {
lookFor = Tokens.For;
}
Token result = null;
while ((currentToken = lexer.NextToken()).Kind != Tokens.EOF) {
if (prevToken == null)
prevToken = currentToken;
if (VBNetFormattingStrategy.IsBlockStart(lexer, currentToken, prevToken))
tokens.Push(currentToken);
if (VBNetFormattingStrategy.IsBlockEnd(currentToken, prevToken)) {
while (tokens.Count > 0 && !VBNetFormattingStrategy.IsMatchingEnd(tokens.Peek(), currentToken))
tokens.Pop();
if (tokens.Count > 0) {
Token t = tokens.Pop();
if (currentToken.Location.Line == endLocation.Line) {
result = t;
break;
}
}
}
prevToken = currentToken;
}
if (result != null) {
IDocumentLine line = document.GetLine(result.Location.Line);
string interestingText = VBNetFormattingStrategy.TrimLine(line.Text).Trim(' ', '\t');
//LoggingService.Debug("text2: '" + interestingText + "'");
Match matchResult = Regex.Match(interestingText, statement.StartRegex, RegexOptions.Singleline | RegexOptions.IgnoreCase);
if (matchResult != null) {
length = matchResult.Value.TrimEnd(' ', '\t').Length;
int diff = line.Length - line.Text.TrimStart(' ', '\t').Length;
int start = diff + line.Offset;
if (IsDeclaration(result.Kind)) {
length += diff + matchResult.Index;
return start;
}
return matchResult.Index + start;
}
}
length = 0;
return -1;
}
int FindEndStatement(IDocument document, VBStatement statement)
{
return -1;
}
#endregion
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

@ -41,38 +41,7 @@ namespace VBNetBinding @@ -41,38 +41,7 @@ namespace VBNetBinding
return CodeCompletionKeyPressResult.Completed;
} else if (ch == '\n') {
TryDeclarationTypeInference(editor, editor.Document.GetLineForOffset(editor.Caret.Offset));
} else if (char.IsLetter(ch) && CodeCompletionOptions.CompleteWhenTyping) {
if (editor.SelectionLength > 0) {
// allow code completion when overwriting an identifier
int endOffset = editor.SelectionStart + editor.SelectionLength;
// but block code completion when overwriting only part of an identifier
if (endOffset < editor.Document.TextLength && char.IsLetterOrDigit(editor.Document.GetCharAt(endOffset)))
return CodeCompletionKeyPressResult.None;
editor.Document.Remove(editor.SelectionStart, editor.SelectionLength);
}
int cursor = editor.Caret.Offset;
char prevChar = cursor > 1 ? editor.Document.GetCharAt(cursor - 1) : ' ';
bool afterUnderscore = prevChar == '_';
if (afterUnderscore) {
cursor--;
prevChar = cursor > 1 ? editor.Document.GetCharAt(cursor - 1) : ' ';
}
if (!char.IsLetterOrDigit(prevChar) && prevChar != '.' && !IsInComment(editor)) {
VBExpressionFinder ef = new VBExpressionFinder();
ExpressionResult result = ef.FindExpression(editor.Document.Text, cursor);
LoggingService.Debug("CC: Beginning to type a word, result=" + result + ", context=" + result.Context);
if (result.Context != ExpressionContext.IdentifierExpected) {
var ctrlSpaceProvider = new NRefactoryCtrlSpaceCompletionItemProvider(LanguageProperties.VBNet, result.Context);
ctrlSpaceProvider.ShowTemplates = true;
ctrlSpaceProvider.AllowCompleteExistingExpression = afterUnderscore;
ctrlSpaceProvider.ShowCompletion(editor);
return CodeCompletionKeyPressResult.CompletedIncludeKeyInCompletion;
}
}
}
return base.HandleKeyPress(editor, ch);
}

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

@ -19,9 +19,5 @@ namespace VBNetBinding @@ -19,9 +19,5 @@ namespace VBNetBinding
public override IFormattingStrategy FormattingStrategy {
get { return new VBNetFormattingStrategy(); }
}
public override IBracketSearcher BracketSearcher {
get { return new VBNetBracketSearcher(); }
}
}
}

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

@ -1,5 +1,4 @@ @@ -1,5 +1,4 @@
<?xml version="1.0" encoding="utf-8"?>
<Project ToolsVersion="4.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<Project ToolsVersion="4.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<PropertyGroup>
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
<Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
@ -52,7 +51,6 @@ @@ -52,7 +51,6 @@
<EmbeddedResource Include="Resources\BuildOptions.xfrm" />
<Compile Include="Src\Extensions.cs" />
<Compile Include="Src\FormattingStrategy\VBStatement.cs" />
<Compile Include="Src\VBNetBracketSearcher.cs" />
<Compile Include="Src\VBNetLanguageBinding.cs" />
<Compile Include="Src\VBNetProjectBinding.cs" />
<Compile Include="Src\FormattingStrategy\VBNetFormattingStrategy.cs" />

77
src/AddIns/DisplayBindings/WpfDesign/WpfDesign.Designer/Project/Controls/GridAdorner.cs

@ -28,7 +28,7 @@ namespace ICSharpCode.WpfDesign.Designer.Controls @@ -28,7 +28,7 @@ namespace ICSharpCode.WpfDesign.Designer.Controls
bgBrush = new SolidColorBrush(Color.FromArgb(0x30, 0x20, 0x20, 0xff));
bgBrush.Freeze();
selBrush = new SolidColorBrush(Color.FromArgb(0xc0, 0xff, 0xb7, 0x4f));
selBrush = new SolidColorBrush(Color.FromArgb(0xC0, 0xff, 0xb7, 0x4f));
selBrush.Freeze();
}
@ -147,7 +147,7 @@ namespace ICSharpCode.WpfDesign.Designer.Controls @@ -147,7 +147,7 @@ namespace ICSharpCode.WpfDesign.Designer.Controls
.FirstOrDefault(r => insertionPosition >= r.Offset &&
insertionPosition <= (r.Offset + r.ActualHeight));
if (current != null && !gridItem.Services.Selection.IsComponentSelected(gridItem.Services.Component.GetDesignItem(current)))
if (current == null || !gridItem.Services.Selection.IsComponentSelected(gridItem.Services.Component.GetDesignItem(current)))
return;
} else {
double insertionPosition = e.GetPosition(this).X;
@ -155,7 +155,7 @@ namespace ICSharpCode.WpfDesign.Designer.Controls @@ -155,7 +155,7 @@ namespace ICSharpCode.WpfDesign.Designer.Controls
.FirstOrDefault(r => insertionPosition >= r.Offset &&
insertionPosition <= (r.Offset + r.ActualWidth));
if (current != null && !gridItem.Services.Selection.IsComponentSelected(gridItem.Services.Component.GetDesignItem(current)))
if (current == null || !gridItem.Services.Selection.IsComponentSelected(gridItem.Services.Component.GetDesignItem(current)))
return;
}
@ -175,27 +175,22 @@ namespace ICSharpCode.WpfDesign.Designer.Controls @@ -175,27 +175,22 @@ namespace ICSharpCode.WpfDesign.Designer.Controls
DesignItem component;
if (current != null) {
component = gridItem.Services.Component.GetDesignItem(current);
if (!gridItem.Services.Selection.IsComponentSelected(component))
return;
rpUnitSelector.XOffset = -(RailSize + RailDistance) * 2.75;
rpUnitSelector.WidthOffset = RailSize + RailDistance;
rpUnitSelector.WidthRelativeToContentWidth = 1;
rpUnitSelector.HeightOffset = 55;
rpUnitSelector.YOffset = current.Offset + current.ActualHeight / 2 - 25;
unitSelector.SelectedItem = component;
unitSelector.Unit = ((GridLength)component.Properties[RowDefinition.HeightProperty].ValueOnInstance).GridUnitType;
AdornerPanel.SetPlacement(unitSelector, rpUnitSelector);
}
if (current == null || !gridItem.Services.Selection.IsComponentSelected(component = gridItem.Services.Component.GetDesignItem(current)))
return;
rp.XOffset = -(RailSize + RailDistance);
rp.WidthOffset = RailSize + RailDistance;
rp.WidthRelativeToContentWidth = 1;
rp.HeightOffset = SplitterWidth;
rp.YOffset = e.GetPosition(this).Y - SplitterWidth / 2;
rpUnitSelector.XOffset = -(RailSize + RailDistance) * 2.75;
rpUnitSelector.WidthOffset = RailSize + RailDistance;
rpUnitSelector.WidthRelativeToContentWidth = 1;
rpUnitSelector.HeightOffset = 55;
rpUnitSelector.YOffset = current.Offset + current.ActualHeight / 2 - 25;
unitSelector.SelectedItem = component;
unitSelector.Unit = ((GridLength)component.Properties[RowDefinition.HeightProperty].ValueOnInstance).GridUnitType;
} else {
double insertionPosition = e.GetPosition(this).X;
ColumnDefinition current = grid.ColumnDefinitions
@ -204,30 +199,26 @@ namespace ICSharpCode.WpfDesign.Designer.Controls @@ -204,30 +199,26 @@ namespace ICSharpCode.WpfDesign.Designer.Controls
DesignItem component;
if (current == null) {
component = gridItem.Services.Component.GetDesignItem(current);
if (!gridItem.Services.Selection.IsComponentSelected(component))
return;
rpUnitSelector.YOffset = -(RailSize + RailDistance) * 2.75;
rpUnitSelector.HeightOffset = RailSize + RailDistance;
rpUnitSelector.HeightRelativeToContentHeight = 1;
rpUnitSelector.WidthOffset = 75;
rpUnitSelector.XOffset = current.Offset + current.ActualWidth / 2 - 35;
unitSelector.SelectedItem = component;
unitSelector.Unit = ((GridLength)component.Properties[ColumnDefinition.WidthProperty].ValueOnInstance).GridUnitType;
AdornerPanel.SetPlacement(unitSelector, rpUnitSelector);
}
if (current == null || !gridItem.Services.Selection.IsComponentSelected(component = gridItem.Services.Component.GetDesignItem(current)))
return;
rp.YOffset = -(RailSize + RailDistance);
rp.HeightOffset = RailSize + RailDistance;
rp.HeightRelativeToContentHeight = 1;
rp.WidthOffset = SplitterWidth;
rp.XOffset = e.GetPosition(this).X - SplitterWidth / 2;
rpUnitSelector.YOffset = -(RailSize + RailDistance) * 2.75;
rpUnitSelector.HeightOffset = RailSize + RailDistance;
rpUnitSelector.HeightRelativeToContentHeight = 1;
rpUnitSelector.WidthOffset = 75;
rpUnitSelector.XOffset = current.Offset + current.ActualWidth / 2 - 35;
unitSelector.SelectedItem = component;
unitSelector.Unit = ((GridLength)component.Properties[ColumnDefinition.WidthProperty].ValueOnInstance).GridUnitType;
}
AdornerPanel.SetPlacement(previewAdorner, rp);
AdornerPanel.SetPlacement(unitSelector, rpUnitSelector);
}
protected override void OnMouseLeave(MouseEventArgs e)
@ -262,12 +253,15 @@ namespace ICSharpCode.WpfDesign.Designer.Controls @@ -262,12 +253,15 @@ namespace ICSharpCode.WpfDesign.Designer.Controls
if (current != null)
currentRow = gridItem.Services.Component.GetDesignItem(current);
}
if (currentRow != null && !gridItem.Services.Selection.IsComponentSelected(currentRow)) {
unitSelector.SelectedItem = currentRow;
if (currentRow == null)
currentRow = gridItem.Services.Component.GetDesignItem(grid.RowDefinitions.Last());
unitSelector.SelectedItem = currentRow;
if (!gridItem.Services.Selection.IsComponentSelected(currentRow)) {
gridItem.Services.Selection.SetSelectedComponents(new DesignItem[] { currentRow }, SelectionTypes.Auto);
changeGroup.Commit();
if (!adornerPanel.Children.Contains(previewAdorner))
adornerPanel.Children.Add(previewAdorner);
@ -317,11 +311,14 @@ namespace ICSharpCode.WpfDesign.Designer.Controls @@ -317,11 +311,14 @@ namespace ICSharpCode.WpfDesign.Designer.Controls
currentColumn = gridItem.Services.Component.GetDesignItem(current);
}
if (currentColumn != null && !gridItem.Services.Selection.IsComponentSelected(currentColumn)) {
if (currentColumn == null)
currentColumn = gridItem.Services.Component.GetDesignItem(grid.ColumnDefinitions.Last());
unitSelector.SelectedItem = currentColumn;
if (!gridItem.Services.Selection.IsComponentSelected(currentColumn)) {
gridItem.Services.Selection.SetSelectedComponents(new DesignItem[] { currentColumn }, SelectionTypes.Auto);
unitSelector.SelectedItem = currentColumn;
changeGroup.Commit();
if (!adornerPanel.Children.Contains(previewAdorner))
adornerPanel.Children.Add(previewAdorner);
OnMouseMove(e);

10
src/Libraries/AvalonEdit/ICSharpCode.AvalonEdit/Highlighting/Resources/VBNET-Mode.xshd

@ -201,16 +201,6 @@ @@ -201,16 +201,6 @@
<Word>Next</Word>
<Word>Select</Word>
<Word>Case</Word>
<Word>From</Word>
<Word>Aggregate</Word>
<Word>Distinct</Word>
<Word>Group</Word>
<Word>Where</Word>
<Word>Skip</Word>
<Word>Join</Word>
<Word>Into</Word>
<Word>Equals</Word>
<Word>Take</Word>
</Keywords>
<Keywords color="ContextKeywords">
<Word>Ansi</Word>

5
src/Libraries/NRefactory/NRefactoryASTGenerator/AST/Expressions.cs

@ -379,9 +379,4 @@ namespace NRefactoryASTGenerator.Ast @@ -379,9 +379,4 @@ namespace NRefactoryASTGenerator.Ast
QueryExpressionJoinVBClause joinClause;
List<ExpressionRangeVariable> intoVariables;
}
[ImplementNullable]
abstract class XmlLiteralExpression : AbstractNode, INullable { }
}

2
src/Libraries/NRefactory/NRefactoryASTGenerator/AST/TypeLevel.cs

@ -159,6 +159,7 @@ namespace NRefactoryASTGenerator.Ast @@ -159,6 +159,7 @@ namespace NRefactoryASTGenerator.Ast
class OperatorDeclaration : MethodDeclaration
{
ConversionType conversionType;
List<AttributeSection> returnTypeAttributes;
OverloadableOperatorType overloadableOperator;
}
@ -184,7 +185,6 @@ namespace NRefactoryASTGenerator.Ast @@ -184,7 +185,6 @@ namespace NRefactoryASTGenerator.Ast
Location bodyEnd;
PropertyGetRegion getRegion;
PropertySetRegion setRegion;
Expression initializer;
public PropertyDeclaration(Modifiers modifier, List<AttributeSection> attributes,
string name, List<ParameterDeclarationExpression> parameters)

38
src/Libraries/NRefactory/Project/Src/Ast/Generated.cs

@ -2991,6 +2991,8 @@ public Location ExtendedEndLocation { get; set; } @@ -2991,6 +2991,8 @@ public Location ExtendedEndLocation { get; set; }
ConversionType conversionType;
List<AttributeSection> returnTypeAttributes;
OverloadableOperatorType overloadableOperator;
public ConversionType ConversionType {
@ -3002,6 +3004,15 @@ public Location ExtendedEndLocation { get; set; } @@ -3002,6 +3004,15 @@ public Location ExtendedEndLocation { get; set; }
}
}
public List<AttributeSection> ReturnTypeAttributes {
get {
return returnTypeAttributes;
}
set {
returnTypeAttributes = value ?? new List<AttributeSection>();
}
}
public OverloadableOperatorType OverloadableOperator {
get {
return overloadableOperator;
@ -3012,6 +3023,7 @@ public Location ExtendedEndLocation { get; set; } @@ -3012,6 +3023,7 @@ public Location ExtendedEndLocation { get; set; }
}
public OperatorDeclaration() {
returnTypeAttributes = new List<AttributeSection>();
}
public bool IsConversionOperator {
@ -3025,9 +3037,10 @@ public Location ExtendedEndLocation { get; set; } @@ -3025,9 +3037,10 @@ public Location ExtendedEndLocation { get; set; }
}
public override string ToString() {
return string.Format("[OperatorDeclaration ConversionType={0} OverloadableOperator={1} Body={2} Handles" +
"Clause={3} Templates={4} IsExtensionMethod={5} InterfaceImplementations={6} Type" +
"Reference={7} Name={8} Parameters={9} Attributes={10} Modifier={11}]", ConversionType, OverloadableOperator, Body, GetCollectionString(HandlesClause), GetCollectionString(Templates), IsExtensionMethod, GetCollectionString(InterfaceImplementations), TypeReference, Name, GetCollectionString(Parameters), GetCollectionString(Attributes), Modifier);
return string.Format("[OperatorDeclaration ConversionType={0} ReturnTypeAttributes={1} OverloadableOper" +
"ator={2} Body={3} HandlesClause={4} Templates={5} IsExtensionMethod={6} Interfac" +
"eImplementations={7} TypeReference={8} Name={9} Parameters={10} Attributes={11} " +
"Modifier={12}]", ConversionType, GetCollectionString(ReturnTypeAttributes), OverloadableOperator, Body, GetCollectionString(HandlesClause), GetCollectionString(Templates), IsExtensionMethod, GetCollectionString(InterfaceImplementations), TypeReference, Name, GetCollectionString(Parameters), GetCollectionString(Attributes), Modifier);
}
}
@ -3286,8 +3299,6 @@ public Location ExtendedEndLocation { get; set; } @@ -3286,8 +3299,6 @@ public Location ExtendedEndLocation { get; set; }
PropertySetRegion setRegion;
Expression initializer;
public Location BodyStart {
get {
return bodyStart;
@ -3326,16 +3337,6 @@ public Location ExtendedEndLocation { get; set; } @@ -3326,16 +3337,6 @@ public Location ExtendedEndLocation { get; set; }
}
}
public Expression Initializer {
get {
return initializer;
}
set {
initializer = value ?? Expression.Null;
if (!initializer.IsNull) initializer.Parent = this;
}
}
public PropertyDeclaration(Modifiers modifier, List<AttributeSection> attributes, string name, List<ParameterDeclarationExpression> parameters) {
Modifier = modifier;
Attributes = attributes;
@ -3345,7 +3346,6 @@ public Location ExtendedEndLocation { get; set; } @@ -3345,7 +3346,6 @@ public Location ExtendedEndLocation { get; set; }
bodyEnd = Location.Empty;
getRegion = PropertyGetRegion.Null;
setRegion = PropertySetRegion.Null;
initializer = Expression.Null;
}
public bool HasGetRegion {
@ -3395,9 +3395,9 @@ public Location ExtendedEndLocation { get; set; } @@ -3395,9 +3395,9 @@ public Location ExtendedEndLocation { get; set; }
}
public override string ToString() {
return string.Format("[PropertyDeclaration BodyStart={0} BodyEnd={1} GetRegion={2} SetRegion={3} Initia" +
"lizer={4} InterfaceImplementations={5} TypeReference={6} Name={7} Parameters={8}" +
" Attributes={9} Modifier={10}]", BodyStart, BodyEnd, GetRegion, SetRegion, Initializer, GetCollectionString(InterfaceImplementations), TypeReference, Name, GetCollectionString(Parameters), GetCollectionString(Attributes), Modifier);
return string.Format("[PropertyDeclaration BodyStart={0} BodyEnd={1} GetRegion={2} SetRegion={3} Interf" +
"aceImplementations={4} TypeReference={5} Name={6} Parameters={7} Attributes={8} " +
"Modifier={9}]", BodyStart, BodyEnd, GetRegion, SetRegion, GetCollectionString(InterfaceImplementations), TypeReference, Name, GetCollectionString(Parameters), GetCollectionString(Attributes), Modifier);
}
}

2
src/Libraries/NRefactory/Project/Src/Lexer/VBNet/Tokens.cs

@ -246,8 +246,6 @@ namespace ICSharpCode.NRefactory.Parser.VB @@ -246,8 +246,6 @@ namespace ICSharpCode.NRefactory.Parser.VB
public static BitArray Null = NewSet(Nothing);
public static BitArray BlockSucc = NewSet(Case, Catch, Else, ElseIf, End, Finally, Loop, Next);
public static BitArray IdentifierTokens = NewSet(Text, Binary, Compare, Assembly, Ansi, Auto, Preserve, Unicode, Until, Off, Explicit, Infer, From, Join, Equals, Distinct, Where, Take, Skip, Order, By, Ascending, Descending, Group, Into, Aggregate);
public static BitArray TypeLevel = NewSet(Public, Friend, Class, Interface, Structure, Enum, Delegate, Shared, Partial, Protected, Private, Public, Const, Event, Explicit, New, Operator);
public static BitArray GlobalLevel = NewSet(Namespace, Imports, Public, Friend, Class, Interface, Structure, Enum, Delegate, Partial);
static string[] tokenList = new string[] {
// ----- terminal classes -----

2554
src/Libraries/NRefactory/Project/Src/Parser/VBNet/Parser.cs

File diff suppressed because it is too large Load Diff

62
src/Libraries/NRefactory/Project/Src/Parser/VBNet/VBNET.ATG

@ -890,16 +890,7 @@ StructureMemberDecl<ModifierList m, List<AttributeSection> attributes> @@ -890,16 +890,7 @@ StructureMemberDecl<ModifierList m, List<AttributeSection> attributes>
Identifier (. name = t.val; .)
TypeParameterList<templates>
[ "(" [ FormalParameterList<p> ] ")" ]
["As" {
AttributeSection<out returnTypeAttributeSection>
(.
if (returnTypeAttributeSection != null) {
returnTypeAttributeSection.AttributeTarget = "return";
attributes.Add(returnTypeAttributeSection);
}
.)
}
TypeName<out type> ]
["As" { AttributeSection<out returnTypeAttributeSection> } TypeName<out type> ]
(.
if(type == null) {
type = new TypeReference("System.Object", true);
@ -927,7 +918,10 @@ StructureMemberDecl<ModifierList m, List<AttributeSection> attributes> @@ -927,7 +918,10 @@ StructureMemberDecl<ModifierList m, List<AttributeSection> attributes>
Templates = templates,
InterfaceImplementations = implementsClause
};
if (returnTypeAttributeSection != null) {
returnTypeAttributeSection.AttributeTarget = "return";
methodDeclaration.Attributes.Add(returnTypeAttributeSection);
}
compilationUnit.AddChild(methodDeclaration);
.)
|
@ -942,6 +936,10 @@ StructureMemberDecl<ModifierList m, List<AttributeSection> attributes> @@ -942,6 +936,10 @@ StructureMemberDecl<ModifierList m, List<AttributeSection> attributes>
HandlesClause = handlesClause,
InterfaceImplementations = implementsClause
};
if (returnTypeAttributeSection != null) {
returnTypeAttributeSection.AttributeTarget = "return";
methodDeclaration.Attributes.Add(returnTypeAttributeSection);
}
compilationUnit.AddChild(methodDeclaration);
@ -1066,45 +1064,20 @@ StructureMemberDecl<ModifierList m, List<AttributeSection> attributes> @@ -1066,45 +1064,20 @@ StructureMemberDecl<ModifierList m, List<AttributeSection> attributes>
m.Check(Modifiers.VBProperties);
Location startPos = t.Location;
List<InterfaceImplementation> implementsClause = null;
AttributeSection returnTypeAttributeSection = null;
Expression initializer = null;
.)
Identifier (. string propertyName = t.val; .)
[ "(" [ FormalParameterList<p> ] ")" ]
[
"As" {
AttributeSection<out returnTypeAttributeSection>
(.
if (returnTypeAttributeSection != null) {
returnTypeAttributeSection.AttributeTarget = "return";
attributes.Add(returnTypeAttributeSection);
}
.)
}
(
IF (IsNewExpression()) ObjectCreateExpression<out initializer>
(.
if (initializer is ObjectCreateExpression) {
type = ((ObjectCreateExpression)initializer).CreateType.Clone();
} else {
type = ((ArrayCreateExpression)initializer).CreateType.Clone();
}
.)
|
TypeName<out type>
)
]
[ "As" TypeName<out type> ]
(.
if(type == null) {
type = new TypeReference("System.Object", true);
}
.)
[ "=" VariableInitializer<out initializer> ]
[ ImplementsClause<out implementsClause> ]
EndOfStmt
(
/* abstract properties without a body */
IF(IsMustOverride(m) || IsAutomaticProperty())
IF(IsMustOverride(m))
(.
PropertyDeclaration pDecl = new PropertyDeclaration(propertyName, type, m.Modifier, attributes);
pDecl.StartLocation = m.GetDeclarationLocation(startPos);
@ -1112,8 +1085,6 @@ StructureMemberDecl<ModifierList m, List<AttributeSection> attributes> @@ -1112,8 +1085,6 @@ StructureMemberDecl<ModifierList m, List<AttributeSection> attributes>
pDecl.TypeReference = type;
pDecl.InterfaceImplementations = implementsClause;
pDecl.Parameters = p;
if (initializer != null)
pDecl.Initializer = initializer;
compilationUnit.AddChild(pDecl);
.)
|
@ -1134,7 +1105,7 @@ StructureMemberDecl<ModifierList m, List<AttributeSection> attributes> @@ -1134,7 +1105,7 @@ StructureMemberDecl<ModifierList m, List<AttributeSection> attributes>
(.
pDecl.GetRegion = getRegion;
pDecl.SetRegion = setRegion;
pDecl.BodyEnd = t.Location; // t = EndOfStmt; not "Property"
pDecl.BodyEnd = t.EndLocation;
compilationUnit.AddChild(pDecl);
.)
)
@ -1210,6 +1181,7 @@ StructureMemberDecl<ModifierList m, List<AttributeSection> attributes> @@ -1210,6 +1181,7 @@ StructureMemberDecl<ModifierList m, List<AttributeSection> attributes>
OverloadableOperatorType operatorType;
AttributeSection section;
List<ParameterDeclarationExpression> parameters = new List<ParameterDeclarationExpression>();
List<AttributeSection> returnTypeAttributes = new List<AttributeSection>();
.)
OverloadableOperator<out operatorType>
"(" [ "ByVal" ] Identifier (. operandName = t.val; .)
@ -1224,12 +1196,7 @@ StructureMemberDecl<ModifierList m, List<AttributeSection> attributes> @@ -1224,12 +1196,7 @@ StructureMemberDecl<ModifierList m, List<AttributeSection> attributes>
}
")"
(. Location endPos = t.EndLocation; .)
[ "As" { AttributeSection<out section>
(. if (section != null) {
section.AttributeTarget = "return";
attributes.Add(section);
} .)
} TypeName<out returnType> (. endPos = t.EndLocation; .) ]
[ "As" { AttributeSection<out section> (. returnTypeAttributes.Add(section); .) } TypeName<out returnType> (. endPos = t.EndLocation; .) ]
EOL
Block<out stmt> "End" "Operator" EndOfStmt
(.
@ -1240,6 +1207,7 @@ StructureMemberDecl<ModifierList m, List<AttributeSection> attributes> @@ -1240,6 +1207,7 @@ StructureMemberDecl<ModifierList m, List<AttributeSection> attributes>
TypeReference = returnType,
OverloadableOperator = operatorType,
ConversionType = opConversionType,
ReturnTypeAttributes = returnTypeAttributes,
Body = (BlockStatement)stmt,
StartLocation = m.GetDeclarationLocation(startPos),
EndLocation = endPos

53
src/Libraries/NRefactory/Project/Src/Parser/VBNet/VBNetParser.cs

@ -5,14 +5,12 @@ @@ -5,14 +5,12 @@
// <version>$Revision$</version>
// </file>
using ICSharpCode.NRefactory.Visitors;
using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.Linq;
using System.Text;
using ICSharpCode.NRefactory.Ast;
using ICSharpCode.NRefactory.Visitors;
namespace ICSharpCode.NRefactory.Parser.VB
{
@ -175,10 +173,6 @@ namespace ICSharpCode.NRefactory.Parser.VB @@ -175,10 +173,6 @@ namespace ICSharpCode.NRefactory.Parser.VB
bool IsObjectCreation() {
return la.kind == Tokens.As && Peek(1).kind == Tokens.New;
}
bool IsNewExpression() {
return la.kind == Tokens.New;
}
/*
True, if "<" is followed by the ident "assembly" or "module"
@ -262,52 +256,15 @@ namespace ICSharpCode.NRefactory.Parser.VB @@ -262,52 +256,15 @@ namespace ICSharpCode.NRefactory.Parser.VB
int peek = Peek(1).kind;
return la.kind == Tokens.Resume && peek == Tokens.Next;
}
/// <summary>
/// Returns True, if ident/literal integer is followed by ":"
/// </summary>
/*
True, if ident/literal integer is followed by ":"
*/
bool IsLabel()
{
return (la.kind == Tokens.Identifier || la.kind == Tokens.LiteralInteger)
&& Peek(1).kind == Tokens.Colon;
}
/// <summary>
/// Returns true if a property declaration is an automatic property.
/// </summary>
bool IsAutomaticProperty()
{
lexer.StartPeek();
Token tn = la;
int braceCount = 0;
// look for attributes
while (tn.kind == Tokens.LessThan) {
while (braceCount > 0 || tn.kind != Tokens.GreaterThan) {
tn = lexer.Peek();
if (tn.kind == Tokens.OpenParenthesis)
braceCount++;
if (tn.kind == Tokens.CloseParenthesis)
braceCount--;
}
Debug.Assert(tn.kind == Tokens.GreaterThan);
tn = lexer.Peek();
}
// look for modifiers
var allowedTokens = new[] {
Tokens.Public, Tokens.Protected,
Tokens.Friend, Tokens.Private
};
while (allowedTokens.Contains(tn.kind))
tn = lexer.Peek();
if (tn.Kind != Tokens.Get && tn.Kind != Tokens.Set)
return true;
return false;
}
bool IsNotStatementSeparator()
{

9
src/Libraries/NRefactory/Project/Src/Visitors/AbstractASTVisitor.cs

@ -704,6 +704,7 @@ namespace ICSharpCode.NRefactory.Visitors { @@ -704,6 +704,7 @@ namespace ICSharpCode.NRefactory.Visitors {
Debug.Assert((operatorDeclaration.TypeReference != null));
Debug.Assert((operatorDeclaration.Body != null));
Debug.Assert((operatorDeclaration.Templates != null));
Debug.Assert((operatorDeclaration.ReturnTypeAttributes != null));
foreach (AttributeSection o in operatorDeclaration.Attributes) {
Debug.Assert(o != null);
o.AcceptVisitor(this, data);
@ -722,6 +723,10 @@ namespace ICSharpCode.NRefactory.Visitors { @@ -722,6 +723,10 @@ namespace ICSharpCode.NRefactory.Visitors {
Debug.Assert(o != null);
o.AcceptVisitor(this, data);
}
foreach (AttributeSection o in operatorDeclaration.ReturnTypeAttributes) {
Debug.Assert(o != null);
o.AcceptVisitor(this, data);
}
return null;
}
@ -774,7 +779,6 @@ namespace ICSharpCode.NRefactory.Visitors { @@ -774,7 +779,6 @@ namespace ICSharpCode.NRefactory.Visitors {
Debug.Assert((propertyDeclaration.TypeReference != null));
Debug.Assert((propertyDeclaration.GetRegion != null));
Debug.Assert((propertyDeclaration.SetRegion != null));
Debug.Assert((propertyDeclaration.Initializer != null));
foreach (AttributeSection o in propertyDeclaration.Attributes) {
Debug.Assert(o != null);
o.AcceptVisitor(this, data);
@ -789,8 +793,7 @@ namespace ICSharpCode.NRefactory.Visitors { @@ -789,8 +793,7 @@ namespace ICSharpCode.NRefactory.Visitors {
}
propertyDeclaration.TypeReference.AcceptVisitor(this, data);
propertyDeclaration.GetRegion.AcceptVisitor(this, data);
propertyDeclaration.SetRegion.AcceptVisitor(this, data);
return propertyDeclaration.Initializer.AcceptVisitor(this, data);
return propertyDeclaration.SetRegion.AcceptVisitor(this, data);
}
public virtual object VisitPropertyGetRegion(PropertyGetRegion propertyGetRegion, object data) {

16
src/Libraries/NRefactory/Project/Src/Visitors/AbstractAstTransformer.cs

@ -1269,6 +1269,7 @@ namespace ICSharpCode.NRefactory.Visitors { @@ -1269,6 +1269,7 @@ namespace ICSharpCode.NRefactory.Visitors {
Debug.Assert((operatorDeclaration.TypeReference != null));
Debug.Assert((operatorDeclaration.Body != null));
Debug.Assert((operatorDeclaration.Templates != null));
Debug.Assert((operatorDeclaration.ReturnTypeAttributes != null));
for (int i = 0; i < operatorDeclaration.Attributes.Count; i++) {
AttributeSection o = operatorDeclaration.Attributes[i];
Debug.Assert(o != null);
@ -1319,6 +1320,17 @@ namespace ICSharpCode.NRefactory.Visitors { @@ -1319,6 +1320,17 @@ namespace ICSharpCode.NRefactory.Visitors {
else
operatorDeclaration.Templates[i] = o;
}
for (int i = 0; i < operatorDeclaration.ReturnTypeAttributes.Count; i++) {
AttributeSection o = operatorDeclaration.ReturnTypeAttributes[i];
Debug.Assert(o != null);
nodeStack.Push(o);
o.AcceptVisitor(this, data);
o = (AttributeSection)nodeStack.Pop();
if (o == null)
operatorDeclaration.ReturnTypeAttributes.RemoveAt(i--);
else
operatorDeclaration.ReturnTypeAttributes[i] = o;
}
return null;
}
@ -1395,7 +1407,6 @@ namespace ICSharpCode.NRefactory.Visitors { @@ -1395,7 +1407,6 @@ namespace ICSharpCode.NRefactory.Visitors {
Debug.Assert((propertyDeclaration.TypeReference != null));
Debug.Assert((propertyDeclaration.GetRegion != null));
Debug.Assert((propertyDeclaration.SetRegion != null));
Debug.Assert((propertyDeclaration.Initializer != null));
for (int i = 0; i < propertyDeclaration.Attributes.Count; i++) {
AttributeSection o = propertyDeclaration.Attributes[i];
Debug.Assert(o != null);
@ -1438,9 +1449,6 @@ namespace ICSharpCode.NRefactory.Visitors { @@ -1438,9 +1449,6 @@ namespace ICSharpCode.NRefactory.Visitors {
nodeStack.Push(propertyDeclaration.SetRegion);
propertyDeclaration.SetRegion.AcceptVisitor(this, data);
propertyDeclaration.SetRegion = ((PropertySetRegion)(nodeStack.Pop()));
nodeStack.Push(propertyDeclaration.Initializer);
propertyDeclaration.Initializer.AcceptVisitor(this, data);
propertyDeclaration.Initializer = ((Expression)(nodeStack.Pop()));
return null;
}

74
src/Libraries/NRefactory/Test/Parser/TypeLevel/PropertyDeclarationTests.cs

@ -120,89 +120,19 @@ namespace ICSharpCode.NRefactory.Tests.Ast @@ -120,89 +120,19 @@ namespace ICSharpCode.NRefactory.Tests.Ast
[Test]
public void VBNetSimpleGetPropertyDeclarationTest()
{
PropertyDeclaration pd = ParseUtilVBNet.ParseTypeMember<PropertyDeclaration>("ReadOnly Property MyProperty \nGet\nEnd Get\nEnd Property");
PropertyDeclaration pd = ParseUtilVBNet.ParseTypeMember<PropertyDeclaration>("Property MyProperty \nGet\nEnd Get\nEnd Property");
Assert.AreEqual("MyProperty", pd.Name);
Assert.AreEqual("System.Object", pd.TypeReference.Type);
Assert.IsTrue(pd.HasGetRegion);
Assert.IsFalse(pd.HasSetRegion);
Assert.IsTrue((pd.Modifier & Modifiers.ReadOnly) == Modifiers.ReadOnly);
}
[Test]
public void VBNetSimpleSetPropertyDeclarationTest()
{
PropertyDeclaration pd = ParseUtilVBNet.ParseTypeMember<PropertyDeclaration>("WriteOnly Property MyProperty \n Set\nEnd Set\nEnd Property ");
PropertyDeclaration pd = ParseUtilVBNet.ParseTypeMember<PropertyDeclaration>("Property MyProperty \n Set\nEnd Set\nEnd Property ");
Assert.AreEqual("MyProperty", pd.Name);
Assert.AreEqual("System.Object", pd.TypeReference.Type);
Assert.IsFalse(pd.HasGetRegion);
Assert.IsTrue(pd.HasSetRegion);
Assert.IsTrue((pd.Modifier & Modifiers.WriteOnly) == Modifiers.WriteOnly);
}
[Test]
public void VBNetAutoPropertyTest()
{
PropertyDeclaration pd = ParseUtilVBNet.ParseTypeMember<PropertyDeclaration>("Property MyProperty");
Assert.AreEqual("MyProperty", pd.Name);
Assert.AreEqual("System.Object", pd.TypeReference.Type);
Assert.IsTrue(pd.HasGetRegion);
Assert.IsTrue(pd.HasSetRegion);
Assert.AreEqual(pd.Initializer, Expression.Null);
}
[Test]
public void VBNetReadOnlyAutoPropertyTest()
{
PropertyDeclaration pd = ParseUtilVBNet.ParseTypeMember<PropertyDeclaration>("ReadOnly Property MyProperty");
Assert.AreEqual("MyProperty", pd.Name);
Assert.AreEqual("System.Object", pd.TypeReference.Type);
Assert.IsTrue(pd.HasGetRegion);
Assert.IsFalse(pd.HasSetRegion);
Assert.AreEqual(pd.Initializer, Expression.Null);
}
[Test]
public void VBNetWriteOnlyAutoPropertyTest()
{
PropertyDeclaration pd = ParseUtilVBNet.ParseTypeMember<PropertyDeclaration>("WriteOnly Property MyProperty");
Assert.AreEqual("MyProperty", pd.Name);
Assert.AreEqual("System.Object", pd.TypeReference.Type);
Assert.IsFalse(pd.HasGetRegion);
Assert.IsTrue(pd.HasSetRegion);
Assert.AreEqual(pd.Initializer, Expression.Null);
}
[Test]
public void VBNetSimpleInitializerAutoPropertyTest()
{
PropertyDeclaration pd = ParseUtilVBNet.ParseTypeMember<PropertyDeclaration>("Property MyProperty = 5");
Assert.AreEqual("MyProperty", pd.Name);
Assert.AreEqual("System.Object", pd.TypeReference.Type);
Assert.IsTrue(pd.HasGetRegion);
Assert.IsTrue(pd.HasSetRegion);
Assert.AreEqual(pd.Initializer.ToString(), new PrimitiveExpression(5).ToString());
}
[Test]
public void VBNetSimpleInitializerAutoPropertyWithTypeTest()
{
PropertyDeclaration pd = ParseUtilVBNet.ParseTypeMember<PropertyDeclaration>("Property MyProperty As Integer = 5");
Assert.AreEqual("MyProperty", pd.Name);
Assert.AreEqual("System.Int32", pd.TypeReference.Type);
Assert.IsTrue(pd.HasGetRegion);
Assert.IsTrue(pd.HasSetRegion);
Assert.AreEqual(pd.Initializer.ToString(), new PrimitiveExpression(5).ToString());
}
[Test]
public void VBNetSimpleObjectInitializerAutoPropertyTest()
{
PropertyDeclaration pd = ParseUtilVBNet.ParseTypeMember<PropertyDeclaration>("Property MyProperty As New List");
Assert.AreEqual("MyProperty", pd.Name);
Assert.AreEqual("List", pd.TypeReference.Type);
Assert.IsTrue(pd.HasGetRegion);
Assert.IsTrue(pd.HasSetRegion);
Assert.AreEqual(pd.Initializer.ToString(), new ObjectCreateExpression(new TypeReference("List"), null).ToString());
}
#endregion
}

2
src/Main/Base/Project/Src/Editor/IBracketSearcher.cs

@ -17,7 +17,7 @@ namespace ICSharpCode.SharpDevelop.Editor @@ -17,7 +17,7 @@ namespace ICSharpCode.SharpDevelop.Editor
/// <summary>
/// Searches for a matching bracket from the given offset to the start of the document.
/// </summary>
/// <returns>A BracketSearchResult that contains the positions and lengths of the brackets. Return null if there is nothing to highlight.</returns>
/// <returns>A BracketSearchResult that contains the positions and lengths of the brackets.</returns>
BracketSearchResult SearchBracket(IDocument document, int offset);
}

1
src/Main/Base/Test/ICSharpCode.SharpDevelop.Tests.csproj

@ -101,7 +101,6 @@ @@ -101,7 +101,6 @@
<Compile Include="Utils\MockTextMarkerService.cs" />
<Compile Include="Utils\Tests\MockAssemblyTests.cs" />
<Compile Include="VBExpressionFinderTests.cs" />
<Compile Include="VBNetExpressionFinderTests.cs" />
<Compile Include="WebReferences\ValidReferenceNameTests.cs" />
<Compile Include="WebReferences\ValidWebReferenceNamespaceTests.cs" />
<Compile Include="WebReferences\WebReferenceProjectItemsTest.cs" />

1
src/Main/ICSharpCode.SharpDevelop.Dom/Project/ICSharpCode.SharpDevelop.Dom.csproj

@ -144,7 +144,6 @@ @@ -144,7 +144,6 @@
<Compile Include="Src\IComment.cs" />
<Compile Include="Src\ReflectionLayer\ReflectionTypeNameSyntaxError.cs" />
<Compile Include="Src\SignatureComparer.cs" />
<Compile Include="Src\VBNet\VBNetExpressionFinder.cs" />
<Compile Include="Src\XmlDoc.cs" />
<Compile Include="Src\Tag.cs" />
<Compile Include="Src\ResolveResult.cs" />

36
src/Main/ICSharpCode.SharpDevelop.Dom/Project/Src/NRefactoryResolver/NRefactoryResolver.cs

@ -1117,15 +1117,6 @@ namespace ICSharpCode.SharpDevelop.Dom.NRefactoryResolver @@ -1117,15 +1117,6 @@ namespace ICSharpCode.SharpDevelop.Dom.NRefactoryResolver
}
}
static void AddVBNetKeywords(List<ICompletionEntry> ar, BitArray keywords)
{
for (int i = 0; i < keywords.Length; i++) {
if (keywords[i]) {
ar.Add(new KeywordEntry(NR.Parser.VB.Tokens.GetTokenString(i)));
}
}
}
public List<ICompletionEntry> CtrlSpace(int caretLine, int caretColumn, ParseInformation parseInfo, string fileContent, ExpressionContext context)
{
if (!Initialize(parseInfo, caretLine, caretColumn))
@ -1133,19 +1124,15 @@ namespace ICSharpCode.SharpDevelop.Dom.NRefactoryResolver @@ -1133,19 +1124,15 @@ namespace ICSharpCode.SharpDevelop.Dom.NRefactoryResolver
List<ICompletionEntry> result = new List<ICompletionEntry>();
if (language == NR.SupportedLanguage.VBNet) {
if (context == ExpressionContext.TypeDeclaration) {
AddVBNetKeywords(result, NR.Parser.VB.Tokens.TypeLevel);
} else if (context == ExpressionContext.Global) {
AddVBNetKeywords(result, NR.Parser.VB.Tokens.GlobalLevel);
} else {
AddVBNetPrimitiveTypes(result);
CtrlSpaceInternal(result, fileContent);
foreach (KeyValuePair<string, string> pair in TypeReference.PrimitiveTypesVB) {
if ("System." + pair.Key != pair.Value) {
IClass c = GetPrimitiveClass(pair.Value, pair.Key);
if (c != null) result.Add(c);
}
}
result.Add(new KeywordEntry("Global"));
result.Add(new KeywordEntry("New"));
CtrlSpaceInternal(result, fileContent);
} else {
if (context == ExpressionContext.TypeDeclaration) {
AddCSharpKeywords(result, NR.Parser.CSharp.Tokens.TypeLevel);
@ -1230,17 +1217,6 @@ namespace ICSharpCode.SharpDevelop.Dom.NRefactoryResolver @@ -1230,17 +1217,6 @@ namespace ICSharpCode.SharpDevelop.Dom.NRefactoryResolver
}
return result;
}
void AddVBNetPrimitiveTypes(List<ICompletionEntry> result)
{
foreach (KeyValuePair<string, string> pair in TypeReference.PrimitiveTypesVB) {
if ("System." + pair.Key != pair.Value) {
IClass c = GetPrimitiveClass(pair.Value, pair.Key);
if (c != null)
result.Add(c);
}
}
}
void AddCSharpPrimitiveTypes(List<ICompletionEntry> result)
{

Loading…
Cancel
Save