Browse Source

- added Exception handling on errors in ExpressionFinder

- implemented Option clauses in EF-Parser to allow automatic keyword completion

git-svn-id: svn://svn.sharpdevelop.net/sharpdevelop/branches/vbnet@6091 1ccf3a8d-04fe-1044-b7c0-cef0b8235c61
pull/1/head
Siegfried Pammer 16 years ago
parent
commit
d5b46a969a
  1. 5
      src/AddIns/BackendBindings/VBNetBinding/Project/Src/VBNetCodeCompletionDataProvider.cs
  2. 109
      src/AddIns/BackendBindings/VBNetBinding/Project/Src/VBNetCompletionBinding.cs
  3. 2
      src/Libraries/NRefactory/Project/Src/Lexer/VBNet/ExpressionFinder.atg
  4. 37
      src/Libraries/NRefactory/Project/Src/Lexer/VBNet/ExpressionFinder.cs
  5. 377
      src/Libraries/NRefactory/Project/Src/Lexer/VBNet/Parser.cs
  6. 13
      src/Libraries/NRefactory/Project/Src/Lexer/VBNet/PushParser.frame
  7. 14
      src/Main/ICSharpCode.SharpDevelop.Dom/Project/Src/VBNet/VBNetExpressionFinder.cs

5
src/AddIns/BackendBindings/VBNetBinding/Project/Src/VBNetCodeCompletionDataProvider.cs

@ -36,6 +36,11 @@ namespace ICSharpCode.VBNetBinding
if (expectedSet != null) if (expectedSet != null)
AddVBNetKeywords(list, expectedSet); AddVBNetKeywords(list, expectedSet);
// Inherits, Implements
if (ExpressionContext.Type == context) {
}
return list; return list;
} }

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

@ -7,14 +7,12 @@
using System; using System;
using System.Collections; using System.Collections;
using System.Collections.Generic;
using ICSharpCode.Core; using ICSharpCode.Core;
using ICSharpCode.NRefactory; using ICSharpCode.NRefactory;
using ICSharpCode.NRefactory.Parser; using ICSharpCode.NRefactory.Parser;
using ICSharpCode.NRefactory.Parser.VB; using ICSharpCode.NRefactory.Parser.VB;
using ICSharpCode.SharpDevelop; using ICSharpCode.SharpDevelop;
using ICSharpCode.SharpDevelop.Dom; using ICSharpCode.SharpDevelop.Dom;
using ICSharpCode.SharpDevelop.Dom.NRefactoryResolver;
using ICSharpCode.SharpDevelop.Dom.VBNet; using ICSharpCode.SharpDevelop.Dom.VBNet;
using ICSharpCode.SharpDevelop.Editor; using ICSharpCode.SharpDevelop.Editor;
using ICSharpCode.SharpDevelop.Editor.CodeCompletion; using ICSharpCode.SharpDevelop.Editor.CodeCompletion;
@ -38,30 +36,32 @@ namespace ICSharpCode.VBNetBinding
if (IsInComment(editor)) if (IsInComment(editor))
return CodeCompletionKeyPressResult.None; return CodeCompletionKeyPressResult.None;
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);
}
VBNetExpressionFinder ef = new VBNetExpressionFinder(ParserService.GetParseInformation(editor.FileName));
ExpressionResult result;
switch (ch) { switch (ch) {
case '\n': case '\n':
break; break;
case ' ': case ' ':
if (CodeCompletionOptions.KeywordCompletionEnabled) { result = ef.FindExpression(editor.Document.Text, editor.Caret.Offset);
string word = editor.GetWordBeforeCaret(); if (HasKeywordsOnly(result.Tag as BitArray)) {
if (!string.IsNullOrEmpty(word)) { ShowCodeCompletion(editor, result, false);
var list = HandleKeyword(editor, word); return CodeCompletionKeyPressResult.Completed;
editor.ShowCompletionWindow(list);
return CodeCompletionKeyPressResult.Completed;
}
} }
break; break;
default: default:
if (CodeCompletionOptions.CompleteWhenTyping) { if (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; int cursor = editor.Caret.Offset;
char prevChar = cursor > 1 ? editor.Document.GetCharAt(cursor - 1) : ' '; char prevChar = cursor > 1 ? editor.Document.GetCharAt(cursor - 1) : ' ';
bool afterUnderscore = prevChar == '_'; bool afterUnderscore = prevChar == '_';
@ -69,17 +69,13 @@ namespace ICSharpCode.VBNetBinding
cursor--; cursor--;
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)); 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); if ((result.Context != ExpressionContext.IdentifierExpected) &&
if (result.Context != ExpressionContext.IdentifierExpected) { (!char.IsLetterOrDigit(prevChar) && prevChar != '.')) {
var provider = new VBNetCodeCompletionDataProvider(result); ShowCodeCompletion(editor, result, afterUnderscore);
provider.ShowTemplates = true; return CodeCompletionKeyPressResult.CompletedIncludeKeyInCompletion;
provider.AllowCompleteExistingExpression = afterUnderscore;
provider.ShowCompletion(editor);
return CodeCompletionKeyPressResult.CompletedIncludeKeyInCompletion;
}
} }
} }
break; break;
@ -88,6 +84,28 @@ namespace ICSharpCode.VBNetBinding
return CodeCompletionKeyPressResult.None; return CodeCompletionKeyPressResult.None;
} }
void ShowCodeCompletion(ITextEditor editor, ExpressionResult result, bool afterUnderscore)
{
LoggingService.Debug("CC: Beginning to type a word, result=" + result + ", context=" + result.Context);
var provider = new VBNetCodeCompletionDataProvider(result);
provider.ShowTemplates = true;
provider.AllowCompleteExistingExpression = afterUnderscore;
provider.ShowCompletion(editor);
}
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;
}
bool IsInComment(ITextEditor editor) bool IsInComment(ITextEditor editor)
{ {
ILexer lexer = ParserFactory.CreateLexer(SupportedLanguage.VBNet, editor.Document.CreateReader()); ILexer lexer = ParserFactory.CreateLexer(SupportedLanguage.VBNet, editor.Document.CreateReader());
@ -142,13 +160,16 @@ namespace ICSharpCode.VBNetBinding
editor.Document.Remove(editor.SelectionStart, editor.SelectionLength); editor.Document.Remove(editor.SelectionStart, editor.SelectionLength);
} }
int cursor = editor.Caret.Offset; int cursor = editor.Caret.Offset;
char prevChar = cursor > 1 ? editor.Document.GetCharAt(cursor - 1) : ' '; char prevChar = cursor > 1 ? editor.Document.GetCharAt(cursor - 1) : ' ';
bool afterUnderscore = prevChar == '_'; bool afterUnderscore = prevChar == '_';
if (afterUnderscore) { if (afterUnderscore) {
cursor--; cursor--;
prevChar = cursor > 1 ? editor.Document.GetCharAt(cursor - 1) : ' '; prevChar = cursor > 1 ? editor.Document.GetCharAt(cursor - 1) : ' ';
} }
if (!char.IsLetterOrDigit(prevChar) && prevChar != '.') { 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);
@ -164,35 +185,5 @@ namespace ICSharpCode.VBNetBinding
return false; return false;
} }
sealed class GlobalCompletionItemProvider : CodeCompletionItemProvider
{
public override ExpressionResult GetExpression(ITextEditor editor)
{
return new ExpressionResult("Global", ExpressionContext.Importable);
}
}
ICompletionItemList HandleKeyword(ITextEditor editor, string word)
{
DefaultCompletionItemList list = new DefaultCompletionItemList();
switch (word.ToLowerInvariant()) {
case "option":
return new TextCompletionItemProvider(
"Explicit On", "Explicit Off",
"Strict On", "Strict Off",
"Compare Binary", "Compare Text",
"Infer On", "Infer Off"
).GenerateCompletionList(editor);
case "imports":
return new GlobalCompletionItemProvider().GenerateCompletionList(editor);
break;
}
return list;
}
} }
} }

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

@ -272,7 +272,7 @@ ExpressionFinder =
StatementTerminator = EOL | ":" . StatementTerminator = EOL | ":" .
OptionStatement = OptionStatement =
"Option" { ANY } StatementTerminator "Option" ( ( "Explicit" | "Strict" | "Infer" ) [ "Off" | "On" ] | "Compare" ( "Text" | "Binary" ) ) StatementTerminator
. .
ImportsStatement = ImportsStatement =

37
src/Libraries/NRefactory/Project/Src/Lexer/VBNet/ExpressionFinder.cs

@ -44,35 +44,16 @@ namespace ICSharpCode.NRefactory.Parser.VB
PushContext(context, la, t); PushContext(context, la, t);
} }
void ApplyToken(Token token) public ExpressionFinder(ExpressionFinderState state)
{ {
//Console.WriteLine(token); wasQualifierTokenAtStart = state.WasQualifierTokenAtStart;
nextTokenIsPotentialStartOfExpression = state.NextTokenIsPotentialStartOfExpression;
if (stack.Count == 0 || token == null) nextTokenIsStartOfImportsOrAccessExpression = state.NextTokenIsStartOfImportsOrAccessExpression;
return; readXmlIdentifier = state.ReadXmlIdentifier;
stateStack = new Stack<int>(state.StateStack.Reverse());
Block current = stack.Peek(); stack = new Stack<Block>(state.BlockStack.Select(x => (Block)x.Clone()).Reverse());
// currentState = state.CurrentState;
// switch (token.kind) { output = new StringBuilder();
// case Tokens.EOL:
// case Tokens.Colon:
// current.lastExpressionStart = token.EndLocation;
// break;
// default:
// if (Tokens.IdentifierTokens[token.Kind]) {
// if (lastToken != Tokens.Dot) {
// if (Tokens.IdentifierTokens[lastToken]) {
// current.context = Context.Default;
// }
// current.lastExpressionStart = token.Location;
// }
// } else if (Tokens.SimpleTypeName[token.Kind] || Tokens.ExpressionStart[token.Kind] || token.Kind == Tokens.Literal) {
// current.lastExpressionStart = token.Location;
// } else {
// current.lastExpressionStart = Location.Empty;
// current.context = Context.Default;
// }
// }
} }
void Print(string text) void Print(string text)

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

@ -2,13 +2,13 @@ using System;
using System.Collections; using System.Collections;
using System.Collections.Generic; using System.Collections.Generic;
using System.Collections.Specialized; using System.Collections.Specialized;
using System.Linq;
using System.Text; using System.Text;
using ICSharpCode.NRefactory.Ast; using ICSharpCode.NRefactory.Ast;
using ICSharpCode.NRefactory.Parser.VB; using ICSharpCode.NRefactory.Parser.VB;
using ASTAttribute = ICSharpCode.NRefactory.Ast.Attribute; using ASTAttribute = ICSharpCode.NRefactory.Ast.Attribute;
namespace ICSharpCode.NRefactory.Parser.VB { namespace ICSharpCode.NRefactory.Parser.VB {
@ -31,6 +31,7 @@ partial class ExpressionFinder {
return set[3]; return set[3];
case 6: case 6:
case 204: case 204:
case 450:
{ {
BitArray a = new BitArray(239); BitArray a = new BitArray(239);
return a; return a;
@ -69,13 +70,12 @@ partial class ExpressionFinder {
case 400: case 400:
case 442: case 442:
case 443: case 443:
case 461:
case 462: case 462:
case 474: case 463:
case 475: case 475:
case 479: case 476:
case 480: case 480:
case 482: case 481:
return set[6]; return set[6];
case 12: case 12:
case 13: case 13:
@ -141,8 +141,8 @@ partial class ExpressionFinder {
case 369: case 369:
case 427: case 427:
case 431: case 431:
case 450: case 451:
case 459: case 460:
return set[8]; return set[8];
case 19: case 19:
case 22: case 22:
@ -186,7 +186,7 @@ partial class ExpressionFinder {
case 404: case 404:
case 417: case 417:
case 430: case 430:
case 452: case 453:
{ {
BitArray a = new BitArray(239); BitArray a = new BitArray(239);
a.Set(38, true); a.Set(38, true);
@ -218,7 +218,7 @@ partial class ExpressionFinder {
case 335: case 335:
case 376: case 376:
case 380: case 380:
case 467: case 468:
{ {
BitArray a = new BitArray(239); BitArray a = new BitArray(239);
a.Set(22, true); a.Set(22, true);
@ -261,7 +261,7 @@ partial class ExpressionFinder {
case 362: case 362:
case 374: case 374:
case 375: case 375:
case 458: case 459:
return set[15]; return set[15];
case 36: case 36:
case 40: case 40:
@ -275,7 +275,7 @@ partial class ExpressionFinder {
} }
case 43: case 43:
case 54: case 54:
case 471: case 472:
{ {
BitArray a = new BitArray(239); BitArray a = new BitArray(239);
a.Set(22, true); a.Set(22, true);
@ -738,7 +738,7 @@ partial class ExpressionFinder {
case 348: case 348:
case 381: case 381:
case 429: case 429:
case 451: case 452:
return set[34]; return set[34];
case 194: case 194:
case 195: case 195:
@ -1108,15 +1108,15 @@ partial class ExpressionFinder {
} }
case 439: case 439:
return set[86]; return set[86];
case 453:
return set[87];
case 454: case 454:
case 460: return set[87];
return set[88];
case 455: case 455:
case 461:
return set[88];
case 456: case 456:
return set[89];
case 457: case 457:
return set[89];
case 458:
{ {
BitArray a = new BitArray(239); BitArray a = new BitArray(239);
a.Set(1, true); a.Set(1, true);
@ -1124,18 +1124,18 @@ partial class ExpressionFinder {
a.Set(21, true); a.Set(21, true);
return a; return a;
} }
case 463: case 464:
{ {
BitArray a = new BitArray(239); BitArray a = new BitArray(239);
a.Set(169, true); a.Set(169, true);
return a; return a;
} }
case 464:
return set[90];
case 465: case 465:
case 473: return set[90];
return set[91];
case 466: case 466:
case 474:
return set[91];
case 467:
{ {
BitArray a = new BitArray(239); BitArray a = new BitArray(239);
a.Set(22, true); a.Set(22, true);
@ -1143,32 +1143,43 @@ partial class ExpressionFinder {
a.Set(63, true); a.Set(63, true);
return a; return a;
} }
case 468:
case 469: case 469:
return set[92];
case 470: case 470:
case 472: return set[92];
case 471:
case 473:
return set[93]; return set[93];
case 476:
return set[94];
case 477: case 477:
return set[94];
case 478:
{ {
BitArray a = new BitArray(239); BitArray a = new BitArray(239);
a.Set(160, true); a.Set(160, true);
return a; return a;
} }
case 478: case 479:
{ {
BitArray a = new BitArray(239); BitArray a = new BitArray(239);
a.Set(137, true); a.Set(137, true);
return a; return a;
} }
case 481: case 482:
{ {
BitArray a = new BitArray(239); BitArray a = new BitArray(239);
a.Set(173, true); a.Set(173, true);
return a; return a;
} }
case 483:
return set[95];
case 484:
{
BitArray a = new BitArray(239);
a.Set(67, true);
a.Set(213, true);
return a;
}
case 485:
return set[96];
default: throw new InvalidOperationException(); default: throw new InvalidOperationException();
} }
} }
@ -1189,18 +1200,6 @@ partial class ExpressionFinder {
{ {
stateStack.Push(-1); // required so that we don't crash when leaving the root production stateStack.Push(-1); // required so that we don't crash when leaving the root production
} }
public ExpressionFinder(ExpressionFinderState state)
{
wasQualifierTokenAtStart = state.WasQualifierTokenAtStart;
nextTokenIsPotentialStartOfExpression = state.NextTokenIsPotentialStartOfExpression;
nextTokenIsStartOfImportsOrAccessExpression = state.NextTokenIsStartOfImportsOrAccessExpression;
readXmlIdentifier = state.ReadXmlIdentifier;
stateStack = new Stack<int>(state.StateStack.Reverse());
stack = new Stack<Block>(state.BlockStack.Select(x => (Block)x.Clone()).Reverse());
currentState = state.CurrentState;
output = new StringBuilder();
}
void Expect(int expectedKind, Token la) void Expect(int expectedKind, Token la)
{ {
@ -1235,7 +1234,7 @@ partial class ExpressionFinder {
if (la == null) { currentState = 1; break; } if (la == null) { currentState = 1; break; }
if (la.kind == 173) { if (la.kind == 173) {
stateStack.Push(1); stateStack.Push(1);
goto case 481; goto case 482;
} else { } else {
goto case 2; goto case 2;
} }
@ -1244,7 +1243,7 @@ partial class ExpressionFinder {
if (la == null) { currentState = 2; break; } if (la == null) { currentState = 2; break; }
if (la.kind == 137) { if (la.kind == 137) {
stateStack.Push(2); stateStack.Push(2);
goto case 478; goto case 479;
} else { } else {
goto case 3; goto case 3;
} }
@ -1272,7 +1271,7 @@ partial class ExpressionFinder {
case 5: { case 5: {
if (la == null) { currentState = 5; break; } if (la == null) { currentState = 5; break; }
if (la.kind == 160) { if (la.kind == 160) {
currentState = 474; currentState = 475;
break; break;
} else { } else {
if (set[4].Get(la.kind)) { if (set[4].Get(la.kind)) {
@ -1298,7 +1297,7 @@ partial class ExpressionFinder {
} }
case 8: { case 8: {
if (la == null) { currentState = 8; break; } if (la == null) { currentState = 8; break; }
if (set[95].Get(la.kind)) { if (set[97].Get(la.kind)) {
currentState = 8; currentState = 8;
break; break;
} else { } else {
@ -1393,7 +1392,7 @@ partial class ExpressionFinder {
currentState = 19; currentState = 19;
break; break;
} else { } else {
if (set[96].Get(la.kind)) { if (set[98].Get(la.kind)) {
currentState = 19; currentState = 19;
break; break;
} else { } else {
@ -1528,7 +1527,7 @@ partial class ExpressionFinder {
} }
case 36: { case 36: {
if (la == null) { currentState = 36; break; } if (la == null) { currentState = 36; break; }
if (set[97].Get(la.kind)) { if (set[99].Get(la.kind)) {
currentState = 35; currentState = 35;
break; break;
} else { } else {
@ -1547,7 +1546,7 @@ partial class ExpressionFinder {
} }
case 39: { case 39: {
if (la == null) { currentState = 39; break; } if (la == null) { currentState = 39; break; }
if (set[98].Get(la.kind)) { if (set[100].Get(la.kind)) {
currentState = 38; currentState = 38;
break; break;
} else { } else {
@ -2833,7 +2832,7 @@ partial class ExpressionFinder {
currentState = 112; currentState = 112;
break; break;
} else { } else {
if (set[99].Get(la.kind)) { if (set[101].Get(la.kind)) {
currentState = 108; currentState = 108;
break; break;
} else { } else {
@ -2905,7 +2904,7 @@ partial class ExpressionFinder {
} }
case 117: { case 117: {
if (la == null) { currentState = 117; break; } if (la == null) { currentState = 117; break; }
if (set[100].Get(la.kind)) { if (set[102].Get(la.kind)) {
currentState = 118; currentState = 118;
break; break;
} else { } else {
@ -2913,11 +2912,11 @@ partial class ExpressionFinder {
currentState = 374; currentState = 374;
break; break;
} else { } else {
if (set[101].Get(la.kind)) { if (set[103].Get(la.kind)) {
currentState = 118; currentState = 118;
break; break;
} else { } else {
if (set[99].Get(la.kind)) { if (set[101].Get(la.kind)) {
currentState = 370; currentState = 370;
break; break;
} else { } else {
@ -3012,7 +3011,7 @@ partial class ExpressionFinder {
} }
case 126: { case 126: {
if (la == null) { currentState = 126; break; } if (la == null) { currentState = 126; break; }
if (set[102].Get(la.kind)) { if (set[104].Get(la.kind)) {
currentState = 131; currentState = 131;
break; break;
} else { } else {
@ -3611,7 +3610,7 @@ partial class ExpressionFinder {
} }
case 202: { case 202: {
if (la == null) { currentState = 202; break; } if (la == null) { currentState = 202; break; }
if (set[103].Get(la.kind)) { if (set[105].Get(la.kind)) {
if (set[57].Get(la.kind)) { if (set[57].Get(la.kind)) {
if (set[39].Get(la.kind)) { if (set[39].Get(la.kind)) {
stateStack.Push(200); stateStack.Push(200);
@ -3729,7 +3728,7 @@ partial class ExpressionFinder {
currentState = 224; currentState = 224;
break; break;
} else { } else {
if (set[104].Get(la.kind)) { if (set[106].Get(la.kind)) {
if (la.kind == 132) { if (la.kind == 132) {
currentState = 221; currentState = 221;
break; break;
@ -3768,7 +3767,7 @@ partial class ExpressionFinder {
currentState = 209; currentState = 209;
break; break;
} else { } else {
if (set[105].Get(la.kind)) { if (set[107].Get(la.kind)) {
if (la.kind == 73) { if (la.kind == 73) {
currentState = 34; currentState = 34;
break; break;
@ -4349,7 +4348,7 @@ partial class ExpressionFinder {
} }
case 286: { case 286: {
if (la == null) { currentState = 286; break; } if (la == null) { currentState = 286; break; }
if (set[106].Get(la.kind)) { if (set[108].Get(la.kind)) {
if (la.kind == 144) { if (la.kind == 144) {
currentState = 288; currentState = 288;
break; break;
@ -4754,7 +4753,7 @@ partial class ExpressionFinder {
} }
case 337: { case 337: {
if (la == null) { currentState = 337; break; } if (la == null) { currentState = 337; break; }
if (set[107].Get(la.kind)) { if (set[109].Get(la.kind)) {
currentState = 337; currentState = 337;
break; break;
} else { } else {
@ -4801,7 +4800,7 @@ partial class ExpressionFinder {
} }
case 344: { case 344: {
if (la == null) { currentState = 344; break; } if (la == null) { currentState = 344; break; }
if (set[108].Get(la.kind)) { if (set[110].Get(la.kind)) {
currentState = 344; currentState = 344;
break; break;
} else { } else {
@ -4911,8 +4910,8 @@ partial class ExpressionFinder {
} }
case 358: { case 358: {
if (la == null) { currentState = 358; break; } if (la == null) { currentState = 358; break; }
if (set[109].Get(la.kind)) { if (set[111].Get(la.kind)) {
if (set[110].Get(la.kind)) { if (set[112].Get(la.kind)) {
currentState = 358; currentState = 358;
break; break;
} else { } else {
@ -4940,8 +4939,8 @@ partial class ExpressionFinder {
} }
case 359: { case 359: {
if (la == null) { currentState = 359; break; } if (la == null) { currentState = 359; break; }
if (set[111].Get(la.kind)) { if (set[113].Get(la.kind)) {
if (set[112].Get(la.kind)) { if (set[114].Get(la.kind)) {
currentState = 359; currentState = 359;
break; break;
} else { } else {
@ -4966,8 +4965,8 @@ partial class ExpressionFinder {
} }
case 360: { case 360: {
if (la == null) { currentState = 360; break; } if (la == null) { currentState = 360; break; }
if (set[113].Get(la.kind)) { if (set[115].Get(la.kind)) {
if (set[114].Get(la.kind)) { if (set[116].Get(la.kind)) {
currentState = 360; currentState = 360;
break; break;
} else { } else {
@ -5142,7 +5141,7 @@ partial class ExpressionFinder {
case 386: { case 386: {
if (la == null) { currentState = 386; break; } if (la == null) { currentState = 386; break; }
if (la.kind == 37) { if (la.kind == 37) {
currentState = 463; currentState = 464;
break; break;
} else { } else {
goto case 387; goto case 387;
@ -5150,7 +5149,7 @@ partial class ExpressionFinder {
} }
case 387: { case 387: {
if (la == null) { currentState = 387; break; } if (la == null) { currentState = 387; break; }
if (set[115].Get(la.kind)) { if (set[117].Get(la.kind)) {
currentState = 387; currentState = 387;
break; break;
} else { } else {
@ -5165,7 +5164,7 @@ partial class ExpressionFinder {
case 388: { case 388: {
if (la == null) { currentState = 388; break; } if (la == null) { currentState = 388; break; }
if (la.kind == 140) { if (la.kind == 140) {
currentState = 462; currentState = 463;
break; break;
} else { } else {
goto case 389; goto case 389;
@ -5174,7 +5173,7 @@ partial class ExpressionFinder {
case 389: { case 389: {
if (la == null) { currentState = 389; break; } if (la == null) { currentState = 389; break; }
if (la.kind == 136) { if (la.kind == 136) {
currentState = 461; currentState = 462;
break; break;
} else { } else {
goto case 390; goto case 390;
@ -5236,13 +5235,13 @@ partial class ExpressionFinder {
} }
case 396: { case 396: {
if (la == null) { currentState = 396; break; } if (la == null) { currentState = 396; break; }
if (set[116].Get(la.kind)) { if (set[118].Get(la.kind)) {
currentState = 396; currentState = 396;
break; break;
} else { } else {
if (set[87].Get(la.kind)) { if (set[87].Get(la.kind)) {
stateStack.Push(397); stateStack.Push(397);
goto case 453; goto case 454;
} else { } else {
if (la.kind == 127 || la.kind == 210) { if (la.kind == 127 || la.kind == 210) {
stateStack.Push(397); stateStack.Push(397);
@ -5471,7 +5470,7 @@ partial class ExpressionFinder {
currentState = 431; currentState = 431;
break; break;
} else { } else {
if (set[117].Get(la.kind)) { if (set[119].Get(la.kind)) {
if (la.kind == 37) { if (la.kind == 37) {
currentState = 429; currentState = 429;
break; break;
@ -5622,7 +5621,7 @@ partial class ExpressionFinder {
case 445: { case 445: {
if (la == null) { currentState = 445; break; } if (la == null) { currentState = 445; break; }
if (la.kind == 37) { if (la.kind == 37) {
currentState = 451; currentState = 452;
break; break;
} else { } else {
goto case 446; goto case 446;
@ -5631,7 +5630,7 @@ partial class ExpressionFinder {
case 446: { case 446: {
if (la == null) { currentState = 446; break; } if (la == null) { currentState = 446; break; }
if (la.kind == 63) { if (la.kind == 63) {
currentState = 450; currentState = 451;
break; break;
} else { } else {
goto case 447; goto case 447;
@ -5657,77 +5656,80 @@ partial class ExpressionFinder {
currentState = 15; currentState = 15;
break; break;
} else { } else {
Error(la); goto case 450;
goto case 15;
} }
} }
} }
case 450: { case 450: {
Error(la);
goto case 15;
}
case 451: {
stateStack.Push(447); stateStack.Push(447);
goto case 18; goto case 18;
} }
case 451: { case 452: {
if (la == null) { currentState = 451; break; } if (la == null) { currentState = 452; break; }
if (set[65].Get(la.kind)) { if (set[65].Get(la.kind)) {
stateStack.Push(452); stateStack.Push(453);
goto case 334; goto case 334;
} else { } else {
goto case 452; goto case 453;
} }
} }
case 452: { case 453: {
if (la == null) { currentState = 452; break; } if (la == null) { currentState = 453; break; }
Expect(38, la); // ")" Expect(38, la); // ")"
currentState = 446; currentState = 446;
break; break;
} }
case 453: { case 454: {
if (la == null) { currentState = 453; break; } if (la == null) { currentState = 454; break; }
if (la.kind == 88) { if (la.kind == 88) {
currentState = 454; currentState = 455;
break; break;
} else { } else {
goto case 454; goto case 455;
} }
} }
case 454: { case 455: {
PushContext(Context.IdentifierExpected, la, t); PushContext(Context.IdentifierExpected, la, t);
stateStack.Push(455); stateStack.Push(456);
goto case 460; goto case 461;
} }
case 455: { case 456: {
PopContext(); PopContext();
goto case 456; goto case 457;
} }
case 456: { case 457: {
if (la == null) { currentState = 456; break; } if (la == null) { currentState = 457; break; }
if (la.kind == 63) { if (la.kind == 63) {
currentState = 459; currentState = 460;
break; break;
} else { } else {
goto case 457; goto case 458;
} }
} }
case 457: { case 458: {
if (la == null) { currentState = 457; break; } if (la == null) { currentState = 458; break; }
if (la.kind == 20) { if (la.kind == 20) {
currentState = 458; currentState = 459;
break; break;
} else { } else {
goto case 15; goto case 15;
} }
} }
case 458: { case 459: {
stateStack.Push(15); stateStack.Push(15);
goto case 34; goto case 34;
} }
case 459: { case 460: {
stateStack.Push(457); stateStack.Push(458);
goto case 18; goto case 18;
} }
case 460: { case 461: {
if (la == null) { currentState = 460; break; } if (la == null) { currentState = 461; break; }
if (set[101].Get(la.kind)) { if (set[103].Get(la.kind)) {
currentState = stateStack.Pop(); currentState = stateStack.Pop();
break; break;
} else { } else {
@ -5742,58 +5744,58 @@ partial class ExpressionFinder {
} }
} }
} }
case 461: { case 462: {
if (la == null) { currentState = 461; break; } if (la == null) { currentState = 462; break; }
if (set[38].Get(la.kind)) { if (set[38].Get(la.kind)) {
currentState = 461; currentState = 462;
break; break;
} else { } else {
stateStack.Push(390); stateStack.Push(390);
goto case 15; goto case 15;
} }
} }
case 462: { case 463: {
if (la == null) { currentState = 462; break; } if (la == null) { currentState = 463; break; }
if (set[38].Get(la.kind)) { if (set[38].Get(la.kind)) {
currentState = 462; currentState = 463;
break; break;
} else { } else {
stateStack.Push(389); stateStack.Push(389);
goto case 15; goto case 15;
} }
} }
case 463: { case 464: {
if (la == null) { currentState = 463; break; } if (la == null) { currentState = 464; break; }
Expect(169, la); // "Of" Expect(169, la); // "Of"
currentState = 464; currentState = 465;
break; break;
} }
case 464: { case 465: {
if (la == null) { currentState = 464; break; } if (la == null) { currentState = 465; break; }
if (la.kind == 138 || la.kind == 178) { if (la.kind == 138 || la.kind == 178) {
currentState = 465; currentState = 466;
break; break;
} else { } else {
goto case 465; goto case 466;
} }
} }
case 465: {
stateStack.Push(466);
goto case 473;
}
case 466: { case 466: {
if (la == null) { currentState = 466; break; } stateStack.Push(467);
goto case 474;
}
case 467: {
if (la == null) { currentState = 467; break; }
if (la.kind == 63) { if (la.kind == 63) {
currentState = 468; currentState = 469;
break; break;
} else { } else {
goto case 467; goto case 468;
} }
} }
case 467: { case 468: {
if (la == null) { currentState = 467; break; } if (la == null) { currentState = 468; break; }
if (la.kind == 22) { if (la.kind == 22) {
currentState = 464; currentState = 465;
break; break;
} else { } else {
Expect(38, la); // ")" Expect(38, la); // ")"
@ -5801,38 +5803,38 @@ partial class ExpressionFinder {
break; break;
} }
} }
case 468: {
stateStack.Push(467);
goto case 469;
}
case 469: { case 469: {
if (la == null) { currentState = 469; break; } stateStack.Push(468);
goto case 470;
}
case 470: {
if (la == null) { currentState = 470; break; }
if (set[93].Get(la.kind)) { if (set[93].Get(la.kind)) {
goto case 472; goto case 473;
} else { } else {
if (la.kind == 35) { if (la.kind == 35) {
currentState = 470; currentState = 471;
break; break;
} else { } else {
goto case 6; goto case 6;
} }
} }
} }
case 470: {
stateStack.Push(471);
goto case 472;
}
case 471: { case 471: {
if (la == null) { currentState = 471; break; } stateStack.Push(472);
goto case 473;
}
case 472: {
if (la == null) { currentState = 472; break; }
if (la.kind == 22) { if (la.kind == 22) {
currentState = 470; currentState = 471;
break; break;
} else { } else {
goto case 44; goto case 44;
} }
} }
case 472: { case 473: {
if (la == null) { currentState = 472; break; } if (la == null) { currentState = 473; break; }
if (set[8].Get(la.kind)) { if (set[8].Get(la.kind)) {
currentState = 19; currentState = 19;
break; break;
@ -5852,8 +5854,8 @@ partial class ExpressionFinder {
} }
} }
} }
case 473: { case 474: {
if (la == null) { currentState = 473; break; } if (la == null) { currentState = 474; break; }
if (la.kind == 2) { if (la.kind == 2) {
goto case 99; goto case 99;
} else { } else {
@ -5960,70 +5962,98 @@ partial class ExpressionFinder {
} }
} }
} }
case 474: { case 475: {
PushContext(Context.IdentifierExpected, la, t); PushContext(Context.IdentifierExpected, la, t);
goto case 475; goto case 476;
} }
case 475: { case 476: {
if (la == null) { currentState = 475; break; } if (la == null) { currentState = 476; break; }
if (set[38].Get(la.kind)) { if (set[38].Get(la.kind)) {
currentState = 475; currentState = 476;
break; break;
} else { } else {
PopContext(); PopContext();
stateStack.Push(476); stateStack.Push(477);
goto case 15; goto case 15;
} }
} }
case 476: { case 477: {
if (la == null) { currentState = 476; break; } if (la == null) { currentState = 477; break; }
if (set[3].Get(la.kind)) { if (set[3].Get(la.kind)) {
stateStack.Push(476); stateStack.Push(477);
goto case 5; goto case 5;
} else { } else {
Expect(113, la); // "End" Expect(113, la); // "End"
currentState = 477; currentState = 478;
break; break;
} }
} }
case 477: { case 478: {
if (la == null) { currentState = 477; break; } if (la == null) { currentState = 478; break; }
Expect(160, la); // "Namespace" Expect(160, la); // "Namespace"
currentState = 15; currentState = 15;
break; break;
} }
case 478: { case 479: {
if (la == null) { currentState = 478; break; } if (la == null) { currentState = 479; break; }
Expect(137, la); // "Imports" Expect(137, la); // "Imports"
currentState = 479; currentState = 480;
break; break;
} }
case 479: { case 480: {
nextTokenIsStartOfImportsOrAccessExpression = true; nextTokenIsStartOfImportsOrAccessExpression = true;
if (la != null) if (la != null)
CurrentBlock.lastExpressionStart = la.Location; CurrentBlock.lastExpressionStart = la.Location;
goto case 480; goto case 481;
} }
case 480: { case 481: {
if (la == null) { currentState = 480; break; } if (la == null) { currentState = 481; break; }
if (set[38].Get(la.kind)) { if (set[38].Get(la.kind)) {
currentState = 480; currentState = 481;
break; break;
} else { } else {
goto case 15; goto case 15;
} }
} }
case 481: { case 482: {
if (la == null) { currentState = 481; break; } if (la == null) { currentState = 482; break; }
Expect(173, la); // "Option" Expect(173, la); // "Option"
currentState = 482; currentState = 483;
break; break;
} }
case 482: { case 483: {
if (la == null) { currentState = 482; break; } if (la == null) { currentState = 483; break; }
if (set[38].Get(la.kind)) { if (la.kind == 121 || la.kind == 139 || la.kind == 207) {
currentState = 482; currentState = 485;
break;
} else {
if (la.kind == 87) {
currentState = 484;
break;
} else {
goto case 450;
}
}
}
case 484: {
if (la == null) { currentState = 484; break; }
if (la.kind == 213) {
currentState = 15;
break;
} else {
if (la.kind == 67) {
currentState = 15;
break;
} else {
goto case 450;
}
}
}
case 485: {
if (la == null) { currentState = 485; break; }
if (la.kind == 170 || la.kind == 171) {
currentState = 15;
break; break;
} else { } else {
goto case 15; goto case 15;
@ -6031,7 +6061,6 @@ partial class ExpressionFinder {
} }
} }
ApplyToken(la);
if (la != null) t = la; if (la != null) t = la;
} }
@ -6139,6 +6168,8 @@ partial class ExpressionFinder {
new BitArray(new int[] {4, 1140850696, 9699551, 1108355356, 9218084, 17106180, -533524976, 67}), new BitArray(new int[] {4, 1140850696, 9699551, 1108355356, 9218084, 17106180, -533524976, 67}),
new BitArray(new int[] {4, 1140850688, 9699551, 1108355356, 9218084, 17106180, -533524976, 67}), new BitArray(new int[] {4, 1140850688, 9699551, 1108355356, 9218084, 17106180, -533524976, 67}),
new BitArray(new int[] {0, 256, 1048576, 537002112, 134217728, 436207617, 131200, 0}), new BitArray(new int[] {0, 256, 1048576, 537002112, 134217728, 436207617, 131200, 0}),
new BitArray(new int[] {0, 0, 8388608, 33554432, 2048, 0, 32768, 0}),
new BitArray(new int[] {2097154, 0, 0, 0, 0, 3072, 0, 0}),
new BitArray(new int[] {0, 0, 0, 536870912, 0, 436207616, 128, 0}), new BitArray(new int[] {0, 0, 0, 536870912, 0, 436207616, 128, 0}),
new BitArray(new int[] {0, 0, 262288, 8216, 8396800, 256, 1610679824, 2}), new BitArray(new int[] {0, 0, 262288, 8216, 8396800, 256, 1610679824, 2}),
new BitArray(new int[] {-1013972992, 822083461, 0, 0, 71499776, 163840, 16777216, 4096}), new BitArray(new int[] {-1013972992, 822083461, 0, 0, 71499776, 163840, 16777216, 4096}),

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

@ -44,18 +44,6 @@ partial class ExpressionFinder {
{ {
stateStack.Push(-1); // required so that we don't crash when leaving the root production stateStack.Push(-1); // required so that we don't crash when leaving the root production
} }
public ExpressionFinder(ExpressionFinderState state)
{
wasQualifierTokenAtStart = state.WasQualifierTokenAtStart;
nextTokenIsPotentialStartOfExpression = state.NextTokenIsPotentialStartOfExpression;
nextTokenIsStartOfImportsOrAccessExpression = state.NextTokenIsStartOfImportsOrAccessExpression;
readXmlIdentifier = state.ReadXmlIdentifier;
stateStack = new Stack<int>(state.StateStack.Reverse());
stack = new Stack<Block>(state.BlockStack.Select(x => (Block)x.Clone()).Reverse());
currentState = state.CurrentState;
output = new StringBuilder();
}
void Expect(int expectedKind, Token la) void Expect(int expectedKind, Token la)
{ {
@ -82,7 +70,6 @@ partial class ExpressionFinder {
nextTokenIsStartOfImportsOrAccessExpression = false; nextTokenIsStartOfImportsOrAccessExpression = false;
wasQualifierTokenAtStart = false; wasQualifierTokenAtStart = false;
-->informToken -->informToken
ApplyToken(la);
if (la != null) t = la; if (la != null) t = la;
} }

14
src/Main/ICSharpCode.SharpDevelop.Dom/Project/Src/VBNet/VBNetExpressionFinder.cs

@ -72,17 +72,25 @@ namespace ICSharpCode.SharpDevelop.Dom.VBNet
p.Advance(); p.Advance();
BitArray expectedSet;
try {
expectedSet = p.GetExpectedSet();
} catch (InvalidOperationException) {
expectedSet = null;
}
if (p.NextTokenIsPotentialStartOfExpression) if (p.NextTokenIsPotentialStartOfExpression)
return new ExpressionResult("", GetContext(p.CurrentBlock)); return new ExpressionResult("", DomRegion.Empty, GetContext(p.CurrentBlock), expectedSet);
int lastExpressionStartOffset = LocationToOffset(block.lastExpressionStart); int lastExpressionStartOffset = LocationToOffset(block.lastExpressionStart);
ExpressionContext context = p.IsIdentifierExpected ? ExpressionContext.IdentifierExpected : GetContext(block); ExpressionContext context = p.IsIdentifierExpected ? ExpressionContext.IdentifierExpected : GetContext(block);
if (lastExpressionStartOffset < 0) if (lastExpressionStartOffset < 0)
return new ExpressionResult(null, DomRegion.Empty, context, p.GetExpectedSet()); return new ExpressionResult(null, DomRegion.Empty, context, expectedSet);
return MakeResult(text, lastExpressionStartOffset, offset, context, p.GetExpectedSet()); return MakeResult(text, lastExpressionStartOffset, offset, context, expectedSet);
} }
ExpressionResult MakeResult(string text, int startOffset, int endOffset, ExpressionContext context, BitArray expectedKeywords) ExpressionResult MakeResult(string text, int startOffset, int endOffset, ExpressionContext context, BitArray expectedKeywords)

Loading…
Cancel
Save