Browse Source

fixed documentation comment completion for VB

pull/14/head
Siegfried Pammer 15 years ago
parent
commit
9b2ae0a73e
  1. 16
      src/AddIns/BackendBindings/VBNetBinding/Project/Src/FormattingStrategy/VBNetFormattingStrategy.cs
  2. 19
      src/AddIns/BackendBindings/VBNetBinding/Project/Src/LanguageUtils.cs
  3. 5
      src/AddIns/BackendBindings/VBNetBinding/Project/Src/VBNetCompletionBinding.cs

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

@ -142,7 +142,7 @@ namespace ICSharpCode.VBNetBinding @@ -142,7 +142,7 @@ namespace ICSharpCode.VBNetBinding
}
if (ch == '\n' && lineAboveText != null) {
if (IsInsideDocumentationComment(editor, lineAbove, lineAbove.EndOffset)) {
if (LanguageUtils.IsInsideDocumentationComment(editor, lineAbove, lineAbove.EndOffset)) {
editor.Document.Insert(cursorOffset, "''' ");
return;
}
@ -173,7 +173,7 @@ namespace ICSharpCode.VBNetBinding @@ -173,7 +173,7 @@ namespace ICSharpCode.VBNetBinding
IndentLines(editor, lineNr - 1, lineNr);
} else if(ch == '>') {
if (IsInsideDocumentationComment(editor, currentLine, cursorOffset)) {
if (LanguageUtils.IsInsideDocumentationComment(editor, currentLine, cursorOffset)) {
int column = editor.Caret.Offset - currentLine.Offset;
int index = Math.Min(column - 1, curLineText.Length - 1);
@ -502,18 +502,6 @@ namespace ICSharpCode.VBNetBinding @@ -502,18 +502,6 @@ namespace ICSharpCode.VBNetBinding
return empty && match;
}
static bool IsInsideDocumentationComment(ITextEditor editor, IDocumentLine curLine, int cursorOffset)
{
for (int i = curLine.Offset; i < cursorOffset; ++i) {
char ch = editor.Document.GetCharAt(i);
if (ch == '"')
return false;
if (ch == '\'' && i + 2 < cursorOffset && editor.Document.GetCharAt(i + 1) == '\'' && editor.Document.GetCharAt(i + 2) == '\'')
return true;
}
return false;
}
public override void IndentLines(ITextEditor editor, int begin, int end)
{
SmartIndentInternal(editor, begin, end);

19
src/AddIns/BackendBindings/VBNetBinding/Project/Src/LanguageUtils.cs

@ -3,6 +3,7 @@ @@ -3,6 +3,7 @@
using System;
using System.Text.RegularExpressions;
using ICSharpCode.SharpDevelop.Editor;
namespace ICSharpCode.VBNetBinding
{
@ -37,5 +38,23 @@ namespace ICSharpCode.VBNetBinding @@ -37,5 +38,23 @@ namespace ICSharpCode.VBNetBinding
// remove comments
return TrimComments(line);
}
public static bool IsInsideDocumentationComment(ITextEditor editor)
{
return IsInsideDocumentationComment(editor, editor.Document.GetLineForOffset(editor.Caret.Offset), editor.Caret.Offset);
}
public static bool IsInsideDocumentationComment(ITextEditor editor, IDocumentLine curLine, int cursorOffset)
{
for (int i = curLine.Offset; i < cursorOffset; ++i) {
char ch = editor.Document.GetCharAt(i);
if (ch == '"')
return false;
if (ch == '\'' && i + 2 < cursorOffset && editor.Document.GetCharAt(i + 1) == '\'' &&
editor.Document.GetCharAt(i + 2) == '\'')
return true;
}
return false;
}
}
}

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

@ -38,6 +38,11 @@ namespace ICSharpCode.VBNetBinding @@ -38,6 +38,11 @@ namespace ICSharpCode.VBNetBinding
public CodeCompletionKeyPressResult HandleKeyPress(ITextEditor editor, char ch)
{
if (LanguageUtils.IsInsideDocumentationComment(editor) && ch == '<') {
new CommentCompletionItemProvider().ShowCompletion(editor);
return CodeCompletionKeyPressResult.Completed;
}
if (IsInComment(editor) || IsInString(editor))
return CodeCompletionKeyPressResult.None;

Loading…
Cancel
Save