mirror of
https://github.com/eclipse-cdt/cdt
synced 2025-04-29 19:45:01 +02:00
Merge remote-tracking branch 'cdt/master' into sd90
This commit is contained in:
commit
110c2856aa
65 changed files with 2333 additions and 1663 deletions
|
@ -32,7 +32,7 @@ public class AST2CSpecTest extends AST2SpecBaseTest {
|
||||||
--End Example]
|
--End Example]
|
||||||
*/
|
*/
|
||||||
public void test4s6() throws Exception {
|
public void test4s6() throws Exception {
|
||||||
StringBuffer buffer = new StringBuffer();
|
StringBuilder buffer = new StringBuilder();
|
||||||
buffer.append("#ifdef __STDC_IEC_559__ /* FE_UPWARD defined */\n"); //$NON-NLS-1$
|
buffer.append("#ifdef __STDC_IEC_559__ /* FE_UPWARD defined */\n"); //$NON-NLS-1$
|
||||||
buffer.append("fesetround(FE_UPWARD);\n"); //$NON-NLS-1$
|
buffer.append("fesetround(FE_UPWARD);\n"); //$NON-NLS-1$
|
||||||
buffer.append("#endif\n"); //$NON-NLS-1$
|
buffer.append("#endif\n"); //$NON-NLS-1$
|
||||||
|
@ -46,7 +46,7 @@ public class AST2CSpecTest extends AST2SpecBaseTest {
|
||||||
--End Example]
|
--End Example]
|
||||||
*/
|
*/
|
||||||
public void test5_1_1_3s2() throws Exception {
|
public void test5_1_1_3s2() throws Exception {
|
||||||
StringBuffer buffer = new StringBuffer();
|
StringBuilder buffer = new StringBuilder();
|
||||||
buffer.append("char i;\n"); //$NON-NLS-1$
|
buffer.append("char i;\n"); //$NON-NLS-1$
|
||||||
buffer.append("int i;\n"); //$NON-NLS-1$
|
buffer.append("int i;\n"); //$NON-NLS-1$
|
||||||
parseCandCPP(buffer.toString(), false, 0);
|
parseCandCPP(buffer.toString(), false, 0);
|
||||||
|
@ -61,7 +61,7 @@ public class AST2CSpecTest extends AST2SpecBaseTest {
|
||||||
--End Example]
|
--End Example]
|
||||||
*/
|
*/
|
||||||
public void test5_1_2_3s10() throws Exception {
|
public void test5_1_2_3s10() throws Exception {
|
||||||
StringBuffer buffer = new StringBuffer();
|
StringBuilder buffer = new StringBuilder();
|
||||||
buffer.append("int f() {\n"); //$NON-NLS-1$
|
buffer.append("int f() {\n"); //$NON-NLS-1$
|
||||||
buffer.append("char c1, c2;\n"); //$NON-NLS-1$
|
buffer.append("char c1, c2;\n"); //$NON-NLS-1$
|
||||||
buffer.append("c1 = c1 + c2;\n"); //$NON-NLS-1$
|
buffer.append("c1 = c1 + c2;\n"); //$NON-NLS-1$
|
||||||
|
@ -79,7 +79,7 @@ public class AST2CSpecTest extends AST2SpecBaseTest {
|
||||||
--End Example]
|
--End Example]
|
||||||
*/
|
*/
|
||||||
public void test5_1_2_3s11() throws Exception {
|
public void test5_1_2_3s11() throws Exception {
|
||||||
StringBuffer buffer = new StringBuffer();
|
StringBuilder buffer = new StringBuilder();
|
||||||
buffer.append("int f() {\n"); //$NON-NLS-1$
|
buffer.append("int f() {\n"); //$NON-NLS-1$
|
||||||
buffer.append("float f1, f2;\n"); //$NON-NLS-1$
|
buffer.append("float f1, f2;\n"); //$NON-NLS-1$
|
||||||
buffer.append("double d;\n"); //$NON-NLS-1$
|
buffer.append("double d;\n"); //$NON-NLS-1$
|
||||||
|
@ -99,7 +99,7 @@ public class AST2CSpecTest extends AST2SpecBaseTest {
|
||||||
--End Example]
|
--End Example]
|
||||||
*/
|
*/
|
||||||
public void test5_1_2_3s12() throws Exception {
|
public void test5_1_2_3s12() throws Exception {
|
||||||
StringBuffer buffer = new StringBuffer();
|
StringBuilder buffer = new StringBuilder();
|
||||||
buffer.append("int f() {\n"); //$NON-NLS-1$
|
buffer.append("int f() {\n"); //$NON-NLS-1$
|
||||||
buffer.append("double d1, d2;\n"); //$NON-NLS-1$
|
buffer.append("double d1, d2;\n"); //$NON-NLS-1$
|
||||||
buffer.append("float f;\n"); //$NON-NLS-1$
|
buffer.append("float f;\n"); //$NON-NLS-1$
|
||||||
|
@ -121,7 +121,7 @@ public class AST2CSpecTest extends AST2SpecBaseTest {
|
||||||
--End Example]
|
--End Example]
|
||||||
*/
|
*/
|
||||||
public void test5_1_2_3s13() throws Exception {
|
public void test5_1_2_3s13() throws Exception {
|
||||||
StringBuffer buffer = new StringBuffer();
|
StringBuilder buffer = new StringBuilder();
|
||||||
buffer.append("int f() {\n"); //$NON-NLS-1$
|
buffer.append("int f() {\n"); //$NON-NLS-1$
|
||||||
buffer.append("double x, y, z;\n"); //$NON-NLS-1$
|
buffer.append("double x, y, z;\n"); //$NON-NLS-1$
|
||||||
buffer.append("x = (x * y) * z; // not equivalent tox *= y * z;\n"); //$NON-NLS-1$
|
buffer.append("x = (x * y) * z; // not equivalent tox *= y * z;\n"); //$NON-NLS-1$
|
||||||
|
@ -145,7 +145,7 @@ public class AST2CSpecTest extends AST2SpecBaseTest {
|
||||||
--End Example]
|
--End Example]
|
||||||
*/
|
*/
|
||||||
public void test5_1_2_3s14() throws Exception {
|
public void test5_1_2_3s14() throws Exception {
|
||||||
StringBuffer buffer = new StringBuffer();
|
StringBuilder buffer = new StringBuilder();
|
||||||
buffer.append("int f() {\n"); //$NON-NLS-1$
|
buffer.append("int f() {\n"); //$NON-NLS-1$
|
||||||
buffer.append("int a, b;\n"); //$NON-NLS-1$
|
buffer.append("int a, b;\n"); //$NON-NLS-1$
|
||||||
buffer.append("a = a + 32760 + b + 5;\n"); //$NON-NLS-1$
|
buffer.append("a = a + 32760 + b + 5;\n"); //$NON-NLS-1$
|
||||||
|
@ -169,7 +169,7 @@ public class AST2CSpecTest extends AST2SpecBaseTest {
|
||||||
--End Example]
|
--End Example]
|
||||||
*/
|
*/
|
||||||
public void test5_1_2_3s15() throws Exception {
|
public void test5_1_2_3s15() throws Exception {
|
||||||
StringBuffer buffer = new StringBuffer();
|
StringBuilder buffer = new StringBuilder();
|
||||||
buffer.append("//#include <stdio.h>\n"); //$NON-NLS-1$
|
buffer.append("//#include <stdio.h>\n"); //$NON-NLS-1$
|
||||||
buffer.append("int f() {");
|
buffer.append("int f() {");
|
||||||
buffer.append("int sum;\n"); //$NON-NLS-1$
|
buffer.append("int sum;\n"); //$NON-NLS-1$
|
||||||
|
@ -186,7 +186,7 @@ public class AST2CSpecTest extends AST2SpecBaseTest {
|
||||||
--End Example]
|
--End Example]
|
||||||
*/
|
*/
|
||||||
public void test6_2_5s28() throws Exception {
|
public void test6_2_5s28() throws Exception {
|
||||||
StringBuffer buffer = new StringBuffer();
|
StringBuilder buffer = new StringBuilder();
|
||||||
buffer.append("struct tag (* a[5])(float);\n"); //$NON-NLS-1$
|
buffer.append("struct tag (* a[5])(float);\n"); //$NON-NLS-1$
|
||||||
parseCandCPP(buffer.toString(), false, 0);
|
parseCandCPP(buffer.toString(), false, 0);
|
||||||
}
|
}
|
||||||
|
@ -199,7 +199,7 @@ public class AST2CSpecTest extends AST2SpecBaseTest {
|
||||||
--End Example]
|
--End Example]
|
||||||
*/
|
*/
|
||||||
public void test6_2_7s5() throws Exception {
|
public void test6_2_7s5() throws Exception {
|
||||||
StringBuffer buffer = new StringBuffer();
|
StringBuilder buffer = new StringBuilder();
|
||||||
buffer.append("int f(int (*)(), double (*)[3]);\n"); //$NON-NLS-1$
|
buffer.append("int f(int (*)(), double (*)[3]);\n"); //$NON-NLS-1$
|
||||||
buffer.append("int f(int (*)(char *), double (*)[]);\n"); //$NON-NLS-1$
|
buffer.append("int f(int (*)(char *), double (*)[]);\n"); //$NON-NLS-1$
|
||||||
buffer.append("int f(int (*)(char *), double (*)[3]);\n"); //$NON-NLS-1$
|
buffer.append("int f(int (*)(char *), double (*)[3]);\n"); //$NON-NLS-1$
|
||||||
|
@ -214,7 +214,7 @@ public class AST2CSpecTest extends AST2SpecBaseTest {
|
||||||
--End Example]
|
--End Example]
|
||||||
*/
|
*/
|
||||||
public void test6_4_4_4s12() throws Exception {
|
public void test6_4_4_4s12() throws Exception {
|
||||||
StringBuffer buffer = new StringBuffer();
|
StringBuilder buffer = new StringBuilder();
|
||||||
buffer.append("char x='\\023';\n"); //$NON-NLS-1$
|
buffer.append("char x='\\023';\n"); //$NON-NLS-1$
|
||||||
buffer.append("char y='\\0';\n"); //$NON-NLS-1$
|
buffer.append("char y='\\0';\n"); //$NON-NLS-1$
|
||||||
buffer.append("char z='\\x13';\n"); //$NON-NLS-1$
|
buffer.append("char z='\\x13';\n"); //$NON-NLS-1$
|
||||||
|
@ -234,7 +234,7 @@ public class AST2CSpecTest extends AST2SpecBaseTest {
|
||||||
--End Example]
|
--End Example]
|
||||||
*/
|
*/
|
||||||
public void test6_5_2_2s12() throws Exception {
|
public void test6_5_2_2s12() throws Exception {
|
||||||
StringBuffer buffer = new StringBuffer();
|
StringBuilder buffer = new StringBuilder();
|
||||||
buffer.append("int f1() {}\n"); //$NON-NLS-1$
|
buffer.append("int f1() {}\n"); //$NON-NLS-1$
|
||||||
buffer.append("int f2() {}\n"); //$NON-NLS-1$
|
buffer.append("int f2() {}\n"); //$NON-NLS-1$
|
||||||
buffer.append("int f3() {}\n"); //$NON-NLS-1$
|
buffer.append("int f3() {}\n"); //$NON-NLS-1$
|
||||||
|
@ -263,7 +263,7 @@ public class AST2CSpecTest extends AST2SpecBaseTest {
|
||||||
--End Example]
|
--End Example]
|
||||||
*/
|
*/
|
||||||
public void test6_5_2_3s7() throws Exception {
|
public void test6_5_2_3s7() throws Exception {
|
||||||
StringBuffer buffer = new StringBuffer();
|
StringBuilder buffer = new StringBuilder();
|
||||||
buffer.append("struct s { int i; const int ci; };\n"); //$NON-NLS-1$
|
buffer.append("struct s { int i; const int ci; };\n"); //$NON-NLS-1$
|
||||||
buffer.append("struct s s;\n"); //$NON-NLS-1$
|
buffer.append("struct s s;\n"); //$NON-NLS-1$
|
||||||
buffer.append("const struct s cs;\n"); //$NON-NLS-1$
|
buffer.append("const struct s cs;\n"); //$NON-NLS-1$
|
||||||
|
@ -305,7 +305,7 @@ public class AST2CSpecTest extends AST2SpecBaseTest {
|
||||||
--End Example]
|
--End Example]
|
||||||
*/
|
*/
|
||||||
public void test6_5_2_3s8a() throws Exception {
|
public void test6_5_2_3s8a() throws Exception {
|
||||||
StringBuffer buffer = new StringBuffer();
|
StringBuilder buffer = new StringBuilder();
|
||||||
buffer.append("union {\n"); //$NON-NLS-1$
|
buffer.append("union {\n"); //$NON-NLS-1$
|
||||||
buffer.append("struct {\n"); //$NON-NLS-1$
|
buffer.append("struct {\n"); //$NON-NLS-1$
|
||||||
buffer.append("int alltypes;\n"); //$NON-NLS-1$
|
buffer.append("int alltypes;\n"); //$NON-NLS-1$
|
||||||
|
@ -351,7 +351,7 @@ public class AST2CSpecTest extends AST2SpecBaseTest {
|
||||||
--End Example]
|
--End Example]
|
||||||
*/
|
*/
|
||||||
public void test6_5_2_3s8b() throws Exception {
|
public void test6_5_2_3s8b() throws Exception {
|
||||||
StringBuffer buffer = new StringBuffer();
|
StringBuilder buffer = new StringBuilder();
|
||||||
buffer.append("struct t1 { int m; };\n"); //$NON-NLS-1$
|
buffer.append("struct t1 { int m; };\n"); //$NON-NLS-1$
|
||||||
buffer.append("struct t2 { int m; };\n"); //$NON-NLS-1$
|
buffer.append("struct t2 { int m; };\n"); //$NON-NLS-1$
|
||||||
buffer.append("int f(struct t1 * p1, struct t2 * p2)\n"); //$NON-NLS-1$
|
buffer.append("int f(struct t1 * p1, struct t2 * p2)\n"); //$NON-NLS-1$
|
||||||
|
@ -377,7 +377,7 @@ public class AST2CSpecTest extends AST2SpecBaseTest {
|
||||||
--End Example]
|
--End Example]
|
||||||
*/
|
*/
|
||||||
public void test6_5_2_5s9() throws Exception {
|
public void test6_5_2_5s9() throws Exception {
|
||||||
StringBuffer buffer = new StringBuffer();
|
StringBuilder buffer = new StringBuilder();
|
||||||
buffer.append("int *p = (int []){2, 4};\n"); //$NON-NLS-1$
|
buffer.append("int *p = (int []){2, 4};\n"); //$NON-NLS-1$
|
||||||
parse(buffer.toString(), ParserLanguage.C, true, 0);
|
parse(buffer.toString(), ParserLanguage.C, true, 0);
|
||||||
}
|
}
|
||||||
|
@ -392,7 +392,7 @@ public class AST2CSpecTest extends AST2SpecBaseTest {
|
||||||
--End Example]
|
--End Example]
|
||||||
*/
|
*/
|
||||||
public void test6_5_2_5s10() throws Exception {
|
public void test6_5_2_5s10() throws Exception {
|
||||||
StringBuffer buffer = new StringBuffer();
|
StringBuilder buffer = new StringBuilder();
|
||||||
buffer.append("void f(void)\n"); //$NON-NLS-1$
|
buffer.append("void f(void)\n"); //$NON-NLS-1$
|
||||||
buffer.append("{\n"); //$NON-NLS-1$
|
buffer.append("{\n"); //$NON-NLS-1$
|
||||||
buffer.append("int *p;\n"); //$NON-NLS-1$
|
buffer.append("int *p;\n"); //$NON-NLS-1$
|
||||||
|
@ -412,7 +412,7 @@ public class AST2CSpecTest extends AST2SpecBaseTest {
|
||||||
--End Example]
|
--End Example]
|
||||||
*/
|
*/
|
||||||
public void test6_5_2_5s11() throws Exception {
|
public void test6_5_2_5s11() throws Exception {
|
||||||
StringBuffer buffer = new StringBuffer();
|
StringBuilder buffer = new StringBuilder();
|
||||||
buffer.append("int f(){\n"); //$NON-NLS-1$
|
buffer.append("int f(){\n"); //$NON-NLS-1$
|
||||||
buffer.append("drawline((struct point){.x=1, .y=1},\n"); //$NON-NLS-1$
|
buffer.append("drawline((struct point){.x=1, .y=1},\n"); //$NON-NLS-1$
|
||||||
buffer.append("(struct point){.x=3, .y=4});\n"); //$NON-NLS-1$
|
buffer.append("(struct point){.x=3, .y=4});\n"); //$NON-NLS-1$
|
||||||
|
@ -430,7 +430,7 @@ public class AST2CSpecTest extends AST2SpecBaseTest {
|
||||||
--End Example]
|
--End Example]
|
||||||
*/
|
*/
|
||||||
public void test6_5_2_5s12() throws Exception {
|
public void test6_5_2_5s12() throws Exception {
|
||||||
StringBuffer buffer = new StringBuffer();
|
StringBuilder buffer = new StringBuilder();
|
||||||
buffer.append("int f() {\n"); //$NON-NLS-1$
|
buffer.append("int f() {\n"); //$NON-NLS-1$
|
||||||
buffer.append("(const float []){1e0, 1e1, 1e2, 1e3, 1e4, 1e5, 1e6};\n"); //$NON-NLS-1$
|
buffer.append("(const float []){1e0, 1e1, 1e2, 1e3, 1e4, 1e5, 1e6};\n"); //$NON-NLS-1$
|
||||||
buffer.append("}\n"); //$NON-NLS-1$
|
buffer.append("}\n"); //$NON-NLS-1$
|
||||||
|
@ -447,7 +447,7 @@ public class AST2CSpecTest extends AST2SpecBaseTest {
|
||||||
--End Example]
|
--End Example]
|
||||||
*/
|
*/
|
||||||
public void test6_5_2_5s13() throws Exception {
|
public void test6_5_2_5s13() throws Exception {
|
||||||
StringBuffer buffer = new StringBuffer();
|
StringBuilder buffer = new StringBuilder();
|
||||||
buffer.append("int f() {\n"); //$NON-NLS-1$
|
buffer.append("int f() {\n"); //$NON-NLS-1$
|
||||||
buffer.append("\"/tmp/fileXXXXXX\";\n"); //$NON-NLS-1$
|
buffer.append("\"/tmp/fileXXXXXX\";\n"); //$NON-NLS-1$
|
||||||
buffer.append("(char []){\"/tmp/fileXXXXXX\"};\n"); //$NON-NLS-1$
|
buffer.append("(char []){\"/tmp/fileXXXXXX\"};\n"); //$NON-NLS-1$
|
||||||
|
@ -464,7 +464,7 @@ public class AST2CSpecTest extends AST2SpecBaseTest {
|
||||||
--End Example]
|
--End Example]
|
||||||
*/
|
*/
|
||||||
public void test6_5_2_5s14() throws Exception {
|
public void test6_5_2_5s14() throws Exception {
|
||||||
StringBuffer buffer = new StringBuffer();
|
StringBuilder buffer = new StringBuilder();
|
||||||
buffer.append("int f() {\n"); //$NON-NLS-1$
|
buffer.append("int f() {\n"); //$NON-NLS-1$
|
||||||
buffer.append("(const char []){\"abc\"} == \"abc\";\n"); //$NON-NLS-1$
|
buffer.append("(const char []){\"abc\"} == \"abc\";\n"); //$NON-NLS-1$
|
||||||
buffer.append("}\n"); //$NON-NLS-1$
|
buffer.append("}\n"); //$NON-NLS-1$
|
||||||
|
@ -481,7 +481,7 @@ public class AST2CSpecTest extends AST2SpecBaseTest {
|
||||||
--End Example]
|
--End Example]
|
||||||
*/
|
*/
|
||||||
public void test6_5_2_5s15() throws Exception {
|
public void test6_5_2_5s15() throws Exception {
|
||||||
StringBuffer buffer = new StringBuffer();
|
StringBuilder buffer = new StringBuilder();
|
||||||
buffer.append("int f() {\n"); //$NON-NLS-1$
|
buffer.append("int f() {\n"); //$NON-NLS-1$
|
||||||
buffer.append("struct int_list { int car; struct int_list *cdr; };\n"); //$NON-NLS-1$
|
buffer.append("struct int_list { int car; struct int_list *cdr; };\n"); //$NON-NLS-1$
|
||||||
buffer.append("struct int_list endless_zeros = {0, &endless_zeros};\n"); //$NON-NLS-1$
|
buffer.append("struct int_list endless_zeros = {0, &endless_zeros};\n"); //$NON-NLS-1$
|
||||||
|
@ -505,7 +505,7 @@ public class AST2CSpecTest extends AST2SpecBaseTest {
|
||||||
--End Example]
|
--End Example]
|
||||||
*/
|
*/
|
||||||
public void test6_5_2_5s16() throws Exception {
|
public void test6_5_2_5s16() throws Exception {
|
||||||
StringBuffer buffer = new StringBuffer();
|
StringBuilder buffer = new StringBuilder();
|
||||||
buffer.append("struct s { int i; };\n"); //$NON-NLS-1$
|
buffer.append("struct s { int i; };\n"); //$NON-NLS-1$
|
||||||
buffer.append("int f (void)\n"); //$NON-NLS-1$
|
buffer.append("int f (void)\n"); //$NON-NLS-1$
|
||||||
buffer.append("{\n"); //$NON-NLS-1$
|
buffer.append("{\n"); //$NON-NLS-1$
|
||||||
|
@ -526,7 +526,7 @@ public class AST2CSpecTest extends AST2SpecBaseTest {
|
||||||
--End Example]
|
--End Example]
|
||||||
*/
|
*/
|
||||||
public void test6_5_3_4s5() throws Exception {
|
public void test6_5_3_4s5() throws Exception {
|
||||||
StringBuffer buffer = new StringBuffer();
|
StringBuilder buffer = new StringBuilder();
|
||||||
buffer.append("extern void *alloc(size_t);\n"); //$NON-NLS-1$
|
buffer.append("extern void *alloc(size_t);\n"); //$NON-NLS-1$
|
||||||
buffer.append("double *dp = alloc(sizeof *dp);\n"); //$NON-NLS-1$
|
buffer.append("double *dp = alloc(sizeof *dp);\n"); //$NON-NLS-1$
|
||||||
parseCandCPP(buffer.toString(), false, 0);
|
parseCandCPP(buffer.toString(), false, 0);
|
||||||
|
@ -541,7 +541,7 @@ public class AST2CSpecTest extends AST2SpecBaseTest {
|
||||||
--End Example]
|
--End Example]
|
||||||
*/
|
*/
|
||||||
public void test6_5_3_4s6() throws Exception {
|
public void test6_5_3_4s6() throws Exception {
|
||||||
StringBuffer buffer = new StringBuffer();
|
StringBuilder buffer = new StringBuilder();
|
||||||
buffer.append("int f() {\n"); //$NON-NLS-1$
|
buffer.append("int f() {\n"); //$NON-NLS-1$
|
||||||
buffer.append("int array[5];\n"); //$NON-NLS-1$
|
buffer.append("int array[5];\n"); //$NON-NLS-1$
|
||||||
buffer.append("int x = sizeof array / sizeof array[0];\n"); //$NON-NLS-1$
|
buffer.append("int x = sizeof array / sizeof array[0];\n"); //$NON-NLS-1$
|
||||||
|
@ -562,7 +562,7 @@ public class AST2CSpecTest extends AST2SpecBaseTest {
|
||||||
--End Example]
|
--End Example]
|
||||||
*/
|
*/
|
||||||
public void test6_5_6s10() throws Exception {
|
public void test6_5_6s10() throws Exception {
|
||||||
StringBuffer buffer = new StringBuffer();
|
StringBuilder buffer = new StringBuilder();
|
||||||
buffer.append("int f() {\n"); //$NON-NLS-1$
|
buffer.append("int f() {\n"); //$NON-NLS-1$
|
||||||
buffer.append("int n = 4, m = 3;\n"); //$NON-NLS-1$
|
buffer.append("int n = 4, m = 3;\n"); //$NON-NLS-1$
|
||||||
buffer.append("int a[n][m];\n"); //$NON-NLS-1$
|
buffer.append("int a[n][m];\n"); //$NON-NLS-1$
|
||||||
|
@ -587,7 +587,7 @@ public class AST2CSpecTest extends AST2SpecBaseTest {
|
||||||
--End Example]
|
--End Example]
|
||||||
*/
|
*/
|
||||||
public void test6_5_15s8() throws Exception {
|
public void test6_5_15s8() throws Exception {
|
||||||
StringBuffer buffer = new StringBuffer();
|
StringBuilder buffer = new StringBuilder();
|
||||||
buffer.append("int f() {\n"); //$NON-NLS-1$
|
buffer.append("int f() {\n"); //$NON-NLS-1$
|
||||||
buffer.append("const void *c_vp;\n"); //$NON-NLS-1$
|
buffer.append("const void *c_vp;\n"); //$NON-NLS-1$
|
||||||
buffer.append("void *vp;\n"); //$NON-NLS-1$
|
buffer.append("void *vp;\n"); //$NON-NLS-1$
|
||||||
|
@ -610,7 +610,7 @@ public class AST2CSpecTest extends AST2SpecBaseTest {
|
||||||
--End Example]
|
--End Example]
|
||||||
*/
|
*/
|
||||||
public void test6_5_16_1s5() throws Exception {
|
public void test6_5_16_1s5() throws Exception {
|
||||||
StringBuffer buffer = new StringBuffer();
|
StringBuilder buffer = new StringBuilder();
|
||||||
buffer.append("int f() {\n"); //$NON-NLS-1$
|
buffer.append("int f() {\n"); //$NON-NLS-1$
|
||||||
buffer.append("char c;\n"); //$NON-NLS-1$
|
buffer.append("char c;\n"); //$NON-NLS-1$
|
||||||
buffer.append("int i;\n"); //$NON-NLS-1$
|
buffer.append("int i;\n"); //$NON-NLS-1$
|
||||||
|
@ -633,7 +633,7 @@ public class AST2CSpecTest extends AST2SpecBaseTest {
|
||||||
--End Example]
|
--End Example]
|
||||||
*/
|
*/
|
||||||
public void test6_5_16_1s6() throws Exception {
|
public void test6_5_16_1s6() throws Exception {
|
||||||
StringBuffer buffer = new StringBuffer();
|
StringBuilder buffer = new StringBuilder();
|
||||||
buffer.append("int f() {\n"); //$NON-NLS-1$
|
buffer.append("int f() {\n"); //$NON-NLS-1$
|
||||||
buffer.append("const char **cpp;\n"); //$NON-NLS-1$
|
buffer.append("const char **cpp;\n"); //$NON-NLS-1$
|
||||||
buffer.append("char *p;\n"); //$NON-NLS-1$
|
buffer.append("char *p;\n"); //$NON-NLS-1$
|
||||||
|
@ -657,7 +657,7 @@ public class AST2CSpecTest extends AST2SpecBaseTest {
|
||||||
--End Example]
|
--End Example]
|
||||||
*/
|
*/
|
||||||
public void test6_7_2_1s17() throws Exception {
|
public void test6_7_2_1s17() throws Exception {
|
||||||
StringBuffer buffer = new StringBuffer();
|
StringBuilder buffer = new StringBuilder();
|
||||||
// offsetoff is a macro defined in stddef.h, using GNU definition
|
// offsetoff is a macro defined in stddef.h, using GNU definition
|
||||||
buffer.append("#define offsetof(TYPE, MEMBER) ((size_t) (&((TYPE *)0)->MEMBER))\n");
|
buffer.append("#define offsetof(TYPE, MEMBER) ((size_t) (&((TYPE *)0)->MEMBER))\n");
|
||||||
|
|
||||||
|
@ -682,7 +682,7 @@ public class AST2CSpecTest extends AST2SpecBaseTest {
|
||||||
--End Example]
|
--End Example]
|
||||||
*/
|
*/
|
||||||
public void test6_7_2_1s18a() throws Exception {
|
public void test6_7_2_1s18a() throws Exception {
|
||||||
StringBuffer buffer = new StringBuffer();
|
StringBuilder buffer = new StringBuilder();
|
||||||
buffer.append("int f() {\n"); //$NON-NLS-1$
|
buffer.append("int f() {\n"); //$NON-NLS-1$
|
||||||
buffer.append("struct s *s1;\n"); //$NON-NLS-1$
|
buffer.append("struct s *s1;\n"); //$NON-NLS-1$
|
||||||
buffer.append("struct s *s2;\n"); //$NON-NLS-1$
|
buffer.append("struct s *s2;\n"); //$NON-NLS-1$
|
||||||
|
@ -699,7 +699,7 @@ public class AST2CSpecTest extends AST2SpecBaseTest {
|
||||||
--End Example]
|
--End Example]
|
||||||
*/
|
*/
|
||||||
public void test6_7_2_1s18b() throws Exception {
|
public void test6_7_2_1s18b() throws Exception {
|
||||||
StringBuffer buffer = new StringBuffer();
|
StringBuilder buffer = new StringBuilder();
|
||||||
buffer.append("struct { int n; double d[8]; } *s1;\n"); //$NON-NLS-1$
|
buffer.append("struct { int n; double d[8]; } *s1;\n"); //$NON-NLS-1$
|
||||||
buffer.append("struct { int n; double d[5]; } *s2;\n"); //$NON-NLS-1$
|
buffer.append("struct { int n; double d[5]; } *s2;\n"); //$NON-NLS-1$
|
||||||
parseCandCPP(buffer.toString(), true, 0);
|
parseCandCPP(buffer.toString(), true, 0);
|
||||||
|
@ -718,7 +718,7 @@ public class AST2CSpecTest extends AST2SpecBaseTest {
|
||||||
--End Example]
|
--End Example]
|
||||||
*/
|
*/
|
||||||
public void test6_7_2_2s5() throws Exception {
|
public void test6_7_2_2s5() throws Exception {
|
||||||
StringBuffer buffer = new StringBuffer();
|
StringBuilder buffer = new StringBuilder();
|
||||||
buffer.append("int f() {\n"); //$NON-NLS-1$
|
buffer.append("int f() {\n"); //$NON-NLS-1$
|
||||||
buffer.append("enum hue { chartreuse, burgundy, claret=20, winedark };\n"); //$NON-NLS-1$
|
buffer.append("enum hue { chartreuse, burgundy, claret=20, winedark };\n"); //$NON-NLS-1$
|
||||||
buffer.append("enum hue col, *cp;\n"); //$NON-NLS-1$
|
buffer.append("enum hue col, *cp;\n"); //$NON-NLS-1$
|
||||||
|
@ -740,7 +740,7 @@ public class AST2CSpecTest extends AST2SpecBaseTest {
|
||||||
--End Example]
|
--End Example]
|
||||||
*/
|
*/
|
||||||
public void test6_7_2_3s9() throws Exception {
|
public void test6_7_2_3s9() throws Exception {
|
||||||
StringBuffer buffer = new StringBuffer();
|
StringBuilder buffer = new StringBuilder();
|
||||||
buffer.append("struct tnode {\n"); //$NON-NLS-1$
|
buffer.append("struct tnode {\n"); //$NON-NLS-1$
|
||||||
buffer.append("int count;\n"); //$NON-NLS-1$
|
buffer.append("int count;\n"); //$NON-NLS-1$
|
||||||
buffer.append("struct tnode *left, *right;\n"); //$NON-NLS-1$
|
buffer.append("struct tnode *left, *right;\n"); //$NON-NLS-1$
|
||||||
|
@ -760,7 +760,7 @@ public class AST2CSpecTest extends AST2SpecBaseTest {
|
||||||
--End Example]
|
--End Example]
|
||||||
*/
|
*/
|
||||||
public void test6_7_2_3s10() throws Exception {
|
public void test6_7_2_3s10() throws Exception {
|
||||||
StringBuffer buffer = new StringBuffer();
|
StringBuilder buffer = new StringBuilder();
|
||||||
buffer.append("typedef struct tnode TNODE;\n"); //$NON-NLS-1$
|
buffer.append("typedef struct tnode TNODE;\n"); //$NON-NLS-1$
|
||||||
buffer.append("struct tnode {\n"); //$NON-NLS-1$
|
buffer.append("struct tnode {\n"); //$NON-NLS-1$
|
||||||
buffer.append("int count;\n"); //$NON-NLS-1$
|
buffer.append("int count;\n"); //$NON-NLS-1$
|
||||||
|
@ -778,7 +778,7 @@ public class AST2CSpecTest extends AST2SpecBaseTest {
|
||||||
--End Example]
|
--End Example]
|
||||||
*/
|
*/
|
||||||
public void test6_7_2_3s11() throws Exception {
|
public void test6_7_2_3s11() throws Exception {
|
||||||
StringBuffer buffer = new StringBuffer();
|
StringBuilder buffer = new StringBuilder();
|
||||||
buffer.append("struct s2;\n"); //$NON-NLS-1$
|
buffer.append("struct s2;\n"); //$NON-NLS-1$
|
||||||
buffer.append("struct s1 { struct s2 *s2p; }; // D1\n"); //$NON-NLS-1$
|
buffer.append("struct s1 { struct s2 *s2p; }; // D1\n"); //$NON-NLS-1$
|
||||||
buffer.append("struct s2 { struct s1 *s1p; }; // D2\n"); //$NON-NLS-1$
|
buffer.append("struct s2 { struct s1 *s1p; }; // D2\n"); //$NON-NLS-1$
|
||||||
|
@ -791,7 +791,7 @@ public class AST2CSpecTest extends AST2SpecBaseTest {
|
||||||
--End Example]
|
--End Example]
|
||||||
*/
|
*/
|
||||||
public void test6_7_3s10() throws Exception {
|
public void test6_7_3s10() throws Exception {
|
||||||
StringBuffer buffer = new StringBuffer();
|
StringBuilder buffer = new StringBuilder();
|
||||||
buffer.append("extern const volatile int real_time_clock;\n"); //$NON-NLS-1$
|
buffer.append("extern const volatile int real_time_clock;\n"); //$NON-NLS-1$
|
||||||
parseCandCPP(buffer.toString(), true, 0);
|
parseCandCPP(buffer.toString(), true, 0);
|
||||||
}
|
}
|
||||||
|
@ -815,7 +815,7 @@ public class AST2CSpecTest extends AST2SpecBaseTest {
|
||||||
--End Example]
|
--End Example]
|
||||||
*/
|
*/
|
||||||
public void test6_7_3s11() throws Exception {
|
public void test6_7_3s11() throws Exception {
|
||||||
StringBuffer buffer = new StringBuffer();
|
StringBuilder buffer = new StringBuilder();
|
||||||
buffer.append("int f() {\n"); //$NON-NLS-1$
|
buffer.append("int f() {\n"); //$NON-NLS-1$
|
||||||
buffer.append("const struct s { int mem; } cs = { 1 };\n"); //$NON-NLS-1$
|
buffer.append("const struct s { int mem; } cs = { 1 };\n"); //$NON-NLS-1$
|
||||||
buffer.append("struct s ncs; // the object ncs is modifiable\n"); //$NON-NLS-1$
|
buffer.append("struct s ncs; // the object ncs is modifiable\n"); //$NON-NLS-1$
|
||||||
|
@ -841,7 +841,7 @@ public class AST2CSpecTest extends AST2SpecBaseTest {
|
||||||
--End Example]
|
--End Example]
|
||||||
*/
|
*/
|
||||||
public void test6_7_3_1s7() throws Exception {
|
public void test6_7_3_1s7() throws Exception {
|
||||||
StringBuffer buffer = new StringBuffer();
|
StringBuilder buffer = new StringBuilder();
|
||||||
buffer.append("int * restrict a;\n"); //$NON-NLS-1$
|
buffer.append("int * restrict a;\n"); //$NON-NLS-1$
|
||||||
buffer.append("int * restrict b;\n"); //$NON-NLS-1$
|
buffer.append("int * restrict b;\n"); //$NON-NLS-1$
|
||||||
buffer.append("extern int c[];\n"); //$NON-NLS-1$
|
buffer.append("extern int c[];\n"); //$NON-NLS-1$
|
||||||
|
@ -858,7 +858,7 @@ public class AST2CSpecTest extends AST2SpecBaseTest {
|
||||||
--End Example]
|
--End Example]
|
||||||
*/
|
*/
|
||||||
public void test6_7_3_1s8() throws Exception {
|
public void test6_7_3_1s8() throws Exception {
|
||||||
StringBuffer buffer = new StringBuffer();
|
StringBuilder buffer = new StringBuilder();
|
||||||
buffer.append("void f(int n, int * restrict p, int * restrict q)\n"); //$NON-NLS-1$
|
buffer.append("void f(int n, int * restrict p, int * restrict q)\n"); //$NON-NLS-1$
|
||||||
buffer.append("{\n"); //$NON-NLS-1$
|
buffer.append("{\n"); //$NON-NLS-1$
|
||||||
buffer.append("while (n-- > 0)\n"); //$NON-NLS-1$
|
buffer.append("while (n-- > 0)\n"); //$NON-NLS-1$
|
||||||
|
@ -883,7 +883,7 @@ public class AST2CSpecTest extends AST2SpecBaseTest {
|
||||||
--End Example]
|
--End Example]
|
||||||
*/
|
*/
|
||||||
public void test6_7_3_1s9() throws Exception {
|
public void test6_7_3_1s9() throws Exception {
|
||||||
StringBuffer buffer = new StringBuffer();
|
StringBuilder buffer = new StringBuilder();
|
||||||
buffer.append("void f(int n, int * restrict p, int * restrict q)\n"); //$NON-NLS-1$
|
buffer.append("void f(int n, int * restrict p, int * restrict q)\n"); //$NON-NLS-1$
|
||||||
buffer.append("{\n"); //$NON-NLS-1$
|
buffer.append("{\n"); //$NON-NLS-1$
|
||||||
buffer.append("while (n-- > 0)\n"); //$NON-NLS-1$
|
buffer.append("while (n-- > 0)\n"); //$NON-NLS-1$
|
||||||
|
@ -909,7 +909,7 @@ public class AST2CSpecTest extends AST2SpecBaseTest {
|
||||||
--End Example]
|
--End Example]
|
||||||
*/
|
*/
|
||||||
public void test6_7_3_1s10() throws Exception {
|
public void test6_7_3_1s10() throws Exception {
|
||||||
StringBuffer buffer = new StringBuffer();
|
StringBuilder buffer = new StringBuilder();
|
||||||
buffer.append("void h(int n, int * restrict p, int * restrict q, int * restrict r)\n"); //$NON-NLS-1$
|
buffer.append("void h(int n, int * restrict p, int * restrict q, int * restrict r)\n"); //$NON-NLS-1$
|
||||||
buffer.append("{\n"); //$NON-NLS-1$
|
buffer.append("{\n"); //$NON-NLS-1$
|
||||||
buffer.append("int i;\n"); //$NON-NLS-1$
|
buffer.append("int i;\n"); //$NON-NLS-1$
|
||||||
|
@ -936,7 +936,7 @@ public class AST2CSpecTest extends AST2SpecBaseTest {
|
||||||
--End Example]
|
--End Example]
|
||||||
*/
|
*/
|
||||||
public void test6_7_3_1s11() throws Exception {
|
public void test6_7_3_1s11() throws Exception {
|
||||||
StringBuffer buffer = new StringBuffer();
|
StringBuilder buffer = new StringBuilder();
|
||||||
buffer.append("int f()\n"); //$NON-NLS-1$
|
buffer.append("int f()\n"); //$NON-NLS-1$
|
||||||
buffer.append("{\n"); //$NON-NLS-1$
|
buffer.append("{\n"); //$NON-NLS-1$
|
||||||
buffer.append("int * restrict p1;\n"); //$NON-NLS-1$
|
buffer.append("int * restrict p1;\n"); //$NON-NLS-1$
|
||||||
|
@ -965,7 +965,7 @@ public class AST2CSpecTest extends AST2SpecBaseTest {
|
||||||
--End Example]
|
--End Example]
|
||||||
*/
|
*/
|
||||||
public void test6_7_3_1s12() throws Exception {
|
public void test6_7_3_1s12() throws Exception {
|
||||||
StringBuffer buffer = new StringBuffer();
|
StringBuilder buffer = new StringBuilder();
|
||||||
buffer.append("typedef struct { int n; float * restrict v; } vector;\n"); //$NON-NLS-1$
|
buffer.append("typedef struct { int n; float * restrict v; } vector;\n"); //$NON-NLS-1$
|
||||||
buffer.append("vector new_vector(int n)\n"); //$NON-NLS-1$
|
buffer.append("vector new_vector(int n)\n"); //$NON-NLS-1$
|
||||||
buffer.append("{\n"); //$NON-NLS-1$
|
buffer.append("{\n"); //$NON-NLS-1$
|
||||||
|
@ -995,7 +995,7 @@ public class AST2CSpecTest extends AST2SpecBaseTest {
|
||||||
--End Example]
|
--End Example]
|
||||||
*/
|
*/
|
||||||
public void test6_7_4s7() throws Exception {
|
public void test6_7_4s7() throws Exception {
|
||||||
StringBuffer buffer = new StringBuffer();
|
StringBuilder buffer = new StringBuilder();
|
||||||
buffer.append("inline double fahr(double t)\n"); //$NON-NLS-1$
|
buffer.append("inline double fahr(double t)\n"); //$NON-NLS-1$
|
||||||
buffer.append("{\n"); //$NON-NLS-1$
|
buffer.append("{\n"); //$NON-NLS-1$
|
||||||
buffer.append("return (9.0 * t) / 5.0 + 32.0;\n"); //$NON-NLS-1$
|
buffer.append("return (9.0 * t) / 5.0 + 32.0;\n"); //$NON-NLS-1$
|
||||||
|
@ -1021,7 +1021,7 @@ public class AST2CSpecTest extends AST2SpecBaseTest {
|
||||||
--End Example]
|
--End Example]
|
||||||
*/
|
*/
|
||||||
public void test6_7_5_1s4() throws Exception {
|
public void test6_7_5_1s4() throws Exception {
|
||||||
StringBuffer buffer = new StringBuffer();
|
StringBuilder buffer = new StringBuilder();
|
||||||
buffer.append("const int *ptr_to_constant;\n"); //$NON-NLS-1$
|
buffer.append("const int *ptr_to_constant;\n"); //$NON-NLS-1$
|
||||||
buffer.append("int *const constant_ptr1;\n"); //$NON-NLS-1$
|
buffer.append("int *const constant_ptr1;\n"); //$NON-NLS-1$
|
||||||
buffer.append("typedef int *int_ptr;\n"); //$NON-NLS-1$
|
buffer.append("typedef int *int_ptr;\n"); //$NON-NLS-1$
|
||||||
|
@ -1035,7 +1035,7 @@ public class AST2CSpecTest extends AST2SpecBaseTest {
|
||||||
--End Example]
|
--End Example]
|
||||||
*/
|
*/
|
||||||
public void test6_7_5_2s7() throws Exception {
|
public void test6_7_5_2s7() throws Exception {
|
||||||
StringBuffer buffer = new StringBuffer();
|
StringBuilder buffer = new StringBuilder();
|
||||||
buffer.append("float fa[11], *afp[17];\n"); //$NON-NLS-1$
|
buffer.append("float fa[11], *afp[17];\n"); //$NON-NLS-1$
|
||||||
parseCandCPP(buffer.toString(), true, 0);
|
parseCandCPP(buffer.toString(), true, 0);
|
||||||
}
|
}
|
||||||
|
@ -1047,7 +1047,7 @@ public class AST2CSpecTest extends AST2SpecBaseTest {
|
||||||
--End Example]
|
--End Example]
|
||||||
*/
|
*/
|
||||||
public void test6_7_5_2s8() throws Exception {
|
public void test6_7_5_2s8() throws Exception {
|
||||||
StringBuffer buffer = new StringBuffer();
|
StringBuilder buffer = new StringBuilder();
|
||||||
buffer.append("extern int *x;\n"); //$NON-NLS-1$
|
buffer.append("extern int *x;\n"); //$NON-NLS-1$
|
||||||
buffer.append("extern int y[];\n"); //$NON-NLS-1$
|
buffer.append("extern int y[];\n"); //$NON-NLS-1$
|
||||||
parseCandCPP(buffer.toString(), true, 0);
|
parseCandCPP(buffer.toString(), true, 0);
|
||||||
|
@ -1070,7 +1070,7 @@ public class AST2CSpecTest extends AST2SpecBaseTest {
|
||||||
--End Example]
|
--End Example]
|
||||||
*/
|
*/
|
||||||
public void test6_7_5_2s9() throws Exception {
|
public void test6_7_5_2s9() throws Exception {
|
||||||
StringBuffer buffer = new StringBuffer();
|
StringBuilder buffer = new StringBuilder();
|
||||||
buffer.append("extern int n;\n"); //$NON-NLS-1$
|
buffer.append("extern int n;\n"); //$NON-NLS-1$
|
||||||
buffer.append("extern int m;\n"); //$NON-NLS-1$
|
buffer.append("extern int m;\n"); //$NON-NLS-1$
|
||||||
buffer.append("void fcompat(void)\n"); //$NON-NLS-1$
|
buffer.append("void fcompat(void)\n"); //$NON-NLS-1$
|
||||||
|
@ -1110,7 +1110,7 @@ public class AST2CSpecTest extends AST2SpecBaseTest {
|
||||||
--End Example]
|
--End Example]
|
||||||
*/
|
*/
|
||||||
public void test6_7_5_2s10() throws Exception {
|
public void test6_7_5_2s10() throws Exception {
|
||||||
StringBuffer buffer = new StringBuffer();
|
StringBuilder buffer = new StringBuilder();
|
||||||
buffer.append("extern int n;\n"); //$NON-NLS-1$
|
buffer.append("extern int n;\n"); //$NON-NLS-1$
|
||||||
buffer.append("int A[n]; // invalid: file scope VLA\n"); //$NON-NLS-1$
|
buffer.append("int A[n]; // invalid: file scope VLA\n"); //$NON-NLS-1$
|
||||||
buffer.append("extern int (*p2)[n]; // invalid: file scope VM\n"); //$NON-NLS-1$
|
buffer.append("extern int (*p2)[n]; // invalid: file scope VM\n"); //$NON-NLS-1$
|
||||||
|
@ -1139,7 +1139,7 @@ public class AST2CSpecTest extends AST2SpecBaseTest {
|
||||||
--End Example]
|
--End Example]
|
||||||
*/
|
*/
|
||||||
public void test6_7_5_3s16() throws Exception {
|
public void test6_7_5_3s16() throws Exception {
|
||||||
StringBuffer buffer = new StringBuffer();
|
StringBuilder buffer = new StringBuilder();
|
||||||
buffer.append("int f(void), *fip(), (*pfi)();\n"); //$NON-NLS-1$
|
buffer.append("int f(void), *fip(), (*pfi)();\n"); //$NON-NLS-1$
|
||||||
parseCandCPP(buffer.toString(), true, 0);
|
parseCandCPP(buffer.toString(), true, 0);
|
||||||
}
|
}
|
||||||
|
@ -1150,7 +1150,7 @@ public class AST2CSpecTest extends AST2SpecBaseTest {
|
||||||
--End Example]
|
--End Example]
|
||||||
*/
|
*/
|
||||||
public void test6_7_5_3s18() throws Exception {
|
public void test6_7_5_3s18() throws Exception {
|
||||||
StringBuffer buffer = new StringBuffer();
|
StringBuilder buffer = new StringBuilder();
|
||||||
buffer.append("int (*apfi[3])(int *x, int *y);\n"); //$NON-NLS-1$
|
buffer.append("int (*apfi[3])(int *x, int *y);\n"); //$NON-NLS-1$
|
||||||
parseCandCPP(buffer.toString(), true, 0);
|
parseCandCPP(buffer.toString(), true, 0);
|
||||||
}
|
}
|
||||||
|
@ -1161,7 +1161,7 @@ public class AST2CSpecTest extends AST2SpecBaseTest {
|
||||||
--End Example]
|
--End Example]
|
||||||
*/
|
*/
|
||||||
public void test6_7_5_3s19() throws Exception {
|
public void test6_7_5_3s19() throws Exception {
|
||||||
StringBuffer buffer = new StringBuffer();
|
StringBuilder buffer = new StringBuilder();
|
||||||
buffer.append("int (*fpfi(int (*)(long), int))(int, ...);\n"); //$NON-NLS-1$
|
buffer.append("int (*fpfi(int (*)(long), int))(int, ...);\n"); //$NON-NLS-1$
|
||||||
parseCandCPP(buffer.toString(), true, 0);
|
parseCandCPP(buffer.toString(), true, 0);
|
||||||
}
|
}
|
||||||
|
@ -1187,7 +1187,7 @@ public class AST2CSpecTest extends AST2SpecBaseTest {
|
||||||
--End Example]
|
--End Example]
|
||||||
*/
|
*/
|
||||||
public void test6_7_5_3s20() throws Exception {
|
public void test6_7_5_3s20() throws Exception {
|
||||||
StringBuffer buffer = new StringBuffer();
|
StringBuilder buffer = new StringBuilder();
|
||||||
buffer.append("void addscalar(int n, int m,\n"); //$NON-NLS-1$
|
buffer.append("void addscalar(int n, int m,\n"); //$NON-NLS-1$
|
||||||
buffer.append("double a[n][n*m+300], double x);\n"); //$NON-NLS-1$
|
buffer.append("double a[n][n*m+300], double x);\n"); //$NON-NLS-1$
|
||||||
buffer.append("int main()\n"); //$NON-NLS-1$
|
buffer.append("int main()\n"); //$NON-NLS-1$
|
||||||
|
@ -1222,7 +1222,7 @@ public class AST2CSpecTest extends AST2SpecBaseTest {
|
||||||
--End Example]
|
--End Example]
|
||||||
*/
|
*/
|
||||||
public void test6_7_5_3s21() throws Exception {
|
public void test6_7_5_3s21() throws Exception {
|
||||||
StringBuffer buffer = new StringBuffer();
|
StringBuilder buffer = new StringBuilder();
|
||||||
buffer.append("double maximum1(int n, int m, double a[n][m]);\n"); //$NON-NLS-1$
|
buffer.append("double maximum1(int n, int m, double a[n][m]);\n"); //$NON-NLS-1$
|
||||||
buffer.append("double maximum2(int n, int m, double a[*][*]);\n"); //$NON-NLS-1$
|
buffer.append("double maximum2(int n, int m, double a[*][*]);\n"); //$NON-NLS-1$
|
||||||
buffer.append("double maximum3(int n, int m, double a[ ][*]);\n"); //$NON-NLS-1$
|
buffer.append("double maximum3(int n, int m, double a[ ][*]);\n"); //$NON-NLS-1$
|
||||||
|
@ -1245,7 +1245,7 @@ public class AST2CSpecTest extends AST2SpecBaseTest {
|
||||||
--End Example]
|
--End Example]
|
||||||
*/
|
*/
|
||||||
public void test6_7_7s4() throws Exception {
|
public void test6_7_7s4() throws Exception {
|
||||||
StringBuffer buffer = new StringBuffer();
|
StringBuilder buffer = new StringBuilder();
|
||||||
buffer.append("typedef int MILES, KLICKSP();\n"); //$NON-NLS-1$
|
buffer.append("typedef int MILES, KLICKSP();\n"); //$NON-NLS-1$
|
||||||
buffer.append("typedef struct { double hi, lo; } range;\n"); //$NON-NLS-1$
|
buffer.append("typedef struct { double hi, lo; } range;\n"); //$NON-NLS-1$
|
||||||
buffer.append("MILES distance;\n"); //$NON-NLS-1$
|
buffer.append("MILES distance;\n"); //$NON-NLS-1$
|
||||||
|
@ -1262,7 +1262,7 @@ public class AST2CSpecTest extends AST2SpecBaseTest {
|
||||||
--End Example]
|
--End Example]
|
||||||
*/
|
*/
|
||||||
public void test6_7_7s5() throws Exception {
|
public void test6_7_7s5() throws Exception {
|
||||||
StringBuffer buffer = new StringBuffer();
|
StringBuilder buffer = new StringBuilder();
|
||||||
buffer.append("typedef struct s1 { int x; } t1, *tp1;\n"); //$NON-NLS-1$
|
buffer.append("typedef struct s1 { int x; } t1, *tp1;\n"); //$NON-NLS-1$
|
||||||
buffer.append("typedef struct s2 { int x; } t2, *tp2;\n"); //$NON-NLS-1$
|
buffer.append("typedef struct s2 { int x; } t2, *tp2;\n"); //$NON-NLS-1$
|
||||||
parseCandCPP(buffer.toString(), true, 0);
|
parseCandCPP(buffer.toString(), true, 0);
|
||||||
|
@ -1277,7 +1277,7 @@ public class AST2CSpecTest extends AST2SpecBaseTest {
|
||||||
--End Example]
|
--End Example]
|
||||||
*/
|
*/
|
||||||
public void test6_7_7s7() throws Exception {
|
public void test6_7_7s7() throws Exception {
|
||||||
StringBuffer buffer = new StringBuffer();
|
StringBuilder buffer = new StringBuilder();
|
||||||
buffer.append("typedef void fv(int), (*pfv)(int);\n"); //$NON-NLS-1$
|
buffer.append("typedef void fv(int), (*pfv)(int);\n"); //$NON-NLS-1$
|
||||||
buffer.append("void (*signal(int, void (*)(int)))(int);\n"); //$NON-NLS-1$
|
buffer.append("void (*signal(int, void (*)(int)))(int);\n"); //$NON-NLS-1$
|
||||||
buffer.append("fv *signal(int, fv *);\n"); //$NON-NLS-1$
|
buffer.append("fv *signal(int, fv *);\n"); //$NON-NLS-1$
|
||||||
|
@ -1299,7 +1299,7 @@ public class AST2CSpecTest extends AST2SpecBaseTest {
|
||||||
--End Example]
|
--End Example]
|
||||||
*/
|
*/
|
||||||
public void test6_7_7s8() throws Exception {
|
public void test6_7_7s8() throws Exception {
|
||||||
StringBuffer buffer = new StringBuffer();
|
StringBuilder buffer = new StringBuilder();
|
||||||
buffer.append("void copyt(int n)\n"); //$NON-NLS-1$
|
buffer.append("void copyt(int n)\n"); //$NON-NLS-1$
|
||||||
buffer.append("{\n"); //$NON-NLS-1$
|
buffer.append("{\n"); //$NON-NLS-1$
|
||||||
buffer.append("typedef int B[n]; // B is n ints, n evaluated now\n"); //$NON-NLS-1$
|
buffer.append("typedef int B[n]; // B is n ints, n evaluated now\n"); //$NON-NLS-1$
|
||||||
|
@ -1319,7 +1319,7 @@ public class AST2CSpecTest extends AST2SpecBaseTest {
|
||||||
--End Example]
|
--End Example]
|
||||||
*/
|
*/
|
||||||
public void test6_7_8s24() throws Exception {
|
public void test6_7_8s24() throws Exception {
|
||||||
StringBuffer buffer = new StringBuffer();
|
StringBuilder buffer = new StringBuilder();
|
||||||
buffer.append("int i = 3.5;\n"); //$NON-NLS-1$
|
buffer.append("int i = 3.5;\n"); //$NON-NLS-1$
|
||||||
buffer.append("complex c = 5 + 3 * I;\n"); //$NON-NLS-1$
|
buffer.append("complex c = 5 + 3 * I;\n"); //$NON-NLS-1$
|
||||||
parseCandCPP(buffer.toString(), false, 0);
|
parseCandCPP(buffer.toString(), false, 0);
|
||||||
|
@ -1331,7 +1331,7 @@ public class AST2CSpecTest extends AST2SpecBaseTest {
|
||||||
--End Example]
|
--End Example]
|
||||||
*/
|
*/
|
||||||
public void test6_7_8s25() throws Exception {
|
public void test6_7_8s25() throws Exception {
|
||||||
StringBuffer buffer = new StringBuffer();
|
StringBuilder buffer = new StringBuilder();
|
||||||
buffer.append("int x[] = { 1, 3, 5 };\n"); //$NON-NLS-1$
|
buffer.append("int x[] = { 1, 3, 5 };\n"); //$NON-NLS-1$
|
||||||
parseCandCPP(buffer.toString(), true, 0);
|
parseCandCPP(buffer.toString(), true, 0);
|
||||||
}
|
}
|
||||||
|
@ -1346,7 +1346,7 @@ public class AST2CSpecTest extends AST2SpecBaseTest {
|
||||||
--End Example]
|
--End Example]
|
||||||
*/
|
*/
|
||||||
public void test6_7_8s26a() throws Exception {
|
public void test6_7_8s26a() throws Exception {
|
||||||
StringBuffer buffer = new StringBuffer();
|
StringBuilder buffer = new StringBuilder();
|
||||||
buffer.append("int y[4][3] = {\n"); //$NON-NLS-1$
|
buffer.append("int y[4][3] = {\n"); //$NON-NLS-1$
|
||||||
buffer.append("{ 1, 3, 5 },\n"); //$NON-NLS-1$
|
buffer.append("{ 1, 3, 5 },\n"); //$NON-NLS-1$
|
||||||
buffer.append("{ 2, 4, 6 },\n"); //$NON-NLS-1$
|
buffer.append("{ 2, 4, 6 },\n"); //$NON-NLS-1$
|
||||||
|
@ -1363,7 +1363,7 @@ public class AST2CSpecTest extends AST2SpecBaseTest {
|
||||||
--End Example]
|
--End Example]
|
||||||
*/
|
*/
|
||||||
public void test6_7_8s26b() throws Exception {
|
public void test6_7_8s26b() throws Exception {
|
||||||
StringBuffer buffer = new StringBuffer();
|
StringBuilder buffer = new StringBuilder();
|
||||||
buffer.append("int y[4][3] = {\n"); //$NON-NLS-1$
|
buffer.append("int y[4][3] = {\n"); //$NON-NLS-1$
|
||||||
buffer.append("1, 3, 5, 2, 4, 6, 3, 5, 7\n"); //$NON-NLS-1$
|
buffer.append("1, 3, 5, 2, 4, 6, 3, 5, 7\n"); //$NON-NLS-1$
|
||||||
buffer.append("};\n"); //$NON-NLS-1$
|
buffer.append("};\n"); //$NON-NLS-1$
|
||||||
|
@ -1378,7 +1378,7 @@ public class AST2CSpecTest extends AST2SpecBaseTest {
|
||||||
--End Example]
|
--End Example]
|
||||||
*/
|
*/
|
||||||
public void test6_7_8s27() throws Exception {
|
public void test6_7_8s27() throws Exception {
|
||||||
StringBuffer buffer = new StringBuffer();
|
StringBuilder buffer = new StringBuilder();
|
||||||
buffer.append("int z[4][3] = {\n"); //$NON-NLS-1$
|
buffer.append("int z[4][3] = {\n"); //$NON-NLS-1$
|
||||||
buffer.append("{ 1 }, { 2 }, { 3 }, { 4 }\n"); //$NON-NLS-1$
|
buffer.append("{ 1 }, { 2 }, { 3 }, { 4 }\n"); //$NON-NLS-1$
|
||||||
buffer.append("};\n"); //$NON-NLS-1$
|
buffer.append("};\n"); //$NON-NLS-1$
|
||||||
|
@ -1391,7 +1391,7 @@ public class AST2CSpecTest extends AST2SpecBaseTest {
|
||||||
--End Example]
|
--End Example]
|
||||||
*/
|
*/
|
||||||
public void test6_7_8s28() throws Exception {
|
public void test6_7_8s28() throws Exception {
|
||||||
StringBuffer buffer = new StringBuffer();
|
StringBuilder buffer = new StringBuilder();
|
||||||
buffer.append("struct { int a[3], b; } w[] = { { 1 }, 2 };\n"); //$NON-NLS-1$
|
buffer.append("struct { int a[3], b; } w[] = { { 1 }, 2 };\n"); //$NON-NLS-1$
|
||||||
parseCandCPP(buffer.toString(), true, 0);
|
parseCandCPP(buffer.toString(), true, 0);
|
||||||
}
|
}
|
||||||
|
@ -1423,7 +1423,7 @@ public class AST2CSpecTest extends AST2SpecBaseTest {
|
||||||
--End Example]
|
--End Example]
|
||||||
*/
|
*/
|
||||||
public void test6_7_8s29() throws Exception {
|
public void test6_7_8s29() throws Exception {
|
||||||
StringBuffer buffer = new StringBuffer();
|
StringBuilder buffer = new StringBuilder();
|
||||||
buffer.append("short q1[4][3][2] = {\n"); //$NON-NLS-1$
|
buffer.append("short q1[4][3][2] = {\n"); //$NON-NLS-1$
|
||||||
buffer.append("{ 1 },\n"); //$NON-NLS-1$
|
buffer.append("{ 1 },\n"); //$NON-NLS-1$
|
||||||
buffer.append("{ 2, 3 },\n"); //$NON-NLS-1$
|
buffer.append("{ 2, 3 },\n"); //$NON-NLS-1$
|
||||||
|
@ -1457,7 +1457,7 @@ public class AST2CSpecTest extends AST2SpecBaseTest {
|
||||||
--End Example]
|
--End Example]
|
||||||
*/
|
*/
|
||||||
public void test6_7_8s31() throws Exception {
|
public void test6_7_8s31() throws Exception {
|
||||||
StringBuffer buffer = new StringBuffer();
|
StringBuilder buffer = new StringBuilder();
|
||||||
buffer.append("typedef int A[]; // OK - declared with block scope\n"); //$NON-NLS-1$
|
buffer.append("typedef int A[]; // OK - declared with block scope\n"); //$NON-NLS-1$
|
||||||
buffer.append("A a1 = { 1, 2 }, b1 = { 3, 4, 5 };\n"); //$NON-NLS-1$
|
buffer.append("A a1 = { 1, 2 }, b1 = { 3, 4, 5 };\n"); //$NON-NLS-1$
|
||||||
buffer.append("int a2[] = { 1, 2 }, b2[] = { 3, 4, 5 };\n"); //$NON-NLS-1$
|
buffer.append("int a2[] = { 1, 2 }, b2[] = { 3, 4, 5 };\n"); //$NON-NLS-1$
|
||||||
|
@ -1475,7 +1475,7 @@ public class AST2CSpecTest extends AST2SpecBaseTest {
|
||||||
--End Example]
|
--End Example]
|
||||||
*/
|
*/
|
||||||
public void test6_7_8s32() throws Exception {
|
public void test6_7_8s32() throws Exception {
|
||||||
StringBuffer buffer = new StringBuffer();
|
StringBuilder buffer = new StringBuilder();
|
||||||
buffer.append("int foo() {\n"); //$NON-NLS-1$
|
buffer.append("int foo() {\n"); //$NON-NLS-1$
|
||||||
buffer.append("char s1[] = \"abc\", t1[3] = \"abc\";\n"); //$NON-NLS-1$
|
buffer.append("char s1[] = \"abc\", t1[3] = \"abc\";\n"); //$NON-NLS-1$
|
||||||
buffer.append("char s2[] = { 'a', 'b', 'c', '\0' },\n"); //$NON-NLS-1$
|
buffer.append("char s2[] = { 'a', 'b', 'c', '\0' },\n"); //$NON-NLS-1$
|
||||||
|
@ -1495,7 +1495,7 @@ public class AST2CSpecTest extends AST2SpecBaseTest {
|
||||||
--End Example]
|
--End Example]
|
||||||
*/
|
*/
|
||||||
public void test6_7_8s33() throws Exception {
|
public void test6_7_8s33() throws Exception {
|
||||||
StringBuffer buffer = new StringBuffer();
|
StringBuilder buffer = new StringBuilder();
|
||||||
buffer.append("enum { member_one, member_two };\n"); //$NON-NLS-1$
|
buffer.append("enum { member_one, member_two };\n"); //$NON-NLS-1$
|
||||||
buffer.append("const char *nm[] = {\n"); //$NON-NLS-1$
|
buffer.append("const char *nm[] = {\n"); //$NON-NLS-1$
|
||||||
buffer.append("[member_two] = \"member two\",\n"); //$NON-NLS-1$
|
buffer.append("[member_two] = \"member two\",\n"); //$NON-NLS-1$
|
||||||
|
@ -1510,7 +1510,7 @@ public class AST2CSpecTest extends AST2SpecBaseTest {
|
||||||
--End Example]
|
--End Example]
|
||||||
*/
|
*/
|
||||||
public void test6_7_8s34() throws Exception {
|
public void test6_7_8s34() throws Exception {
|
||||||
StringBuffer buffer = new StringBuffer();
|
StringBuilder buffer = new StringBuilder();
|
||||||
buffer.append("div_t answer = { .quot = 2, .rem = -1 };\n"); //$NON-NLS-1$
|
buffer.append("div_t answer = { .quot = 2, .rem = -1 };\n"); //$NON-NLS-1$
|
||||||
parse(buffer.toString(), ParserLanguage.C, true, 1); // div_t (correctly) cannot be resolved
|
parse(buffer.toString(), ParserLanguage.C, true, 1); // div_t (correctly) cannot be resolved
|
||||||
}
|
}
|
||||||
|
@ -1522,7 +1522,7 @@ public class AST2CSpecTest extends AST2SpecBaseTest {
|
||||||
--End Example]
|
--End Example]
|
||||||
*/
|
*/
|
||||||
public void test6_7_8s35() throws Exception {
|
public void test6_7_8s35() throws Exception {
|
||||||
StringBuffer buffer = new StringBuffer();
|
StringBuilder buffer = new StringBuilder();
|
||||||
buffer.append("struct { int a[3], b; } w[] =\n"); //$NON-NLS-1$
|
buffer.append("struct { int a[3], b; } w[] =\n"); //$NON-NLS-1$
|
||||||
buffer.append("{ [0].a = {1}, [1].a[0] = 2 };\n"); //$NON-NLS-1$
|
buffer.append("{ [0].a = {1}, [1].a[0] = 2 };\n"); //$NON-NLS-1$
|
||||||
parse(buffer.toString(), ParserLanguage.C, true, 0);
|
parse(buffer.toString(), ParserLanguage.C, true, 0);
|
||||||
|
@ -1537,7 +1537,7 @@ public class AST2CSpecTest extends AST2SpecBaseTest {
|
||||||
--End Example]
|
--End Example]
|
||||||
*/
|
*/
|
||||||
public void test6_7_8s36() throws Exception {
|
public void test6_7_8s36() throws Exception {
|
||||||
StringBuffer buffer = new StringBuffer();
|
StringBuilder buffer = new StringBuilder();
|
||||||
buffer.append("int MAX=15;\n"); //$NON-NLS-1$
|
buffer.append("int MAX=15;\n"); //$NON-NLS-1$
|
||||||
buffer.append("int a[MAX] = {\n"); //$NON-NLS-1$
|
buffer.append("int a[MAX] = {\n"); //$NON-NLS-1$
|
||||||
buffer.append("1, 3, 5, 7, 9, [MAX-5] = 8, 6, 4, 2, 0\n"); //$NON-NLS-1$
|
buffer.append("1, 3, 5, 7, 9, [MAX-5] = 8, 6, 4, 2, 0\n"); //$NON-NLS-1$
|
||||||
|
@ -1551,7 +1551,7 @@ public class AST2CSpecTest extends AST2SpecBaseTest {
|
||||||
--End Example]
|
--End Example]
|
||||||
*/
|
*/
|
||||||
public void test6_7_8s38() throws Exception {
|
public void test6_7_8s38() throws Exception {
|
||||||
StringBuffer buffer = new StringBuffer();
|
StringBuilder buffer = new StringBuilder();
|
||||||
buffer.append("union { int any_member; } u = { .any_member = 42 };\n"); //$NON-NLS-1$
|
buffer.append("union { int any_member; } u = { .any_member = 42 };\n"); //$NON-NLS-1$
|
||||||
parse(buffer.toString(), ParserLanguage.C, true, 0);
|
parse(buffer.toString(), ParserLanguage.C, true, 0);
|
||||||
}
|
}
|
||||||
|
@ -1565,7 +1565,7 @@ public class AST2CSpecTest extends AST2SpecBaseTest {
|
||||||
--End Example]
|
--End Example]
|
||||||
*/
|
*/
|
||||||
public void test6_8_3s4() throws Exception {
|
public void test6_8_3s4() throws Exception {
|
||||||
StringBuffer buffer = new StringBuffer();
|
StringBuilder buffer = new StringBuilder();
|
||||||
buffer.append("int p(int);\n"); //$NON-NLS-1$
|
buffer.append("int p(int);\n"); //$NON-NLS-1$
|
||||||
buffer.append("int f() {\n"); //$NON-NLS-1$
|
buffer.append("int f() {\n"); //$NON-NLS-1$
|
||||||
buffer.append("(void)p(0);\n"); //$NON-NLS-1$
|
buffer.append("(void)p(0);\n"); //$NON-NLS-1$
|
||||||
|
@ -1583,7 +1583,7 @@ public class AST2CSpecTest extends AST2SpecBaseTest {
|
||||||
--End Example]
|
--End Example]
|
||||||
*/
|
*/
|
||||||
public void test6_8_3s5() throws Exception {
|
public void test6_8_3s5() throws Exception {
|
||||||
StringBuffer buffer = new StringBuffer();
|
StringBuilder buffer = new StringBuilder();
|
||||||
buffer.append("int f() {\n"); //$NON-NLS-1$
|
buffer.append("int f() {\n"); //$NON-NLS-1$
|
||||||
buffer.append("char *s;\n"); //$NON-NLS-1$
|
buffer.append("char *s;\n"); //$NON-NLS-1$
|
||||||
buffer.append("while (*s++ != '\0')\n"); //$NON-NLS-1$
|
buffer.append("while (*s++ != '\0')\n"); //$NON-NLS-1$
|
||||||
|
@ -1608,7 +1608,7 @@ public class AST2CSpecTest extends AST2SpecBaseTest {
|
||||||
--End Example]
|
--End Example]
|
||||||
*/
|
*/
|
||||||
public void test6_8_3s6() throws Exception {
|
public void test6_8_3s6() throws Exception {
|
||||||
StringBuffer buffer = new StringBuffer();
|
StringBuilder buffer = new StringBuilder();
|
||||||
buffer.append("int f() {\n"); //$NON-NLS-1$
|
buffer.append("int f() {\n"); //$NON-NLS-1$
|
||||||
buffer.append("int i=1;\n"); //$NON-NLS-1$
|
buffer.append("int i=1;\n"); //$NON-NLS-1$
|
||||||
buffer.append("while (i) {\n"); //$NON-NLS-1$
|
buffer.append("while (i) {\n"); //$NON-NLS-1$
|
||||||
|
@ -1640,7 +1640,7 @@ public class AST2CSpecTest extends AST2SpecBaseTest {
|
||||||
--End Example]
|
--End Example]
|
||||||
*/
|
*/
|
||||||
public void test6_8_4s7() throws Exception {
|
public void test6_8_4s7() throws Exception {
|
||||||
StringBuffer buffer = new StringBuffer();
|
StringBuilder buffer = new StringBuilder();
|
||||||
buffer.append("int f(int a) {}\n"); //$NON-NLS-1$
|
buffer.append("int f(int a) {}\n"); //$NON-NLS-1$
|
||||||
buffer.append("int g(int expr) {\n"); //$NON-NLS-1$
|
buffer.append("int g(int expr) {\n"); //$NON-NLS-1$
|
||||||
buffer.append("switch (expr)\n"); //$NON-NLS-1$
|
buffer.append("switch (expr)\n"); //$NON-NLS-1$
|
||||||
|
@ -1674,7 +1674,7 @@ public class AST2CSpecTest extends AST2SpecBaseTest {
|
||||||
--End Example]
|
--End Example]
|
||||||
*/
|
*/
|
||||||
public void test6_8_6_1s3() throws Exception {
|
public void test6_8_6_1s3() throws Exception {
|
||||||
StringBuffer buffer = new StringBuffer();
|
StringBuilder buffer = new StringBuilder();
|
||||||
buffer.append("int f() {\n"); //$NON-NLS-1$
|
buffer.append("int f() {\n"); //$NON-NLS-1$
|
||||||
buffer.append("goto first_time;\n"); //$NON-NLS-1$
|
buffer.append("goto first_time;\n"); //$NON-NLS-1$
|
||||||
buffer.append("for (;;) {\n"); //$NON-NLS-1$
|
buffer.append("for (;;) {\n"); //$NON-NLS-1$
|
||||||
|
@ -1710,7 +1710,7 @@ public class AST2CSpecTest extends AST2SpecBaseTest {
|
||||||
--End Example]
|
--End Example]
|
||||||
*/
|
*/
|
||||||
public void test6_8_6_1s4() throws Exception {
|
public void test6_8_6_1s4() throws Exception {
|
||||||
StringBuffer buffer = new StringBuffer();
|
StringBuilder buffer = new StringBuilder();
|
||||||
buffer.append("int f() {\n"); //$NON-NLS-1$
|
buffer.append("int f() {\n"); //$NON-NLS-1$
|
||||||
buffer.append("goto lab3; // invalid: going INTO scope of VLA.\n"); //$NON-NLS-1$
|
buffer.append("goto lab3; // invalid: going INTO scope of VLA.\n"); //$NON-NLS-1$
|
||||||
buffer.append("{\n"); //$NON-NLS-1$
|
buffer.append("{\n"); //$NON-NLS-1$
|
||||||
|
@ -1751,7 +1751,7 @@ public class AST2CSpecTest extends AST2SpecBaseTest {
|
||||||
--End Example]
|
--End Example]
|
||||||
*/
|
*/
|
||||||
public void test6_8_6_4s4() throws Exception {
|
public void test6_8_6_4s4() throws Exception {
|
||||||
StringBuffer buffer = new StringBuffer();
|
StringBuilder buffer = new StringBuilder();
|
||||||
buffer.append("struct s { double i; } f(void);\n"); //$NON-NLS-1$
|
buffer.append("struct s { double i; } f(void);\n"); //$NON-NLS-1$
|
||||||
buffer.append("union {\n"); //$NON-NLS-1$
|
buffer.append("union {\n"); //$NON-NLS-1$
|
||||||
buffer.append("struct {\n"); //$NON-NLS-1$
|
buffer.append("struct {\n"); //$NON-NLS-1$
|
||||||
|
@ -1782,7 +1782,7 @@ public class AST2CSpecTest extends AST2SpecBaseTest {
|
||||||
--End Example]
|
--End Example]
|
||||||
*/
|
*/
|
||||||
public void test6_9_1s13() throws Exception {
|
public void test6_9_1s13() throws Exception {
|
||||||
StringBuffer buffer = new StringBuffer();
|
StringBuilder buffer = new StringBuilder();
|
||||||
buffer.append("extern int max(int a, int b)\n"); //$NON-NLS-1$
|
buffer.append("extern int max(int a, int b)\n"); //$NON-NLS-1$
|
||||||
buffer.append("{\n"); //$NON-NLS-1$
|
buffer.append("{\n"); //$NON-NLS-1$
|
||||||
buffer.append("return a > b ? a : b;\n"); //$NON-NLS-1$
|
buffer.append("return a > b ? a : b;\n"); //$NON-NLS-1$
|
||||||
|
@ -1800,7 +1800,7 @@ public class AST2CSpecTest extends AST2SpecBaseTest {
|
||||||
--End Example]
|
--End Example]
|
||||||
*/
|
*/
|
||||||
public void test6_9_1s14() throws Exception {
|
public void test6_9_1s14() throws Exception {
|
||||||
StringBuffer buffer = new StringBuffer();
|
StringBuilder buffer = new StringBuilder();
|
||||||
buffer.append("void g(int (*funcp)(void))\n"); //$NON-NLS-1$
|
buffer.append("void g(int (*funcp)(void))\n"); //$NON-NLS-1$
|
||||||
buffer.append("{\n"); //$NON-NLS-1$
|
buffer.append("{\n"); //$NON-NLS-1$
|
||||||
buffer.append("(*funcp)();\n"); //$NON-NLS-1$
|
buffer.append("(*funcp)();\n"); //$NON-NLS-1$
|
||||||
|
@ -1829,7 +1829,7 @@ public class AST2CSpecTest extends AST2SpecBaseTest {
|
||||||
--End Example]
|
--End Example]
|
||||||
*/
|
*/
|
||||||
public void test6_9_2s4() throws Exception {
|
public void test6_9_2s4() throws Exception {
|
||||||
StringBuffer buffer = new StringBuffer();
|
StringBuilder buffer = new StringBuilder();
|
||||||
buffer.append("int i1 = 1; // definition, external linkage\n"); //$NON-NLS-1$
|
buffer.append("int i1 = 1; // definition, external linkage\n"); //$NON-NLS-1$
|
||||||
buffer.append("static int i2 = 2; // definition, internal linkage\n"); //$NON-NLS-1$
|
buffer.append("static int i2 = 2; // definition, internal linkage\n"); //$NON-NLS-1$
|
||||||
buffer.append("extern int i3 = 3; // definition, external linkage\n"); //$NON-NLS-1$
|
buffer.append("extern int i3 = 3; // definition, external linkage\n"); //$NON-NLS-1$
|
||||||
|
@ -1861,7 +1861,7 @@ public class AST2CSpecTest extends AST2SpecBaseTest {
|
||||||
--End Example]
|
--End Example]
|
||||||
*/
|
*/
|
||||||
public void test6_10_1s4() throws Exception {
|
public void test6_10_1s4() throws Exception {
|
||||||
StringBuffer buffer = new StringBuffer();
|
StringBuilder buffer = new StringBuilder();
|
||||||
buffer.append("int g() {}\n"); //$NON-NLS-1$
|
buffer.append("int g() {}\n"); //$NON-NLS-1$
|
||||||
buffer.append("int f() {\n"); //$NON-NLS-1$
|
buffer.append("int f() {\n"); //$NON-NLS-1$
|
||||||
buffer.append("#if 'z' - 'a' == 25\n"); //$NON-NLS-1$
|
buffer.append("#if 'z' - 'a' == 25\n"); //$NON-NLS-1$
|
||||||
|
@ -1884,7 +1884,7 @@ public class AST2CSpecTest extends AST2SpecBaseTest {
|
||||||
--End Example]
|
--End Example]
|
||||||
*/
|
*/
|
||||||
public void test6_10_3_3s4() throws Exception {
|
public void test6_10_3_3s4() throws Exception {
|
||||||
StringBuffer buffer = new StringBuffer();
|
StringBuilder buffer = new StringBuilder();
|
||||||
buffer.append("#define hash_hash # ## #\n"); //$NON-NLS-1$
|
buffer.append("#define hash_hash # ## #\n"); //$NON-NLS-1$
|
||||||
buffer.append("#define mkstr(a) # a\n"); //$NON-NLS-1$
|
buffer.append("#define mkstr(a) # a\n"); //$NON-NLS-1$
|
||||||
buffer.append("#define in_between(a) mkstr(a)\n"); //$NON-NLS-1$
|
buffer.append("#define in_between(a) mkstr(a)\n"); //$NON-NLS-1$
|
||||||
|
@ -1901,7 +1901,7 @@ public class AST2CSpecTest extends AST2SpecBaseTest {
|
||||||
--End Example]
|
--End Example]
|
||||||
*/
|
*/
|
||||||
public void test6_10_3_5s3() throws Exception {
|
public void test6_10_3_5s3() throws Exception {
|
||||||
StringBuffer buffer = new StringBuffer();
|
StringBuilder buffer = new StringBuilder();
|
||||||
buffer.append("#define TABSIZE 100\n"); //$NON-NLS-1$
|
buffer.append("#define TABSIZE 100\n"); //$NON-NLS-1$
|
||||||
buffer.append("int table[TABSIZE];\n"); //$NON-NLS-1$
|
buffer.append("int table[TABSIZE];\n"); //$NON-NLS-1$
|
||||||
parseCandCPP(buffer.toString(), true, 0);
|
parseCandCPP(buffer.toString(), true, 0);
|
||||||
|
@ -1913,7 +1913,7 @@ public class AST2CSpecTest extends AST2SpecBaseTest {
|
||||||
--End Example]
|
--End Example]
|
||||||
*/
|
*/
|
||||||
public void test6_10_3_5s4() throws Exception {
|
public void test6_10_3_5s4() throws Exception {
|
||||||
StringBuffer buffer = new StringBuffer();
|
StringBuilder buffer = new StringBuilder();
|
||||||
buffer.append("#define max(a, b) ((a) > (b) ? (a) : (b))\n"); //$NON-NLS-1$
|
buffer.append("#define max(a, b) ((a) > (b) ? (a) : (b))\n"); //$NON-NLS-1$
|
||||||
parseCandCPP(buffer.toString(), true, 0);
|
parseCandCPP(buffer.toString(), true, 0);
|
||||||
}
|
}
|
||||||
|
@ -1941,7 +1941,7 @@ public class AST2CSpecTest extends AST2SpecBaseTest {
|
||||||
--End Example]
|
--End Example]
|
||||||
*/
|
*/
|
||||||
public void test6_10_3_5s5() throws Exception {
|
public void test6_10_3_5s5() throws Exception {
|
||||||
StringBuffer buffer = new StringBuffer();
|
StringBuilder buffer = new StringBuilder();
|
||||||
buffer.append("#define x 3\n"); //$NON-NLS-1$
|
buffer.append("#define x 3\n"); //$NON-NLS-1$
|
||||||
buffer.append("#define f(a) f(x * (a))\n"); //$NON-NLS-1$
|
buffer.append("#define f(a) f(x * (a))\n"); //$NON-NLS-1$
|
||||||
buffer.append("#undef x\n"); //$NON-NLS-1$
|
buffer.append("#undef x\n"); //$NON-NLS-1$
|
||||||
|
@ -1985,7 +1985,7 @@ public class AST2CSpecTest extends AST2SpecBaseTest {
|
||||||
--End Example]
|
--End Example]
|
||||||
*/
|
*/
|
||||||
public void test6_10_3_5s6() throws Exception {
|
public void test6_10_3_5s6() throws Exception {
|
||||||
StringBuffer buffer = new StringBuffer();
|
StringBuilder buffer = new StringBuilder();
|
||||||
buffer.append("#define str(s) # s \n"); //$NON-NLS-1$
|
buffer.append("#define str(s) # s \n"); //$NON-NLS-1$
|
||||||
buffer.append("#define xstr(s) str(s) \n"); //$NON-NLS-1$
|
buffer.append("#define xstr(s) str(s) \n"); //$NON-NLS-1$
|
||||||
buffer.append("#define debug(s, t) printf(\"x\" # s \"= %d, x\" # t \"= %s\", \\\n"); //$NON-NLS-1$
|
buffer.append("#define debug(s, t) printf(\"x\" # s \"= %d, x\" # t \"= %s\", \\\n"); //$NON-NLS-1$
|
||||||
|
@ -2017,7 +2017,7 @@ public class AST2CSpecTest extends AST2SpecBaseTest {
|
||||||
--End Example]
|
--End Example]
|
||||||
*/
|
*/
|
||||||
public void test6_10_3_5s7() throws Exception {
|
public void test6_10_3_5s7() throws Exception {
|
||||||
StringBuffer buffer = new StringBuffer();
|
StringBuilder buffer = new StringBuilder();
|
||||||
buffer.append("#define t(x,y,z) x ## y ## z\n"); //$NON-NLS-1$
|
buffer.append("#define t(x,y,z) x ## y ## z\n"); //$NON-NLS-1$
|
||||||
buffer.append("int j[] = { t(1,2,3), t(,4,5), t(6,,7), t(8,9,),\n"); //$NON-NLS-1$
|
buffer.append("int j[] = { t(1,2,3), t(,4,5), t(6,,7), t(8,9,),\n"); //$NON-NLS-1$
|
||||||
buffer.append("t(10,,), t(,11,), t(,,12), t(,,) };\n"); //$NON-NLS-1$
|
buffer.append("t(10,,), t(,11,), t(,,12), t(,,) };\n"); //$NON-NLS-1$
|
||||||
|
@ -2036,7 +2036,7 @@ public class AST2CSpecTest extends AST2SpecBaseTest {
|
||||||
--End Example]
|
--End Example]
|
||||||
*/
|
*/
|
||||||
public void test6_10_3_5s8() throws Exception {
|
public void test6_10_3_5s8() throws Exception {
|
||||||
StringBuffer buffer = new StringBuffer();
|
StringBuilder buffer = new StringBuilder();
|
||||||
buffer.append("#define OBJ_LIKE1 (1-1)\n"); //$NON-NLS-1$
|
buffer.append("#define OBJ_LIKE1 (1-1)\n"); //$NON-NLS-1$
|
||||||
buffer.append("#define OBJ_LIKE2 \\n"); //$NON-NLS-1$
|
buffer.append("#define OBJ_LIKE2 \\n"); //$NON-NLS-1$
|
||||||
buffer.append(" (1-1) \\n"); //$NON-NLS-1$
|
buffer.append(" (1-1) \\n"); //$NON-NLS-1$
|
||||||
|
@ -2062,7 +2062,7 @@ public class AST2CSpecTest extends AST2SpecBaseTest {
|
||||||
--End Example]
|
--End Example]
|
||||||
*/
|
*/
|
||||||
public void test6_10_3_5s9() throws Exception {
|
public void test6_10_3_5s9() throws Exception {
|
||||||
StringBuffer buffer = new StringBuffer();
|
StringBuilder buffer = new StringBuilder();
|
||||||
buffer.append("#define debug(...) fprintf(stderr, __VA_ARGS__)\n"); //$NON-NLS-1$
|
buffer.append("#define debug(...) fprintf(stderr, __VA_ARGS__)\n"); //$NON-NLS-1$
|
||||||
buffer.append("#define showlist(...) puts(#__VA_ARGS__)\n"); //$NON-NLS-1$
|
buffer.append("#define showlist(...) puts(#__VA_ARGS__)\n"); //$NON-NLS-1$
|
||||||
buffer.append("#define report(test, ...) ((test)?puts(#test):\\\n"); //$NON-NLS-1$
|
buffer.append("#define report(test, ...) ((test)?puts(#test):\\\n"); //$NON-NLS-1$
|
||||||
|
@ -2095,7 +2095,7 @@ public class AST2CSpecTest extends AST2SpecBaseTest {
|
||||||
--End Example]
|
--End Example]
|
||||||
*/
|
*/
|
||||||
public void test6_7_7s6() throws Exception {
|
public void test6_7_7s6() throws Exception {
|
||||||
StringBuffer buffer = new StringBuffer();
|
StringBuilder buffer = new StringBuilder();
|
||||||
buffer.append("typedef signed int t;\n"); //$NON-NLS-1$
|
buffer.append("typedef signed int t;\n"); //$NON-NLS-1$
|
||||||
buffer.append("typedef int plain;\n"); //$NON-NLS-1$
|
buffer.append("typedef int plain;\n"); //$NON-NLS-1$
|
||||||
buffer.append("struct tag {\n"); //$NON-NLS-1$
|
buffer.append("struct tag {\n"); //$NON-NLS-1$
|
||||||
|
|
|
@ -69,161 +69,161 @@ public class AST2KnRTests extends AST2BaseTest {
|
||||||
}
|
}
|
||||||
|
|
||||||
public void testSimpleKRCTest1() throws Exception {
|
public void testSimpleKRCTest1() throws Exception {
|
||||||
StringBuffer buffer = new StringBuffer();
|
StringBuilder buffer = new StringBuilder();
|
||||||
buffer.append( "int f(char x);\n" ); //$NON-NLS-1$
|
buffer.append("int f(char x);\n"); //$NON-NLS-1$
|
||||||
buffer.append( "int f(x) char x;\n" ); //$NON-NLS-1$
|
buffer.append("int f(x) char x;\n"); //$NON-NLS-1$
|
||||||
buffer.append( "{ return x == 0; }\n" ); //$NON-NLS-1$
|
buffer.append("{ return x == 0; }\n"); //$NON-NLS-1$
|
||||||
IASTTranslationUnit tu = parse( buffer.toString(), ParserLanguage.C, true );
|
IASTTranslationUnit tu = parse(buffer.toString(), ParserLanguage.C, true);
|
||||||
|
|
||||||
IASTSimpleDeclaration f1 = (IASTSimpleDeclaration)tu.getDeclarations()[0];
|
IASTSimpleDeclaration f1 = (IASTSimpleDeclaration) tu.getDeclarations()[0];
|
||||||
IASTFunctionDefinition f2 = (IASTFunctionDefinition)tu.getDeclarations()[1];
|
IASTFunctionDefinition f2 = (IASTFunctionDefinition) tu.getDeclarations()[1];
|
||||||
|
|
||||||
assertTrue( f1.getDeclarators()[0] instanceof IASTStandardFunctionDeclarator );
|
assertTrue(f1.getDeclarators()[0] instanceof IASTStandardFunctionDeclarator);
|
||||||
|
|
||||||
IParameter x4 = (IParameter)((IASTIdExpression)((IASTBinaryExpression)((IASTReturnStatement)((IASTCompoundStatement)f2.getBody()).getStatements()[0]).getReturnValue()).getOperand1()).getName().resolveBinding();
|
IParameter x4 = (IParameter) ((IASTIdExpression) ((IASTBinaryExpression) ((IASTReturnStatement) ((IASTCompoundStatement) f2.getBody()).getStatements()[0]).getReturnValue()).getOperand1()).getName().resolveBinding();
|
||||||
IParameter x3 = (IParameter)((IASTSimpleDeclaration)((ICASTKnRFunctionDeclarator)f2.getDeclarator()).getParameterDeclarations()[0]).getDeclarators()[0].getName().resolveBinding();
|
IParameter x3 = (IParameter) ((IASTSimpleDeclaration) ((ICASTKnRFunctionDeclarator) f2.getDeclarator()).getParameterDeclarations()[0]).getDeclarators()[0].getName().resolveBinding();
|
||||||
IParameter x2 = (IParameter)((ICASTKnRFunctionDeclarator)f2.getDeclarator()).getParameterNames()[0].resolveBinding();
|
IParameter x2 = (IParameter) ((ICASTKnRFunctionDeclarator) f2.getDeclarator()).getParameterNames()[0].resolveBinding();
|
||||||
IParameter x1 = (IParameter)((IASTStandardFunctionDeclarator)f1.getDeclarators()[0]).getParameters()[0].getDeclarator().getName().resolveBinding();
|
IParameter x1 = (IParameter) ((IASTStandardFunctionDeclarator) f1.getDeclarators()[0]).getParameters()[0].getDeclarator().getName().resolveBinding();
|
||||||
|
|
||||||
assertNotNull( x1 );
|
assertNotNull(x1);
|
||||||
assertNotNull( x2 );
|
assertNotNull(x2);
|
||||||
assertNotNull( x3 );
|
assertNotNull(x3);
|
||||||
assertNotNull( x4 );
|
assertNotNull(x4);
|
||||||
assertEquals( x1, x2 );
|
assertEquals(x1, x2);
|
||||||
assertEquals( x2, x3 );
|
assertEquals(x2, x3);
|
||||||
assertEquals( x3, x4 );
|
assertEquals(x3, x4);
|
||||||
|
|
||||||
// test tu.getDeclarationsInAST(IBinding)
|
// test tu.getDeclarationsInAST(IBinding)
|
||||||
IASTName[] decls = tu.getDeclarationsInAST(x1);
|
IASTName[] decls = tu.getDeclarationsInAST(x1);
|
||||||
assertEquals( decls.length, 2 );
|
assertEquals(decls.length, 2);
|
||||||
assertEquals( decls[0], ((IASTStandardFunctionDeclarator)f1.getDeclarators()[0]).getParameters()[0].getDeclarator().getName() );
|
assertEquals(decls[0], ((IASTStandardFunctionDeclarator) f1.getDeclarators()[0]).getParameters()[0].getDeclarator().getName());
|
||||||
assertEquals( decls[1], ((IASTSimpleDeclaration)((ICASTKnRFunctionDeclarator)f2.getDeclarator()).getParameterDeclarations()[0]).getDeclarators()[0].getName() );
|
assertEquals(decls[1], ((IASTSimpleDeclaration) ((ICASTKnRFunctionDeclarator) f2.getDeclarator()).getParameterDeclarations()[0]).getDeclarators()[0].getName());
|
||||||
|
|
||||||
assertNotNull( ((CScope)tu.getScope()).getBinding(CScope.NAMESPACE_TYPE_OTHER, new String("f").toCharArray()) ); //$NON-NLS-1$
|
assertNotNull(((CScope) tu.getScope()).getBinding(CScope.NAMESPACE_TYPE_OTHER, new String("f").toCharArray())); //$NON-NLS-1$
|
||||||
assertNotNull( ((CScope)((IASTCompoundStatement)f2.getBody()).getScope()).getBinding(CScope.NAMESPACE_TYPE_OTHER, new String("x").toCharArray()) ); //$NON-NLS-1$
|
assertNotNull(((CScope) ((IASTCompoundStatement) f2.getBody()).getScope()).getBinding(CScope.NAMESPACE_TYPE_OTHER, new String("x").toCharArray())); //$NON-NLS-1$
|
||||||
}
|
}
|
||||||
|
|
||||||
public void testSimpleKRCTest2() throws Exception {
|
public void testSimpleKRCTest2() throws Exception {
|
||||||
StringBuffer buffer = new StringBuffer();
|
StringBuilder buffer = new StringBuilder();
|
||||||
buffer.append( "int f();\n" ); //$NON-NLS-1$
|
buffer.append("int f();\n"); //$NON-NLS-1$
|
||||||
buffer.append( "int f(x) char x;\n" ); //$NON-NLS-1$
|
buffer.append("int f(x) char x;\n"); //$NON-NLS-1$
|
||||||
buffer.append( "{ return x == 0; }\n" ); //$NON-NLS-1$
|
buffer.append("{ return x == 0; }\n"); //$NON-NLS-1$
|
||||||
IASTTranslationUnit tu = parse( buffer.toString(), ParserLanguage.C, true );
|
IASTTranslationUnit tu = parse(buffer.toString(), ParserLanguage.C, true);
|
||||||
|
|
||||||
IASTSimpleDeclaration f1 = (IASTSimpleDeclaration)tu.getDeclarations()[0];
|
IASTSimpleDeclaration f1 = (IASTSimpleDeclaration) tu.getDeclarations()[0];
|
||||||
IASTFunctionDefinition f2 = (IASTFunctionDefinition)tu.getDeclarations()[1];
|
IASTFunctionDefinition f2 = (IASTFunctionDefinition) tu.getDeclarations()[1];
|
||||||
|
|
||||||
assertTrue( f1.getDeclarators()[0] instanceof IASTStandardFunctionDeclarator );
|
assertTrue(f1.getDeclarators()[0] instanceof IASTStandardFunctionDeclarator);
|
||||||
|
|
||||||
IParameter x4 = (IParameter)((IASTIdExpression)((IASTBinaryExpression)((IASTReturnStatement)((IASTCompoundStatement)f2.getBody()).getStatements()[0]).getReturnValue()).getOperand1()).getName().resolveBinding();
|
IParameter x4 = (IParameter) ((IASTIdExpression) ((IASTBinaryExpression) ((IASTReturnStatement) ((IASTCompoundStatement) f2.getBody()).getStatements()[0]).getReturnValue()).getOperand1()).getName().resolveBinding();
|
||||||
IParameter x3 = (IParameter)((IASTSimpleDeclaration)((ICASTKnRFunctionDeclarator)f2.getDeclarator()).getParameterDeclarations()[0]).getDeclarators()[0].getName().resolveBinding();
|
IParameter x3 = (IParameter) ((IASTSimpleDeclaration) ((ICASTKnRFunctionDeclarator) f2.getDeclarator()).getParameterDeclarations()[0]).getDeclarators()[0].getName().resolveBinding();
|
||||||
IParameter x2 = (IParameter)((ICASTKnRFunctionDeclarator)f2.getDeclarator()).getParameterNames()[0].resolveBinding();
|
IParameter x2 = (IParameter) ((ICASTKnRFunctionDeclarator) f2.getDeclarator()).getParameterNames()[0].resolveBinding();
|
||||||
|
|
||||||
assertNotNull( x2 );
|
assertNotNull(x2);
|
||||||
assertNotNull( x3 );
|
assertNotNull(x3);
|
||||||
assertNotNull( x4 );
|
assertNotNull(x4);
|
||||||
assertEquals( x2, x3 );
|
assertEquals(x2, x3);
|
||||||
assertEquals( x3, x4 );
|
assertEquals(x3, x4);
|
||||||
|
|
||||||
// test tu.getDeclarationsInAST(IBinding)
|
// test tu.getDeclarationsInAST(IBinding)
|
||||||
IASTName[] decls = tu.getDeclarationsInAST(x2);
|
IASTName[] decls = tu.getDeclarationsInAST(x2);
|
||||||
assertEquals( decls.length, 1 );
|
assertEquals(decls.length, 1);
|
||||||
assertEquals( decls[0], ((IASTSimpleDeclaration)((ICASTKnRFunctionDeclarator)f2.getDeclarator()).getParameterDeclarations()[0]).getDeclarators()[0].getName() );
|
assertEquals(decls[0], ((IASTSimpleDeclaration) ((ICASTKnRFunctionDeclarator) f2.getDeclarator()).getParameterDeclarations()[0]).getDeclarators()[0].getName());
|
||||||
|
|
||||||
assertNotNull( ((CScope)tu.getScope()).getBinding(CScope.NAMESPACE_TYPE_OTHER, new String("f").toCharArray()) ); //$NON-NLS-1$
|
assertNotNull(((CScope) tu.getScope()).getBinding(CScope.NAMESPACE_TYPE_OTHER, new String("f").toCharArray())); //$NON-NLS-1$
|
||||||
assertNotNull( ((CScope)((IASTCompoundStatement)f2.getBody()).getScope()).getBinding(CScope.NAMESPACE_TYPE_OTHER, new String("x").toCharArray()) ); //$NON-NLS-1$
|
assertNotNull(((CScope) ((IASTCompoundStatement) f2.getBody()).getScope()).getBinding(CScope.NAMESPACE_TYPE_OTHER, new String("x").toCharArray())); //$NON-NLS-1$
|
||||||
}
|
}
|
||||||
|
|
||||||
public void testSimpleKRCTest3() throws Exception {
|
public void testSimpleKRCTest3() throws Exception {
|
||||||
StringBuffer buffer = new StringBuffer();
|
StringBuilder buffer = new StringBuilder();
|
||||||
buffer.append( "int const *f();\n" ); //$NON-NLS-1$
|
buffer.append("int const *f();\n"); //$NON-NLS-1$
|
||||||
buffer.append( "int const *f(x) char x;\n" ); //$NON-NLS-1$
|
buffer.append("int const *f(x) char x;\n"); //$NON-NLS-1$
|
||||||
buffer.append( "{ return x == 0; }\n" ); //$NON-NLS-1$
|
buffer.append("{ return x == 0; }\n"); //$NON-NLS-1$
|
||||||
IASTTranslationUnit tu = parse( buffer.toString(), ParserLanguage.C, true );
|
IASTTranslationUnit tu = parse(buffer.toString(), ParserLanguage.C, true);
|
||||||
|
|
||||||
IASTSimpleDeclaration f1 = (IASTSimpleDeclaration)tu.getDeclarations()[0];
|
IASTSimpleDeclaration f1 = (IASTSimpleDeclaration) tu.getDeclarations()[0];
|
||||||
IASTFunctionDefinition f2 = (IASTFunctionDefinition)tu.getDeclarations()[1];
|
IASTFunctionDefinition f2 = (IASTFunctionDefinition) tu.getDeclarations()[1];
|
||||||
|
|
||||||
assertTrue( f1.getDeclarators()[0] instanceof IASTStandardFunctionDeclarator );
|
assertTrue(f1.getDeclarators()[0] instanceof IASTStandardFunctionDeclarator);
|
||||||
|
|
||||||
IParameter x4 = (IParameter)((IASTIdExpression)((IASTBinaryExpression)((IASTReturnStatement)((IASTCompoundStatement)f2.getBody()).getStatements()[0]).getReturnValue()).getOperand1()).getName().resolveBinding();
|
IParameter x4 = (IParameter) ((IASTIdExpression) ((IASTBinaryExpression) ((IASTReturnStatement) ((IASTCompoundStatement) f2.getBody()).getStatements()[0]).getReturnValue()).getOperand1()).getName().resolveBinding();
|
||||||
IParameter x3 = (IParameter)((IASTSimpleDeclaration)((ICASTKnRFunctionDeclarator)f2.getDeclarator()).getParameterDeclarations()[0]).getDeclarators()[0].getName().resolveBinding();
|
IParameter x3 = (IParameter) ((IASTSimpleDeclaration) ((ICASTKnRFunctionDeclarator) f2.getDeclarator()).getParameterDeclarations()[0]).getDeclarators()[0].getName().resolveBinding();
|
||||||
IParameter x2 = (IParameter)((ICASTKnRFunctionDeclarator)f2.getDeclarator()).getParameterNames()[0].resolveBinding();
|
IParameter x2 = (IParameter) ((ICASTKnRFunctionDeclarator) f2.getDeclarator()).getParameterNames()[0].resolveBinding();
|
||||||
|
|
||||||
assertNotNull( x2 );
|
assertNotNull(x2);
|
||||||
assertNotNull( x3 );
|
assertNotNull(x3);
|
||||||
assertNotNull( x4 );
|
assertNotNull(x4);
|
||||||
assertEquals( x2, x3 );
|
assertEquals(x2, x3);
|
||||||
assertEquals( x3, x4 );
|
assertEquals(x3, x4);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void testKRC_1() throws Exception {
|
public void testKRC_1() throws Exception {
|
||||||
StringBuffer buffer = new StringBuffer();
|
StringBuilder buffer = new StringBuilder();
|
||||||
buffer.append( "int isroot (x, y) /* comment */ \n" ); //$NON-NLS-1$
|
buffer.append("int isroot (x, y) /* comment */ \n"); //$NON-NLS-1$
|
||||||
buffer.append( "int x;\n" ); //$NON-NLS-1$
|
buffer.append("int x;\n"); //$NON-NLS-1$
|
||||||
buffer.append( "int y;\n" ); //$NON-NLS-1$
|
buffer.append("int y;\n"); //$NON-NLS-1$
|
||||||
buffer.append( "{ return x == 0; }\n" ); //$NON-NLS-1$
|
buffer.append("{ return x == 0; }\n"); //$NON-NLS-1$
|
||||||
IASTTranslationUnit tu = parse( buffer.toString(), ParserLanguage.C, true );
|
IASTTranslationUnit tu = parse(buffer.toString(), ParserLanguage.C, true);
|
||||||
|
|
||||||
IASTFunctionDefinition isroot_def = (IASTFunctionDefinition)tu.getDeclarations()[0];
|
IASTFunctionDefinition isroot_def = (IASTFunctionDefinition) tu.getDeclarations()[0];
|
||||||
|
|
||||||
IASTName ret_x = ((IASTIdExpression)((IASTBinaryExpression)((IASTReturnStatement)((IASTCompoundStatement)isroot_def.getBody()).getStatements()[0]).getReturnValue()).getOperand1()).getName();
|
IASTName ret_x = ((IASTIdExpression) ((IASTBinaryExpression) ((IASTReturnStatement) ((IASTCompoundStatement) isroot_def.getBody()).getStatements()[0]).getReturnValue()).getOperand1()).getName();
|
||||||
IASTDeclarator isroot_decltor = isroot_def.getDeclarator();
|
IASTDeclarator isroot_decltor = isroot_def.getDeclarator();
|
||||||
|
|
||||||
assertTrue( isroot_decltor instanceof ICASTKnRFunctionDeclarator );
|
assertTrue(isroot_decltor instanceof ICASTKnRFunctionDeclarator);
|
||||||
IASTDeclarator x1 = ((IASTSimpleDeclaration)((ICASTKnRFunctionDeclarator)isroot_decltor).getParameterDeclarations()[0]).getDeclarators()[0];
|
IASTDeclarator x1 = ((IASTSimpleDeclaration) ((ICASTKnRFunctionDeclarator) isroot_decltor).getParameterDeclarations()[0]).getDeclarators()[0];
|
||||||
IASTDeclarator y1 = ((IASTSimpleDeclaration)((ICASTKnRFunctionDeclarator)isroot_decltor).getParameterDeclarations()[1]).getDeclarators()[0];
|
IASTDeclarator y1 = ((IASTSimpleDeclaration) ((ICASTKnRFunctionDeclarator) isroot_decltor).getParameterDeclarations()[1]).getDeclarators()[0];
|
||||||
|
|
||||||
IParameter x_parm = (IParameter)x1.getName().resolveBinding();
|
IParameter x_parm = (IParameter) x1.getName().resolveBinding();
|
||||||
IParameter y_parm = (IParameter)y1.getName().resolveBinding();
|
IParameter y_parm = (IParameter) y1.getName().resolveBinding();
|
||||||
assertNotNull( x_parm );
|
assertNotNull(x_parm);
|
||||||
assertNotNull( y_parm );
|
assertNotNull(y_parm);
|
||||||
|
|
||||||
IASTDeclarator x2 = ((IASTSimpleDeclaration)((ICASTKnRFunctionDeclarator)isroot_decltor).getParameterDeclarations()[0]).getDeclarators()[0];
|
IASTDeclarator x2 = ((IASTSimpleDeclaration) ((ICASTKnRFunctionDeclarator) isroot_decltor).getParameterDeclarations()[0]).getDeclarators()[0];
|
||||||
IASTDeclarator y2 = ((IASTSimpleDeclaration)((ICASTKnRFunctionDeclarator)isroot_decltor).getParameterDeclarations()[1]).getDeclarators()[0];
|
IASTDeclarator y2 = ((IASTSimpleDeclaration) ((ICASTKnRFunctionDeclarator) isroot_decltor).getParameterDeclarations()[1]).getDeclarators()[0];
|
||||||
|
|
||||||
IParameter x_parm2 = (IParameter)x2.getName().resolveBinding();
|
IParameter x_parm2 = (IParameter) x2.getName().resolveBinding();
|
||||||
IParameter y_parm2 = (IParameter)y2.getName().resolveBinding();
|
IParameter y_parm2 = (IParameter) y2.getName().resolveBinding();
|
||||||
|
|
||||||
assertNotNull( x_parm2 );
|
assertNotNull(x_parm2);
|
||||||
assertNotNull( y_parm2 );
|
assertNotNull(y_parm2);
|
||||||
assertNotNull( ret_x.resolveBinding() );
|
assertNotNull(ret_x.resolveBinding());
|
||||||
|
|
||||||
assertEquals( x_parm, x_parm2 );
|
assertEquals(x_parm, x_parm2);
|
||||||
assertEquals( y_parm, y_parm2 );
|
assertEquals(y_parm, y_parm2);
|
||||||
assertEquals( ret_x.resolveBinding(), x_parm );
|
assertEquals(ret_x.resolveBinding(), x_parm);
|
||||||
|
|
||||||
// test tu.getDeclarationsInAST(IBinding)
|
// test tu.getDeclarationsInAST(IBinding)
|
||||||
IASTName[] decls = tu.getDeclarationsInAST(ret_x.resolveBinding());
|
IASTName[] decls = tu.getDeclarationsInAST(ret_x.resolveBinding());
|
||||||
assertEquals( decls.length, 1 );
|
assertEquals(decls.length, 1);
|
||||||
assertEquals( decls[0], x1.getName() );
|
assertEquals(decls[0], x1.getName());
|
||||||
|
|
||||||
assertNotNull( ((CScope)tu.getScope()).getBinding(CScope.NAMESPACE_TYPE_OTHER, new String("isroot").toCharArray()) ); //$NON-NLS-1$
|
assertNotNull(((CScope) tu.getScope()).getBinding(CScope.NAMESPACE_TYPE_OTHER, new String("isroot").toCharArray())); //$NON-NLS-1$
|
||||||
assertNotNull( ((CScope)((IASTCompoundStatement)isroot_def.getBody()).getScope()).getBinding(CScope.NAMESPACE_TYPE_OTHER, new String("x").toCharArray()) ); //$NON-NLS-1$
|
assertNotNull(((CScope) ((IASTCompoundStatement) isroot_def.getBody()).getScope()).getBinding(CScope.NAMESPACE_TYPE_OTHER, new String("x").toCharArray())); //$NON-NLS-1$
|
||||||
assertNotNull( ((CScope)((IASTCompoundStatement)isroot_def.getBody()).getScope()).getBinding(CScope.NAMESPACE_TYPE_OTHER, new String("y").toCharArray()) ); //$NON-NLS-1$
|
assertNotNull(((CScope) ((IASTCompoundStatement) isroot_def.getBody()).getScope()).getBinding(CScope.NAMESPACE_TYPE_OTHER, new String("y").toCharArray())); //$NON-NLS-1$
|
||||||
}
|
}
|
||||||
|
|
||||||
public void testKRCWithTypes() throws Exception {
|
public void testKRCWithTypes() throws Exception {
|
||||||
StringBuffer buffer = new StringBuffer();
|
StringBuilder buffer = new StringBuilder();
|
||||||
buffer.append( "typedef char c;\n" ); //$NON-NLS-1$
|
buffer.append("typedef char c;\n"); //$NON-NLS-1$
|
||||||
buffer.append( "int isroot (c);\n" ); //$NON-NLS-1$
|
buffer.append("int isroot (c);\n"); //$NON-NLS-1$
|
||||||
buffer.append( "int isroot (x) \n" ); //$NON-NLS-1$
|
buffer.append("int isroot (x) \n"); //$NON-NLS-1$
|
||||||
buffer.append( "c x;\n" ); //$NON-NLS-1$
|
buffer.append("c x;\n"); //$NON-NLS-1$
|
||||||
buffer.append( "{ return x == 0; }\n" ); //$NON-NLS-1$
|
buffer.append("{ return x == 0; }\n"); //$NON-NLS-1$
|
||||||
IASTTranslationUnit tu = parse( buffer.toString(), ParserLanguage.C, true );
|
IASTTranslationUnit tu = parse(buffer.toString(), ParserLanguage.C, true);
|
||||||
|
|
||||||
IASTSimpleDeclaration c_decl = (IASTSimpleDeclaration)tu.getDeclarations()[0];
|
IASTSimpleDeclaration c_decl = (IASTSimpleDeclaration) tu.getDeclarations()[0];
|
||||||
IASTSimpleDeclaration isroot_decl = (IASTSimpleDeclaration)tu.getDeclarations()[1];
|
IASTSimpleDeclaration isroot_decl = (IASTSimpleDeclaration) tu.getDeclarations()[1];
|
||||||
IASTFunctionDefinition isroot_def = (IASTFunctionDefinition)tu.getDeclarations()[2];
|
IASTFunctionDefinition isroot_def = (IASTFunctionDefinition) tu.getDeclarations()[2];
|
||||||
|
|
||||||
//IASTName x0 = ((IASTStandardFunctionDeclarator)isroot_decl.getDeclarators()[0]).getParameters()[0].getDeclarator().getName();
|
//IASTName x0 = ((IASTStandardFunctionDeclarator) isroot_decl.getDeclarators()[0]).getParameters()[0].getDeclarator().getName();
|
||||||
IASTName x1 = ((ICASTKnRFunctionDeclarator)isroot_def.getDeclarator()).getParameterNames()[0];
|
IASTName x1 = ((ICASTKnRFunctionDeclarator) isroot_def.getDeclarator()).getParameterNames()[0];
|
||||||
IASTName x2 = ((IASTSimpleDeclaration)((ICASTKnRFunctionDeclarator)isroot_def.getDeclarator()).getParameterDeclarations()[0]).getDeclarators()[0].getName();
|
IASTName x2 = ((IASTSimpleDeclaration) ((ICASTKnRFunctionDeclarator) isroot_def.getDeclarator()).getParameterDeclarations()[0]).getDeclarators()[0].getName();
|
||||||
IASTName x3 = ((IASTIdExpression)((IASTBinaryExpression)((IASTReturnStatement)((IASTCompoundStatement)isroot_def.getBody()).getStatements()[0]).getReturnValue()).getOperand1()).getName();
|
IASTName x3 = ((IASTIdExpression) ((IASTBinaryExpression) ((IASTReturnStatement) ((IASTCompoundStatement) isroot_def.getBody()).getStatements()[0]).getReturnValue()).getOperand1()).getName();
|
||||||
|
|
||||||
IParameter x1_var = (IParameter)x1.resolveBinding();
|
IParameter x1_var = (IParameter) x1.resolveBinding();
|
||||||
IParameter x2_var = (IParameter)x2.resolveBinding();
|
IParameter x2_var = (IParameter) x2.resolveBinding();
|
||||||
IParameter x3_var = (IParameter)x3.resolveBinding();
|
IParameter x3_var = (IParameter) x3.resolveBinding();
|
||||||
|
|
||||||
assertNotNull(x1_var);
|
assertNotNull(x1_var);
|
||||||
assertNotNull(x2_var);
|
assertNotNull(x2_var);
|
||||||
|
@ -232,12 +232,12 @@ public class AST2KnRTests extends AST2BaseTest {
|
||||||
assertEquals(x2_var, x3_var);
|
assertEquals(x2_var, x3_var);
|
||||||
|
|
||||||
IASTName c1 = c_decl.getDeclarators()[0].getName();
|
IASTName c1 = c_decl.getDeclarators()[0].getName();
|
||||||
IASTName c2 = ((IASTNamedTypeSpecifier)((IASTStandardFunctionDeclarator)isroot_decl.getDeclarators()[0]).getParameters()[0].getDeclSpecifier()).getName();
|
IASTName c2 = ((IASTNamedTypeSpecifier) ((IASTStandardFunctionDeclarator) isroot_decl.getDeclarators()[0]).getParameters()[0].getDeclSpecifier()).getName();
|
||||||
IASTName c3 = ((IASTNamedTypeSpecifier)((IASTSimpleDeclaration)((ICASTKnRFunctionDeclarator)isroot_def.getDeclarator()).getParameterDeclarations()[0]).getDeclSpecifier()).getName();
|
IASTName c3 = ((IASTNamedTypeSpecifier) ((IASTSimpleDeclaration) ((ICASTKnRFunctionDeclarator) isroot_def.getDeclarator()).getParameterDeclarations()[0]).getDeclSpecifier()).getName();
|
||||||
|
|
||||||
ITypedef c1_t = (ITypedef)c1.resolveBinding();
|
ITypedef c1_t = (ITypedef) c1.resolveBinding();
|
||||||
ITypedef c2_t = (ITypedef)c2.resolveBinding();
|
ITypedef c2_t = (ITypedef) c2.resolveBinding();
|
||||||
ITypedef c3_t = (ITypedef)c3.resolveBinding();
|
ITypedef c3_t = (ITypedef) c3.resolveBinding();
|
||||||
|
|
||||||
assertNotNull(c1_t);
|
assertNotNull(c1_t);
|
||||||
assertNotNull(c2_t);
|
assertNotNull(c2_t);
|
||||||
|
@ -245,101 +245,101 @@ public class AST2KnRTests extends AST2BaseTest {
|
||||||
assertEquals(c1_t, c2_t);
|
assertEquals(c1_t, c2_t);
|
||||||
assertEquals(c2_t, c3_t);
|
assertEquals(c2_t, c3_t);
|
||||||
assertTrue(c1_t.getType() instanceof IBasicType);
|
assertTrue(c1_t.getType() instanceof IBasicType);
|
||||||
assertEquals(((IBasicType)c1_t.getType()).getType(), IBasicType.t_char);
|
assertEquals(((IBasicType) c1_t.getType()).getType(), IBasicType.t_char);
|
||||||
|
|
||||||
// test tu.getDeclarationsInAST(IBinding)
|
// test tu.getDeclarationsInAST(IBinding)
|
||||||
IASTName[] decls = tu.getDeclarationsInAST(x3.resolveBinding());
|
IASTName[] decls = tu.getDeclarationsInAST(x3.resolveBinding());
|
||||||
assertEquals( decls.length, 1 );
|
assertEquals(decls.length, 1);
|
||||||
assertEquals( decls[0], x2 );
|
assertEquals(decls[0], x2);
|
||||||
|
|
||||||
assertNotNull( ((CScope)tu.getScope()).getBinding(CScope.NAMESPACE_TYPE_OTHER, new String("c").toCharArray()) ); //$NON-NLS-1$
|
assertNotNull(((CScope) tu.getScope()).getBinding(CScope.NAMESPACE_TYPE_OTHER, new String("c").toCharArray())); //$NON-NLS-1$
|
||||||
assertNotNull( ((CScope)tu.getScope()).getBinding(CScope.NAMESPACE_TYPE_OTHER, new String("isroot").toCharArray()) ); //$NON-NLS-1$
|
assertNotNull(((CScope) tu.getScope()).getBinding(CScope.NAMESPACE_TYPE_OTHER, new String("isroot").toCharArray())); //$NON-NLS-1$
|
||||||
assertNotNull( ((CScope)((IASTCompoundStatement)isroot_def.getBody()).getScope()).getBinding(CScope.NAMESPACE_TYPE_OTHER, new String("x").toCharArray()) ); //$NON-NLS-1$
|
assertNotNull(((CScope) ((IASTCompoundStatement) isroot_def.getBody()).getScope()).getBinding(CScope.NAMESPACE_TYPE_OTHER, new String("x").toCharArray())); //$NON-NLS-1$
|
||||||
}
|
}
|
||||||
|
|
||||||
public void testKRCProblem1() throws Exception {
|
public void testKRCProblem1() throws Exception {
|
||||||
StringBuffer buffer = new StringBuffer();
|
StringBuilder buffer = new StringBuilder();
|
||||||
buffer.append( "int f(x) char\n" ); //$NON-NLS-1$
|
buffer.append("int f(x) char\n"); //$NON-NLS-1$
|
||||||
buffer.append( "{ return x == 0; }\n" ); //$NON-NLS-1$
|
buffer.append("{ return x == 0; }\n"); //$NON-NLS-1$
|
||||||
IASTTranslationUnit tu = parse( buffer.toString(), ParserLanguage.C, true, false );
|
IASTTranslationUnit tu = parse(buffer.toString(), ParserLanguage.C, true, false);
|
||||||
IASTDeclaration[] decls= tu.getDeclarations();
|
IASTDeclaration[] decls= tu.getDeclarations();
|
||||||
|
|
||||||
assertTrue(CVisitor.getProblems(tu).length > 0);
|
assertTrue(CVisitor.getProblems(tu).length > 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void testKRCProblem2() throws Exception {
|
public void testKRCProblem2() throws Exception {
|
||||||
StringBuffer buffer = new StringBuffer();
|
StringBuilder buffer = new StringBuilder();
|
||||||
buffer.append( "int i=0;\n" ); //$NON-NLS-1$
|
buffer.append("int i=0;\n"); //$NON-NLS-1$
|
||||||
buffer.append( "int f(x) i++;\n" ); //$NON-NLS-1$
|
buffer.append("int f(x) i++;\n"); //$NON-NLS-1$
|
||||||
buffer.append( "{ return x == 0; }\n" ); //$NON-NLS-1$
|
buffer.append("{ return x == 0; }\n"); //$NON-NLS-1$
|
||||||
IASTTranslationUnit tu = parse( buffer.toString(), ParserLanguage.C, true, false );
|
IASTTranslationUnit tu = parse(buffer.toString(), ParserLanguage.C, true, false);
|
||||||
|
|
||||||
IASTSimpleDeclaration sd= getDeclaration(tu, 0);
|
IASTSimpleDeclaration sd= getDeclaration(tu, 0);
|
||||||
assertTrue(CVisitor.getProblems(tu).length > 0);
|
assertTrue(CVisitor.getProblems(tu).length > 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void testKRCProblem3() throws Exception {
|
public void testKRCProblem3() throws Exception {
|
||||||
StringBuffer buffer = new StringBuffer();
|
StringBuilder buffer = new StringBuilder();
|
||||||
buffer.append( "int f(x) char y;\n" ); //$NON-NLS-1$
|
buffer.append("int f(x) char y;\n"); //$NON-NLS-1$
|
||||||
buffer.append( "{ return x == 0; }\n" ); //$NON-NLS-1$
|
buffer.append("{ return x == 0; }\n"); //$NON-NLS-1$
|
||||||
IASTTranslationUnit tu = parse( buffer.toString(), ParserLanguage.C, true, false );
|
IASTTranslationUnit tu = parse(buffer.toString(), ParserLanguage.C, true, false);
|
||||||
|
|
||||||
IASTFunctionDefinition f = (IASTFunctionDefinition)tu.getDeclarations()[0];
|
IASTFunctionDefinition f = (IASTFunctionDefinition) tu.getDeclarations()[0];
|
||||||
assertTrue(f.getDeclarator() instanceof ICASTKnRFunctionDeclarator);
|
assertTrue(f.getDeclarator() instanceof ICASTKnRFunctionDeclarator);
|
||||||
ICASTKnRFunctionDeclarator f_kr = (ICASTKnRFunctionDeclarator)f.getDeclarator();
|
ICASTKnRFunctionDeclarator f_kr = (ICASTKnRFunctionDeclarator) f.getDeclarator();
|
||||||
assertEquals(f_kr.getName().toString(), "f"); //$NON-NLS-1$
|
assertEquals(f_kr.getName().toString(), "f"); //$NON-NLS-1$
|
||||||
assertEquals(f_kr.getParameterNames()[0].toString(), "x"); //$NON-NLS-1$
|
assertEquals(f_kr.getParameterNames()[0].toString(), "x"); //$NON-NLS-1$
|
||||||
assertTrue(f_kr.getParameterDeclarations()[0] instanceof IASTProblemDeclaration);
|
assertTrue(f_kr.getParameterDeclarations()[0] instanceof IASTProblemDeclaration);
|
||||||
assertTrue(f.getBody() instanceof IASTCompoundStatement);
|
assertTrue(f.getBody() instanceof IASTCompoundStatement);
|
||||||
assertTrue(((IASTCompoundStatement)f.getBody()).getStatements()[0] instanceof IASTReturnStatement);
|
assertTrue(((IASTCompoundStatement) f.getBody()).getStatements()[0] instanceof IASTReturnStatement);
|
||||||
assertTrue(((IASTReturnStatement)((IASTCompoundStatement)f.getBody()).getStatements()[0]).getReturnValue() instanceof IASTBinaryExpression);
|
assertTrue(((IASTReturnStatement) ((IASTCompoundStatement) f.getBody()).getStatements()[0]).getReturnValue() instanceof IASTBinaryExpression);
|
||||||
assertTrue(((IASTBinaryExpression)((IASTReturnStatement)((IASTCompoundStatement)f.getBody()).getStatements()[0]).getReturnValue()).getOperand1() instanceof IASTIdExpression);
|
assertTrue(((IASTBinaryExpression) ((IASTReturnStatement) ((IASTCompoundStatement) f.getBody()).getStatements()[0]).getReturnValue()).getOperand1() instanceof IASTIdExpression);
|
||||||
assertEquals(((IASTIdExpression)((IASTBinaryExpression)((IASTReturnStatement)((IASTCompoundStatement)f.getBody()).getStatements()[0]).getReturnValue()).getOperand1()).getName().toString(), "x"); //$NON-NLS-1$
|
assertEquals(((IASTIdExpression) ((IASTBinaryExpression) ((IASTReturnStatement) ((IASTCompoundStatement) f.getBody()).getStatements()[0]).getReturnValue()).getOperand1()).getName().toString(), "x"); //$NON-NLS-1$
|
||||||
assertTrue(((IASTBinaryExpression)((IASTReturnStatement)((IASTCompoundStatement)f.getBody()).getStatements()[0]).getReturnValue()).getOperand2() instanceof IASTLiteralExpression);
|
assertTrue(((IASTBinaryExpression) ((IASTReturnStatement) ((IASTCompoundStatement) f.getBody()).getStatements()[0]).getReturnValue()).getOperand2() instanceof IASTLiteralExpression);
|
||||||
assertEquals(((IASTLiteralExpression)((IASTBinaryExpression)((IASTReturnStatement)((IASTCompoundStatement)f.getBody()).getStatements()[0]).getReturnValue()).getOperand2()).toString(), "0"); //$NON-NLS-1$
|
assertEquals(((IASTLiteralExpression) ((IASTBinaryExpression) ((IASTReturnStatement) ((IASTCompoundStatement) f.getBody()).getStatements()[0]).getReturnValue()).getOperand2()).toString(), "0"); //$NON-NLS-1$
|
||||||
|
|
||||||
// test tu.getDeclarationsInAST(IBinding)
|
// test tu.getDeclarationsInAST(IBinding)
|
||||||
IASTName[] decls = tu.getDeclarationsInAST(((IASTIdExpression)((IASTBinaryExpression)((IASTReturnStatement)((IASTCompoundStatement)f.getBody()).getStatements()[0]).getReturnValue()).getOperand1()).getName().resolveBinding());
|
IASTName[] decls = tu.getDeclarationsInAST(((IASTIdExpression) ((IASTBinaryExpression) ((IASTReturnStatement) ((IASTCompoundStatement) f.getBody()).getStatements()[0]).getReturnValue()).getOperand1()).getName().resolveBinding());
|
||||||
assertEquals( decls.length, 0 );
|
assertEquals(decls.length, 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void testKRCProblem4() throws Exception {
|
public void testKRCProblem4() throws Exception {
|
||||||
StringBuffer buffer = new StringBuffer();
|
StringBuilder buffer = new StringBuilder();
|
||||||
buffer.append( "int f(x,y,z) char x,y,z; int a;\n" ); //$NON-NLS-1$
|
buffer.append("int f(x,y,z) char x,y,z; int a;\n"); //$NON-NLS-1$
|
||||||
buffer.append( "{ return x == 0; }\n" ); //$NON-NLS-1$
|
buffer.append("{ return x == 0; }\n"); //$NON-NLS-1$
|
||||||
IASTTranslationUnit tu = parse( buffer.toString(), ParserLanguage.C, true, false );
|
IASTTranslationUnit tu = parse(buffer.toString(), ParserLanguage.C, true, false);
|
||||||
|
|
||||||
IASTFunctionDefinition f = (IASTFunctionDefinition)tu.getDeclarations()[0];
|
IASTFunctionDefinition f = (IASTFunctionDefinition) tu.getDeclarations()[0];
|
||||||
assertTrue(f.getDeclarator() instanceof ICASTKnRFunctionDeclarator);
|
assertTrue(f.getDeclarator() instanceof ICASTKnRFunctionDeclarator);
|
||||||
ICASTKnRFunctionDeclarator f_kr = (ICASTKnRFunctionDeclarator)f.getDeclarator();
|
ICASTKnRFunctionDeclarator f_kr = (ICASTKnRFunctionDeclarator) f.getDeclarator();
|
||||||
assertEquals(f_kr.getName().toString(), "f"); //$NON-NLS-1$
|
assertEquals(f_kr.getName().toString(), "f"); //$NON-NLS-1$
|
||||||
assertEquals(f_kr.getParameterNames()[0].toString(), "x"); //$NON-NLS-1$
|
assertEquals(f_kr.getParameterNames()[0].toString(), "x"); //$NON-NLS-1$
|
||||||
assertTrue(f_kr.getParameterDeclarations()[0] instanceof IASTSimpleDeclaration);
|
assertTrue(f_kr.getParameterDeclarations()[0] instanceof IASTSimpleDeclaration);
|
||||||
assertTrue(f_kr.getParameterDeclarations()[1] instanceof IASTProblemDeclaration);
|
assertTrue(f_kr.getParameterDeclarations()[1] instanceof IASTProblemDeclaration);
|
||||||
assertTrue(f.getBody() instanceof IASTCompoundStatement);
|
assertTrue(f.getBody() instanceof IASTCompoundStatement);
|
||||||
assertTrue(((IASTCompoundStatement)f.getBody()).getStatements()[0] instanceof IASTReturnStatement);
|
assertTrue(((IASTCompoundStatement) f.getBody()).getStatements()[0] instanceof IASTReturnStatement);
|
||||||
assertTrue(((IASTReturnStatement)((IASTCompoundStatement)f.getBody()).getStatements()[0]).getReturnValue() instanceof IASTBinaryExpression);
|
assertTrue(((IASTReturnStatement) ((IASTCompoundStatement) f.getBody()).getStatements()[0]).getReturnValue() instanceof IASTBinaryExpression);
|
||||||
assertTrue(((IASTBinaryExpression)((IASTReturnStatement)((IASTCompoundStatement)f.getBody()).getStatements()[0]).getReturnValue()).getOperand1() instanceof IASTIdExpression);
|
assertTrue(((IASTBinaryExpression) ((IASTReturnStatement) ((IASTCompoundStatement) f.getBody()).getStatements()[0]).getReturnValue()).getOperand1() instanceof IASTIdExpression);
|
||||||
assertEquals(((IASTIdExpression)((IASTBinaryExpression)((IASTReturnStatement)((IASTCompoundStatement)f.getBody()).getStatements()[0]).getReturnValue()).getOperand1()).getName().toString(), "x"); //$NON-NLS-1$
|
assertEquals(((IASTIdExpression) ((IASTBinaryExpression) ((IASTReturnStatement) ((IASTCompoundStatement) f.getBody()).getStatements()[0]).getReturnValue()).getOperand1()).getName().toString(), "x"); //$NON-NLS-1$
|
||||||
assertTrue(((IASTBinaryExpression)((IASTReturnStatement)((IASTCompoundStatement)f.getBody()).getStatements()[0]).getReturnValue()).getOperand2() instanceof IASTLiteralExpression);
|
assertTrue(((IASTBinaryExpression) ((IASTReturnStatement) ((IASTCompoundStatement) f.getBody()).getStatements()[0]).getReturnValue()).getOperand2() instanceof IASTLiteralExpression);
|
||||||
assertEquals(((IASTLiteralExpression)((IASTBinaryExpression)((IASTReturnStatement)((IASTCompoundStatement)f.getBody()).getStatements()[0]).getReturnValue()).getOperand2()).toString(), "0"); //$NON-NLS-1$
|
assertEquals(((IASTLiteralExpression) ((IASTBinaryExpression) ((IASTReturnStatement) ((IASTCompoundStatement) f.getBody()).getStatements()[0]).getReturnValue()).getOperand2()).toString(), "0"); //$NON-NLS-1$
|
||||||
|
|
||||||
// bindings should still be ok
|
// bindings should still be ok
|
||||||
IASTName x1 = f_kr.getParameterNames()[0];
|
IASTName x1 = f_kr.getParameterNames()[0];
|
||||||
IASTName y1 = f_kr.getParameterNames()[1];
|
IASTName y1 = f_kr.getParameterNames()[1];
|
||||||
IASTName z1 = f_kr.getParameterNames()[2];
|
IASTName z1 = f_kr.getParameterNames()[2];
|
||||||
IASTName x2 = ((IASTSimpleDeclaration)f_kr.getParameterDeclarations()[0]).getDeclarators()[0].getName();
|
IASTName x2 = ((IASTSimpleDeclaration) f_kr.getParameterDeclarations()[0]).getDeclarators()[0].getName();
|
||||||
IASTName y2 = ((IASTSimpleDeclaration)f_kr.getParameterDeclarations()[0]).getDeclarators()[1].getName();
|
IASTName y2 = ((IASTSimpleDeclaration) f_kr.getParameterDeclarations()[0]).getDeclarators()[1].getName();
|
||||||
IASTName z2 = ((IASTSimpleDeclaration)f_kr.getParameterDeclarations()[0]).getDeclarators()[2].getName();
|
IASTName z2 = ((IASTSimpleDeclaration) f_kr.getParameterDeclarations()[0]).getDeclarators()[2].getName();
|
||||||
IASTName x3 = ((IASTIdExpression)((IASTBinaryExpression)((IASTReturnStatement)((IASTCompoundStatement)f.getBody()).getStatements()[0]).getReturnValue()).getOperand1()).getName();
|
IASTName x3 = ((IASTIdExpression) ((IASTBinaryExpression) ((IASTReturnStatement) ((IASTCompoundStatement) f.getBody()).getStatements()[0]).getReturnValue()).getOperand1()).getName();
|
||||||
|
|
||||||
IParameter x1_parm = (IParameter)x1.resolveBinding();
|
IParameter x1_parm = (IParameter) x1.resolveBinding();
|
||||||
IParameter x2_parm = (IParameter)x2.resolveBinding();
|
IParameter x2_parm = (IParameter) x2.resolveBinding();
|
||||||
IParameter x3_parm = (IParameter)x3.resolveBinding();
|
IParameter x3_parm = (IParameter) x3.resolveBinding();
|
||||||
IParameter y1_parm = (IParameter)y1.resolveBinding();
|
IParameter y1_parm = (IParameter) y1.resolveBinding();
|
||||||
IParameter y2_parm = (IParameter)y2.resolveBinding();
|
IParameter y2_parm = (IParameter) y2.resolveBinding();
|
||||||
IParameter z1_parm = (IParameter)z1.resolveBinding();
|
IParameter z1_parm = (IParameter) z1.resolveBinding();
|
||||||
IParameter z2_parm = (IParameter)z2.resolveBinding();
|
IParameter z2_parm = (IParameter) z2.resolveBinding();
|
||||||
|
|
||||||
assertEquals(x1_parm, x2_parm);
|
assertEquals(x1_parm, x2_parm);
|
||||||
assertEquals(x2_parm, x3_parm);
|
assertEquals(x2_parm, x3_parm);
|
||||||
|
@ -347,267 +347,265 @@ public class AST2KnRTests extends AST2BaseTest {
|
||||||
assertEquals(z1_parm, z2_parm);
|
assertEquals(z1_parm, z2_parm);
|
||||||
|
|
||||||
// test tu.getDeclarationsInAST(IBinding)
|
// test tu.getDeclarationsInAST(IBinding)
|
||||||
IASTName[] decls = tu.getDeclarationsInAST(((IASTIdExpression)((IASTBinaryExpression)((IASTReturnStatement)((IASTCompoundStatement)f.getBody()).getStatements()[0]).getReturnValue()).getOperand1()).getName().resolveBinding());
|
IASTName[] decls = tu.getDeclarationsInAST(((IASTIdExpression) ((IASTBinaryExpression) ((IASTReturnStatement) ((IASTCompoundStatement) f.getBody()).getStatements()[0]).getReturnValue()).getOperand1()).getName().resolveBinding());
|
||||||
assertEquals( decls.length, 1 );
|
assertEquals(decls.length, 1);
|
||||||
assertEquals( decls[0], x2 );
|
assertEquals(decls[0], x2);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public void testKRCProblem5() throws Exception {
|
public void testKRCProblem5() throws Exception {
|
||||||
StringBuffer buffer = new StringBuffer();
|
StringBuilder buffer = new StringBuilder();
|
||||||
buffer.append( "int f(x) char x,a;\n" ); //$NON-NLS-1$
|
buffer.append("int f(x) char x,a;\n"); //$NON-NLS-1$
|
||||||
buffer.append( "{ return x == 0; }\n" ); //$NON-NLS-1$
|
buffer.append("{ return x == 0; }\n"); //$NON-NLS-1$
|
||||||
IASTTranslationUnit tu = parse( buffer.toString(), ParserLanguage.C, true, false );
|
IASTTranslationUnit tu = parse(buffer.toString(), ParserLanguage.C, true, false);
|
||||||
|
|
||||||
IASTFunctionDefinition f = (IASTFunctionDefinition)tu.getDeclarations()[0];
|
IASTFunctionDefinition f = (IASTFunctionDefinition) tu.getDeclarations()[0];
|
||||||
assertTrue(f.getDeclarator() instanceof ICASTKnRFunctionDeclarator);
|
assertTrue(f.getDeclarator() instanceof ICASTKnRFunctionDeclarator);
|
||||||
ICASTKnRFunctionDeclarator f_kr = (ICASTKnRFunctionDeclarator)f.getDeclarator();
|
ICASTKnRFunctionDeclarator f_kr = (ICASTKnRFunctionDeclarator) f.getDeclarator();
|
||||||
assertEquals(f_kr.getName().toString(), "f"); //$NON-NLS-1$
|
assertEquals(f_kr.getName().toString(), "f"); //$NON-NLS-1$
|
||||||
assertEquals(f_kr.getParameterNames()[0].toString(), "x"); //$NON-NLS-1$
|
assertEquals(f_kr.getParameterNames()[0].toString(), "x"); //$NON-NLS-1$
|
||||||
assertTrue(f_kr.getParameterDeclarations()[0] instanceof IASTProblemDeclaration);
|
assertTrue(f_kr.getParameterDeclarations()[0] instanceof IASTProblemDeclaration);
|
||||||
assertTrue(f.getBody() instanceof IASTCompoundStatement);
|
assertTrue(f.getBody() instanceof IASTCompoundStatement);
|
||||||
assertTrue(((IASTCompoundStatement)f.getBody()).getStatements()[0] instanceof IASTReturnStatement);
|
assertTrue(((IASTCompoundStatement) f.getBody()).getStatements()[0] instanceof IASTReturnStatement);
|
||||||
assertTrue(((IASTReturnStatement)((IASTCompoundStatement)f.getBody()).getStatements()[0]).getReturnValue() instanceof IASTBinaryExpression);
|
assertTrue(((IASTReturnStatement) ((IASTCompoundStatement) f.getBody()).getStatements()[0]).getReturnValue() instanceof IASTBinaryExpression);
|
||||||
assertTrue(((IASTBinaryExpression)((IASTReturnStatement)((IASTCompoundStatement)f.getBody()).getStatements()[0]).getReturnValue()).getOperand1() instanceof IASTIdExpression);
|
assertTrue(((IASTBinaryExpression) ((IASTReturnStatement) ((IASTCompoundStatement) f.getBody()).getStatements()[0]).getReturnValue()).getOperand1() instanceof IASTIdExpression);
|
||||||
assertEquals(((IASTIdExpression)((IASTBinaryExpression)((IASTReturnStatement)((IASTCompoundStatement)f.getBody()).getStatements()[0]).getReturnValue()).getOperand1()).getName().toString(), "x"); //$NON-NLS-1$
|
assertEquals(((IASTIdExpression) ((IASTBinaryExpression) ((IASTReturnStatement) ((IASTCompoundStatement) f.getBody()).getStatements()[0]).getReturnValue()).getOperand1()).getName().toString(), "x"); //$NON-NLS-1$
|
||||||
assertTrue(((IASTBinaryExpression)((IASTReturnStatement)((IASTCompoundStatement)f.getBody()).getStatements()[0]).getReturnValue()).getOperand2() instanceof IASTLiteralExpression);
|
assertTrue(((IASTBinaryExpression) ((IASTReturnStatement) ((IASTCompoundStatement) f.getBody()).getStatements()[0]).getReturnValue()).getOperand2() instanceof IASTLiteralExpression);
|
||||||
assertEquals(((IASTLiteralExpression)((IASTBinaryExpression)((IASTReturnStatement)((IASTCompoundStatement)f.getBody()).getStatements()[0]).getReturnValue()).getOperand2()).toString(), "0"); //$NON-NLS-1$
|
assertEquals(((IASTLiteralExpression) ((IASTBinaryExpression) ((IASTReturnStatement) ((IASTCompoundStatement) f.getBody()).getStatements()[0]).getReturnValue()).getOperand2()).toString(), "0"); //$NON-NLS-1$
|
||||||
|
|
||||||
// test tu.getDeclarationsInAST(IBinding)
|
// test tu.getDeclarationsInAST(IBinding)
|
||||||
IASTName[] decls = tu.getDeclarationsInAST(((IASTIdExpression)((IASTBinaryExpression)((IASTReturnStatement)((IASTCompoundStatement)f.getBody()).getStatements()[0]).getReturnValue()).getOperand1()).getName().resolveBinding());
|
IASTName[] decls = tu.getDeclarationsInAST(((IASTIdExpression) ((IASTBinaryExpression) ((IASTReturnStatement) ((IASTCompoundStatement) f.getBody()).getStatements()[0]).getReturnValue()).getOperand1()).getName().resolveBinding());
|
||||||
assertEquals( decls.length, 0 );
|
assertEquals(decls.length, 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
public void testKRC_monop_cards1() throws Exception {
|
public void testKRC_monop_cards1() throws Exception {
|
||||||
StringBuffer buffer = new StringBuffer();
|
StringBuilder buffer = new StringBuilder();
|
||||||
buffer.append( "#ifdef __STDC__\n" ); //$NON-NLS-1$
|
buffer.append("#ifdef __STDC__\n"); //$NON-NLS-1$
|
||||||
buffer.append( "#define __P(x) x\n" ); //$NON-NLS-1$
|
buffer.append("#define __P(x) x\n"); //$NON-NLS-1$
|
||||||
buffer.append( "#else\n" ); //$NON-NLS-1$
|
buffer.append("#else\n"); //$NON-NLS-1$
|
||||||
buffer.append( "#define __P(x) ()\n" ); //$NON-NLS-1$
|
buffer.append("#define __P(x) ()\n"); //$NON-NLS-1$
|
||||||
buffer.append( "#endif\n" ); //$NON-NLS-1$
|
buffer.append("#endif\n"); //$NON-NLS-1$
|
||||||
buffer.append( "struct A_struct {\n" ); //$NON-NLS-1$
|
buffer.append("struct A_struct {\n"); //$NON-NLS-1$
|
||||||
buffer.append( "int a;\n" ); //$NON-NLS-1$
|
buffer.append("int a;\n"); //$NON-NLS-1$
|
||||||
buffer.append( "long *c;\n" ); //$NON-NLS-1$
|
buffer.append("long *c;\n"); //$NON-NLS-1$
|
||||||
buffer.append( "};\n" ); //$NON-NLS-1$
|
buffer.append("};\n"); //$NON-NLS-1$
|
||||||
buffer.append( "typedef struct A_struct A;\n" ); //$NON-NLS-1$
|
buffer.append("typedef struct A_struct A;\n"); //$NON-NLS-1$
|
||||||
buffer.append( "static void f __P((A *));\n" ); //$NON-NLS-1$
|
buffer.append("static void f __P((A *));\n"); //$NON-NLS-1$
|
||||||
buffer.append( "static void\n" ); //$NON-NLS-1$
|
buffer.append("static void\n"); //$NON-NLS-1$
|
||||||
buffer.append( "f(x)\n" ); //$NON-NLS-1$
|
buffer.append("f(x)\n"); //$NON-NLS-1$
|
||||||
buffer.append( "A *x; {\n" ); //$NON-NLS-1$
|
buffer.append("A *x; {\n"); //$NON-NLS-1$
|
||||||
buffer.append( "x->a = 0;\n" ); //$NON-NLS-1$
|
buffer.append("x->a = 0;\n"); //$NON-NLS-1$
|
||||||
buffer.append( "x->c[1]=x->c[2];\n" ); //$NON-NLS-1$
|
buffer.append("x->c[1]=x->c[2];\n"); //$NON-NLS-1$
|
||||||
buffer.append( "}\n" ); //$NON-NLS-1$
|
buffer.append("}\n"); //$NON-NLS-1$
|
||||||
IASTTranslationUnit tu = parse( buffer.toString(), ParserLanguage.C, true );
|
IASTTranslationUnit tu = parse(buffer.toString(), ParserLanguage.C, true);
|
||||||
|
|
||||||
IASTSimpleDeclaration A_struct = (IASTSimpleDeclaration)tu.getDeclarations()[0];
|
IASTSimpleDeclaration A_struct = (IASTSimpleDeclaration) tu.getDeclarations()[0];
|
||||||
IASTSimpleDeclaration A = (IASTSimpleDeclaration)tu.getDeclarations()[1];
|
IASTSimpleDeclaration A = (IASTSimpleDeclaration) tu.getDeclarations()[1];
|
||||||
IASTSimpleDeclaration f_decl = (IASTSimpleDeclaration)tu.getDeclarations()[2];
|
IASTSimpleDeclaration f_decl = (IASTSimpleDeclaration) tu.getDeclarations()[2];
|
||||||
IASTFunctionDefinition f_def = (IASTFunctionDefinition)tu.getDeclarations()[3];
|
IASTFunctionDefinition f_def = (IASTFunctionDefinition) tu.getDeclarations()[3];
|
||||||
|
|
||||||
// check A_struct
|
// check A_struct
|
||||||
assertTrue( A_struct.getDeclSpecifier() instanceof IASTCompositeTypeSpecifier );
|
assertTrue(A_struct.getDeclSpecifier() instanceof IASTCompositeTypeSpecifier);
|
||||||
assertEquals( A_struct.getDeclarators().length, 0 );
|
assertEquals(A_struct.getDeclarators().length, 0);
|
||||||
IASTName A_struct_name1 = ((IASTCompositeTypeSpecifier)A_struct.getDeclSpecifier()).getName();
|
IASTName A_struct_name1 = ((IASTCompositeTypeSpecifier)A_struct.getDeclSpecifier()).getName();
|
||||||
assertEquals( A_struct_name1.toString(), "A_struct" ); //$NON-NLS-1$
|
assertEquals(A_struct_name1.toString(), "A_struct"); //$NON-NLS-1$
|
||||||
ICompositeType A_struct_type1 = (ICompositeType)A_struct_name1.resolveBinding();
|
ICompositeType A_struct_type1 = (ICompositeType)A_struct_name1.resolveBinding();
|
||||||
assertEquals( ((ICInternalBinding)A_struct_type1).getPhysicalNode(), ((IASTCompositeTypeSpecifier)A_struct.getDeclSpecifier()).getName() );
|
assertEquals(((ICInternalBinding)A_struct_type1).getPhysicalNode(), ((IASTCompositeTypeSpecifier)A_struct.getDeclSpecifier()).getName());
|
||||||
IField[] fields = A_struct_type1.getFields();
|
IField[] fields = A_struct_type1.getFields();
|
||||||
IField a1 = fields[0];
|
IField a1 = fields[0];
|
||||||
IField c1 = fields[1];
|
IField c1 = fields[1];
|
||||||
assertEquals( a1.getName().toString(), "a" ); //$NON-NLS-1$
|
assertEquals(a1.getName().toString(), "a"); //$NON-NLS-1$
|
||||||
assertEquals( c1.getName().toString(), "c" ); //$NON-NLS-1$
|
assertEquals(c1.getName().toString(), "c"); //$NON-NLS-1$
|
||||||
IBasicType a1_t = (IBasicType)a1.getType();
|
IBasicType a1_t = (IBasicType) a1.getType();
|
||||||
IPointerType c1_t = (IPointerType)c1.getType();
|
IPointerType c1_t = (IPointerType) c1.getType();
|
||||||
assertEquals( a1_t.getType(), IBasicType.t_int );
|
assertEquals(a1_t.getType(), IBasicType.t_int);
|
||||||
assertTrue( c1_t.getType() instanceof IBasicType );
|
assertTrue(c1_t.getType() instanceof IBasicType);
|
||||||
assertTrue( ((IBasicType)c1_t.getType()).isLong() );
|
assertTrue(((IBasicType) c1_t.getType()).isLong());
|
||||||
|
|
||||||
// check A
|
// check A
|
||||||
IASTName A_name1 = A.getDeclarators()[0].getName();
|
IASTName A_name1 = A.getDeclarators()[0].getName();
|
||||||
assertEquals( A_name1.toString(), "A" ); //$NON-NLS-1$
|
assertEquals(A_name1.toString(), "A"); //$NON-NLS-1$
|
||||||
ITypedef A_var1 = (ITypedef)A_name1.resolveBinding();
|
ITypedef A_var1 = (ITypedef)A_name1.resolveBinding();
|
||||||
assertTrue( A.getDeclSpecifier() instanceof IASTElaboratedTypeSpecifier );
|
assertTrue(A.getDeclSpecifier() instanceof IASTElaboratedTypeSpecifier);
|
||||||
IASTName A_struct_name_2 = ((IASTElaboratedTypeSpecifier)A.getDeclSpecifier()).getName();
|
IASTName A_struct_name_2 = ((IASTElaboratedTypeSpecifier)A.getDeclSpecifier()).getName();
|
||||||
assertEquals( A_struct_name_2.toString(), "A_struct" ); //$NON-NLS-1$
|
assertEquals(A_struct_name_2.toString(), "A_struct"); //$NON-NLS-1$
|
||||||
assertEquals( ((IASTElaboratedTypeSpecifier)A.getDeclSpecifier()).getStorageClass(), IASTDeclSpecifier.sc_typedef );
|
assertEquals(((IASTElaboratedTypeSpecifier)A.getDeclSpecifier()).getStorageClass(), IASTDeclSpecifier.sc_typedef);
|
||||||
ICompositeType A_struct_type2 = (ICompositeType)A_struct_name_2.resolveBinding();
|
ICompositeType A_struct_type2 = (ICompositeType)A_struct_name_2.resolveBinding();
|
||||||
assertEquals( A_struct_type2, A_struct_type1 );
|
assertEquals(A_struct_type2, A_struct_type1);
|
||||||
|
|
||||||
// check f_decl
|
// check f_decl
|
||||||
assertTrue( f_decl.getDeclarators()[0] instanceof IASTStandardFunctionDeclarator );
|
assertTrue(f_decl.getDeclarators()[0] instanceof IASTStandardFunctionDeclarator);
|
||||||
IASTStandardFunctionDeclarator f_decltor1 = ((IASTStandardFunctionDeclarator)f_decl.getDeclarators()[0]);
|
IASTStandardFunctionDeclarator f_decltor1 = ((IASTStandardFunctionDeclarator) f_decl.getDeclarators()[0]);
|
||||||
IASTName f_name1 = f_decltor1.getName();
|
IASTName f_name1 = f_decltor1.getName();
|
||||||
IFunction f_fun1 = (IFunction)f_name1.resolveBinding();
|
IFunction f_fun1 = (IFunction) f_name1.resolveBinding();
|
||||||
assertEquals( f_name1.toString(), "f" ); //$NON-NLS-1$
|
assertEquals(f_name1.toString(), "f"); //$NON-NLS-1$
|
||||||
assertEquals( f_decltor1.getParameters().length, 1 );
|
assertEquals(f_decltor1.getParameters().length, 1);
|
||||||
//IASTName x0 = f_decltor1.getParameters()[0].getDeclarator().getName();
|
//IASTName x0 = f_decltor1.getParameters()[0].getDeclarator().getName();
|
||||||
IASTName A_name2 = ((ICASTTypedefNameSpecifier)f_decltor1.getParameters()[0].getDeclSpecifier()).getName();
|
IASTName A_name2 = ((ICASTTypedefNameSpecifier) f_decltor1.getParameters()[0].getDeclSpecifier()).getName();
|
||||||
assertEquals( A_name2.toString(), "A" ); //$NON-NLS-1$
|
assertEquals(A_name2.toString(), "A"); //$NON-NLS-1$
|
||||||
ITypedef A_var2 = (ITypedef)A_name2.resolveBinding();
|
ITypedef A_var2 = (ITypedef)A_name2.resolveBinding();
|
||||||
assertEquals( A_var1, A_var2 );
|
assertEquals(A_var1, A_var2);
|
||||||
|
|
||||||
// check f_def
|
// check f_def
|
||||||
assertTrue( f_def.getDeclarator() instanceof ICASTKnRFunctionDeclarator );
|
assertTrue(f_def.getDeclarator() instanceof ICASTKnRFunctionDeclarator);
|
||||||
|
|
||||||
ICASTKnRFunctionDeclarator f_decltor2 = (ICASTKnRFunctionDeclarator)f_def.getDeclarator();
|
ICASTKnRFunctionDeclarator f_decltor2 = (ICASTKnRFunctionDeclarator) f_def.getDeclarator();
|
||||||
assertEquals( f_decltor2.getName().toString(), "f" ); //$NON-NLS-1$
|
assertEquals(f_decltor2.getName().toString(), "f"); //$NON-NLS-1$
|
||||||
IFunction f_fun2 = (IFunction)f_decltor2.getName().resolveBinding();
|
IFunction f_fun2 = (IFunction) f_decltor2.getName().resolveBinding();
|
||||||
assertEquals( f_fun1, f_fun2 );
|
assertEquals(f_fun1, f_fun2);
|
||||||
ICBasicType f_ret_t = (ICBasicType)f_fun2.getType().getReturnType();
|
ICBasicType f_ret_t = (ICBasicType) f_fun2.getType().getReturnType();
|
||||||
assertEquals( f_ret_t.getType(), IBasicType.t_void );
|
assertEquals(f_ret_t.getType(), IBasicType.t_void);
|
||||||
IASTName x1 = f_decltor2.getParameterNames()[0];
|
IASTName x1 = f_decltor2.getParameterNames()[0];
|
||||||
assertEquals( x1.toString(), "x" ); //$NON-NLS-1$
|
assertEquals(x1.toString(), "x"); //$NON-NLS-1$
|
||||||
IASTSimpleDeclaration x_parm = (IASTSimpleDeclaration)f_decltor2.getParameterDeclarations()[0];
|
IASTSimpleDeclaration x_parm = (IASTSimpleDeclaration) f_decltor2.getParameterDeclarations()[0];
|
||||||
IASTName x2 = x_parm.getDeclarators()[0].getName();
|
IASTName x2 = x_parm.getDeclarators()[0].getName();
|
||||||
assertEquals( x2.toString(), "x" ); //$NON-NLS-1$
|
assertEquals(x2.toString(), "x"); //$NON-NLS-1$
|
||||||
assertEquals( x_parm.getDeclarators()[0].getPointerOperators().length, 1 );
|
assertEquals(x_parm.getDeclarators()[0].getPointerOperators().length, 1);
|
||||||
IASTName A3 = ((IASTNamedTypeSpecifier)x_parm.getDeclSpecifier()).getName();
|
IASTName A3 = ((IASTNamedTypeSpecifier) x_parm.getDeclSpecifier()).getName();
|
||||||
ITypedef A_var3 = (ITypedef)A3.resolveBinding();
|
ITypedef A_var3 = (ITypedef)A3.resolveBinding();
|
||||||
assertEquals( A_var2, A_var3 );
|
assertEquals(A_var2, A_var3);
|
||||||
assertEquals( A3.toString(), "A" ); //$NON-NLS-1$;
|
assertEquals(A3.toString(), "A"); //$NON-NLS-1$;
|
||||||
assertEquals( x1.resolveBinding(), x2.resolveBinding() );
|
assertEquals(x1.resolveBinding(), x2.resolveBinding());
|
||||||
|
|
||||||
// check f_def body
|
// check f_def body
|
||||||
assertTrue( f_def.getBody() instanceof IASTCompoundStatement );
|
assertTrue(f_def.getBody() instanceof IASTCompoundStatement);
|
||||||
IASTCompoundStatement f_def_body = (IASTCompoundStatement)f_def.getBody();
|
IASTCompoundStatement f_def_body = (IASTCompoundStatement) f_def.getBody();
|
||||||
IASTExpressionStatement stmt1 = (IASTExpressionStatement)f_def_body.getStatements()[0];
|
IASTExpressionStatement stmt1 = (IASTExpressionStatement) f_def_body.getStatements()[0];
|
||||||
IASTExpressionStatement stmt2 = (IASTExpressionStatement)f_def_body.getStatements()[1];
|
IASTExpressionStatement stmt2 = (IASTExpressionStatement) f_def_body.getStatements()[1];
|
||||||
IASTName a2 = ((IASTFieldReference)((IASTBinaryExpression)stmt1.getExpression()).getOperand1()).getFieldName();
|
IASTName a2 = ((IASTFieldReference) ((IASTBinaryExpression) stmt1.getExpression()).getOperand1()).getFieldName();
|
||||||
assertEquals( ((IASTName)((ICInternalBinding)a1).getPhysicalNode()).resolveBinding(), a2.resolveBinding() );
|
assertEquals(((IASTName) ((ICInternalBinding) a1).getPhysicalNode()).resolveBinding(), a2.resolveBinding());
|
||||||
IASTName x3 = ((IASTIdExpression)((IASTFieldReference)((IASTBinaryExpression)stmt1.getExpression()).getOperand1()).getFieldOwner()).getName();
|
IASTName x3 = ((IASTIdExpression) ((IASTFieldReference) ((IASTBinaryExpression) stmt1.getExpression()).getOperand1()).getFieldOwner()).getName();
|
||||||
assertEquals( x2.resolveBinding(), x3.resolveBinding() );
|
assertEquals(x2.resolveBinding(), x3.resolveBinding());
|
||||||
assertEquals( ((IASTBinaryExpression)stmt1.getExpression()).getOperand2().toString(), "0" ); //$NON-NLS-1$
|
assertEquals(((IASTBinaryExpression) stmt1.getExpression()).getOperand2().toString(), "0"); //$NON-NLS-1$
|
||||||
assertTrue( ((IASTBinaryExpression)stmt2.getExpression()).getOperand1() instanceof IASTArraySubscriptExpression );
|
assertTrue(((IASTBinaryExpression) stmt2.getExpression()).getOperand1() instanceof IASTArraySubscriptExpression);
|
||||||
assertTrue( ((IASTBinaryExpression)stmt2.getExpression()).getOperand2() instanceof IASTArraySubscriptExpression );
|
assertTrue(((IASTBinaryExpression) stmt2.getExpression()).getOperand2() instanceof IASTArraySubscriptExpression);
|
||||||
IASTName c2 = ((IASTFieldReference)((IASTArraySubscriptExpression)((IASTBinaryExpression)stmt2.getExpression()).getOperand1()).getArrayExpression()).getFieldName();
|
IASTName c2 = ((IASTFieldReference) ((IASTArraySubscriptExpression) ((IASTBinaryExpression) stmt2.getExpression()).getOperand1()).getArrayExpression()).getFieldName();
|
||||||
IASTName x4 = ((IASTIdExpression)((IASTFieldReference)((IASTArraySubscriptExpression)((IASTBinaryExpression)stmt2.getExpression()).getOperand1()).getArrayExpression()).getFieldOwner()).getName();
|
IASTName x4 = ((IASTIdExpression) ((IASTFieldReference) ((IASTArraySubscriptExpression) ((IASTBinaryExpression) stmt2.getExpression()).getOperand1()).getArrayExpression()).getFieldOwner()).getName();
|
||||||
IASTName c3 = ((IASTFieldReference)((IASTArraySubscriptExpression)((IASTBinaryExpression)stmt2.getExpression()).getOperand2()).getArrayExpression()).getFieldName();
|
IASTName c3 = ((IASTFieldReference) ((IASTArraySubscriptExpression) ((IASTBinaryExpression) stmt2.getExpression()).getOperand2()).getArrayExpression()).getFieldName();
|
||||||
IASTName x5 = ((IASTIdExpression)((IASTFieldReference)((IASTArraySubscriptExpression)((IASTBinaryExpression)stmt2.getExpression()).getOperand1()).getArrayExpression()).getFieldOwner()).getName();
|
IASTName x5 = ((IASTIdExpression) ((IASTFieldReference) ((IASTArraySubscriptExpression) ((IASTBinaryExpression) stmt2.getExpression()).getOperand1()).getArrayExpression()).getFieldOwner()).getName();
|
||||||
assertEquals( ((IASTName)((ICInternalBinding)c1).getPhysicalNode()).resolveBinding(), c2.resolveBinding() );
|
assertEquals(((IASTName) ((ICInternalBinding) c1).getPhysicalNode()).resolveBinding(), c2.resolveBinding());
|
||||||
assertEquals( ((IASTName)((ICInternalBinding)c1).getPhysicalNode()).resolveBinding(), c3.resolveBinding() );
|
assertEquals(((IASTName) ((ICInternalBinding) c1).getPhysicalNode()).resolveBinding(), c3.resolveBinding());
|
||||||
assertEquals( x3.resolveBinding(), x4.resolveBinding() );
|
assertEquals(x3.resolveBinding(), x4.resolveBinding());
|
||||||
assertEquals( x4.resolveBinding(), x5.resolveBinding() );
|
assertEquals(x4.resolveBinding(), x5.resolveBinding());
|
||||||
|
|
||||||
// test CFunction.getParameters size
|
// test CFunction.getParameters size
|
||||||
IParameter[] f1_parms = f_fun1.getParameters();
|
IParameter[] f1_parms = f_fun1.getParameters();
|
||||||
assertEquals( f1_parms.length, 1 );
|
assertEquals(f1_parms.length, 1);
|
||||||
|
|
||||||
// test tu.getDeclarationsInAST(IBinding)
|
// test tu.getDeclarationsInAST(IBinding)
|
||||||
IASTName[] decls = tu.getDeclarationsInAST(x2.resolveBinding());
|
IASTName[] decls = tu.getDeclarationsInAST(x2.resolveBinding());
|
||||||
assertEquals( decls.length, 1 );
|
assertEquals(decls.length, 1);
|
||||||
assertEquals( decls[0], x2 );
|
assertEquals(decls[0], x2);
|
||||||
|
|
||||||
assertNotNull( ((CScope)tu.getScope()).getBinding(CScope.NAMESPACE_TYPE_TAG, new String("A_struct").toCharArray()) ); //$NON-NLS-1$
|
assertNotNull(((CScope) tu.getScope()).getBinding(CScope.NAMESPACE_TYPE_TAG, new String("A_struct").toCharArray())); //$NON-NLS-1$
|
||||||
assertNotNull( ((CScope)tu.getScope()).getBinding(CScope.NAMESPACE_TYPE_OTHER, new String("A").toCharArray()) ); //$NON-NLS-1$
|
assertNotNull(((CScope) tu.getScope()).getBinding(CScope.NAMESPACE_TYPE_OTHER, new String("A").toCharArray())); //$NON-NLS-1$
|
||||||
assertNotNull( ((CScope)tu.getScope()).getBinding(CScope.NAMESPACE_TYPE_OTHER, new String("f").toCharArray()) ); //$NON-NLS-1$
|
assertNotNull(((CScope) tu.getScope()).getBinding(CScope.NAMESPACE_TYPE_OTHER, new String("f").toCharArray())); //$NON-NLS-1$
|
||||||
assertNotNull( ((CScope)((IASTCompoundStatement)f_def.getBody()).getScope()).getBinding(CScope.NAMESPACE_TYPE_OTHER, new String("x").toCharArray()) ); //$NON-NLS-1$
|
assertNotNull(((CScope) ((IASTCompoundStatement) f_def.getBody()).getScope()).getBinding(CScope.NAMESPACE_TYPE_OTHER, new String("x").toCharArray())); //$NON-NLS-1$
|
||||||
}
|
}
|
||||||
|
|
||||||
public void testKRC_monop_cards2() throws Exception {
|
public void testKRC_monop_cards2() throws Exception {
|
||||||
StringBuffer buffer = new StringBuffer();
|
StringBuilder buffer = new StringBuilder();
|
||||||
buffer.append( "int\n" ); //$NON-NLS-1$
|
buffer.append("int\n"); //$NON-NLS-1$
|
||||||
buffer.append( "getinp(prompt, list)\n" ); //$NON-NLS-1$
|
buffer.append("getinp(prompt, list)\n"); //$NON-NLS-1$
|
||||||
buffer.append( " const char *prompt, *const list[];\n" ); //$NON-NLS-1$
|
buffer.append(" const char *prompt, *const list[];\n"); //$NON-NLS-1$
|
||||||
buffer.append( "{\n *list[1] = 'a';\n}\n" ); //$NON-NLS-1$
|
buffer.append("{\n *list[1] = 'a';\n}\n"); //$NON-NLS-1$
|
||||||
IASTTranslationUnit tu = parse( buffer.toString(), ParserLanguage.C, true );
|
IASTTranslationUnit tu = parse(buffer.toString(), ParserLanguage.C, true);
|
||||||
|
|
||||||
IASTFunctionDefinition getinp = (IASTFunctionDefinition)tu.getDeclarations()[0];
|
IASTFunctionDefinition getinp = (IASTFunctionDefinition) tu.getDeclarations()[0];
|
||||||
|
|
||||||
IASTName prompt1 = ((ICASTKnRFunctionDeclarator)getinp.getDeclarator()).getParameterNames()[0];
|
IASTName prompt1 = ((ICASTKnRFunctionDeclarator) getinp.getDeclarator()).getParameterNames()[0];
|
||||||
IASTName list1 = ((ICASTKnRFunctionDeclarator)getinp.getDeclarator()).getParameterNames()[1];
|
IASTName list1 = ((ICASTKnRFunctionDeclarator) getinp.getDeclarator()).getParameterNames()[1];
|
||||||
IASTName prompt2 = ((IASTSimpleDeclaration)((ICASTKnRFunctionDeclarator)getinp.getDeclarator()).getParameterDeclarations()[0]).getDeclarators()[0].getName();
|
IASTName prompt2 = ((IASTSimpleDeclaration) ((ICASTKnRFunctionDeclarator) getinp.getDeclarator()).getParameterDeclarations()[0]).getDeclarators()[0].getName();
|
||||||
IASTName list2 = ((IASTSimpleDeclaration)((ICASTKnRFunctionDeclarator)getinp.getDeclarator()).getParameterDeclarations()[0]).getDeclarators()[1].getName();
|
IASTName list2 = ((IASTSimpleDeclaration) ((ICASTKnRFunctionDeclarator) getinp.getDeclarator()).getParameterDeclarations()[0]).getDeclarators()[1].getName();
|
||||||
IASTName list3 = ((IASTIdExpression)((IASTArraySubscriptExpression)((IASTUnaryExpression)((IASTBinaryExpression)((IASTExpressionStatement)((IASTCompoundStatement)getinp.getBody()).getStatements()[0]).getExpression()).getOperand1()).getOperand()).getArrayExpression()).getName();
|
IASTName list3 = ((IASTIdExpression) ((IASTArraySubscriptExpression) ((IASTUnaryExpression) ((IASTBinaryExpression) ((IASTExpressionStatement) ((IASTCompoundStatement) getinp.getBody()).getStatements()[0]).getExpression()).getOperand1()).getOperand()).getArrayExpression()).getName();
|
||||||
|
|
||||||
assertEquals( prompt1.resolveBinding(), prompt2.resolveBinding() );
|
assertEquals(prompt1.resolveBinding(), prompt2.resolveBinding());
|
||||||
assertEquals( list1.resolveBinding(), list2.resolveBinding() );
|
assertEquals(list1.resolveBinding(), list2.resolveBinding());
|
||||||
assertEquals( list2.resolveBinding(), list3.resolveBinding() );
|
assertEquals(list2.resolveBinding(), list3.resolveBinding());
|
||||||
|
|
||||||
IASTSimpleDeclaration parm_decl = (IASTSimpleDeclaration)((ICASTKnRFunctionDeclarator)getinp.getDeclarator()).getParameterDeclarations()[0];
|
IASTSimpleDeclaration parm_decl = (IASTSimpleDeclaration) ((ICASTKnRFunctionDeclarator) getinp.getDeclarator()).getParameterDeclarations()[0];
|
||||||
assertTrue( ((IASTSimpleDeclSpecifier)parm_decl.getDeclSpecifier()).isConst() );
|
assertTrue(((IASTSimpleDeclSpecifier) parm_decl.getDeclSpecifier()).isConst());
|
||||||
assertEquals( ((IASTSimpleDeclSpecifier)parm_decl.getDeclSpecifier()).getType(), IASTSimpleDeclSpecifier.t_char );
|
assertEquals(((IASTSimpleDeclSpecifier) parm_decl.getDeclSpecifier()).getType(), IASTSimpleDeclSpecifier.t_char);
|
||||||
IASTDeclarator prompt = parm_decl.getDeclarators()[0];
|
IASTDeclarator prompt = parm_decl.getDeclarators()[0];
|
||||||
IASTArrayDeclarator list = (IASTArrayDeclarator)parm_decl.getDeclarators()[1];
|
IASTArrayDeclarator list = (IASTArrayDeclarator) parm_decl.getDeclarators()[1];
|
||||||
assertEquals( prompt.getName().toString(), "prompt" ); //$NON-NLS-1$
|
assertEquals(prompt.getName().toString(), "prompt"); //$NON-NLS-1$
|
||||||
assertEquals( prompt.getPointerOperators().length, 1 );
|
assertEquals(prompt.getPointerOperators().length, 1);
|
||||||
assertEquals( list.getName().toString(), "list" ); //$NON-NLS-1$
|
assertEquals(list.getName().toString(), "list"); //$NON-NLS-1$
|
||||||
assertEquals( list.getArrayModifiers().length, 1 );
|
assertEquals(list.getArrayModifiers().length, 1);
|
||||||
assertNull( list.getArrayModifiers()[0].getConstantExpression() );
|
assertNull(list.getArrayModifiers()[0].getConstantExpression());
|
||||||
assertEquals( list.getPointerOperators().length, 1 );
|
assertEquals(list.getPointerOperators().length, 1);
|
||||||
|
|
||||||
// test tu.getDeclarationsInAST(IBinding)
|
// test tu.getDeclarationsInAST(IBinding)
|
||||||
IASTName[] decls = tu.getDeclarationsInAST(list3.resolveBinding());
|
IASTName[] decls = tu.getDeclarationsInAST(list3.resolveBinding());
|
||||||
assertEquals( decls.length, 1 );
|
assertEquals(decls.length, 1);
|
||||||
assertEquals( decls[0], list2 );
|
assertEquals(decls[0], list2);
|
||||||
|
|
||||||
decls = tu.getDeclarationsInAST(prompt1.resolveBinding());
|
decls = tu.getDeclarationsInAST(prompt1.resolveBinding());
|
||||||
assertEquals( decls.length, 1 );
|
assertEquals(decls.length, 1);
|
||||||
assertEquals( decls[0], prompt2 );
|
assertEquals(decls[0], prompt2);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void testKRC_getParametersOrder() throws Exception {
|
public void testKRC_getParametersOrder() throws Exception {
|
||||||
StringBuffer buffer = new StringBuffer();
|
StringBuilder buffer = new StringBuilder();
|
||||||
buffer.append( "int f(a, b) int b,a;{}\n" ); //$NON-NLS-1$
|
buffer.append("int f(a, b) int b,a;{}\n"); //$NON-NLS-1$
|
||||||
IASTTranslationUnit tu = parse( buffer.toString(), ParserLanguage.C, true );
|
IASTTranslationUnit tu = parse(buffer.toString(), ParserLanguage.C, true);
|
||||||
|
|
||||||
IASTFunctionDefinition f = (IASTFunctionDefinition)tu.getDeclarations()[0];
|
|
||||||
ICASTKnRFunctionDeclarator f_decltor = (ICASTKnRFunctionDeclarator)f.getDeclarator();
|
|
||||||
IFunction f_fun = (IFunction)f_decltor.getName().resolveBinding();
|
|
||||||
IParameter [] f_parms = f_fun.getParameters();
|
|
||||||
assertEquals( f_parms.length, 2 );
|
|
||||||
assertEquals( ((CParameter)f_parms[0]).getName(), "a" ); //$NON-NLS-1$
|
|
||||||
assertEquals( ((CParameter)f_parms[1]).getName(), "b" ); //$NON-NLS-1$
|
|
||||||
|
|
||||||
|
IASTFunctionDefinition f = (IASTFunctionDefinition) tu.getDeclarations()[0];
|
||||||
|
ICASTKnRFunctionDeclarator f_decltor = (ICASTKnRFunctionDeclarator) f.getDeclarator();
|
||||||
|
IFunction f_fun = (IFunction) f_decltor.getName().resolveBinding();
|
||||||
|
IParameter[] f_parms = f_fun.getParameters();
|
||||||
|
assertEquals(f_parms.length, 2);
|
||||||
|
assertEquals(((CParameter) f_parms[0]).getName(), "a"); //$NON-NLS-1$
|
||||||
|
assertEquals(((CParameter) f_parms[1]).getName(), "b"); //$NON-NLS-1$
|
||||||
}
|
}
|
||||||
|
|
||||||
public void testKRC_Ethereal_1() throws Exception {
|
public void testKRC_Ethereal_1() throws Exception {
|
||||||
StringBuffer buffer = new StringBuffer();
|
StringBuilder buffer = new StringBuilder();
|
||||||
buffer.append( "struct symbol {\n" ); //$NON-NLS-1$
|
buffer.append("struct symbol {\n"); //$NON-NLS-1$
|
||||||
buffer.append( "int lambda;\n};\n" ); //$NON-NLS-1$
|
buffer.append("int lambda;\n};\n"); //$NON-NLS-1$
|
||||||
buffer.append( "struct lemon {\n" ); //$NON-NLS-1$
|
buffer.append("struct lemon {\n"); //$NON-NLS-1$
|
||||||
buffer.append( "struct symbol **symbols;\n" ); //$NON-NLS-1$
|
buffer.append("struct symbol **symbols;\n"); //$NON-NLS-1$
|
||||||
buffer.append( "int errorcnt;\n};\n" ); //$NON-NLS-1$
|
buffer.append("int errorcnt;\n};\n"); //$NON-NLS-1$
|
||||||
buffer.append( "void f(lemp)\n" ); //$NON-NLS-1$
|
buffer.append("void f(lemp)\n"); //$NON-NLS-1$
|
||||||
buffer.append( "struct lemon *lemp;\n{\n" ); //$NON-NLS-1$
|
buffer.append("struct lemon *lemp;\n{\n"); //$NON-NLS-1$
|
||||||
buffer.append( "lemp->symbols[1]->lambda = 1;\n" ); //$NON-NLS-1$
|
buffer.append("lemp->symbols[1]->lambda = 1;\n"); //$NON-NLS-1$
|
||||||
buffer.append( "lemp->errorcnt++;}\n" ); //$NON-NLS-1$
|
buffer.append("lemp->errorcnt++;}\n"); //$NON-NLS-1$
|
||||||
IASTTranslationUnit tu = parse( buffer.toString(), ParserLanguage.C, true );
|
IASTTranslationUnit tu = parse(buffer.toString(), ParserLanguage.C, true);
|
||||||
|
|
||||||
IASTSimpleDeclaration symbol_decl = (IASTSimpleDeclaration)tu.getDeclarations()[0];
|
IASTSimpleDeclaration symbol_decl = (IASTSimpleDeclaration) tu.getDeclarations()[0];
|
||||||
IASTSimpleDeclaration lemon_decl = (IASTSimpleDeclaration)tu.getDeclarations()[1];
|
IASTSimpleDeclaration lemon_decl = (IASTSimpleDeclaration) tu.getDeclarations()[1];
|
||||||
IASTFunctionDefinition f_def = (IASTFunctionDefinition)tu.getDeclarations()[2];
|
IASTFunctionDefinition f_def = (IASTFunctionDefinition) tu.getDeclarations()[2];
|
||||||
|
|
||||||
IASTName symbol_name1 = ((IASTCompositeTypeSpecifier)symbol_decl.getDeclSpecifier()).getName();
|
IASTName symbol_name1 = ((IASTCompositeTypeSpecifier) symbol_decl.getDeclSpecifier()).getName();
|
||||||
IASTName lambda_name1 = ((IASTSimpleDeclaration)((IASTCompositeTypeSpecifier)symbol_decl.getDeclSpecifier()).getMembers()[0]).getDeclarators()[0].getName();
|
IASTName lambda_name1 = ((IASTSimpleDeclaration) ((IASTCompositeTypeSpecifier) symbol_decl.getDeclSpecifier()).getMembers()[0]).getDeclarators()[0].getName();
|
||||||
IASTName lemon_name1 = ((IASTCompositeTypeSpecifier)lemon_decl.getDeclSpecifier()).getName();
|
IASTName lemon_name1 = ((IASTCompositeTypeSpecifier) lemon_decl.getDeclSpecifier()).getName();
|
||||||
IASTName symbol_name2 = ((IASTElaboratedTypeSpecifier)((IASTSimpleDeclaration)((IASTCompositeTypeSpecifier)lemon_decl.getDeclSpecifier()).getMembers()[0]).getDeclSpecifier()).getName();
|
IASTName symbol_name2 = ((IASTElaboratedTypeSpecifier) ((IASTSimpleDeclaration) ((IASTCompositeTypeSpecifier) lemon_decl.getDeclSpecifier()).getMembers()[0]).getDeclSpecifier()).getName();
|
||||||
IASTName symbols_name1 = ((IASTSimpleDeclaration)((IASTCompositeTypeSpecifier)lemon_decl.getDeclSpecifier()).getMembers()[0]).getDeclarators()[0].getName();
|
IASTName symbols_name1 = ((IASTSimpleDeclaration) ((IASTCompositeTypeSpecifier) lemon_decl.getDeclSpecifier()).getMembers()[0]).getDeclarators()[0].getName();
|
||||||
IASTName errorcnt_name1 = ((IASTSimpleDeclaration)((IASTCompositeTypeSpecifier)lemon_decl.getDeclSpecifier()).getMembers()[1]).getDeclarators()[0].getName();
|
IASTName errorcnt_name1 = ((IASTSimpleDeclaration) ((IASTCompositeTypeSpecifier) lemon_decl.getDeclSpecifier()).getMembers()[1]).getDeclarators()[0].getName();
|
||||||
IASTName lemp_name1 = ((ICASTKnRFunctionDeclarator)f_def.getDeclarator()).getParameterNames()[0];
|
IASTName lemp_name1 = ((ICASTKnRFunctionDeclarator) f_def.getDeclarator()).getParameterNames()[0];
|
||||||
IASTName lemon_name2 = ((IASTElaboratedTypeSpecifier)((IASTSimpleDeclaration)((ICASTKnRFunctionDeclarator)f_def.getDeclarator()).getParameterDeclarations()[0]).getDeclSpecifier()).getName();
|
IASTName lemon_name2 = ((IASTElaboratedTypeSpecifier) ((IASTSimpleDeclaration) ((ICASTKnRFunctionDeclarator) f_def.getDeclarator()).getParameterDeclarations()[0]).getDeclSpecifier()).getName();
|
||||||
IASTName lemp_name2 = ((IASTSimpleDeclaration)((ICASTKnRFunctionDeclarator)f_def.getDeclarator()).getParameterDeclarations()[0]).getDeclarators()[0].getName();
|
IASTName lemp_name2 = ((IASTSimpleDeclaration) ((ICASTKnRFunctionDeclarator) f_def.getDeclarator()).getParameterDeclarations()[0]).getDeclarators()[0].getName();
|
||||||
IASTName lemp_name3 = ((IASTIdExpression)((IASTFieldReference)((IASTArraySubscriptExpression)((IASTFieldReference)((IASTBinaryExpression)((IASTExpressionStatement)((IASTCompoundStatement)f_def.getBody()).getStatements()[0]).getExpression()).getOperand1()).getFieldOwner()).getArrayExpression()).getFieldOwner()).getName();
|
IASTName lemp_name3 = ((IASTIdExpression) ((IASTFieldReference) ((IASTArraySubscriptExpression) ((IASTFieldReference) ((IASTBinaryExpression) ((IASTExpressionStatement) ((IASTCompoundStatement) f_def.getBody()).getStatements()[0]).getExpression()).getOperand1()).getFieldOwner()).getArrayExpression()).getFieldOwner()).getName();
|
||||||
IASTName symbols_name2 = ((IASTFieldReference)((IASTArraySubscriptExpression)((IASTFieldReference)((IASTBinaryExpression)((IASTExpressionStatement)((IASTCompoundStatement)f_def.getBody()).getStatements()[0]).getExpression()).getOperand1()).getFieldOwner()).getArrayExpression()).getFieldName();
|
IASTName symbols_name2 = ((IASTFieldReference) ((IASTArraySubscriptExpression) ((IASTFieldReference) ((IASTBinaryExpression) ((IASTExpressionStatement) ((IASTCompoundStatement) f_def.getBody()).getStatements()[0]).getExpression()).getOperand1()).getFieldOwner()).getArrayExpression()).getFieldName();
|
||||||
IASTName lambda_name2 = ((IASTFieldReference)((IASTBinaryExpression)((IASTExpressionStatement)((IASTCompoundStatement)f_def.getBody()).getStatements()[0]).getExpression()).getOperand1()).getFieldName();
|
IASTName lambda_name2 = ((IASTFieldReference) ((IASTBinaryExpression) ((IASTExpressionStatement) ((IASTCompoundStatement) f_def.getBody()).getStatements()[0]).getExpression()).getOperand1()).getFieldName();
|
||||||
|
|
||||||
IASTName lemp_name4 = ((IASTIdExpression)((IASTFieldReference)((IASTUnaryExpression)((IASTExpressionStatement)((IASTCompoundStatement)f_def.getBody()).getStatements()[1]).getExpression()).getOperand()).getFieldOwner()).getName();
|
IASTName lemp_name4 = ((IASTIdExpression) ((IASTFieldReference) ((IASTUnaryExpression) ((IASTExpressionStatement) ((IASTCompoundStatement) f_def.getBody()).getStatements()[1]).getExpression()).getOperand()).getFieldOwner()).getName();
|
||||||
IASTName errorcnt_name2 = ((IASTFieldReference)((IASTUnaryExpression)((IASTExpressionStatement)((IASTCompoundStatement)f_def.getBody()).getStatements()[1]).getExpression()).getOperand()).getFieldName();
|
IASTName errorcnt_name2 = ((IASTFieldReference) ((IASTUnaryExpression) ((IASTExpressionStatement) ((IASTCompoundStatement) f_def.getBody()).getStatements()[1]).getExpression()).getOperand()).getFieldName();
|
||||||
|
|
||||||
assertEquals( symbol_name1.resolveBinding(), symbol_name2.resolveBinding() );
|
assertEquals(symbol_name1.resolveBinding(), symbol_name2.resolveBinding());
|
||||||
assertEquals( lambda_name1.resolveBinding(), lambda_name2.resolveBinding() );
|
assertEquals(lambda_name1.resolveBinding(), lambda_name2.resolveBinding());
|
||||||
assertEquals( lemon_name1.resolveBinding(), lemon_name2.resolveBinding() );
|
assertEquals(lemon_name1.resolveBinding(), lemon_name2.resolveBinding());
|
||||||
assertEquals( symbols_name1.resolveBinding(), symbols_name2.resolveBinding() );
|
assertEquals(symbols_name1.resolveBinding(), symbols_name2.resolveBinding());
|
||||||
assertEquals( errorcnt_name1.resolveBinding(), errorcnt_name2.resolveBinding() );
|
assertEquals(errorcnt_name1.resolveBinding(), errorcnt_name2.resolveBinding());
|
||||||
assertEquals( lemp_name1.resolveBinding(), lemp_name2.resolveBinding() );
|
assertEquals(lemp_name1.resolveBinding(), lemp_name2.resolveBinding());
|
||||||
assertEquals( lemp_name2.resolveBinding(), lemp_name3.resolveBinding() );
|
assertEquals(lemp_name2.resolveBinding(), lemp_name3.resolveBinding());
|
||||||
assertEquals( lemp_name3.resolveBinding(), lemp_name4.resolveBinding() );
|
assertEquals(lemp_name3.resolveBinding(), lemp_name4.resolveBinding());
|
||||||
}
|
}
|
||||||
|
|
||||||
public void testBug97447() throws Exception {
|
public void testBug97447() throws Exception {
|
||||||
StringBuffer buffer = new StringBuffer();
|
StringBuilder buffer = new StringBuilder();
|
||||||
buffer.append("void f( a ) int a; {} \n"); //$NON-NLS-1$
|
buffer.append("void f(a) int a; {} \n"); //$NON-NLS-1$
|
||||||
buffer.append("void f( int ); \n"); //$NON-NLS-1$
|
buffer.append("void f(int); \n"); //$NON-NLS-1$
|
||||||
|
|
||||||
IASTTranslationUnit tu = parse(buffer.toString(), ParserLanguage.C, true);
|
IASTTranslationUnit tu = parse(buffer.toString(), ParserLanguage.C, true);
|
||||||
CNameCollector col = new CNameCollector();
|
CNameCollector col = new CNameCollector();
|
||||||
|
@ -619,38 +617,38 @@ public class AST2KnRTests extends AST2BaseTest {
|
||||||
}
|
}
|
||||||
|
|
||||||
public void testBug100104() throws Exception {
|
public void testBug100104() throws Exception {
|
||||||
StringBuffer buffer = new StringBuffer();
|
StringBuilder buffer = new StringBuilder();
|
||||||
buffer.append("typedef int ush;\n"); //$NON-NLS-1$
|
buffer.append("typedef int ush;\n"); //$NON-NLS-1$
|
||||||
buffer.append("int f()\n"); //$NON-NLS-1$
|
buffer.append("int f()\n"); //$NON-NLS-1$
|
||||||
buffer.append("{\n"); //$NON-NLS-1$
|
buffer.append("{\n"); //$NON-NLS-1$
|
||||||
buffer.append("int a=1;\n"); //$NON-NLS-1$
|
buffer.append("int a=1;\n"); //$NON-NLS-1$
|
||||||
buffer.append("((ush)(a)*(ush)(a) * a);\n"); //$NON-NLS-1$
|
buffer.append("((ush) (a)*(ush) (a) * a);\n"); //$NON-NLS-1$
|
||||||
buffer.append("{\n"); //$NON-NLS-1$
|
buffer.append("{\n"); //$NON-NLS-1$
|
||||||
buffer.append("};\n"); //$NON-NLS-1$
|
buffer.append("};\n"); //$NON-NLS-1$
|
||||||
buffer.append("}\n"); //$NON-NLS-1$
|
buffer.append("}\n"); //$NON-NLS-1$
|
||||||
|
|
||||||
IASTTranslationUnit tu = parse(buffer.toString(), ParserLanguage.C, true, true);
|
IASTTranslationUnit tu = parse(buffer.toString(), ParserLanguage.C, true, true);
|
||||||
assertTrue( tu.getDeclarations()[0] instanceof IASTSimpleDeclaration );
|
assertTrue(tu.getDeclarations()[0] instanceof IASTSimpleDeclaration);
|
||||||
assertTrue( tu.getDeclarations()[1] instanceof IASTFunctionDefinition );
|
assertTrue(tu.getDeclarations()[1] instanceof IASTFunctionDefinition);
|
||||||
IASTStatement[] stmts = ((IASTCompoundStatement)((IASTFunctionDefinition)tu.getDeclarations()[1]).getBody()).getStatements();
|
IASTStatement[] stmts = ((IASTCompoundStatement) ((IASTFunctionDefinition) tu.getDeclarations()[1]).getBody()).getStatements();
|
||||||
assertTrue( stmts[0] instanceof IASTDeclarationStatement );
|
assertTrue(stmts[0] instanceof IASTDeclarationStatement);
|
||||||
assertTrue( stmts[1] instanceof IASTExpressionStatement );
|
assertTrue(stmts[1] instanceof IASTExpressionStatement);
|
||||||
assertTrue( stmts[2] instanceof IASTCompoundStatement );
|
assertTrue(stmts[2] instanceof IASTCompoundStatement);
|
||||||
assertTrue( stmts[3] instanceof IASTNullStatement );
|
assertTrue(stmts[3] instanceof IASTNullStatement);
|
||||||
}
|
}
|
||||||
|
|
||||||
// see https://bugs.eclipse.org/bugs/show_bug.cgi?id=203050
|
// see https://bugs.eclipse.org/bugs/show_bug.cgi?id=203050
|
||||||
public void testBug203050() throws Exception {
|
public void testBug203050() throws Exception {
|
||||||
StringBuffer buffer = new StringBuffer();
|
StringBuilder buffer = new StringBuilder();
|
||||||
buffer.append("typedef long time_t;\n" + //$NON-NLS-1$
|
buffer.append("typedef long time_t;\n" + //$NON-NLS-1$
|
||||||
"\n" + //$NON-NLS-1$
|
"\n" + //$NON-NLS-1$
|
||||||
"void (foo)(timep)\n" + //$NON-NLS-1$
|
"void (foo) (timep)\n" + //$NON-NLS-1$
|
||||||
" const time_t * const timep;\n" + //$NON-NLS-1$
|
" const time_t * const timep;\n" + //$NON-NLS-1$
|
||||||
"{\n" + //$NON-NLS-1$
|
"{\n" + //$NON-NLS-1$
|
||||||
" struct tm tmp;\n" + //$NON-NLS-1$
|
" struct tm tmp;\n" + //$NON-NLS-1$
|
||||||
" bar(timep, &tmp);\n" + //$NON-NLS-1$
|
" bar(timep, &tmp);\n" + //$NON-NLS-1$
|
||||||
"}\n" + //$NON-NLS-1$
|
"}\n" + //$NON-NLS-1$
|
||||||
"int (bar)(timep, tmp)\n" + //$NON-NLS-1$
|
"int (bar) (timep, tmp)\n" + //$NON-NLS-1$
|
||||||
" const time_t * const timep;\n" + //$NON-NLS-1$
|
" const time_t * const timep;\n" + //$NON-NLS-1$
|
||||||
" struct tm * tmp;\n" + //$NON-NLS-1$
|
" struct tm * tmp;\n" + //$NON-NLS-1$
|
||||||
"{\n" + //$NON-NLS-1$
|
"{\n" + //$NON-NLS-1$
|
||||||
|
@ -658,23 +656,22 @@ public class AST2KnRTests extends AST2BaseTest {
|
||||||
"}\n"); //$NON-NLS-1$
|
"}\n"); //$NON-NLS-1$
|
||||||
|
|
||||||
IASTTranslationUnit tu = parse(buffer.toString(), ParserLanguage.C, true, true);
|
IASTTranslationUnit tu = parse(buffer.toString(), ParserLanguage.C, true, true);
|
||||||
assertTrue( tu.getDeclarations()[0] instanceof IASTSimpleDeclaration );
|
assertTrue(tu.getDeclarations()[0] instanceof IASTSimpleDeclaration);
|
||||||
assertTrue( tu.getDeclarations()[1] instanceof IASTFunctionDefinition );
|
assertTrue(tu.getDeclarations()[1] instanceof IASTFunctionDefinition);
|
||||||
assertTrue( tu.getDeclarations()[2] instanceof IASTFunctionDefinition );
|
assertTrue(tu.getDeclarations()[2] instanceof IASTFunctionDefinition);
|
||||||
IASTStatement[] stmts = ((IASTCompoundStatement)((IASTFunctionDefinition)tu.getDeclarations()[1]).getBody()).getStatements();
|
IASTStatement[] stmts = ((IASTCompoundStatement) ((IASTFunctionDefinition) tu.getDeclarations()[1]).getBody()).getStatements();
|
||||||
assertTrue( stmts[0] instanceof IASTDeclarationStatement );
|
assertTrue(stmts[0] instanceof IASTDeclarationStatement);
|
||||||
assertTrue( stmts[1] instanceof IASTExpressionStatement );
|
assertTrue(stmts[1] instanceof IASTExpressionStatement);
|
||||||
IASTExpression expr= ((IASTExpressionStatement)stmts[1]).getExpression();
|
IASTExpression expr= ((IASTExpressionStatement) stmts[1]).getExpression();
|
||||||
assertTrue(expr instanceof IASTFunctionCallExpression);
|
assertTrue(expr instanceof IASTFunctionCallExpression);
|
||||||
IASTIdExpression fnameExpr= (IASTIdExpression)((IASTFunctionCallExpression)expr).getFunctionNameExpression();
|
IASTIdExpression fnameExpr= (IASTIdExpression) ((IASTFunctionCallExpression) expr).getFunctionNameExpression();
|
||||||
fnameExpr.getName().resolveBinding();
|
fnameExpr.getName().resolveBinding();
|
||||||
|
|
||||||
IASTName fname= ((IASTFunctionDefinition)tu.getDeclarations()[2]).getDeclarator().getName();
|
IASTName fname= ((IASTFunctionDefinition) tu.getDeclarations()[2]).getDeclarator().getName();
|
||||||
try {
|
try {
|
||||||
fname.resolveBinding();
|
fname.resolveBinding();
|
||||||
} catch (StackOverflowError e) {
|
} catch (StackOverflowError e) {
|
||||||
fail(e.getMessage());
|
fail(e.getMessage());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
File diff suppressed because it is too large
Load diff
|
@ -1,12 +1,12 @@
|
||||||
/*******************************************************************************
|
/*******************************************************************************
|
||||||
* Copyright (c) 2008, 2011 Institute for Software, HSR Hochschule fuer Technik
|
* Copyright (c) 2008, 2011 Institute for Software, HSR Hochschule fuer Technik
|
||||||
* Rapperswil, University of applied sciences and others
|
* Rapperswil, University of applied sciences and others
|
||||||
* All rights reserved. This program and the accompanying materials
|
* All rights reserved. This program and the accompanying materials
|
||||||
* are made available under the terms of the Eclipse Public License v1.0
|
* are made available under the terms of the Eclipse Public License v1.0
|
||||||
* which accompanies this distribution, and is available at
|
* which accompanies this distribution, and is available at
|
||||||
* http://www.eclipse.org/legal/epl-v10.html
|
* http://www.eclipse.org/legal/epl-v10.html
|
||||||
*
|
*
|
||||||
* Contributors:
|
* Contributors:
|
||||||
* Institute for Software - initial API and implementation
|
* Institute for Software - initial API and implementation
|
||||||
*******************************************************************************/
|
*******************************************************************************/
|
||||||
package org.eclipse.cdt.core.parser.tests.rewrite.changegenerator;
|
package org.eclipse.cdt.core.parser.tests.rewrite.changegenerator;
|
||||||
|
@ -51,7 +51,7 @@ public abstract class ChangeGeneratorTest extends BaseTestFramework {
|
||||||
@Override
|
@Override
|
||||||
public void runTest() throws Exception {
|
public void runTest() throws Exception {
|
||||||
final ASTModificationStore modStore = new ASTModificationStore();
|
final ASTModificationStore modStore = new ASTModificationStore();
|
||||||
IFile testFile = importFile("source.h", source); //$NON-NLS-1$
|
IFile testFile = importFile("source.h", source); //$NON-NLS-1$
|
||||||
|
|
||||||
ASTVisitor visitor = createModificator(modStore);
|
ASTVisitor visitor = createModificator(modStore);
|
||||||
|
|
||||||
|
@ -63,15 +63,15 @@ public abstract class ChangeGeneratorTest extends BaseTestFramework {
|
||||||
assertTrue("The indexing operation of the test CProject has not finished jet. This should not happen...", joined);
|
assertTrue("The indexing operation of the test CProject has not finished jet. This should not happen...", joined);
|
||||||
|
|
||||||
IASTTranslationUnit unit = CoreModelUtil.findTranslationUnit(testFile).getAST();
|
IASTTranslationUnit unit = CoreModelUtil.findTranslationUnit(testFile).getAST();
|
||||||
final ChangeGenerator changeGenerator = new ChangeGenerator(modStore,
|
final ChangeGenerator changeGenerator =
|
||||||
ASTCommenter.getCommentedNodeMap(unit));
|
new ChangeGenerator(modStore, ASTCommenter.getCommentedNodeMap(unit));
|
||||||
unit.accept(visitor);
|
unit.accept(visitor);
|
||||||
|
|
||||||
changeGenerator.generateChange(unit);
|
changeGenerator.generateChange(unit);
|
||||||
Document doc = new Document(source);
|
Document doc = new Document(source);
|
||||||
for (Change curChange : ((CompositeChange) changeGenerator.getChange()).getChildren()) {
|
for (Change change : ((CompositeChange) changeGenerator.getChange()).getChildren()) {
|
||||||
if (curChange instanceof TextFileChange) {
|
if (change instanceof TextFileChange) {
|
||||||
TextFileChange textChange = (TextFileChange) curChange;
|
TextFileChange textChange = (TextFileChange) change;
|
||||||
textChange.getEdit().apply(doc);
|
textChange.getEdit().apply(doc);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -22,10 +22,10 @@ import org.eclipse.cdt.core.parser.tests.rewrite.changegenerator.replace.Replace
|
||||||
/**
|
/**
|
||||||
* @author Thomas Corbat
|
* @author Thomas Corbat
|
||||||
*/
|
*/
|
||||||
public class ChangeGeneratorTestSuite{
|
public class ChangeGeneratorTestSuite {
|
||||||
|
|
||||||
public static Test suite() throws Exception {
|
public static Test suite() throws Exception {
|
||||||
TestSuite suite = new TestSuite("ChangeGeneratorTests");
|
TestSuite suite = new TestSuite("ChangeGeneratorTestSuite");
|
||||||
|
|
||||||
suite.addTest(ReplaceTestSuite.suite());
|
suite.addTest(ReplaceTestSuite.suite());
|
||||||
suite.addTest(RemoveTestSuite.suite());
|
suite.addTest(RemoveTestSuite.suite());
|
||||||
|
|
|
@ -1,13 +1,13 @@
|
||||||
/*******************************************************************************
|
/*******************************************************************************
|
||||||
* Copyright (c) 2008, 2011 Institute for Software, HSR Hochschule fuer Technik
|
* Copyright (c) 2008, 2011 Institute for Software, HSR Hochschule fuer Technik
|
||||||
* Rapperswil, University of applied sciences and others.
|
* Rapperswil, University of applied sciences and others.
|
||||||
* All rights reserved. This program and the accompanying materials
|
* All rights reserved. This program and the accompanying materials
|
||||||
* are made available under the terms of the Eclipse Public License v1.0
|
* are made available under the terms of the Eclipse Public License v1.0
|
||||||
* which accompanies this distribution, and is available at
|
* which accompanies this distribution, and is available at
|
||||||
* http://www.eclipse.org/legal/epl-v10.html
|
* http://www.eclipse.org/legal/epl-v10.html
|
||||||
*
|
*
|
||||||
* Contributors:
|
* Contributors:
|
||||||
* Institute for Software (IFS)- initial API and implementation
|
* Institute for Software (IFS)- initial API and implementation
|
||||||
******************************************************************************/
|
******************************************************************************/
|
||||||
package org.eclipse.cdt.core.parser.tests.rewrite.changegenerator.insertbefore;
|
package org.eclipse.cdt.core.parser.tests.rewrite.changegenerator.insertbefore;
|
||||||
|
|
||||||
|
@ -41,7 +41,7 @@ public class AddDeclarationBug extends ChangeGeneratorTest {
|
||||||
super("AddDeclarationBug");
|
super("AddDeclarationBug");
|
||||||
}
|
}
|
||||||
|
|
||||||
public static Test suite() {
|
public static Test suite() {
|
||||||
return new AddDeclarationBug();
|
return new AddDeclarationBug();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -64,11 +64,11 @@ public class AddDeclarationBug extends ChangeGeneratorTest {
|
||||||
if (declSpec instanceof ICPPASTCompositeTypeSpecifier) {
|
if (declSpec instanceof ICPPASTCompositeTypeSpecifier) {
|
||||||
ICPPASTCompositeTypeSpecifier classNode = (ICPPASTCompositeTypeSpecifier) declSpec;
|
ICPPASTCompositeTypeSpecifier classNode = (ICPPASTCompositeTypeSpecifier) declSpec;
|
||||||
IASTSimpleDeclaration newDecl = new CPPASTSimpleDeclaration();
|
IASTSimpleDeclaration newDecl = new CPPASTSimpleDeclaration();
|
||||||
|
|
||||||
IASTSimpleDeclSpecifier returnTyp = new CPPASTSimpleDeclSpecifier();
|
IASTSimpleDeclSpecifier returnTyp = new CPPASTSimpleDeclSpecifier();
|
||||||
returnTyp.setType(IASTSimpleDeclSpecifier.t_int);
|
returnTyp.setType(IASTSimpleDeclSpecifier.t_int);
|
||||||
newDecl.setDeclSpecifier(returnTyp);
|
newDecl.setDeclSpecifier(returnTyp);
|
||||||
|
|
||||||
IASTStandardFunctionDeclarator declarator = new CPPASTFunctionDeclarator(
|
IASTStandardFunctionDeclarator declarator = new CPPASTFunctionDeclarator(
|
||||||
new CPPASTName("exp".toCharArray())); //$NON-NLS-1$
|
new CPPASTName("exp".toCharArray())); //$NON-NLS-1$
|
||||||
IASTSimpleDeclSpecifier paramTyp = new CPPASTSimpleDeclSpecifier();
|
IASTSimpleDeclSpecifier paramTyp = new CPPASTSimpleDeclSpecifier();
|
||||||
|
@ -77,7 +77,7 @@ public class AddDeclarationBug extends ChangeGeneratorTest {
|
||||||
ICPPASTParameterDeclaration param = new CPPASTParameterDeclaration(paramTyp, decl);
|
ICPPASTParameterDeclaration param = new CPPASTParameterDeclaration(paramTyp, decl);
|
||||||
declarator.addParameterDeclaration(param);
|
declarator.addParameterDeclaration(param);
|
||||||
newDecl.addDeclarator(declarator);
|
newDecl.addDeclarator(declarator);
|
||||||
|
|
||||||
ASTModification mod = new ASTModification(ModificationKind.APPEND_CHILD, classNode,
|
ASTModification mod = new ASTModification(ModificationKind.APPEND_CHILD, classNode,
|
||||||
newDecl, null);
|
newDecl, null);
|
||||||
modStore.storeModification(null, mod);
|
modStore.storeModification(null, mod);
|
||||||
|
|
|
@ -20,7 +20,7 @@ import junit.framework.TestSuite;
|
||||||
public class InsertBeforeTestSuite {
|
public class InsertBeforeTestSuite {
|
||||||
|
|
||||||
public static Test suite() throws Exception {
|
public static Test suite() throws Exception {
|
||||||
TestSuite suite = new TestSuite("ChangeGenerator InsertBefore Tests");
|
TestSuite suite = new TestSuite("InsertBeforeTestSuite");
|
||||||
|
|
||||||
suite.addTest(FirstParameterTest.suite());
|
suite.addTest(FirstParameterTest.suite());
|
||||||
suite.addTest(PointerParameterTest.suite());
|
suite.addTest(PointerParameterTest.suite());
|
||||||
|
|
|
@ -1,26 +1,26 @@
|
||||||
/*******************************************************************************
|
/*******************************************************************************
|
||||||
* Copyright (c) 2008 Institute for Software, HSR Hochschule fuer Technik
|
* Copyright (c) 2008 Institute for Software, HSR Hochschule fuer Technik
|
||||||
* Rapperswil, University of applied sciences and others
|
* Rapperswil, University of applied sciences and others
|
||||||
* All rights reserved. This program and the accompanying materials
|
* All rights reserved. This program and the accompanying materials
|
||||||
* are made available under the terms of the Eclipse Public License v1.0
|
* are made available under the terms of the Eclipse Public License v1.0
|
||||||
* which accompanies this distribution, and is available at
|
* which accompanies this distribution, and is available at
|
||||||
* http://www.eclipse.org/legal/epl-v10.html
|
* http://www.eclipse.org/legal/epl-v10.html
|
||||||
*
|
*
|
||||||
* Contributors:
|
* Contributors:
|
||||||
* Institute for Software - initial API and implementation
|
* Institute for Software - initial API and implementation
|
||||||
*******************************************************************************/
|
*******************************************************************************/
|
||||||
package org.eclipse.cdt.core.parser.tests.rewrite.changegenerator.remove;
|
package org.eclipse.cdt.core.parser.tests.rewrite.changegenerator.remove;
|
||||||
|
|
||||||
import junit.framework.Test;
|
import junit.framework.Test;
|
||||||
|
|
||||||
|
import org.eclipse.cdt.core.dom.ast.ASTVisitor;
|
||||||
import org.eclipse.cdt.core.dom.ast.IASTArrayDeclarator;
|
import org.eclipse.cdt.core.dom.ast.IASTArrayDeclarator;
|
||||||
import org.eclipse.cdt.core.dom.ast.IASTArrayModifier;
|
import org.eclipse.cdt.core.dom.ast.IASTArrayModifier;
|
||||||
import org.eclipse.cdt.core.dom.ast.IASTDeclarator;
|
import org.eclipse.cdt.core.dom.ast.IASTDeclarator;
|
||||||
import org.eclipse.cdt.core.dom.ast.ASTVisitor;
|
|
||||||
import org.eclipse.cdt.core.parser.tests.rewrite.changegenerator.ChangeGeneratorTest;
|
import org.eclipse.cdt.core.parser.tests.rewrite.changegenerator.ChangeGeneratorTest;
|
||||||
import org.eclipse.cdt.internal.core.dom.rewrite.ASTModification;
|
import org.eclipse.cdt.internal.core.dom.rewrite.ASTModification;
|
||||||
import org.eclipse.cdt.internal.core.dom.rewrite.ASTModificationStore;
|
|
||||||
import org.eclipse.cdt.internal.core.dom.rewrite.ASTModification.ModificationKind;
|
import org.eclipse.cdt.internal.core.dom.rewrite.ASTModification.ModificationKind;
|
||||||
|
import org.eclipse.cdt.internal.core.dom.rewrite.ASTModificationStore;
|
||||||
|
|
||||||
public class ArrayModifierTest extends ChangeGeneratorTest {
|
public class ArrayModifierTest extends ChangeGeneratorTest {
|
||||||
|
|
||||||
|
@ -40,18 +40,17 @@ public class ArrayModifierTest extends ChangeGeneratorTest {
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected ASTVisitor createModificator(
|
protected ASTVisitor createModificator(final ASTModificationStore modStore) {
|
||||||
final ASTModificationStore modStore) {
|
|
||||||
return new ASTVisitor() {
|
return new ASTVisitor() {
|
||||||
{
|
{
|
||||||
shouldVisitDeclarators = true;
|
shouldVisitDeclarators = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public int visit(IASTDeclarator declarator) {
|
public int visit(IASTDeclarator declarator) {
|
||||||
if (declarator instanceof IASTArrayDeclarator) {
|
if (declarator instanceof IASTArrayDeclarator) {
|
||||||
IASTArrayDeclarator arrayDeclarator = (IASTArrayDeclarator)declarator;
|
IASTArrayDeclarator arrayDeclarator = (IASTArrayDeclarator)declarator;
|
||||||
|
|
||||||
IASTArrayModifier[] modifiers = arrayDeclarator.getArrayModifiers();
|
IASTArrayModifier[] modifiers = arrayDeclarator.getArrayModifiers();
|
||||||
ASTModification modification = new ASTModification(ModificationKind.REPLACE, modifiers[0], null, null);
|
ASTModification modification = new ASTModification(ModificationKind.REPLACE, modifiers[0], null, null);
|
||||||
modStore.storeModification(null, modification);
|
modStore.storeModification(null, modification);
|
||||||
|
|
|
@ -1,29 +1,29 @@
|
||||||
/*******************************************************************************
|
/*******************************************************************************
|
||||||
* Copyright (c) 2008 Institute for Software, HSR Hochschule fuer Technik
|
* Copyright (c) 2008 Institute for Software, HSR Hochschule fuer Technik
|
||||||
* Rapperswil, University of applied sciences and others
|
* Rapperswil, University of applied sciences and others
|
||||||
* All rights reserved. This program and the accompanying materials
|
* All rights reserved. This program and the accompanying materials
|
||||||
* are made available under the terms of the Eclipse Public License v1.0
|
* are made available under the terms of the Eclipse Public License v1.0
|
||||||
* which accompanies this distribution, and is available at
|
* which accompanies this distribution, and is available at
|
||||||
* http://www.eclipse.org/legal/epl-v10.html
|
* http://www.eclipse.org/legal/epl-v10.html
|
||||||
*
|
*
|
||||||
* Contributors:
|
* Contributors:
|
||||||
* Institute for Software - initial API and implementation
|
* Institute for Software - initial API and implementation
|
||||||
*******************************************************************************/
|
*******************************************************************************/
|
||||||
package org.eclipse.cdt.core.parser.tests.rewrite.changegenerator.replace;
|
package org.eclipse.cdt.core.parser.tests.rewrite.changegenerator.replace;
|
||||||
|
|
||||||
import junit.framework.Test;
|
import junit.framework.Test;
|
||||||
|
|
||||||
|
import org.eclipse.cdt.core.dom.ast.ASTVisitor;
|
||||||
import org.eclipse.cdt.core.dom.ast.IASTArrayDeclarator;
|
import org.eclipse.cdt.core.dom.ast.IASTArrayDeclarator;
|
||||||
import org.eclipse.cdt.core.dom.ast.IASTArrayModifier;
|
import org.eclipse.cdt.core.dom.ast.IASTArrayModifier;
|
||||||
import org.eclipse.cdt.core.dom.ast.IASTDeclarator;
|
import org.eclipse.cdt.core.dom.ast.IASTDeclarator;
|
||||||
import org.eclipse.cdt.core.dom.ast.IASTExpression;
|
import org.eclipse.cdt.core.dom.ast.IASTExpression;
|
||||||
import org.eclipse.cdt.core.dom.ast.ASTVisitor;
|
|
||||||
import org.eclipse.cdt.core.parser.tests.rewrite.changegenerator.ChangeGeneratorTest;
|
import org.eclipse.cdt.core.parser.tests.rewrite.changegenerator.ChangeGeneratorTest;
|
||||||
import org.eclipse.cdt.internal.core.dom.parser.cpp.CPPASTArrayModifier;
|
import org.eclipse.cdt.internal.core.dom.parser.cpp.CPPASTArrayModifier;
|
||||||
import org.eclipse.cdt.internal.core.dom.parser.cpp.CPPASTLiteralExpression;
|
import org.eclipse.cdt.internal.core.dom.parser.cpp.CPPASTLiteralExpression;
|
||||||
import org.eclipse.cdt.internal.core.dom.rewrite.ASTModification;
|
import org.eclipse.cdt.internal.core.dom.rewrite.ASTModification;
|
||||||
import org.eclipse.cdt.internal.core.dom.rewrite.ASTModificationStore;
|
|
||||||
import org.eclipse.cdt.internal.core.dom.rewrite.ASTModification.ModificationKind;
|
import org.eclipse.cdt.internal.core.dom.rewrite.ASTModification.ModificationKind;
|
||||||
|
import org.eclipse.cdt.internal.core.dom.rewrite.ASTModificationStore;
|
||||||
|
|
||||||
public class ArrayModifierTest extends ChangeGeneratorTest {
|
public class ArrayModifierTest extends ChangeGeneratorTest {
|
||||||
|
|
||||||
|
@ -42,22 +42,20 @@ public class ArrayModifierTest extends ChangeGeneratorTest {
|
||||||
return new ArrayModifierTest();
|
return new ArrayModifierTest();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected ASTVisitor createModificator(
|
protected ASTVisitor createModificator(final ASTModificationStore modStore) {
|
||||||
final ASTModificationStore modStore) {
|
|
||||||
return new ASTVisitor() {
|
return new ASTVisitor() {
|
||||||
{
|
{
|
||||||
shouldVisitDeclarators = true;
|
shouldVisitDeclarators = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public int visit(IASTDeclarator declarator) {
|
public int visit(IASTDeclarator declarator) {
|
||||||
if (declarator instanceof IASTArrayDeclarator) {
|
if (declarator instanceof IASTArrayDeclarator) {
|
||||||
IASTArrayDeclarator arrayDeclarator = (IASTArrayDeclarator)declarator;
|
IASTArrayDeclarator arrayDeclarator = (IASTArrayDeclarator)declarator;
|
||||||
IASTArrayModifier[] modifiers = arrayDeclarator.getArrayModifiers();
|
IASTArrayModifier[] modifiers = arrayDeclarator.getArrayModifiers();
|
||||||
IASTArrayModifier newModifier = new CPPASTArrayModifier();
|
IASTArrayModifier newModifier = new CPPASTArrayModifier();
|
||||||
IASTExpression expr = new CPPASTLiteralExpression(0, "15"); //$NON-NLS-1$
|
IASTExpression expr = new CPPASTLiteralExpression(0, "15".toCharArray()); //$NON-NLS-1$
|
||||||
newModifier.setConstantExpression(expr);
|
newModifier.setConstantExpression(expr);
|
||||||
ASTModification modification = new ASTModification(ModificationKind.REPLACE, modifiers[0], newModifier, null);
|
ASTModification modification = new ASTModification(ModificationKind.REPLACE, modifiers[0], newModifier, null);
|
||||||
modStore.storeModification(null, modification);
|
modStore.storeModification(null, modification);
|
||||||
|
|
|
@ -13,21 +13,21 @@ package org.eclipse.cdt.core.parser.tests.rewrite.changegenerator.replace;
|
||||||
|
|
||||||
import junit.framework.Test;
|
import junit.framework.Test;
|
||||||
|
|
||||||
|
import org.eclipse.cdt.core.dom.ast.ASTVisitor;
|
||||||
import org.eclipse.cdt.core.dom.ast.IASTDeclarator;
|
import org.eclipse.cdt.core.dom.ast.IASTDeclarator;
|
||||||
import org.eclipse.cdt.core.dom.ast.IASTParameterDeclaration;
|
import org.eclipse.cdt.core.dom.ast.IASTParameterDeclaration;
|
||||||
import org.eclipse.cdt.core.dom.ast.IASTPointerOperator;
|
import org.eclipse.cdt.core.dom.ast.IASTPointerOperator;
|
||||||
import org.eclipse.cdt.core.dom.ast.ASTVisitor;
|
|
||||||
import org.eclipse.cdt.core.parser.tests.rewrite.changegenerator.ChangeGeneratorTest;
|
import org.eclipse.cdt.core.parser.tests.rewrite.changegenerator.ChangeGeneratorTest;
|
||||||
import org.eclipse.cdt.internal.core.dom.parser.cpp.CPPASTFunctionDeclarator;
|
import org.eclipse.cdt.internal.core.dom.parser.cpp.CPPASTFunctionDeclarator;
|
||||||
import org.eclipse.cdt.internal.core.dom.parser.cpp.CPPASTPointer;
|
import org.eclipse.cdt.internal.core.dom.parser.cpp.CPPASTPointer;
|
||||||
import org.eclipse.cdt.internal.core.dom.rewrite.ASTModification;
|
import org.eclipse.cdt.internal.core.dom.rewrite.ASTModification;
|
||||||
import org.eclipse.cdt.internal.core.dom.rewrite.ASTModificationStore;
|
|
||||||
import org.eclipse.cdt.internal.core.dom.rewrite.ASTModification.ModificationKind;
|
import org.eclipse.cdt.internal.core.dom.rewrite.ASTModification.ModificationKind;
|
||||||
|
import org.eclipse.cdt.internal.core.dom.rewrite.ASTModificationStore;
|
||||||
|
|
||||||
public class PointerInParameterTest extends ChangeGeneratorTest {
|
public class PointerInParameterTest extends ChangeGeneratorTest {
|
||||||
|
|
||||||
public PointerInParameterTest() {
|
public PointerInParameterTest() {
|
||||||
super("Replace Pointer for Parameter"); //$NON-NLS-1$
|
super("PointerInParameterTest"); //$NON-NLS-1$
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|
|
@ -7,30 +7,25 @@
|
||||||
* http://www.eclipse.org/legal/epl-v10.html
|
* http://www.eclipse.org/legal/epl-v10.html
|
||||||
*
|
*
|
||||||
* Contributors:
|
* Contributors:
|
||||||
* Institute for Software - initial API and implementation
|
* Institute for Software - initial API and implementation
|
||||||
*******************************************************************************/
|
*******************************************************************************/
|
||||||
package org.eclipse.cdt.core.parser.tests.rewrite.changegenerator.replace;
|
package org.eclipse.cdt.core.parser.tests.rewrite.changegenerator.replace;
|
||||||
|
|
||||||
import junit.framework.Test;
|
import junit.framework.Test;
|
||||||
|
|
||||||
import org.eclipse.cdt.core.dom.ast.IASTStatement;
|
|
||||||
import org.eclipse.cdt.core.dom.ast.ASTVisitor;
|
import org.eclipse.cdt.core.dom.ast.ASTVisitor;
|
||||||
|
import org.eclipse.cdt.core.dom.ast.IASTStatement;
|
||||||
import org.eclipse.cdt.core.dom.ast.cpp.ICPPASTForStatement;
|
import org.eclipse.cdt.core.dom.ast.cpp.ICPPASTForStatement;
|
||||||
import org.eclipse.cdt.core.parser.tests.rewrite.changegenerator.ChangeGeneratorTest;
|
import org.eclipse.cdt.core.parser.tests.rewrite.changegenerator.ChangeGeneratorTest;
|
||||||
import org.eclipse.cdt.internal.core.dom.parser.cpp.CPPNodeFactory;
|
import org.eclipse.cdt.internal.core.dom.parser.cpp.CPPNodeFactory;
|
||||||
import org.eclipse.cdt.internal.core.dom.rewrite.ASTModification;
|
import org.eclipse.cdt.internal.core.dom.rewrite.ASTModification;
|
||||||
import org.eclipse.cdt.internal.core.dom.rewrite.ASTModificationStore;
|
import org.eclipse.cdt.internal.core.dom.rewrite.ASTModificationStore;
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
public class ReplaceForLoopBodyTest extends ChangeGeneratorTest {
|
public class ReplaceForLoopBodyTest extends ChangeGeneratorTest {
|
||||||
|
private boolean forReplaced;
|
||||||
private boolean forReplaced = false;
|
|
||||||
|
|
||||||
public ReplaceForLoopBodyTest(){
|
public ReplaceForLoopBodyTest(){
|
||||||
super("Replace For-Loop"); //$NON-NLS-1$
|
super("ReplaceForLoopBodyTest"); //$NON-NLS-1$
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -45,7 +40,6 @@ public class ReplaceForLoopBodyTest extends ChangeGeneratorTest {
|
||||||
return new ReplaceForLoopBodyTest();
|
return new ReplaceForLoopBodyTest();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected ASTVisitor createModificator(
|
protected ASTVisitor createModificator(
|
||||||
final ASTModificationStore modStore) {
|
final ASTModificationStore modStore) {
|
||||||
|
|
|
@ -65,8 +65,7 @@ public class ReplaceInsertStatementTest extends ChangeGeneratorTest {
|
||||||
IASTLiteralExpression value = new CPPASTLiteralExpression(
|
IASTLiteralExpression value = new CPPASTLiteralExpression(
|
||||||
IASTLiteralExpression.lk_integer_constant, "42".toCharArray());
|
IASTLiteralExpression.lk_integer_constant, "42".toCharArray());
|
||||||
IASTExpressionStatement insertStmt = new CPPASTExpressionStatement(
|
IASTExpressionStatement insertStmt = new CPPASTExpressionStatement(
|
||||||
new CPPASTBinaryExpression(
|
new CPPASTBinaryExpression(IASTBinaryExpression.op_assign, id, value));
|
||||||
IASTBinaryExpression.op_assign, id, value));
|
|
||||||
|
|
||||||
IASTIdExpression incId = new CPPASTIdExpression(
|
IASTIdExpression incId = new CPPASTIdExpression(
|
||||||
new CPPASTName("i".toCharArray()));
|
new CPPASTName("i".toCharArray()));
|
||||||
|
@ -88,5 +87,4 @@ public class ReplaceInsertStatementTest extends ChangeGeneratorTest {
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -20,7 +20,7 @@ import junit.framework.TestSuite;
|
||||||
public class ReplaceTestSuite {
|
public class ReplaceTestSuite {
|
||||||
|
|
||||||
public static Test suite() throws Exception {
|
public static Test suite() throws Exception {
|
||||||
TestSuite suite = new TestSuite("ChangeGeneratorReplaceTests");
|
TestSuite suite = new TestSuite("ReplaceTestSuite");
|
||||||
|
|
||||||
suite.addTest(NameTest.suite());
|
suite.addTest(NameTest.suite());
|
||||||
suite.addTest(MoveTest.suite());
|
suite.addTest(MoveTest.suite());
|
||||||
|
|
|
@ -9,6 +9,9 @@ org.eclipse.cdt.core/debug/parser=false
|
||||||
# Prints parser stack traces
|
# Prints parser stack traces
|
||||||
org.eclipse.cdt.core/debug/parser/exceptions=false
|
org.eclipse.cdt.core/debug/parser/exceptions=false
|
||||||
|
|
||||||
|
# Reports statistics for building the structure to do resource lookups.
|
||||||
|
org.eclipse.cdt.core/debug/resourceLookup=false
|
||||||
|
|
||||||
# Reports scanner activity
|
# Reports scanner activity
|
||||||
org.eclipse.cdt.core/debug/scanner=false
|
org.eclipse.cdt.core/debug/scanner=false
|
||||||
|
|
||||||
|
|
|
@ -17,7 +17,7 @@ package org.eclipse.cdt.core.dom.ast;
|
||||||
* @noimplement This interface is not intended to be implemented by clients.
|
* @noimplement This interface is not intended to be implemented by clients.
|
||||||
*/
|
*/
|
||||||
public interface IASTDeclaration extends IASTNode {
|
public interface IASTDeclaration extends IASTNode {
|
||||||
public static final IASTDeclaration[] EMPTY_DECLARATION_ARRAY = new IASTDeclaration[0];
|
public static final IASTDeclaration[] EMPTY_DECLARATION_ARRAY = {};
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @since 5.1
|
* @since 5.1
|
||||||
|
|
|
@ -67,7 +67,7 @@ public interface IASTDeclarator extends IASTNode, IASTNameOwner {
|
||||||
public void addPointerOperator(IASTPointerOperator operator);
|
public void addPointerOperator(IASTPointerOperator operator);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* If the declarator is nested in parentheses, this returns the declarator
|
* If the declarator is nested in parentheses, returns the declarator
|
||||||
* as found in those parentheses.
|
* as found in those parentheses.
|
||||||
*
|
*
|
||||||
* @return the nested declarator or null
|
* @return the nested declarator or null
|
||||||
|
@ -77,7 +77,7 @@ public interface IASTDeclarator extends IASTNode, IASTNameOwner {
|
||||||
public void setNestedDeclarator(IASTDeclarator nested);
|
public void setNestedDeclarator(IASTDeclarator nested);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* This returns the name of the declarator. If this is an abstract
|
* Returns the name of the declarator. If this is an abstract
|
||||||
* declarator, this will return an empty name.
|
* declarator, this will return an empty name.
|
||||||
*
|
*
|
||||||
* @return the name of the declarator
|
* @return the name of the declarator
|
||||||
|
@ -85,7 +85,7 @@ public interface IASTDeclarator extends IASTNode, IASTNameOwner {
|
||||||
public IASTName getName();
|
public IASTName getName();
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Set the name of he declarator.
|
* Sets the name of he declarator.
|
||||||
*
|
*
|
||||||
* @param name
|
* @param name
|
||||||
* <code>IASTName</code>
|
* <code>IASTName</code>
|
||||||
|
@ -93,7 +93,7 @@ public interface IASTDeclarator extends IASTNode, IASTNameOwner {
|
||||||
public void setName(IASTName name);
|
public void setName(IASTName name);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* This is the optional initializer for this declarator.
|
* Returns the optional initializer for this declarator.
|
||||||
*
|
*
|
||||||
* @return the initializer expression or null
|
* @return the initializer expression or null
|
||||||
*/
|
*/
|
||||||
|
|
|
@ -17,7 +17,6 @@ package org.eclipse.cdt.core.dom.ast;
|
||||||
* @noimplement This interface is not intended to be implemented by clients.
|
* @noimplement This interface is not intended to be implemented by clients.
|
||||||
*/
|
*/
|
||||||
public interface IASTExpressionList extends IASTExpression {
|
public interface IASTExpressionList extends IASTExpression {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* <code>NESTED_EXPRESSION</code> describes the relationship between
|
* <code>NESTED_EXPRESSION</code> describes the relationship between
|
||||||
* <code>IASTExpressionList</code> and the nested
|
* <code>IASTExpressionList</code> and the nested
|
||||||
|
@ -29,7 +28,7 @@ public interface IASTExpressionList extends IASTExpression {
|
||||||
/**
|
/**
|
||||||
* Get nested expressions.
|
* Get nested expressions.
|
||||||
*
|
*
|
||||||
* @return <code>IASTExpression [] </code> nested expressions
|
* @return <code>IASTExpression[] </code> nested expressions
|
||||||
*/
|
*/
|
||||||
public IASTExpression[] getExpressions();
|
public IASTExpression[] getExpressions();
|
||||||
|
|
||||||
|
|
|
@ -6,7 +6,7 @@
|
||||||
* http://www.eclipse.org/legal/epl-v10.html
|
* http://www.eclipse.org/legal/epl-v10.html
|
||||||
*
|
*
|
||||||
* Contributors:
|
* Contributors:
|
||||||
* Doug Schaefer (IBM) - Initial API and implementation
|
* Doug Schaefer (IBM) - Initial API and implementation
|
||||||
*******************************************************************************/
|
*******************************************************************************/
|
||||||
package org.eclipse.cdt.core.dom.ast;
|
package org.eclipse.cdt.core.dom.ast;
|
||||||
|
|
||||||
|
@ -19,7 +19,6 @@ package org.eclipse.cdt.core.dom.ast;
|
||||||
*/
|
*/
|
||||||
@Deprecated
|
@Deprecated
|
||||||
public interface IASTInitializerExpression extends IASTEqualsInitializer {
|
public interface IASTInitializerExpression extends IASTEqualsInitializer {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* <code>INITIALIZER_EXPRESSION</code> represents the relationship between
|
* <code>INITIALIZER_EXPRESSION</code> represents the relationship between
|
||||||
* an <code>IASTInitializerExpression</code>. and its <code></code>IASTExpression</code>.
|
* an <code>IASTInitializerExpression</code>. and its <code></code>IASTExpression</code>.
|
||||||
|
|
|
@ -6,7 +6,7 @@
|
||||||
* http://www.eclipse.org/legal/epl-v10.html
|
* http://www.eclipse.org/legal/epl-v10.html
|
||||||
*
|
*
|
||||||
* Contributors:
|
* Contributors:
|
||||||
* Markus Schorn - initial API and implementation
|
* Markus Schorn - initial API and implementation
|
||||||
*******************************************************************************/
|
*******************************************************************************/
|
||||||
package org.eclipse.cdt.core.dom.ast;
|
package org.eclipse.cdt.core.dom.ast;
|
||||||
|
|
||||||
|
@ -24,8 +24,8 @@ public interface IValue {
|
||||||
Long numericalValue();
|
Long numericalValue();
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Returns an internal representation of the expression that builds up the
|
* Returns an internal representation of the expression that builds up
|
||||||
* value. It is suitable for instantiating dependent values but may not be
|
* the value. It is suitable for instantiating dependent values but may not be
|
||||||
* used for the purpose of displaying values.
|
* used for the purpose of displaying values.
|
||||||
*/
|
*/
|
||||||
char[] getInternalExpression();
|
char[] getInternalExpression();
|
||||||
|
@ -37,8 +37,8 @@ public interface IValue {
|
||||||
IBinding[] getUnknownBindings();
|
IBinding[] getUnknownBindings();
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Returns a signature containing both the internal representation and the
|
* Returns a signature containing both the internal representation and
|
||||||
* unknown bindings. The representation is sufficient to distinguish values
|
* the unknown bindings. The representation is sufficient to distinguish values
|
||||||
* for the purpose of instantiation, it may not be used to display the value.
|
* for the purpose of instantiation, it may not be used to display the value.
|
||||||
*/
|
*/
|
||||||
char[] getSignature();
|
char[] getSignature();
|
||||||
|
|
|
@ -7,7 +7,7 @@
|
||||||
*
|
*
|
||||||
* Contributors:
|
* Contributors:
|
||||||
* Markus Schorn - initial API and implementation
|
* Markus Schorn - initial API and implementation
|
||||||
*******************************************************************************/
|
*******************************************************************************/
|
||||||
package org.eclipse.cdt.core.dom.rewrite;
|
package org.eclipse.cdt.core.dom.rewrite;
|
||||||
|
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
@ -42,14 +42,14 @@ import org.eclipse.text.edits.TextEditGroup;
|
||||||
* progress. There is no guarantee that this API will work or that it will remain the same.
|
* progress. There is no guarantee that this API will work or that it will remain the same.
|
||||||
* Please do not use this API without consulting with the CDT team.
|
* Please do not use this API without consulting with the CDT team.
|
||||||
* </p>
|
* </p>
|
||||||
*
|
*
|
||||||
* @since 5.0
|
* @since 5.0
|
||||||
* @noinstantiate This class is not intended to be instantiated by clients.
|
* @noinstantiate This class is not intended to be instantiated by clients.
|
||||||
*/
|
*/
|
||||||
public final class ASTRewrite {
|
public final class ASTRewrite {
|
||||||
/**
|
/**
|
||||||
* Defines the positions of the comment.
|
* Defines the positions of the comment.
|
||||||
*
|
*
|
||||||
* @since 5.3
|
* @since 5.3
|
||||||
*/
|
*/
|
||||||
public enum CommentPosition {
|
public enum CommentPosition {
|
||||||
|
@ -67,7 +67,7 @@ public final class ASTRewrite {
|
||||||
*/
|
*/
|
||||||
freestanding
|
freestanding
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Creates a rewriter for a translation unit.
|
* Creates a rewriter for a translation unit.
|
||||||
*/
|
*/
|
||||||
|
@ -80,7 +80,7 @@ public final class ASTRewrite {
|
||||||
private final ASTModificationStore fModificationStore;
|
private final ASTModificationStore fModificationStore;
|
||||||
private final ASTModification fParentMod;
|
private final ASTModification fParentMod;
|
||||||
private final NodeCommentMap fCommentMap;
|
private final NodeCommentMap fCommentMap;
|
||||||
|
|
||||||
private enum Operation {
|
private enum Operation {
|
||||||
insertBefore,
|
insertBefore,
|
||||||
replace,
|
replace,
|
||||||
|
@ -99,8 +99,8 @@ public final class ASTRewrite {
|
||||||
* Creates and returns a node for a source string that is to be inserted into
|
* Creates and returns a node for a source string that is to be inserted into
|
||||||
* the output document.
|
* the output document.
|
||||||
* The string will be inserted without being reformatted beyond correcting
|
* The string will be inserted without being reformatted beyond correcting
|
||||||
* the indentation level.
|
* the indentation level.
|
||||||
*
|
*
|
||||||
* @param code the string to be inserted; lines should not have extra indentation
|
* @param code the string to be inserted; lines should not have extra indentation
|
||||||
* @return a synthetic node representing the literal code.
|
* @return a synthetic node representing the literal code.
|
||||||
* @throws IllegalArgumentException if the code is null.
|
* @throws IllegalArgumentException if the code is null.
|
||||||
|
@ -115,7 +115,7 @@ public final class ASTRewrite {
|
||||||
*
|
*
|
||||||
* @param node the node being removed
|
* @param node the node being removed
|
||||||
* @param editGroup the edit group in which to collect the corresponding
|
* @param editGroup the edit group in which to collect the corresponding
|
||||||
* text edits, or <code>null</code>
|
* text edits, or <code>null</code>
|
||||||
* @throws IllegalArgumentException if the node is null, the node is not
|
* @throws IllegalArgumentException if the node is null, the node is not
|
||||||
* part of this rewriter's AST.
|
* part of this rewriter's AST.
|
||||||
*/
|
*/
|
||||||
|
@ -129,13 +129,13 @@ public final class ASTRewrite {
|
||||||
/**
|
/**
|
||||||
* Replaces the given node in this rewriter. The ast is not modified, the rewriter
|
* Replaces the given node in this rewriter. The ast is not modified, the rewriter
|
||||||
* just records the replacement.
|
* just records the replacement.
|
||||||
* The replacement node can be part of a translation-unit or it is a synthetic
|
* The replacement node can be part of a translation-unit or it is a synthetic
|
||||||
* (newly created) node.
|
* (newly created) node.
|
||||||
*
|
*
|
||||||
* @param node the node being replaced
|
* @param node the node being replaced
|
||||||
* @param replacement the node replacing the given one
|
* @param replacement the node replacing the given one
|
||||||
* @param editGroup the edit group in which to collect the corresponding text edits,
|
* @param editGroup the edit group in which to collect the corresponding text edits,
|
||||||
* or <code>null</code>
|
* or <code>null</code>
|
||||||
* @return a rewriter for further rewriting the replacement node.
|
* @return a rewriter for further rewriting the replacement node.
|
||||||
* @throws IllegalArgumentException if the node or the replacement is null, or if the node is
|
* @throws IllegalArgumentException if the node or the replacement is null, or if the node is
|
||||||
* not part of this rewriter's AST
|
* not part of this rewriter's AST
|
||||||
|
@ -155,14 +155,14 @@ public final class ASTRewrite {
|
||||||
/**
|
/**
|
||||||
* Inserts the given node in this rewriter. The ast is not modified, the rewriter
|
* Inserts the given node in this rewriter. The ast is not modified, the rewriter
|
||||||
* just records the insertion.
|
* just records the insertion.
|
||||||
* The new node can be part of a translation-unit or it is a synthetic
|
* The new node can be part of a translation-unit or it is a synthetic
|
||||||
* (newly created) node.
|
* (newly created) node.
|
||||||
* @param parent the parent the new node is added to.
|
* @param parent the parent the new node is added to.
|
||||||
* @param insertionPoint the node before which the insertion shall be done, or <code>null</code>
|
* @param insertionPoint the node before which the insertion shall be done, or <code>null</code>
|
||||||
* for inserting after the last child.
|
* for inserting after the last child.
|
||||||
* @param newNode the node being inserted
|
* @param newNode the node being inserted
|
||||||
* @param editGroup the edit group in which to collect the corresponding
|
* @param editGroup the edit group in which to collect the corresponding
|
||||||
* text edits, or <code>null</code>
|
* text edits, or <code>null</code>
|
||||||
* @return a rewriter for further rewriting the inserted node.
|
* @return a rewriter for further rewriting the inserted node.
|
||||||
* @throws IllegalArgumentException if the parent or the newNode is null, or if the parent is
|
* @throws IllegalArgumentException if the parent or the newNode is null, or if the parent is
|
||||||
* not part of this rewriter's AST, or the insertionPoint is not a child of the parent.
|
* not part of this rewriter's AST, or the insertionPoint is not a child of the parent.
|
||||||
|
@ -191,17 +191,17 @@ public final class ASTRewrite {
|
||||||
fModificationStore.storeModification(fParentMod, mod);
|
fModificationStore.storeModification(fParentMod, mod);
|
||||||
return new ASTRewrite(newNode, fModificationStore, mod, fCommentMap);
|
return new ASTRewrite(newNode, fModificationStore, mod, fCommentMap);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Converts all modifications recorded by this rewriter into the change object required by
|
* Converts all modifications recorded by this rewriter into the change object required by
|
||||||
* the refactoring framework.
|
* the refactoring framework.
|
||||||
* <p>
|
* <p>
|
||||||
* Calling this methods does not discard the modifications on record. Subsequence modifications
|
* Calling this methods does not discard the modifications on record. Subsequence modifications
|
||||||
* are added to the ones already on record. If this method is called again later,
|
* are added to the ones already on record. If this method is called again later,
|
||||||
* the resulting text edit object will accurately reflect the net cumulative affect of all those
|
* the resulting text edit object will accurately reflect the net cumulative affect of all those
|
||||||
* changes.
|
* changes.
|
||||||
* </p>
|
* </p>
|
||||||
*
|
*
|
||||||
* @return Change object describing the changes to the document corresponding to the changes
|
* @return Change object describing the changes to the document corresponding to the changes
|
||||||
* recorded by this rewriter
|
* recorded by this rewriter
|
||||||
* @since 5.0
|
* @since 5.0
|
||||||
|
@ -210,7 +210,8 @@ public final class ASTRewrite {
|
||||||
if (!(fRoot instanceof IASTTranslationUnit)) {
|
if (!(fRoot instanceof IASTTranslationUnit)) {
|
||||||
throw new IllegalArgumentException("This API can only be used for the root rewrite object."); //$NON-NLS-1$
|
throw new IllegalArgumentException("This API can only be used for the root rewrite object."); //$NON-NLS-1$
|
||||||
}
|
}
|
||||||
return ASTRewriteAnalyzer.rewriteAST((IASTTranslationUnit) fRoot, fModificationStore, fCommentMap);
|
return ASTRewriteAnalyzer.rewriteAST((IASTTranslationUnit) fRoot, fModificationStore,
|
||||||
|
fCommentMap);
|
||||||
}
|
}
|
||||||
|
|
||||||
private void checkBelongsToAST(IASTNode node) {
|
private void checkBelongsToAST(IASTNode node) {
|
||||||
|
@ -222,7 +223,7 @@ public final class ASTRewrite {
|
||||||
}
|
}
|
||||||
throw new IllegalArgumentException();
|
throw new IllegalArgumentException();
|
||||||
}
|
}
|
||||||
|
|
||||||
private void checkSupportedNode(IASTNode node, Operation op) {
|
private void checkSupportedNode(IASTNode node, Operation op) {
|
||||||
if (node instanceof IASTComment) {
|
if (node instanceof IASTComment) {
|
||||||
if (op != Operation.remove) {
|
if (op != Operation.remove) {
|
||||||
|
@ -234,12 +235,12 @@ public final class ASTRewrite {
|
||||||
}
|
}
|
||||||
if (node instanceof IASTProblem) {
|
if (node instanceof IASTProblem) {
|
||||||
throw new IllegalArgumentException("Rewriting problem nodes is not supported"); //$NON-NLS-1$
|
throw new IllegalArgumentException("Rewriting problem nodes is not supported"); //$NON-NLS-1$
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Assigns the comment to the node.
|
* Assigns the comment to the node.
|
||||||
*
|
*
|
||||||
* @param node the node.
|
* @param node the node.
|
||||||
* @param comment the comment to be attached to the node at the given position.
|
* @param comment the comment to be attached to the node at the given position.
|
||||||
* @param pos the position of the comment.
|
* @param pos the position of the comment.
|
||||||
|
@ -261,7 +262,7 @@ public final class ASTRewrite {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Returns comments for the given node.
|
* Returns comments for the given node.
|
||||||
*
|
*
|
||||||
* @param node the node
|
* @param node the node
|
||||||
* @param pos the position of the comments
|
* @param pos the position of the comments
|
||||||
* @return All comments assigned to the node at this position
|
* @return All comments assigned to the node at this position
|
||||||
|
|
|
@ -30,7 +30,6 @@ import org.eclipse.cdt.internal.core.parser.scanner.Lexer;
|
||||||
* @noimplement This interface is not intended to be implemented by clients.
|
* @noimplement This interface is not intended to be implemented by clients.
|
||||||
*/
|
*/
|
||||||
public interface IScanner {
|
public interface IScanner {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Returns a map from {@link String} to {@link IMacroBinding} containing
|
* Returns a map from {@link String} to {@link IMacroBinding} containing
|
||||||
* all the definitions that are defined at the current point in the
|
* all the definitions that are defined at the current point in the
|
||||||
|
|
|
@ -20,9 +20,8 @@ import org.eclipse.cdt.core.dom.ast.IASTNode;
|
||||||
/**
|
/**
|
||||||
* Initializer with equals sign (copy initialization)
|
* Initializer with equals sign (copy initialization)
|
||||||
*/
|
*/
|
||||||
public abstract class ASTEqualsInitializer extends ASTNode implements IASTEqualsInitializer,
|
public abstract class ASTEqualsInitializer extends ASTNode
|
||||||
IASTAmbiguityParent {
|
implements IASTEqualsInitializer, IASTAmbiguityParent {
|
||||||
|
|
||||||
private IASTInitializerClause fArgument;
|
private IASTInitializerClause fArgument;
|
||||||
|
|
||||||
public ASTEqualsInitializer() {
|
public ASTEqualsInitializer() {
|
||||||
|
|
|
@ -181,7 +181,6 @@ public abstract class AbstractGNUSourceCodeParser implements ISourceCodeParser {
|
||||||
|
|
||||||
protected boolean functionCallCanBeLValue= false;
|
protected boolean functionCallCanBeLValue= false;
|
||||||
protected boolean skipTrivialExpressionsInAggregateInitializers= false;
|
protected boolean skipTrivialExpressionsInAggregateInitializers= false;
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Marks the beginning of the current declaration. It is important to clear the mark whenever we
|
* Marks the beginning of the current declaration. It is important to clear the mark whenever we
|
||||||
|
@ -563,10 +562,9 @@ public abstract class AbstractGNUSourceCodeParser implements ISourceCodeParser {
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Parse an identifier.
|
* Parses an identifier.
|
||||||
*
|
*
|
||||||
* @throws BacktrackException
|
* @throws BacktrackException request a backtrack
|
||||||
* request a backtrack
|
|
||||||
*/
|
*/
|
||||||
protected abstract IASTName identifier() throws EndOfFileException, BacktrackException;
|
protected abstract IASTName identifier() throws EndOfFileException, BacktrackException;
|
||||||
|
|
||||||
|
@ -1242,7 +1240,7 @@ public abstract class AbstractGNUSourceCodeParser implements ISourceCodeParser {
|
||||||
}
|
}
|
||||||
IASTCastExpression result = buildCastExpression(IASTCastExpression.op_cast,
|
IASTCastExpression result = buildCastExpression(IASTCastExpression.op_cast,
|
||||||
typeId, rhs, startingOffset, calculateEndOffset(rhs));
|
typeId, rhs, startingOffset, calculateEndOffset(rhs));
|
||||||
if (!unaryFailed && couldBeFunctionCall && rhs instanceof IASTCastExpression == false) {
|
if (!unaryFailed && couldBeFunctionCall && !(rhs instanceof IASTCastExpression)) {
|
||||||
IToken markEnd= mark();
|
IToken markEnd= mark();
|
||||||
backup(mark);
|
backup(mark);
|
||||||
try {
|
try {
|
||||||
|
@ -2123,7 +2121,6 @@ public abstract class AbstractGNUSourceCodeParser implements ISourceCodeParser {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
protected IASTStatement parseCompoundStatement() throws EndOfFileException, BacktrackException {
|
protected IASTStatement parseCompoundStatement() throws EndOfFileException, BacktrackException {
|
||||||
IASTCompoundStatement compound = compoundStatement();
|
IASTCompoundStatement compound = compoundStatement();
|
||||||
return compound;
|
return compound;
|
||||||
|
@ -2164,27 +2161,25 @@ public abstract class AbstractGNUSourceCodeParser implements ISourceCodeParser {
|
||||||
return cs;
|
return cs;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
protected int figureEndOffset(IASTDeclSpecifier declSpec, IASTDeclarator[] declarators) {
|
protected int figureEndOffset(IASTDeclSpecifier declSpec, IASTDeclarator[] declarators) {
|
||||||
if (declarators.length == 0)
|
if (declarators.length == 0)
|
||||||
return calculateEndOffset(declSpec);
|
return calculateEndOffset(declSpec);
|
||||||
return calculateEndOffset(declarators[declarators.length - 1]);
|
return calculateEndOffset(declarators[declarators.length - 1]);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
protected int figureEndOffset(IASTDeclSpecifier declSpecifier, IASTDeclarator declarator) {
|
protected int figureEndOffset(IASTDeclSpecifier declSpecifier, IASTDeclarator declarator) {
|
||||||
if (declarator == null || ((ASTNode) declarator).getLength() == 0)
|
if (declarator == null || ((ASTNode) declarator).getLength() == 0)
|
||||||
return calculateEndOffset(declSpecifier);
|
return calculateEndOffset(declSpecifier);
|
||||||
return calculateEndOffset(declarator);
|
return calculateEndOffset(declarator);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
protected void throwBacktrack(IToken token) throws BacktrackException {
|
protected void throwBacktrack(IToken token) throws BacktrackException {
|
||||||
throwBacktrack(token.getOffset(), token.getLength());
|
throwBacktrack(token.getOffset(), token.getLength());
|
||||||
}
|
}
|
||||||
|
|
||||||
protected IASTExpression parseTypeidInParenthesisOrUnaryExpression(boolean exprIsLimitedToParenthesis,
|
protected IASTExpression parseTypeidInParenthesisOrUnaryExpression(boolean exprIsLimitedToParenthesis,
|
||||||
int offset, int typeExprKind, int unaryExprKind, CastExprCtx ctx, ITemplateIdStrategy strat) throws BacktrackException, EndOfFileException {
|
int offset, int typeExprKind, int unaryExprKind, CastExprCtx ctx, ITemplateIdStrategy strat)
|
||||||
|
throws BacktrackException, EndOfFileException {
|
||||||
IASTTypeId typeid;
|
IASTTypeId typeid;
|
||||||
IASTExpression expr= null;
|
IASTExpression expr= null;
|
||||||
IToken typeidLA= null;
|
IToken typeidLA= null;
|
||||||
|
@ -2315,7 +2310,7 @@ public abstract class AbstractGNUSourceCodeParser implements ISourceCodeParser {
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Accept a sequence of __attribute__ or __declspec
|
* Accepts a sequence of __attribute__ or __declspec.
|
||||||
*
|
*
|
||||||
* @param allowAttrib if true accept any number of __attribute__
|
* @param allowAttrib if true accept any number of __attribute__
|
||||||
* @param allowDeclspec if true accept any number of __declspec
|
* @param allowDeclspec if true accept any number of __declspec
|
||||||
|
@ -2416,7 +2411,7 @@ public abstract class AbstractGNUSourceCodeParser implements ISourceCodeParser {
|
||||||
* @throws EndOfFileException
|
* @throws EndOfFileException
|
||||||
*/
|
*/
|
||||||
protected void handleOtherDeclSpecModifier() throws BacktrackException, EndOfFileException {
|
protected void handleOtherDeclSpecModifier() throws BacktrackException, EndOfFileException {
|
||||||
// default action: consume keyword plus optional parenthesised "something"
|
// default action: consume keyword plus optional parenthesized "something"
|
||||||
consume();
|
consume();
|
||||||
|
|
||||||
IToken token = LA(1);
|
IToken token = LA(1);
|
||||||
|
@ -2504,7 +2499,6 @@ public abstract class AbstractGNUSourceCodeParser implements ISourceCodeParser {
|
||||||
}
|
}
|
||||||
|
|
||||||
protected boolean canBeTypeSpecifier() throws EndOfFileException {
|
protected boolean canBeTypeSpecifier() throws EndOfFileException {
|
||||||
|
|
||||||
final int lt1 = LT(1);
|
final int lt1 = LT(1);
|
||||||
switch (lt1) {
|
switch (lt1) {
|
||||||
// simple type specifiers:
|
// simple type specifiers:
|
||||||
|
|
|
@ -17,7 +17,6 @@ import org.eclipse.cdt.core.dom.ast.INodeFactory;
|
||||||
* Abstract base class for node factories.
|
* Abstract base class for node factories.
|
||||||
*/
|
*/
|
||||||
public abstract class NodeFactory implements INodeFactory {
|
public abstract class NodeFactory implements INodeFactory {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public final void setOffsets(IASTNode node, int offset, int endOffset) {
|
public final void setOffsets(IASTNode node, int offset, int endOffset) {
|
||||||
((ASTNode) node).setOffsetAndLength(offset, endOffset-offset);
|
((ASTNode) node).setOffsetAndLength(offset, endOffset-offset);
|
||||||
|
|
|
@ -6,7 +6,7 @@
|
||||||
* http://www.eclipse.org/legal/epl-v10.html
|
* http://www.eclipse.org/legal/epl-v10.html
|
||||||
*
|
*
|
||||||
* Contributors:
|
* Contributors:
|
||||||
* Markus Schorn - Initial API and implementation
|
* Markus Schorn - Initial API and implementation
|
||||||
*******************************************************************************/
|
*******************************************************************************/
|
||||||
package org.eclipse.cdt.internal.core.dom.parser.c;
|
package org.eclipse.cdt.internal.core.dom.parser.c;
|
||||||
|
|
||||||
|
@ -29,13 +29,11 @@ import org.eclipse.core.runtime.Assert;
|
||||||
* @since 5.0.1
|
* @since 5.0.1
|
||||||
*/
|
*/
|
||||||
public class CASTAmbiguousDeclarator extends ASTAmbiguousNode implements IASTAmbiguousDeclarator {
|
public class CASTAmbiguousDeclarator extends ASTAmbiguousNode implements IASTAmbiguousDeclarator {
|
||||||
|
|
||||||
private IASTDeclarator[] dtors = new IASTDeclarator[2];
|
private IASTDeclarator[] dtors = new IASTDeclarator[2];
|
||||||
private int dtorPos=-1;
|
private int dtorPos= -1;
|
||||||
|
|
||||||
|
|
||||||
public CASTAmbiguousDeclarator(IASTDeclarator... decls) {
|
public CASTAmbiguousDeclarator(IASTDeclarator... decls) {
|
||||||
for(IASTDeclarator d : decls) {
|
for (IASTDeclarator d : decls) {
|
||||||
if (d != null) {
|
if (d != null) {
|
||||||
addDeclarator(d);
|
addDeclarator(d);
|
||||||
}
|
}
|
||||||
|
@ -63,7 +61,7 @@ public class CASTAmbiguousDeclarator extends ASTAmbiguousNode implements IASTAmb
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public IASTDeclarator[] getDeclarators() {
|
public IASTDeclarator[] getDeclarators() {
|
||||||
dtors = ArrayUtil.trimAt(IASTDeclarator.class, dtors, dtorPos );
|
dtors = ArrayUtil.trimAt(IASTDeclarator.class, dtors, dtorPos);
|
||||||
return dtors;
|
return dtors;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -6,10 +6,10 @@
|
||||||
* http://www.eclipse.org/legal/epl-v10.html
|
* http://www.eclipse.org/legal/epl-v10.html
|
||||||
*
|
*
|
||||||
* Contributors:
|
* Contributors:
|
||||||
* John Camelon (IBM Rational Software) - Initial API and implementation
|
* John Camelon (IBM Rational Software) - Initial API and implementation
|
||||||
* Markus Schorn (Wind River Systems)
|
* Markus Schorn (Wind River Systems)
|
||||||
* Ed Swartz (Nokia)
|
* Ed Swartz (Nokia)
|
||||||
* Mike Kucera (IBM) - bug #206952
|
* Mike Kucera (IBM) - bug #206952
|
||||||
*******************************************************************************/
|
*******************************************************************************/
|
||||||
package org.eclipse.cdt.internal.core.dom.parser.c;
|
package org.eclipse.cdt.internal.core.dom.parser.c;
|
||||||
|
|
||||||
|
@ -415,7 +415,7 @@ public class GNUCSourceParser extends AbstractGNUSourceCodeParser {
|
||||||
|
|
||||||
final IASTDeclarator outerDtor= declarators[0];
|
final IASTDeclarator outerDtor= declarators[0];
|
||||||
final IASTDeclarator fdtor= ASTQueries.findTypeRelevantDeclarator(outerDtor);
|
final IASTDeclarator fdtor= ASTQueries.findTypeRelevantDeclarator(outerDtor);
|
||||||
if (fdtor instanceof IASTFunctionDeclarator == false)
|
if (!(fdtor instanceof IASTFunctionDeclarator))
|
||||||
throwBacktrack(firstOffset, LA(1).getEndOffset() - firstOffset);
|
throwBacktrack(firstOffset, LA(1).getEndOffset() - firstOffset);
|
||||||
|
|
||||||
IASTFunctionDefinition funcDefinition = nodeFactory.newFunctionDefinition(declSpec, (IASTFunctionDeclarator) fdtor, null);
|
IASTFunctionDefinition funcDefinition = nodeFactory.newFunctionDefinition(declSpec, (IASTFunctionDeclarator) fdtor, null);
|
||||||
|
@ -465,8 +465,8 @@ public class GNUCSourceParser extends AbstractGNUSourceCodeParser {
|
||||||
}
|
}
|
||||||
|
|
||||||
private IASTExpression expression(final ExprKind kind) throws EndOfFileException, BacktrackException {
|
private IASTExpression expression(final ExprKind kind) throws EndOfFileException, BacktrackException {
|
||||||
final boolean allowComma= kind==ExprKind.eExpression;
|
final boolean allowComma= kind == ExprKind.eExpression;
|
||||||
boolean allowAssignment= kind !=ExprKind.eConstant;
|
boolean allowAssignment= kind != ExprKind.eConstant;
|
||||||
int lt1;
|
int lt1;
|
||||||
int conditionCount= 0;
|
int conditionCount= 0;
|
||||||
BinaryOperator lastOperator= null;
|
BinaryOperator lastOperator= null;
|
||||||
|
@ -479,7 +479,7 @@ public class GNUCSourceParser extends AbstractGNUSourceCodeParser {
|
||||||
// <logical-or> ? <expression> : <assignment-expression>
|
// <logical-or> ? <expression> : <assignment-expression>
|
||||||
// Precedence: 25 is lower than precedence of logical or; 0 is lower than precedence of expression
|
// Precedence: 25 is lower than precedence of logical or; 0 is lower than precedence of expression
|
||||||
lastOperator= new BinaryOperator(lastOperator, lastExpression, lt1, 25, 0);
|
lastOperator= new BinaryOperator(lastOperator, lastExpression, lt1, 25, 0);
|
||||||
if (LT(2) == IToken.tCOLON) {
|
if (LT(2) == IToken.tCOLON) {
|
||||||
// Gnu extension: The expression after '?' can be omitted.
|
// Gnu extension: The expression after '?' can be omitted.
|
||||||
consume(); // Consume operator
|
consume(); // Consume operator
|
||||||
lastExpression= null; // Next cast expression is just null
|
lastExpression= null; // Next cast expression is just null
|
||||||
|
@ -1491,7 +1491,7 @@ public class GNUCSourceParser extends AbstractGNUSourceCodeParser {
|
||||||
int startOffset= last.getOffset();
|
int startOffset= last.getOffset();
|
||||||
|
|
||||||
// check for K&R C parameters (0 means it's not K&R C)
|
// check for K&R C parameters (0 means it's not K&R C)
|
||||||
if (fPreventKnrCheck==0 && supportKnRC) {
|
if (fPreventKnrCheck == 0 && supportKnRC) {
|
||||||
fPreventKnrCheck++;
|
fPreventKnrCheck++;
|
||||||
try {
|
try {
|
||||||
final int numKnRCParms = countKnRCParms();
|
final int numKnRCParms = countKnRCParms();
|
||||||
|
@ -1597,7 +1597,7 @@ public class GNUCSourceParser extends AbstractGNUSourceCodeParser {
|
||||||
}
|
}
|
||||||
|
|
||||||
private IASTSimpleDeclaration checkKnrParameterDeclaration(IASTDeclaration decl, final IASTName[] parmNames) {
|
private IASTSimpleDeclaration checkKnrParameterDeclaration(IASTDeclaration decl, final IASTName[] parmNames) {
|
||||||
if (decl instanceof IASTSimpleDeclaration == false)
|
if (!(decl instanceof IASTSimpleDeclaration))
|
||||||
return null;
|
return null;
|
||||||
|
|
||||||
IASTSimpleDeclaration declaration= ((IASTSimpleDeclaration) decl);
|
IASTSimpleDeclaration declaration= ((IASTSimpleDeclaration) decl);
|
||||||
|
@ -1839,7 +1839,6 @@ public class GNUCSourceParser extends AbstractGNUSourceCodeParser {
|
||||||
|
|
||||||
return parseDeclarationOrExpressionStatement();
|
return parseDeclarationOrExpressionStatement();
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -1863,7 +1862,7 @@ public class GNUCSourceParser extends AbstractGNUSourceCodeParser {
|
||||||
previousWasIdentifier = false;
|
previousWasIdentifier = false;
|
||||||
} else if (LT(1) == IToken.tIDENTIFIER) {
|
} else if (LT(1) == IToken.tIDENTIFIER) {
|
||||||
consume();
|
consume();
|
||||||
if (previousWasIdentifier == true) {
|
if (previousWasIdentifier) {
|
||||||
backup(mark);
|
backup(mark);
|
||||||
return 0; // i.e. KnR C won't have int f(typedef x)
|
return 0; // i.e. KnR C won't have int f(typedef x)
|
||||||
// char
|
// char
|
||||||
|
@ -2011,9 +2010,8 @@ public class GNUCSourceParser extends AbstractGNUSourceCodeParser {
|
||||||
|
|
||||||
if (if_statement != null) {
|
if (if_statement != null) {
|
||||||
if_statement.setElseClause(new_if_statement);
|
if_statement.setElseClause(new_if_statement);
|
||||||
((ASTNode) if_statement)
|
((ASTNode) if_statement).setLength(calculateEndOffset(new_if_statement)
|
||||||
.setLength(calculateEndOffset(new_if_statement)
|
- ((ASTNode) if_statement).getOffset());
|
||||||
- ((ASTNode) if_statement).getOffset());
|
|
||||||
}
|
}
|
||||||
if (result == null && if_statement != null)
|
if (result == null && if_statement != null)
|
||||||
result = if_statement;
|
result = if_statement;
|
||||||
|
@ -2027,9 +2025,8 @@ public class GNUCSourceParser extends AbstractGNUSourceCodeParser {
|
||||||
new_if_statement.setElseClause(elseStatement);
|
new_if_statement.setElseClause(elseStatement);
|
||||||
if (if_statement != null) {
|
if (if_statement != null) {
|
||||||
if_statement.setElseClause(new_if_statement);
|
if_statement.setElseClause(new_if_statement);
|
||||||
((ASTNode) if_statement)
|
((ASTNode) if_statement).setLength(calculateEndOffset(new_if_statement)
|
||||||
.setLength(calculateEndOffset(new_if_statement)
|
- ((ASTNode) if_statement).getOffset());
|
||||||
- ((ASTNode) if_statement).getOffset());
|
|
||||||
} else {
|
} else {
|
||||||
if (result == null)
|
if (result == null)
|
||||||
result = new_if_statement;
|
result = new_if_statement;
|
||||||
|
@ -2037,12 +2034,10 @@ public class GNUCSourceParser extends AbstractGNUSourceCodeParser {
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
if( thenClause != null )
|
if( thenClause != null )
|
||||||
((ASTNode) new_if_statement)
|
((ASTNode) new_if_statement).setLength(calculateEndOffset(thenClause) - start);
|
||||||
.setLength(calculateEndOffset(thenClause) - start);
|
|
||||||
if (if_statement != null) {
|
if (if_statement != null) {
|
||||||
if_statement.setElseClause(new_if_statement);
|
if_statement.setElseClause(new_if_statement);
|
||||||
((ASTNode) new_if_statement)
|
((ASTNode) new_if_statement).setLength(calculateEndOffset(new_if_statement) - start);
|
||||||
.setLength(calculateEndOffset(new_if_statement) - start);
|
|
||||||
}
|
}
|
||||||
if (result == null && if_statement != null)
|
if (result == null && if_statement != null)
|
||||||
result = if_statement;
|
result = if_statement;
|
||||||
|
|
|
@ -6,7 +6,7 @@
|
||||||
* http://www.eclipse.org/legal/epl-v10.html
|
* http://www.eclipse.org/legal/epl-v10.html
|
||||||
*
|
*
|
||||||
* Contributors:
|
* Contributors:
|
||||||
* Markus Schorn - Initial API and implementation
|
* Markus Schorn - Initial API and implementation
|
||||||
*******************************************************************************/
|
*******************************************************************************/
|
||||||
package org.eclipse.cdt.internal.core.dom.parser.cpp;
|
package org.eclipse.cdt.internal.core.dom.parser.cpp;
|
||||||
|
|
||||||
|
@ -29,15 +29,14 @@ import org.eclipse.core.runtime.Assert;
|
||||||
* <br>
|
* <br>
|
||||||
* Example: void f(int (D)); // is D a type?
|
* Example: void f(int (D)); // is D a type?
|
||||||
*/
|
*/
|
||||||
public class CPPASTAmbiguousDeclarator extends ASTAmbiguousNode implements IASTAmbiguousDeclarator, ICPPASTDeclarator {
|
public class CPPASTAmbiguousDeclarator extends ASTAmbiguousNode
|
||||||
|
implements IASTAmbiguousDeclarator, ICPPASTDeclarator {
|
||||||
private IASTDeclarator[] dtors = new IASTDeclarator[2];
|
private IASTDeclarator[] dtors = new IASTDeclarator[2];
|
||||||
private int dtorPos=-1;
|
private int dtorPos= -1;
|
||||||
private IASTInitializer fInitializer;
|
private IASTInitializer fInitializer;
|
||||||
|
|
||||||
|
|
||||||
public CPPASTAmbiguousDeclarator(IASTDeclarator... decls) {
|
public CPPASTAmbiguousDeclarator(IASTDeclarator... decls) {
|
||||||
for(IASTDeclarator d : decls) {
|
for (IASTDeclarator d : decls) {
|
||||||
if (d != null) {
|
if (d != null) {
|
||||||
addDeclarator(d);
|
addDeclarator(d);
|
||||||
}
|
}
|
||||||
|
|
|
@ -6,9 +6,9 @@
|
||||||
* http://www.eclipse.org/legal/epl-v10.html
|
* http://www.eclipse.org/legal/epl-v10.html
|
||||||
*
|
*
|
||||||
* Contributors:
|
* Contributors:
|
||||||
* IBM - Initial API and implementation
|
* IBM - Initial API and implementation
|
||||||
* Anton Leherbauer (Wind River Systems)
|
* Anton Leherbauer (Wind River Systems)
|
||||||
* Markus Schorn (Wind River Systems)
|
* Markus Schorn (Wind River Systems)
|
||||||
*******************************************************************************/
|
*******************************************************************************/
|
||||||
package org.eclipse.cdt.internal.core.dom.parser.cpp;
|
package org.eclipse.cdt.internal.core.dom.parser.cpp;
|
||||||
|
|
||||||
|
@ -16,7 +16,7 @@ import org.eclipse.cdt.core.dom.ast.ASTVisitor;
|
||||||
import org.eclipse.cdt.internal.core.dom.parser.ASTProblem;
|
import org.eclipse.cdt.internal.core.dom.parser.ASTProblem;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* cpp-specific implementation allows actions to visit the problem.
|
* C++-specific implementation allows actions to visit the problem.
|
||||||
*/
|
*/
|
||||||
public class CPPASTProblem extends ASTProblem {
|
public class CPPASTProblem extends ASTProblem {
|
||||||
|
|
||||||
|
@ -41,19 +41,19 @@ public class CPPASTProblem extends ASTProblem {
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean accept( ASTVisitor action ){
|
public boolean accept(ASTVisitor action) {
|
||||||
if( action.shouldVisitProblems ){
|
if (action.shouldVisitProblems) {
|
||||||
switch( action.visit( this ) ){
|
switch (action.visit(this)) {
|
||||||
case ASTVisitor.PROCESS_ABORT : return false;
|
case ASTVisitor.PROCESS_ABORT: return false;
|
||||||
case ASTVisitor.PROCESS_SKIP : return true;
|
case ASTVisitor.PROCESS_SKIP: return true;
|
||||||
default : break;
|
default: break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if( action.shouldVisitProblems ){
|
if (action.shouldVisitProblems) {
|
||||||
switch( action.leave( this ) ){
|
switch (action.leave(this)) {
|
||||||
case ASTVisitor.PROCESS_ABORT : return false;
|
case ASTVisitor.PROCESS_ABORT: return false;
|
||||||
case ASTVisitor.PROCESS_SKIP : return true;
|
case ASTVisitor.PROCESS_SKIP: return true;
|
||||||
default : break;
|
default: break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return true;
|
return true;
|
||||||
|
|
|
@ -27,8 +27,8 @@ import org.eclipse.cdt.internal.core.dom.parser.IASTAmbiguityParent;
|
||||||
public class CPPASTWhileStatement extends ASTNode
|
public class CPPASTWhileStatement extends ASTNode
|
||||||
implements ICPPASTWhileStatement, IASTAmbiguityParent {
|
implements ICPPASTWhileStatement, IASTAmbiguityParent {
|
||||||
private IASTExpression condition;
|
private IASTExpression condition;
|
||||||
private IASTStatement body;
|
|
||||||
private IASTDeclaration condition2;
|
private IASTDeclaration condition2;
|
||||||
|
private IASTStatement body;
|
||||||
private IScope scope;
|
private IScope scope;
|
||||||
|
|
||||||
public CPPASTWhileStatement() {
|
public CPPASTWhileStatement() {
|
||||||
|
@ -118,17 +118,16 @@ public class CPPASTWhileStatement extends ASTNode
|
||||||
default: break;
|
default: break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (condition != null && !condition.accept(action)) return false;
|
if (condition != null && !condition.accept(action))
|
||||||
if (condition2 != null && !condition2.accept(action)) return false;
|
return false;
|
||||||
if (body != null && !body.accept(action)) return false;
|
if (condition2 != null && !condition2.accept(action))
|
||||||
|
return false;
|
||||||
|
if (body != null && !body.accept(action))
|
||||||
|
return false;
|
||||||
|
|
||||||
if (action.shouldVisitExpressions) {
|
if (action.shouldVisitStatements && action.leave(this) == ASTVisitor.PROCESS_ABORT)
|
||||||
switch (action.leave(this)) {
|
return false;
|
||||||
case ASTVisitor.PROCESS_ABORT: return false;
|
|
||||||
case ASTVisitor.PROCESS_SKIP: return true;
|
|
||||||
default: break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -2454,7 +2454,7 @@ public class GNUCPPSourceParser extends AbstractGNUSourceCodeParser {
|
||||||
IASTDeclarator outerDtor) throws EndOfFileException, BacktrackException {
|
IASTDeclarator outerDtor) throws EndOfFileException, BacktrackException {
|
||||||
|
|
||||||
final IASTDeclarator dtor= ASTQueries.findTypeRelevantDeclarator(outerDtor);
|
final IASTDeclarator dtor= ASTQueries.findTypeRelevantDeclarator(outerDtor);
|
||||||
if (dtor instanceof ICPPASTFunctionDeclarator == false)
|
if (!(dtor instanceof ICPPASTFunctionDeclarator))
|
||||||
throwBacktrack(firstOffset, LA(1).getEndOffset() - firstOffset);
|
throwBacktrack(firstOffset, LA(1).getEndOffset() - firstOffset);
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -6,8 +6,8 @@
|
||||||
* http://www.eclipse.org/legal/epl-v10.html
|
* http://www.eclipse.org/legal/epl-v10.html
|
||||||
*
|
*
|
||||||
* Contributors:
|
* Contributors:
|
||||||
* Markus Schorn - initial API and implementation
|
* Markus Schorn - initial API and implementation
|
||||||
*******************************************************************************/
|
*******************************************************************************/
|
||||||
package org.eclipse.cdt.internal.core.dom.rewrite;
|
package org.eclipse.cdt.internal.core.dom.rewrite;
|
||||||
|
|
||||||
import org.eclipse.cdt.core.dom.ast.IASTTranslationUnit;
|
import org.eclipse.cdt.core.dom.ast.IASTTranslationUnit;
|
||||||
|
@ -20,7 +20,8 @@ import org.eclipse.ltk.core.refactoring.TextFileChange;
|
||||||
public class ASTRewriteAnalyzer {
|
public class ASTRewriteAnalyzer {
|
||||||
private static ICTextFileChangeFactory sFileChangeFactory;
|
private static ICTextFileChangeFactory sFileChangeFactory;
|
||||||
|
|
||||||
public static Change rewriteAST(IASTTranslationUnit root, ASTModificationStore modificationStore, NodeCommentMap commentMap) {
|
public static Change rewriteAST(IASTTranslationUnit root, ASTModificationStore modificationStore,
|
||||||
|
NodeCommentMap commentMap) {
|
||||||
ChangeGenerator rewriter = new ChangeGenerator(modificationStore, commentMap);
|
ChangeGenerator rewriter = new ChangeGenerator(modificationStore, commentMap);
|
||||||
rewriter.generateChange(root);
|
rewriter.generateChange(root);
|
||||||
return rewriter.getChange();
|
return rewriter.getChange();
|
||||||
|
@ -29,7 +30,7 @@ public class ASTRewriteAnalyzer {
|
||||||
public static void setCTextFileChangeFactory(ICTextFileChangeFactory factory) {
|
public static void setCTextFileChangeFactory(ICTextFileChangeFactory factory) {
|
||||||
sFileChangeFactory= factory;
|
sFileChangeFactory= factory;
|
||||||
}
|
}
|
||||||
|
|
||||||
public static TextFileChange createCTextFileChange(IFile file) {
|
public static TextFileChange createCTextFileChange(IFile file) {
|
||||||
if (sFileChangeFactory == null) {
|
if (sFileChangeFactory == null) {
|
||||||
return new TextFileChange(file.getName(), file);
|
return new TextFileChange(file.getName(), file);
|
||||||
|
|
|
@ -72,6 +72,8 @@ import org.eclipse.jface.text.TextUtilities;
|
||||||
import org.eclipse.ltk.core.refactoring.Change;
|
import org.eclipse.ltk.core.refactoring.Change;
|
||||||
import org.eclipse.ltk.core.refactoring.CompositeChange;
|
import org.eclipse.ltk.core.refactoring.CompositeChange;
|
||||||
import org.eclipse.ltk.core.refactoring.TextFileChange;
|
import org.eclipse.ltk.core.refactoring.TextFileChange;
|
||||||
|
import org.eclipse.text.edits.DeleteEdit;
|
||||||
|
import org.eclipse.text.edits.InsertEdit;
|
||||||
import org.eclipse.text.edits.MalformedTreeException;
|
import org.eclipse.text.edits.MalformedTreeException;
|
||||||
import org.eclipse.text.edits.MultiTextEdit;
|
import org.eclipse.text.edits.MultiTextEdit;
|
||||||
import org.eclipse.text.edits.ReplaceEdit;
|
import org.eclipse.text.edits.ReplaceEdit;
|
||||||
|
@ -312,6 +314,37 @@ public class ChangeGenerator extends ASTVisitor {
|
||||||
return super.leave(statement);
|
return super.leave(statement);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private void addChildEdit(TextEdit edit) {
|
||||||
|
rootEdit.addChild(edit);
|
||||||
|
processedOffset = edit.getExclusiveEnd();
|
||||||
|
}
|
||||||
|
|
||||||
|
private TextEdit clippedEdit(TextEdit edit, IRegion region) {
|
||||||
|
if ((edit.getOffset() < region.getOffset() && edit.getExclusiveEnd() <= region.getOffset()) ||
|
||||||
|
edit.getOffset() >= endOffset(region)) {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
int offset = Math.max(edit.getOffset(), region.getOffset());
|
||||||
|
int length = Math.min(endOffset(edit), endOffset(region)) - offset;
|
||||||
|
if (offset == edit.getOffset() && length == edit.getLength()) {
|
||||||
|
// InsertEdit always satisfies the above condition.
|
||||||
|
return edit;
|
||||||
|
}
|
||||||
|
if (edit instanceof DeleteEdit) {
|
||||||
|
return new DeleteEdit(offset, length);
|
||||||
|
} if (edit instanceof ReplaceEdit) {
|
||||||
|
String replacement = ((ReplaceEdit) edit).getText();
|
||||||
|
int start = Math.max(offset - edit.getOffset(), 0);
|
||||||
|
int end = Math.min(endOffset(region) - offset, replacement.length());
|
||||||
|
if (end <= start) {
|
||||||
|
return new DeleteEdit(offset, length);
|
||||||
|
}
|
||||||
|
return new ReplaceEdit(offset, length, replacement.substring(start, end));
|
||||||
|
} else {
|
||||||
|
throw new IllegalArgumentException("Unexpected edit type: " + edit.getClass().getSimpleName()); //$NON-NLS-1$
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Applies the C++ code formatter to the code affected by refactoring.
|
* Applies the C++ code formatter to the code affected by refactoring.
|
||||||
*
|
*
|
||||||
|
@ -321,47 +354,40 @@ public class ChangeGenerator extends ASTVisitor {
|
||||||
private void formatChangedCode(String code, ITranslationUnit tu) {
|
private void formatChangedCode(String code, ITranslationUnit tu) {
|
||||||
IDocument document = new Document(code);
|
IDocument document = new Document(code);
|
||||||
try {
|
try {
|
||||||
// Apply refactoring changes to a temporary document.
|
|
||||||
TextEdit edit = rootEdit.copy();
|
TextEdit edit = rootEdit.copy();
|
||||||
|
// Apply refactoring changes to a temporary document.
|
||||||
edit.apply(document, TextEdit.UPDATE_REGIONS);
|
edit.apply(document, TextEdit.UPDATE_REGIONS);
|
||||||
|
|
||||||
// Expand regions affected by the changes to cover complete lines. We calculate two
|
// Expand regions affected by the changes to cover complete lines. We calculate two
|
||||||
// sets of regions, reflecting the state of the document before and after
|
// sets of regions, reflecting the state of the document before and after
|
||||||
// the refactoring changes.
|
// the refactoring changes.
|
||||||
TextEdit[] edits = edit.getChildren();
|
TextEdit[] appliedEdits = edit.getChildren();
|
||||||
TextEdit[] originalEdits = rootEdit.getChildren();
|
TextEdit[] edits = rootEdit.removeChildren();
|
||||||
IRegion[] regionsAfter = new IRegion[edits.length];
|
IRegion[] regions = new IRegion[appliedEdits.length];
|
||||||
IRegion[] regionsBefore = new IRegion[edits.length];
|
|
||||||
int numRegions = 0;
|
int numRegions = 0;
|
||||||
int prevEnd = -1;
|
int prevEnd = -1;
|
||||||
for (int i = 0; i < edits.length; i++) {
|
for (int i = 0; i < appliedEdits.length; i++) {
|
||||||
edit = edits[i];
|
edit = appliedEdits[i];
|
||||||
int offset = edit.getOffset();
|
int offset = edit.getOffset();
|
||||||
int end = offset + edit.getLength();
|
int end = offset + edit.getLength();
|
||||||
int newOffset = document.getLineInformationOfOffset(offset).getOffset();
|
int newOffset = document.getLineInformationOfOffset(offset).getOffset();
|
||||||
edit = originalEdits[i];
|
edit = edits[i];
|
||||||
int originalEnd = edit.getExclusiveEnd();
|
int originalEnd = edit.getExclusiveEnd();
|
||||||
// Expand to the end of the line unless the end of the edit region is at
|
// Expand to the end of the line unless the end of the edit region is at
|
||||||
// the beginning of line both, before and after the change.
|
// the beginning of line both, before and after the change.
|
||||||
int newEnd = (originalEnd == 0 || code.charAt(originalEnd - 1) == '\n') && end == newOffset ?
|
int newEnd = (originalEnd == 0 || code.charAt(originalEnd - 1) == '\n') && end == newOffset ?
|
||||||
end : endOffset(document.getLineInformationOfOffset(end));
|
end : endOffset(document.getLineInformationOfOffset(end));
|
||||||
int offsetBefore = edit.getOffset();
|
|
||||||
int newOffsetBefore = newOffset + offsetBefore - offset;
|
|
||||||
int newEndBefore = newEnd + offsetBefore + edit.getLength() - end;
|
|
||||||
if (newOffset <= prevEnd) {
|
if (newOffset <= prevEnd) {
|
||||||
numRegions--;
|
numRegions--;
|
||||||
newOffset = regionsAfter[numRegions].getOffset();
|
newOffset = regions[numRegions].getOffset();
|
||||||
newOffsetBefore = regionsBefore[numRegions].getOffset();
|
|
||||||
}
|
}
|
||||||
prevEnd = newEnd;
|
prevEnd = newEnd;
|
||||||
regionsAfter[numRegions] = new Region(newOffset, newEnd - newOffset);
|
regions[numRegions] = new Region(newOffset, newEnd - newOffset);
|
||||||
regionsBefore[numRegions] = new Region(newOffsetBefore, newEndBefore - newOffsetBefore);
|
|
||||||
numRegions++;
|
numRegions++;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (numRegions < regionsAfter.length) {
|
if (numRegions < regions.length) {
|
||||||
regionsAfter = Arrays.copyOf(regionsAfter, numRegions);
|
regions = Arrays.copyOf(regions, numRegions);
|
||||||
regionsBefore = Arrays.copyOf(regionsBefore, numRegions);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// Calculate formatting changes for the regions after the refactoring changes.
|
// Calculate formatting changes for the regions after the refactoring changes.
|
||||||
|
@ -374,23 +400,71 @@ public class ChangeGenerator extends ASTVisitor {
|
||||||
CodeFormatter formatter = ToolFactory.createCodeFormatter(options);
|
CodeFormatter formatter = ToolFactory.createCodeFormatter(options);
|
||||||
code = document.get();
|
code = document.get();
|
||||||
TextEdit[] formatEdits = formatter.format(CodeFormatter.K_TRANSLATION_UNIT, code,
|
TextEdit[] formatEdits = formatter.format(CodeFormatter.K_TRANSLATION_UNIT, code,
|
||||||
regionsAfter, TextUtilities.getDefaultLineDelimiter(document));
|
regions, TextUtilities.getDefaultLineDelimiter(document));
|
||||||
|
|
||||||
// For each of the regions we apply formatting changes and create a ReplaceEdit using
|
TextEdit combinedFormatEdit = new MultiTextEdit();
|
||||||
// the region before the refactoring changes and the text after the formatting changes.
|
for (TextEdit formatEdit : formatEdits) {
|
||||||
MultiTextEdit resultEdit = new MultiTextEdit();
|
combinedFormatEdit = TextEditUtil.merge(combinedFormatEdit, formatEdit);
|
||||||
for (int i = 0; i < regionsAfter.length; i++) {
|
|
||||||
IRegion region = regionsAfter[i];
|
|
||||||
int offset = region.getOffset();
|
|
||||||
edit = formatEdits[i];
|
|
||||||
edit.moveTree(-offset);
|
|
||||||
document = new Document(code.substring(offset, offset + region.getLength()));
|
|
||||||
edit.apply(document, TextEdit.NONE);
|
|
||||||
region = regionsBefore[i];
|
|
||||||
edit = new ReplaceEdit(region.getOffset(), region.getLength(), document.get());
|
|
||||||
resultEdit.addChild(edit);
|
|
||||||
}
|
}
|
||||||
rootEdit = resultEdit;
|
formatEdits = TextEditUtil.flatten(combinedFormatEdit).removeChildren();
|
||||||
|
|
||||||
|
MultiTextEdit result = new MultiTextEdit();
|
||||||
|
int delta = 0;
|
||||||
|
TextEdit edit1 = null;
|
||||||
|
TextEdit edit2 = null;
|
||||||
|
int i = 0;
|
||||||
|
int j = 0;
|
||||||
|
while (true) {
|
||||||
|
if (edit1 == null && i < edits.length)
|
||||||
|
edit1 = edits[i++];
|
||||||
|
if (edit2 == null && j < formatEdits.length)
|
||||||
|
edit2 = formatEdits[j++];
|
||||||
|
if (edit1 == null) {
|
||||||
|
if (edit2 == null)
|
||||||
|
break;
|
||||||
|
edit2.moveTree(-delta);
|
||||||
|
result.addChild(edit2);
|
||||||
|
edit2 = null;
|
||||||
|
} else if (edit2 == null) {
|
||||||
|
delta += TextEditUtil.delta(edit1);
|
||||||
|
result.addChild(edit1);
|
||||||
|
edit1 = null;
|
||||||
|
} else {
|
||||||
|
if (edit2.getExclusiveEnd() - delta <= edit1.getOffset()) {
|
||||||
|
edit2.moveTree(-delta);
|
||||||
|
result.addChild(edit2);
|
||||||
|
edit2 = null;
|
||||||
|
} else {
|
||||||
|
TextEdit piece = clippedEdit(edit2, new Region(-1, edit1.getOffset() + delta));
|
||||||
|
if (piece != null) {
|
||||||
|
piece.moveTree(-delta);
|
||||||
|
result.addChild(piece);
|
||||||
|
}
|
||||||
|
int d = TextEditUtil.delta(edit1);
|
||||||
|
Region region = new Region(edit1.getOffset() + delta, edit1.getLength() + d);
|
||||||
|
int end = endOffset(region);
|
||||||
|
MultiTextEdit format = new MultiTextEdit();
|
||||||
|
while ((piece = clippedEdit(edit2, region)) != null) {
|
||||||
|
format.addChild(piece);
|
||||||
|
// The warning "The variable edit2 may be null at this location" is bogus.
|
||||||
|
if (edit2.getExclusiveEnd() >= end || j >= formatEdits.length) {
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
edit2 = formatEdits[j++];
|
||||||
|
}
|
||||||
|
if (format.hasChildren()) {
|
||||||
|
format.moveTree(-delta);
|
||||||
|
edit1 = applyEdit(format, edit1);
|
||||||
|
}
|
||||||
|
delta += d;
|
||||||
|
result.addChild(edit1);
|
||||||
|
edit1 = null;
|
||||||
|
|
||||||
|
edit2 = clippedEdit(edit2, new Region(end, Integer.MAX_VALUE - end));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
rootEdit = result;
|
||||||
} catch (MalformedTreeException e) {
|
} catch (MalformedTreeException e) {
|
||||||
CCorePlugin.log(e);
|
CCorePlugin.log(e);
|
||||||
} catch (BadLocationException e) {
|
} catch (BadLocationException e) {
|
||||||
|
@ -398,10 +472,39 @@ public class ChangeGenerator extends ASTVisitor {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Applies source edit to the target one and returns the combined edit.
|
||||||
|
*/
|
||||||
|
private TextEdit applyEdit(TextEdit source, TextEdit target)
|
||||||
|
throws MalformedTreeException, BadLocationException {
|
||||||
|
source.moveTree(-target.getOffset());
|
||||||
|
String text;
|
||||||
|
if (target instanceof InsertEdit) {
|
||||||
|
text = ((InsertEdit) target).getText();
|
||||||
|
} else if (target instanceof ReplaceEdit) {
|
||||||
|
text = ((ReplaceEdit) target).getText();
|
||||||
|
} else {
|
||||||
|
text = ""; //$NON-NLS-1$
|
||||||
|
}
|
||||||
|
|
||||||
|
IDocument document = new Document(text);
|
||||||
|
source.apply(document, TextEdit.NONE);
|
||||||
|
text = document.get();
|
||||||
|
if (target.getLength() == 0) {
|
||||||
|
return new InsertEdit(target.getOffset(), text);
|
||||||
|
} else {
|
||||||
|
return new ReplaceEdit(target.getOffset(), target.getLength(), text);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
private int endOffset(IRegion region) {
|
private int endOffset(IRegion region) {
|
||||||
return region.getOffset() + region.getLength();
|
return region.getOffset() + region.getLength();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private int endOffset(TextEdit edit) {
|
||||||
|
return edit.getOffset() + edit.getLength();
|
||||||
|
}
|
||||||
|
|
||||||
private int endOffset(IASTFileLocation nodeLocation) {
|
private int endOffset(IASTFileLocation nodeLocation) {
|
||||||
return nodeLocation.getNodeOffset() + nodeLocation.getNodeLength();
|
return nodeLocation.getNodeOffset() + nodeLocation.getNodeLength();
|
||||||
}
|
}
|
||||||
|
@ -451,21 +554,23 @@ public class ChangeGenerator extends ASTVisitor {
|
||||||
insertPos = skipPrecedingBlankLines(tuCode, insertPos);
|
insertPos = skipPrecedingBlankLines(tuCode, insertPos);
|
||||||
length -= insertPos;
|
length -= insertPos;
|
||||||
}
|
}
|
||||||
String code = writer.toString();
|
|
||||||
ReplaceEdit edit = new ReplaceEdit(insertPos, length, code);
|
|
||||||
addToRootEdit(anchorNode);
|
addToRootEdit(anchorNode);
|
||||||
rootEdit.addChild(edit);
|
String code = writer.toString();
|
||||||
processedOffset = edit.getOffset();
|
if (!code.isEmpty())
|
||||||
|
addChildEdit(new InsertEdit(insertPos, code));
|
||||||
|
if (length != 0)
|
||||||
|
addChildEdit(new DeleteEdit(insertPos, length));
|
||||||
}
|
}
|
||||||
|
|
||||||
private void handleReplace(IASTNode node) {
|
private void handleReplace(IASTNode node) {
|
||||||
List<ASTModification> modifications = getModifications(node, ModificationKind.REPLACE);
|
List<ASTModification> modifications = getModifications(node, ModificationKind.REPLACE);
|
||||||
String source = node.getTranslationUnit().getRawSignature();
|
String source = node.getTranslationUnit().getRawSignature();
|
||||||
TextEdit edit;
|
|
||||||
ChangeGeneratorWriterVisitor writer =
|
ChangeGeneratorWriterVisitor writer =
|
||||||
new ChangeGeneratorWriterVisitor(modificationStore, commentMap);
|
new ChangeGeneratorWriterVisitor(modificationStore, commentMap);
|
||||||
IASTFileLocation fileLocation = node.getFileLocation();
|
IASTFileLocation fileLocation = node.getFileLocation();
|
||||||
|
addToRootEdit(node);
|
||||||
if (modifications.size() == 1 && modifications.get(0).getNewNode() == null) {
|
if (modifications.size() == 1 && modifications.get(0).getNewNode() == null) {
|
||||||
|
// There is no replacement. We are deleting a piece of existing code.
|
||||||
int offset = getOffsetIncludingComments(node);
|
int offset = getOffsetIncludingComments(node);
|
||||||
int endOffset = getEndOffsetIncludingComments(node);
|
int endOffset = getEndOffsetIncludingComments(node);
|
||||||
offset = Math.max(skipPrecedingBlankLines(source, offset), processedOffset);
|
offset = Math.max(skipPrecedingBlankLines(source, offset), processedOffset);
|
||||||
|
@ -492,25 +597,27 @@ public class ChangeGenerator extends ASTVisitor {
|
||||||
writer.newLine();
|
writer.newLine();
|
||||||
}
|
}
|
||||||
String code = writer.toString();
|
String code = writer.toString();
|
||||||
edit = new ReplaceEdit(offset, endOffset - offset, code);
|
if (endOffset > offset)
|
||||||
|
addChildEdit(new DeleteEdit(offset, endOffset - offset));
|
||||||
|
if (!code.isEmpty())
|
||||||
|
addChildEdit(new InsertEdit(endOffset, code));
|
||||||
} else {
|
} else {
|
||||||
node.accept(writer);
|
node.accept(writer);
|
||||||
String code = writer.toString();
|
String code = writer.toString();
|
||||||
int offset = fileLocation.getNodeOffset();
|
int offset = fileLocation.getNodeOffset();
|
||||||
int endOffset = offset + fileLocation.getNodeLength();
|
int endOffset = offset + fileLocation.getNodeLength();
|
||||||
if (node instanceof IASTStatement || node instanceof IASTDeclaration) {
|
|
||||||
// Include trailing comments in the area to be replaced.
|
|
||||||
endOffset = Math.max(endOffset, getEndOffsetIncludingTrailingComments(node));
|
|
||||||
}
|
|
||||||
String lineSeparator = writer.getScribe().getLineSeparator();
|
String lineSeparator = writer.getScribe().getLineSeparator();
|
||||||
if (code.endsWith(lineSeparator)) {
|
if (code.endsWith(lineSeparator)) {
|
||||||
code = code.substring(0, code.length() - lineSeparator.length());
|
code = code.substring(0, code.length() - lineSeparator.length());
|
||||||
}
|
}
|
||||||
edit = new ReplaceEdit(offset, endOffset - offset, code);
|
addChildEdit(new ReplaceEdit(offset, endOffset - offset, code));
|
||||||
|
if (node instanceof IASTStatement || node instanceof IASTDeclaration) {
|
||||||
|
// Include trailing comments in the area to be replaced.
|
||||||
|
int commentEnd = getEndOffsetIncludingTrailingComments(node);
|
||||||
|
if (commentEnd > endOffset)
|
||||||
|
addChildEdit(new DeleteEdit(endOffset, commentEnd - endOffset));
|
||||||
|
}
|
||||||
}
|
}
|
||||||
addToRootEdit(node);
|
|
||||||
rootEdit.addChild(edit);
|
|
||||||
processedOffset = edit.getExclusiveEnd();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private void handleAppends(IASTNode node) {
|
private void handleAppends(IASTNode node) {
|
||||||
|
@ -537,13 +644,12 @@ public class ChangeGenerator extends ASTVisitor {
|
||||||
if (node instanceof ICPPASTNamespaceDefinition) {
|
if (node instanceof ICPPASTNamespaceDefinition) {
|
||||||
writer.newLine();
|
writer.newLine();
|
||||||
}
|
}
|
||||||
String code = writer.toString();
|
|
||||||
addToRootEdit(node);
|
addToRootEdit(node);
|
||||||
ReplaceEdit edit = new ReplaceEdit(anchor.getOffset(), anchor.getLength(),
|
String code = writer.toString();
|
||||||
code + anchor.getText());
|
if (!code.isEmpty())
|
||||||
rootEdit.addChild(edit);
|
addChildEdit(new InsertEdit(anchor.getOffset(), code));
|
||||||
IASTFileLocation fileLocation = node.getFileLocation();
|
addChildEdit(new ReplaceEdit(anchor.getOffset(), anchor.getLength(), anchor.getText()));
|
||||||
processedOffset = endOffset(fileLocation);
|
processedOffset = endOffset(node);
|
||||||
}
|
}
|
||||||
|
|
||||||
private void handleAppends(IASTTranslationUnit node) {
|
private void handleAppends(IASTTranslationUnit node) {
|
||||||
|
@ -565,6 +671,7 @@ public class ChangeGenerator extends ASTVisitor {
|
||||||
String source = node.getRawSignature();
|
String source = node.getRawSignature();
|
||||||
int endOffset = skipTrailingBlankLines(source, offset);
|
int endOffset = skipTrailingBlankLines(source, offset);
|
||||||
|
|
||||||
|
addToRootEdit(node);
|
||||||
ChangeGeneratorWriterVisitor writer =
|
ChangeGeneratorWriterVisitor writer =
|
||||||
new ChangeGeneratorWriterVisitor(modificationStore, commentMap);
|
new ChangeGeneratorWriterVisitor(modificationStore, commentMap);
|
||||||
IASTNode newNode = null;
|
IASTNode newNode = null;
|
||||||
|
@ -593,8 +700,10 @@ public class ChangeGenerator extends ASTVisitor {
|
||||||
}
|
}
|
||||||
|
|
||||||
String code = writer.toString();
|
String code = writer.toString();
|
||||||
addToRootEdit(node);
|
if (!code.isEmpty())
|
||||||
rootEdit.addChild(new ReplaceEdit(offset, endOffset - offset, code));
|
addChildEdit(new InsertEdit(offset, code));
|
||||||
|
if (endOffset > offset)
|
||||||
|
addChildEdit(new DeleteEdit(offset, endOffset - offset));
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
|
@ -0,0 +1,219 @@
|
||||||
|
/*******************************************************************************
|
||||||
|
* Copyright (c) 2007, 2012 IBM Corporation and others.
|
||||||
|
* All rights reserved. This program and the accompanying materials
|
||||||
|
* are made available under the terms of the Eclipse Public License v1.0
|
||||||
|
* which accompanies this distribution, and is available at
|
||||||
|
* http://www.eclipse.org/legal/epl-v10.html
|
||||||
|
*
|
||||||
|
* Contributors:
|
||||||
|
* IBM Corporation - initial API and implementation
|
||||||
|
* Sergey Prigogin (Google)
|
||||||
|
*******************************************************************************/
|
||||||
|
package org.eclipse.cdt.internal.core.dom.rewrite.changegenerator;
|
||||||
|
|
||||||
|
import org.eclipse.text.edits.CopyTargetEdit;
|
||||||
|
import org.eclipse.text.edits.DeleteEdit;
|
||||||
|
import org.eclipse.text.edits.InsertEdit;
|
||||||
|
import org.eclipse.text.edits.MalformedTreeException;
|
||||||
|
import org.eclipse.text.edits.MoveSourceEdit;
|
||||||
|
import org.eclipse.text.edits.MoveTargetEdit;
|
||||||
|
import org.eclipse.text.edits.MultiTextEdit;
|
||||||
|
import org.eclipse.text.edits.ReplaceEdit;
|
||||||
|
import org.eclipse.text.edits.TextEdit;
|
||||||
|
|
||||||
|
public class TextEditUtil {
|
||||||
|
// Do not instantiate. All methods are static.
|
||||||
|
private TextEditUtil() {
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Degenerates the given edit tree into a list.<br>
|
||||||
|
* All nodes of the result are leafs.<br>
|
||||||
|
* <strong>The given edit is modified and can no longer be used.</strong>
|
||||||
|
*
|
||||||
|
* @param edit the edit tree to flatten
|
||||||
|
* @return a MultiTextEdit containing the list of edits
|
||||||
|
*/
|
||||||
|
public static MultiTextEdit flatten(TextEdit edit) {
|
||||||
|
MultiTextEdit result= new MultiTextEdit();
|
||||||
|
flatten(edit, result);
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
|
private static void flatten(TextEdit edit, MultiTextEdit result) {
|
||||||
|
if (edit.hasChildren()) {
|
||||||
|
TextEdit[] children= edit.getChildren();
|
||||||
|
for (int i= 0; i < children.length; i++) {
|
||||||
|
TextEdit child= children[i];
|
||||||
|
child.getParent().removeChild(0);
|
||||||
|
flatten(child, result);
|
||||||
|
}
|
||||||
|
} else if (!(edit instanceof MultiTextEdit)) {
|
||||||
|
result.addChild(edit);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Create an edit which contains <code>edit1</code> and <code>edit2</code>
|
||||||
|
* <p><strong>The given edits are modified and they can no longer be used.</strong></p>
|
||||||
|
*
|
||||||
|
* @param edit1 the edit to merge with edit2
|
||||||
|
* @param edit2 the edit to merge with edit1
|
||||||
|
* @return the merged tree
|
||||||
|
* @throws MalformedTreeException if the two edits ovelap
|
||||||
|
*/
|
||||||
|
public static TextEdit merge(TextEdit edit1, TextEdit edit2) {
|
||||||
|
if (edit1 instanceof MultiTextEdit && !edit1.hasChildren()) {
|
||||||
|
return edit2;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (edit2 instanceof MultiTextEdit && !edit2.hasChildren()) {
|
||||||
|
return edit1;
|
||||||
|
}
|
||||||
|
|
||||||
|
MultiTextEdit result= new MultiTextEdit();
|
||||||
|
merge(edit1, edit2, result);
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
|
private static void merge(TextEdit edit1, TextEdit edit2, MultiTextEdit result) {
|
||||||
|
if (edit1 instanceof MultiTextEdit && edit2 instanceof MultiTextEdit) {
|
||||||
|
MultiTextEdit multiTextEdit1= (MultiTextEdit) edit1;
|
||||||
|
if (!multiTextEdit1.hasChildren()) {
|
||||||
|
result.addChild(edit2);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
MultiTextEdit multiTextEdit2= (MultiTextEdit) edit2;
|
||||||
|
if (!multiTextEdit2.hasChildren()) {
|
||||||
|
result.addChild(edit1);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
TextEdit[] children1= multiTextEdit1.getChildren();
|
||||||
|
TextEdit[] children2= multiTextEdit2.getChildren();
|
||||||
|
|
||||||
|
int i1= 0;
|
||||||
|
int i2= 0;
|
||||||
|
while (i1 < children1.length && i2 < children2.length) {
|
||||||
|
while (i1 < children1.length && children1[i1].getExclusiveEnd() < children2[i2].getOffset()) {
|
||||||
|
edit1.removeChild(0);
|
||||||
|
result.addChild(children1[i1]);
|
||||||
|
i1++;
|
||||||
|
}
|
||||||
|
if (i1 >= children1.length)
|
||||||
|
break;
|
||||||
|
|
||||||
|
while (i2 < children2.length && children2[i2].getExclusiveEnd() < children1[i1].getOffset()) {
|
||||||
|
edit2.removeChild(0);
|
||||||
|
result.addChild(children2[i2]);
|
||||||
|
i2++;
|
||||||
|
}
|
||||||
|
if (i2 >= children2.length)
|
||||||
|
break;
|
||||||
|
|
||||||
|
if (children1[i1].getExclusiveEnd() < children2[i2].getOffset())
|
||||||
|
continue;
|
||||||
|
|
||||||
|
edit1.removeChild(0);
|
||||||
|
edit2.removeChild(0);
|
||||||
|
merge(children1[i1], children2[i2], result);
|
||||||
|
|
||||||
|
i1++;
|
||||||
|
i2++;
|
||||||
|
}
|
||||||
|
|
||||||
|
while (i1 < children1.length) {
|
||||||
|
edit1.removeChild(0);
|
||||||
|
result.addChild(children1[i1]);
|
||||||
|
i1++;
|
||||||
|
}
|
||||||
|
|
||||||
|
while (i2 < children2.length) {
|
||||||
|
edit2.removeChild(0);
|
||||||
|
result.addChild(children2[i2]);
|
||||||
|
i2++;
|
||||||
|
}
|
||||||
|
} else if (edit1 instanceof MultiTextEdit) {
|
||||||
|
TextEdit[] children= edit1.getChildren();
|
||||||
|
|
||||||
|
int i= 0;
|
||||||
|
while (children[i].getExclusiveEnd() < edit2.getOffset()) {
|
||||||
|
edit1.removeChild(0);
|
||||||
|
result.addChild(children[i]);
|
||||||
|
i++;
|
||||||
|
if (i >= children.length) {
|
||||||
|
result.addChild(edit2);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
edit1.removeChild(0);
|
||||||
|
merge(children[i], edit2, result);
|
||||||
|
i++;
|
||||||
|
while (i < children.length) {
|
||||||
|
edit1.removeChild(0);
|
||||||
|
result.addChild(children[i]);
|
||||||
|
i++;
|
||||||
|
}
|
||||||
|
} else if (edit2 instanceof MultiTextEdit) {
|
||||||
|
TextEdit[] children= edit2.getChildren();
|
||||||
|
|
||||||
|
int i= 0;
|
||||||
|
while (children[i].getExclusiveEnd() < edit1.getOffset()) {
|
||||||
|
edit2.removeChild(0);
|
||||||
|
result.addChild(children[i]);
|
||||||
|
i++;
|
||||||
|
if (i >= children.length) {
|
||||||
|
result.addChild(edit1);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
edit2.removeChild(0);
|
||||||
|
merge(edit1, children[i], result);
|
||||||
|
i++;
|
||||||
|
while (i < children.length) {
|
||||||
|
edit2.removeChild(0);
|
||||||
|
result.addChild(children[i]);
|
||||||
|
i++;
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
if (edit1.getExclusiveEnd() < edit2.getOffset()) {
|
||||||
|
result.addChild(edit1);
|
||||||
|
result.addChild(edit2);
|
||||||
|
} else {
|
||||||
|
result.addChild(edit2);
|
||||||
|
result.addChild(edit1);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Returns the difference in the document length caused by the edit. {@code InsertEdit}s have
|
||||||
|
* positive delta, {@code DeleteEdit}s have negative one.
|
||||||
|
* @param edit the edit to determine delta for.
|
||||||
|
* @return the delta
|
||||||
|
*/
|
||||||
|
public static int delta(TextEdit edit) {
|
||||||
|
int delta = 0;
|
||||||
|
for (TextEdit child : edit.getChildren()) {
|
||||||
|
delta += delta(child);
|
||||||
|
}
|
||||||
|
delta += ownDelta(edit);
|
||||||
|
return delta;
|
||||||
|
}
|
||||||
|
|
||||||
|
private static int ownDelta(TextEdit edit) {
|
||||||
|
if (edit instanceof DeleteEdit || edit instanceof MoveSourceEdit) {
|
||||||
|
return -edit.getLength();
|
||||||
|
} else if (edit instanceof InsertEdit) {
|
||||||
|
return ((InsertEdit) edit).getText().length();
|
||||||
|
} else if (edit instanceof ReplaceEdit) {
|
||||||
|
return ((ReplaceEdit) edit).getText().length() - edit.getLength();
|
||||||
|
} else if (edit instanceof CopyTargetEdit) {
|
||||||
|
return ((CopyTargetEdit) edit).getSourceEdit().getLength();
|
||||||
|
} else if (edit instanceof MoveTargetEdit) {
|
||||||
|
return ((MoveTargetEdit) edit).getSourceEdit().getLength();
|
||||||
|
}
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
}
|
|
@ -85,7 +85,6 @@ import org.eclipse.core.resources.IFile;
|
||||||
import org.eclipse.core.resources.IProject;
|
import org.eclipse.core.resources.IProject;
|
||||||
import org.eclipse.core.resources.IResource;
|
import org.eclipse.core.resources.IResource;
|
||||||
import org.eclipse.core.resources.IResourceChangeEvent;
|
import org.eclipse.core.resources.IResourceChangeEvent;
|
||||||
import org.eclipse.core.resources.ProjectScope;
|
|
||||||
import org.eclipse.core.resources.ResourcesPlugin;
|
import org.eclipse.core.resources.ResourcesPlugin;
|
||||||
import org.eclipse.core.runtime.CoreException;
|
import org.eclipse.core.runtime.CoreException;
|
||||||
import org.eclipse.core.runtime.IConfigurationElement;
|
import org.eclipse.core.runtime.IConfigurationElement;
|
||||||
|
@ -495,8 +494,6 @@ public class PDOMManager implements IWritableIndexManager, IListener {
|
||||||
String newid= IndexerPreferences.get(prj, IndexerPreferences.KEY_INDEXER_ID, IPDOMManager.ID_NO_INDEXER);
|
String newid= IndexerPreferences.get(prj, IndexerPreferences.KEY_INDEXER_ID, IPDOMManager.ID_NO_INDEXER);
|
||||||
Properties props= IndexerPreferences.getProperties(prj);
|
Properties props= IndexerPreferences.getProperties(prj);
|
||||||
|
|
||||||
// Workaround for https://bugs.eclipse.org/bugs/show_bug.cgi?id=359485
|
|
||||||
synchronized (new ProjectScope(prj).getNode(CCorePlugin.PLUGIN_ID)) {
|
|
||||||
synchronized (fUpdatePolicies) {
|
synchronized (fUpdatePolicies) {
|
||||||
if (fClosingProjects.contains(prj.getName())) {
|
if (fClosingProjects.contains(prj.getName())) {
|
||||||
return;
|
return;
|
||||||
|
@ -520,7 +517,7 @@ public class PDOMManager implements IWritableIndexManager, IListener {
|
||||||
}
|
}
|
||||||
enqueue(new PDOMRebuildTask(indexer));
|
enqueue(new PDOMRebuildTask(indexer));
|
||||||
}
|
}
|
||||||
}}
|
}
|
||||||
|
|
||||||
if (oldIndexer != null) {
|
if (oldIndexer != null) {
|
||||||
stopIndexer(oldIndexer);
|
stopIndexer(oldIndexer);
|
||||||
|
@ -553,8 +550,6 @@ public class PDOMManager implements IWritableIndexManager, IListener {
|
||||||
|
|
||||||
assert !Thread.holdsLock(fProjectToPDOM);
|
assert !Thread.holdsLock(fProjectToPDOM);
|
||||||
try {
|
try {
|
||||||
// Workaround for https://bugs.eclipse.org/bugs/show_bug.cgi?id=359485
|
|
||||||
synchronized (new ProjectScope(prj).getNode(CCorePlugin.PLUGIN_ID)) {
|
|
||||||
synchronized (fUpdatePolicies) {
|
synchronized (fUpdatePolicies) {
|
||||||
if (fClosingProjects.contains(name)) {
|
if (fClosingProjects.contains(name)) {
|
||||||
if (fTraceIndexerSetup)
|
if (fTraceIndexerSetup)
|
||||||
|
@ -604,14 +599,12 @@ public class PDOMManager implements IWritableIndexManager, IListener {
|
||||||
}
|
}
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
}}
|
}
|
||||||
|
|
||||||
// rebuild is required, try import first.
|
// rebuild is required, try import first.
|
||||||
TeamPDOMImportOperation operation= new TeamPDOMImportOperation(project);
|
TeamPDOMImportOperation operation= new TeamPDOMImportOperation(project);
|
||||||
operation.run(pm);
|
operation.run(pm);
|
||||||
|
|
||||||
// Workaround for https://bugs.eclipse.org/bugs/show_bug.cgi?id=359485
|
|
||||||
synchronized (new ProjectScope(prj).getNode(CCorePlugin.PLUGIN_ID)) {
|
|
||||||
synchronized (fUpdatePolicies) {
|
synchronized (fUpdatePolicies) {
|
||||||
if (fClosingProjects.contains(name)) {
|
if (fClosingProjects.contains(name)) {
|
||||||
if (fTraceIndexerSetup)
|
if (fTraceIndexerSetup)
|
||||||
|
@ -624,21 +617,23 @@ public class PDOMManager implements IWritableIndexManager, IListener {
|
||||||
registerIndexer(project, indexer);
|
registerIndexer(project, indexer);
|
||||||
final IndexUpdatePolicy policy= createPolicy(project);
|
final IndexUpdatePolicy policy= createPolicy(project);
|
||||||
policy.clearTUs();
|
policy.clearTUs();
|
||||||
policy.clearInitialFlags();
|
|
||||||
|
|
||||||
IPDOMIndexerTask task= null;
|
IPDOMIndexerTask task= null;
|
||||||
if (operation.wasSuccessful()) {
|
if (policy.isAutomatic() || policy.isInitialRebuildRequested()) {
|
||||||
if (fTraceIndexerSetup)
|
policy.clearInitialFlags();
|
||||||
System.out.println("Indexer: Imported shared index for project " + name); //$NON-NLS-1$
|
if (operation.wasSuccessful()) {
|
||||||
task= new PDOMUpdateTask(indexer,
|
if (fTraceIndexerSetup)
|
||||||
IIndexManager.UPDATE_CHECK_TIMESTAMPS | IIndexManager.UPDATE_CHECK_CONTENTS_HASH);
|
System.out.println("Indexer: Imported shared index for project " + name); //$NON-NLS-1$
|
||||||
} else {
|
task= new PDOMUpdateTask(indexer,
|
||||||
if (fTraceIndexerSetup)
|
IIndexManager.UPDATE_CHECK_TIMESTAMPS | IIndexManager.UPDATE_CHECK_CONTENTS_HASH);
|
||||||
System.out.println("Indexer: Rebuiding for project " + name); //$NON-NLS-1$
|
} else {
|
||||||
task= new PDOMRebuildTask(indexer);
|
if (fTraceIndexerSetup)
|
||||||
|
System.out.println("Indexer: Rebuiding for project " + name); //$NON-NLS-1$
|
||||||
|
task= new PDOMRebuildTask(indexer);
|
||||||
|
}
|
||||||
|
enqueue(task);
|
||||||
}
|
}
|
||||||
enqueue(task);
|
}
|
||||||
}}
|
|
||||||
} catch (CoreException e) {
|
} catch (CoreException e) {
|
||||||
// Ignore if project is no longer open
|
// Ignore if project is no longer open
|
||||||
if (prj.isOpen()) {
|
if (prj.isOpen()) {
|
||||||
|
@ -653,8 +648,7 @@ public class PDOMManager implements IWritableIndexManager, IListener {
|
||||||
IExtension indexerExt = Platform.getExtensionRegistry().getExtension(CCorePlugin.INDEXER_UNIQ_ID, indexerId);
|
IExtension indexerExt = Platform.getExtensionRegistry().getExtension(CCorePlugin.INDEXER_UNIQ_ID, indexerId);
|
||||||
if (indexerExt != null) {
|
if (indexerExt != null) {
|
||||||
IConfigurationElement[] elements = indexerExt.getConfigurationElements();
|
IConfigurationElement[] elements = indexerExt.getConfigurationElements();
|
||||||
for (int i = 0; i < elements.length; ++i) {
|
for (IConfigurationElement element : elements) {
|
||||||
IConfigurationElement element = elements[i];
|
|
||||||
if ("run".equals(element.getName())) { //$NON-NLS-1$
|
if ("run".equals(element.getName())) { //$NON-NLS-1$
|
||||||
try {
|
try {
|
||||||
indexer = (IPDOMIndexer) element.createExecutableExtension("class"); //$NON-NLS-1$
|
indexer = (IPDOMIndexer) element.createExecutableExtension("class"); //$NON-NLS-1$
|
||||||
|
|
|
@ -122,6 +122,8 @@ class ResourceLookupTree implements IResourceChangeListener, IResourceDeltaVisit
|
||||||
private boolean fNeedCleanup;
|
private boolean fNeedCleanup;
|
||||||
private Node fLastFolderNode;
|
private Node fLastFolderNode;
|
||||||
|
|
||||||
|
private boolean fTrace;
|
||||||
|
|
||||||
public ResourceLookupTree() {
|
public ResourceLookupTree() {
|
||||||
fRootNode= new Node(null, CharArrayUtils.EMPTY, false, false) {};
|
fRootNode= new Node(null, CharArrayUtils.EMPTY, false, false) {};
|
||||||
fFileExtensions= new HashMap<String, Extensions>();
|
fFileExtensions= new HashMap<String, Extensions>();
|
||||||
|
@ -133,6 +135,7 @@ class ResourceLookupTree implements IResourceChangeListener, IResourceDeltaVisit
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
fUnrefJob.setSystem(true);
|
fUnrefJob.setSystem(true);
|
||||||
|
fTrace= "true".equals(Platform.getDebugOption(CCorePlugin.PLUGIN_ID + "/debug/resourceLookup")); //$NON-NLS-1$//$NON-NLS-2$
|
||||||
}
|
}
|
||||||
|
|
||||||
public void startup() {
|
public void startup() {
|
||||||
|
@ -265,14 +268,36 @@ class ResourceLookupTree implements IResourceChangeListener, IResourceDeltaVisit
|
||||||
createFileNode(res.getFullPath(), null);
|
createFileNode(res.getFullPath(), null);
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
|
long time=0, count=0;
|
||||||
|
final boolean trace = fTrace && res instanceof IProject;
|
||||||
|
if (trace) {
|
||||||
|
time= System.currentTimeMillis();
|
||||||
|
count= countNodes();
|
||||||
|
}
|
||||||
try {
|
try {
|
||||||
res.accept(this, 0);
|
res.accept(this, 0);
|
||||||
} catch (CoreException e) {
|
} catch (CoreException e) {
|
||||||
CCorePlugin.log(e);
|
CCorePlugin.log(e);
|
||||||
}
|
}
|
||||||
|
if (trace) {
|
||||||
|
System.out.println("Built file lookup tree for " + res.getName() + ", took " + //$NON-NLS-1$//$NON-NLS-2$
|
||||||
|
(System.currentTimeMillis() - time) + "ms to add " + (countNodes()-count) + " nodes."); //$NON-NLS-1$ //$NON-NLS-2$
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private long countNodes() {
|
||||||
|
long result= 0;
|
||||||
|
for (Object node : fNodeMap.values()) {
|
||||||
|
if (node instanceof Node[]) {
|
||||||
|
result += ((Node[]) node).length;
|
||||||
|
} else {
|
||||||
|
result++;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Add a resource tree by using a resource proxy visitor.
|
* Add a resource tree by using a resource proxy visitor.
|
||||||
*/
|
*/
|
||||||
|
|
|
@ -128,7 +128,7 @@ public class Scribe {
|
||||||
indentationLevel= preferences.initial_indentation_level * indentationSize;
|
indentationLevel= preferences.initial_indentation_level * indentationSize;
|
||||||
preserveNewLines = false;
|
preserveNewLines = false;
|
||||||
textRegionStart= offset;
|
textRegionStart= offset;
|
||||||
textRegionEnd= offset + length - 1;
|
textRegionEnd= offset + length;
|
||||||
reset();
|
reset();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -574,12 +574,12 @@ public class Scribe {
|
||||||
|
|
||||||
public TextEdit getRootEdit() {
|
public TextEdit getRootEdit() {
|
||||||
MultiTextEdit edit= null;
|
MultiTextEdit edit= null;
|
||||||
int length= textRegionEnd - textRegionStart + 1;
|
int length= textRegionEnd - textRegionStart;
|
||||||
if (textRegionStart <= 0) {
|
if (textRegionStart <= 0) {
|
||||||
if (length <= 0) {
|
if (length <= 0) {
|
||||||
edit= new MultiTextEdit(0, 0);
|
edit= new MultiTextEdit(0, 0);
|
||||||
} else {
|
} else {
|
||||||
edit= new MultiTextEdit(0, textRegionEnd + 1);
|
edit= new MultiTextEdit(0, textRegionEnd);
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
edit= new MultiTextEdit(textRegionStart, length);
|
edit= new MultiTextEdit(textRegionStart, length);
|
||||||
|
@ -595,7 +595,7 @@ public class Scribe {
|
||||||
}
|
}
|
||||||
|
|
||||||
public void handleLineTooLong() {
|
public void handleLineTooLong() {
|
||||||
// Search for closest breakable alignment, using tie break rules.
|
// Search for closest breakable alignment, using tie-breaking rules.
|
||||||
// Look for innermost breakable one.
|
// Look for innermost breakable one.
|
||||||
int relativeDepth= 0;
|
int relativeDepth= 0;
|
||||||
Alignment targetAlignment= currentAlignment;
|
Alignment targetAlignment= currentAlignment;
|
||||||
|
@ -621,6 +621,7 @@ public class Scribe {
|
||||||
if (outerMostDepth >= 0) {
|
if (outerMostDepth >= 0) {
|
||||||
throwAlignmentException(AlignmentException.LINE_TOO_LONG, outerMostDepth);
|
throwAlignmentException(AlignmentException.LINE_TOO_LONG, outerMostDepth);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Look for innermost breakable one but don't stop if we encounter a R_OUTERMOST
|
// Look for innermost breakable one but don't stop if we encounter a R_OUTERMOST
|
||||||
// tie-breaking rule.
|
// tie-breaking rule.
|
||||||
relativeDepth= 0;
|
relativeDepth= 0;
|
||||||
|
@ -710,7 +711,7 @@ public class Scribe {
|
||||||
final int editReplacementLength= edit.replacement.length();
|
final int editReplacementLength= edit.replacement.length();
|
||||||
final int editOffset= edit.offset;
|
final int editOffset= edit.offset;
|
||||||
if (editLength != 0) {
|
if (editLength != 0) {
|
||||||
if (textRegionStart <= editOffset && (editOffset + editLength - 1) <= textRegionEnd) {
|
if (textRegionStart <= editOffset && editOffset + editLength <= textRegionEnd) {
|
||||||
if (editReplacementLength != 0 && editLength == editReplacementLength) {
|
if (editReplacementLength != 0 && editLength == editReplacementLength) {
|
||||||
for (int i= editOffset, max= editOffset + editLength; i < max; i++) {
|
for (int i= editOffset, max= editOffset + editLength; i < max; i++) {
|
||||||
if (scanner.source[i] != edit.replacement.charAt(i - editOffset)) {
|
if (scanner.source[i] != edit.replacement.charAt(i - editOffset)) {
|
||||||
|
@ -737,9 +738,9 @@ public class Scribe {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} else if (textRegionStart <= editOffset && editOffset <= textRegionEnd) {
|
} else if (textRegionStart <= editOffset && editOffset < textRegionEnd) {
|
||||||
return true;
|
return true;
|
||||||
} else if (editOffset == scannerEndPosition && editOffset == textRegionEnd + 1) {
|
} else if (editOffset == scannerEndPosition && editOffset == textRegionEnd) {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
return false;
|
return false;
|
||||||
|
|
|
@ -1,12 +1,12 @@
|
||||||
/*******************************************************************************
|
/*******************************************************************************
|
||||||
* Copyright (c) 2008, 2012 Institute for Software, HSR Hochschule fuer Technik
|
* Copyright (c) 2008, 2012 Institute for Software, HSR Hochschule fuer Technik
|
||||||
* Rapperswil, University of applied sciences and others
|
* Rapperswil, University of applied sciences and others
|
||||||
* All rights reserved. This program and the accompanying materials
|
* All rights reserved. This program and the accompanying materials
|
||||||
* are made available under the terms of the Eclipse Public License v1.0
|
* are made available under the terms of the Eclipse Public License v1.0
|
||||||
* which accompanies this distribution, and is available at
|
* which accompanies this distribution, and is available at
|
||||||
* http://www.eclipse.org/legal/epl-v10.html
|
* http://www.eclipse.org/legal/epl-v10.html
|
||||||
*
|
*
|
||||||
* Contributors:
|
* Contributors:
|
||||||
* Institute for Software - initial API and implementation
|
* Institute for Software - initial API and implementation
|
||||||
* Sergey Prigogin (Google)
|
* Sergey Prigogin (Google)
|
||||||
*******************************************************************************/
|
*******************************************************************************/
|
||||||
|
@ -333,7 +333,6 @@ public class ExtractLocalVariableRefactoringTest extends RefactoringTestBase {
|
||||||
}
|
}
|
||||||
|
|
||||||
//A.cpp
|
//A.cpp
|
||||||
//
|
|
||||||
//template<class T>
|
//template<class T>
|
||||||
//class Foo {
|
//class Foo {
|
||||||
//};
|
//};
|
||||||
|
@ -345,7 +344,6 @@ public class ExtractLocalVariableRefactoringTest extends RefactoringTestBase {
|
||||||
// return 0;
|
// return 0;
|
||||||
//}
|
//}
|
||||||
//====================
|
//====================
|
||||||
//
|
|
||||||
//template<class T>
|
//template<class T>
|
||||||
//class Foo {
|
//class Foo {
|
||||||
//};
|
//};
|
||||||
|
|
|
@ -51,7 +51,6 @@ import org.eclipse.cdt.internal.ui.editor.SemanticHighlightingManager.Highlighte
|
||||||
import org.eclipse.cdt.internal.ui.editor.SemanticHighlightingManager.HighlightingStyle;
|
import org.eclipse.cdt.internal.ui.editor.SemanticHighlightingManager.HighlightingStyle;
|
||||||
import org.eclipse.cdt.internal.ui.text.ICReconcilingListener;
|
import org.eclipse.cdt.internal.ui.text.ICReconcilingListener;
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Semantic highlighting reconciler - Background thread implementation.
|
* Semantic highlighting reconciler - Background thread implementation.
|
||||||
* Cloned from JDT.
|
* Cloned from JDT.
|
||||||
|
@ -59,12 +58,10 @@ import org.eclipse.cdt.internal.ui.text.ICReconcilingListener;
|
||||||
* @since 4.0
|
* @since 4.0
|
||||||
*/
|
*/
|
||||||
public class SemanticHighlightingReconciler implements ICReconcilingListener {
|
public class SemanticHighlightingReconciler implements ICReconcilingListener {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Collects positions from the AST.
|
* Collects positions from the AST.
|
||||||
*/
|
*/
|
||||||
private class PositionCollector extends ASTVisitor {
|
private class PositionCollector extends ASTVisitor {
|
||||||
|
|
||||||
/** The semantic token */
|
/** The semantic token */
|
||||||
private SemanticToken fToken= new SemanticToken();
|
private SemanticToken fToken= new SemanticToken();
|
||||||
private int fMinLocation;
|
private int fMinLocation;
|
||||||
|
@ -82,12 +79,8 @@ public class SemanticHighlightingReconciler implements ICReconcilingListener {
|
||||||
shouldVisitImplicitNameAlternates = visitImplicitNames;
|
shouldVisitImplicitNameAlternates = visitImplicitNames;
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
|
||||||
* @see org.eclipse.cdt.core.dom.ast.ASTVisitor#visit(org.eclipse.cdt.core.dom.ast.IASTTranslationUnit)
|
|
||||||
*/
|
|
||||||
@Override
|
@Override
|
||||||
public int visit(IASTTranslationUnit tu) {
|
public int visit(IASTTranslationUnit tu) {
|
||||||
|
|
||||||
// visit macro definitions
|
// visit macro definitions
|
||||||
IASTPreprocessorMacroDefinition[] macroDefs= tu.getMacroDefinitions();
|
IASTPreprocessorMacroDefinition[] macroDefs= tu.getMacroDefinitions();
|
||||||
for (IASTPreprocessorMacroDefinition macroDef : macroDefs) {
|
for (IASTPreprocessorMacroDefinition macroDef : macroDefs) {
|
||||||
|
@ -115,9 +108,6 @@ public class SemanticHighlightingReconciler implements ICReconcilingListener {
|
||||||
return super.visit(tu);
|
return super.visit(tu);
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
|
||||||
* @see org.eclipse.cdt.core.dom.ast.ASTVisitor#visit(org.eclipse.cdt.core.dom.ast.IASTDeclaration)
|
|
||||||
*/
|
|
||||||
@Override
|
@Override
|
||||||
public int visit(IASTDeclaration declaration) {
|
public int visit(IASTDeclaration declaration) {
|
||||||
if (!declaration.isPartOfTranslationUnitFile()) {
|
if (!declaration.isPartOfTranslationUnitFile()) {
|
||||||
|
@ -126,9 +116,6 @@ public class SemanticHighlightingReconciler implements ICReconcilingListener {
|
||||||
return PROCESS_CONTINUE;
|
return PROCESS_CONTINUE;
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
|
||||||
* @see org.eclipse.cdt.core.dom.ast.ASTVisitor#leave(org.eclipse.cdt.core.dom.ast.IASTDeclaration)
|
|
||||||
*/
|
|
||||||
@Override
|
@Override
|
||||||
public int leave(IASTDeclaration declaration) {
|
public int leave(IASTDeclaration declaration) {
|
||||||
// if (!shouldVisitCatchHandlers && declaration instanceof IASTFunctionDefinition) {
|
// if (!shouldVisitCatchHandlers && declaration instanceof IASTFunctionDefinition) {
|
||||||
|
@ -154,9 +141,6 @@ public class SemanticHighlightingReconciler implements ICReconcilingListener {
|
||||||
return PROCESS_CONTINUE;
|
return PROCESS_CONTINUE;
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
|
||||||
* @see org.eclipse.cdt.core.dom.ast.ASTVisitor#visit(org.eclipse.cdt.core.dom.ast.IASTDeclarator)
|
|
||||||
*/
|
|
||||||
@Override
|
@Override
|
||||||
public int visit(IASTDeclarator declarator) {
|
public int visit(IASTDeclarator declarator) {
|
||||||
// if (declarator instanceof ICPPASTFunctionTryBlockDeclarator) {
|
// if (declarator instanceof ICPPASTFunctionTryBlockDeclarator) {
|
||||||
|
@ -165,9 +149,6 @@ public class SemanticHighlightingReconciler implements ICReconcilingListener {
|
||||||
return PROCESS_CONTINUE;
|
return PROCESS_CONTINUE;
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
|
||||||
* @see org.eclipse.cdt.core.dom.ast.ASTVisitor#visit(org.eclipse.cdt.core.dom.ast.IASTStatement)
|
|
||||||
*/
|
|
||||||
@Override
|
@Override
|
||||||
public int visit(IASTStatement statement) {
|
public int visit(IASTStatement statement) {
|
||||||
// if (!shouldVisitCatchHandlers && statement instanceof ICPPASTCatchHandler) {
|
// if (!shouldVisitCatchHandlers && statement instanceof ICPPASTCatchHandler) {
|
||||||
|
@ -176,9 +157,6 @@ public class SemanticHighlightingReconciler implements ICReconcilingListener {
|
||||||
return PROCESS_CONTINUE;
|
return PROCESS_CONTINUE;
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
|
||||||
* @see org.eclipse.cdt.core.dom.ast.ASTVisitor#visit(org.eclipse.cdt.core.dom.ast.IASTName)
|
|
||||||
*/
|
|
||||||
@Override
|
@Override
|
||||||
public int visit(IASTName name) {
|
public int visit(IASTName name) {
|
||||||
if (visitNode(name)) {
|
if (visitNode(name)) {
|
||||||
|
@ -226,7 +204,7 @@ public class SemanticHighlightingReconciler implements ICReconcilingListener {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
// fallback in case no image location available
|
// Fallback in case no image location available
|
||||||
IASTNodeLocation[] nodeLocations= name.getNodeLocations();
|
IASTNodeLocation[] nodeLocations= name.getNodeLocations();
|
||||||
if (nodeLocations.length == 1 && !(nodeLocations[0] instanceof IASTMacroExpansionLocation)) {
|
if (nodeLocations.length == 1 && !(nodeLocations[0] instanceof IASTMacroExpansionLocation)) {
|
||||||
addNodeLocation(nodeLocations[0], highlightingStyle);
|
addNodeLocation(nodeLocations[0], highlightingStyle);
|
||||||
|
@ -319,20 +297,14 @@ public class SemanticHighlightingReconciler implements ICReconcilingListener {
|
||||||
/** Highlightings - cache for background thread, only valid during {@link #reconciled(IASTTranslationUnit, boolean, IProgressMonitor)} */
|
/** Highlightings - cache for background thread, only valid during {@link #reconciled(IASTTranslationUnit, boolean, IProgressMonitor)} */
|
||||||
private HighlightingStyle[] fJobHighlightings;
|
private HighlightingStyle[] fJobHighlightings;
|
||||||
|
|
||||||
/*
|
|
||||||
* @see org.eclipse.cdt.internal.ui.text.java.ICReconcilingListener#aboutToBeReconciled()
|
|
||||||
*/
|
|
||||||
@Override
|
@Override
|
||||||
public void aboutToBeReconciled() {
|
public void aboutToBeReconciled() {
|
||||||
// Do nothing
|
// Do nothing
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
|
||||||
* @see org.eclipse.cdt.internal.ui.text.ICReconcilingListener#reconciled(IASTTranslationUnit, boolean, IProgressMonitor)
|
|
||||||
*/
|
|
||||||
@Override
|
@Override
|
||||||
public void reconciled(IASTTranslationUnit ast, boolean force, IProgressMonitor progressMonitor) {
|
public void reconciled(IASTTranslationUnit ast, boolean force, IProgressMonitor progressMonitor) {
|
||||||
// ensure at most one thread can be reconciling at any time
|
// Ensure at most one thread can be reconciling at any time
|
||||||
synchronized (fReconcileLock) {
|
synchronized (fReconcileLock) {
|
||||||
if (fIsReconciling)
|
if (fIsReconciling)
|
||||||
return;
|
return;
|
||||||
|
@ -397,8 +369,8 @@ public class SemanticHighlightingReconciler implements ICReconcilingListener {
|
||||||
/**
|
/**
|
||||||
* Reconcile positions based on the AST.
|
* Reconcile positions based on the AST.
|
||||||
*
|
*
|
||||||
* @param ast the AST
|
* @param ast the AST
|
||||||
* @param visitor the AST visitor
|
* @param visitor the AST visitor
|
||||||
*/
|
*/
|
||||||
private void reconcilePositions(IASTTranslationUnit ast, PositionCollector visitor) {
|
private void reconcilePositions(IASTTranslationUnit ast, PositionCollector visitor) {
|
||||||
ast.accept(visitor);
|
ast.accept(visitor);
|
||||||
|
@ -410,12 +382,13 @@ public class SemanticHighlightingReconciler implements ICReconcilingListener {
|
||||||
newPositions.add(current);
|
newPositions.add(current);
|
||||||
}
|
}
|
||||||
fRemovedPositions= newPositions;
|
fRemovedPositions= newPositions;
|
||||||
// positions need to be sorted by ascending offset
|
// Positions need to be sorted by ascending offset
|
||||||
Collections.sort(fAddedPositions, new Comparator<Position>() {
|
Collections.sort(fAddedPositions, new Comparator<Position>() {
|
||||||
@Override
|
@Override
|
||||||
public int compare(final Position p1, final Position p2) {
|
public int compare(final Position p1, final Position p2) {
|
||||||
return p1.getOffset() - p2.getOffset();
|
return p1.getOffset() - p2.getOffset();
|
||||||
}});
|
}
|
||||||
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -450,7 +423,7 @@ public class SemanticHighlightingReconciler implements ICReconcilingListener {
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Stop reconciling positions.
|
* Stops reconciling positions.
|
||||||
*/
|
*/
|
||||||
protected void stopReconcilingPositions() {
|
protected void stopReconcilingPositions() {
|
||||||
fRemovedPositions.clear();
|
fRemovedPositions.clear();
|
||||||
|
@ -459,7 +432,7 @@ public class SemanticHighlightingReconciler implements ICReconcilingListener {
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Install this reconciler on the given editor, presenter and highlightings.
|
* Installs this reconciler on the given editor, presenter and highlightings.
|
||||||
* @param editor the editor
|
* @param editor the editor
|
||||||
* @param sourceViewer the source viewer
|
* @param sourceViewer the source viewer
|
||||||
* @param presenter the semantic highlighting presenter
|
* @param presenter the semantic highlighting presenter
|
||||||
|
@ -479,7 +452,7 @@ public class SemanticHighlightingReconciler implements ICReconcilingListener {
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Uninstall this reconciler from the editor
|
* Uninstalsl this reconciler from the editor
|
||||||
*/
|
*/
|
||||||
public void uninstall() {
|
public void uninstall() {
|
||||||
if (fPresenter != null)
|
if (fPresenter != null)
|
||||||
|
@ -496,7 +469,7 @@ public class SemanticHighlightingReconciler implements ICReconcilingListener {
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Schedule a background job for retrieving the AST and reconciling the Semantic Highlighting model.
|
* Schedules a background job for retrieving the AST and reconciling the Semantic Highlighting model.
|
||||||
*/
|
*/
|
||||||
private void scheduleJob() {
|
private void scheduleJob() {
|
||||||
final ICElement element= fEditor.getInputCElement();
|
final ICElement element= fEditor.getInputCElement();
|
||||||
|
|
|
@ -9,7 +9,6 @@
|
||||||
* IBM Corporation - initial API and implementation
|
* IBM Corporation - initial API and implementation
|
||||||
* Anton Leherbauer (Wind River Systems) - Adapted for CDT
|
* Anton Leherbauer (Wind River Systems) - Adapted for CDT
|
||||||
*******************************************************************************/
|
*******************************************************************************/
|
||||||
|
|
||||||
package org.eclipse.cdt.internal.ui.editor;
|
package org.eclipse.cdt.internal.ui.editor;
|
||||||
|
|
||||||
import org.eclipse.cdt.core.dom.ast.IASTName;
|
import org.eclipse.cdt.core.dom.ast.IASTName;
|
||||||
|
@ -24,7 +23,6 @@ import org.eclipse.cdt.core.dom.ast.IBinding;
|
||||||
* @since 4.0
|
* @since 4.0
|
||||||
*/
|
*/
|
||||||
public final class SemanticToken {
|
public final class SemanticToken {
|
||||||
|
|
||||||
/** AST node */
|
/** AST node */
|
||||||
private IASTNode fNode;
|
private IASTNode fNode;
|
||||||
|
|
||||||
|
@ -35,7 +33,7 @@ public final class SemanticToken {
|
||||||
|
|
||||||
/** AST root */
|
/** AST root */
|
||||||
private IASTTranslationUnit fRoot;
|
private IASTTranslationUnit fRoot;
|
||||||
private boolean fIsRootResolved= false;
|
private boolean fIsRootResolved;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @return Returns the binding, can be <code>null</code>.
|
* @return Returns the binding, can be <code>null</code>.
|
||||||
|
@ -44,7 +42,7 @@ public final class SemanticToken {
|
||||||
if (!fIsBindingResolved) {
|
if (!fIsBindingResolved) {
|
||||||
fIsBindingResolved= true;
|
fIsBindingResolved= true;
|
||||||
if (fNode instanceof IASTName)
|
if (fNode instanceof IASTName)
|
||||||
fBinding= ((IASTName)fNode).resolveBinding();
|
fBinding= ((IASTName) fNode).resolveBinding();
|
||||||
}
|
}
|
||||||
|
|
||||||
return fBinding;
|
return fBinding;
|
||||||
|
|
|
@ -251,7 +251,7 @@ public class ExtractFunctionInputPage extends UserInputWizardPage {
|
||||||
return;
|
return;
|
||||||
|
|
||||||
if (methodName.isEmpty()) {
|
if (methodName.isEmpty()) {
|
||||||
methodName = StubUtility.suggestMethodName("someMethodName", null, //$NON-NLS-1$
|
methodName = StubUtility.suggestMethodName("extracted", null, //$NON-NLS-1$
|
||||||
refactoring.getTranslationUnit());
|
refactoring.getTranslationUnit());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -643,8 +643,8 @@ public class ExtractFunctionRefactoring extends CRefactoring {
|
||||||
insertion = new InsertionInfo(parent, functionToExtractFrom);
|
insertion = new InsertionInfo(parent, functionToExtractFrom);
|
||||||
}
|
}
|
||||||
if (insertion.getPrologue() != null) {
|
if (insertion.getPrologue() != null) {
|
||||||
rewrite.insertBefore(insertion.getParentNode(),
|
rewrite.insertBefore(insertion.getParentNode(), insertion.getInsertBeforeNode(),
|
||||||
insertion.getInsertBeforeNode(), insertion.getPrologue(), group);
|
insertion.getPrologue(), group);
|
||||||
}
|
}
|
||||||
subRewrite = rewrite.insertBefore(insertion.getParentNode(),
|
subRewrite = rewrite.insertBefore(insertion.getParentNode(),
|
||||||
insertion.getInsertBeforeNode(), nodeToInsert, group);
|
insertion.getInsertBeforeNode(), nodeToInsert, group);
|
||||||
|
|
|
@ -120,9 +120,9 @@ public class ToggleFromImplementationToHeaderOrClassStrategy implements IToggleR
|
||||||
ICPPASTCompositeTypeSpecifier.class);
|
ICPPASTCompositeTypeSpecifier.class);
|
||||||
IASTNode parentnode = null;
|
IASTNode parentnode = null;
|
||||||
if (parent != null) {
|
if (parent != null) {
|
||||||
parentnode = parent;
|
parentnode = parent;
|
||||||
} else {
|
} else {
|
||||||
parentnode =context.getDeclarationAST();
|
parentnode = context.getDeclarationAST();
|
||||||
}
|
}
|
||||||
return parentnode;
|
return parentnode;
|
||||||
}
|
}
|
||||||
|
|
|
@ -35,8 +35,8 @@ public interface ICBreakpoint extends IBreakpoint {
|
||||||
/**
|
/**
|
||||||
* This debug model identifier can be returned by a debug implementation
|
* This debug model identifier can be returned by a debug implementation
|
||||||
* to indicate that a given debugger integration is using C Breakpoints.
|
* to indicate that a given debugger integration is using C Breakpoints.
|
||||||
* This model ID will allow breakpoint actions to configure their default
|
* This model ID will allow toggle breakpoint actions to configure their
|
||||||
* selection.
|
* default selection.
|
||||||
*
|
*
|
||||||
* @since 7.0
|
* @since 7.0
|
||||||
*/
|
*/
|
||||||
|
|
|
@ -9,4 +9,11 @@
|
||||||
</message_arguments>
|
</message_arguments>
|
||||||
</filter>
|
</filter>
|
||||||
</resource>
|
</resource>
|
||||||
|
<resource path="src/org/eclipse/cdt/debug/ui/breakpoints/ICBreakpointsUIContribution.java" type="org.eclipse.cdt.debug.ui.breakpoints.ICBreakpointsUIContribution">
|
||||||
|
<filter comment="@noimplement and @noextend attributes were previously implied in interface declaration." id="403853384">
|
||||||
|
<message_arguments>
|
||||||
|
<message_argument value="org.eclipse.cdt.debug.ui.breakpoints.ICBreakpointsUIContribution"/>
|
||||||
|
</message_arguments>
|
||||||
|
</filter>
|
||||||
|
</resource>
|
||||||
</component>
|
</component>
|
||||||
|
|
|
@ -38,7 +38,7 @@ ShowDebuggerConsoleAction.tooltip=Show Debugger Console On Target Selection
|
||||||
AddBreakpoint.label=Toggle &Breakpoint\tDouble Click
|
AddBreakpoint.label=Toggle &Breakpoint\tDouble Click
|
||||||
AddBreakpointInteractive.label=&Add Breakpoint...\tCtrl+Double Click
|
AddBreakpointInteractive.label=&Add Breakpoint...\tCtrl+Double Click
|
||||||
EnableBreakpoint.label=&Toggle Breakpoint Enabled\tShift+Double Click
|
EnableBreakpoint.label=&Toggle Breakpoint Enabled\tShift+Double Click
|
||||||
BreakpointProperties.label=Breakpoint P&roperties
|
BreakpointProperties.label=Breakpoint P&roperties...
|
||||||
RulerBreakpointProperties.label=Breakpoint P&roperties...\tCtrl+Double Click
|
RulerBreakpointProperties.label=Breakpoint P&roperties...\tCtrl+Double Click
|
||||||
BreakpointPropertiesCommand.name=C/C++ Breakpoint Properties
|
BreakpointPropertiesCommand.name=C/C++ Breakpoint Properties
|
||||||
BreakpointPropertiesCommand.description=View and edit properties for a given C/C++ breakpoint
|
BreakpointPropertiesCommand.description=View and edit properties for a given C/C++ breakpoint
|
||||||
|
|
|
@ -435,7 +435,7 @@
|
||||||
<action
|
<action
|
||||||
label="%EnableBreakpoint.label"
|
label="%EnableBreakpoint.label"
|
||||||
helpContextId="enable_disable_breakpoint_action_context"
|
helpContextId="enable_disable_breakpoint_action_context"
|
||||||
class="org.eclipse.debug.ui.actions.RulerEnableDisableBreakpointActionDelegate"
|
class="org.eclipse.cdt.debug.internal.ui.actions.breakpoints.CRulerEnableDisableBreakpointActionDelegate"
|
||||||
menubarPath="debug"
|
menubarPath="debug"
|
||||||
id="org.eclipse.cdt.debug.internal.ui.actions.EnableDisableBreakpointRulerActionDelegate">
|
id="org.eclipse.cdt.debug.internal.ui.actions.EnableDisableBreakpointRulerActionDelegate">
|
||||||
</action>
|
</action>
|
||||||
|
@ -444,14 +444,14 @@
|
||||||
helpContextId="add_breakpoint_interactive_action_context"
|
helpContextId="add_breakpoint_interactive_action_context"
|
||||||
class="org.eclipse.cdt.debug.internal.ui.actions.breakpoints.CAddBreakpointInteractiveRulerActionDelegate"
|
class="org.eclipse.cdt.debug.internal.ui.actions.breakpoints.CAddBreakpointInteractiveRulerActionDelegate"
|
||||||
menubarPath="debug"
|
menubarPath="debug"
|
||||||
id="org.eclipse.debug.ui.actions.RulerCreateBreakpointInteractiveAction">
|
id="org.eclipse.cdt.debug.ui.actions.RulerCreateBreakpointInteractiveAction">
|
||||||
</action>
|
</action>
|
||||||
<action
|
<action
|
||||||
label="%AddBreakpoint.label"
|
label="%AddBreakpoint.label"
|
||||||
helpContextId="manage_breakpoint_action_context"
|
helpContextId="manage_breakpoint_action_context"
|
||||||
class="org.eclipse.debug.ui.actions.RulerToggleBreakpointActionDelegate"
|
class="org.eclipse.cdt.debug.internal.ui.actions.breakpoints.CRulerToggleBreakpointActionDelegate"
|
||||||
menubarPath="debug"
|
menubarPath="debug"
|
||||||
id="org.eclipse.debug.ui.actions.RulerToggleBreakpointAction">
|
id="org.eclipse.cdt.debug.ui.actions.RulerToggleBreakpointAction">
|
||||||
</action>
|
</action>
|
||||||
</viewerContribution>
|
</viewerContribution>
|
||||||
<viewerContribution
|
<viewerContribution
|
||||||
|
@ -508,28 +508,28 @@
|
||||||
helpContextId="breakpoint_properties_action_context"
|
helpContextId="breakpoint_properties_action_context"
|
||||||
class="org.eclipse.cdt.debug.internal.ui.actions.breakpoints.CBreakpointPropertiesRulerActionDelegate"
|
class="org.eclipse.cdt.debug.internal.ui.actions.breakpoints.CBreakpointPropertiesRulerActionDelegate"
|
||||||
menubarPath="debug"
|
menubarPath="debug"
|
||||||
id="org.eclipse.cdt.debug.internal.ui.actions.CBreakpointPropertiesRulerActionDelegate">
|
id="org.eclipse.cdt.debug.internal.ui.actions.asm.CBreakpointPropertiesRulerActionDelegate">
|
||||||
</action>
|
</action>
|
||||||
<action
|
<action
|
||||||
label="%EnableBreakpoint.label"
|
label="%EnableBreakpoint.label"
|
||||||
helpContextId="enable_disable_breakpoint_action_context"
|
helpContextId="enable_disable_breakpoint_action_context"
|
||||||
class="org.eclipse.debug.ui.actions.RulerEnableDisableBreakpointActionDelegate"
|
class="org.eclipse.cdt.debug.internal.ui.actions.breakpoints.CRulerEnableDisableBreakpointActionDelegate"
|
||||||
menubarPath="debug"
|
menubarPath="debug"
|
||||||
id="org.eclipse.cdt.debug.internal.ui.actions.EnableDisableBreakpointRulerActionDelegate">
|
id="org.eclipse.cdt.debug.internal.ui.actions.asm.EnableDisableBreakpointRulerActionDelegate">
|
||||||
</action>
|
</action>
|
||||||
<action
|
<action
|
||||||
label="%AddBreakpointInteractive.label"
|
label="%AddBreakpointInteractive.label"
|
||||||
helpContextId="create_breakpoint_interactive_action_context"
|
helpContextId="add_breakpoint_interactive_action_context"
|
||||||
class="org.eclipse.cdt.debug.internal.ui.actions.breakpoints.CAddBreakpointInteractiveRulerActionDelegate"
|
class="org.eclipse.cdt.debug.internal.ui.actions.breakpoints.CAddBreakpointInteractiveRulerActionDelegate"
|
||||||
menubarPath="debug"
|
menubarPath="debug"
|
||||||
id="org.eclipse.debug.ui.actions.RulerCreateBreakpointInteractiveAction">
|
id="org.eclipse.cdt.debug.ui.actions.asm.RulerCreateBreakpointInteractiveAction">
|
||||||
</action>
|
</action>
|
||||||
<action
|
<action
|
||||||
label="%AddBreakpoint.label"
|
label="%AddBreakpoint.label"
|
||||||
helpContextId="manage_breakpoint_action_context"
|
helpContextId="manage_breakpoint_action_context"
|
||||||
class="org.eclipse.debug.ui.actions.RulerToggleBreakpointActionDelegate"
|
class="org.eclipse.cdt.debug.internal.ui.actions.breakpoints.CRulerToggleBreakpointActionDelegate"
|
||||||
menubarPath="debug"
|
menubarPath="debug"
|
||||||
id="org.eclipse.debug.ui.actions.RulerToggleBreakpointAction">
|
id="org.eclipse.cdt.debug.ui.actions.asm.RulerToggleBreakpointAction">
|
||||||
</action>
|
</action>
|
||||||
</viewerContribution>
|
</viewerContribution>
|
||||||
<viewerContribution
|
<viewerContribution
|
||||||
|
|
|
@ -2,18 +2,26 @@
|
||||||
<!-- Schema file written by PDE -->
|
<!-- Schema file written by PDE -->
|
||||||
<schema targetNamespace="org.eclipse.cdt.debug.ui" xmlns="http://www.w3.org/2001/XMLSchema">
|
<schema targetNamespace="org.eclipse.cdt.debug.ui" xmlns="http://www.w3.org/2001/XMLSchema">
|
||||||
<annotation>
|
<annotation>
|
||||||
<appinfo>
|
<appInfo>
|
||||||
<meta.schema plugin="org.eclipse.cdt.debug.ui" id="breakpointContribution" name="Breakpoint UI Contribution"/>
|
<meta.schema plugin="org.eclipse.cdt.debug.ui" id="breakpointContribution" name="Breakpoint UI Contribution"/>
|
||||||
</appinfo>
|
</appInfo>
|
||||||
<documentation>
|
<documentation>
|
||||||
This extension point provides a mechanism for contributing UI to view and edit breakpoint attributes.
|
This extension point provides a mechanism for contributing controls for viewing and editing breakpoint attributes.
|
||||||
|
The UI controls are added to the "Common" page of the breakpoint properties dialog. If a debug model ID is specified, the
|
||||||
|
contribution is shown only when a debugger with corresponding model ID is currently active.
|
||||||
</documentation>
|
</documentation>
|
||||||
</annotation>
|
</annotation>
|
||||||
|
|
||||||
<element name="extension">
|
<element name="extension">
|
||||||
|
<annotation>
|
||||||
|
<appInfo>
|
||||||
|
<meta.element />
|
||||||
|
</appInfo>
|
||||||
|
</annotation>
|
||||||
<complexType>
|
<complexType>
|
||||||
<sequence minOccurs="1" maxOccurs="unbounded">
|
<sequence minOccurs="1" maxOccurs="unbounded">
|
||||||
<element ref="breakpointLabels"/>
|
<element ref="breakpointLabels" minOccurs="0" maxOccurs="unbounded"/>
|
||||||
|
<element ref="breakpointEditors" minOccurs="0" maxOccurs="unbounded"/>
|
||||||
</sequence>
|
</sequence>
|
||||||
<attribute name="point" type="string" use="required">
|
<attribute name="point" type="string" use="required">
|
||||||
<annotation>
|
<annotation>
|
||||||
|
@ -34,15 +42,20 @@
|
||||||
<documentation>
|
<documentation>
|
||||||
|
|
||||||
</documentation>
|
</documentation>
|
||||||
<appinfo>
|
<appInfo>
|
||||||
<meta.attribute translatable="true"/>
|
<meta.attribute translatable="true"/>
|
||||||
</appinfo>
|
</appInfo>
|
||||||
</annotation>
|
</annotation>
|
||||||
</attribute>
|
</attribute>
|
||||||
</complexType>
|
</complexType>
|
||||||
</element>
|
</element>
|
||||||
|
|
||||||
<element name="breakpointLabels">
|
<element name="breakpointLabels">
|
||||||
|
<annotation>
|
||||||
|
<documentation>
|
||||||
|
A breakpoint label is appended to the top section the breakpoint properties common page.
|
||||||
|
</documentation>
|
||||||
|
</annotation>
|
||||||
<complexType>
|
<complexType>
|
||||||
<sequence minOccurs="0" maxOccurs="unbounded">
|
<sequence minOccurs="0" maxOccurs="unbounded">
|
||||||
<element ref="attribute"/>
|
<element ref="attribute"/>
|
||||||
|
@ -50,28 +63,65 @@
|
||||||
<attribute name="markerType" type="string">
|
<attribute name="markerType" type="string">
|
||||||
<annotation>
|
<annotation>
|
||||||
<documentation>
|
<documentation>
|
||||||
marker type for which attribute labels are applied
|
Breakpoint's marker type for which the given attribute labels are applied.
|
||||||
</documentation>
|
</documentation>
|
||||||
<appinfo>
|
<appInfo>
|
||||||
<meta.attribute kind="identifier"/>
|
<meta.attribute kind="identifier"/>
|
||||||
</appinfo>
|
</appInfo>
|
||||||
</annotation>
|
</annotation>
|
||||||
</attribute>
|
</attribute>
|
||||||
<attribute name="debugModelId" type="string">
|
<attribute name="debugModelId" type="string">
|
||||||
<annotation>
|
<annotation>
|
||||||
<documentation>
|
<documentation>
|
||||||
debug model Id for this extension is valid
|
Debug model Id of the active debug context for which this extension is valid. If not specified or if the model ID equals the CDT breakpoint's model (org.eclipse.cdt.debug.core), the option is always shown.
|
||||||
(debugModelId is a property of cbreakpoint)
|
|
||||||
</documentation>
|
</documentation>
|
||||||
<appinfo>
|
<appInfo>
|
||||||
<meta.attribute kind="identifier"/>
|
<meta.attribute kind="identifier"/>
|
||||||
</appinfo>
|
</appInfo>
|
||||||
|
</annotation>
|
||||||
|
</attribute>
|
||||||
|
</complexType>
|
||||||
|
</element>
|
||||||
|
|
||||||
|
<element name="breakpointEditors">
|
||||||
|
<annotation>
|
||||||
|
<documentation>
|
||||||
|
A breakpoint editor is appended to the bottom section the breakpoint properties common page.
|
||||||
|
</documentation>
|
||||||
|
</annotation>
|
||||||
|
<complexType>
|
||||||
|
<sequence minOccurs="0" maxOccurs="unbounded">
|
||||||
|
<element ref="attribute"/>
|
||||||
|
</sequence>
|
||||||
|
<attribute name="markerType" type="string">
|
||||||
|
<annotation>
|
||||||
|
<documentation>
|
||||||
|
Breakpoint's marker type for which the given attribute labels are applied.
|
||||||
|
</documentation>
|
||||||
|
<appInfo>
|
||||||
|
<meta.attribute kind="identifier"/>
|
||||||
|
</appInfo>
|
||||||
|
</annotation>
|
||||||
|
</attribute>
|
||||||
|
<attribute name="debugModelId" type="string">
|
||||||
|
<annotation>
|
||||||
|
<documentation>
|
||||||
|
Debug model Id of the active debug context for which this extension is valid. If not specified or if the model ID equals the CDT breakpoint's model (org.eclipse.cdt.debug.core), the option is always shown.
|
||||||
|
</documentation>
|
||||||
|
<appInfo>
|
||||||
|
<meta.attribute kind="identifier"/>
|
||||||
|
</appInfo>
|
||||||
</annotation>
|
</annotation>
|
||||||
</attribute>
|
</attribute>
|
||||||
</complexType>
|
</complexType>
|
||||||
</element>
|
</element>
|
||||||
|
|
||||||
<element name="attribute">
|
<element name="attribute">
|
||||||
|
<annotation>
|
||||||
|
<documentation>
|
||||||
|
Each attribute entry displays or modifies a breakpoint attribute with the given ID.
|
||||||
|
</documentation>
|
||||||
|
</annotation>
|
||||||
<complexType>
|
<complexType>
|
||||||
<sequence minOccurs="0" maxOccurs="unbounded">
|
<sequence minOccurs="0" maxOccurs="unbounded">
|
||||||
<element ref="value"/>
|
<element ref="value"/>
|
||||||
|
@ -88,28 +138,47 @@
|
||||||
<documentation>
|
<documentation>
|
||||||
user visible label for the breakpoint attribute value
|
user visible label for the breakpoint attribute value
|
||||||
</documentation>
|
</documentation>
|
||||||
<appinfo>
|
<appInfo>
|
||||||
<meta.attribute translatable="true"/>
|
<meta.attribute translatable="true"/>
|
||||||
</appinfo>
|
</appInfo>
|
||||||
</annotation>
|
</annotation>
|
||||||
</attribute>
|
</attribute>
|
||||||
<attribute name="fieldEditor" type="string">
|
<attribute name="fieldEditor" type="string">
|
||||||
<annotation>
|
<annotation>
|
||||||
<documentation>
|
<documentation>
|
||||||
field editor that will be shown to for given attribute.
|
Field editor that will be shown to for given attribute. This field editor must be on the classpath of the org.eclipse.cdt.debug.ui plugin. For a custom field editor use the newer fieldEditorFactory attribute. If this parameter is not specified, the org.eclipse.cdt.debug.ui.preferences.ReadOnlyFieldEditor field editor will be used by default.
|
||||||
If not specified this attribute will not be visible in Common page.
|
|
||||||
</documentation>
|
</documentation>
|
||||||
<appinfo>
|
<appInfo>
|
||||||
<meta.attribute kind="java" basedOn="org.eclipse.jface.preference.FieldEditor:"/>
|
<meta.attribute kind="java" basedOn="org.eclipse.jface.preference.FieldEditor:"/>
|
||||||
</appinfo>
|
</appInfo>
|
||||||
</annotation>
|
</annotation>
|
||||||
</attribute>
|
</attribute>
|
||||||
<attribute name="type" type="string" use="default" value="string">
|
<attribute name="type" use="default" value="string">
|
||||||
<annotation>
|
<annotation>
|
||||||
<documentation>
|
<documentation>
|
||||||
Type of the attribute. Value should be one of "boolean", "string", "integer", "float".
|
Type of the attribute. Value should be one of "boolean", "string", "integer", "float".
|
||||||
</documentation>
|
</documentation>
|
||||||
</annotation>
|
</annotation>
|
||||||
|
<simpleType>
|
||||||
|
<restriction base="string">
|
||||||
|
<enumeration value="string">
|
||||||
|
</enumeration>
|
||||||
|
<enumeration value="integer">
|
||||||
|
</enumeration>
|
||||||
|
<enumeration value="float">
|
||||||
|
</enumeration>
|
||||||
|
</restriction>
|
||||||
|
</simpleType>
|
||||||
|
</attribute>
|
||||||
|
<attribute name="fieldEditorFactory" type="string">
|
||||||
|
<annotation>
|
||||||
|
<documentation>
|
||||||
|
|
||||||
|
</documentation>
|
||||||
|
<appInfo>
|
||||||
|
<meta.attribute kind="java" basedOn=":org.eclipse.cdt.debug.ui.breakpoints.IFieldEditorFactory"/>
|
||||||
|
</appInfo>
|
||||||
|
</annotation>
|
||||||
</attribute>
|
</attribute>
|
||||||
</complexType>
|
</complexType>
|
||||||
</element>
|
</element>
|
||||||
|
@ -117,8 +186,7 @@ If not specified this attribute will not be visible in Common page.
|
||||||
<element name="value">
|
<element name="value">
|
||||||
<annotation>
|
<annotation>
|
||||||
<documentation>
|
<documentation>
|
||||||
Properties of value for parent attribute.
|
Properties of value for parent attribute. If a value elemnt contains child attribute elements it means that these property only enabled when value of parent attribute equal to current element value.
|
||||||
If Value contains child attributes it means that these property only enabled when value of parent attribute equal to current element value
|
|
||||||
</documentation>
|
</documentation>
|
||||||
</annotation>
|
</annotation>
|
||||||
<complexType>
|
<complexType>
|
||||||
|
@ -137,27 +205,27 @@ If Value contains child attributes it means that these property only enabled whe
|
||||||
<documentation>
|
<documentation>
|
||||||
User visible label for the breakpoint attribute value
|
User visible label for the breakpoint attribute value
|
||||||
</documentation>
|
</documentation>
|
||||||
<appinfo>
|
<appInfo>
|
||||||
<meta.attribute translatable="true"/>
|
<meta.attribute translatable="true"/>
|
||||||
</appinfo>
|
</appInfo>
|
||||||
</annotation>
|
</annotation>
|
||||||
</attribute>
|
</attribute>
|
||||||
</complexType>
|
</complexType>
|
||||||
</element>
|
</element>
|
||||||
|
|
||||||
<annotation>
|
<annotation>
|
||||||
<appinfo>
|
<appInfo>
|
||||||
<meta.section type="since"/>
|
<meta.section type="since"/>
|
||||||
</appinfo>
|
</appInfo>
|
||||||
<documentation>
|
<documentation>
|
||||||
CDT 5.0
|
CDT 5.0
|
||||||
</documentation>
|
</documentation>
|
||||||
</annotation>
|
</annotation>
|
||||||
|
|
||||||
<annotation>
|
<annotation>
|
||||||
<appinfo>
|
<appInfo>
|
||||||
<meta.section type="examples"/>
|
<meta.section type="examples"/>
|
||||||
</appinfo>
|
</appInfo>
|
||||||
<documentation>
|
<documentation>
|
||||||
<pre>
|
<pre>
|
||||||
<extension id="com.xyz.coolMarkerLabels" point="org.eclipse.cdt.debug.ui.breakpointContribution">
|
<extension id="com.xyz.coolMarkerLabels" point="org.eclipse.cdt.debug.ui.breakpointContribution">
|
||||||
|
|
|
@ -132,6 +132,4 @@ RetargetResumeAtLineAction.0=The operation is unavailable on the current selecti
|
||||||
CAddBreakpointInteractiveRulerAction_label=&Add Breakpoint...\tCtrl+Double Click
|
CAddBreakpointInteractiveRulerAction_label=&Add Breakpoint...\tCtrl+Double Click
|
||||||
CAddBreakpointInteractiveRulerAction_error_title=Error
|
CAddBreakpointInteractiveRulerAction_error_title=Error
|
||||||
CAddBreakpointInteractiveRulerAction_error_message=Unable to create breakpoint
|
CAddBreakpointInteractiveRulerAction_error_message=Unable to create breakpoint
|
||||||
CBreakpointToggleRulerAction_error_label=Toggle Brea&kpoint\tDouble Click
|
CRulerToggleBreakpointActionDelegate_label=Toggle Brea&kpoint\tDouble Click
|
||||||
CBreakpointToggleRulerAction_error_title=Error
|
|
||||||
CBreakpointToggleRulerAction_error_message=Unable to toggle breakpoint
|
|
||||||
|
|
|
@ -0,0 +1,34 @@
|
||||||
|
/*******************************************************************************
|
||||||
|
* Copyright (c) 2005, 2012 IBM Corporation and others.
|
||||||
|
* All rights reserved. This program and the accompanying materials
|
||||||
|
* are made available under the terms of the Eclipse Public License v1.0
|
||||||
|
* which accompanies this distribution, and is available at
|
||||||
|
* http://www.eclipse.org/legal/epl-v10.html
|
||||||
|
*
|
||||||
|
* Contributors:
|
||||||
|
* IBM Corporation - initial API and implementation
|
||||||
|
*******************************************************************************/
|
||||||
|
package org.eclipse.cdt.debug.internal.ui.actions.breakpoints;
|
||||||
|
|
||||||
|
import org.eclipse.jface.action.IAction;
|
||||||
|
import org.eclipse.jface.text.source.IVerticalRulerInfo;
|
||||||
|
import org.eclipse.ui.texteditor.AbstractRulerActionDelegate;
|
||||||
|
import org.eclipse.ui.texteditor.ITextEditor;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* This is a copy of the RulerEnableDisableBreakpointActionDelegate in platform.
|
||||||
|
* It updates the toggle action to include an accelertor text in its label.
|
||||||
|
* See bug 374153.
|
||||||
|
*
|
||||||
|
* @see org.eclipse.debug.ui.actions.RulerEnableDisableBreakpointActionDelegate
|
||||||
|
*/
|
||||||
|
public class CRulerEnableDisableBreakpointActionDelegate extends AbstractRulerActionDelegate {
|
||||||
|
|
||||||
|
/* (non-Javadoc)
|
||||||
|
* @see org.eclipse.ui.texteditor.AbstractRulerActionDelegate#createAction(org.eclipse.ui.texteditor.ITextEditor, org.eclipse.jface.text.source.IVerticalRulerInfo)
|
||||||
|
*/
|
||||||
|
protected IAction createAction(ITextEditor editor, IVerticalRulerInfo rulerInfo) {
|
||||||
|
return new EnableDisableBreakpointRulerAction(editor, rulerInfo);
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
|
@ -0,0 +1,84 @@
|
||||||
|
/*******************************************************************************
|
||||||
|
* Copyright (c) 2005, 2012 IBM Corporation and others.
|
||||||
|
* All rights reserved. This program and the accompanying materials
|
||||||
|
* are made available under the terms of the Eclipse Public License v1.0
|
||||||
|
* which accompanies this distribution, and is available at
|
||||||
|
* http://www.eclipse.org/legal/epl-v10.html
|
||||||
|
*
|
||||||
|
* Contributors:
|
||||||
|
* IBM Corporation - initial API and implementation
|
||||||
|
*******************************************************************************/
|
||||||
|
package org.eclipse.cdt.debug.internal.ui.actions.breakpoints;
|
||||||
|
|
||||||
|
import org.eclipse.cdt.debug.internal.ui.actions.ActionMessages;
|
||||||
|
import org.eclipse.debug.ui.actions.ToggleBreakpointAction;
|
||||||
|
import org.eclipse.jface.action.IAction;
|
||||||
|
import org.eclipse.jface.text.source.IVerticalRulerInfo;
|
||||||
|
import org.eclipse.swt.widgets.Event;
|
||||||
|
import org.eclipse.ui.IActionDelegate2;
|
||||||
|
import org.eclipse.ui.IEditorPart;
|
||||||
|
import org.eclipse.ui.texteditor.AbstractRulerActionDelegate;
|
||||||
|
import org.eclipse.ui.texteditor.ITextEditor;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* This is a copy of the RulerToggleBreakpointActionDelegate in platform.
|
||||||
|
* It updates the toggle action to include an accelertor text in its label.
|
||||||
|
* See bug 374153.
|
||||||
|
*
|
||||||
|
* @see org.eclipse.debug.ui.actions.RulerToggleBreakpointActionDelegate
|
||||||
|
*/
|
||||||
|
public class CRulerToggleBreakpointActionDelegate extends AbstractRulerActionDelegate implements IActionDelegate2 {
|
||||||
|
|
||||||
|
private IEditorPart fEditor = null;
|
||||||
|
private ToggleBreakpointAction fDelegate = null;
|
||||||
|
|
||||||
|
/* (non-Javadoc)
|
||||||
|
* @see org.eclipse.ui.texteditor.AbstractRulerActionDelegate#createAction(org.eclipse.ui.texteditor.ITextEditor, org.eclipse.jface.text.source.IVerticalRulerInfo)
|
||||||
|
*/
|
||||||
|
protected IAction createAction(ITextEditor editor, IVerticalRulerInfo rulerInfo) {
|
||||||
|
fDelegate = new ToggleBreakpointAction(editor, null, rulerInfo);
|
||||||
|
fDelegate.setText( ActionMessages.getString("CRulerToggleBreakpointActionDelegate_label") ); //$NON-NLS-1$
|
||||||
|
|
||||||
|
return fDelegate;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* (non-Javadoc)
|
||||||
|
* @see org.eclipse.ui.IEditorActionDelegate#setActiveEditor(org.eclipse.jface.action.IAction, org.eclipse.ui.IEditorPart)
|
||||||
|
*/
|
||||||
|
public void setActiveEditor(IAction callerAction, IEditorPart targetEditor) {
|
||||||
|
if (fEditor != null) {
|
||||||
|
if (fDelegate != null) {
|
||||||
|
fDelegate.dispose();
|
||||||
|
fDelegate = null;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
fEditor = targetEditor;
|
||||||
|
super.setActiveEditor(callerAction, targetEditor);
|
||||||
|
}
|
||||||
|
|
||||||
|
/* (non-Javadoc)
|
||||||
|
* @see org.eclipse.ui.IActionDelegate2#init(org.eclipse.jface.action.IAction)
|
||||||
|
*/
|
||||||
|
public void init(IAction action) {
|
||||||
|
}
|
||||||
|
|
||||||
|
/* (non-Javadoc)
|
||||||
|
* @see org.eclipse.ui.IActionDelegate2#dispose()
|
||||||
|
*/
|
||||||
|
public void dispose() {
|
||||||
|
if (fDelegate != null) {
|
||||||
|
fDelegate.dispose();
|
||||||
|
}
|
||||||
|
fDelegate = null;
|
||||||
|
fEditor = null;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* (non-Javadoc)
|
||||||
|
* @see org.eclipse.ui.IActionDelegate2#runWithEvent(org.eclipse.jface.action.IAction, org.eclipse.swt.widgets.Event)
|
||||||
|
*/
|
||||||
|
public void runWithEvent(IAction action, Event event) {
|
||||||
|
if(fDelegate != null) {
|
||||||
|
fDelegate.runWithEvent(event);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
|
@ -34,6 +34,7 @@ import org.eclipse.core.resources.IResource;
|
||||||
import org.eclipse.core.runtime.CoreException;
|
import org.eclipse.core.runtime.CoreException;
|
||||||
import org.eclipse.core.runtime.IAdaptable;
|
import org.eclipse.core.runtime.IAdaptable;
|
||||||
import org.eclipse.debug.core.DebugPlugin;
|
import org.eclipse.debug.core.DebugPlugin;
|
||||||
|
import org.eclipse.debug.core.model.IDebugModelProvider;
|
||||||
import org.eclipse.debug.core.model.ILineBreakpoint;
|
import org.eclipse.debug.core.model.ILineBreakpoint;
|
||||||
import org.eclipse.debug.ui.DebugUITools;
|
import org.eclipse.debug.ui.DebugUITools;
|
||||||
import org.eclipse.debug.ui.contexts.IDebugContextProvider;
|
import org.eclipse.debug.ui.contexts.IDebugContextProvider;
|
||||||
|
@ -462,11 +463,12 @@ public class CBreakpointPropertyPage extends FieldEditorPreferencePage implement
|
||||||
protected void createFieldEditors() {
|
protected void createFieldEditors() {
|
||||||
ICBreakpoint breakpoint = getBreakpoint();
|
ICBreakpoint breakpoint = getBreakpoint();
|
||||||
createMainLabel(breakpoint);
|
createMainLabel(breakpoint);
|
||||||
createContributedFieldEditors(breakpoint);
|
createContributedFieldEditors(breakpoint, ICBreakpointsUIContribution.BREAKPOINT_LABELS);
|
||||||
createTypeSpecificLabelFieldEditors( breakpoint );
|
createTypeSpecificLabelFieldEditors( breakpoint );
|
||||||
createEnabledField( getFieldEditorParent() );
|
createEnabledField( getFieldEditorParent() );
|
||||||
createConditionEditor( getFieldEditorParent() );
|
createConditionEditor( getFieldEditorParent() );
|
||||||
createIgnoreCountEditor( getFieldEditorParent() );
|
createIgnoreCountEditor( getFieldEditorParent() );
|
||||||
|
createContributedFieldEditors(breakpoint, ICBreakpointsUIContribution.BREAKPOINT_EDITORS);
|
||||||
}
|
}
|
||||||
|
|
||||||
private void createMainLabel(ICBreakpoint breakpoint) {
|
private void createMainLabel(ICBreakpoint breakpoint) {
|
||||||
|
@ -760,26 +762,34 @@ public class CBreakpointPropertyPage extends FieldEditorPreferencePage implement
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Creates field editors contributed using breakpointUIContribution extension point
|
* Creates field editors contributed using breakpointUIContribution extension point
|
||||||
* @param breakpoint
|
|
||||||
*/
|
*/
|
||||||
private void createContributedFieldEditors(ICBreakpoint breakpoint) {
|
private void createContributedFieldEditors(ICBreakpoint breakpoint, String conMainElement) {
|
||||||
Composite parent = getFieldEditorParent();
|
Composite parent = getFieldEditorParent();
|
||||||
|
String[] debugModelIds = CBreakpointUIContributionFactory.DEBUG_MODEL_IDS_DEFAULT;
|
||||||
|
IDebugModelProvider debugModelProvider = (IDebugModelProvider)DebugPlugin.getAdapter(
|
||||||
|
getDebugContext(), IDebugModelProvider.class);
|
||||||
|
if (debugModelProvider != null) {
|
||||||
|
debugModelIds = debugModelProvider.getModelIdentifiers();
|
||||||
|
}
|
||||||
|
|
||||||
try {
|
try {
|
||||||
ICBreakpointsUIContribution[] cons;
|
ICBreakpointsUIContribution[] cons;
|
||||||
CBreakpointUIContributionFactory factory = CBreakpointUIContributionFactory.getInstance();
|
CBreakpointUIContributionFactory factory = CBreakpointUIContributionFactory.getInstance();
|
||||||
IPreferenceStore prefStore = getPreferenceStore();
|
IPreferenceStore prefStore = getPreferenceStore();
|
||||||
if (prefStore instanceof CBreakpointPreferenceStore) {
|
if (prefStore instanceof CBreakpointPreferenceStore) {
|
||||||
cons = factory.getBreakpointUIContributions(
|
cons = factory.getBreakpointUIContributions(
|
||||||
breakpoint, ((CBreakpointPreferenceStore) prefStore).getAttributes());
|
debugModelIds, breakpoint, ((CBreakpointPreferenceStore) prefStore).getAttributes());
|
||||||
} else {
|
} else {
|
||||||
cons = factory.getBreakpointUIContributions(breakpoint);
|
cons = factory.getBreakpointUIContributions(breakpoint);
|
||||||
}
|
}
|
||||||
|
|
||||||
for (ICBreakpointsUIContribution con : cons) {
|
for (ICBreakpointsUIContribution con : cons) {
|
||||||
FieldEditor fieldEditor = con.getFieldEditor(con.getId(), con.getLabel()+":", parent); //$NON-NLS-1$
|
if ( conMainElement.equals(con.getMainElement()) ) {
|
||||||
if (fieldEditor != null) {
|
FieldEditor fieldEditor = con.getFieldEditor(con.getId(), con.getLabel() + ":", parent); //$NON-NLS-1$
|
||||||
addField(fieldEditor);
|
if (fieldEditor != null) {
|
||||||
}
|
addField(fieldEditor);
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
} catch (CoreException ce) {
|
} catch (CoreException ce) {
|
||||||
CDebugUIPlugin.log(ce);
|
CDebugUIPlugin.log(ce);
|
||||||
|
|
|
@ -13,7 +13,9 @@
|
||||||
package org.eclipse.cdt.debug.ui.breakpoints;
|
package org.eclipse.cdt.debug.ui.breakpoints;
|
||||||
|
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
|
import java.util.Arrays;
|
||||||
import java.util.Collections;
|
import java.util.Collections;
|
||||||
|
import java.util.List;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
|
|
||||||
import org.eclipse.cdt.debug.core.CDIDebugModel;
|
import org.eclipse.cdt.debug.core.CDIDebugModel;
|
||||||
|
@ -31,7 +33,6 @@ import org.eclipse.debug.core.model.IBreakpoint;
|
||||||
|
|
||||||
public class CBreakpointUIContributionFactory {
|
public class CBreakpointUIContributionFactory {
|
||||||
private static final String EXTENSION_POINT_NAME = "breakpointContribution"; //$NON-NLS-1$
|
private static final String EXTENSION_POINT_NAME = "breakpointContribution"; //$NON-NLS-1$
|
||||||
private static final String MAIN_ELEMENT = "breakpointLabels"; //$NON-NLS-1$
|
|
||||||
|
|
||||||
private static CBreakpointUIContributionFactory instance;
|
private static CBreakpointUIContributionFactory instance;
|
||||||
protected ArrayList<ICBreakpointsUIContribution> contributions;
|
protected ArrayList<ICBreakpointsUIContribution> contributions;
|
||||||
|
@ -70,22 +71,28 @@ public class CBreakpointUIContributionFactory {
|
||||||
* @throws CoreException if cannot get marker attributes from bearkpoint
|
* @throws CoreException if cannot get marker attributes from bearkpoint
|
||||||
* @since 7.2
|
* @since 7.2
|
||||||
*/
|
*/
|
||||||
public ICBreakpointsUIContribution[] getBreakpointUIContributions(IBreakpoint breakpoint,
|
public ICBreakpointsUIContribution[] getBreakpointUIContributions(String[] debugModelIDs, IBreakpoint breakpoint,
|
||||||
Map<String, Object> attributes)
|
Map<String, Object> attributes) throws CoreException
|
||||||
throws CoreException
|
|
||||||
{
|
{
|
||||||
String debugModelId = breakpoint.getModelIdentifier();
|
|
||||||
IMarker bmarker = breakpoint.getMarker();
|
IMarker bmarker = breakpoint.getMarker();
|
||||||
String markerType = CDIDebugModel.calculateMarkerType(breakpoint);
|
String markerType = CDIDebugModel.calculateMarkerType(breakpoint);
|
||||||
if (bmarker != null) {
|
if (bmarker != null) {
|
||||||
markerType = bmarker.getType();
|
markerType = bmarker.getType();
|
||||||
}
|
}
|
||||||
return getBreakpointUIContributions(debugModelId, markerType, attributes);
|
return getBreakpointUIContributions(debugModelIDs, markerType, attributes);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Default debug model ID list which will cause only the general UI contributions to be returned.
|
||||||
|
* @since 7.2
|
||||||
|
*/
|
||||||
|
public final static String[] DEBUG_MODEL_IDS_DEFAULT = new String[] {};
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Calculates the breakpoint UI contributions for the given breakpoint.
|
* Calculates the breakpoint UI contributions for the given breakpoint.
|
||||||
*
|
*
|
||||||
|
* @param debugModelId The debug model ID of the active debug context for
|
||||||
|
* which to calculate contributions.
|
||||||
* @param breakpoint Breakpoint to find UI contributions for.
|
* @param breakpoint Breakpoint to find UI contributions for.
|
||||||
* @param markerType Marker type of the breakpoint.
|
* @param markerType Marker type of the breakpoint.
|
||||||
* @param attributes Attributes of the breakpoint
|
* @param attributes Attributes of the breakpoint
|
||||||
|
@ -96,25 +103,54 @@ public class CBreakpointUIContributionFactory {
|
||||||
public ICBreakpointsUIContribution[] getBreakpointUIContributions(String debugModelId, String markerType,
|
public ICBreakpointsUIContribution[] getBreakpointUIContributions(String debugModelId, String markerType,
|
||||||
Map<String, Object> attributes)
|
Map<String, Object> attributes)
|
||||||
{
|
{
|
||||||
ArrayList<ICBreakpointsUIContribution> list = new ArrayList<ICBreakpointsUIContribution>();
|
return getBreakpointUIContributions(
|
||||||
for (ICBreakpointsUIContribution con : contributions) {
|
debugModelId != null ? new String[] { debugModelId } : DEBUG_MODEL_IDS_DEFAULT,
|
||||||
try {
|
markerType,
|
||||||
if (debugModelId == null || con.getDebugModelId() == null || debugModelId.equals(con.getDebugModelId())) {
|
attributes);
|
||||||
String contributedMarkerType = con.getMarkerType();
|
|
||||||
if (isMarkerSubtypeOf(markerType, contributedMarkerType)) {
|
|
||||||
if (attributes == null || con.isApplicable(attributes)) {
|
|
||||||
list.add(con);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
} catch (Exception e) {
|
|
||||||
CDebugUIPlugin.log(e);
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
return list.toArray(new ICBreakpointsUIContribution[list.size()]);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Calculates the breakpoint UI contributions for the given breakpoint.
|
||||||
|
*
|
||||||
|
* @param debugModelId The debug model IDs of the active debug context for
|
||||||
|
* which to calculate contributions.
|
||||||
|
* @param breakpoint Breakpoint to find UI contributions for.
|
||||||
|
* @param markerType Marker type of the breakpoint.
|
||||||
|
* @param attributes Attributes of the breakpoint
|
||||||
|
* @return non-null array of ICBreakpointsUIContribution
|
||||||
|
* @throws CoreException
|
||||||
|
* @throws CoreException if cannot get marker attributes from berakpoint
|
||||||
|
*
|
||||||
|
* @since 7.2
|
||||||
|
*/
|
||||||
|
public ICBreakpointsUIContribution[] getBreakpointUIContributions(String[] debugModelIds, String markerType,
|
||||||
|
Map<String, Object> attributes)
|
||||||
|
{
|
||||||
|
List<String> debugModelIdsList = Arrays.asList(debugModelIds);
|
||||||
|
ArrayList<ICBreakpointsUIContribution> list = new ArrayList<ICBreakpointsUIContribution>();
|
||||||
|
for (ICBreakpointsUIContribution con : contributions) {
|
||||||
|
try {
|
||||||
|
if (con.getDebugModelId() == null ||
|
||||||
|
con.getDebugModelId().equals(CDIDebugModel.getPluginIdentifier()) ||
|
||||||
|
debugModelIdsList.contains(con.getDebugModelId()))
|
||||||
|
{
|
||||||
|
String contributedMarkerType = con.getMarkerType();
|
||||||
|
if (isMarkerSubtypeOf(markerType, contributedMarkerType)) {
|
||||||
|
if (attributes == null || con.isApplicable(attributes)) {
|
||||||
|
list.add(con);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
} catch (Exception e) {
|
||||||
|
CDebugUIPlugin.log(e);
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
return list.toArray(new ICBreakpointsUIContribution[list.size()]);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
public boolean isMarkerSubtypeOf(String currentType, String type) throws CoreException {
|
public boolean isMarkerSubtypeOf(String currentType, String type) throws CoreException {
|
||||||
return getWorkspace().getMarkerManager().isSubtype(currentType, type);
|
return getWorkspace().getMarkerManager().isSubtype(currentType, type);
|
||||||
}
|
}
|
||||||
|
@ -132,15 +168,19 @@ public class CBreakpointUIContributionFactory {
|
||||||
IConfigurationElement[] elements = ep.getConfigurationElements();
|
IConfigurationElement[] elements = ep.getConfigurationElements();
|
||||||
for (int i = 0; i < elements.length; i++) {
|
for (int i = 0; i < elements.length; i++) {
|
||||||
IConfigurationElement configurationElement = elements[i];
|
IConfigurationElement configurationElement = elements[i];
|
||||||
if (configurationElement.getName().equals(MAIN_ELEMENT)) {
|
if (configurationElement.getName().equals(ICBreakpointsUIContribution.BREAKPOINT_LABELS) ||
|
||||||
|
configurationElement.getName().equals(ICBreakpointsUIContribution.BREAKPOINT_EDITORS))
|
||||||
|
{
|
||||||
|
String mainElement = configurationElement.getName();
|
||||||
String modelId = configurationElement.getAttribute("debugModelId"); //$NON-NLS-1$
|
String modelId = configurationElement.getAttribute("debugModelId"); //$NON-NLS-1$
|
||||||
String markerType = getRequired(configurationElement, "markerType"); //$NON-NLS-1$
|
String markerType = getRequired(configurationElement, "markerType"); //$NON-NLS-1$
|
||||||
if (markerType == null)
|
if (markerType == null)
|
||||||
continue;
|
continue;
|
||||||
IConfigurationElement[] children = configurationElement.getChildren("attribute"); //$NON-NLS-1$
|
IConfigurationElement[] children = configurationElement.getChildren("attribute"); //$NON-NLS-1$
|
||||||
for (IConfigurationElement att : children) {
|
for (IConfigurationElement att : children) {
|
||||||
|
|
||||||
DefaultCBreakpointUIContribution adapter = new DefaultCBreakpointUIContribution();
|
DefaultCBreakpointUIContribution adapter = new DefaultCBreakpointUIContribution(att);
|
||||||
|
adapter.setMainElement(mainElement);
|
||||||
adapter.setMarkerType(markerType);
|
adapter.setMarkerType(markerType);
|
||||||
adapter.setDebugModelId(modelId);
|
adapter.setDebugModelId(modelId);
|
||||||
if (processAttribute(att, adapter) == false)
|
if (processAttribute(att, adapter) == false)
|
||||||
|
@ -152,10 +192,13 @@ public class CBreakpointUIContributionFactory {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private boolean processAttribute(IConfigurationElement attrElement, DefaultCBreakpointUIContribution adapter) {
|
private boolean processAttribute(IConfigurationElement attrElement,
|
||||||
|
DefaultCBreakpointUIContribution adapter)
|
||||||
|
{
|
||||||
String attrId = getRequired(attrElement, "name"); //$NON-NLS-1$
|
String attrId = getRequired(attrElement, "name"); //$NON-NLS-1$
|
||||||
String attrLabel = getRequired(attrElement, "label"); //$NON-NLS-1$
|
String attrLabel = getRequired(attrElement, "label"); //$NON-NLS-1$
|
||||||
String className = attrElement.getAttribute("fieldEditor"); //$NON-NLS-1$
|
String fieldEditorClass = attrElement.getAttribute("fieldEditor"); //$NON-NLS-1$
|
||||||
|
String fieldEditorFactoryClass = attrElement.getAttribute("fieldEditorFactory"); //$NON-NLS-1$
|
||||||
String type = attrElement.getAttribute("type"); //$NON-NLS-1$
|
String type = attrElement.getAttribute("type"); //$NON-NLS-1$
|
||||||
String svisible = attrElement.getAttribute("visible"); //$NON-NLS-1$
|
String svisible = attrElement.getAttribute("visible"); //$NON-NLS-1$
|
||||||
|
|
||||||
|
@ -174,7 +217,8 @@ public class CBreakpointUIContributionFactory {
|
||||||
}
|
}
|
||||||
adapter.setId(attrId);
|
adapter.setId(attrId);
|
||||||
adapter.setLabel(attrLabel);
|
adapter.setLabel(attrLabel);
|
||||||
adapter.setControlClass(className);
|
adapter.setControlClass(fieldEditorClass);
|
||||||
|
adapter.setFieldEditorFactory(fieldEditorFactoryClass);
|
||||||
adapter.setType(type);
|
adapter.setType(type);
|
||||||
adapter.setVisible(visible);
|
adapter.setVisible(visible);
|
||||||
addContribution(adapter);
|
addContribution(adapter);
|
||||||
|
@ -196,8 +240,9 @@ public class CBreakpointUIContributionFactory {
|
||||||
adapter.addValue(valueId, valueLabel);
|
adapter.addValue(valueId, valueLabel);
|
||||||
IConfigurationElement[] children = valueElement.getChildren("attribute"); //$NON-NLS-1$
|
IConfigurationElement[] children = valueElement.getChildren("attribute"); //$NON-NLS-1$
|
||||||
for (IConfigurationElement att : children) {
|
for (IConfigurationElement att : children) {
|
||||||
DefaultCBreakpointUIContribution adapter2 = new DefaultCBreakpointUIContribution();
|
DefaultCBreakpointUIContribution adapter2 = new DefaultCBreakpointUIContribution(att);
|
||||||
// inherit values
|
// inherit values
|
||||||
|
adapter2.setMainElement(adapter.getMainElement());
|
||||||
adapter2.setMarkerType(adapter.getMarkerType());
|
adapter2.setMarkerType(adapter.getMarkerType());
|
||||||
adapter2.setDebugModelId(adapter.getDebugModelId());
|
adapter2.setDebugModelId(adapter.getDebugModelId());
|
||||||
adapter2.addContionsAll(adapter.getConditions());
|
adapter2.addContionsAll(adapter.getConditions());
|
||||||
|
|
|
@ -96,7 +96,7 @@ public class CEventBreakpointsLabelProviderFactory implements IAdapterFactory {
|
||||||
if (ignoreCount > 0) {
|
if (ignoreCount > 0) {
|
||||||
label.append(' ');
|
label.append(' ');
|
||||||
label.append(MessageFormat.format(
|
label.append(MessageFormat.format(
|
||||||
DebugCoreMessages.getString("CDebugUtils.3"), new String[] { Integer.toString(ignoreCount) })); //$NON-NLS-1$
|
DebugCoreMessages.getString("CDebugUtils.3"), new Object[] { Integer.toString(ignoreCount) })); //$NON-NLS-1$
|
||||||
}
|
}
|
||||||
return label;
|
return label;
|
||||||
}
|
}
|
||||||
|
@ -106,7 +106,7 @@ public class CEventBreakpointsLabelProviderFactory implements IAdapterFactory {
|
||||||
if (condition != null && condition.length() > 0) {
|
if (condition != null && condition.length() > 0) {
|
||||||
buffer.append(' ');
|
buffer.append(' ');
|
||||||
buffer.append(MessageFormat
|
buffer.append(MessageFormat
|
||||||
.format(DebugCoreMessages.getString("CDebugUtils.4"), new String[] { condition })); //$NON-NLS-1$
|
.format(DebugCoreMessages.getString("CDebugUtils.4"), new Object[] { condition })); //$NON-NLS-1$
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -20,19 +20,31 @@ import java.util.Set;
|
||||||
|
|
||||||
import org.eclipse.cdt.debug.ui.CDebugUIPlugin;
|
import org.eclipse.cdt.debug.ui.CDebugUIPlugin;
|
||||||
import org.eclipse.cdt.debug.ui.preferences.ReadOnlyFieldEditor;
|
import org.eclipse.cdt.debug.ui.preferences.ReadOnlyFieldEditor;
|
||||||
|
import org.eclipse.core.runtime.CoreException;
|
||||||
|
import org.eclipse.core.runtime.IConfigurationElement;
|
||||||
import org.eclipse.jface.preference.FieldEditor;
|
import org.eclipse.jface.preference.FieldEditor;
|
||||||
import org.eclipse.swt.widgets.Composite;
|
import org.eclipse.swt.widgets.Composite;
|
||||||
|
|
||||||
class DefaultCBreakpointUIContribution implements ICBreakpointsUIContribution {
|
class DefaultCBreakpointUIContribution implements ICBreakpointsUIContribution {
|
||||||
|
|
||||||
|
private final IConfigurationElement fConfig;
|
||||||
|
private String mainElement;
|
||||||
private String attLabel;
|
private String attLabel;
|
||||||
private String attId;
|
private String attId;
|
||||||
private String fieldEditorClassName;
|
private String fieldEditorClassName;
|
||||||
|
private String fieldEditorFactoryClass;
|
||||||
|
private IFieldEditorFactory fieldEditorFactory;
|
||||||
private String markerType;
|
private String markerType;
|
||||||
private String modelId;
|
private String modelId;
|
||||||
private String attType;
|
private String attType;
|
||||||
private Map<String, String> valueLabels = new LinkedHashMap<String, String>();
|
private Map<String, String> valueLabels = new LinkedHashMap<String, String>();
|
||||||
private Map<String, String> conditions = new HashMap<String, String>();
|
private Map<String, String> conditions = new HashMap<String, String>();
|
||||||
|
|
||||||
|
DefaultCBreakpointUIContribution(IConfigurationElement config) {
|
||||||
|
fConfig = config;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String getId() {
|
public String getId() {
|
||||||
return attId;
|
return attId;
|
||||||
|
@ -48,28 +60,43 @@ class DefaultCBreakpointUIContribution implements ICBreakpointsUIContribution {
|
||||||
return modelId;
|
return modelId;
|
||||||
}
|
}
|
||||||
|
|
||||||
static private Class[] fieldSignature = new Class[] { String.class, String.class,
|
@Override
|
||||||
|
public String getMainElement() {
|
||||||
|
return mainElement;
|
||||||
|
}
|
||||||
|
|
||||||
|
static private Class<?>[] fieldSignature = new Class[] { String.class, String.class,
|
||||||
Composite.class };
|
Composite.class };
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public FieldEditor getFieldEditor(String name, String labelText, Composite parent) {
|
public FieldEditor getFieldEditor(String name, String labelText, Composite parent) {
|
||||||
String className = fieldEditorClassName;
|
if (fieldEditorFactory != null) {
|
||||||
if (fieldEditorClassName == null) {
|
return fieldEditorFactory.createFieldEditor(name, labelText, parent);
|
||||||
className = ReadOnlyFieldEditor.class.getName();
|
} else if (fieldEditorFactoryClass != null) {
|
||||||
}
|
try {
|
||||||
try {
|
fieldEditorFactory = (IFieldEditorFactory) fConfig.createExecutableExtension("fieldEditorFactory"); //$NON-NLS-1$
|
||||||
Class cclass = Class.forName(className);
|
} catch (CoreException e) {
|
||||||
Constructor constructor = cclass.getConstructor(fieldSignature);
|
CDebugUIPlugin.log(e);
|
||||||
FieldEditor editor = (FieldEditor) constructor.newInstance(name, labelText, parent);
|
return null;
|
||||||
if (editor instanceof ICBreakpointsUIContributionUser) {
|
}
|
||||||
((ICBreakpointsUIContributionUser)editor).setContribution(this);
|
return fieldEditorFactory.createFieldEditor(name, labelText, parent);
|
||||||
}
|
} else if (fieldEditorClassName != null) {
|
||||||
return editor;
|
try {
|
||||||
} catch (Exception e) {
|
@SuppressWarnings("unchecked")
|
||||||
// cannot happened, would have happened when loading extension
|
Class<FieldEditor> cclass = (Class<FieldEditor>)Class.forName(fieldEditorClassName);
|
||||||
CDebugUIPlugin.log(e);
|
Constructor<FieldEditor> constructor = cclass.getConstructor(fieldSignature);
|
||||||
return null;
|
FieldEditor editor = constructor.newInstance(name, labelText, parent);
|
||||||
}
|
if (editor instanceof ICBreakpointsUIContributionUser) {
|
||||||
|
((ICBreakpointsUIContributionUser)editor).setContribution(this);
|
||||||
|
}
|
||||||
|
return editor;
|
||||||
|
} catch (Exception e) {
|
||||||
|
CDebugUIPlugin.log(e);
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
return new ReadOnlyFieldEditor(name, labelText, parent);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -96,7 +123,7 @@ class DefaultCBreakpointUIContribution implements ICBreakpointsUIContribution {
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean isApplicable(Map properties) {
|
public boolean isApplicable(Map<String, Object> properties) {
|
||||||
for (Object key : properties.keySet()) {
|
for (Object key : properties.keySet()) {
|
||||||
String value = conditions.get(key);
|
String value = conditions.get(key);
|
||||||
if (value != null) {
|
if (value != null) {
|
||||||
|
@ -109,6 +136,10 @@ class DefaultCBreakpointUIContribution implements ICBreakpointsUIContribution {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void setMainElement(String mainElement) {
|
||||||
|
this.mainElement = mainElement;
|
||||||
|
}
|
||||||
|
|
||||||
public void setLabel(String attLabel) {
|
public void setLabel(String attLabel) {
|
||||||
this.attLabel = attLabel;
|
this.attLabel = attLabel;
|
||||||
}
|
}
|
||||||
|
@ -120,6 +151,10 @@ class DefaultCBreakpointUIContribution implements ICBreakpointsUIContribution {
|
||||||
public void setControlClass(String controlClass) {
|
public void setControlClass(String controlClass) {
|
||||||
this.fieldEditorClassName = controlClass;
|
this.fieldEditorClassName = controlClass;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void setFieldEditorFactory(String factoryClass) {
|
||||||
|
fieldEditorFactoryClass = factoryClass;
|
||||||
|
}
|
||||||
|
|
||||||
public void setMarkerType(String markerId) {
|
public void setMarkerType(String markerId) {
|
||||||
this.markerType = markerId;
|
this.markerType = markerId;
|
||||||
|
|
|
@ -19,13 +19,33 @@ import org.eclipse.jface.preference.FieldEditor;
|
||||||
import org.eclipse.swt.widgets.Composite;
|
import org.eclipse.swt.widgets.Composite;
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Interface representing a contributed UI element for breakpoint properties
|
||||||
|
* dialogs.
|
||||||
|
*
|
||||||
|
* @noimplement This interface is not intended to be implemented by clients.
|
||||||
|
* @noextend This interface is not intended to be extended by clients.
|
||||||
|
*/
|
||||||
public interface ICBreakpointsUIContribution {
|
public interface ICBreakpointsUIContribution {
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Main element name of breakpoint labels extension element.
|
||||||
|
* @since 7.2
|
||||||
|
*/
|
||||||
|
public static final String BREAKPOINT_LABELS = "breakpointLabels"; //$NON-NLS-1$
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Main element name of breakpoint editors extension element.
|
||||||
|
* @since 7.2
|
||||||
|
*/
|
||||||
|
public static final String BREAKPOINT_EDITORS = "breakpointEditors"; //$NON-NLS-1$
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Attribute id
|
* Attribute id
|
||||||
* @return
|
* @return
|
||||||
*/
|
*/
|
||||||
public String getId();
|
public String getId();
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Extenralizable label for this attribute id
|
* Extenralizable label for this attribute id
|
||||||
* @return
|
* @return
|
||||||
|
@ -41,6 +61,14 @@ public interface ICBreakpointsUIContribution {
|
||||||
*/
|
*/
|
||||||
public FieldEditor getFieldEditor(String name, String labelText, Composite parent);
|
public FieldEditor getFieldEditor(String name, String labelText, Composite parent);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Returns the element name under which this attribute was added. The value should either be
|
||||||
|
* "breakpointLabels" or "breakpointEditors".
|
||||||
|
* @return Main element name.
|
||||||
|
* @since 7.2
|
||||||
|
*/
|
||||||
|
public String getMainElement();
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Get raw field editor class name
|
* Get raw field editor class name
|
||||||
* @return class name
|
* @return class name
|
||||||
|
|
|
@ -0,0 +1,38 @@
|
||||||
|
/*******************************************************************************
|
||||||
|
* Copyright (c) 2012 Wind River Systems and others.
|
||||||
|
* All rights reserved. This program and the accompanying materials
|
||||||
|
* are made available under the terms of the Eclipse Public License v1.0
|
||||||
|
* which accompanies this distribution, and is available at
|
||||||
|
* http://www.eclipse.org/legal/epl-v10.html
|
||||||
|
*
|
||||||
|
* Contributors:
|
||||||
|
* Wind River Systems - initial API and implementation
|
||||||
|
*******************************************************************************/
|
||||||
|
package org.eclipse.cdt.debug.ui.breakpoints;
|
||||||
|
|
||||||
|
import org.eclipse.jface.preference.FieldEditor;
|
||||||
|
import org.eclipse.swt.widgets.Composite;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Factory for creating field editors contributed through the <code>
|
||||||
|
* org.eclipse.cdt.debug.ui.breakpointContribution</code> extension point.
|
||||||
|
* <p>
|
||||||
|
* Field editors do not have a non-arg constructor, therefore custom editors
|
||||||
|
* cannot be created directly by the extension point directly. This factory
|
||||||
|
* allows clients to instantiate a custom field editor which is not on the class
|
||||||
|
* path of the CDT debug UI plugin.
|
||||||
|
* </p>
|
||||||
|
* @since 7.2
|
||||||
|
*/
|
||||||
|
public interface IFieldEditorFactory {
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Creates a field editor with given parameters.
|
||||||
|
*
|
||||||
|
* @param name Field editor's property name.
|
||||||
|
* @param labelText Field editors label.
|
||||||
|
* @param parent Field editors parent control.
|
||||||
|
* @return Newly created field editor.
|
||||||
|
*/
|
||||||
|
public FieldEditor createFieldEditor(String name, String labelText, Composite parent);
|
||||||
|
}
|
|
@ -38,7 +38,6 @@ import org.eclipse.swt.widgets.Group;
|
||||||
import org.eclipse.swt.widgets.Label;
|
import org.eclipse.swt.widgets.Label;
|
||||||
import org.eclipse.swt.widgets.Text;
|
import org.eclipse.swt.widgets.Text;
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* A launch configuration tab that displays and edits program arguments,
|
* A launch configuration tab that displays and edits program arguments,
|
||||||
* and working directory launch configuration attributes.
|
* and working directory launch configuration attributes.
|
||||||
|
@ -47,7 +46,6 @@ import org.eclipse.swt.widgets.Text;
|
||||||
* </p>
|
* </p>
|
||||||
*/
|
*/
|
||||||
public class CArgumentsTab extends CLaunchConfigurationTab {
|
public class CArgumentsTab extends CLaunchConfigurationTab {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Tab identifier used for ordering of tabs added using the
|
* Tab identifier used for ordering of tabs added using the
|
||||||
* <code>org.eclipse.debug.ui.launchConfigurationTabs</code>
|
* <code>org.eclipse.debug.ui.launchConfigurationTabs</code>
|
||||||
|
@ -65,20 +63,17 @@ public class CArgumentsTab extends CLaunchConfigurationTab {
|
||||||
// Working directory
|
// Working directory
|
||||||
protected WorkingDirectoryBlock fWorkingDirectoryBlock = new WorkingDirectoryBlock();
|
protected WorkingDirectoryBlock fWorkingDirectoryBlock = new WorkingDirectoryBlock();
|
||||||
|
|
||||||
/* (non-Javadoc)
|
|
||||||
* @see org.eclipse.debug.ui.ILaunchConfigurationTab#createControl(org.eclipse.swt.widgets.Composite)
|
|
||||||
*/
|
|
||||||
@Override
|
@Override
|
||||||
public void createControl(Composite parent) {
|
public void createControl(Composite parent) {
|
||||||
Font font = parent.getFont();
|
Font font = parent.getFont();
|
||||||
Composite comp = new Composite(parent, SWT.NONE);
|
Composite comp = new Composite(parent, SWT.NONE);
|
||||||
GridLayout layout = new GridLayout(1, true);
|
GridLayout layout = new GridLayout(1, true);
|
||||||
comp.setLayout(layout);
|
comp.setLayout(layout);
|
||||||
comp.setFont(font);
|
comp.setFont(font);
|
||||||
|
|
||||||
GridData gd = new GridData(GridData.FILL_BOTH);
|
GridData gd = new GridData(GridData.FILL_BOTH);
|
||||||
comp.setLayoutData(gd);
|
comp.setLayoutData(gd);
|
||||||
setControl(comp);
|
setControl(comp);
|
||||||
|
|
||||||
GdbUIPlugin.getDefault().getWorkbench().getHelpSystem().setHelp(getControl(), ICDTLaunchHelpContextIds.LAUNCH_CONFIGURATION_DIALOG_ARGUMNETS_TAB);
|
GdbUIPlugin.getDefault().getWorkbench().getHelpSystem().setHelp(getControl(), ICDTLaunchHelpContextIds.LAUNCH_CONFIGURATION_DIALOG_ARGUMNETS_TAB);
|
||||||
|
|
||||||
|
@ -87,52 +82,46 @@ public class CArgumentsTab extends CLaunchConfigurationTab {
|
||||||
fWorkingDirectoryBlock.createControl(comp);
|
fWorkingDirectoryBlock.createControl(comp);
|
||||||
}
|
}
|
||||||
|
|
||||||
protected void createArgumentComponent(Composite comp, int horizontalSpan) {
|
protected void createArgumentComponent(Composite comp, int horizontalSpan) {
|
||||||
Font font = comp.getFont();
|
Font font = comp.getFont();
|
||||||
Group group = new Group(comp, SWT.NONE);
|
Group group = new Group(comp, SWT.NONE);
|
||||||
group.setFont(font);
|
group.setFont(font);
|
||||||
group.setLayout(new GridLayout());
|
group.setLayout(new GridLayout());
|
||||||
GridData gd = new GridData(GridData.FILL_BOTH);
|
GridData gd = new GridData(GridData.FILL_BOTH);
|
||||||
gd.horizontalSpan = horizontalSpan;
|
gd.horizontalSpan = horizontalSpan;
|
||||||
group.setLayoutData(gd);
|
group.setLayoutData(gd);
|
||||||
|
|
||||||
group.setText(LaunchMessages.getString("CArgumentsTab.C/C++_Program_Arguments")); //$NON-NLS-1$
|
group.setText(LaunchMessages.getString("CArgumentsTab.C/C++_Program_Arguments")); //$NON-NLS-1$
|
||||||
fPrgmArgumentsText = new Text(group, SWT.MULTI | SWT.WRAP | SWT.BORDER | SWT.V_SCROLL);
|
fPrgmArgumentsText = new Text(group, SWT.MULTI | SWT.WRAP | SWT.BORDER | SWT.V_SCROLL);
|
||||||
fPrgmArgumentsText.getAccessible().addAccessibleListener(
|
fPrgmArgumentsText.getAccessible().addAccessibleListener(
|
||||||
new AccessibleAdapter() {
|
new AccessibleAdapter() {
|
||||||
@Override
|
@Override
|
||||||
public void getName(AccessibleEvent e) {
|
public void getName(AccessibleEvent e) {
|
||||||
e.result = LaunchMessages.getString("CArgumentsTab.C/C++_Program_Arguments"); //$NON-NLS-1$
|
e.result = LaunchMessages.getString("CArgumentsTab.C/C++_Program_Arguments"); //$NON-NLS-1$
|
||||||
}
|
}
|
||||||
}
|
});
|
||||||
);
|
gd = new GridData(GridData.FILL_BOTH);
|
||||||
gd = new GridData(GridData.FILL_BOTH);
|
gd.heightHint = 40;
|
||||||
gd.heightHint = 40;
|
gd.widthHint = 100;
|
||||||
gd.widthHint = 100;
|
fPrgmArgumentsText.setLayoutData(gd);
|
||||||
fPrgmArgumentsText.setLayoutData(gd);
|
fPrgmArgumentsText.setFont(font);
|
||||||
fPrgmArgumentsText.setFont(font);
|
fPrgmArgumentsText.addModifyListener(new ModifyListener() {
|
||||||
fPrgmArgumentsText.addModifyListener(new ModifyListener() {
|
@Override
|
||||||
@Override
|
public void modifyText(ModifyEvent evt) {
|
||||||
public void modifyText(ModifyEvent evt) {
|
updateLaunchConfigurationDialog();
|
||||||
updateLaunchConfigurationDialog();
|
}
|
||||||
}
|
});
|
||||||
});
|
fArgumentVariablesButton= createPushButton(group, LaunchMessages.getString("CArgumentsTab.Variables"), null); //$NON-NLS-1$
|
||||||
fArgumentVariablesButton= createPushButton(group, LaunchMessages.getString("CArgumentsTab.Variables"), null); //$NON-NLS-1$
|
gd = new GridData(GridData.HORIZONTAL_ALIGN_END);
|
||||||
gd = new GridData(GridData.HORIZONTAL_ALIGN_END);
|
fArgumentVariablesButton.setLayoutData(gd);
|
||||||
fArgumentVariablesButton.setLayoutData(gd);
|
fArgumentVariablesButton.addSelectionListener(new SelectionAdapter() {
|
||||||
fArgumentVariablesButton.addSelectionListener(new SelectionAdapter() {
|
@Override
|
||||||
|
public void widgetSelected(SelectionEvent arg0) {
|
||||||
/* (non-Javadoc)
|
handleVariablesButtonSelected(fPrgmArgumentsText);
|
||||||
* @see org.eclipse.swt.events.SelectionAdapter#widgetSelected(org.eclipse.swt.events.SelectionEvent)
|
}
|
||||||
*/
|
});
|
||||||
@Override
|
addControlAccessibleListener(fArgumentVariablesButton, fArgumentVariablesButton.getText()); // need to strip the mnemonic from buttons
|
||||||
public void widgetSelected(SelectionEvent arg0) {
|
}
|
||||||
handleVariablesButtonSelected(fPrgmArgumentsText);
|
|
||||||
}
|
|
||||||
|
|
||||||
});
|
|
||||||
addControlAccessibleListener(fArgumentVariablesButton, fArgumentVariablesButton.getText()); // need to strip the mnemonic from buttons
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* A variable entry button has been pressed for the given text
|
* A variable entry button has been pressed for the given text
|
||||||
|
@ -142,7 +131,6 @@ public class CArgumentsTab extends CLaunchConfigurationTab {
|
||||||
protected void handleVariablesButtonSelected(Text textField) {
|
protected void handleVariablesButtonSelected(Text textField) {
|
||||||
String variable = getVariable();
|
String variable = getVariable();
|
||||||
if (variable != null) {
|
if (variable != null) {
|
||||||
// We should use insert() but not append() to be consistent with the Platform behavior (e.g. Common tab)
|
|
||||||
textField.insert(variable);
|
textField.insert(variable);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -158,7 +146,7 @@ public class CArgumentsTab extends CLaunchConfigurationTab {
|
||||||
}
|
}
|
||||||
|
|
||||||
public void addControlAccessibleListener(Control control, String controlName) {
|
public void addControlAccessibleListener(Control control, String controlName) {
|
||||||
//strip mnemonic (&)
|
// Strip mnemonic (&)
|
||||||
String[] strs = controlName.split("&"); //$NON-NLS-1$
|
String[] strs = controlName.split("&"); //$NON-NLS-1$
|
||||||
StringBuffer stripped = new StringBuffer();
|
StringBuffer stripped = new StringBuffer();
|
||||||
for (int i = 0; i < strs.length; i++) {
|
for (int i = 0; i < strs.length; i++) {
|
||||||
|
@ -169,36 +157,28 @@ public class CArgumentsTab extends CLaunchConfigurationTab {
|
||||||
|
|
||||||
private class ControlAccessibleListener extends AccessibleAdapter {
|
private class ControlAccessibleListener extends AccessibleAdapter {
|
||||||
private String controlName;
|
private String controlName;
|
||||||
|
|
||||||
ControlAccessibleListener(String name) {
|
ControlAccessibleListener(String name) {
|
||||||
controlName = name;
|
controlName = name;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void getName(AccessibleEvent e) {
|
public void getName(AccessibleEvent e) {
|
||||||
e.result = controlName;
|
e.result = controlName;
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/* (non-Javadoc)
|
|
||||||
* @see org.eclipse.debug.ui.ILaunchConfigurationTab#isValid(org.eclipse.debug.core.ILaunchConfiguration)
|
|
||||||
*/
|
|
||||||
@Override
|
@Override
|
||||||
public boolean isValid(ILaunchConfiguration config) {
|
public boolean isValid(ILaunchConfiguration config) {
|
||||||
return fWorkingDirectoryBlock.isValid(config);
|
return fWorkingDirectoryBlock.isValid(config);
|
||||||
}
|
}
|
||||||
|
|
||||||
/* (non-Javadoc)
|
|
||||||
* @see org.eclipse.debug.ui.ILaunchConfigurationTab#setDefaults(org.eclipse.debug.core.ILaunchConfigurationWorkingCopy)
|
|
||||||
*/
|
|
||||||
@Override
|
@Override
|
||||||
public void setDefaults(ILaunchConfigurationWorkingCopy config) {
|
public void setDefaults(ILaunchConfigurationWorkingCopy config) {
|
||||||
config.setAttribute(ICDTLaunchConfigurationConstants.ATTR_PROGRAM_ARGUMENTS, (String) null);
|
config.setAttribute(ICDTLaunchConfigurationConstants.ATTR_PROGRAM_ARGUMENTS, (String) null);
|
||||||
config.setAttribute(ICDTLaunchConfigurationConstants.ATTR_WORKING_DIRECTORY, (String) null);
|
config.setAttribute(ICDTLaunchConfigurationConstants.ATTR_WORKING_DIRECTORY, (String) null);
|
||||||
}
|
}
|
||||||
|
|
||||||
/* (non-Javadoc)
|
|
||||||
* @see org.eclipse.debug.ui.ILaunchConfigurationTab#initializeFrom(org.eclipse.debug.core.ILaunchConfiguration)
|
|
||||||
*/
|
|
||||||
@Override
|
@Override
|
||||||
public void initializeFrom(ILaunchConfiguration configuration) {
|
public void initializeFrom(ILaunchConfiguration configuration) {
|
||||||
try {
|
try {
|
||||||
|
@ -211,9 +191,6 @@ public class CArgumentsTab extends CLaunchConfigurationTab {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/* (non-Javadoc)
|
|
||||||
* @see org.eclipse.debug.ui.ILaunchConfigurationTab#performApply(org.eclipse.debug.core.ILaunchConfigurationWorkingCopy)
|
|
||||||
*/
|
|
||||||
@Override
|
@Override
|
||||||
public void performApply(ILaunchConfigurationWorkingCopy configuration) {
|
public void performApply(ILaunchConfigurationWorkingCopy configuration) {
|
||||||
configuration.setAttribute(
|
configuration.setAttribute(
|
||||||
|
@ -242,26 +219,17 @@ public class CArgumentsTab extends CLaunchConfigurationTab {
|
||||||
return TAB_ID;
|
return TAB_ID;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* (non-Javadoc)
|
|
||||||
* @see org.eclipse.debug.ui.ILaunchConfigurationTab#getName()
|
|
||||||
*/
|
|
||||||
@Override
|
@Override
|
||||||
public String getName() {
|
public String getName() {
|
||||||
return LaunchMessages.getString("CArgumentsTab.Arguments"); //$NON-NLS-1$
|
return LaunchMessages.getString("CArgumentsTab.Arguments"); //$NON-NLS-1$
|
||||||
}
|
}
|
||||||
|
|
||||||
/* (non-Javadoc)
|
|
||||||
* @see org.eclipse.debug.ui.ILaunchConfigurationTab#setLaunchConfigurationDialog(org.eclipse.debug.ui.ILaunchConfigurationDialog)
|
|
||||||
*/
|
|
||||||
@Override
|
@Override
|
||||||
public void setLaunchConfigurationDialog(ILaunchConfigurationDialog dialog) {
|
public void setLaunchConfigurationDialog(ILaunchConfigurationDialog dialog) {
|
||||||
super.setLaunchConfigurationDialog(dialog);
|
super.setLaunchConfigurationDialog(dialog);
|
||||||
fWorkingDirectoryBlock.setLaunchConfigurationDialog(dialog);
|
fWorkingDirectoryBlock.setLaunchConfigurationDialog(dialog);
|
||||||
}
|
}
|
||||||
|
|
||||||
/* (non-Javadoc)
|
|
||||||
* @see org.eclipse.debug.ui.ILaunchConfigurationTab#getErrorMessage()
|
|
||||||
*/
|
|
||||||
@Override
|
@Override
|
||||||
public String getErrorMessage() {
|
public String getErrorMessage() {
|
||||||
String m = super.getErrorMessage();
|
String m = super.getErrorMessage();
|
||||||
|
@ -271,9 +239,6 @@ public class CArgumentsTab extends CLaunchConfigurationTab {
|
||||||
return m;
|
return m;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* (non-Javadoc)
|
|
||||||
* @see org.eclipse.debug.ui.ILaunchConfigurationTab#getMessage()
|
|
||||||
*/
|
|
||||||
@Override
|
@Override
|
||||||
public String getMessage() {
|
public String getMessage() {
|
||||||
String m = super.getMessage();
|
String m = super.getMessage();
|
||||||
|
@ -283,17 +248,11 @@ public class CArgumentsTab extends CLaunchConfigurationTab {
|
||||||
return m;
|
return m;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* (non-Javadoc)
|
|
||||||
* @see org.eclipse.debug.ui.ILaunchConfigurationTab#getImage()
|
|
||||||
*/
|
|
||||||
@Override
|
@Override
|
||||||
public Image getImage() {
|
public Image getImage() {
|
||||||
return LaunchImages.get(LaunchImages.IMG_VIEW_ARGUMENTS_TAB);
|
return LaunchImages.get(LaunchImages.IMG_VIEW_ARGUMENTS_TAB);
|
||||||
}
|
}
|
||||||
|
|
||||||
/* (non-Javadoc)
|
|
||||||
* @see org.eclipse.debug.ui.AbstractLaunchConfigurationTab#updateLaunchConfigurationDialog()
|
|
||||||
*/
|
|
||||||
@Override
|
@Override
|
||||||
protected void updateLaunchConfigurationDialog() {
|
protected void updateLaunchConfigurationDialog() {
|
||||||
super.updateLaunchConfigurationDialog();
|
super.updateLaunchConfigurationDialog();
|
||||||
|
|
|
@ -38,7 +38,6 @@ import org.eclipse.ui.IFileEditorInput;
|
||||||
import org.eclipse.ui.IWorkbenchPage;
|
import org.eclipse.ui.IWorkbenchPage;
|
||||||
|
|
||||||
public abstract class CLaunchConfigurationTab extends AbstractLaunchConfigurationTab {
|
public abstract class CLaunchConfigurationTab extends AbstractLaunchConfigurationTab {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Returns the current C element context from which to initialize default
|
* Returns the current C element context from which to initialize default
|
||||||
* settings, or <code>null</code> if none. Note, if possible we will
|
* settings, or <code>null</code> if none. Note, if possible we will
|
||||||
|
@ -53,13 +52,14 @@ public abstract class CLaunchConfigurationTab extends AbstractLaunchConfiguratio
|
||||||
IWorkbenchPage page = GdbUIPlugin.getActivePage();
|
IWorkbenchPage page = GdbUIPlugin.getActivePage();
|
||||||
Object obj = null;
|
Object obj = null;
|
||||||
try {
|
try {
|
||||||
projectName = config.getAttribute(ICDTLaunchConfigurationConstants.ATTR_PROJECT_NAME, (String)null);
|
projectName = config.getAttribute(ICDTLaunchConfigurationConstants.ATTR_PROJECT_NAME, (String) null);
|
||||||
programName = config.getAttribute(ICDTLaunchConfigurationConstants.ATTR_PROGRAM_NAME, (String)null);
|
programName = config.getAttribute(ICDTLaunchConfigurationConstants.ATTR_PROGRAM_NAME, (String) null);
|
||||||
if (programName != null) {
|
if (programName != null) {
|
||||||
programName = VariablesPlugin.getDefault().getStringVariableManager().performStringSubstitution(programName);
|
programName = VariablesPlugin.getDefault().getStringVariableManager().performStringSubstitution(programName);
|
||||||
}
|
}
|
||||||
} catch (CoreException e) {
|
} catch (CoreException e) {
|
||||||
}
|
}
|
||||||
|
|
||||||
if (projectName != null && !projectName.equals("")) { //$NON-NLS-1$
|
if (projectName != null && !projectName.equals("")) { //$NON-NLS-1$
|
||||||
IProject project = ResourcesPlugin.getWorkspace().getRoot().getProject(projectName);
|
IProject project = ResourcesPlugin.getWorkspace().getRoot().getProject(projectName);
|
||||||
ICProject cProject = CCorePlugin.getDefault().getCoreModel().create(project);
|
ICProject cProject = CCorePlugin.getDefault().getCoreModel().create(project);
|
||||||
|
@ -115,15 +115,13 @@ public abstract class CLaunchConfigurationTab extends AbstractLaunchConfiguratio
|
||||||
return (ICElement)obj;
|
return (ICElement)obj;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (page != null)
|
if (page != null) {
|
||||||
{
|
|
||||||
IEditorPart part = page.getActiveEditor();
|
IEditorPart part = page.getActiveEditor();
|
||||||
if (part != null) {
|
if (part != null) {
|
||||||
IEditorInput input = part.getEditorInput();
|
IEditorInput input = part.getEditorInput();
|
||||||
if (input instanceof IFileEditorInput) {
|
if (input instanceof IFileEditorInput) {
|
||||||
IFile file = ((IFileEditorInput)input).getFile();
|
IFile file = ((IFileEditorInput)input).getFile();
|
||||||
if (file != null)
|
if (file != null) {
|
||||||
{
|
|
||||||
ICElement ce = CoreModel.getDefault().create(file);
|
ICElement ce = CoreModel.getDefault().create(file);
|
||||||
if (ce == null) {
|
if (ce == null) {
|
||||||
IProject pro = file.getProject();
|
IProject pro = file.getProject();
|
||||||
|
@ -146,14 +144,12 @@ public abstract class CLaunchConfigurationTab extends AbstractLaunchConfiguratio
|
||||||
if (cProject != null && cProject.exists()) {
|
if (cProject != null && cProject.exists()) {
|
||||||
name = cProject.getElementName();
|
name = cProject.getElementName();
|
||||||
config.setMappedResources(new IResource[] {cProject.getProject()});
|
config.setMappedResources(new IResource[] {cProject.getProject()});
|
||||||
|
|
||||||
ICProjectDescription projDes = CCorePlugin.getDefault().getProjectDescription(cProject.getProject());
|
ICProjectDescription projDes = CCorePlugin.getDefault().getProjectDescription(cProject.getProject());
|
||||||
String buildConfigID = projDes.getActiveConfiguration().getId();
|
String buildConfigID = projDes.getActiveConfiguration().getId();
|
||||||
config.setAttribute(ICDTLaunchConfigurationConstants.ATTR_PROJECT_BUILD_CONFIG_ID, buildConfigID);
|
config.setAttribute(ICDTLaunchConfigurationConstants.ATTR_PROJECT_BUILD_CONFIG_ID, buildConfigID);
|
||||||
|
|
||||||
}
|
}
|
||||||
config.setAttribute(ICDTLaunchConfigurationConstants.ATTR_PROJECT_NAME, name);
|
config.setAttribute(ICDTLaunchConfigurationConstants.ATTR_PROJECT_NAME, name);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
protected String getPlatform(ILaunchConfiguration config) {
|
protected String getPlatform(ILaunchConfiguration config) {
|
||||||
|
|
|
@ -16,7 +16,8 @@ Require-Bundle: org.eclipse.core.runtime,
|
||||||
org.eclipse.ui.ide,
|
org.eclipse.ui.ide,
|
||||||
org.eclipse.cdt.examples.dsf.pda,
|
org.eclipse.cdt.examples.dsf.pda,
|
||||||
org.eclipse.cdt.dsf,
|
org.eclipse.cdt.dsf,
|
||||||
org.eclipse.cdt.dsf.ui
|
org.eclipse.cdt.dsf.ui,
|
||||||
|
org.eclipse.cdt.debug.ui;bundle-version="7.2.0"
|
||||||
Bundle-ActivationPolicy: lazy
|
Bundle-ActivationPolicy: lazy
|
||||||
Export-Package: org.eclipse.cdt.examples.dsf.pda.ui,
|
Export-Package: org.eclipse.cdt.examples.dsf.pda.ui,
|
||||||
org.eclipse.cdt.examples.dsf.pda.ui.breakpoints,
|
org.eclipse.cdt.examples.dsf.pda.ui.breakpoints,
|
||||||
|
|
|
@ -110,5 +110,18 @@
|
||||||
class="org.eclipse.cdt.examples.dsf.pda.ui.viewmodel.VariablePersistableFactory"
|
class="org.eclipse.cdt.examples.dsf.pda.ui.viewmodel.VariablePersistableFactory"
|
||||||
id="org.eclipse.cdt.examples.dsf.pda.ui.variablePersitableFactory">
|
id="org.eclipse.cdt.examples.dsf.pda.ui.variablePersitableFactory">
|
||||||
</factory>
|
</factory>
|
||||||
|
</extension>
|
||||||
|
<extension
|
||||||
|
point="org.eclipse.cdt.debug.ui.breakpointContribution">
|
||||||
|
<breakpointEditors
|
||||||
|
debugModelId="org.eclipse.cdt.examples.dsf.pda.debugModel"
|
||||||
|
markerType="org.eclipse.cdt.debug.core.cWatchpointMarker">
|
||||||
|
<attribute
|
||||||
|
fieldEditorFactory="org.eclipse.cdt.examples.dsf.pda.ui.breakpoints.PDAWatchpointFunctionFieldEditorFactory"
|
||||||
|
label="Function"
|
||||||
|
name="FUNCTION_NAME"
|
||||||
|
type="string">
|
||||||
|
</attribute>
|
||||||
|
</breakpointEditors>
|
||||||
</extension> -->
|
</extension> -->
|
||||||
</plugin>
|
</plugin>
|
||||||
|
|
|
@ -0,0 +1,26 @@
|
||||||
|
/*******************************************************************************
|
||||||
|
* Copyright (c) 2012 Wind River Systems and others.
|
||||||
|
* All rights reserved. This program and the accompanying materials
|
||||||
|
* are made available under the terms of the Eclipse Public License v1.0
|
||||||
|
* which accompanies this distribution, and is available at
|
||||||
|
* http://www.eclipse.org/legal/epl-v10.html
|
||||||
|
*
|
||||||
|
* Contributors:
|
||||||
|
* Wind River Systems - initial API and implementation
|
||||||
|
*******************************************************************************/
|
||||||
|
package org.eclipse.cdt.examples.dsf.pda.ui.breakpoints;
|
||||||
|
|
||||||
|
import org.eclipse.cdt.debug.ui.breakpoints.IFieldEditorFactory;
|
||||||
|
import org.eclipse.jface.preference.FieldEditor;
|
||||||
|
import org.eclipse.jface.preference.StringFieldEditor;
|
||||||
|
import org.eclipse.swt.widgets.Composite;
|
||||||
|
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
public class PDAWatchpointFunctionFieldEditorFactory implements IFieldEditorFactory {
|
||||||
|
|
||||||
|
public FieldEditor createFieldEditor(String name, String labelText, Composite parent) {
|
||||||
|
return new StringFieldEditor(name, labelText, parent);
|
||||||
|
}
|
||||||
|
}
|
|
@ -16,6 +16,7 @@ import java.util.List;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
|
|
||||||
import org.eclipse.cdt.debug.core.model.ICLineBreakpoint;
|
import org.eclipse.cdt.debug.core.model.ICLineBreakpoint;
|
||||||
|
import org.eclipse.cdt.debug.core.model.ICWatchpoint;
|
||||||
import org.eclipse.cdt.dsf.concurrent.DataRequestMonitor;
|
import org.eclipse.cdt.dsf.concurrent.DataRequestMonitor;
|
||||||
import org.eclipse.cdt.dsf.debug.service.BreakpointsMediator;
|
import org.eclipse.cdt.dsf.debug.service.BreakpointsMediator;
|
||||||
import org.eclipse.cdt.dsf.debug.service.BreakpointsMediator2;
|
import org.eclipse.cdt.dsf.debug.service.BreakpointsMediator2;
|
||||||
|
@ -59,6 +60,11 @@ public class PDABreakpointAttributeTranslator implements IBreakpointAttributeTra
|
||||||
PDAWatchpoint.MODIFICATION
|
PDAWatchpoint.MODIFICATION
|
||||||
};
|
};
|
||||||
|
|
||||||
|
private static final String[] fgCDTWatchpointAttributes = {
|
||||||
|
IBreakpoint.ENABLED,
|
||||||
|
PDAWatchpoint.FUNCTION_NAME,
|
||||||
|
};
|
||||||
|
|
||||||
// PDA breakpoints translator doesn't keep any state and it doesn't
|
// PDA breakpoints translator doesn't keep any state and it doesn't
|
||||||
// need to initialize or clean up.
|
// need to initialize or clean up.
|
||||||
public void initialize(BreakpointsMediator2 mediator) {
|
public void initialize(BreakpointsMediator2 mediator) {
|
||||||
|
@ -71,8 +77,10 @@ public class PDABreakpointAttributeTranslator implements IBreakpointAttributeTra
|
||||||
private List<Map<String, Object>> getBreakpointAttributes(IBreakpoint bp, boolean bpManagerEnabled)
|
private List<Map<String, Object>> getBreakpointAttributes(IBreakpoint bp, boolean bpManagerEnabled)
|
||||||
throws CoreException
|
throws CoreException
|
||||||
{
|
{
|
||||||
if (bp instanceof ICLineBreakpoint) {
|
if (bp instanceof ICLineBreakpoint) {
|
||||||
return getCBreakpointAttributes((ICLineBreakpoint)bp, bpManagerEnabled);
|
return getCBreakpointAttributes((ICLineBreakpoint)bp, bpManagerEnabled);
|
||||||
|
} else if (bp instanceof ICWatchpoint) {
|
||||||
|
return getCWatchpointAttributes((ICWatchpoint)bp, bpManagerEnabled);
|
||||||
} else {
|
} else {
|
||||||
return getPDABreakpointAttributes(bp, bpManagerEnabled);
|
return getPDABreakpointAttributes(bp, bpManagerEnabled);
|
||||||
}
|
}
|
||||||
|
@ -112,7 +120,45 @@ public class PDABreakpointAttributeTranslator implements IBreakpointAttributeTra
|
||||||
retVal.add(attrs);
|
retVal.add(attrs);
|
||||||
return retVal;
|
return retVal;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private List<Map<String, Object>> getCWatchpointAttributes(ICWatchpoint bp, boolean bpManagerEnabled)
|
||||||
|
throws CoreException
|
||||||
|
{
|
||||||
|
Map<String, Object> attrs = new HashMap<String, Object>();
|
||||||
|
|
||||||
|
// Check that the marker exists and retrieve its attributes.
|
||||||
|
// Due to accepted race conditions, the breakpiont marker may become null
|
||||||
|
// while this method is being invoked. In this case throw an exception
|
||||||
|
// and let the caller handle it.
|
||||||
|
IMarker marker = bp.getMarker();
|
||||||
|
if (marker == null || !marker.exists()) {
|
||||||
|
throw new DebugException(new Status(IStatus.ERROR, PDAPlugin.PLUGIN_ID, DebugException.REQUEST_FAILED, "Breakpoint marker does not exist", null));
|
||||||
|
}
|
||||||
|
// Suppress cast warning: platform is still on Java 1.3
|
||||||
|
Map<String, Object> platformBpAttrs = marker.getAttributes();
|
||||||
|
|
||||||
|
// Copy breakpoint attributes.
|
||||||
|
attrs.put(PDABreakpoints.ATTR_BREAKPOINT_TYPE, PDABreakpoints.PDA_WATCHPOINT);
|
||||||
|
attrs.put(PDABreakpoints.ATTR_BREAKPOINT_TYPE, PDABreakpoints.PDA_WATCHPOINT);
|
||||||
|
attrs.put(PDAWatchpoint.VAR_NAME, platformBpAttrs.get(ICWatchpoint.EXPRESSION));
|
||||||
|
attrs.put(PDAWatchpoint.ACCESS, platformBpAttrs.get(ICWatchpoint.READ));
|
||||||
|
attrs.put(PDAWatchpoint.MODIFICATION, platformBpAttrs.get(ICWatchpoint.WRITE));
|
||||||
|
|
||||||
|
copyAttributes(platformBpAttrs, attrs, fgCDTWatchpointAttributes);
|
||||||
|
|
||||||
|
// If the breakpoint manager is disabled, override the enabled attribute.
|
||||||
|
if (!bpManagerEnabled) {
|
||||||
|
attrs.put(IBreakpoint.ENABLED, false);
|
||||||
|
}
|
||||||
|
|
||||||
|
// The breakpoint mediator allows for multiple target-side breakpoints
|
||||||
|
// to be created for each IDE breakpoint. Although in case of PDA this
|
||||||
|
// feature is never used, we still have to return a list of attributes.
|
||||||
|
List<Map<String, Object>> retVal = new ArrayList<Map<String, Object>>(1);
|
||||||
|
retVal.add(attrs);
|
||||||
|
return retVal;
|
||||||
|
}
|
||||||
|
|
||||||
private List<Map<String, Object>> getPDABreakpointAttributes(IBreakpoint bp, boolean bpManagerEnabled)
|
private List<Map<String, Object>> getPDABreakpointAttributes(IBreakpoint bp, boolean bpManagerEnabled)
|
||||||
throws CoreException
|
throws CoreException
|
||||||
{
|
{
|
||||||
|
@ -178,7 +224,7 @@ public class PDABreakpointAttributeTranslator implements IBreakpointAttributeTra
|
||||||
|
|
||||||
public boolean supportsBreakpoint(IBreakpoint bp) {
|
public boolean supportsBreakpoint(IBreakpoint bp) {
|
||||||
return bp.getModelIdentifier().equals(PDAPlugin.ID_PDA_DEBUG_MODEL) ||
|
return bp.getModelIdentifier().equals(PDAPlugin.ID_PDA_DEBUG_MODEL) ||
|
||||||
bp instanceof ICLineBreakpoint;
|
bp instanceof ICLineBreakpoint || bp instanceof ICWatchpoint;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void updateBreakpointsStatus(
|
public void updateBreakpointsStatus(
|
||||||
|
|
|
@ -2,7 +2,7 @@ Manifest-Version: 1.0
|
||||||
Bundle-ManifestVersion: 2
|
Bundle-ManifestVersion: 2
|
||||||
Bundle-Name: %pluginName
|
Bundle-Name: %pluginName
|
||||||
Bundle-SymbolicName: org.eclipse.cdt.launch; singleton:=true
|
Bundle-SymbolicName: org.eclipse.cdt.launch; singleton:=true
|
||||||
Bundle-Version: 7.0.0.qualifier
|
Bundle-Version: 7.1.0.qualifier
|
||||||
Bundle-Activator: org.eclipse.cdt.launch.internal.ui.LaunchUIPlugin
|
Bundle-Activator: org.eclipse.cdt.launch.internal.ui.LaunchUIPlugin
|
||||||
Bundle-Vendor: %providerName
|
Bundle-Vendor: %providerName
|
||||||
Bundle-Localization: plugin
|
Bundle-Localization: plugin
|
||||||
|
|
|
@ -11,7 +11,7 @@
|
||||||
<relativePath>../../pom.xml</relativePath>
|
<relativePath>../../pom.xml</relativePath>
|
||||||
</parent>
|
</parent>
|
||||||
|
|
||||||
<version>7.0.0-SNAPSHOT</version>
|
<version>7.1.0-SNAPSHOT</version>
|
||||||
<artifactId>org.eclipse.cdt.launch</artifactId>
|
<artifactId>org.eclipse.cdt.launch</artifactId>
|
||||||
<packaging>eclipse-plugin</packaging>
|
<packaging>eclipse-plugin</packaging>
|
||||||
</project>
|
</project>
|
||||||
|
|
|
@ -8,7 +8,6 @@
|
||||||
* Contributors:
|
* Contributors:
|
||||||
* QNX Software Systems - Initial API and implementation
|
* QNX Software Systems - Initial API and implementation
|
||||||
* Ken Ryall (Nokia) - bug 178731
|
* Ken Ryall (Nokia) - bug 178731
|
||||||
* Anton Gorenkov
|
|
||||||
*******************************************************************************/
|
*******************************************************************************/
|
||||||
package org.eclipse.cdt.launch.ui;
|
package org.eclipse.cdt.launch.ui;
|
||||||
|
|
||||||
|
@ -45,7 +44,6 @@ import org.eclipse.ui.IFileEditorInput;
|
||||||
import org.eclipse.ui.IWorkbenchPage;
|
import org.eclipse.ui.IWorkbenchPage;
|
||||||
|
|
||||||
public abstract class CLaunchConfigurationTab extends AbstractLaunchConfigurationTab {
|
public abstract class CLaunchConfigurationTab extends AbstractLaunchConfigurationTab {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Returns the current C element context from which to initialize default
|
* Returns the current C element context from which to initialize default
|
||||||
* settings, or <code>null</code> if none. Note, if possible we will
|
* settings, or <code>null</code> if none. Note, if possible we will
|
||||||
|
@ -85,9 +83,9 @@ public abstract class CLaunchConfigurationTab extends AbstractLaunchConfiguratio
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (obj instanceof IResource) {
|
if (obj instanceof IResource) {
|
||||||
ICElement ce = CoreModel.getDefault().create((IResource)obj);
|
ICElement ce = CoreModel.getDefault().create((IResource) obj);
|
||||||
if (ce == null) {
|
if (ce == null) {
|
||||||
IProject pro = ((IResource)obj).getProject();
|
IProject pro = ((IResource) obj).getProject();
|
||||||
ce = CoreModel.getDefault().create(pro);
|
ce = CoreModel.getDefault().create(pro);
|
||||||
}
|
}
|
||||||
obj = ce;
|
obj = ce;
|
||||||
|
@ -96,7 +94,7 @@ public abstract class CLaunchConfigurationTab extends AbstractLaunchConfiguratio
|
||||||
if (platform != null && !platform.equals("*")) { //$NON-NLS-1$
|
if (platform != null && !platform.equals("*")) { //$NON-NLS-1$
|
||||||
ICDescriptor descriptor;
|
ICDescriptor descriptor;
|
||||||
try {
|
try {
|
||||||
descriptor = CCorePlugin.getDefault().getCProjectDescription( ((ICElement)obj).getCProject().getProject(),
|
descriptor = CCorePlugin.getDefault().getCProjectDescription(((ICElement) obj).getCProject().getProject(),
|
||||||
false);
|
false);
|
||||||
if (descriptor != null) {
|
if (descriptor != null) {
|
||||||
String projectPlatform = descriptor.getPlatform();
|
String projectPlatform = descriptor.getPlatform();
|
||||||
|
@ -109,9 +107,9 @@ public abstract class CLaunchConfigurationTab extends AbstractLaunchConfiguratio
|
||||||
}
|
}
|
||||||
if (obj != null) {
|
if (obj != null) {
|
||||||
if (programName == null || programName.equals("")) { //$NON-NLS-1$
|
if (programName == null || programName.equals("")) { //$NON-NLS-1$
|
||||||
return (ICElement)obj;
|
return (ICElement) obj;
|
||||||
}
|
}
|
||||||
ICElement ce = (ICElement)obj;
|
ICElement ce = (ICElement) obj;
|
||||||
IProject project;
|
IProject project;
|
||||||
project = (IProject)ce.getCProject().getResource();
|
project = (IProject)ce.getCProject().getResource();
|
||||||
IPath programFile = project.getFile(programName).getLocation();
|
IPath programFile = project.getFile(programName).getLocation();
|
||||||
|
@ -119,11 +117,10 @@ public abstract class CLaunchConfigurationTab extends AbstractLaunchConfiguratio
|
||||||
if (ce != null && ce.exists()) {
|
if (ce != null && ce.exists()) {
|
||||||
return ce;
|
return ce;
|
||||||
}
|
}
|
||||||
return (ICElement)obj;
|
return (ICElement) obj;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (page != null)
|
if (page != null) {
|
||||||
{
|
|
||||||
IEditorPart part = page.getActiveEditor();
|
IEditorPart part = page.getActiveEditor();
|
||||||
if (part != null) {
|
if (part != null) {
|
||||||
IEditorInput input = part.getEditorInput();
|
IEditorInput input = part.getEditorInput();
|
||||||
|
@ -160,7 +157,6 @@ public abstract class CLaunchConfigurationTab extends AbstractLaunchConfiguratio
|
||||||
|
|
||||||
}
|
}
|
||||||
config.setAttribute(ICDTLaunchConfigurationConstants.ATTR_PROJECT_NAME, name);
|
config.setAttribute(ICDTLaunchConfigurationConstants.ATTR_PROJECT_NAME, name);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
protected String getPlatform(ILaunchConfiguration config) {
|
protected String getPlatform(ILaunchConfiguration config) {
|
||||||
|
@ -175,7 +171,7 @@ public abstract class CLaunchConfigurationTab extends AbstractLaunchConfiguratio
|
||||||
/**
|
/**
|
||||||
* Creates a button that allows user to insert build variables.
|
* Creates a button that allows user to insert build variables.
|
||||||
*
|
*
|
||||||
* @since 7.0
|
* @since 7.1
|
||||||
*/
|
*/
|
||||||
protected Button createVariablesButton(Composite parent, String label, final Text textField) {
|
protected Button createVariablesButton(Composite parent, String label, final Text textField) {
|
||||||
Button variablesButton = createPushButton(parent, label, null);
|
Button variablesButton = createPushButton(parent, label, null);
|
||||||
|
@ -196,7 +192,6 @@ public abstract class CLaunchConfigurationTab extends AbstractLaunchConfiguratio
|
||||||
private void handleVariablesButtonSelected(Text textField) {
|
private void handleVariablesButtonSelected(Text textField) {
|
||||||
String variable = getVariable();
|
String variable = getVariable();
|
||||||
if (variable != null) {
|
if (variable != null) {
|
||||||
// We should use insert() but not append() to be consistent with the Platform behavior (e.g. Common tab)
|
|
||||||
textField.insert(variable);
|
textField.insert(variable);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -210,5 +205,4 @@ public abstract class CLaunchConfigurationTab extends AbstractLaunchConfiguratio
|
||||||
dialog.open();
|
dialog.open();
|
||||||
return dialog.getVariableExpression();
|
return dialog.getVariableExpression();
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Reference in a new issue