mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-09-18 09:34:34 +07:00
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:
+48
@@ -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);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user