mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-09-27 10:03:11 +07:00
Process todo in docstrings (PY-11040)
This commit is contained in:
@@ -58,6 +58,9 @@ public class PyFilterLexer extends BaseFilterLexer {
|
||||
}
|
||||
else if (PyTokenTypes.STRING_NODES.contains(tokenType)) {
|
||||
scanWordsInToken(UsageSearchContext.IN_STRINGS | UsageSearchContext.IN_FOREIGN_LANGUAGES, false, true);
|
||||
if (tokenType == PyTokenTypes.DOCSTRING) {
|
||||
advanceTodoItemCountsInToken();
|
||||
}
|
||||
}
|
||||
else if (PyIndexPatternBuilder.COMMENTS.contains(tokenType)) {
|
||||
scanWordsInToken(UsageSearchContext.IN_COMMENTS, false, false);
|
||||
|
||||
@@ -44,4 +44,23 @@ public class PyTodoTest extends LightPlatformCodeInsightFixtureTestCase {
|
||||
todo.setTodoPatterns(oldPatterns);
|
||||
}
|
||||
}
|
||||
|
||||
public void testTodoInDocstrings() {
|
||||
myFixture.configureByText(PythonFileType.INSTANCE, "''' TODO: return dead parrot '''");
|
||||
TodoItem[] items = PsiTodoSearchHelper.SERVICE.getInstance(getProject()).findTodoItems(myFixture.getFile());
|
||||
assertEquals(1, items.length);
|
||||
}
|
||||
|
||||
public void testTodoInDocstrings2() {
|
||||
myFixture.configureByText(PythonFileType.INSTANCE, "def foo():\n''' TODO: return dead parrot '''");
|
||||
TodoItem[] items = PsiTodoSearchHelper.SERVICE.getInstance(getProject()).findTodoItems(myFixture.getFile());
|
||||
assertEquals(1, items.length);
|
||||
}
|
||||
|
||||
public void testTodoInTripleQuotedString() {
|
||||
myFixture.configureByText(PythonFileType.INSTANCE, "s = ''' TODO: return dead parrot '''");
|
||||
TodoItem[] items = PsiTodoSearchHelper.SERVICE.getInstance(getProject()).findTodoItems(myFixture.getFile());
|
||||
assertEquals(0, items.length); // no todo in normal triple quoted strings
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user