Skip to content
This repository has been archived by the owner on Oct 16, 2020. It is now read-only.

Commit

Permalink
Browse files Browse the repository at this point in the history
fixed documentation comment completion for VB
  • Loading branch information
siegfriedpammer committed Nov 25, 2010
1 parent dabf54f commit 9b2ae0a
Show file tree
Hide file tree
Showing 3 changed files with 26 additions and 14 deletions.
Expand Up @@ -142,7 +142,7 @@ void FormatLineInternal(ITextEditor editor, int lineNr, int cursorOffset, char c
}

if (ch == '\n' && lineAboveText != null) {
if (IsInsideDocumentationComment(editor, lineAbove, lineAbove.EndOffset)) {
if (LanguageUtils.IsInsideDocumentationComment(editor, lineAbove, lineAbove.EndOffset)) {
editor.Document.Insert(cursorOffset, "''' ");
return;
}
Expand Down Expand Up @@ -173,7 +173,7 @@ void FormatLineInternal(ITextEditor editor, int lineNr, int cursorOffset, char c

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);

Expand Down Expand Up @@ -502,18 +502,6 @@ static bool IsMatchingStatement(Token token, VBStatement statement)
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);
Expand Down
Expand Up @@ -3,6 +3,7 @@

using System;
using System.Text.RegularExpressions;
using ICSharpCode.SharpDevelop.Editor;

namespace ICSharpCode.VBNetBinding
{
Expand Down Expand Up @@ -37,5 +38,23 @@ public static string TrimLine(this string line)
// 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;
}
}
}
Expand Up @@ -38,6 +38,11 @@ public class VBNetCompletionBinding : ICodeCompletionBinding

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;

Expand Down

0 comments on commit 9b2ae0a

Please sign in to comment.