mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-09-27 10:03:11 +07:00
search in strings option works correctly for Python refactorings (PY-670)
This commit is contained in:
@@ -28,12 +28,14 @@ public class PythonParserDefinition implements ParserDefinition {
|
||||
|
||||
private final TokenSet myWhitespaceTokens;
|
||||
private final TokenSet myCommentTokens;
|
||||
private final TokenSet myStringLiteralTokens;
|
||||
|
||||
public PythonParserDefinition() {
|
||||
language = (PythonLanguage)PythonFileType.INSTANCE.getLanguage();
|
||||
|
||||
myWhitespaceTokens = TokenSet.create(PyTokenTypes.LINE_BREAK, PyTokenTypes.SPACE, PyTokenTypes.TAB, PyTokenTypes.FORMFEED);
|
||||
myCommentTokens = TokenSet.create(PyTokenTypes.END_OF_LINE_COMMENT);
|
||||
myStringLiteralTokens = TokenSet.create(PyTokenTypes.STRING_LITERAL);
|
||||
}
|
||||
|
||||
@NotNull
|
||||
@@ -57,7 +59,7 @@ public class PythonParserDefinition implements ParserDefinition {
|
||||
|
||||
@NotNull
|
||||
public TokenSet getStringLiteralElements() {
|
||||
return TokenSet.EMPTY;
|
||||
return myStringLiteralTokens;
|
||||
}
|
||||
|
||||
@NotNull
|
||||
|
||||
@@ -0,0 +1,3 @@
|
||||
def f<caret>oo():
|
||||
'this is method foo'
|
||||
pass
|
||||
@@ -0,0 +1,3 @@
|
||||
def bar():
|
||||
'this is method bar'
|
||||
pass
|
||||
@@ -1,5 +1,7 @@
|
||||
package com.jetbrains.python.refactoring;
|
||||
|
||||
import com.intellij.codeInsight.TargetElementUtilBase;
|
||||
import com.intellij.psi.PsiElement;
|
||||
import com.jetbrains.python.fixtures.PyLightFixtureTestCase;
|
||||
|
||||
/**
|
||||
@@ -11,4 +13,13 @@ public class PyRenameTest extends PyLightFixtureTestCase {
|
||||
myFixture.renameElementAtCaret("qu");
|
||||
myFixture.checkResultByFile("refactoring/rename/" + getTestName(true) + "_after.py");
|
||||
}
|
||||
|
||||
public void testSearchInStrings() throws Exception { // PY-670
|
||||
myFixture.configureByFile("refactoring/rename/" + getTestName(true) + ".py");
|
||||
final PsiElement element = TargetElementUtilBase.findTargetElement(myFixture.getEditor(), TargetElementUtilBase.REFERENCED_ELEMENT_ACCEPTED |
|
||||
TargetElementUtilBase.ELEMENT_NAME_ACCEPTED);
|
||||
assertNotNull(element);
|
||||
myFixture.renameElement(element, "bar", true, false);
|
||||
myFixture.checkResultByFile("refactoring/rename/" + getTestName(true) + "_after.py");
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user