mirror of
https://gitflic.ru/project/openide/openide.git
synced 2025-12-19 01:50:56 +07:00
Adds highligting of class and function definitions, decorators, and builtins.
Fixes PY-2.
No test for builtin highlighting yet.
This commit is contained in:
@@ -2,6 +2,13 @@ package com.jetbrains.python;
|
||||
|
||||
import com.intellij.codeInsight.daemon.DaemonAnalyzerTestCase;
|
||||
import com.intellij.openapi.application.PathManager;
|
||||
import com.intellij.openapi.editor.colors.EditorColorsManager;
|
||||
import com.intellij.openapi.editor.colors.EditorColorsScheme;
|
||||
import com.intellij.openapi.editor.colors.TextAttributesKey;
|
||||
import com.intellij.openapi.editor.markup.TextAttributes;
|
||||
import com.intellij.openapi.editor.markup.EffectType;
|
||||
|
||||
import java.awt.*;
|
||||
|
||||
/**
|
||||
* @author yole
|
||||
@@ -11,6 +18,27 @@ public class PythonHighlightingTest extends DaemonAnalyzerTestCase {
|
||||
return PathManager.getHomePath() + "/plugins/python/testData/highlighting/";
|
||||
}
|
||||
|
||||
public void testDeclarations() throws Exception {
|
||||
EditorColorsManager manager = EditorColorsManager.getInstance();
|
||||
EditorColorsScheme scheme = (EditorColorsScheme)manager.getGlobalScheme().clone();
|
||||
manager.addColorsScheme(scheme);
|
||||
EditorColorsManager.getInstance().setGlobalScheme(scheme);
|
||||
|
||||
TextAttributesKey xKey = TextAttributesKey.find("PY.CLASS_DEFINITION");
|
||||
TextAttributes xAttributes = new TextAttributes(Color.blue, Color.black, Color.white, EffectType.BOXED, Font.BOLD);
|
||||
scheme.setAttributes(xKey, xAttributes);
|
||||
|
||||
xKey = TextAttributesKey.find("PY.FUNC_DEFINITION");
|
||||
xAttributes = new TextAttributes(Color.red, Color.black, Color.white, EffectType.BOXED, Font.BOLD);
|
||||
scheme.setAttributes(xKey, xAttributes);
|
||||
|
||||
xKey = TextAttributesKey.find("PY.PREDEFINED_DEFINITION");
|
||||
xAttributes = new TextAttributes(Color.green, Color.black, Color.white, EffectType.BOXED, Font.BOLD);
|
||||
scheme.setAttributes(xKey, xAttributes);
|
||||
|
||||
doTest();
|
||||
}
|
||||
|
||||
public void testReturnOutsideOfFunction() throws Exception {
|
||||
doTest();
|
||||
}
|
||||
@@ -39,13 +67,17 @@ public class PythonHighlightingTest extends DaemonAnalyzerTestCase {
|
||||
doTest();
|
||||
}
|
||||
|
||||
/* TODO: move to inspection test
|
||||
public void testMethodParams() throws Exception {
|
||||
doTest();
|
||||
}
|
||||
*/
|
||||
|
||||
public void testYieldInNestedFunction() throws Exception {
|
||||
// highlight func declaration first, lest we get an "Extra fragment highlighted" error.
|
||||
EditorColorsManager manager = EditorColorsManager.getInstance();
|
||||
EditorColorsScheme scheme = (EditorColorsScheme)manager.getGlobalScheme().clone();
|
||||
manager.addColorsScheme(scheme);
|
||||
EditorColorsManager.getInstance().setGlobalScheme(scheme);
|
||||
|
||||
TextAttributesKey xKey = TextAttributesKey.find("PY.FUNC_DEFINITION");
|
||||
TextAttributes xAttributes = new TextAttributes(Color.red, Color.black, Color.white, EffectType.BOXED, Font.BOLD);
|
||||
scheme.setAttributes(xKey, xAttributes);
|
||||
|
||||
doTest();
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user