Browse Source

enabled completing existing expressions on ctrl+space

git-svn-id: svn://svn.sharpdevelop.net/sharpdevelop/branches/vbnet@6136 1ccf3a8d-04fe-1044-b7c0-cef0b8235c61
pull/1/head
Siegfried Pammer 16 years ago
parent
commit
e7e141401b
  1. 8
      src/AddIns/BackendBindings/VBNetBinding/Project/Src/CompletionDataHelper.cs
  2. 18
      src/AddIns/BackendBindings/VBNetBinding/Project/Src/VBNetCompletionBinding.cs
  3. 2
      src/Libraries/NRefactory/Project/Src/Lexer/VBNet/ExpressionFinder.atg
  4. 13
      src/Libraries/NRefactory/Project/Src/Lexer/VBNet/Parser.cs
  5. 12
      src/Libraries/NRefactory/Project/Src/Lexer/VBNet/PushParser.frame
  6. 2
      src/Main/Base/Test/VBExpressionFinderTests.cs

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

@ -62,6 +62,14 @@ namespace ICSharpCode.VBNetBinding
if (addedKeywords) if (addedKeywords)
AddTemplates(editor, result); AddTemplates(editor, result);
if (pressedKey == '\0') { // ctrl+space
char prevChar = editor.Caret.Offset > 0 ? editor.Document.GetCharAt(editor.Caret.Offset - 1) : '\0';
string word = char.IsLetterOrDigit(prevChar) || prevChar == '_' ? editor.GetWordBeforeCaret() : "";
if (!string.IsNullOrWhiteSpace(word))
result.PreselectionLength = word.Length;
}
return result; return result;
} }

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

@ -46,10 +46,6 @@ namespace ICSharpCode.VBNetBinding
editor.Document.Remove(editor.SelectionStart, editor.SelectionLength); editor.Document.Remove(editor.SelectionStart, editor.SelectionLength);
} }
if (ch == ' ') {
}
VBNetExpressionFinder ef = new VBNetExpressionFinder(ParserService.GetParseInformation(editor.FileName)); VBNetExpressionFinder ef = new VBNetExpressionFinder(ParserService.GetParseInformation(editor.FileName));
ExpressionResult result; ExpressionResult result;
@ -211,15 +207,11 @@ namespace ICSharpCode.VBNetBinding
prevChar = cursor > 1 ? editor.Document.GetCharAt(cursor - 1) : ' '; prevChar = cursor > 1 ? editor.Document.GetCharAt(cursor - 1) : ' ';
} }
if (!char.IsLetterOrDigit(prevChar) && prevChar != '.') { VBNetExpressionFinder ef = new VBNetExpressionFinder(ParserService.GetParseInformation(editor.FileName));
VBNetExpressionFinder ef = new VBNetExpressionFinder(ParserService.GetParseInformation(editor.FileName)); ExpressionResult result = ef.FindExpression(editor.Document.Text, cursor);
ExpressionResult result = ef.FindExpression(editor.Document.Text, cursor); LoggingService.Debug("CC: Beginning to type a word, result=" + result + ", context=" + result.Context);
LoggingService.Debug("CC: Beginning to type a word, result=" + result + ", context=" + result.Context); editor.ShowCompletionWindow(CompletionDataHelper.GenerateCompletionData(result, editor, '\0'));
editor.ShowCompletionWindow(CompletionDataHelper.GenerateCompletionData(result, editor, ' ')); return true;
return true;
}
return false;
} }
} }
} }

2
src/Libraries/NRefactory/Project/Src/Lexer/VBNet/ExpressionFinder.atg

@ -945,7 +945,7 @@ Statement =
VariableDeclarationStatement = VariableDeclarationStatement =
( "Dim" | "Static" | "Const" ) ( "Dim" | "Static" | "Const" )
(. PushContext(Context.Identifier, la, t); .) (. PushContext(Context.Identifier, la, t); .) (.OnEachPossiblePath: SetIdentifierExpected(la); .)
Identifier (. PopContext(); .) [ "?" ] [ ( "(" { "," } ")" ) ] Identifier (. PopContext(); .) [ "?" ] [ ( "(" { "," } ")" ) ]
{ "," { ","
(. PushContext(Context.Identifier, la, t); .) (.OnEachPossiblePath: SetIdentifierExpected(la); .) (. PushContext(Context.Identifier, la, t); .) (.OnEachPossiblePath: SetIdentifierExpected(la); .)

13
src/Libraries/NRefactory/Project/Src/Lexer/VBNet/Parser.cs

@ -1333,13 +1333,13 @@ partial class ExpressionFinder {
public void InformToken(Token la) public void InformToken(Token la)
{ {
if (la != null) { nextTokenIsPotentialStartOfExpression = false;
nextTokenIsPotentialStartOfExpression = false; readXmlIdentifier = false;
readXmlIdentifier = false; nextTokenIsStartOfImportsOrAccessExpression = false;
nextTokenIsStartOfImportsOrAccessExpression = false; wasQualifierTokenAtStart = false;
//if (la != null)
identifierExpected = false; identifierExpected = false;
wasQualifierTokenAtStart = false;
}
switchlbl: switch (currentState) { switchlbl: switch (currentState) {
case 0: { case 0: {
PushContext(Context.Global, la, t); PushContext(Context.Global, la, t);
@ -4815,6 +4815,7 @@ partial class ExpressionFinder {
} }
case 335: { case 335: {
PushContext(Context.Identifier, la, t); PushContext(Context.Identifier, la, t);
SetIdentifierExpected(la);
stateStack.Push(336); stateStack.Push(336);
goto case 154; goto case 154;
} }

12
src/Libraries/NRefactory/Project/Src/Lexer/VBNet/PushParser.frame

@ -67,13 +67,13 @@ partial class ExpressionFinder {
public void InformToken(Token la) public void InformToken(Token la)
{ {
if (la != null) { nextTokenIsPotentialStartOfExpression = false;
nextTokenIsPotentialStartOfExpression = false; readXmlIdentifier = false;
readXmlIdentifier = false; nextTokenIsStartOfImportsOrAccessExpression = false;
nextTokenIsStartOfImportsOrAccessExpression = false; wasQualifierTokenAtStart = false;
//if (la != null)
identifierExpected = false; identifierExpected = false;
wasQualifierTokenAtStart = false;
}
-->informToken -->informToken
if (la != null) t = la; if (la != null) t = la;
} }

2
src/Main/Base/Test/VBExpressionFinderTests.cs

@ -91,7 +91,7 @@ End Class
[Test] [Test]
public void FindSimple() public void FindSimple()
{ {
Find(program2, "sole", 0,"Con", ExpressionContext.MethodBody); Find(program2, "sole", 0, "Con", ExpressionContext.MethodBody);
} }
[Test] [Test]

Loading…
Cancel
Save