mirror of
https://github.com/eclipse-cdt/cdt
synced 2025-06-09 18:56:02 +02:00
Fix function and method highlighting
This commit is contained in:
parent
66b8cbde90
commit
98a81457f6
8 changed files with 171 additions and 139 deletions
|
@ -7,7 +7,7 @@ enum Enumeration {
|
||||||
|
|
||||||
const int globalConstant = 0;
|
const int globalConstant = 0;
|
||||||
int globalVariable = 0;
|
int globalVariable = 0;
|
||||||
static int globalStaticVariable;
|
static int globalStaticVariable = 0;
|
||||||
|
|
||||||
void globalFunc(int a);
|
void globalFunc(int a);
|
||||||
static void globalStaticFunc() {
|
static void globalStaticFunc() {
|
||||||
|
@ -29,6 +29,7 @@ public:
|
||||||
static int staticPubMethod(int arg) {
|
static int staticPubMethod(int arg) {
|
||||||
FUNCTION_MACRO(arg);
|
FUNCTION_MACRO(arg);
|
||||||
globalFunc(arg);
|
globalFunc(arg);
|
||||||
|
return globalStaticVariable;
|
||||||
}
|
}
|
||||||
int pubMethod();
|
int pubMethod();
|
||||||
|
|
||||||
|
@ -71,7 +72,7 @@ private:
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|
||||||
template<T1,T2> class TemplateClass {
|
template<class T1, class T2> class TemplateClass {
|
||||||
T1 tArg1;
|
T1 tArg1;
|
||||||
T2 tArg2;
|
T2 tArg2;
|
||||||
TemplateClass(T1 arg1, T2 arg2) {
|
TemplateClass(T1 arg1, T2 arg2) {
|
||||||
|
@ -80,7 +81,7 @@ template<T1,T2> class TemplateClass {
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
template<T1> class PartialInstantiatedClass : TemplateClass<T1,Base1> {};
|
template<class T1> class PartialInstantiatedClass : TemplateClass<T1, Base1> {};
|
||||||
|
|
||||||
|
|
||||||
struct CppStruct {
|
struct CppStruct {
|
||||||
|
@ -94,8 +95,10 @@ union CppUnion {
|
||||||
typedef CppUnion TUnion;
|
typedef CppUnion TUnion;
|
||||||
|
|
||||||
namespace ns {
|
namespace ns {
|
||||||
int namespaceField = 0;
|
int namespaceVar = 0;
|
||||||
int namespaceFunc() {
|
int namespaceFunc() {
|
||||||
|
globalStaticFunc();
|
||||||
|
return namespaceVar;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -104,17 +107,19 @@ int ClassContainer::protMethod() {
|
||||||
}
|
}
|
||||||
|
|
||||||
int ClassContainer::pubMethod() {
|
int ClassContainer::pubMethod() {
|
||||||
int localVar;
|
int localVar = 0;
|
||||||
return pubField;
|
return pubField + localVar;
|
||||||
}
|
}
|
||||||
|
|
||||||
int ClassContainer::staticPrivMethod() {
|
int ClassContainer::staticPrivMethod() {
|
||||||
CppStruct st= new CppStruct();
|
CppStruct* st= new CppStruct();
|
||||||
st.structField= 1;
|
st->structField= 1;
|
||||||
CppUnion un= new CppUnion();
|
CppUnion un;
|
||||||
un.unionField= 2;
|
un.unionField= 2;
|
||||||
staticPubMethod(staticPrivField);
|
staticPubMethod(staticPrivField);
|
||||||
label:
|
label:
|
||||||
FUNCTION_MACRO(0);
|
FUNCTION_MACRO(0);
|
||||||
|
if (un.unionField < st->structField) goto label;
|
||||||
|
problemMethod();
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
|
@ -19,6 +19,7 @@ import org.eclipse.cdt.ui.tests.text.CBreakIteratorTest;
|
||||||
import org.eclipse.cdt.ui.tests.text.CPartitionerTest;
|
import org.eclipse.cdt.ui.tests.text.CPartitionerTest;
|
||||||
import org.eclipse.cdt.ui.tests.text.CWordIteratorTest;
|
import org.eclipse.cdt.ui.tests.text.CWordIteratorTest;
|
||||||
import org.eclipse.cdt.ui.tests.text.NumberRuleTest;
|
import org.eclipse.cdt.ui.tests.text.NumberRuleTest;
|
||||||
|
import org.eclipse.cdt.ui.tests.text.SemanticHighlightingTest;
|
||||||
import org.eclipse.cdt.ui.tests.text.contentassist.CompletionFailedTest_MemberReference_Arrow_Prefix2;
|
import org.eclipse.cdt.ui.tests.text.contentassist.CompletionFailedTest_MemberReference_Arrow_Prefix2;
|
||||||
import org.eclipse.cdt.ui.tests.text.contentassist.CompletionTest_ArgumentType_NoPrefix;
|
import org.eclipse.cdt.ui.tests.text.contentassist.CompletionTest_ArgumentType_NoPrefix;
|
||||||
import org.eclipse.cdt.ui.tests.text.contentassist.CompletionTest_ArgumentType_NoPrefix2;
|
import org.eclipse.cdt.ui.tests.text.contentassist.CompletionTest_ArgumentType_NoPrefix2;
|
||||||
|
@ -145,6 +146,10 @@ public class AutomatedSuite extends TestSuite {
|
||||||
// Break iterator tests.
|
// Break iterator tests.
|
||||||
addTest(CBreakIteratorTest.suite());
|
addTest(CBreakIteratorTest.suite());
|
||||||
addTest(CWordIteratorTest.suite());
|
addTest(CWordIteratorTest.suite());
|
||||||
|
|
||||||
|
// highlighting tests
|
||||||
|
addTest(SemanticHighlightingTest.suite());
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -91,6 +91,8 @@ public class AbstractSemanticHighlightingTest extends TestCase {
|
||||||
|
|
||||||
private static SourceViewer fSourceViewer;
|
private static SourceViewer fSourceViewer;
|
||||||
|
|
||||||
|
private String fCurrentHighlighting;
|
||||||
|
|
||||||
protected void setUp() throws Exception {
|
protected void setUp() throws Exception {
|
||||||
super.setUp();
|
super.setUp();
|
||||||
disableAllSemanticHighlightings();
|
disableAllSemanticHighlightings();
|
||||||
|
@ -112,6 +114,7 @@ public class AbstractSemanticHighlightingTest extends TestCase {
|
||||||
|
|
||||||
String toString(Position[] positions) throws BadLocationException {
|
String toString(Position[] positions) throws BadLocationException {
|
||||||
StringBuffer buf= new StringBuffer();
|
StringBuffer buf= new StringBuffer();
|
||||||
|
buf.append("// "+fCurrentHighlighting+'\n');
|
||||||
IDocument document= fSourceViewer.getDocument();
|
IDocument document= fSourceViewer.getDocument();
|
||||||
buf.append("Position[] expected= new Position[] {\n");
|
buf.append("Position[] expected= new Position[] {\n");
|
||||||
for (int i= 0, n= positions.length; i < n; i++) {
|
for (int i= 0, n= positions.length; i < n; i++) {
|
||||||
|
@ -133,6 +136,7 @@ public class AbstractSemanticHighlightingTest extends TestCase {
|
||||||
}
|
}
|
||||||
|
|
||||||
protected void setUpSemanticHighlighting(String semanticHighlighting) {
|
protected void setUpSemanticHighlighting(String semanticHighlighting) {
|
||||||
|
fCurrentHighlighting= semanticHighlighting;
|
||||||
enableSemanticHighlighting(semanticHighlighting);
|
enableSemanticHighlighting(semanticHighlighting);
|
||||||
EditorTestHelper.forceReconcile(fSourceViewer);
|
EditorTestHelper.forceReconcile(fSourceViewer);
|
||||||
assertTrue(EditorTestHelper.joinReconciler(fSourceViewer, 0, 10000, 100));
|
assertTrue(EditorTestHelper.joinReconciler(fSourceViewer, 0, 10000, 100));
|
||||||
|
|
|
@ -27,6 +27,8 @@ import org.eclipse.cdt.internal.ui.editor.SemanticHighlightings;
|
||||||
*/
|
*/
|
||||||
public class SemanticHighlightingTest extends AbstractSemanticHighlightingTest {
|
public class SemanticHighlightingTest extends AbstractSemanticHighlightingTest {
|
||||||
|
|
||||||
|
private static final boolean PRINT_POSITIONS= false;
|
||||||
|
|
||||||
private static final Class THIS= SemanticHighlightingTest.class;
|
private static final Class THIS= SemanticHighlightingTest.class;
|
||||||
|
|
||||||
public static Test suite() {
|
public static Test suite() {
|
||||||
|
@ -50,13 +52,13 @@ public class SemanticHighlightingTest extends AbstractSemanticHighlightingTest {
|
||||||
Position[] expected= new Position[] {
|
Position[] expected= new Position[] {
|
||||||
createPosition(23, 15, 14),
|
createPosition(23, 15, 14),
|
||||||
createPosition(25, 21, 19),
|
createPosition(25, 21, 19),
|
||||||
createPosition(41, 21, 20),
|
createPosition(42, 21, 20),
|
||||||
createPosition(42, 15, 15),
|
createPosition(43, 15, 15),
|
||||||
createPosition(56, 21, 20),
|
createPosition(57, 21, 20),
|
||||||
createPosition(57, 15, 15),
|
createPosition(58, 15, 15),
|
||||||
createPosition(115, 20, 15),
|
createPosition(118, 20, 15),
|
||||||
};
|
};
|
||||||
// System.out.println(toString(actual));
|
if (PRINT_POSITIONS) System.out.println(toString(actual));
|
||||||
assertEqualPositions(expected, actual);
|
assertEqualPositions(expected, actual);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -66,22 +68,24 @@ public class SemanticHighlightingTest extends AbstractSemanticHighlightingTest {
|
||||||
Position[] expected= new Position[] {
|
Position[] expected= new Position[] {
|
||||||
createPosition(24, 14, 13),
|
createPosition(24, 14, 13),
|
||||||
createPosition(26, 8, 8),
|
createPosition(26, 8, 8),
|
||||||
createPosition(43, 15, 14),
|
createPosition(44, 15, 14),
|
||||||
createPosition(44, 8, 9),
|
createPosition(45, 8, 9),
|
||||||
createPosition(58, 15, 14),
|
createPosition(59, 15, 14),
|
||||||
createPosition(59, 8, 9),
|
createPosition(60, 8, 9),
|
||||||
createPosition(74, 7, 5),
|
|
||||||
createPosition(75, 7, 5),
|
createPosition(75, 7, 5),
|
||||||
createPosition(77, 8, 5),
|
createPosition(76, 7, 5),
|
||||||
createPosition(78, 8, 5),
|
createPosition(78, 8, 5),
|
||||||
createPosition(86, 8, 11),
|
createPosition(79, 8, 5),
|
||||||
createPosition(90, 8, 10),
|
createPosition(87, 8, 11),
|
||||||
createPosition(102, 11, 9),
|
createPosition(91, 8, 10),
|
||||||
createPosition(107, 11, 8),
|
createPosition(105, 11, 9),
|
||||||
createPosition(112, 7, 11),
|
createPosition(110, 11, 8),
|
||||||
createPosition(114, 7, 10),
|
createPosition(115, 8, 11),
|
||||||
|
createPosition(117, 7, 10),
|
||||||
|
createPosition(121, 11, 10),
|
||||||
|
createPosition(121, 28, 11),
|
||||||
};
|
};
|
||||||
// System.out.println(toString(actual));
|
if (PRINT_POSITIONS) System.out.println(toString(actual));
|
||||||
assertEqualPositions(expected, actual);
|
assertEqualPositions(expected, actual);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -90,32 +94,31 @@ public class SemanticHighlightingTest extends AbstractSemanticHighlightingTest {
|
||||||
Position[] actual= getSemanticHighlightingPositions();
|
Position[] actual= getSemanticHighlightingPositions();
|
||||||
Position[] expected= new Position[] {
|
Position[] expected= new Position[] {
|
||||||
createPosition(28, 15, 15),
|
createPosition(28, 15, 15),
|
||||||
createPosition(32, 8, 9),
|
createPosition(33, 8, 9),
|
||||||
createPosition(46, 15, 16),
|
createPosition(47, 15, 16),
|
||||||
createPosition(47, 8, 10),
|
createPosition(48, 8, 10),
|
||||||
createPosition(61, 15, 16),
|
createPosition(62, 15, 16),
|
||||||
createPosition(62, 8, 10),
|
createPosition(63, 8, 10),
|
||||||
createPosition(76, 4, 13),
|
createPosition(77, 4, 13),
|
||||||
createPosition(101, 4, 26),
|
createPosition(104, 4, 26),
|
||||||
createPosition(101, 20, 10),
|
createPosition(104, 20, 10),
|
||||||
createPosition(105, 4, 25),
|
createPosition(108, 4, 25),
|
||||||
createPosition(105, 20, 9),
|
createPosition(108, 20, 9),
|
||||||
createPosition(110, 4, 32),
|
createPosition(113, 4, 32),
|
||||||
createPosition(110, 20, 16),
|
createPosition(113, 20, 16),
|
||||||
};
|
};
|
||||||
// System.out.println(toString(actual));
|
if (PRINT_POSITIONS) System.out.println(toString(actual));
|
||||||
assertEqualPositions(expected, actual);
|
assertEqualPositions(expected, actual);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void testMethodInvocationHighlighting() throws Exception {
|
public void testMethodInvocationHighlighting() throws Exception {
|
||||||
setUpSemanticHighlighting(SemanticHighlightings.METHOD_INVOCATION);
|
setUpSemanticHighlighting(SemanticHighlightings.METHOD_INVOCATION);
|
||||||
Position[] expected= new Position[] {
|
Position[] expected= new Position[] {
|
||||||
createPosition(111, 22, 9),
|
createPosition(114, 23, 9),
|
||||||
createPosition(113, 21, 8),
|
createPosition(118, 4, 15),
|
||||||
createPosition(115, 4, 15),
|
|
||||||
};
|
};
|
||||||
Position[] actual= getSemanticHighlightingPositions();
|
Position[] actual= getSemanticHighlightingPositions();
|
||||||
// System.out.println(toString(actual));
|
if (PRINT_POSITIONS) System.out.println(toString(actual));
|
||||||
assertEqualPositions(expected, actual);
|
assertEqualPositions(expected, actual);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -154,23 +157,26 @@ public class SemanticHighlightingTest extends AbstractSemanticHighlightingTest {
|
||||||
public void testLocalVariableDeclarationHighlighting() throws Exception {
|
public void testLocalVariableDeclarationHighlighting() throws Exception {
|
||||||
setUpSemanticHighlighting(SemanticHighlightings.LOCAL_VARIABLE_DECLARATION);
|
setUpSemanticHighlighting(SemanticHighlightings.LOCAL_VARIABLE_DECLARATION);
|
||||||
Position[] expected= new Position[] {
|
Position[] expected= new Position[] {
|
||||||
createPosition(106, 8, 8),
|
createPosition(109, 8, 8),
|
||||||
createPosition(111, 14, 2),
|
createPosition(114, 15, 2),
|
||||||
createPosition(113, 13, 2),
|
createPosition(116, 13, 2),
|
||||||
};
|
};
|
||||||
Position[] actual= getSemanticHighlightingPositions();
|
Position[] actual= getSemanticHighlightingPositions();
|
||||||
// System.out.println(toString(actual));
|
if (PRINT_POSITIONS) System.out.println(toString(actual));
|
||||||
assertEqualPositions(expected, actual);
|
assertEqualPositions(expected, actual);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void testLocalVariableHighlighting() throws Exception {
|
public void testLocalVariableHighlighting() throws Exception {
|
||||||
setUpSemanticHighlighting(SemanticHighlightings.LOCAL_VARIABLE);
|
setUpSemanticHighlighting(SemanticHighlightings.LOCAL_VARIABLE);
|
||||||
Position[] expected= new Position[] {
|
Position[] expected= new Position[] {
|
||||||
createPosition(112, 4, 2),
|
createPosition(110, 22, 8),
|
||||||
createPosition(114, 4, 2),
|
createPosition(115, 4, 2),
|
||||||
|
createPosition(117, 4, 2),
|
||||||
|
createPosition(121, 8, 2),
|
||||||
|
createPosition(121, 24, 2),
|
||||||
};
|
};
|
||||||
Position[] actual= getSemanticHighlightingPositions();
|
Position[] actual= getSemanticHighlightingPositions();
|
||||||
// System.out.println(toString(actual));
|
if (PRINT_POSITIONS) System.out.println(toString(actual));
|
||||||
assertEqualPositions(expected, actual);
|
assertEqualPositions(expected, actual);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -182,12 +188,12 @@ public class SemanticHighlightingTest extends AbstractSemanticHighlightingTest {
|
||||||
createPosition(28, 35, 3),
|
createPosition(28, 35, 3),
|
||||||
createPosition(29, 8, 19),
|
createPosition(29, 8, 19),
|
||||||
createPosition(30, 19, 3),
|
createPosition(30, 19, 3),
|
||||||
createPosition(76, 21, 4),
|
createPosition(77, 21, 4),
|
||||||
createPosition(76, 30, 4),
|
createPosition(77, 30, 4),
|
||||||
createPosition(77, 16, 4),
|
|
||||||
createPosition(78, 16, 4),
|
createPosition(78, 16, 4),
|
||||||
|
createPosition(79, 16, 4),
|
||||||
};
|
};
|
||||||
// System.out.println(toString(actual));
|
if (PRINT_POSITIONS) System.out.println(toString(actual));
|
||||||
assertEqualPositions(expected, actual);
|
assertEqualPositions(expected, actual);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -195,8 +201,16 @@ public class SemanticHighlightingTest extends AbstractSemanticHighlightingTest {
|
||||||
setUpSemanticHighlighting(SemanticHighlightings.TEMPLATE_PARAMETER);
|
setUpSemanticHighlighting(SemanticHighlightings.TEMPLATE_PARAMETER);
|
||||||
Position[] actual= getSemanticHighlightingPositions();
|
Position[] actual= getSemanticHighlightingPositions();
|
||||||
Position[] expected= new Position[] {
|
Position[] expected= new Position[] {
|
||||||
|
createPosition(74, 15, 2),
|
||||||
|
createPosition(74, 25, 2),
|
||||||
|
createPosition(75, 4, 2),
|
||||||
|
createPosition(76, 4, 2),
|
||||||
|
createPosition(77, 18, 2),
|
||||||
|
createPosition(77, 27, 2),
|
||||||
|
createPosition(83, 15, 2),
|
||||||
|
createPosition(83, 66, 2),
|
||||||
};
|
};
|
||||||
// System.out.println(toString(actual));
|
if (PRINT_POSITIONS) System.out.println(toString(actual));
|
||||||
assertEqualPositions(expected, actual);
|
assertEqualPositions(expected, actual);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -215,11 +229,11 @@ public class SemanticHighlightingTest extends AbstractSemanticHighlightingTest {
|
||||||
Position[] actual= getSemanticHighlightingPositions();
|
Position[] actual= getSemanticHighlightingPositions();
|
||||||
Position[] expected= new Position[] {
|
Position[] expected= new Position[] {
|
||||||
createPosition(3, 5, 11),
|
createPosition(3, 5, 11),
|
||||||
createPosition(34, 9, 14),
|
createPosition(35, 9, 14),
|
||||||
createPosition(49, 9, 15),
|
createPosition(50, 9, 15),
|
||||||
createPosition(64, 9, 15),
|
createPosition(65, 9, 15),
|
||||||
};
|
};
|
||||||
// System.out.println(toString(actual));
|
if (PRINT_POSITIONS) System.out.println(toString(actual));
|
||||||
assertEqualPositions(expected, actual);
|
assertEqualPositions(expected, actual);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -233,29 +247,30 @@ public class SemanticHighlightingTest extends AbstractSemanticHighlightingTest {
|
||||||
createPosition(18, 23, 5),
|
createPosition(18, 23, 5),
|
||||||
createPosition(18, 30, 5),
|
createPosition(18, 30, 5),
|
||||||
createPosition(20, 17, 11),
|
createPosition(20, 17, 11),
|
||||||
createPosition(35, 10, 8),
|
createPosition(36, 10, 8),
|
||||||
createPosition(36, 10, 9),
|
createPosition(37, 10, 9),
|
||||||
createPosition(37, 10, 8),
|
createPosition(38, 10, 8),
|
||||||
createPosition(38, 12, 8),
|
createPosition(39, 12, 8),
|
||||||
createPosition(50, 10, 9),
|
createPosition(51, 10, 9),
|
||||||
createPosition(51, 10, 10),
|
createPosition(52, 10, 10),
|
||||||
createPosition(52, 10, 9),
|
createPosition(53, 10, 9),
|
||||||
createPosition(53, 12, 9),
|
createPosition(54, 12, 9),
|
||||||
createPosition(65, 10, 9),
|
createPosition(66, 10, 9),
|
||||||
createPosition(66, 10, 10),
|
createPosition(67, 10, 10),
|
||||||
createPosition(67, 10, 9),
|
createPosition(68, 10, 9),
|
||||||
createPosition(68, 12, 9),
|
createPosition(69, 12, 9),
|
||||||
createPosition(73, 22, 13),
|
createPosition(74, 35, 13),
|
||||||
createPosition(82, 19, 24),
|
createPosition(83, 25, 24),
|
||||||
createPosition(82, 46, 13),
|
createPosition(83, 52, 13),
|
||||||
createPosition(82, 63, 5),
|
createPosition(83, 52, 24),
|
||||||
createPosition(85, 7, 9),
|
createPosition(83, 70, 5),
|
||||||
createPosition(89, 6, 8),
|
createPosition(86, 7, 9),
|
||||||
createPosition(93, 8, 8),
|
createPosition(90, 6, 8),
|
||||||
createPosition(111, 4, 9),
|
createPosition(94, 8, 8),
|
||||||
createPosition(113, 4, 8),
|
createPosition(114, 4, 9),
|
||||||
|
createPosition(116, 4, 8),
|
||||||
};
|
};
|
||||||
// System.out.println(toString(actual));
|
if (PRINT_POSITIONS) System.out.println(toString(actual));
|
||||||
assertEqualPositions(expected, actual);
|
assertEqualPositions(expected, actual);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -266,22 +281,9 @@ public class SemanticHighlightingTest extends AbstractSemanticHighlightingTest {
|
||||||
createPosition(11, 5, 10),
|
createPosition(11, 5, 10),
|
||||||
createPosition(12, 12, 16),
|
createPosition(12, 12, 16),
|
||||||
createPosition(19, 16, 10),
|
createPosition(19, 16, 10),
|
||||||
createPosition(28, 15, 15),
|
createPosition(98, 8, 13),
|
||||||
createPosition(32, 8, 9),
|
|
||||||
createPosition(46, 15, 16),
|
|
||||||
createPosition(47, 8, 10),
|
|
||||||
createPosition(61, 15, 16),
|
|
||||||
createPosition(62, 8, 10),
|
|
||||||
createPosition(76, 4, 13),
|
|
||||||
createPosition(97, 8, 13),
|
|
||||||
createPosition(101, 4, 26),
|
|
||||||
createPosition(101, 20, 10),
|
|
||||||
createPosition(105, 4, 25),
|
|
||||||
createPosition(105, 20, 9),
|
|
||||||
createPosition(110, 4, 32),
|
|
||||||
createPosition(110, 20, 16),
|
|
||||||
};
|
};
|
||||||
// System.out.println(toString(actual));
|
if (PRINT_POSITIONS) System.out.println(toString(actual));
|
||||||
assertEqualPositions(expected, actual);
|
assertEqualPositions(expected, actual);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -291,12 +293,10 @@ public class SemanticHighlightingTest extends AbstractSemanticHighlightingTest {
|
||||||
Position[] expected= new Position[] {
|
Position[] expected= new Position[] {
|
||||||
createPosition(29, 8, 19),
|
createPosition(29, 8, 19),
|
||||||
createPosition(30, 8, 10),
|
createPosition(30, 8, 10),
|
||||||
createPosition(111, 22, 9),
|
createPosition(99, 1, 16),
|
||||||
createPosition(113, 21, 8),
|
createPosition(120, 4, 17),
|
||||||
createPosition(115, 4, 15),
|
|
||||||
createPosition(117, 4, 17),
|
|
||||||
};
|
};
|
||||||
// System.out.println(toString(actual));
|
if (PRINT_POSITIONS) System.out.println(toString(actual));
|
||||||
assertEqualPositions(expected, actual);
|
assertEqualPositions(expected, actual);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -308,9 +308,11 @@ public class SemanticHighlightingTest extends AbstractSemanticHighlightingTest {
|
||||||
createPosition(7, 10, 14),
|
createPosition(7, 10, 14),
|
||||||
createPosition(8, 4, 14),
|
createPosition(8, 4, 14),
|
||||||
createPosition(9, 11, 20),
|
createPosition(9, 11, 20),
|
||||||
createPosition(96, 8, 14),
|
createPosition(31, 15, 20),
|
||||||
|
createPosition(97, 8, 12),
|
||||||
|
createPosition(100, 8, 12),
|
||||||
};
|
};
|
||||||
// System.out.println(toString(actual));
|
if (PRINT_POSITIONS) System.out.println(toString(actual));
|
||||||
assertEqualPositions(expected, actual);
|
assertEqualPositions(expected, actual);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -319,9 +321,9 @@ public class SemanticHighlightingTest extends AbstractSemanticHighlightingTest {
|
||||||
Position[] actual= getSemanticHighlightingPositions();
|
Position[] actual= getSemanticHighlightingPositions();
|
||||||
Position[] expected= new Position[] {
|
Position[] expected= new Position[] {
|
||||||
createPosition(29, 8, 19),
|
createPosition(29, 8, 19),
|
||||||
createPosition(117, 4, 17),
|
createPosition(120, 4, 17),
|
||||||
};
|
};
|
||||||
// System.out.println(toString(actual));
|
if (PRINT_POSITIONS) System.out.println(toString(actual));
|
||||||
assertEqualPositions(expected, actual);
|
assertEqualPositions(expected, actual);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -329,12 +331,12 @@ public class SemanticHighlightingTest extends AbstractSemanticHighlightingTest {
|
||||||
setUpSemanticHighlighting(SemanticHighlightings.TYPEDEF);
|
setUpSemanticHighlighting(SemanticHighlightings.TYPEDEF);
|
||||||
Position[] actual= getSemanticHighlightingPositions();
|
Position[] actual= getSemanticHighlightingPositions();
|
||||||
Position[] expected= new Position[] {
|
Position[] expected= new Position[] {
|
||||||
createPosition(38, 21, 10),
|
createPosition(39, 21, 10),
|
||||||
createPosition(53, 22, 11),
|
createPosition(54, 22, 11),
|
||||||
createPosition(68, 22, 11),
|
createPosition(69, 22, 11),
|
||||||
createPosition(93, 17, 6),
|
createPosition(94, 17, 6),
|
||||||
};
|
};
|
||||||
// System.out.println(toString(actual));
|
if (PRINT_POSITIONS) System.out.println(toString(actual));
|
||||||
assertEqualPositions(expected, actual);
|
assertEqualPositions(expected, actual);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -342,9 +344,9 @@ public class SemanticHighlightingTest extends AbstractSemanticHighlightingTest {
|
||||||
setUpSemanticHighlighting(SemanticHighlightings.NAMESPACE);
|
setUpSemanticHighlighting(SemanticHighlightings.NAMESPACE);
|
||||||
Position[] actual= getSemanticHighlightingPositions();
|
Position[] actual= getSemanticHighlightingPositions();
|
||||||
Position[] expected= new Position[] {
|
Position[] expected= new Position[] {
|
||||||
createPosition(95, 10, 2),
|
createPosition(96, 10, 2),
|
||||||
};
|
};
|
||||||
// System.out.println(toString(actual));
|
if (PRINT_POSITIONS) System.out.println(toString(actual));
|
||||||
assertEqualPositions(expected, actual);
|
assertEqualPositions(expected, actual);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -352,9 +354,10 @@ public class SemanticHighlightingTest extends AbstractSemanticHighlightingTest {
|
||||||
setUpSemanticHighlighting(SemanticHighlightings.LABEL);
|
setUpSemanticHighlighting(SemanticHighlightings.LABEL);
|
||||||
Position[] actual= getSemanticHighlightingPositions();
|
Position[] actual= getSemanticHighlightingPositions();
|
||||||
Position[] expected= new Position[] {
|
Position[] expected= new Position[] {
|
||||||
createPosition(116, 0, 5),
|
createPosition(119, 0, 5),
|
||||||
|
createPosition(121, 46, 5),
|
||||||
};
|
};
|
||||||
// System.out.println(toString(actual));
|
if (PRINT_POSITIONS) System.out.println(toString(actual));
|
||||||
assertEqualPositions(expected, actual);
|
assertEqualPositions(expected, actual);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -363,11 +366,11 @@ public class SemanticHighlightingTest extends AbstractSemanticHighlightingTest {
|
||||||
Position[] actual= getSemanticHighlightingPositions();
|
Position[] actual= getSemanticHighlightingPositions();
|
||||||
Position[] expected= new Position[] {
|
Position[] expected= new Position[] {
|
||||||
createPosition(4, 4, 10),
|
createPosition(4, 4, 10),
|
||||||
createPosition(34, 25, 13),
|
createPosition(35, 25, 13),
|
||||||
createPosition(49, 26, 14),
|
createPosition(50, 26, 14),
|
||||||
createPosition(64, 26, 14),
|
createPosition(65, 26, 14),
|
||||||
};
|
};
|
||||||
// System.out.println(toString(actual));
|
if (PRINT_POSITIONS) System.out.println(toString(actual));
|
||||||
assertEqualPositions(expected, actual);
|
assertEqualPositions(expected, actual);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -375,16 +378,9 @@ public class SemanticHighlightingTest extends AbstractSemanticHighlightingTest {
|
||||||
setUpSemanticHighlighting(SemanticHighlightings.PROBLEM);
|
setUpSemanticHighlighting(SemanticHighlightings.PROBLEM);
|
||||||
Position[] actual= getSemanticHighlightingPositions();
|
Position[] actual= getSemanticHighlightingPositions();
|
||||||
Position[] expected= new Position[] {
|
Position[] expected= new Position[] {
|
||||||
createPosition(73, 9, 2),
|
createPosition(122, 4, 13),
|
||||||
createPosition(73, 12, 2),
|
|
||||||
createPosition(74, 4, 2),
|
|
||||||
createPosition(75, 4, 2),
|
|
||||||
createPosition(76, 18, 2),
|
|
||||||
createPosition(76, 27, 2),
|
|
||||||
createPosition(82, 9, 2),
|
|
||||||
createPosition(82, 60, 2),
|
|
||||||
};
|
};
|
||||||
// System.out.println(toString(actual));
|
if (PRINT_POSITIONS) System.out.println(toString(actual));
|
||||||
assertEqualPositions(expected, actual);
|
assertEqualPositions(expected, actual);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -18,8 +18,11 @@ import org.eclipse.core.resources.IFile;
|
||||||
import org.eclipse.core.runtime.CoreException;
|
import org.eclipse.core.runtime.CoreException;
|
||||||
import org.eclipse.core.runtime.IPath;
|
import org.eclipse.core.runtime.IPath;
|
||||||
import org.eclipse.core.runtime.content.IContentType;
|
import org.eclipse.core.runtime.content.IContentType;
|
||||||
|
import org.eclipse.jface.text.Assert;
|
||||||
import org.eclipse.jface.text.DocumentCommand;
|
import org.eclipse.jface.text.DocumentCommand;
|
||||||
|
import org.eclipse.jface.text.ITextPresentationListener;
|
||||||
import org.eclipse.jface.text.ITextViewerExtension;
|
import org.eclipse.jface.text.ITextViewerExtension;
|
||||||
|
import org.eclipse.jface.text.TextViewer;
|
||||||
import org.eclipse.jface.text.contentassist.IContentAssistant;
|
import org.eclipse.jface.text.contentassist.IContentAssistant;
|
||||||
import org.eclipse.jface.text.information.IInformationPresenter;
|
import org.eclipse.jface.text.information.IInformationPresenter;
|
||||||
import org.eclipse.jface.text.source.IOverviewRuler;
|
import org.eclipse.jface.text.source.IOverviewRuler;
|
||||||
|
@ -221,4 +224,22 @@ public class CSourceViewer extends ProjectionViewer implements ITextViewerExtens
|
||||||
super.setRangeIndication(offset, length, false);
|
super.setRangeIndication(offset, length, false);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Prepend given listener to the list of presentation listeners
|
||||||
|
*
|
||||||
|
* @param listener The listener to be added.
|
||||||
|
*
|
||||||
|
* @see TextViewer#addTextPresentationListener(ITextPresentationListener)
|
||||||
|
* @since 4.0
|
||||||
|
*/
|
||||||
|
public void prependTextPresentationListener(ITextPresentationListener listener) {
|
||||||
|
Assert.isNotNull(listener);
|
||||||
|
|
||||||
|
if (fTextPresentationListeners == null)
|
||||||
|
fTextPresentationListeners= new ArrayList();
|
||||||
|
|
||||||
|
fTextPresentationListeners.remove(listener);
|
||||||
|
fTextPresentationListeners.add(0, listener);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -255,7 +255,7 @@ public class InactiveCodeHighlighting implements ICReconcilingListener {
|
||||||
inInactiveCode = true;
|
inInactiveCode = true;
|
||||||
} else if (elseStmt.taken() && inInactiveCode) {
|
} else if (elseStmt.taken() && inInactiveCode) {
|
||||||
IASTNodeLocation nodeLocation = elseStmt.getNodeLocations()[0];
|
IASTNodeLocation nodeLocation = elseStmt.getNodeLocations()[0];
|
||||||
int inactiveCodeEnd = nodeLocation.getNodeOffset() + nodeLocation.getNodeLength();
|
int inactiveCodeEnd = nodeLocation.getNodeOffset() - 1;
|
||||||
positions.add(new HighlightPosition(inactiveCodeStart, inactiveCodeEnd - inactiveCodeStart, fHighlightKey));
|
positions.add(new HighlightPosition(inactiveCodeStart, inactiveCodeEnd - inactiveCodeStart, fHighlightKey));
|
||||||
inInactiveCode = false;
|
inInactiveCode = false;
|
||||||
}
|
}
|
||||||
|
@ -267,7 +267,7 @@ public class InactiveCodeHighlighting implements ICReconcilingListener {
|
||||||
inInactiveCode = true;
|
inInactiveCode = true;
|
||||||
} else if (elifStmt.taken() && inInactiveCode) {
|
} else if (elifStmt.taken() && inInactiveCode) {
|
||||||
IASTNodeLocation nodeLocation = elifStmt.getNodeLocations()[0];
|
IASTNodeLocation nodeLocation = elifStmt.getNodeLocations()[0];
|
||||||
int inactiveCodeEnd = nodeLocation.getNodeOffset() + nodeLocation.getNodeLength();
|
int inactiveCodeEnd = nodeLocation.getNodeOffset() - 1;
|
||||||
positions.add(new HighlightPosition(inactiveCodeStart, inactiveCodeEnd - inactiveCodeStart, fHighlightKey));
|
positions.add(new HighlightPosition(inactiveCodeStart, inactiveCodeEnd - inactiveCodeStart, fHighlightKey));
|
||||||
inInactiveCode = false;
|
inInactiveCode = false;
|
||||||
}
|
}
|
||||||
|
|
|
@ -653,8 +653,7 @@ public class SemanticHighlightingPresenter implements ITextPresentationListener,
|
||||||
fSourceViewer= sourceViewer;
|
fSourceViewer= sourceViewer;
|
||||||
fPresentationReconciler= backgroundPresentationReconciler;
|
fPresentationReconciler= backgroundPresentationReconciler;
|
||||||
|
|
||||||
fSourceViewer.addTextPresentationListener(this);
|
fSourceViewer.prependTextPresentationListener(this);
|
||||||
// fSourceViewer.prependTextPresentationListener(this);
|
|
||||||
fSourceViewer.addTextInputListener(this);
|
fSourceViewer.addTextInputListener(this);
|
||||||
manageDocument(fSourceViewer.getDocument());
|
manageDocument(fSourceViewer.getDocument());
|
||||||
}
|
}
|
||||||
|
|
|
@ -781,7 +781,7 @@ public class SemanticHighlightings {
|
||||||
* @see org.eclipse.cdt.internal.ui.editor.SemanticHighlighting#getDefaultTextStyleBold()
|
* @see org.eclipse.cdt.internal.ui.editor.SemanticHighlighting#getDefaultTextStyleBold()
|
||||||
*/
|
*/
|
||||||
public boolean isBoldByDefault() {
|
public boolean isBoldByDefault() {
|
||||||
return false;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|
@ -814,7 +814,7 @@ public class SemanticHighlightings {
|
||||||
IASTName name= (IASTName)node;
|
IASTName name= (IASTName)node;
|
||||||
if (name.isDeclaration()) {
|
if (name.isDeclaration()) {
|
||||||
IBinding binding= token.getBinding();
|
IBinding binding= token.getBinding();
|
||||||
if (binding instanceof IFunction) {
|
if (binding instanceof IFunction && !(binding instanceof ICPPMethod)) {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -879,7 +879,9 @@ public class SemanticHighlightings {
|
||||||
IASTName name= (IASTName)node;
|
IASTName name= (IASTName)node;
|
||||||
if (name.isReference()) {
|
if (name.isReference()) {
|
||||||
IBinding binding= token.getBinding();
|
IBinding binding= token.getBinding();
|
||||||
return binding instanceof IFunction;
|
if (binding instanceof IFunction && !(binding instanceof ICPPMethod)) {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return false;
|
return false;
|
||||||
|
@ -1934,8 +1936,6 @@ public class SemanticHighlightings {
|
||||||
if (fgSemanticHighlightings == null)
|
if (fgSemanticHighlightings == null)
|
||||||
fgSemanticHighlightings= new SemanticHighlighting[] {
|
fgSemanticHighlightings= new SemanticHighlighting[] {
|
||||||
new MacroSubstitutionHighlighting(), // before all others!
|
new MacroSubstitutionHighlighting(), // before all others!
|
||||||
new FunctionDeclarationHighlighting(),
|
|
||||||
new FunctionInvocationHighlighting(),
|
|
||||||
new ClassHighlighting(),
|
new ClassHighlighting(),
|
||||||
// new StaticConstFieldHighlighting(),
|
// new StaticConstFieldHighlighting(),
|
||||||
new StaticFieldHighlighting(),
|
new StaticFieldHighlighting(),
|
||||||
|
@ -1959,6 +1959,8 @@ public class SemanticHighlightings {
|
||||||
new EnumHighlighting(),
|
new EnumHighlighting(),
|
||||||
// TLETODO [semanticHighlighting] Macro definition highlighting
|
// TLETODO [semanticHighlighting] Macro definition highlighting
|
||||||
// new MacroDefinitionHighlighting(),
|
// new MacroDefinitionHighlighting(),
|
||||||
|
new FunctionDeclarationHighlighting(),
|
||||||
|
new FunctionInvocationHighlighting(),
|
||||||
new TypedefHighlighting(),
|
new TypedefHighlighting(),
|
||||||
new NamespaceHighlighting(),
|
new NamespaceHighlighting(),
|
||||||
new LabelHighlighting(),
|
new LabelHighlighting(),
|
||||||
|
|
Loading…
Add table
Reference in a new issue