IDEA-64964 Javadoc: Provide ability to configure IntelliJ IDEA to automatically insert closing tags during typing in javadoc

1. Javadoc typed handler with 'auto insert closing tag' logic is added;
2. Corresponding test is added;
3. Corresponding GUI control is provided;
This commit is contained in:
Denis Zhdanov
2011-02-02 16:06:01 +03:00
parent ae12db2a44
commit bd5fc794e0
8 changed files with 330 additions and 1 deletions
@@ -0,0 +1,48 @@
package com.intellij.codeInsight.editorActions;
import org.junit.Test;
import static org.junit.Assert.assertEquals;
/**
* @author Denis Zhdanov
* @since 02/02/2011
*/
public class JavadocTypedHandlerTest {
private static final String CARET_MARKER = "<caret>";
@Test
public void correctEmptyTagStart() {
doTest("<first></first><second><caret>", "second");
}
@Test
public void standaloneBracket() {
doTest("asdf ><caret>", null);
}
@Test
public void emptyElement() {
doTest("<tag/><caret>", null);
}
@Test
public void closingTag() {
doTest("<tag></tag><caret>", null);
}
@Test
public void startTagOnNewLine() {
doTest("<t\nag><caret>", null);
}
private static void doTest(String text, String expected) {
StringBuilder normalized = new StringBuilder();
int offset = text.indexOf(CARET_MARKER);
normalized.append(text.substring(0, offset));
normalized.append(text.substring(offset + CARET_MARKER.length()));
CharSequence actual = JavadocTypedHandler.getTagName(normalized.toString(), offset);
assertEquals(expected, actual);
}
}