From 0d060673297dc057af689b2a7295ca5e250550c9 Mon Sep 17 00:00:00 2001 From: "Ilya.Kazakevich" Date: Wed, 25 Feb 2015 22:31:53 +0300 Subject: [PATCH] PY-14977 PyCharm is not obeying my file specific code style for HTML Django Templates do not have HTML as base language anymore. Instead, they use DjangoTemplateFormatter.getTemplateDataLanguage() which is much better. Indents are provided via EP DjangoFileIndentOptionsProvider. --- .../PythonTemplateLanguage.java | 5 ++--- .../com/jetbrains/python/PyEditingTest.java | 7 +------ .../com/jetbrains/python/PyIndentTest.java | 7 +------ .../jetbrains/python/fixtures/PyTestCase.java | 17 +++++++++++++++++ 4 files changed, 21 insertions(+), 15 deletions(-) diff --git a/python/openapi/src/com/jetbrains/python/templateLanguages/PythonTemplateLanguage.java b/python/openapi/src/com/jetbrains/python/templateLanguages/PythonTemplateLanguage.java index b5ccf9bd6eb7..30ea8f0b6859 100644 --- a/python/openapi/src/com/jetbrains/python/templateLanguages/PythonTemplateLanguage.java +++ b/python/openapi/src/com/jetbrains/python/templateLanguages/PythonTemplateLanguage.java @@ -14,10 +14,9 @@ import org.jetbrains.annotations.Nullable; public abstract class PythonTemplateLanguage extends Language implements TemplateLanguage { - protected PythonTemplateLanguage(@Nullable final Language baseLanguage, - @NotNull @NonNls final String ID, + protected PythonTemplateLanguage(@NotNull @NonNls final String ID, @NotNull @NonNls final String... mimeTypes) { - super(baseLanguage, ID, mimeTypes); + super(null, ID, mimeTypes); } /** diff --git a/python/testSrc/com/jetbrains/python/PyEditingTest.java b/python/testSrc/com/jetbrains/python/PyEditingTest.java index b9511b92c04b..7a671b0b8b3d 100644 --- a/python/testSrc/com/jetbrains/python/PyEditingTest.java +++ b/python/testSrc/com/jetbrains/python/PyEditingTest.java @@ -105,12 +105,7 @@ public class PyEditingTest extends PyTestCase { private void doTestBackspace(final String fileName, final LogicalPosition pos) { myFixture.configureByFile("/editing/" + fileName + ".before.py"); myFixture.getEditor().getCaretModel().moveToLogicalPosition(pos); - CommandProcessor.getInstance().executeCommand(myFixture.getProject(), new Runnable() { - @Override - public void run() { - myFixture.performEditorAction(IdeActions.ACTION_EDITOR_BACKSPACE); - } - }, "", null); + pressButton(IdeActions.ACTION_EDITOR_BACKSPACE); myFixture.checkResultByFile("/editing/" + fileName + ".after.py", true); } diff --git a/python/testSrc/com/jetbrains/python/PyIndentTest.java b/python/testSrc/com/jetbrains/python/PyIndentTest.java index 691608dfa0c3..0164e14fc5ce 100644 --- a/python/testSrc/com/jetbrains/python/PyIndentTest.java +++ b/python/testSrc/com/jetbrains/python/PyIndentTest.java @@ -28,12 +28,7 @@ public class PyIndentTest extends PyTestCase { final String name = getTestName(false); myFixture.configureByText(name + ".py", before); - CommandProcessor.getInstance().executeCommand(myFixture.getProject(), new Runnable() { - @Override - public void run() { - myFixture.performEditorAction(IdeActions.ACTION_EDITOR_ENTER); - } - }, "", null); + pressButton(IdeActions.ACTION_EDITOR_ENTER); String s = myFixture.getFile().getText(); myFixture.checkResult(after); } diff --git a/python/testSrc/com/jetbrains/python/fixtures/PyTestCase.java b/python/testSrc/com/jetbrains/python/fixtures/PyTestCase.java index ddd200e071d0..526c95efc07b 100644 --- a/python/testSrc/com/jetbrains/python/fixtures/PyTestCase.java +++ b/python/testSrc/com/jetbrains/python/fixtures/PyTestCase.java @@ -27,6 +27,7 @@ import com.intellij.find.findUsages.CustomUsageSearcher; import com.intellij.find.findUsages.FindUsagesOptions; import com.intellij.ide.DataManager; import com.intellij.openapi.actionSystem.DataContext; +import com.intellij.openapi.actionSystem.IdeActions; import com.intellij.openapi.application.ApplicationManager; import com.intellij.openapi.command.CommandProcessor; import com.intellij.openapi.editor.Editor; @@ -356,5 +357,21 @@ public abstract class PyTestCase extends UsefulTestCase { final Joiner joiner = Joiner.on("\n"); Assert.assertEquals(message, joiner.join(new TreeSet(actual)), joiner.join(new TreeSet(expected))); } + + + /** + * Clicks certain button in document on caret position + * + * @param action what button to click (const from {@link IdeActions}) (btw, there should be some way to express it using annotations) + * @see IdeActions + */ + protected final void pressButton(@NotNull final String action) { + CommandProcessor.getInstance().executeCommand(myFixture.getProject(), new Runnable() { + @Override + public void run() { + myFixture.performEditorAction(action); + } + }, "", null); + } }