PY-19927 Add highlighting to __setstate__ and __sizeof__ magic methods

This commit is contained in:
Lada Gagina
2016-08-10 15:32:04 +03:00
parent a12837bf8a
commit 49caa2b777
3 changed files with 22 additions and 0 deletions
@@ -388,6 +388,8 @@ public class PyNames {
.put("__setattr__", new BuiltinDescription("(self, key, value)"))
.put("__setitem__", new BuiltinDescription("(self, key, value)"))
.put("__setslice__", new BuiltinDescription("(self, i, j, sequence)"))
.put("__setstate__", new BuiltinDescription("(self, state)"))
.put(SIZEOF, _only_self_descr)
//_BuiltinMethods.put("__self__", _only_self_descr);
//_BuiltinMethods.put("__slots__", _only_self_descr);
.put("__str__", _only_self_descr)
@@ -0,0 +1,6 @@
class <info descr="null" type="INFORMATION">A</info>():
def <info descr="null" type="INFORMATION" foreground="0x00ff00" background="0x000000" effectcolor="0xffffff" effecttype="BOXED" fonttype="1">__sizeof__</info>(<info descr="null">self</info>):
pass
def <info descr="null" type="INFORMATION" foreground="0x00ff00" background="0x000000" effectcolor="0xffffff" effecttype="BOXED" fonttype="1">__setstate__</info>(<info descr="null">self</info>, <info descr="null">state</info>):
pass
@@ -266,6 +266,20 @@ public class PythonHighlightingTest extends PyTestCase {
doTest(LanguageLevel.PYTHON35, false, false);
}
// PY-19927
public void testMagicMethods() {
EditorColorsManager manager = EditorColorsManager.getInstance();
EditorColorsScheme scheme = (EditorColorsScheme)manager.getGlobalScheme().clone();
manager.addColorsScheme(scheme);
EditorColorsManager.getInstance().setGlobalScheme(scheme);
TextAttributesKey xKey = TextAttributesKey.find("PY.PREDEFINED_DEFINITION");
TextAttributes xAttributes = new TextAttributes(Color.green, Color.black, Color.white, EffectType.BOXED, Font.BOLD);
scheme.setAttributes(xKey, xAttributes);
doTest();
}
// PY-19775
public void testAsyncBuiltinMethods() {
doTest(LanguageLevel.PYTHON35, true, false);