Browse Source

- improved handling of highlighting of current parameter

- added SYNC to EndOfStmt to allow parser to continue at EOL and : in VB

git-svn-id: svn://svn.sharpdevelop.net/sharpdevelop/trunk@6335 1ccf3a8d-04fe-1044-b7c0-cef0b8235c61
pull/1/head
Siegfried Pammer 16 years ago
parent
commit
138742401f
  1. 12
      src/AddIns/BackendBindings/VBNetBinding/Project/Src/CompletionDataHelper.cs
  2. 9
      src/AddIns/BackendBindings/VBNetBinding/Project/Src/VBNetCompletionBinding.cs
  3. 34
      src/AddIns/DisplayBindings/AvalonEdit.AddIn/Src/SharpDevelopInsightWindow.cs
  4. 2
      src/Libraries/NRefactory/Project/Src/Lexer/VBNet/ExpressionFinder.atg
  5. 5151
      src/Libraries/NRefactory/Project/Src/Lexer/VBNet/Parser.cs
  6. 2974
      src/Libraries/NRefactory/Project/Src/Parser/VBNet/Parser.cs
  7. 4
      src/Libraries/NRefactory/Project/Src/Parser/VBNet/VBNET.ATG
  8. 4
      src/Main/Base/Project/Src/Editor/CodeCompletion/IInsightWindow.cs
  9. 4
      src/Main/Base/Project/Src/Editor/CodeCompletion/NRefactoryInsightWindowHandler.cs

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

@ -130,12 +130,12 @@ namespace ICSharpCode.VBNetBinding
static void AddSpecialItems(ref VBNetCompletionItemList result, ParseInformation info, IReturnType resolvedType, string word, IMember m, ExpressionResult expressionResult, ITextEditor editor) static void AddSpecialItems(ref VBNetCompletionItemList result, ParseInformation info, IReturnType resolvedType, string word, IMember m, ExpressionResult expressionResult, ITextEditor editor)
{ {
// if (expressionResult.Context == ExpressionContext.Type && m != null && m.BodyRegion.IsInside(editor.Caret.Line, editor.Caret.Column)) { if (expressionResult.Context == ExpressionContext.Type && m != null && m.BodyRegion.IsInside(editor.Caret.Line, editor.Caret.Column)) {
// result.Items.Add(new DefaultCompletionItem("? =") { result.Items.Add(new DefaultCompletionItem("? =") {
// Image = ClassBrowserIconService.GotoArrow, Image = ClassBrowserIconService.GotoArrow,
// Description = StringParser.Parse("${res:AddIns.VBNetBinding.CodeCompletion.QuestionmarkEqualsItem.Description}") Description = StringParser.Parse("${res:AddIns.VBNetBinding.CodeCompletion.QuestionmarkEqualsItem.Description}")
// }); });
// } }
if (resolvedType != null && AllowsDescendentAccess(resolvedType, info.CompilationUnit.ProjectContent)) if (resolvedType != null && AllowsDescendentAccess(resolvedType, info.CompilationUnit.ProjectContent))
result.Items.Add(new DefaultCompletionItem("..") { Image = ClassBrowserIconService.GotoArrow }); result.Items.Add(new DefaultCompletionItem("..") { Image = ClassBrowserIconService.GotoArrow });
if (resolvedType != null && AllowsAttributeValueAccess(resolvedType, info.CompilationUnit.ProjectContent)) if (resolvedType != null && AllowsAttributeValueAccess(resolvedType, info.CompilationUnit.ProjectContent))

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

@ -66,6 +66,7 @@ namespace ICSharpCode.VBNetBinding
if (insightWindow != null) { if (insightWindow != null) {
insightHandler.InitializeOpenedInsightWindow(editor, insightWindow); insightHandler.InitializeOpenedInsightWindow(editor, insightWindow);
insightHandler.HighlightParameter(insightWindow, 0); insightHandler.HighlightParameter(insightWindow, 0);
insightWindow.CaretPositionChanged += delegate { Run(insightWindow, editor); };;
} }
return CodeCompletionKeyPressResult.Completed; return CodeCompletionKeyPressResult.Completed;
} }
@ -77,6 +78,7 @@ namespace ICSharpCode.VBNetBinding
if (insightHandler.InsightRefreshOnComma(editor, ch, out insightWindow)) { if (insightHandler.InsightRefreshOnComma(editor, ch, out insightWindow)) {
if (insightWindow != null) { if (insightWindow != null) {
insightHandler.HighlightParameter(insightWindow, GetArgumentIndex(editor) + 1); insightHandler.HighlightParameter(insightWindow, GetArgumentIndex(editor) + 1);
insightWindow.CaretPositionChanged += delegate { Run(insightWindow, editor); };;
} }
return CodeCompletionKeyPressResult.EatKey; return CodeCompletionKeyPressResult.EatKey;
} }
@ -136,6 +138,11 @@ namespace ICSharpCode.VBNetBinding
return CodeCompletionKeyPressResult.None; return CodeCompletionKeyPressResult.None;
} }
void Run(IInsightWindow insightWindow, ITextEditor editor)
{
insightHandler.HighlightParameter(insightWindow, GetArgumentIndex(editor));
}
static int GetArgumentIndex(ITextEditor editor) static int GetArgumentIndex(ITextEditor editor)
{ {
ILexer lexer = ParserFactory.CreateLexer(SupportedLanguage.VBNet, editor.Document.CreateReader()); ILexer lexer = ParserFactory.CreateLexer(SupportedLanguage.VBNet, editor.Document.CreateReader());
@ -143,7 +150,7 @@ namespace ICSharpCode.VBNetBinding
Token t = lexer.NextToken(); Token t = lexer.NextToken();
while (t.Kind != Tokens.EOF && t.EndLocation < editor.Caret.Position) { while (t.Kind != Tokens.EOF && t.Location < editor.Caret.Position) {
ef.InformToken(t); ef.InformToken(t);
t = lexer.NextToken(); t = lexer.NextToken();
} }

34
src/AddIns/DisplayBindings/AvalonEdit.AddIn/Src/SharpDevelopInsightWindow.cs

@ -95,6 +95,10 @@ namespace ICSharpCode.AvalonEdit.AddIn
public SharpDevelopInsightWindow(TextArea textArea) : base(textArea) public SharpDevelopInsightWindow(TextArea textArea) : base(textArea)
{ {
this.Provider = new SDItemProvider(this); this.Provider = new SDItemProvider(this);
this.Provider.PropertyChanged += delegate(object sender, PropertyChangedEventArgs e) {
if (e.PropertyName == "SelectedIndex")
OnSelectedItemChanged(EventArgs.Empty);
};
this.Style = ICSharpCode.Core.Presentation.GlobalStyles.WindowStyle; this.Style = ICSharpCode.Core.Presentation.GlobalStyles.WindowStyle;
AttachEvents(); AttachEvents();
} }
@ -113,16 +117,26 @@ namespace ICSharpCode.AvalonEdit.AddIn
} }
set { set {
this.Provider.SelectedIndex = items.IndexOf(value); this.Provider.SelectedIndex = items.IndexOf(value);
OnSelectedItemChanged(EventArgs.Empty);
} }
} }
TextDocument document; TextDocument document;
Caret caret;
void AttachEvents() void AttachEvents()
{ {
document = this.TextArea.Document; document = this.TextArea.Document;
caret = this.TextArea.Caret;
if (document != null) if (document != null)
document.Changed += document_Changed; document.Changed += document_Changed;
if (caret != null)
caret.PositionChanged += caret_PositionChanged;
}
void caret_PositionChanged(object sender, EventArgs e)
{
OnCaretPositionChanged(e);
} }
/// <inheritdoc/> /// <inheritdoc/>
@ -130,6 +144,8 @@ namespace ICSharpCode.AvalonEdit.AddIn
{ {
if (document != null) if (document != null)
document.Changed -= document_Changed; document.Changed -= document_Changed;
if (caret != null)
caret.PositionChanged -= caret_PositionChanged;
base.DetachEvents(); base.DetachEvents();
} }
@ -140,5 +156,23 @@ namespace ICSharpCode.AvalonEdit.AddIn
} }
public event EventHandler<TextChangeEventArgs> DocumentChanged; public event EventHandler<TextChangeEventArgs> DocumentChanged;
public event EventHandler SelectedItemChanged;
protected virtual void OnSelectedItemChanged(EventArgs e)
{
if (SelectedItemChanged != null) {
SelectedItemChanged(this, e);
}
}
public event EventHandler CaretPositionChanged;
protected virtual void OnCaretPositionChanged(EventArgs e)
{
if (CaretPositionChanged != null) {
CaretPositionChanged(this, e);
}
}
} }
} }

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

@ -1183,7 +1183,7 @@ InvocationStatement =
ArgumentList = ArgumentList =
(. activeArgument = 0; .) Expression { "," (. activeArgument++; .) [ Expression ] } (. activeArgument = 0; .) Expression { "," (. activeArgument++; .) [ Expression ] }
| "," [ Expression ] { "," [ Expression ] } | (. activeArgument = 0; .) "," (. activeArgument++; .) [ Expression ] { "," (. activeArgument++; .) [ Expression ] }
. .
/* This production handles pseudo keywords that are needed in the grammar */ /* This production handles pseudo keywords that are needed in the grammar */

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

File diff suppressed because it is too large Load Diff

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

File diff suppressed because it is too large Load Diff

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

@ -307,9 +307,7 @@ OptionValue<ref bool val> =
. .
EndOfStmt = EndOfStmt =
EOL SYNC ( EOL | ":" )
|
":"
. .
ImportsStmt ImportsStmt

4
src/Main/Base/Project/Src/Editor/CodeCompletion/IInsightWindow.cs

@ -34,5 +34,9 @@ namespace ICSharpCode.SharpDevelop.Editor.CodeCompletion
/// when the insight window is closed. This makes it easier to avoid memory leaks. /// when the insight window is closed. This makes it easier to avoid memory leaks.
/// </remarks> /// </remarks>
event EventHandler<TextChangeEventArgs> DocumentChanged; event EventHandler<TextChangeEventArgs> DocumentChanged;
event EventHandler SelectedItemChanged;
event EventHandler CaretPositionChanged;
} }
} }

4
src/Main/Base/Project/Src/Editor/CodeCompletion/NRefactoryInsightWindowHandler.cs

@ -81,6 +81,7 @@ namespace ICSharpCode.SharpDevelop.Editor.CodeCompletion
} }
}; };
insightWindow.DocumentChanged += onDocumentChanged; insightWindow.DocumentChanged += onDocumentChanged;
insightWindow.SelectedItemChanged += delegate { HighlightParameter(insightWindow, HighlightedParameter); };
onDocumentChanged(null, null); onDocumentChanged(null, null);
} }
@ -277,12 +278,15 @@ namespace ICSharpCode.SharpDevelop.Editor.CodeCompletion
} }
} }
public int HighlightedParameter { get; set; }
public void HighlightParameter(IInsightWindow window, int index) public void HighlightParameter(IInsightWindow window, int index)
{ {
var item = window.SelectedItem as MethodInsightItem; var item = window.SelectedItem as MethodInsightItem;
if (item != null) if (item != null)
item.HighlightParameter = index; item.HighlightParameter = index;
HighlightedParameter = index;
} }
} }
} }

Loading…
Cancel
Save