Browse Source

- updated visitors

- implemented "convert to automatic property" for VB.NET
- started implementation of "CC while you type"
- first draft of Block highlighting
- implemented bracket highlighting

git-svn-id: svn://svn.sharpdevelop.net/sharpdevelop/branches/vbnet@5799 1ccf3a8d-04fe-1044-b7c0-cef0b8235c61
pull/1/head
Siegfried Pammer 16 years ago
parent
commit
dfbcf6faf4
  1. 5
      src/AddIns/BackendBindings/Boo/NRefactoryToBooConverter/Project/ConvertVisitor.cs
  2. 187
      src/AddIns/BackendBindings/VBNetBinding/Project/Src/FormattingStrategy/VBNetFormattingStrategy.cs
  3. 6
      src/AddIns/BackendBindings/VBNetBinding/Project/Src/FormattingStrategy/VBStatement.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. 12
      src/Libraries/AvalonEdit/ICSharpCode.AvalonEdit/Highlighting/Resources/VBNET-Mode.xshd
  8. 2
      src/Main/Base/Project/Src/Editor/IBracketSearcher.cs
  9. 43
      src/Main/Base/Project/Src/TextEditor/Commands/ClassMemberMenuBuilder.cs
  10. 1
      src/Main/Base/Test/ICSharpCode.SharpDevelop.Tests.csproj
  11. 1
      src/Main/ICSharpCode.SharpDevelop.Dom/Project/ICSharpCode.SharpDevelop.Dom.csproj
  12. 36
      src/Main/ICSharpCode.SharpDevelop.Dom/Project/Src/NRefactoryResolver/NRefactoryResolver.cs

5
src/AddIns/BackendBindings/Boo/NRefactoryToBooConverter/Project/ConvertVisitor.cs

@ -259,5 +259,10 @@ namespace NRefactoryToBooConverter
{ {
throw new NotImplementedException(); throw new NotImplementedException();
} }
public object VisitMemberInitializerExpression(MemberInitializerExpression memberInitializerExpression, object data)
{
throw new NotImplementedException();
}
} }
} }

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

@ -27,11 +27,21 @@ namespace VBNetBinding
/// </summary> /// </summary>
public class VBNetFormattingStrategy : DefaultFormattingStrategy public class VBNetFormattingStrategy : DefaultFormattingStrategy
{ {
List<VBStatement> statements; static readonly List<VBStatement> statements;
IList<string> keywords;
VBStatement interfaceStatement;
List<int> blockTokens = new List<int>( 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>(
new int[] { new int[] {
Tokens.Class, Tokens.Module, Tokens.Namespace, Tokens.Interface, Tokens.Structure, Tokens.Class, Tokens.Module, Tokens.Namespace, Tokens.Interface, Tokens.Structure,
Tokens.Sub, Tokens.Function, Tokens.Operator, Tokens.Sub, Tokens.Function, Tokens.Operator,
@ -42,33 +52,33 @@ namespace VBNetBinding
bool doCasing; bool doCasing;
bool doInsertion; bool doInsertion;
public VBNetFormattingStrategy() static VBNetFormattingStrategy()
{ {
statements = new List<VBStatement>(); statements = new List<VBStatement>();
statements.Add(new VBStatement(@"^if.*?(then|\s+_)$", "^end ?if$", "End If", 1)); 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)); 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)); 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)); 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)); 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)); statements.Add(new VBStatement(@"^while\s+", "^end while$", "End While", 1, Tokens.While));
statements.Add(new VBStatement(@"^select case", "^end select$", "End Select", 1)); 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)); 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)); 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)); 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)); 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)); statements.Add(new VBStatement(@"\bfor\s+.*?$", "^next( \\w+)?$", "Next", 1, Tokens.For));
statements.Add(new VBStatement(@"^synclock\s+.*?$", "^end synclock$", "End SyncLock", 1)); statements.Add(new VBStatement(@"^synclock\s+.*?$", "^end synclock$", "End SyncLock", 1, Tokens.SyncLock));
statements.Add(new VBStatement(@"^get$", "^end get$", "End Get", 1)); statements.Add(new VBStatement(@"^get$", "^end get$", "End Get", 1, Tokens.Get));
statements.Add(new VBStatement(@"^with\s+.*?$", "^end with$", "End With", 1)); statements.Add(new VBStatement(@"^with\s+.*?$", "^end with$", "End With", 1, Tokens.With));
statements.Add(new VBStatement(@"^set(\s*\(.*?\))?$", "^end set$", "End Set", 1)); statements.Add(new VBStatement(@"^set(\s*\(.*?\))?$", "^end set$", "End Set", 1, Tokens.Set));
statements.Add(new VBStatement(@"^try$", "^end try$", "End Try", 1)); statements.Add(new VBStatement(@"^try$", "^end try$", "End Try", 1, Tokens.Try));
statements.Add(new VBStatement(@"^do\s+.+?$", "^loop$", "Loop", 1)); statements.Add(new VBStatement(@"^do\s+.+?$", "^loop$", "Loop", 1, Tokens.Do));
statements.Add(new VBStatement(@"^do$", "^loop .+?$", "Loop While ", 1)); statements.Add(new VBStatement(@"^do$", "^loop .+?$", "Loop While ", 1, Tokens.Do));
statements.Add(new VBStatement(@"\benum\s+\w+$", "^end enum$", "End Enum", 1)); 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); interfaceStatement = new VBStatement(@"\binterface\s+\w+\s*($|\(\s*Of)", "^end interface$", "End Interface", 1, Tokens.Interface);
statements.Add(interfaceStatement); statements.Add(interfaceStatement);
statements.Add(new VBStatement(@"\busing\s+", "^end using$", "End Using", 1)); statements.Add(new VBStatement(@"\busing\s+", "^end using$", "End Using", 1, Tokens.Using));
statements.Add(new VBStatement(@"^#region\s+", "^#end region$", "#End Region", 0)); statements.Add(new VBStatement(@"^#region\s+", "^#end region$", "#End Region", 0, -1));
keywords = new string[] { keywords = new string[] {
"AddHandler", "AddressOf", "Alias", "And", "AddHandler", "AddressOf", "Alias", "And",
@ -139,15 +149,7 @@ namespace VBNetBinding
if (ch == '\n' && lineAboveText != null) if (ch == '\n' && lineAboveText != null)
{ {
string textToReplace = lineAboveText; string textToReplace = TrimLine(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) if (doCasing)
DoCasingOnLine(lineAbove, textToReplace, editor); DoCasingOnLine(lineAbove, textToReplace, editor);
@ -158,11 +160,11 @@ namespace VBNetBinding
if (IsInString(lineAboveText)) { if (IsInString(lineAboveText)) {
if (IsFinishedString(curLineText)) { if (IsFinishedString(curLineText)) {
editor.Document.Insert(lineAbove.Offset + lineAbove.Length, editor.Document.Insert(lineAbove.Offset + lineAbove.Length,
"\" & _"); "\" & _");
editor.Document.Insert(currentLine.Offset, "\""); editor.Document.Insert(currentLine.Offset, "\"");
} else { } else {
editor.Document.Insert(lineAbove.Offset + lineAbove.Length, editor.Document.Insert(lineAbove.Offset + lineAbove.Length,
"\""); "\"");
} }
} else { } else {
string indent = DocumentUtilitites.GetWhitespaceAfter(editor.Document, lineAbove.Offset); string indent = DocumentUtilitites.GetWhitespaceAfter(editor.Document, lineAbove.Offset);
@ -205,6 +207,18 @@ 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) void DoInsertionOnLine(string terminator, IDocumentLine currentLine, IDocumentLine lineAbove, string textToReplace, ITextEditor editor, int lineNr)
{ {
string curLineText = currentLine.Text; string curLineText = currentLine.Text;
@ -355,6 +369,8 @@ namespace VBNetBinding
if (currentToken.EndLocation.Line > lineNr) if (currentToken.EndLocation.Line > lineNr)
break; break;
prevToken = currentToken;
} }
if (tokens.Count > 0) if (tokens.Count > 0)
@ -400,7 +416,7 @@ namespace VBNetBinding
return !inString; return !inString;
} }
bool IsDeclaration(int type) internal static bool IsDeclaration(int type)
{ {
return (type == Tokens.Class) || return (type == Tokens.Class) ||
(type == Tokens.Module) || (type == Tokens.Module) ||
@ -489,7 +505,7 @@ namespace VBNetBinding
return false; return false;
} }
bool IsMatchingEnd(Token begin, Token end) internal static bool IsMatchingEnd(Token begin, Token end)
{ {
if (begin.Kind == end.Kind) if (begin.Kind == end.Kind)
return true; return true;
@ -648,7 +664,7 @@ namespace VBNetBinding
indentation.Push((indentation.PeekOrDefault() ?? string.Empty) + addIndent); indentation.Push((indentation.PeekOrDefault() ?? string.Empty) + addIndent);
} }
bool IsBlockStart(ILexer lexer, Token current, Token prev) internal static bool IsBlockStart(ILexer lexer, Token current, Token prev)
{ {
if (blockTokens.Contains(current.Kind)) { if (blockTokens.Contains(current.Kind)) {
if (current.Kind == Tokens.If) { if (current.Kind == Tokens.If) {
@ -714,7 +730,7 @@ namespace VBNetBinding
return IsSpecialCase(current, prev); return IsSpecialCase(current, prev);
} }
bool IsBlockEnd(Token current, Token prev) internal static bool IsBlockEnd(Token current, Token prev)
{ {
if (current.Kind == Tokens.Next) { if (current.Kind == Tokens.Next) {
if (prev.Kind == Tokens.Resume) if (prev.Kind == Tokens.Resume)
@ -736,7 +752,7 @@ namespace VBNetBinding
return IsSpecialCase(current, prev); return IsSpecialCase(current, prev);
} }
bool IsSpecialCase(Token current, Token prev) static bool IsSpecialCase(Token current, Token prev)
{ {
switch (current.Kind) { switch (current.Kind) {
case Tokens.Else: case Tokens.Else:
@ -789,9 +805,9 @@ namespace VBNetBinding
} }
} }
bool IsStatement(string text) static bool IsStatement(string text)
{ {
foreach (VBStatement s in this.statements) { foreach (VBStatement s in statements) {
if (Regex.IsMatch(text, s.StartRegex, RegexOptions.IgnoreCase)) if (Regex.IsMatch(text, s.StartRegex, RegexOptions.IgnoreCase))
return true; return true;
} }
@ -849,84 +865,5 @@ namespace VBNetBinding
{ {
SurroundSelectionWithSingleLineComment(editor, "'"); 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,6 +6,8 @@
// </file> // </file>
using System; using System;
using ICSharpCode.NRefactory.Parser;
using ICSharpCode.NRefactory.Parser.VB;
namespace VBNetBinding namespace VBNetBinding
{ {
@ -15,18 +17,20 @@ namespace VBNetBinding
public string EndRegex = ""; public string EndRegex = "";
public string EndStatement = ""; public string EndStatement = "";
public int StatementToken = 0;
public int IndentPlus = 0; public int IndentPlus = 0;
public VBStatement() public VBStatement()
{ {
} }
public VBStatement(string startRegex, string endRegex, string endStatement, int indentPlus) public VBStatement(string startRegex, string endRegex, string endStatement, int indentPlus, int statementToken)
{ {
StartRegex = startRegex; StartRegex = startRegex;
EndRegex = endRegex; EndRegex = endRegex;
EndStatement = endStatement; EndStatement = endStatement;
IndentPlus = indentPlus; IndentPlus = indentPlus;
StatementToken = statementToken;
} }
} }
} }

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

@ -41,7 +41,38 @@ namespace VBNetBinding
return CodeCompletionKeyPressResult.Completed; return CodeCompletionKeyPressResult.Completed;
} else if (ch == '\n') { } else if (ch == '\n') {
TryDeclarationTypeInference(editor, editor.Document.GetLineForOffset(editor.Caret.Offset)); 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); return base.HandleKeyPress(editor, ch);
} }

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

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

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

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

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

@ -3,6 +3,7 @@
<!-- Syntaxdefinition for VB.NET, v0.1 Rev 1 by Christian Holm --> <!-- Syntaxdefinition for VB.NET, v0.1 Rev 1 by Christian Holm -->
<!-- Updated 2005 by Daniel Grunwald for VB.NET 2.0 --> <!-- Updated 2005 by Daniel Grunwald for VB.NET 2.0 -->
<!-- Converted to AvalonEdit format by Daniel Grunwald in 2010 --> <!-- Converted to AvalonEdit format by Daniel Grunwald in 2010 -->
<!-- Updated 2010 by Siegfried Oleg Pammer for VB.NET 9 and 10 -->
<SyntaxDefinition name="VBNET" extensions=".vb" xmlns="http://icsharpcode.net/sharpdevelop/syntaxdefinition/2008"> <SyntaxDefinition name="VBNET" extensions=".vb" xmlns="http://icsharpcode.net/sharpdevelop/syntaxdefinition/2008">
<Color name="Comment" foreground="Green" exampleText="' comment" /> <Color name="Comment" foreground="Green" exampleText="' comment" />
<Color name="String" exampleText="text = &quot;Hello, World!&quot;" /> <Color name="String" exampleText="text = &quot;Hello, World!&quot;" />
@ -201,6 +202,17 @@
<Word>Next</Word> <Word>Next</Word>
<Word>Select</Word> <Word>Select</Word>
<Word>Case</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>
<Word>Key</Word>
</Keywords> </Keywords>
<Keywords color="ContextKeywords"> <Keywords color="ContextKeywords">
<Word>Ansi</Word> <Word>Ansi</Word>

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

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

43
src/Main/Base/Project/Src/TextEditor/Commands/ClassMemberMenuBuilder.cs

@ -255,27 +255,33 @@ namespace ICSharpCode.SharpDevelop.DefaultEditor.Commands
bool isAutomatic = false; bool isAutomatic = false;
if (property.CanGet) { if (property.CanGet) {
int getterStartOffset = editor.Document.PositionToOffset(property.GetterRegion.BeginLine, property.GetterRegion.BeginColumn); if (property.GetterRegion.IsEmpty)
int getterEndOffset = editor.Document.PositionToOffset(property.GetterRegion.EndLine, property.GetterRegion.EndColumn); isAutomatic = true;
else {
string text = editor.Document.GetText(getterStartOffset, getterEndOffset - getterStartOffset) int getterStartOffset = editor.Document.PositionToOffset(property.GetterRegion.BeginLine, property.GetterRegion.BeginColumn);
.Replace(" ", "").Replace("\t", "").Replace("\n", "").Replace("\r", ""); int getterEndOffset = editor.Document.PositionToOffset(property.GetterRegion.EndLine, property.GetterRegion.EndColumn);
isAutomatic = text == "get;"; string text = editor.Document.GetText(getterStartOffset, getterEndOffset - getterStartOffset)
.Replace(" ", "").Replace("\t", "").Replace("\n", "").Replace("\r", "");
isAutomatic = text == "get;";
}
} }
if (property.CanSet) { if (property.CanSet) {
int setterStartOffset = editor.Document.PositionToOffset(property.SetterRegion.BeginLine, property.SetterRegion.BeginColumn); if (property.SetterRegion.IsEmpty)
int setterEndOffset = editor.Document.PositionToOffset(property.SetterRegion.EndLine, property.SetterRegion.EndColumn); isAutomatic |= true;
else {
string text = editor.Document.GetText(setterStartOffset, setterEndOffset - setterStartOffset) int setterStartOffset = editor.Document.PositionToOffset(property.SetterRegion.BeginLine, property.SetterRegion.BeginColumn);
.Replace(" ", "").Replace("\t", "").Replace("\n", "").Replace("\r", ""); int setterEndOffset = editor.Document.PositionToOffset(property.SetterRegion.EndLine, property.SetterRegion.EndColumn);
isAutomatic |= text == "set;"; string text = editor.Document.GetText(setterStartOffset, setterEndOffset - setterStartOffset)
.Replace(" ", "").Replace("\t", "").Replace("\n", "").Replace("\r", "");
isAutomatic |= text == "set;";
}
} }
Console.WriteLine(property.GetterRegion);
Console.WriteLine(property.SetterRegion);
return isAutomatic; return isAutomatic;
} }
@ -302,7 +308,10 @@ namespace ICSharpCode.SharpDevelop.DefaultEditor.Commands
p.SetRegion.Modifier = CodeGenerator.ConvertModifier(member.SetterModifiers, finder); p.SetRegion.Modifier = CodeGenerator.ConvertModifier(member.SetterModifiers, finder);
int startOffset = textEditor.Document.PositionToOffset(member.Region.BeginLine, member.Region.BeginColumn); int startOffset = textEditor.Document.PositionToOffset(member.Region.BeginLine, member.Region.BeginColumn);
int endOffset = textEditor.Document.PositionToOffset(member.BodyRegion.EndLine, member.BodyRegion.EndColumn); int endOffset = textEditor.Document.PositionToOffset(member.Region.EndLine, member.Region.EndColumn);
if (!member.BodyRegion.IsEmpty)
endOffset = textEditor.Document.PositionToOffset(member.BodyRegion.EndLine, member.BodyRegion.EndColumn);
using (textEditor.Document.OpenUndoGroup()) { using (textEditor.Document.OpenUndoGroup()) {
textEditor.Document.Remove(startOffset, endOffset - startOffset); textEditor.Document.Remove(startOffset, endOffset - startOffset);

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

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

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

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

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

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

Loading…
Cancel
Save