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]
|
||||
*/
|
||||
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("fesetround(FE_UPWARD);\n"); //$NON-NLS-1$
|
||||
buffer.append("#endif\n"); //$NON-NLS-1$
|
||||
|
@ -46,7 +46,7 @@ public class AST2CSpecTest extends AST2SpecBaseTest {
|
|||
--End Example]
|
||||
*/
|
||||
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("int i;\n"); //$NON-NLS-1$
|
||||
parseCandCPP(buffer.toString(), false, 0);
|
||||
|
@ -61,7 +61,7 @@ public class AST2CSpecTest extends AST2SpecBaseTest {
|
|||
--End Example]
|
||||
*/
|
||||
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("char 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]
|
||||
*/
|
||||
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("float f1, f2;\n"); //$NON-NLS-1$
|
||||
buffer.append("double d;\n"); //$NON-NLS-1$
|
||||
|
@ -99,7 +99,7 @@ public class AST2CSpecTest extends AST2SpecBaseTest {
|
|||
--End Example]
|
||||
*/
|
||||
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("double d1, d2;\n"); //$NON-NLS-1$
|
||||
buffer.append("float f;\n"); //$NON-NLS-1$
|
||||
|
@ -121,7 +121,7 @@ public class AST2CSpecTest extends AST2SpecBaseTest {
|
|||
--End Example]
|
||||
*/
|
||||
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("double x, 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]
|
||||
*/
|
||||
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 a, b;\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]
|
||||
*/
|
||||
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("int f() {");
|
||||
buffer.append("int sum;\n"); //$NON-NLS-1$
|
||||
|
@ -186,7 +186,7 @@ public class AST2CSpecTest extends AST2SpecBaseTest {
|
|||
--End Example]
|
||||
*/
|
||||
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$
|
||||
parseCandCPP(buffer.toString(), false, 0);
|
||||
}
|
||||
|
@ -199,7 +199,7 @@ public class AST2CSpecTest extends AST2SpecBaseTest {
|
|||
--End Example]
|
||||
*/
|
||||
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 (*)(char *), double (*)[]);\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]
|
||||
*/
|
||||
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 y='\\0';\n"); //$NON-NLS-1$
|
||||
buffer.append("char z='\\x13';\n"); //$NON-NLS-1$
|
||||
|
@ -234,7 +234,7 @@ public class AST2CSpecTest extends AST2SpecBaseTest {
|
|||
--End Example]
|
||||
*/
|
||||
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 f2() {}\n"); //$NON-NLS-1$
|
||||
buffer.append("int f3() {}\n"); //$NON-NLS-1$
|
||||
|
@ -263,7 +263,7 @@ public class AST2CSpecTest extends AST2SpecBaseTest {
|
|||
--End Example]
|
||||
*/
|
||||
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 s;\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]
|
||||
*/
|
||||
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("struct {\n"); //$NON-NLS-1$
|
||||
buffer.append("int alltypes;\n"); //$NON-NLS-1$
|
||||
|
@ -351,7 +351,7 @@ public class AST2CSpecTest extends AST2SpecBaseTest {
|
|||
--End Example]
|
||||
*/
|
||||
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 t2 { int m; };\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]
|
||||
*/
|
||||
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$
|
||||
parse(buffer.toString(), ParserLanguage.C, true, 0);
|
||||
}
|
||||
|
@ -392,7 +392,7 @@ public class AST2CSpecTest extends AST2SpecBaseTest {
|
|||
--End Example]
|
||||
*/
|
||||
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("{\n"); //$NON-NLS-1$
|
||||
buffer.append("int *p;\n"); //$NON-NLS-1$
|
||||
|
@ -412,7 +412,7 @@ public class AST2CSpecTest extends AST2SpecBaseTest {
|
|||
--End Example]
|
||||
*/
|
||||
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("drawline((struct point){.x=1, .y=1},\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]
|
||||
*/
|
||||
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("(const float []){1e0, 1e1, 1e2, 1e3, 1e4, 1e5, 1e6};\n"); //$NON-NLS-1$
|
||||
buffer.append("}\n"); //$NON-NLS-1$
|
||||
|
@ -447,7 +447,7 @@ public class AST2CSpecTest extends AST2SpecBaseTest {
|
|||
--End Example]
|
||||
*/
|
||||
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("\"/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]
|
||||
*/
|
||||
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("(const char []){\"abc\"} == \"abc\";\n"); //$NON-NLS-1$
|
||||
buffer.append("}\n"); //$NON-NLS-1$
|
||||
|
@ -481,7 +481,7 @@ public class AST2CSpecTest extends AST2SpecBaseTest {
|
|||
--End Example]
|
||||
*/
|
||||
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("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$
|
||||
|
@ -505,7 +505,7 @@ public class AST2CSpecTest extends AST2SpecBaseTest {
|
|||
--End Example]
|
||||
*/
|
||||
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("int f (void)\n"); //$NON-NLS-1$
|
||||
buffer.append("{\n"); //$NON-NLS-1$
|
||||
|
@ -526,7 +526,7 @@ public class AST2CSpecTest extends AST2SpecBaseTest {
|
|||
--End Example]
|
||||
*/
|
||||
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("double *dp = alloc(sizeof *dp);\n"); //$NON-NLS-1$
|
||||
parseCandCPP(buffer.toString(), false, 0);
|
||||
|
@ -541,7 +541,7 @@ public class AST2CSpecTest extends AST2SpecBaseTest {
|
|||
--End Example]
|
||||
*/
|
||||
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 array[5];\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]
|
||||
*/
|
||||
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 n = 4, m = 3;\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]
|
||||
*/
|
||||
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("const void *c_vp;\n"); //$NON-NLS-1$
|
||||
buffer.append("void *vp;\n"); //$NON-NLS-1$
|
||||
|
@ -610,7 +610,7 @@ public class AST2CSpecTest extends AST2SpecBaseTest {
|
|||
--End Example]
|
||||
*/
|
||||
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("char c;\n"); //$NON-NLS-1$
|
||||
buffer.append("int i;\n"); //$NON-NLS-1$
|
||||
|
@ -633,7 +633,7 @@ public class AST2CSpecTest extends AST2SpecBaseTest {
|
|||
--End Example]
|
||||
*/
|
||||
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("const char **cpp;\n"); //$NON-NLS-1$
|
||||
buffer.append("char *p;\n"); //$NON-NLS-1$
|
||||
|
@ -657,7 +657,7 @@ public class AST2CSpecTest extends AST2SpecBaseTest {
|
|||
--End Example]
|
||||
*/
|
||||
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
|
||||
buffer.append("#define offsetof(TYPE, MEMBER) ((size_t) (&((TYPE *)0)->MEMBER))\n");
|
||||
|
||||
|
@ -682,7 +682,7 @@ public class AST2CSpecTest extends AST2SpecBaseTest {
|
|||
--End Example]
|
||||
*/
|
||||
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("struct s *s1;\n"); //$NON-NLS-1$
|
||||
buffer.append("struct s *s2;\n"); //$NON-NLS-1$
|
||||
|
@ -699,7 +699,7 @@ public class AST2CSpecTest extends AST2SpecBaseTest {
|
|||
--End Example]
|
||||
*/
|
||||
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[5]; } *s2;\n"); //$NON-NLS-1$
|
||||
parseCandCPP(buffer.toString(), true, 0);
|
||||
|
@ -718,7 +718,7 @@ public class AST2CSpecTest extends AST2SpecBaseTest {
|
|||
--End Example]
|
||||
*/
|
||||
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("enum hue { chartreuse, burgundy, claret=20, winedark };\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]
|
||||
*/
|
||||
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("int count;\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]
|
||||
*/
|
||||
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("struct tnode {\n"); //$NON-NLS-1$
|
||||
buffer.append("int count;\n"); //$NON-NLS-1$
|
||||
|
@ -778,7 +778,7 @@ public class AST2CSpecTest extends AST2SpecBaseTest {
|
|||
--End Example]
|
||||
*/
|
||||
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 s1 { struct s2 *s2p; }; // D1\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]
|
||||
*/
|
||||
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$
|
||||
parseCandCPP(buffer.toString(), true, 0);
|
||||
}
|
||||
|
@ -815,7 +815,7 @@ public class AST2CSpecTest extends AST2SpecBaseTest {
|
|||
--End Example]
|
||||
*/
|
||||
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("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$
|
||||
|
@ -841,7 +841,7 @@ public class AST2CSpecTest extends AST2SpecBaseTest {
|
|||
--End Example]
|
||||
*/
|
||||
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 b;\n"); //$NON-NLS-1$
|
||||
buffer.append("extern int c[];\n"); //$NON-NLS-1$
|
||||
|
@ -858,7 +858,7 @@ public class AST2CSpecTest extends AST2SpecBaseTest {
|
|||
--End Example]
|
||||
*/
|
||||
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("{\n"); //$NON-NLS-1$
|
||||
buffer.append("while (n-- > 0)\n"); //$NON-NLS-1$
|
||||
|
@ -883,7 +883,7 @@ public class AST2CSpecTest extends AST2SpecBaseTest {
|
|||
--End Example]
|
||||
*/
|
||||
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("{\n"); //$NON-NLS-1$
|
||||
buffer.append("while (n-- > 0)\n"); //$NON-NLS-1$
|
||||
|
@ -909,7 +909,7 @@ public class AST2CSpecTest extends AST2SpecBaseTest {
|
|||
--End Example]
|
||||
*/
|
||||
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("{\n"); //$NON-NLS-1$
|
||||
buffer.append("int i;\n"); //$NON-NLS-1$
|
||||
|
@ -936,7 +936,7 @@ public class AST2CSpecTest extends AST2SpecBaseTest {
|
|||
--End Example]
|
||||
*/
|
||||
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("{\n"); //$NON-NLS-1$
|
||||
buffer.append("int * restrict p1;\n"); //$NON-NLS-1$
|
||||
|
@ -965,7 +965,7 @@ public class AST2CSpecTest extends AST2SpecBaseTest {
|
|||
--End Example]
|
||||
*/
|
||||
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("vector new_vector(int n)\n"); //$NON-NLS-1$
|
||||
buffer.append("{\n"); //$NON-NLS-1$
|
||||
|
@ -995,7 +995,7 @@ public class AST2CSpecTest extends AST2SpecBaseTest {
|
|||
--End Example]
|
||||
*/
|
||||
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("{\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]
|
||||
*/
|
||||
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("int *const constant_ptr1;\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]
|
||||
*/
|
||||
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$
|
||||
parseCandCPP(buffer.toString(), true, 0);
|
||||
}
|
||||
|
@ -1047,7 +1047,7 @@ public class AST2CSpecTest extends AST2SpecBaseTest {
|
|||
--End Example]
|
||||
*/
|
||||
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 y[];\n"); //$NON-NLS-1$
|
||||
parseCandCPP(buffer.toString(), true, 0);
|
||||
|
@ -1070,7 +1070,7 @@ public class AST2CSpecTest extends AST2SpecBaseTest {
|
|||
--End Example]
|
||||
*/
|
||||
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 m;\n"); //$NON-NLS-1$
|
||||
buffer.append("void fcompat(void)\n"); //$NON-NLS-1$
|
||||
|
@ -1110,7 +1110,7 @@ public class AST2CSpecTest extends AST2SpecBaseTest {
|
|||
--End Example]
|
||||
*/
|
||||
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("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$
|
||||
|
@ -1139,7 +1139,7 @@ public class AST2CSpecTest extends AST2SpecBaseTest {
|
|||
--End Example]
|
||||
*/
|
||||
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$
|
||||
parseCandCPP(buffer.toString(), true, 0);
|
||||
}
|
||||
|
@ -1150,7 +1150,7 @@ public class AST2CSpecTest extends AST2SpecBaseTest {
|
|||
--End Example]
|
||||
*/
|
||||
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$
|
||||
parseCandCPP(buffer.toString(), true, 0);
|
||||
}
|
||||
|
@ -1161,7 +1161,7 @@ public class AST2CSpecTest extends AST2SpecBaseTest {
|
|||
--End Example]
|
||||
*/
|
||||
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$
|
||||
parseCandCPP(buffer.toString(), true, 0);
|
||||
}
|
||||
|
@ -1187,7 +1187,7 @@ public class AST2CSpecTest extends AST2SpecBaseTest {
|
|||
--End Example]
|
||||
*/
|
||||
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("double a[n][n*m+300], double x);\n"); //$NON-NLS-1$
|
||||
buffer.append("int main()\n"); //$NON-NLS-1$
|
||||
|
@ -1222,7 +1222,7 @@ public class AST2CSpecTest extends AST2SpecBaseTest {
|
|||
--End Example]
|
||||
*/
|
||||
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 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$
|
||||
|
@ -1245,7 +1245,7 @@ public class AST2CSpecTest extends AST2SpecBaseTest {
|
|||
--End Example]
|
||||
*/
|
||||
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 struct { double hi, lo; } range;\n"); //$NON-NLS-1$
|
||||
buffer.append("MILES distance;\n"); //$NON-NLS-1$
|
||||
|
@ -1262,7 +1262,7 @@ public class AST2CSpecTest extends AST2SpecBaseTest {
|
|||
--End Example]
|
||||
*/
|
||||
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 s2 { int x; } t2, *tp2;\n"); //$NON-NLS-1$
|
||||
parseCandCPP(buffer.toString(), true, 0);
|
||||
|
@ -1277,7 +1277,7 @@ public class AST2CSpecTest extends AST2SpecBaseTest {
|
|||
--End Example]
|
||||
*/
|
||||
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("void (*signal(int, void (*)(int)))(int);\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]
|
||||
*/
|
||||
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("{\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]
|
||||
*/
|
||||
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("complex c = 5 + 3 * I;\n"); //$NON-NLS-1$
|
||||
parseCandCPP(buffer.toString(), false, 0);
|
||||
|
@ -1331,7 +1331,7 @@ public class AST2CSpecTest extends AST2SpecBaseTest {
|
|||
--End Example]
|
||||
*/
|
||||
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$
|
||||
parseCandCPP(buffer.toString(), true, 0);
|
||||
}
|
||||
|
@ -1346,7 +1346,7 @@ public class AST2CSpecTest extends AST2SpecBaseTest {
|
|||
--End Example]
|
||||
*/
|
||||
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("{ 1, 3, 5 },\n"); //$NON-NLS-1$
|
||||
buffer.append("{ 2, 4, 6 },\n"); //$NON-NLS-1$
|
||||
|
@ -1363,7 +1363,7 @@ public class AST2CSpecTest extends AST2SpecBaseTest {
|
|||
--End Example]
|
||||
*/
|
||||
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("1, 3, 5, 2, 4, 6, 3, 5, 7\n"); //$NON-NLS-1$
|
||||
buffer.append("};\n"); //$NON-NLS-1$
|
||||
|
@ -1378,7 +1378,7 @@ public class AST2CSpecTest extends AST2SpecBaseTest {
|
|||
--End Example]
|
||||
*/
|
||||
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("{ 1 }, { 2 }, { 3 }, { 4 }\n"); //$NON-NLS-1$
|
||||
buffer.append("};\n"); //$NON-NLS-1$
|
||||
|
@ -1391,7 +1391,7 @@ public class AST2CSpecTest extends AST2SpecBaseTest {
|
|||
--End Example]
|
||||
*/
|
||||
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$
|
||||
parseCandCPP(buffer.toString(), true, 0);
|
||||
}
|
||||
|
@ -1423,7 +1423,7 @@ public class AST2CSpecTest extends AST2SpecBaseTest {
|
|||
--End Example]
|
||||
*/
|
||||
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("{ 1 },\n"); //$NON-NLS-1$
|
||||
buffer.append("{ 2, 3 },\n"); //$NON-NLS-1$
|
||||
|
@ -1457,7 +1457,7 @@ public class AST2CSpecTest extends AST2SpecBaseTest {
|
|||
--End Example]
|
||||
*/
|
||||
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("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$
|
||||
|
@ -1475,7 +1475,7 @@ public class AST2CSpecTest extends AST2SpecBaseTest {
|
|||
--End Example]
|
||||
*/
|
||||
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("char s1[] = \"abc\", t1[3] = \"abc\";\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]
|
||||
*/
|
||||
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("const char *nm[] = {\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]
|
||||
*/
|
||||
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$
|
||||
parse(buffer.toString(), ParserLanguage.C, true, 1); // div_t (correctly) cannot be resolved
|
||||
}
|
||||
|
@ -1522,7 +1522,7 @@ public class AST2CSpecTest extends AST2SpecBaseTest {
|
|||
--End Example]
|
||||
*/
|
||||
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("{ [0].a = {1}, [1].a[0] = 2 };\n"); //$NON-NLS-1$
|
||||
parse(buffer.toString(), ParserLanguage.C, true, 0);
|
||||
|
@ -1537,7 +1537,7 @@ public class AST2CSpecTest extends AST2SpecBaseTest {
|
|||
--End Example]
|
||||
*/
|
||||
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 a[MAX] = {\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]
|
||||
*/
|
||||
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$
|
||||
parse(buffer.toString(), ParserLanguage.C, true, 0);
|
||||
}
|
||||
|
@ -1565,7 +1565,7 @@ public class AST2CSpecTest extends AST2SpecBaseTest {
|
|||
--End Example]
|
||||
*/
|
||||
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 f() {\n"); //$NON-NLS-1$
|
||||
buffer.append("(void)p(0);\n"); //$NON-NLS-1$
|
||||
|
@ -1583,7 +1583,7 @@ public class AST2CSpecTest extends AST2SpecBaseTest {
|
|||
--End Example]
|
||||
*/
|
||||
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("char *s;\n"); //$NON-NLS-1$
|
||||
buffer.append("while (*s++ != '\0')\n"); //$NON-NLS-1$
|
||||
|
@ -1608,7 +1608,7 @@ public class AST2CSpecTest extends AST2SpecBaseTest {
|
|||
--End Example]
|
||||
*/
|
||||
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 i=1;\n"); //$NON-NLS-1$
|
||||
buffer.append("while (i) {\n"); //$NON-NLS-1$
|
||||
|
@ -1640,7 +1640,7 @@ public class AST2CSpecTest extends AST2SpecBaseTest {
|
|||
--End Example]
|
||||
*/
|
||||
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 g(int expr) {\n"); //$NON-NLS-1$
|
||||
buffer.append("switch (expr)\n"); //$NON-NLS-1$
|
||||
|
@ -1674,7 +1674,7 @@ public class AST2CSpecTest extends AST2SpecBaseTest {
|
|||
--End Example]
|
||||
*/
|
||||
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("goto first_time;\n"); //$NON-NLS-1$
|
||||
buffer.append("for (;;) {\n"); //$NON-NLS-1$
|
||||
|
@ -1710,7 +1710,7 @@ public class AST2CSpecTest extends AST2SpecBaseTest {
|
|||
--End Example]
|
||||
*/
|
||||
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("goto lab3; // invalid: going INTO scope of VLA.\n"); //$NON-NLS-1$
|
||||
buffer.append("{\n"); //$NON-NLS-1$
|
||||
|
@ -1751,7 +1751,7 @@ public class AST2CSpecTest extends AST2SpecBaseTest {
|
|||
--End Example]
|
||||
*/
|
||||
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("union {\n"); //$NON-NLS-1$
|
||||
buffer.append("struct {\n"); //$NON-NLS-1$
|
||||
|
@ -1782,7 +1782,7 @@ public class AST2CSpecTest extends AST2SpecBaseTest {
|
|||
--End Example]
|
||||
*/
|
||||
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("{\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]
|
||||
*/
|
||||
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("{\n"); //$NON-NLS-1$
|
||||
buffer.append("(*funcp)();\n"); //$NON-NLS-1$
|
||||
|
@ -1829,7 +1829,7 @@ public class AST2CSpecTest extends AST2SpecBaseTest {
|
|||
--End Example]
|
||||
*/
|
||||
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("static int i2 = 2; // definition, internal 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]
|
||||
*/
|
||||
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 f() {\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]
|
||||
*/
|
||||
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 mkstr(a) # 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]
|
||||
*/
|
||||
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("int table[TABSIZE];\n"); //$NON-NLS-1$
|
||||
parseCandCPP(buffer.toString(), true, 0);
|
||||
|
@ -1913,7 +1913,7 @@ public class AST2CSpecTest extends AST2SpecBaseTest {
|
|||
--End Example]
|
||||
*/
|
||||
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$
|
||||
parseCandCPP(buffer.toString(), true, 0);
|
||||
}
|
||||
|
@ -1941,7 +1941,7 @@ public class AST2CSpecTest extends AST2SpecBaseTest {
|
|||
--End Example]
|
||||
*/
|
||||
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 f(a) f(x * (a))\n"); //$NON-NLS-1$
|
||||
buffer.append("#undef x\n"); //$NON-NLS-1$
|
||||
|
@ -1985,7 +1985,7 @@ public class AST2CSpecTest extends AST2SpecBaseTest {
|
|||
--End Example]
|
||||
*/
|
||||
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 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$
|
||||
|
@ -2017,7 +2017,7 @@ public class AST2CSpecTest extends AST2SpecBaseTest {
|
|||
--End Example]
|
||||
*/
|
||||
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("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$
|
||||
|
@ -2036,7 +2036,7 @@ public class AST2CSpecTest extends AST2SpecBaseTest {
|
|||
--End Example]
|
||||
*/
|
||||
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_LIKE2 \\n"); //$NON-NLS-1$
|
||||
buffer.append(" (1-1) \\n"); //$NON-NLS-1$
|
||||
|
@ -2062,7 +2062,7 @@ public class AST2CSpecTest extends AST2SpecBaseTest {
|
|||
--End Example]
|
||||
*/
|
||||
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 showlist(...) puts(#__VA_ARGS__)\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]
|
||||
*/
|
||||
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 int plain;\n"); //$NON-NLS-1$
|
||||
buffer.append("struct tag {\n"); //$NON-NLS-1$
|
||||
|
|
|
@ -69,7 +69,7 @@ public class AST2KnRTests extends AST2BaseTest {
|
|||
}
|
||||
|
||||
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(x) char x;\n"); //$NON-NLS-1$
|
||||
buffer.append("{ return x == 0; }\n"); //$NON-NLS-1$
|
||||
|
@ -104,7 +104,7 @@ public class AST2KnRTests extends AST2BaseTest {
|
|||
}
|
||||
|
||||
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(x) char x;\n"); //$NON-NLS-1$
|
||||
buffer.append("{ return x == 0; }\n"); //$NON-NLS-1$
|
||||
|
@ -135,7 +135,7 @@ public class AST2KnRTests extends AST2BaseTest {
|
|||
}
|
||||
|
||||
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(x) char x;\n"); //$NON-NLS-1$
|
||||
buffer.append("{ return x == 0; }\n"); //$NON-NLS-1$
|
||||
|
@ -158,7 +158,7 @@ public class AST2KnRTests extends AST2BaseTest {
|
|||
}
|
||||
|
||||
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 x;\n"); //$NON-NLS-1$
|
||||
buffer.append("int y;\n"); //$NON-NLS-1$
|
||||
|
@ -204,7 +204,7 @@ public class AST2KnRTests extends AST2BaseTest {
|
|||
}
|
||||
|
||||
public void testKRCWithTypes() throws Exception {
|
||||
StringBuffer buffer = new StringBuffer();
|
||||
StringBuilder buffer = new StringBuilder();
|
||||
buffer.append("typedef char c;\n"); //$NON-NLS-1$
|
||||
buffer.append("int isroot (c);\n"); //$NON-NLS-1$
|
||||
buffer.append("int isroot (x) \n"); //$NON-NLS-1$
|
||||
|
@ -258,7 +258,7 @@ public class AST2KnRTests extends AST2BaseTest {
|
|||
}
|
||||
|
||||
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("{ return x == 0; }\n"); //$NON-NLS-1$
|
||||
IASTTranslationUnit tu = parse(buffer.toString(), ParserLanguage.C, true, false);
|
||||
|
@ -268,7 +268,7 @@ public class AST2KnRTests extends AST2BaseTest {
|
|||
}
|
||||
|
||||
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 f(x) i++;\n"); //$NON-NLS-1$
|
||||
buffer.append("{ return x == 0; }\n"); //$NON-NLS-1$
|
||||
|
@ -279,7 +279,7 @@ public class AST2KnRTests extends AST2BaseTest {
|
|||
}
|
||||
|
||||
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("{ return x == 0; }\n"); //$NON-NLS-1$
|
||||
IASTTranslationUnit tu = parse(buffer.toString(), ParserLanguage.C, true, false);
|
||||
|
@ -304,7 +304,7 @@ public class AST2KnRTests extends AST2BaseTest {
|
|||
}
|
||||
|
||||
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("{ return x == 0; }\n"); //$NON-NLS-1$
|
||||
IASTTranslationUnit tu = parse(buffer.toString(), ParserLanguage.C, true, false);
|
||||
|
@ -350,11 +350,10 @@ public class AST2KnRTests extends AST2BaseTest {
|
|||
IASTName[] decls = tu.getDeclarationsInAST(((IASTIdExpression) ((IASTBinaryExpression) ((IASTReturnStatement) ((IASTCompoundStatement) f.getBody()).getStatements()[0]).getReturnValue()).getOperand1()).getName().resolveBinding());
|
||||
assertEquals(decls.length, 1);
|
||||
assertEquals(decls[0], x2);
|
||||
|
||||
}
|
||||
|
||||
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("{ return x == 0; }\n"); //$NON-NLS-1$
|
||||
IASTTranslationUnit tu = parse(buffer.toString(), ParserLanguage.C, true, false);
|
||||
|
@ -380,7 +379,7 @@ public class AST2KnRTests extends AST2BaseTest {
|
|||
|
||||
|
||||
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("#define __P(x) x\n"); //$NON-NLS-1$
|
||||
buffer.append("#else\n"); //$NON-NLS-1$
|
||||
|
@ -505,7 +504,7 @@ public class AST2KnRTests extends AST2BaseTest {
|
|||
}
|
||||
|
||||
public void testKRC_monop_cards2() throws Exception {
|
||||
StringBuffer buffer = new StringBuffer();
|
||||
StringBuilder buffer = new StringBuilder();
|
||||
buffer.append("int\n"); //$NON-NLS-1$
|
||||
buffer.append("getinp(prompt, list)\n"); //$NON-NLS-1$
|
||||
buffer.append(" const char *prompt, *const list[];\n"); //$NON-NLS-1$
|
||||
|
@ -547,7 +546,7 @@ public class AST2KnRTests extends AST2BaseTest {
|
|||
}
|
||||
|
||||
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$
|
||||
IASTTranslationUnit tu = parse(buffer.toString(), ParserLanguage.C, true);
|
||||
|
||||
|
@ -558,11 +557,10 @@ public class AST2KnRTests extends AST2BaseTest {
|
|||
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 {
|
||||
StringBuffer buffer = new StringBuffer();
|
||||
StringBuilder buffer = new StringBuilder();
|
||||
buffer.append("struct symbol {\n"); //$NON-NLS-1$
|
||||
buffer.append("int lambda;\n};\n"); //$NON-NLS-1$
|
||||
buffer.append("struct lemon {\n"); //$NON-NLS-1$
|
||||
|
@ -605,7 +603,7 @@ public class AST2KnRTests extends AST2BaseTest {
|
|||
}
|
||||
|
||||
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(int); \n"); //$NON-NLS-1$
|
||||
|
||||
|
@ -619,7 +617,7 @@ public class AST2KnRTests extends AST2BaseTest {
|
|||
}
|
||||
|
||||
public void testBug100104() throws Exception {
|
||||
StringBuffer buffer = new StringBuffer();
|
||||
StringBuilder buffer = new StringBuilder();
|
||||
buffer.append("typedef int ush;\n"); //$NON-NLS-1$
|
||||
buffer.append("int f()\n"); //$NON-NLS-1$
|
||||
buffer.append("{\n"); //$NON-NLS-1$
|
||||
|
@ -641,7 +639,7 @@ public class AST2KnRTests extends AST2BaseTest {
|
|||
|
||||
// see https://bugs.eclipse.org/bugs/show_bug.cgi?id=203050
|
||||
public void testBug203050() throws Exception {
|
||||
StringBuffer buffer = new StringBuffer();
|
||||
StringBuilder buffer = new StringBuilder();
|
||||
buffer.append("typedef long time_t;\n" + //$NON-NLS-1$
|
||||
"\n" + //$NON-NLS-1$
|
||||
"void (foo) (timep)\n" + //$NON-NLS-1$
|
||||
|
@ -676,5 +674,4 @@ public class AST2KnRTests extends AST2BaseTest {
|
|||
fail(e.getMessage());
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -39,7 +39,7 @@ public class GCCTests extends AST2BaseTest {
|
|||
}
|
||||
|
||||
public void testGCC20000113() throws Exception {
|
||||
StringBuffer buffer = new StringBuffer();
|
||||
StringBuilder buffer = new StringBuilder();
|
||||
buffer.append("struct x { \n"); //$NON-NLS-1$
|
||||
buffer.append(" unsigned x1:1; \n"); //$NON-NLS-1$
|
||||
buffer.append(" unsigned x2:2; \n"); //$NON-NLS-1$
|
||||
|
@ -85,7 +85,7 @@ public class GCCTests extends AST2BaseTest {
|
|||
}
|
||||
|
||||
public void testGCC20000205() throws Exception{
|
||||
StringBuffer buffer = new StringBuffer();
|
||||
StringBuilder buffer = new StringBuilder();
|
||||
buffer.append("static int f(int a) { \n"); //$NON-NLS-1$
|
||||
buffer.append(" if (a == 0) \n"); //$NON-NLS-1$
|
||||
buffer.append(" return 0; \n"); //$NON-NLS-1$
|
||||
|
@ -110,7 +110,7 @@ public class GCCTests extends AST2BaseTest {
|
|||
}
|
||||
|
||||
public void testGCC20000217() throws Exception{
|
||||
StringBuffer buffer = new StringBuffer();
|
||||
StringBuilder buffer = new StringBuilder();
|
||||
buffer.append("unsigned short int showbug(unsigned short int * a, \n"); //$NON-NLS-1$
|
||||
buffer.append(" unsigned short int * b) { \n"); //$NON-NLS-1$
|
||||
buffer.append(" *a += *b - 8; \n"); //$NON-NLS-1$
|
||||
|
@ -144,7 +144,7 @@ public class GCCTests extends AST2BaseTest {
|
|||
}
|
||||
|
||||
public void testGCC20000224() throws Exception{
|
||||
StringBuffer buffer = new StringBuffer();
|
||||
StringBuilder buffer = new StringBuilder();
|
||||
buffer.append("int loop_1 = 100; \n"); //$NON-NLS-1$
|
||||
buffer.append("int loop_2 = 7; \n"); //$NON-NLS-1$
|
||||
buffer.append("int flag = 0; \n"); //$NON-NLS-1$
|
||||
|
@ -181,7 +181,7 @@ public class GCCTests extends AST2BaseTest {
|
|||
}
|
||||
|
||||
public void testGCC20000225() throws Exception {
|
||||
StringBuffer buffer = new StringBuffer();
|
||||
StringBuilder buffer = new StringBuilder();
|
||||
buffer.append("int main() { \n"); //$NON-NLS-1$
|
||||
buffer.append(" int nResult, b = 0, i = -1; \n"); //$NON-NLS-1$
|
||||
buffer.append(" do { \n"); //$NON-NLS-1$
|
||||
|
@ -211,7 +211,7 @@ public class GCCTests extends AST2BaseTest {
|
|||
}
|
||||
|
||||
public void testGCC20000227() throws Exception {
|
||||
StringBuffer buffer = new StringBuffer();
|
||||
StringBuilder buffer = new StringBuilder();
|
||||
buffer.append("static const unsigned char f[] = \"\\0\\377\"; \n"); //$NON-NLS-1$
|
||||
buffer.append("static const unsigned char g[] = \"\\0y\"; \n"); //$NON-NLS-1$
|
||||
buffer.append("int main() { \n"); //$NON-NLS-1$
|
||||
|
@ -237,7 +237,7 @@ public class GCCTests extends AST2BaseTest {
|
|||
}
|
||||
|
||||
public void testGCC20000313() throws Exception{
|
||||
StringBuffer buffer = new StringBuffer();
|
||||
StringBuilder buffer = new StringBuilder();
|
||||
buffer.append("unsigned int buggy(unsigned int *param) { \n"); //$NON-NLS-1$
|
||||
buffer.append(" unsigned int accu, zero = 0, borrow; \n"); //$NON-NLS-1$
|
||||
buffer.append(" accu = - *param; \n"); //$NON-NLS-1$
|
||||
|
@ -277,7 +277,7 @@ public class GCCTests extends AST2BaseTest {
|
|||
}
|
||||
|
||||
public void testGCC20000314_1() throws Exception{
|
||||
StringBuffer buffer = new StringBuffer();
|
||||
StringBuilder buffer = new StringBuilder();
|
||||
buffer.append("int main() { \n"); //$NON-NLS-1$
|
||||
buffer.append(" long winds = 0; \n"); //$NON-NLS-1$
|
||||
buffer.append(" while (winds != 0) { \n"); //$NON-NLS-1$
|
||||
|
@ -300,7 +300,7 @@ public class GCCTests extends AST2BaseTest {
|
|||
}
|
||||
|
||||
public void testGCC20000314_2() throws Exception{
|
||||
StringBuffer buffer = new StringBuffer();
|
||||
StringBuilder buffer = new StringBuilder();
|
||||
buffer.append("typedef unsigned long long uint64; \n"); //$NON-NLS-1$
|
||||
buffer.append("const uint64 bigconst = 1ULL << 34; \n"); //$NON-NLS-1$
|
||||
buffer.append("int a = 1; \n"); //$NON-NLS-1$
|
||||
|
@ -334,7 +334,7 @@ public class GCCTests extends AST2BaseTest {
|
|||
}
|
||||
|
||||
public void testGCC20000403() throws Exception {
|
||||
StringBuffer buffer = new StringBuffer();
|
||||
StringBuilder buffer = new StringBuilder();
|
||||
buffer.append("extern unsigned long aa[], bb[]; \n"); //$NON-NLS-1$
|
||||
buffer.append("int seqgt(unsigned long a, unsigned short win, unsigned long b); \n"); //$NON-NLS-1$
|
||||
buffer.append("int seqgt2 (unsigned long a, unsigned short win, unsigned long b); \n"); //$NON-NLS-1$
|
||||
|
@ -382,7 +382,7 @@ public class GCCTests extends AST2BaseTest {
|
|||
}
|
||||
|
||||
public void testGCC20000412_1 () throws Exception {
|
||||
StringBuffer buffer = new StringBuffer();
|
||||
StringBuilder buffer = new StringBuilder();
|
||||
buffer.append("short int i = -1; \n"); //$NON-NLS-1$
|
||||
buffer.append("const char * const wordlist[207]; \n"); //$NON-NLS-1$
|
||||
buffer.append("const char * const * foo(void) { \n"); //$NON-NLS-1$
|
||||
|
@ -412,7 +412,7 @@ public class GCCTests extends AST2BaseTest {
|
|||
}
|
||||
|
||||
public void testGCC20000412_2() throws Exception {
|
||||
StringBuffer buffer = new StringBuffer();
|
||||
StringBuilder buffer = new StringBuilder();
|
||||
buffer.append("int f(int a, int *y) { \n"); //$NON-NLS-1$
|
||||
buffer.append(" int x = a; \n"); //$NON-NLS-1$
|
||||
buffer.append(" if (a == 0) return *y; \n"); //$NON-NLS-1$
|
||||
|
@ -441,7 +441,7 @@ public class GCCTests extends AST2BaseTest {
|
|||
}
|
||||
|
||||
public void testGCC20000412_3() throws Exception{
|
||||
StringBuffer buffer = new StringBuffer();
|
||||
StringBuilder buffer = new StringBuilder();
|
||||
buffer.append("typedef struct { \n"); //$NON-NLS-1$
|
||||
buffer.append(" char y; \n"); //$NON-NLS-1$
|
||||
buffer.append(" char x[32]; \n"); //$NON-NLS-1$
|
||||
|
@ -489,7 +489,7 @@ public class GCCTests extends AST2BaseTest {
|
|||
}
|
||||
|
||||
public void testGCC20000412_4() throws Exception{
|
||||
StringBuffer buffer = new StringBuffer();
|
||||
StringBuilder buffer = new StringBuilder();
|
||||
buffer.append("void f(int i, int j, int radius, int width, int N) { \n"); //$NON-NLS-1$
|
||||
buffer.append(" const int diff = i - radius; \n"); //$NON-NLS-1$
|
||||
buffer.append(" const int lowk = (diff > 0 ? diff : 0); \n"); //$NON-NLS-1$
|
||||
|
@ -544,7 +544,7 @@ public class GCCTests extends AST2BaseTest {
|
|||
}
|
||||
|
||||
public void testGCC20000412_5() throws Exception {
|
||||
StringBuffer buffer = new StringBuffer();
|
||||
StringBuilder buffer = new StringBuilder();
|
||||
buffer.append("int main(void) { \n"); //$NON-NLS-1$
|
||||
buffer.append(" struct { \n"); //$NON-NLS-1$
|
||||
buffer.append(" int node; \n"); //$NON-NLS-1$
|
||||
|
@ -570,7 +570,7 @@ public class GCCTests extends AST2BaseTest {
|
|||
}
|
||||
|
||||
public void testGCC20000419() throws Exception {
|
||||
StringBuffer buffer = new StringBuffer();
|
||||
StringBuilder buffer = new StringBuilder();
|
||||
buffer.append("struct foo { int a, b, c; }; \n"); //$NON-NLS-1$
|
||||
buffer.append("void brother(int a, int b, int c) { \n"); //$NON-NLS-1$
|
||||
buffer.append(" if (a) return; \n"); //$NON-NLS-1$
|
||||
|
@ -618,7 +618,7 @@ public class GCCTests extends AST2BaseTest {
|
|||
assertInstances(collector, f, 2);
|
||||
}
|
||||
public void testGCC20000503() throws Exception {
|
||||
StringBuffer buffer = new StringBuffer();
|
||||
StringBuilder buffer = new StringBuilder();
|
||||
buffer.append("unsigned long sub(int a) { \n"); //$NON-NLS-1$
|
||||
buffer.append(" return ((0 > a - 2) ? 0 : a - 2) * sizeof(long); \n"); //$NON-NLS-1$
|
||||
buffer.append("} \n"); //$NON-NLS-1$
|
||||
|
@ -639,7 +639,7 @@ public class GCCTests extends AST2BaseTest {
|
|||
}
|
||||
|
||||
public void testGCC20000511() throws Exception {
|
||||
StringBuffer buffer = new StringBuffer();
|
||||
StringBuilder buffer = new StringBuilder();
|
||||
buffer.append("int f(int value, int expect) { \n"); //$NON-NLS-1$
|
||||
buffer.append(" return (value == expect); \n"); //$NON-NLS-1$
|
||||
buffer.append("} \n"); //$NON-NLS-1$
|
||||
|
@ -693,7 +693,7 @@ public class GCCTests extends AST2BaseTest {
|
|||
assertInstances(collector, e, 15);
|
||||
}
|
||||
public void testGCC20000603() throws Exception {
|
||||
StringBuffer buffer = new StringBuffer();
|
||||
StringBuilder buffer = new StringBuilder();
|
||||
buffer.append("struct s1 { double d; }; \n"); //$NON-NLS-1$
|
||||
buffer.append("struct s2 { double d; }; \n"); //$NON-NLS-1$
|
||||
buffer.append("double f(struct s1 * a, struct s2 *b) { \n"); //$NON-NLS-1$
|
||||
|
@ -732,7 +732,7 @@ public class GCCTests extends AST2BaseTest {
|
|||
assertInstances(collector, a, 4);
|
||||
}
|
||||
public void testGCC20000605_2() throws Exception{
|
||||
StringBuffer buffer = new StringBuffer();
|
||||
StringBuilder buffer = new StringBuilder();
|
||||
buffer.append("struct F { int i; }; \n"); //$NON-NLS-1$
|
||||
buffer.append("void f1(struct F *x, struct F * y) { \n"); //$NON-NLS-1$
|
||||
buffer.append(" int timeout = 0; \n"); //$NON-NLS-1$
|
||||
|
@ -770,7 +770,7 @@ public class GCCTests extends AST2BaseTest {
|
|||
assertInstances(collector, y, 3);
|
||||
}
|
||||
public void testGCC20000605_3() throws Exception{
|
||||
StringBuffer buffer = new StringBuffer();
|
||||
StringBuilder buffer = new StringBuilder();
|
||||
buffer.append("struct F { int x; int y; }; \n"); //$NON-NLS-1$
|
||||
buffer.append("int main() { \n"); //$NON-NLS-1$
|
||||
buffer.append(" int timeout = 0, x = 0; \n"); //$NON-NLS-1$
|
||||
|
@ -806,7 +806,7 @@ public class GCCTests extends AST2BaseTest {
|
|||
assertInstances(collector, die, 2);
|
||||
}
|
||||
public void testGCCenum_2() throws Exception {
|
||||
StringBuffer buffer = new StringBuffer();
|
||||
StringBuilder buffer = new StringBuilder();
|
||||
buffer.append("enum foo { FOO, BAR }; \n"); //$NON-NLS-1$
|
||||
buffer.append("int main() { \n"); //$NON-NLS-1$
|
||||
buffer.append(" int i; \n"); //$NON-NLS-1$
|
||||
|
|
|
@ -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);
|
||||
|
||||
IASTTranslationUnit unit = CoreModelUtil.findTranslationUnit(testFile).getAST();
|
||||
final ChangeGenerator changeGenerator = new ChangeGenerator(modStore,
|
||||
ASTCommenter.getCommentedNodeMap(unit));
|
||||
final ChangeGenerator changeGenerator =
|
||||
new ChangeGenerator(modStore, ASTCommenter.getCommentedNodeMap(unit));
|
||||
unit.accept(visitor);
|
||||
|
||||
changeGenerator.generateChange(unit);
|
||||
Document doc = new Document(source);
|
||||
for (Change curChange : ((CompositeChange) changeGenerator.getChange()).getChildren()) {
|
||||
if (curChange instanceof TextFileChange) {
|
||||
TextFileChange textChange = (TextFileChange) curChange;
|
||||
for (Change change : ((CompositeChange) changeGenerator.getChange()).getChildren()) {
|
||||
if (change instanceof TextFileChange) {
|
||||
TextFileChange textChange = (TextFileChange) change;
|
||||
textChange.getEdit().apply(doc);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -25,7 +25,7 @@ import org.eclipse.cdt.core.parser.tests.rewrite.changegenerator.replace.Replace
|
|||
public class ChangeGeneratorTestSuite {
|
||||
|
||||
public static Test suite() throws Exception {
|
||||
TestSuite suite = new TestSuite("ChangeGeneratorTests");
|
||||
TestSuite suite = new TestSuite("ChangeGeneratorTestSuite");
|
||||
|
||||
suite.addTest(ReplaceTestSuite.suite());
|
||||
suite.addTest(RemoveTestSuite.suite());
|
||||
|
|
|
@ -20,7 +20,7 @@ import junit.framework.TestSuite;
|
|||
public class InsertBeforeTestSuite {
|
||||
|
||||
public static Test suite() throws Exception {
|
||||
TestSuite suite = new TestSuite("ChangeGenerator InsertBefore Tests");
|
||||
TestSuite suite = new TestSuite("InsertBeforeTestSuite");
|
||||
|
||||
suite.addTest(FirstParameterTest.suite());
|
||||
suite.addTest(PointerParameterTest.suite());
|
||||
|
|
|
@ -13,14 +13,14 @@ package org.eclipse.cdt.core.parser.tests.rewrite.changegenerator.remove;
|
|||
|
||||
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.IASTArrayModifier;
|
||||
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.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.ASTModificationStore;
|
||||
|
||||
public class ArrayModifierTest extends ChangeGeneratorTest {
|
||||
|
||||
|
@ -40,8 +40,7 @@ public class ArrayModifierTest extends ChangeGeneratorTest {
|
|||
}
|
||||
|
||||
@Override
|
||||
protected ASTVisitor createModificator(
|
||||
final ASTModificationStore modStore) {
|
||||
protected ASTVisitor createModificator(final ASTModificationStore modStore) {
|
||||
return new ASTVisitor() {
|
||||
{
|
||||
shouldVisitDeclarators = true;
|
||||
|
|
|
@ -13,17 +13,17 @@ package org.eclipse.cdt.core.parser.tests.rewrite.changegenerator.replace;
|
|||
|
||||
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.IASTArrayModifier;
|
||||
import org.eclipse.cdt.core.dom.ast.IASTDeclarator;
|
||||
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.internal.core.dom.parser.cpp.CPPASTArrayModifier;
|
||||
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.ASTModificationStore;
|
||||
import org.eclipse.cdt.internal.core.dom.rewrite.ASTModification.ModificationKind;
|
||||
import org.eclipse.cdt.internal.core.dom.rewrite.ASTModificationStore;
|
||||
|
||||
public class ArrayModifierTest extends ChangeGeneratorTest {
|
||||
|
||||
|
@ -42,10 +42,8 @@ public class ArrayModifierTest extends ChangeGeneratorTest {
|
|||
return new ArrayModifierTest();
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
protected ASTVisitor createModificator(
|
||||
final ASTModificationStore modStore) {
|
||||
protected ASTVisitor createModificator(final ASTModificationStore modStore) {
|
||||
return new ASTVisitor() {
|
||||
{
|
||||
shouldVisitDeclarators = true;
|
||||
|
@ -57,7 +55,7 @@ public class ArrayModifierTest extends ChangeGeneratorTest {
|
|||
IASTArrayDeclarator arrayDeclarator = (IASTArrayDeclarator)declarator;
|
||||
IASTArrayModifier[] modifiers = arrayDeclarator.getArrayModifiers();
|
||||
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);
|
||||
ASTModification modification = new ASTModification(ModificationKind.REPLACE, modifiers[0], newModifier, null);
|
||||
modStore.storeModification(null, modification);
|
||||
|
|
|
@ -13,21 +13,21 @@ package org.eclipse.cdt.core.parser.tests.rewrite.changegenerator.replace;
|
|||
|
||||
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.IASTParameterDeclaration;
|
||||
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.internal.core.dom.parser.cpp.CPPASTFunctionDeclarator;
|
||||
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.ASTModificationStore;
|
||||
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 PointerInParameterTest() {
|
||||
super("Replace Pointer for Parameter"); //$NON-NLS-1$
|
||||
super("PointerInParameterTest"); //$NON-NLS-1$
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
|
@ -13,24 +13,19 @@ package org.eclipse.cdt.core.parser.tests.rewrite.changegenerator.replace;
|
|||
|
||||
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.IASTStatement;
|
||||
import org.eclipse.cdt.core.dom.ast.cpp.ICPPASTForStatement;
|
||||
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.rewrite.ASTModification;
|
||||
import org.eclipse.cdt.internal.core.dom.rewrite.ASTModificationStore;
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
public class ReplaceForLoopBodyTest extends ChangeGeneratorTest {
|
||||
|
||||
private boolean forReplaced = false;
|
||||
private boolean forReplaced;
|
||||
|
||||
public ReplaceForLoopBodyTest(){
|
||||
super("Replace For-Loop"); //$NON-NLS-1$
|
||||
super("ReplaceForLoopBodyTest"); //$NON-NLS-1$
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -45,7 +40,6 @@ public class ReplaceForLoopBodyTest extends ChangeGeneratorTest {
|
|||
return new ReplaceForLoopBodyTest();
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
protected ASTVisitor createModificator(
|
||||
final ASTModificationStore modStore) {
|
||||
|
|
|
@ -65,8 +65,7 @@ public class ReplaceInsertStatementTest extends ChangeGeneratorTest {
|
|||
IASTLiteralExpression value = new CPPASTLiteralExpression(
|
||||
IASTLiteralExpression.lk_integer_constant, "42".toCharArray());
|
||||
IASTExpressionStatement insertStmt = new CPPASTExpressionStatement(
|
||||
new CPPASTBinaryExpression(
|
||||
IASTBinaryExpression.op_assign, id, value));
|
||||
new CPPASTBinaryExpression(IASTBinaryExpression.op_assign, id, value));
|
||||
|
||||
IASTIdExpression incId = new CPPASTIdExpression(
|
||||
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 static Test suite() throws Exception {
|
||||
TestSuite suite = new TestSuite("ChangeGeneratorReplaceTests");
|
||||
TestSuite suite = new TestSuite("ReplaceTestSuite");
|
||||
|
||||
suite.addTest(NameTest.suite());
|
||||
suite.addTest(MoveTest.suite());
|
||||
|
|
|
@ -9,6 +9,9 @@ org.eclipse.cdt.core/debug/parser=false
|
|||
# Prints parser stack traces
|
||||
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
|
||||
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.
|
||||
*/
|
||||
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
|
||||
|
|
|
@ -67,7 +67,7 @@ public interface IASTDeclarator extends IASTNode, IASTNameOwner {
|
|||
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.
|
||||
*
|
||||
* @return the nested declarator or null
|
||||
|
@ -77,7 +77,7 @@ public interface IASTDeclarator extends IASTNode, IASTNameOwner {
|
|||
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.
|
||||
*
|
||||
* @return the name of the declarator
|
||||
|
@ -85,7 +85,7 @@ public interface IASTDeclarator extends IASTNode, IASTNameOwner {
|
|||
public IASTName getName();
|
||||
|
||||
/**
|
||||
* Set the name of he declarator.
|
||||
* Sets the name of he declarator.
|
||||
*
|
||||
* @param name
|
||||
* <code>IASTName</code>
|
||||
|
@ -93,7 +93,7 @@ public interface IASTDeclarator extends IASTNode, IASTNameOwner {
|
|||
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
|
||||
*/
|
||||
|
|
|
@ -17,7 +17,6 @@ package org.eclipse.cdt.core.dom.ast;
|
|||
* @noimplement This interface is not intended to be implemented by clients.
|
||||
*/
|
||||
public interface IASTExpressionList extends IASTExpression {
|
||||
|
||||
/**
|
||||
* <code>NESTED_EXPRESSION</code> describes the relationship between
|
||||
* <code>IASTExpressionList</code> and the nested
|
||||
|
|
|
@ -19,7 +19,6 @@ package org.eclipse.cdt.core.dom.ast;
|
|||
*/
|
||||
@Deprecated
|
||||
public interface IASTInitializerExpression extends IASTEqualsInitializer {
|
||||
|
||||
/**
|
||||
* <code>INITIALIZER_EXPRESSION</code> represents the relationship between
|
||||
* an <code>IASTInitializerExpression</code>. and its <code></code>IASTExpression</code>.
|
||||
|
|
|
@ -24,8 +24,8 @@ public interface IValue {
|
|||
Long numericalValue();
|
||||
|
||||
/**
|
||||
* Returns an internal representation of the expression that builds up the
|
||||
* value. It is suitable for instantiating dependent values but may not be
|
||||
* Returns an internal representation of the expression that builds up
|
||||
* the value. It is suitable for instantiating dependent values but may not be
|
||||
* used for the purpose of displaying values.
|
||||
*/
|
||||
char[] getInternalExpression();
|
||||
|
@ -37,8 +37,8 @@ public interface IValue {
|
|||
IBinding[] getUnknownBindings();
|
||||
|
||||
/**
|
||||
* Returns a signature containing both the internal representation and the
|
||||
* unknown bindings. The representation is sufficient to distinguish values
|
||||
* Returns a signature containing both the internal representation and
|
||||
* the unknown bindings. The representation is sufficient to distinguish values
|
||||
* for the purpose of instantiation, it may not be used to display the value.
|
||||
*/
|
||||
char[] getSignature();
|
||||
|
|
|
@ -210,7 +210,8 @@ public final class ASTRewrite {
|
|||
if (!(fRoot instanceof IASTTranslationUnit)) {
|
||||
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) {
|
||||
|
|
|
@ -30,7 +30,6 @@ import org.eclipse.cdt.internal.core.parser.scanner.Lexer;
|
|||
* @noimplement This interface is not intended to be implemented by clients.
|
||||
*/
|
||||
public interface IScanner {
|
||||
|
||||
/**
|
||||
* Returns a map from {@link String} to {@link IMacroBinding} containing
|
||||
* 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)
|
||||
*/
|
||||
public abstract class ASTEqualsInitializer extends ASTNode implements IASTEqualsInitializer,
|
||||
IASTAmbiguityParent {
|
||||
|
||||
public abstract class ASTEqualsInitializer extends ASTNode
|
||||
implements IASTEqualsInitializer, IASTAmbiguityParent {
|
||||
private IASTInitializerClause fArgument;
|
||||
|
||||
public ASTEqualsInitializer() {
|
||||
|
|
|
@ -182,7 +182,6 @@ public abstract class AbstractGNUSourceCodeParser implements ISourceCodeParser {
|
|||
protected boolean functionCallCanBeLValue= false;
|
||||
protected boolean skipTrivialExpressionsInAggregateInitializers= false;
|
||||
|
||||
|
||||
/**
|
||||
* Marks the beginning of the current declaration. It is important to clear the mark whenever we
|
||||
* enter a nested declaration, in order to avoid holding on to all the tokens.
|
||||
|
@ -563,10 +562,9 @@ public abstract class AbstractGNUSourceCodeParser implements ISourceCodeParser {
|
|||
}
|
||||
|
||||
/**
|
||||
* Parse an identifier.
|
||||
* Parses an identifier.
|
||||
*
|
||||
* @throws BacktrackException
|
||||
* request a backtrack
|
||||
* @throws BacktrackException request a backtrack
|
||||
*/
|
||||
protected abstract IASTName identifier() throws EndOfFileException, BacktrackException;
|
||||
|
||||
|
@ -1242,7 +1240,7 @@ public abstract class AbstractGNUSourceCodeParser implements ISourceCodeParser {
|
|||
}
|
||||
IASTCastExpression result = buildCastExpression(IASTCastExpression.op_cast,
|
||||
typeId, rhs, startingOffset, calculateEndOffset(rhs));
|
||||
if (!unaryFailed && couldBeFunctionCall && rhs instanceof IASTCastExpression == false) {
|
||||
if (!unaryFailed && couldBeFunctionCall && !(rhs instanceof IASTCastExpression)) {
|
||||
IToken markEnd= mark();
|
||||
backup(mark);
|
||||
try {
|
||||
|
@ -2123,7 +2121,6 @@ public abstract class AbstractGNUSourceCodeParser implements ISourceCodeParser {
|
|||
}
|
||||
}
|
||||
|
||||
|
||||
protected IASTStatement parseCompoundStatement() throws EndOfFileException, BacktrackException {
|
||||
IASTCompoundStatement compound = compoundStatement();
|
||||
return compound;
|
||||
|
@ -2164,27 +2161,25 @@ public abstract class AbstractGNUSourceCodeParser implements ISourceCodeParser {
|
|||
return cs;
|
||||
}
|
||||
|
||||
|
||||
protected int figureEndOffset(IASTDeclSpecifier declSpec, IASTDeclarator[] declarators) {
|
||||
if (declarators.length == 0)
|
||||
return calculateEndOffset(declSpec);
|
||||
return calculateEndOffset(declarators[declarators.length - 1]);
|
||||
}
|
||||
|
||||
|
||||
protected int figureEndOffset(IASTDeclSpecifier declSpecifier, IASTDeclarator declarator) {
|
||||
if (declarator == null || ((ASTNode) declarator).getLength() == 0)
|
||||
return calculateEndOffset(declSpecifier);
|
||||
return calculateEndOffset(declarator);
|
||||
}
|
||||
|
||||
|
||||
protected void throwBacktrack(IToken token) throws BacktrackException {
|
||||
throwBacktrack(token.getOffset(), token.getLength());
|
||||
}
|
||||
|
||||
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;
|
||||
IASTExpression expr= 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 allowDeclspec if true accept any number of __declspec
|
||||
|
@ -2416,7 +2411,7 @@ public abstract class AbstractGNUSourceCodeParser implements ISourceCodeParser {
|
|||
* @throws EndOfFileException
|
||||
*/
|
||||
protected void handleOtherDeclSpecModifier() throws BacktrackException, EndOfFileException {
|
||||
// default action: consume keyword plus optional parenthesised "something"
|
||||
// default action: consume keyword plus optional parenthesized "something"
|
||||
consume();
|
||||
|
||||
IToken token = LA(1);
|
||||
|
@ -2504,7 +2499,6 @@ public abstract class AbstractGNUSourceCodeParser implements ISourceCodeParser {
|
|||
}
|
||||
|
||||
protected boolean canBeTypeSpecifier() throws EndOfFileException {
|
||||
|
||||
final int lt1 = LT(1);
|
||||
switch (lt1) {
|
||||
// simple type specifiers:
|
||||
|
|
|
@ -17,7 +17,6 @@ import org.eclipse.cdt.core.dom.ast.INodeFactory;
|
|||
* Abstract base class for node factories.
|
||||
*/
|
||||
public abstract class NodeFactory implements INodeFactory {
|
||||
|
||||
@Override
|
||||
public final void setOffsets(IASTNode node, int offset, int endOffset) {
|
||||
((ASTNode) node).setOffsetAndLength(offset, endOffset-offset);
|
||||
|
|
|
@ -29,11 +29,9 @@ import org.eclipse.core.runtime.Assert;
|
|||
* @since 5.0.1
|
||||
*/
|
||||
public class CASTAmbiguousDeclarator extends ASTAmbiguousNode implements IASTAmbiguousDeclarator {
|
||||
|
||||
private IASTDeclarator[] dtors = new IASTDeclarator[2];
|
||||
private int dtorPos= -1;
|
||||
|
||||
|
||||
public CASTAmbiguousDeclarator(IASTDeclarator... decls) {
|
||||
for (IASTDeclarator d : decls) {
|
||||
if (d != null) {
|
||||
|
|
|
@ -415,7 +415,7 @@ public class GNUCSourceParser extends AbstractGNUSourceCodeParser {
|
|||
|
||||
final IASTDeclarator outerDtor= declarators[0];
|
||||
final IASTDeclarator fdtor= ASTQueries.findTypeRelevantDeclarator(outerDtor);
|
||||
if (fdtor instanceof IASTFunctionDeclarator == false)
|
||||
if (!(fdtor instanceof IASTFunctionDeclarator))
|
||||
throwBacktrack(firstOffset, LA(1).getEndOffset() - firstOffset);
|
||||
|
||||
IASTFunctionDefinition funcDefinition = nodeFactory.newFunctionDefinition(declSpec, (IASTFunctionDeclarator) fdtor, null);
|
||||
|
@ -1597,7 +1597,7 @@ public class GNUCSourceParser extends AbstractGNUSourceCodeParser {
|
|||
}
|
||||
|
||||
private IASTSimpleDeclaration checkKnrParameterDeclaration(IASTDeclaration decl, final IASTName[] parmNames) {
|
||||
if (decl instanceof IASTSimpleDeclaration == false)
|
||||
if (!(decl instanceof IASTSimpleDeclaration))
|
||||
return null;
|
||||
|
||||
IASTSimpleDeclaration declaration= ((IASTSimpleDeclaration) decl);
|
||||
|
@ -1839,7 +1839,6 @@ public class GNUCSourceParser extends AbstractGNUSourceCodeParser {
|
|||
|
||||
return parseDeclarationOrExpressionStatement();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -1863,7 +1862,7 @@ public class GNUCSourceParser extends AbstractGNUSourceCodeParser {
|
|||
previousWasIdentifier = false;
|
||||
} else if (LT(1) == IToken.tIDENTIFIER) {
|
||||
consume();
|
||||
if (previousWasIdentifier == true) {
|
||||
if (previousWasIdentifier) {
|
||||
backup(mark);
|
||||
return 0; // i.e. KnR C won't have int f(typedef x)
|
||||
// char
|
||||
|
@ -2011,8 +2010,7 @@ public class GNUCSourceParser extends AbstractGNUSourceCodeParser {
|
|||
|
||||
if (if_statement != null) {
|
||||
if_statement.setElseClause(new_if_statement);
|
||||
((ASTNode) if_statement)
|
||||
.setLength(calculateEndOffset(new_if_statement)
|
||||
((ASTNode) if_statement).setLength(calculateEndOffset(new_if_statement)
|
||||
- ((ASTNode) if_statement).getOffset());
|
||||
}
|
||||
if (result == null && if_statement != null)
|
||||
|
@ -2027,8 +2025,7 @@ public class GNUCSourceParser extends AbstractGNUSourceCodeParser {
|
|||
new_if_statement.setElseClause(elseStatement);
|
||||
if (if_statement != null) {
|
||||
if_statement.setElseClause(new_if_statement);
|
||||
((ASTNode) if_statement)
|
||||
.setLength(calculateEndOffset(new_if_statement)
|
||||
((ASTNode) if_statement).setLength(calculateEndOffset(new_if_statement)
|
||||
- ((ASTNode) if_statement).getOffset());
|
||||
} else {
|
||||
if (result == null)
|
||||
|
@ -2037,12 +2034,10 @@ public class GNUCSourceParser extends AbstractGNUSourceCodeParser {
|
|||
}
|
||||
} else {
|
||||
if( thenClause != null )
|
||||
((ASTNode) new_if_statement)
|
||||
.setLength(calculateEndOffset(thenClause) - start);
|
||||
((ASTNode) new_if_statement).setLength(calculateEndOffset(thenClause) - start);
|
||||
if (if_statement != null) {
|
||||
if_statement.setElseClause(new_if_statement);
|
||||
((ASTNode) new_if_statement)
|
||||
.setLength(calculateEndOffset(new_if_statement) - start);
|
||||
((ASTNode) new_if_statement).setLength(calculateEndOffset(new_if_statement) - start);
|
||||
}
|
||||
if (result == null && if_statement != null)
|
||||
result = if_statement;
|
||||
|
|
|
@ -29,13 +29,12 @@ import org.eclipse.core.runtime.Assert;
|
|||
* <br>
|
||||
* 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 int dtorPos= -1;
|
||||
private IASTInitializer fInitializer;
|
||||
|
||||
|
||||
public CPPASTAmbiguousDeclarator(IASTDeclarator... decls) {
|
||||
for (IASTDeclarator d : decls) {
|
||||
if (d != null) {
|
||||
|
|
|
@ -16,7 +16,7 @@ import org.eclipse.cdt.core.dom.ast.ASTVisitor;
|
|||
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 {
|
||||
|
||||
|
|
|
@ -27,8 +27,8 @@ import org.eclipse.cdt.internal.core.dom.parser.IASTAmbiguityParent;
|
|||
public class CPPASTWhileStatement extends ASTNode
|
||||
implements ICPPASTWhileStatement, IASTAmbiguityParent {
|
||||
private IASTExpression condition;
|
||||
private IASTStatement body;
|
||||
private IASTDeclaration condition2;
|
||||
private IASTStatement body;
|
||||
private IScope scope;
|
||||
|
||||
public CPPASTWhileStatement() {
|
||||
|
@ -118,17 +118,16 @@ public class CPPASTWhileStatement extends ASTNode
|
|||
default: break;
|
||||
}
|
||||
}
|
||||
if (condition != null && !condition.accept(action)) return false;
|
||||
if (condition2 != null && !condition2.accept(action)) return false;
|
||||
if (body != null && !body.accept(action)) return false;
|
||||
if (condition != null && !condition.accept(action))
|
||||
return false;
|
||||
if (condition2 != null && !condition2.accept(action))
|
||||
return false;
|
||||
if (body != null && !body.accept(action))
|
||||
return false;
|
||||
|
||||
if (action.shouldVisitStatements && action.leave(this) == ASTVisitor.PROCESS_ABORT)
|
||||
return false;
|
||||
|
||||
if (action.shouldVisitExpressions) {
|
||||
switch (action.leave(this)) {
|
||||
case ASTVisitor.PROCESS_ABORT: return false;
|
||||
case ASTVisitor.PROCESS_SKIP: return true;
|
||||
default: break;
|
||||
}
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
|
|
|
@ -2454,7 +2454,7 @@ public class GNUCPPSourceParser extends AbstractGNUSourceCodeParser {
|
|||
IASTDeclarator outerDtor) throws EndOfFileException, BacktrackException {
|
||||
|
||||
final IASTDeclarator dtor= ASTQueries.findTypeRelevantDeclarator(outerDtor);
|
||||
if (dtor instanceof ICPPASTFunctionDeclarator == false)
|
||||
if (!(dtor instanceof ICPPASTFunctionDeclarator))
|
||||
throwBacktrack(firstOffset, LA(1).getEndOffset() - firstOffset);
|
||||
|
||||
|
||||
|
|
|
@ -20,7 +20,8 @@ import org.eclipse.ltk.core.refactoring.TextFileChange;
|
|||
public class ASTRewriteAnalyzer {
|
||||
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);
|
||||
rewriter.generateChange(root);
|
||||
return rewriter.getChange();
|
||||
|
|
|
@ -72,6 +72,8 @@ import org.eclipse.jface.text.TextUtilities;
|
|||
import org.eclipse.ltk.core.refactoring.Change;
|
||||
import org.eclipse.ltk.core.refactoring.CompositeChange;
|
||||
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.MultiTextEdit;
|
||||
import org.eclipse.text.edits.ReplaceEdit;
|
||||
|
@ -312,6 +314,37 @@ public class ChangeGenerator extends ASTVisitor {
|
|||
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.
|
||||
*
|
||||
|
@ -321,47 +354,40 @@ public class ChangeGenerator extends ASTVisitor {
|
|||
private void formatChangedCode(String code, ITranslationUnit tu) {
|
||||
IDocument document = new Document(code);
|
||||
try {
|
||||
// Apply refactoring changes to a temporary document.
|
||||
TextEdit edit = rootEdit.copy();
|
||||
// Apply refactoring changes to a temporary document.
|
||||
edit.apply(document, TextEdit.UPDATE_REGIONS);
|
||||
|
||||
// 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
|
||||
// the refactoring changes.
|
||||
TextEdit[] edits = edit.getChildren();
|
||||
TextEdit[] originalEdits = rootEdit.getChildren();
|
||||
IRegion[] regionsAfter = new IRegion[edits.length];
|
||||
IRegion[] regionsBefore = new IRegion[edits.length];
|
||||
TextEdit[] appliedEdits = edit.getChildren();
|
||||
TextEdit[] edits = rootEdit.removeChildren();
|
||||
IRegion[] regions = new IRegion[appliedEdits.length];
|
||||
int numRegions = 0;
|
||||
int prevEnd = -1;
|
||||
for (int i = 0; i < edits.length; i++) {
|
||||
edit = edits[i];
|
||||
for (int i = 0; i < appliedEdits.length; i++) {
|
||||
edit = appliedEdits[i];
|
||||
int offset = edit.getOffset();
|
||||
int end = offset + edit.getLength();
|
||||
int newOffset = document.getLineInformationOfOffset(offset).getOffset();
|
||||
edit = originalEdits[i];
|
||||
edit = edits[i];
|
||||
int originalEnd = edit.getExclusiveEnd();
|
||||
// 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.
|
||||
int newEnd = (originalEnd == 0 || code.charAt(originalEnd - 1) == '\n') && end == newOffset ?
|
||||
end : endOffset(document.getLineInformationOfOffset(end));
|
||||
int offsetBefore = edit.getOffset();
|
||||
int newOffsetBefore = newOffset + offsetBefore - offset;
|
||||
int newEndBefore = newEnd + offsetBefore + edit.getLength() - end;
|
||||
if (newOffset <= prevEnd) {
|
||||
numRegions--;
|
||||
newOffset = regionsAfter[numRegions].getOffset();
|
||||
newOffsetBefore = regionsBefore[numRegions].getOffset();
|
||||
newOffset = regions[numRegions].getOffset();
|
||||
}
|
||||
prevEnd = newEnd;
|
||||
regionsAfter[numRegions] = new Region(newOffset, newEnd - newOffset);
|
||||
regionsBefore[numRegions] = new Region(newOffsetBefore, newEndBefore - newOffsetBefore);
|
||||
regions[numRegions] = new Region(newOffset, newEnd - newOffset);
|
||||
numRegions++;
|
||||
}
|
||||
|
||||
if (numRegions < regionsAfter.length) {
|
||||
regionsAfter = Arrays.copyOf(regionsAfter, numRegions);
|
||||
regionsBefore = Arrays.copyOf(regionsBefore, numRegions);
|
||||
if (numRegions < regions.length) {
|
||||
regions = Arrays.copyOf(regions, numRegions);
|
||||
}
|
||||
|
||||
// Calculate formatting changes for the regions after the refactoring changes.
|
||||
|
@ -374,23 +400,71 @@ public class ChangeGenerator extends ASTVisitor {
|
|||
CodeFormatter formatter = ToolFactory.createCodeFormatter(options);
|
||||
code = document.get();
|
||||
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
|
||||
// the region before the refactoring changes and the text after the formatting changes.
|
||||
MultiTextEdit resultEdit = new MultiTextEdit();
|
||||
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);
|
||||
TextEdit combinedFormatEdit = new MultiTextEdit();
|
||||
for (TextEdit formatEdit : formatEdits) {
|
||||
combinedFormatEdit = TextEditUtil.merge(combinedFormatEdit, formatEdit);
|
||||
}
|
||||
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) {
|
||||
CCorePlugin.log(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) {
|
||||
return region.getOffset() + region.getLength();
|
||||
}
|
||||
|
||||
private int endOffset(TextEdit edit) {
|
||||
return edit.getOffset() + edit.getLength();
|
||||
}
|
||||
|
||||
private int endOffset(IASTFileLocation nodeLocation) {
|
||||
return nodeLocation.getNodeOffset() + nodeLocation.getNodeLength();
|
||||
}
|
||||
|
@ -451,21 +554,23 @@ public class ChangeGenerator extends ASTVisitor {
|
|||
insertPos = skipPrecedingBlankLines(tuCode, insertPos);
|
||||
length -= insertPos;
|
||||
}
|
||||
String code = writer.toString();
|
||||
ReplaceEdit edit = new ReplaceEdit(insertPos, length, code);
|
||||
addToRootEdit(anchorNode);
|
||||
rootEdit.addChild(edit);
|
||||
processedOffset = edit.getOffset();
|
||||
String code = writer.toString();
|
||||
if (!code.isEmpty())
|
||||
addChildEdit(new InsertEdit(insertPos, code));
|
||||
if (length != 0)
|
||||
addChildEdit(new DeleteEdit(insertPos, length));
|
||||
}
|
||||
|
||||
private void handleReplace(IASTNode node) {
|
||||
List<ASTModification> modifications = getModifications(node, ModificationKind.REPLACE);
|
||||
String source = node.getTranslationUnit().getRawSignature();
|
||||
TextEdit edit;
|
||||
ChangeGeneratorWriterVisitor writer =
|
||||
new ChangeGeneratorWriterVisitor(modificationStore, commentMap);
|
||||
IASTFileLocation fileLocation = node.getFileLocation();
|
||||
addToRootEdit(node);
|
||||
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 endOffset = getEndOffsetIncludingComments(node);
|
||||
offset = Math.max(skipPrecedingBlankLines(source, offset), processedOffset);
|
||||
|
@ -492,25 +597,27 @@ public class ChangeGenerator extends ASTVisitor {
|
|||
writer.newLine();
|
||||
}
|
||||
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 {
|
||||
node.accept(writer);
|
||||
String code = writer.toString();
|
||||
int offset = fileLocation.getNodeOffset();
|
||||
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();
|
||||
if (code.endsWith(lineSeparator)) {
|
||||
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) {
|
||||
|
@ -537,13 +644,12 @@ public class ChangeGenerator extends ASTVisitor {
|
|||
if (node instanceof ICPPASTNamespaceDefinition) {
|
||||
writer.newLine();
|
||||
}
|
||||
String code = writer.toString();
|
||||
addToRootEdit(node);
|
||||
ReplaceEdit edit = new ReplaceEdit(anchor.getOffset(), anchor.getLength(),
|
||||
code + anchor.getText());
|
||||
rootEdit.addChild(edit);
|
||||
IASTFileLocation fileLocation = node.getFileLocation();
|
||||
processedOffset = endOffset(fileLocation);
|
||||
String code = writer.toString();
|
||||
if (!code.isEmpty())
|
||||
addChildEdit(new InsertEdit(anchor.getOffset(), code));
|
||||
addChildEdit(new ReplaceEdit(anchor.getOffset(), anchor.getLength(), anchor.getText()));
|
||||
processedOffset = endOffset(node);
|
||||
}
|
||||
|
||||
private void handleAppends(IASTTranslationUnit node) {
|
||||
|
@ -565,6 +671,7 @@ public class ChangeGenerator extends ASTVisitor {
|
|||
String source = node.getRawSignature();
|
||||
int endOffset = skipTrailingBlankLines(source, offset);
|
||||
|
||||
addToRootEdit(node);
|
||||
ChangeGeneratorWriterVisitor writer =
|
||||
new ChangeGeneratorWriterVisitor(modificationStore, commentMap);
|
||||
IASTNode newNode = null;
|
||||
|
@ -593,8 +700,10 @@ public class ChangeGenerator extends ASTVisitor {
|
|||
}
|
||||
|
||||
String code = writer.toString();
|
||||
addToRootEdit(node);
|
||||
rootEdit.addChild(new ReplaceEdit(offset, endOffset - offset, code));
|
||||
if (!code.isEmpty())
|
||||
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.IResource;
|
||||
import org.eclipse.core.resources.IResourceChangeEvent;
|
||||
import org.eclipse.core.resources.ProjectScope;
|
||||
import org.eclipse.core.resources.ResourcesPlugin;
|
||||
import org.eclipse.core.runtime.CoreException;
|
||||
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);
|
||||
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) {
|
||||
if (fClosingProjects.contains(prj.getName())) {
|
||||
return;
|
||||
|
@ -520,7 +517,7 @@ public class PDOMManager implements IWritableIndexManager, IListener {
|
|||
}
|
||||
enqueue(new PDOMRebuildTask(indexer));
|
||||
}
|
||||
}}
|
||||
}
|
||||
|
||||
if (oldIndexer != null) {
|
||||
stopIndexer(oldIndexer);
|
||||
|
@ -553,8 +550,6 @@ public class PDOMManager implements IWritableIndexManager, IListener {
|
|||
|
||||
assert !Thread.holdsLock(fProjectToPDOM);
|
||||
try {
|
||||
// Workaround for https://bugs.eclipse.org/bugs/show_bug.cgi?id=359485
|
||||
synchronized (new ProjectScope(prj).getNode(CCorePlugin.PLUGIN_ID)) {
|
||||
synchronized (fUpdatePolicies) {
|
||||
if (fClosingProjects.contains(name)) {
|
||||
if (fTraceIndexerSetup)
|
||||
|
@ -604,14 +599,12 @@ public class PDOMManager implements IWritableIndexManager, IListener {
|
|||
}
|
||||
return;
|
||||
}
|
||||
}}
|
||||
}
|
||||
|
||||
// rebuild is required, try import first.
|
||||
TeamPDOMImportOperation operation= new TeamPDOMImportOperation(project);
|
||||
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) {
|
||||
if (fClosingProjects.contains(name)) {
|
||||
if (fTraceIndexerSetup)
|
||||
|
@ -624,9 +617,10 @@ public class PDOMManager implements IWritableIndexManager, IListener {
|
|||
registerIndexer(project, indexer);
|
||||
final IndexUpdatePolicy policy= createPolicy(project);
|
||||
policy.clearTUs();
|
||||
policy.clearInitialFlags();
|
||||
|
||||
IPDOMIndexerTask task= null;
|
||||
if (policy.isAutomatic() || policy.isInitialRebuildRequested()) {
|
||||
policy.clearInitialFlags();
|
||||
if (operation.wasSuccessful()) {
|
||||
if (fTraceIndexerSetup)
|
||||
System.out.println("Indexer: Imported shared index for project " + name); //$NON-NLS-1$
|
||||
|
@ -638,7 +632,8 @@ public class PDOMManager implements IWritableIndexManager, IListener {
|
|||
task= new PDOMRebuildTask(indexer);
|
||||
}
|
||||
enqueue(task);
|
||||
}}
|
||||
}
|
||||
}
|
||||
} catch (CoreException e) {
|
||||
// Ignore if project is no longer open
|
||||
if (prj.isOpen()) {
|
||||
|
@ -653,8 +648,7 @@ public class PDOMManager implements IWritableIndexManager, IListener {
|
|||
IExtension indexerExt = Platform.getExtensionRegistry().getExtension(CCorePlugin.INDEXER_UNIQ_ID, indexerId);
|
||||
if (indexerExt != null) {
|
||||
IConfigurationElement[] elements = indexerExt.getConfigurationElements();
|
||||
for (int i = 0; i < elements.length; ++i) {
|
||||
IConfigurationElement element = elements[i];
|
||||
for (IConfigurationElement element : elements) {
|
||||
if ("run".equals(element.getName())) { //$NON-NLS-1$
|
||||
try {
|
||||
indexer = (IPDOMIndexer) element.createExecutableExtension("class"); //$NON-NLS-1$
|
||||
|
|
|
@ -122,6 +122,8 @@ class ResourceLookupTree implements IResourceChangeListener, IResourceDeltaVisit
|
|||
private boolean fNeedCleanup;
|
||||
private Node fLastFolderNode;
|
||||
|
||||
private boolean fTrace;
|
||||
|
||||
public ResourceLookupTree() {
|
||||
fRootNode= new Node(null, CharArrayUtils.EMPTY, false, false) {};
|
||||
fFileExtensions= new HashMap<String, Extensions>();
|
||||
|
@ -133,6 +135,7 @@ class ResourceLookupTree implements IResourceChangeListener, IResourceDeltaVisit
|
|||
}
|
||||
};
|
||||
fUnrefJob.setSystem(true);
|
||||
fTrace= "true".equals(Platform.getDebugOption(CCorePlugin.PLUGIN_ID + "/debug/resourceLookup")); //$NON-NLS-1$//$NON-NLS-2$
|
||||
}
|
||||
|
||||
public void startup() {
|
||||
|
@ -265,13 +268,35 @@ class ResourceLookupTree implements IResourceChangeListener, IResourceDeltaVisit
|
|||
createFileNode(res.getFullPath(), null);
|
||||
}
|
||||
} else {
|
||||
long time=0, count=0;
|
||||
final boolean trace = fTrace && res instanceof IProject;
|
||||
if (trace) {
|
||||
time= System.currentTimeMillis();
|
||||
count= countNodes();
|
||||
}
|
||||
try {
|
||||
res.accept(this, 0);
|
||||
} catch (CoreException 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.
|
||||
|
|
|
@ -128,7 +128,7 @@ public class Scribe {
|
|||
indentationLevel= preferences.initial_indentation_level * indentationSize;
|
||||
preserveNewLines = false;
|
||||
textRegionStart= offset;
|
||||
textRegionEnd= offset + length - 1;
|
||||
textRegionEnd= offset + length;
|
||||
reset();
|
||||
}
|
||||
|
||||
|
@ -574,12 +574,12 @@ public class Scribe {
|
|||
|
||||
public TextEdit getRootEdit() {
|
||||
MultiTextEdit edit= null;
|
||||
int length= textRegionEnd - textRegionStart + 1;
|
||||
int length= textRegionEnd - textRegionStart;
|
||||
if (textRegionStart <= 0) {
|
||||
if (length <= 0) {
|
||||
edit= new MultiTextEdit(0, 0);
|
||||
} else {
|
||||
edit= new MultiTextEdit(0, textRegionEnd + 1);
|
||||
edit= new MultiTextEdit(0, textRegionEnd);
|
||||
}
|
||||
} else {
|
||||
edit= new MultiTextEdit(textRegionStart, length);
|
||||
|
@ -595,7 +595,7 @@ public class Scribe {
|
|||
}
|
||||
|
||||
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.
|
||||
int relativeDepth= 0;
|
||||
Alignment targetAlignment= currentAlignment;
|
||||
|
@ -621,6 +621,7 @@ public class Scribe {
|
|||
if (outerMostDepth >= 0) {
|
||||
throwAlignmentException(AlignmentException.LINE_TOO_LONG, outerMostDepth);
|
||||
}
|
||||
|
||||
// Look for innermost breakable one but don't stop if we encounter a R_OUTERMOST
|
||||
// tie-breaking rule.
|
||||
relativeDepth= 0;
|
||||
|
@ -710,7 +711,7 @@ public class Scribe {
|
|||
final int editReplacementLength= edit.replacement.length();
|
||||
final int editOffset= edit.offset;
|
||||
if (editLength != 0) {
|
||||
if (textRegionStart <= editOffset && (editOffset + editLength - 1) <= textRegionEnd) {
|
||||
if (textRegionStart <= editOffset && editOffset + editLength <= textRegionEnd) {
|
||||
if (editReplacementLength != 0 && editLength == editReplacementLength) {
|
||||
for (int i= editOffset, max= editOffset + editLength; i < max; i++) {
|
||||
if (scanner.source[i] != edit.replacement.charAt(i - editOffset)) {
|
||||
|
@ -737,9 +738,9 @@ public class Scribe {
|
|||
return true;
|
||||
}
|
||||
}
|
||||
} else if (textRegionStart <= editOffset && editOffset <= textRegionEnd) {
|
||||
} else if (textRegionStart <= editOffset && editOffset < textRegionEnd) {
|
||||
return true;
|
||||
} else if (editOffset == scannerEndPosition && editOffset == textRegionEnd + 1) {
|
||||
} else if (editOffset == scannerEndPosition && editOffset == textRegionEnd) {
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
|
|
|
@ -333,7 +333,6 @@ public class ExtractLocalVariableRefactoringTest extends RefactoringTestBase {
|
|||
}
|
||||
|
||||
//A.cpp
|
||||
//
|
||||
//template<class T>
|
||||
//class Foo {
|
||||
//};
|
||||
|
@ -345,7 +344,6 @@ public class ExtractLocalVariableRefactoringTest extends RefactoringTestBase {
|
|||
// return 0;
|
||||
//}
|
||||
//====================
|
||||
//
|
||||
//template<class T>
|
||||
//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.text.ICReconcilingListener;
|
||||
|
||||
|
||||
/**
|
||||
* Semantic highlighting reconciler - Background thread implementation.
|
||||
* Cloned from JDT.
|
||||
|
@ -59,12 +58,10 @@ import org.eclipse.cdt.internal.ui.text.ICReconcilingListener;
|
|||
* @since 4.0
|
||||
*/
|
||||
public class SemanticHighlightingReconciler implements ICReconcilingListener {
|
||||
|
||||
/**
|
||||
* Collects positions from the AST.
|
||||
*/
|
||||
private class PositionCollector extends ASTVisitor {
|
||||
|
||||
/** The semantic token */
|
||||
private SemanticToken fToken= new SemanticToken();
|
||||
private int fMinLocation;
|
||||
|
@ -82,12 +79,8 @@ public class SemanticHighlightingReconciler implements ICReconcilingListener {
|
|||
shouldVisitImplicitNameAlternates = visitImplicitNames;
|
||||
}
|
||||
|
||||
/*
|
||||
* @see org.eclipse.cdt.core.dom.ast.ASTVisitor#visit(org.eclipse.cdt.core.dom.ast.IASTTranslationUnit)
|
||||
*/
|
||||
@Override
|
||||
public int visit(IASTTranslationUnit tu) {
|
||||
|
||||
// visit macro definitions
|
||||
IASTPreprocessorMacroDefinition[] macroDefs= tu.getMacroDefinitions();
|
||||
for (IASTPreprocessorMacroDefinition macroDef : macroDefs) {
|
||||
|
@ -115,9 +108,6 @@ public class SemanticHighlightingReconciler implements ICReconcilingListener {
|
|||
return super.visit(tu);
|
||||
}
|
||||
|
||||
/*
|
||||
* @see org.eclipse.cdt.core.dom.ast.ASTVisitor#visit(org.eclipse.cdt.core.dom.ast.IASTDeclaration)
|
||||
*/
|
||||
@Override
|
||||
public int visit(IASTDeclaration declaration) {
|
||||
if (!declaration.isPartOfTranslationUnitFile()) {
|
||||
|
@ -126,9 +116,6 @@ public class SemanticHighlightingReconciler implements ICReconcilingListener {
|
|||
return PROCESS_CONTINUE;
|
||||
}
|
||||
|
||||
/*
|
||||
* @see org.eclipse.cdt.core.dom.ast.ASTVisitor#leave(org.eclipse.cdt.core.dom.ast.IASTDeclaration)
|
||||
*/
|
||||
@Override
|
||||
public int leave(IASTDeclaration declaration) {
|
||||
// if (!shouldVisitCatchHandlers && declaration instanceof IASTFunctionDefinition) {
|
||||
|
@ -154,9 +141,6 @@ public class SemanticHighlightingReconciler implements ICReconcilingListener {
|
|||
return PROCESS_CONTINUE;
|
||||
}
|
||||
|
||||
/*
|
||||
* @see org.eclipse.cdt.core.dom.ast.ASTVisitor#visit(org.eclipse.cdt.core.dom.ast.IASTDeclarator)
|
||||
*/
|
||||
@Override
|
||||
public int visit(IASTDeclarator declarator) {
|
||||
// if (declarator instanceof ICPPASTFunctionTryBlockDeclarator) {
|
||||
|
@ -165,9 +149,6 @@ public class SemanticHighlightingReconciler implements ICReconcilingListener {
|
|||
return PROCESS_CONTINUE;
|
||||
}
|
||||
|
||||
/*
|
||||
* @see org.eclipse.cdt.core.dom.ast.ASTVisitor#visit(org.eclipse.cdt.core.dom.ast.IASTStatement)
|
||||
*/
|
||||
@Override
|
||||
public int visit(IASTStatement statement) {
|
||||
// if (!shouldVisitCatchHandlers && statement instanceof ICPPASTCatchHandler) {
|
||||
|
@ -176,9 +157,6 @@ public class SemanticHighlightingReconciler implements ICReconcilingListener {
|
|||
return PROCESS_CONTINUE;
|
||||
}
|
||||
|
||||
/*
|
||||
* @see org.eclipse.cdt.core.dom.ast.ASTVisitor#visit(org.eclipse.cdt.core.dom.ast.IASTName)
|
||||
*/
|
||||
@Override
|
||||
public int visit(IASTName name) {
|
||||
if (visitNode(name)) {
|
||||
|
@ -226,7 +204,7 @@ public class SemanticHighlightingReconciler implements ICReconcilingListener {
|
|||
}
|
||||
}
|
||||
} else {
|
||||
// fallback in case no image location available
|
||||
// Fallback in case no image location available
|
||||
IASTNodeLocation[] nodeLocations= name.getNodeLocations();
|
||||
if (nodeLocations.length == 1 && !(nodeLocations[0] instanceof IASTMacroExpansionLocation)) {
|
||||
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)} */
|
||||
private HighlightingStyle[] fJobHighlightings;
|
||||
|
||||
/*
|
||||
* @see org.eclipse.cdt.internal.ui.text.java.ICReconcilingListener#aboutToBeReconciled()
|
||||
*/
|
||||
@Override
|
||||
public void aboutToBeReconciled() {
|
||||
// Do nothing
|
||||
}
|
||||
|
||||
/*
|
||||
* @see org.eclipse.cdt.internal.ui.text.ICReconcilingListener#reconciled(IASTTranslationUnit, boolean, IProgressMonitor)
|
||||
*/
|
||||
@Override
|
||||
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) {
|
||||
if (fIsReconciling)
|
||||
return;
|
||||
|
@ -410,12 +382,13 @@ public class SemanticHighlightingReconciler implements ICReconcilingListener {
|
|||
newPositions.add(current);
|
||||
}
|
||||
fRemovedPositions= newPositions;
|
||||
// positions need to be sorted by ascending offset
|
||||
// Positions need to be sorted by ascending offset
|
||||
Collections.sort(fAddedPositions, new Comparator<Position>() {
|
||||
@Override
|
||||
public int compare(final Position p1, final Position p2) {
|
||||
return p1.getOffset() - p2.getOffset();
|
||||
}});
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -450,7 +423,7 @@ public class SemanticHighlightingReconciler implements ICReconcilingListener {
|
|||
}
|
||||
|
||||
/**
|
||||
* Stop reconciling positions.
|
||||
* Stops reconciling positions.
|
||||
*/
|
||||
protected void stopReconcilingPositions() {
|
||||
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 sourceViewer the source viewer
|
||||
* @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() {
|
||||
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() {
|
||||
final ICElement element= fEditor.getInputCElement();
|
||||
|
|
|
@ -9,7 +9,6 @@
|
|||
* IBM Corporation - initial API and implementation
|
||||
* Anton Leherbauer (Wind River Systems) - Adapted for CDT
|
||||
*******************************************************************************/
|
||||
|
||||
package org.eclipse.cdt.internal.ui.editor;
|
||||
|
||||
import org.eclipse.cdt.core.dom.ast.IASTName;
|
||||
|
@ -24,7 +23,6 @@ import org.eclipse.cdt.core.dom.ast.IBinding;
|
|||
* @since 4.0
|
||||
*/
|
||||
public final class SemanticToken {
|
||||
|
||||
/** AST node */
|
||||
private IASTNode fNode;
|
||||
|
||||
|
@ -35,7 +33,7 @@ public final class SemanticToken {
|
|||
|
||||
/** AST root */
|
||||
private IASTTranslationUnit fRoot;
|
||||
private boolean fIsRootResolved= false;
|
||||
private boolean fIsRootResolved;
|
||||
|
||||
/**
|
||||
* @return Returns the binding, can be <code>null</code>.
|
||||
|
|
|
@ -251,7 +251,7 @@ public class ExtractFunctionInputPage extends UserInputWizardPage {
|
|||
return;
|
||||
|
||||
if (methodName.isEmpty()) {
|
||||
methodName = StubUtility.suggestMethodName("someMethodName", null, //$NON-NLS-1$
|
||||
methodName = StubUtility.suggestMethodName("extracted", null, //$NON-NLS-1$
|
||||
refactoring.getTranslationUnit());
|
||||
}
|
||||
|
||||
|
|
|
@ -643,8 +643,8 @@ public class ExtractFunctionRefactoring extends CRefactoring {
|
|||
insertion = new InsertionInfo(parent, functionToExtractFrom);
|
||||
}
|
||||
if (insertion.getPrologue() != null) {
|
||||
rewrite.insertBefore(insertion.getParentNode(),
|
||||
insertion.getInsertBeforeNode(), insertion.getPrologue(), group);
|
||||
rewrite.insertBefore(insertion.getParentNode(), insertion.getInsertBeforeNode(),
|
||||
insertion.getPrologue(), group);
|
||||
}
|
||||
subRewrite = rewrite.insertBefore(insertion.getParentNode(),
|
||||
insertion.getInsertBeforeNode(), nodeToInsert, group);
|
||||
|
|
|
@ -35,8 +35,8 @@ public interface ICBreakpoint extends IBreakpoint {
|
|||
/**
|
||||
* This debug model identifier can be returned by a debug implementation
|
||||
* to indicate that a given debugger integration is using C Breakpoints.
|
||||
* This model ID will allow breakpoint actions to configure their default
|
||||
* selection.
|
||||
* This model ID will allow toggle breakpoint actions to configure their
|
||||
* default selection.
|
||||
*
|
||||
* @since 7.0
|
||||
*/
|
||||
|
|
|
@ -9,4 +9,11 @@
|
|||
</message_arguments>
|
||||
</filter>
|
||||
</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>
|
||||
|
|
|
@ -38,7 +38,7 @@ ShowDebuggerConsoleAction.tooltip=Show Debugger Console On Target Selection
|
|||
AddBreakpoint.label=Toggle &Breakpoint\tDouble Click
|
||||
AddBreakpointInteractive.label=&Add Breakpoint...\tCtrl+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
|
||||
BreakpointPropertiesCommand.name=C/C++ Breakpoint Properties
|
||||
BreakpointPropertiesCommand.description=View and edit properties for a given C/C++ breakpoint
|
||||
|
|
|
@ -435,7 +435,7 @@
|
|||
<action
|
||||
label="%EnableBreakpoint.label"
|
||||
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"
|
||||
id="org.eclipse.cdt.debug.internal.ui.actions.EnableDisableBreakpointRulerActionDelegate">
|
||||
</action>
|
||||
|
@ -444,14 +444,14 @@
|
|||
helpContextId="add_breakpoint_interactive_action_context"
|
||||
class="org.eclipse.cdt.debug.internal.ui.actions.breakpoints.CAddBreakpointInteractiveRulerActionDelegate"
|
||||
menubarPath="debug"
|
||||
id="org.eclipse.debug.ui.actions.RulerCreateBreakpointInteractiveAction">
|
||||
id="org.eclipse.cdt.debug.ui.actions.RulerCreateBreakpointInteractiveAction">
|
||||
</action>
|
||||
<action
|
||||
label="%AddBreakpoint.label"
|
||||
helpContextId="manage_breakpoint_action_context"
|
||||
class="org.eclipse.debug.ui.actions.RulerToggleBreakpointActionDelegate"
|
||||
class="org.eclipse.cdt.debug.internal.ui.actions.breakpoints.CRulerToggleBreakpointActionDelegate"
|
||||
menubarPath="debug"
|
||||
id="org.eclipse.debug.ui.actions.RulerToggleBreakpointAction">
|
||||
id="org.eclipse.cdt.debug.ui.actions.RulerToggleBreakpointAction">
|
||||
</action>
|
||||
</viewerContribution>
|
||||
<viewerContribution
|
||||
|
@ -508,28 +508,28 @@
|
|||
helpContextId="breakpoint_properties_action_context"
|
||||
class="org.eclipse.cdt.debug.internal.ui.actions.breakpoints.CBreakpointPropertiesRulerActionDelegate"
|
||||
menubarPath="debug"
|
||||
id="org.eclipse.cdt.debug.internal.ui.actions.CBreakpointPropertiesRulerActionDelegate">
|
||||
id="org.eclipse.cdt.debug.internal.ui.actions.asm.CBreakpointPropertiesRulerActionDelegate">
|
||||
</action>
|
||||
<action
|
||||
label="%EnableBreakpoint.label"
|
||||
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"
|
||||
id="org.eclipse.cdt.debug.internal.ui.actions.EnableDisableBreakpointRulerActionDelegate">
|
||||
id="org.eclipse.cdt.debug.internal.ui.actions.asm.EnableDisableBreakpointRulerActionDelegate">
|
||||
</action>
|
||||
<action
|
||||
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"
|
||||
menubarPath="debug"
|
||||
id="org.eclipse.debug.ui.actions.RulerCreateBreakpointInteractiveAction">
|
||||
id="org.eclipse.cdt.debug.ui.actions.asm.RulerCreateBreakpointInteractiveAction">
|
||||
</action>
|
||||
<action
|
||||
label="%AddBreakpoint.label"
|
||||
helpContextId="manage_breakpoint_action_context"
|
||||
class="org.eclipse.debug.ui.actions.RulerToggleBreakpointActionDelegate"
|
||||
class="org.eclipse.cdt.debug.internal.ui.actions.breakpoints.CRulerToggleBreakpointActionDelegate"
|
||||
menubarPath="debug"
|
||||
id="org.eclipse.debug.ui.actions.RulerToggleBreakpointAction">
|
||||
id="org.eclipse.cdt.debug.ui.actions.asm.RulerToggleBreakpointAction">
|
||||
</action>
|
||||
</viewerContribution>
|
||||
<viewerContribution
|
||||
|
|
|
@ -2,18 +2,26 @@
|
|||
<!-- Schema file written by PDE -->
|
||||
<schema targetNamespace="org.eclipse.cdt.debug.ui" xmlns="http://www.w3.org/2001/XMLSchema">
|
||||
<annotation>
|
||||
<appinfo>
|
||||
<appInfo>
|
||||
<meta.schema plugin="org.eclipse.cdt.debug.ui" id="breakpointContribution" name="Breakpoint UI Contribution"/>
|
||||
</appinfo>
|
||||
</appInfo>
|
||||
<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>
|
||||
</annotation>
|
||||
|
||||
<element name="extension">
|
||||
<annotation>
|
||||
<appInfo>
|
||||
<meta.element />
|
||||
</appInfo>
|
||||
</annotation>
|
||||
<complexType>
|
||||
<sequence minOccurs="1" maxOccurs="unbounded">
|
||||
<element ref="breakpointLabels"/>
|
||||
<element ref="breakpointLabels" minOccurs="0" maxOccurs="unbounded"/>
|
||||
<element ref="breakpointEditors" minOccurs="0" maxOccurs="unbounded"/>
|
||||
</sequence>
|
||||
<attribute name="point" type="string" use="required">
|
||||
<annotation>
|
||||
|
@ -34,15 +42,20 @@
|
|||
<documentation>
|
||||
|
||||
</documentation>
|
||||
<appinfo>
|
||||
<appInfo>
|
||||
<meta.attribute translatable="true"/>
|
||||
</appinfo>
|
||||
</appInfo>
|
||||
</annotation>
|
||||
</attribute>
|
||||
</complexType>
|
||||
</element>
|
||||
|
||||
<element name="breakpointLabels">
|
||||
<annotation>
|
||||
<documentation>
|
||||
A breakpoint label is appended to the top section the breakpoint properties common page.
|
||||
</documentation>
|
||||
</annotation>
|
||||
<complexType>
|
||||
<sequence minOccurs="0" maxOccurs="unbounded">
|
||||
<element ref="attribute"/>
|
||||
|
@ -50,28 +63,65 @@
|
|||
<attribute name="markerType" type="string">
|
||||
<annotation>
|
||||
<documentation>
|
||||
marker type for which attribute labels are applied
|
||||
Breakpoint's marker type for which the given attribute labels are applied.
|
||||
</documentation>
|
||||
<appinfo>
|
||||
<appInfo>
|
||||
<meta.attribute kind="identifier"/>
|
||||
</appinfo>
|
||||
</appInfo>
|
||||
</annotation>
|
||||
</attribute>
|
||||
<attribute name="debugModelId" type="string">
|
||||
<annotation>
|
||||
<documentation>
|
||||
debug model Id for this extension is valid
|
||||
(debugModelId is a property of cbreakpoint)
|
||||
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>
|
||||
<appInfo>
|
||||
<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>
|
||||
</attribute>
|
||||
</complexType>
|
||||
</element>
|
||||
|
||||
<element name="attribute">
|
||||
<annotation>
|
||||
<documentation>
|
||||
Each attribute entry displays or modifies a breakpoint attribute with the given ID.
|
||||
</documentation>
|
||||
</annotation>
|
||||
<complexType>
|
||||
<sequence minOccurs="0" maxOccurs="unbounded">
|
||||
<element ref="value"/>
|
||||
|
@ -88,28 +138,47 @@
|
|||
<documentation>
|
||||
user visible label for the breakpoint attribute value
|
||||
</documentation>
|
||||
<appinfo>
|
||||
<appInfo>
|
||||
<meta.attribute translatable="true"/>
|
||||
</appinfo>
|
||||
</appInfo>
|
||||
</annotation>
|
||||
</attribute>
|
||||
<attribute name="fieldEditor" type="string">
|
||||
<annotation>
|
||||
<documentation>
|
||||
field editor that will be shown to for given attribute.
|
||||
If not specified this attribute will not be visible in Common page.
|
||||
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.
|
||||
</documentation>
|
||||
<appinfo>
|
||||
<appInfo>
|
||||
<meta.attribute kind="java" basedOn="org.eclipse.jface.preference.FieldEditor:"/>
|
||||
</appinfo>
|
||||
</appInfo>
|
||||
</annotation>
|
||||
</attribute>
|
||||
<attribute name="type" type="string" use="default" value="string">
|
||||
<attribute name="type" use="default" value="string">
|
||||
<annotation>
|
||||
<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>
|
||||
</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>
|
||||
</complexType>
|
||||
</element>
|
||||
|
@ -117,8 +186,7 @@ If not specified this attribute will not be visible in Common page.
|
|||
<element name="value">
|
||||
<annotation>
|
||||
<documentation>
|
||||
Properties of value for parent attribute.
|
||||
If Value contains child attributes it means that these property only enabled when value of parent attribute equal to current element value
|
||||
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.
|
||||
</documentation>
|
||||
</annotation>
|
||||
<complexType>
|
||||
|
@ -137,27 +205,27 @@ If Value contains child attributes it means that these property only enabled whe
|
|||
<documentation>
|
||||
User visible label for the breakpoint attribute value
|
||||
</documentation>
|
||||
<appinfo>
|
||||
<appInfo>
|
||||
<meta.attribute translatable="true"/>
|
||||
</appinfo>
|
||||
</appInfo>
|
||||
</annotation>
|
||||
</attribute>
|
||||
</complexType>
|
||||
</element>
|
||||
|
||||
<annotation>
|
||||
<appinfo>
|
||||
<appInfo>
|
||||
<meta.section type="since"/>
|
||||
</appinfo>
|
||||
</appInfo>
|
||||
<documentation>
|
||||
CDT 5.0
|
||||
</documentation>
|
||||
</annotation>
|
||||
|
||||
<annotation>
|
||||
<appinfo>
|
||||
<appInfo>
|
||||
<meta.section type="examples"/>
|
||||
</appinfo>
|
||||
</appInfo>
|
||||
<documentation>
|
||||
<pre>
|
||||
<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_error_title=Error
|
||||
CAddBreakpointInteractiveRulerAction_error_message=Unable to create breakpoint
|
||||
CBreakpointToggleRulerAction_error_label=Toggle Brea&kpoint\tDouble Click
|
||||
CBreakpointToggleRulerAction_error_title=Error
|
||||
CBreakpointToggleRulerAction_error_message=Unable to toggle breakpoint
|
||||
CRulerToggleBreakpointActionDelegate_label=Toggle Brea&kpoint\tDouble Click
|
||||
|
|
|
@ -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.IAdaptable;
|
||||
import org.eclipse.debug.core.DebugPlugin;
|
||||
import org.eclipse.debug.core.model.IDebugModelProvider;
|
||||
import org.eclipse.debug.core.model.ILineBreakpoint;
|
||||
import org.eclipse.debug.ui.DebugUITools;
|
||||
import org.eclipse.debug.ui.contexts.IDebugContextProvider;
|
||||
|
@ -462,11 +463,12 @@ public class CBreakpointPropertyPage extends FieldEditorPreferencePage implement
|
|||
protected void createFieldEditors() {
|
||||
ICBreakpoint breakpoint = getBreakpoint();
|
||||
createMainLabel(breakpoint);
|
||||
createContributedFieldEditors(breakpoint);
|
||||
createContributedFieldEditors(breakpoint, ICBreakpointsUIContribution.BREAKPOINT_LABELS);
|
||||
createTypeSpecificLabelFieldEditors( breakpoint );
|
||||
createEnabledField( getFieldEditorParent() );
|
||||
createConditionEditor( getFieldEditorParent() );
|
||||
createIgnoreCountEditor( getFieldEditorParent() );
|
||||
createContributedFieldEditors(breakpoint, ICBreakpointsUIContribution.BREAKPOINT_EDITORS);
|
||||
}
|
||||
|
||||
private void createMainLabel(ICBreakpoint breakpoint) {
|
||||
|
@ -760,27 +762,35 @@ public class CBreakpointPropertyPage extends FieldEditorPreferencePage implement
|
|||
|
||||
/**
|
||||
* 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();
|
||||
String[] debugModelIds = CBreakpointUIContributionFactory.DEBUG_MODEL_IDS_DEFAULT;
|
||||
IDebugModelProvider debugModelProvider = (IDebugModelProvider)DebugPlugin.getAdapter(
|
||||
getDebugContext(), IDebugModelProvider.class);
|
||||
if (debugModelProvider != null) {
|
||||
debugModelIds = debugModelProvider.getModelIdentifiers();
|
||||
}
|
||||
|
||||
try {
|
||||
ICBreakpointsUIContribution[] cons;
|
||||
CBreakpointUIContributionFactory factory = CBreakpointUIContributionFactory.getInstance();
|
||||
IPreferenceStore prefStore = getPreferenceStore();
|
||||
if (prefStore instanceof CBreakpointPreferenceStore) {
|
||||
cons = factory.getBreakpointUIContributions(
|
||||
breakpoint, ((CBreakpointPreferenceStore) prefStore).getAttributes());
|
||||
debugModelIds, breakpoint, ((CBreakpointPreferenceStore) prefStore).getAttributes());
|
||||
} else {
|
||||
cons = factory.getBreakpointUIContributions(breakpoint);
|
||||
}
|
||||
|
||||
for (ICBreakpointsUIContribution con : cons) {
|
||||
if ( conMainElement.equals(con.getMainElement()) ) {
|
||||
FieldEditor fieldEditor = con.getFieldEditor(con.getId(), con.getLabel() + ":", parent); //$NON-NLS-1$
|
||||
if (fieldEditor != null) {
|
||||
addField(fieldEditor);
|
||||
}
|
||||
}
|
||||
}
|
||||
} catch (CoreException ce) {
|
||||
CDebugUIPlugin.log(ce);
|
||||
}
|
||||
|
|
|
@ -13,7 +13,9 @@
|
|||
package org.eclipse.cdt.debug.ui.breakpoints;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
import java.util.Collections;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
import org.eclipse.cdt.debug.core.CDIDebugModel;
|
||||
|
@ -31,7 +33,6 @@ import org.eclipse.debug.core.model.IBreakpoint;
|
|||
|
||||
public class CBreakpointUIContributionFactory {
|
||||
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;
|
||||
protected ArrayList<ICBreakpointsUIContribution> contributions;
|
||||
|
@ -70,22 +71,28 @@ public class CBreakpointUIContributionFactory {
|
|||
* @throws CoreException if cannot get marker attributes from bearkpoint
|
||||
* @since 7.2
|
||||
*/
|
||||
public ICBreakpointsUIContribution[] getBreakpointUIContributions(IBreakpoint breakpoint,
|
||||
Map<String, Object> attributes)
|
||||
throws CoreException
|
||||
public ICBreakpointsUIContribution[] getBreakpointUIContributions(String[] debugModelIDs, IBreakpoint breakpoint,
|
||||
Map<String, Object> attributes) throws CoreException
|
||||
{
|
||||
String debugModelId = breakpoint.getModelIdentifier();
|
||||
IMarker bmarker = breakpoint.getMarker();
|
||||
String markerType = CDIDebugModel.calculateMarkerType(breakpoint);
|
||||
if (bmarker != null) {
|
||||
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.
|
||||
*
|
||||
* @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 markerType Marker type of the breakpoint.
|
||||
* @param attributes Attributes of the breakpoint
|
||||
|
@ -96,10 +103,38 @@ public class CBreakpointUIContributionFactory {
|
|||
public ICBreakpointsUIContribution[] getBreakpointUIContributions(String debugModelId, String markerType,
|
||||
Map<String, Object> attributes)
|
||||
{
|
||||
return getBreakpointUIContributions(
|
||||
debugModelId != null ? new String[] { debugModelId } : DEBUG_MODEL_IDS_DEFAULT,
|
||||
markerType,
|
||||
attributes);
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* 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 (debugModelId == null || con.getDebugModelId() == null || debugModelId.equals(con.getDebugModelId())) {
|
||||
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)) {
|
||||
|
@ -115,6 +150,7 @@ public class CBreakpointUIContributionFactory {
|
|||
return list.toArray(new ICBreakpointsUIContribution[list.size()]);
|
||||
}
|
||||
|
||||
|
||||
public boolean isMarkerSubtypeOf(String currentType, String type) throws CoreException {
|
||||
return getWorkspace().getMarkerManager().isSubtype(currentType, type);
|
||||
}
|
||||
|
@ -132,7 +168,10 @@ public class CBreakpointUIContributionFactory {
|
|||
IConfigurationElement[] elements = ep.getConfigurationElements();
|
||||
for (int i = 0; i < elements.length; 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 markerType = getRequired(configurationElement, "markerType"); //$NON-NLS-1$
|
||||
if (markerType == null)
|
||||
|
@ -140,7 +179,8 @@ public class CBreakpointUIContributionFactory {
|
|||
IConfigurationElement[] children = configurationElement.getChildren("attribute"); //$NON-NLS-1$
|
||||
for (IConfigurationElement att : children) {
|
||||
|
||||
DefaultCBreakpointUIContribution adapter = new DefaultCBreakpointUIContribution();
|
||||
DefaultCBreakpointUIContribution adapter = new DefaultCBreakpointUIContribution(att);
|
||||
adapter.setMainElement(mainElement);
|
||||
adapter.setMarkerType(markerType);
|
||||
adapter.setDebugModelId(modelId);
|
||||
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 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 svisible = attrElement.getAttribute("visible"); //$NON-NLS-1$
|
||||
|
||||
|
@ -174,7 +217,8 @@ public class CBreakpointUIContributionFactory {
|
|||
}
|
||||
adapter.setId(attrId);
|
||||
adapter.setLabel(attrLabel);
|
||||
adapter.setControlClass(className);
|
||||
adapter.setControlClass(fieldEditorClass);
|
||||
adapter.setFieldEditorFactory(fieldEditorFactoryClass);
|
||||
adapter.setType(type);
|
||||
adapter.setVisible(visible);
|
||||
addContribution(adapter);
|
||||
|
@ -196,8 +240,9 @@ public class CBreakpointUIContributionFactory {
|
|||
adapter.addValue(valueId, valueLabel);
|
||||
IConfigurationElement[] children = valueElement.getChildren("attribute"); //$NON-NLS-1$
|
||||
for (IConfigurationElement att : children) {
|
||||
DefaultCBreakpointUIContribution adapter2 = new DefaultCBreakpointUIContribution();
|
||||
DefaultCBreakpointUIContribution adapter2 = new DefaultCBreakpointUIContribution(att);
|
||||
// inherit values
|
||||
adapter2.setMainElement(adapter.getMainElement());
|
||||
adapter2.setMarkerType(adapter.getMarkerType());
|
||||
adapter2.setDebugModelId(adapter.getDebugModelId());
|
||||
adapter2.addContionsAll(adapter.getConditions());
|
||||
|
|
|
@ -96,7 +96,7 @@ public class CEventBreakpointsLabelProviderFactory implements IAdapterFactory {
|
|||
if (ignoreCount > 0) {
|
||||
label.append(' ');
|
||||
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;
|
||||
}
|
||||
|
@ -106,7 +106,7 @@ public class CEventBreakpointsLabelProviderFactory implements IAdapterFactory {
|
|||
if (condition != null && condition.length() > 0) {
|
||||
buffer.append(' ');
|
||||
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.preferences.ReadOnlyFieldEditor;
|
||||
import org.eclipse.core.runtime.CoreException;
|
||||
import org.eclipse.core.runtime.IConfigurationElement;
|
||||
import org.eclipse.jface.preference.FieldEditor;
|
||||
import org.eclipse.swt.widgets.Composite;
|
||||
|
||||
class DefaultCBreakpointUIContribution implements ICBreakpointsUIContribution {
|
||||
|
||||
private final IConfigurationElement fConfig;
|
||||
private String mainElement;
|
||||
private String attLabel;
|
||||
private String attId;
|
||||
private String fieldEditorClassName;
|
||||
private String fieldEditorFactoryClass;
|
||||
private IFieldEditorFactory fieldEditorFactory;
|
||||
private String markerType;
|
||||
private String modelId;
|
||||
private String attType;
|
||||
private Map<String, String> valueLabels = new LinkedHashMap<String, String>();
|
||||
private Map<String, String> conditions = new HashMap<String, String>();
|
||||
|
||||
DefaultCBreakpointUIContribution(IConfigurationElement config) {
|
||||
fConfig = config;
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public String getId() {
|
||||
return attId;
|
||||
|
@ -48,28 +60,43 @@ class DefaultCBreakpointUIContribution implements ICBreakpointsUIContribution {
|
|||
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 };
|
||||
|
||||
@Override
|
||||
public FieldEditor getFieldEditor(String name, String labelText, Composite parent) {
|
||||
String className = fieldEditorClassName;
|
||||
if (fieldEditorClassName == null) {
|
||||
className = ReadOnlyFieldEditor.class.getName();
|
||||
}
|
||||
if (fieldEditorFactory != null) {
|
||||
return fieldEditorFactory.createFieldEditor(name, labelText, parent);
|
||||
} else if (fieldEditorFactoryClass != null) {
|
||||
try {
|
||||
Class cclass = Class.forName(className);
|
||||
Constructor constructor = cclass.getConstructor(fieldSignature);
|
||||
FieldEditor editor = (FieldEditor) constructor.newInstance(name, labelText, parent);
|
||||
fieldEditorFactory = (IFieldEditorFactory) fConfig.createExecutableExtension("fieldEditorFactory"); //$NON-NLS-1$
|
||||
} catch (CoreException e) {
|
||||
CDebugUIPlugin.log(e);
|
||||
return null;
|
||||
}
|
||||
return fieldEditorFactory.createFieldEditor(name, labelText, parent);
|
||||
} else if (fieldEditorClassName != null) {
|
||||
try {
|
||||
@SuppressWarnings("unchecked")
|
||||
Class<FieldEditor> cclass = (Class<FieldEditor>)Class.forName(fieldEditorClassName);
|
||||
Constructor<FieldEditor> constructor = cclass.getConstructor(fieldSignature);
|
||||
FieldEditor editor = constructor.newInstance(name, labelText, parent);
|
||||
if (editor instanceof ICBreakpointsUIContributionUser) {
|
||||
((ICBreakpointsUIContributionUser)editor).setContribution(this);
|
||||
}
|
||||
return editor;
|
||||
} catch (Exception e) {
|
||||
// cannot happened, would have happened when loading extension
|
||||
CDebugUIPlugin.log(e);
|
||||
return null;
|
||||
}
|
||||
} else {
|
||||
return new ReadOnlyFieldEditor(name, labelText, parent);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -96,7 +123,7 @@ class DefaultCBreakpointUIContribution implements ICBreakpointsUIContribution {
|
|||
}
|
||||
|
||||
@Override
|
||||
public boolean isApplicable(Map properties) {
|
||||
public boolean isApplicable(Map<String, Object> properties) {
|
||||
for (Object key : properties.keySet()) {
|
||||
String value = conditions.get(key);
|
||||
if (value != null) {
|
||||
|
@ -109,6 +136,10 @@ class DefaultCBreakpointUIContribution implements ICBreakpointsUIContribution {
|
|||
return true;
|
||||
}
|
||||
|
||||
public void setMainElement(String mainElement) {
|
||||
this.mainElement = mainElement;
|
||||
}
|
||||
|
||||
public void setLabel(String attLabel) {
|
||||
this.attLabel = attLabel;
|
||||
}
|
||||
|
@ -121,6 +152,10 @@ class DefaultCBreakpointUIContribution implements ICBreakpointsUIContribution {
|
|||
this.fieldEditorClassName = controlClass;
|
||||
}
|
||||
|
||||
public void setFieldEditorFactory(String factoryClass) {
|
||||
fieldEditorFactoryClass = factoryClass;
|
||||
}
|
||||
|
||||
public void setMarkerType(String markerId) {
|
||||
this.markerType = markerId;
|
||||
}
|
||||
|
|
|
@ -19,13 +19,33 @@ import org.eclipse.jface.preference.FieldEditor;
|
|||
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 {
|
||||
|
||||
/**
|
||||
* 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
|
||||
* @return
|
||||
*/
|
||||
public String getId();
|
||||
|
||||
/**
|
||||
* Extenralizable label for this attribute id
|
||||
* @return
|
||||
|
@ -41,6 +61,14 @@ public interface ICBreakpointsUIContribution {
|
|||
*/
|
||||
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
|
||||
* @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.Text;
|
||||
|
||||
|
||||
/**
|
||||
* A launch configuration tab that displays and edits program arguments,
|
||||
* and working directory launch configuration attributes.
|
||||
|
@ -47,7 +46,6 @@ import org.eclipse.swt.widgets.Text;
|
|||
* </p>
|
||||
*/
|
||||
public class CArgumentsTab extends CLaunchConfigurationTab {
|
||||
|
||||
/**
|
||||
* Tab identifier used for ordering of tabs added using the
|
||||
* <code>org.eclipse.debug.ui.launchConfigurationTabs</code>
|
||||
|
@ -65,9 +63,6 @@ public class CArgumentsTab extends CLaunchConfigurationTab {
|
|||
// Working directory
|
||||
protected WorkingDirectoryBlock fWorkingDirectoryBlock = new WorkingDirectoryBlock();
|
||||
|
||||
/* (non-Javadoc)
|
||||
* @see org.eclipse.debug.ui.ILaunchConfigurationTab#createControl(org.eclipse.swt.widgets.Composite)
|
||||
*/
|
||||
@Override
|
||||
public void createControl(Composite parent) {
|
||||
Font font = parent.getFont();
|
||||
|
@ -104,8 +99,7 @@ public class CArgumentsTab extends CLaunchConfigurationTab {
|
|||
public void getName(AccessibleEvent e) {
|
||||
e.result = LaunchMessages.getString("CArgumentsTab.C/C++_Program_Arguments"); //$NON-NLS-1$
|
||||
}
|
||||
}
|
||||
);
|
||||
});
|
||||
gd = new GridData(GridData.FILL_BOTH);
|
||||
gd.heightHint = 40;
|
||||
gd.widthHint = 100;
|
||||
|
@ -121,15 +115,10 @@ public class CArgumentsTab extends CLaunchConfigurationTab {
|
|||
gd = new GridData(GridData.HORIZONTAL_ALIGN_END);
|
||||
fArgumentVariablesButton.setLayoutData(gd);
|
||||
fArgumentVariablesButton.addSelectionListener(new SelectionAdapter() {
|
||||
|
||||
/* (non-Javadoc)
|
||||
* @see org.eclipse.swt.events.SelectionAdapter#widgetSelected(org.eclipse.swt.events.SelectionEvent)
|
||||
*/
|
||||
@Override
|
||||
public void widgetSelected(SelectionEvent arg0) {
|
||||
handleVariablesButtonSelected(fPrgmArgumentsText);
|
||||
}
|
||||
|
||||
});
|
||||
addControlAccessibleListener(fArgumentVariablesButton, fArgumentVariablesButton.getText()); // need to strip the mnemonic from buttons
|
||||
}
|
||||
|
@ -142,7 +131,6 @@ public class CArgumentsTab extends CLaunchConfigurationTab {
|
|||
protected void handleVariablesButtonSelected(Text textField) {
|
||||
String variable = getVariable();
|
||||
if (variable != null) {
|
||||
// We should use insert() but not append() to be consistent with the Platform behavior (e.g. Common tab)
|
||||
textField.insert(variable);
|
||||
}
|
||||
}
|
||||
|
@ -158,7 +146,7 @@ public class CArgumentsTab extends CLaunchConfigurationTab {
|
|||
}
|
||||
|
||||
public void addControlAccessibleListener(Control control, String controlName) {
|
||||
//strip mnemonic (&)
|
||||
// Strip mnemonic (&)
|
||||
String[] strs = controlName.split("&"); //$NON-NLS-1$
|
||||
StringBuffer stripped = new StringBuffer();
|
||||
for (int i = 0; i < strs.length; i++) {
|
||||
|
@ -169,36 +157,28 @@ public class CArgumentsTab extends CLaunchConfigurationTab {
|
|||
|
||||
private class ControlAccessibleListener extends AccessibleAdapter {
|
||||
private String controlName;
|
||||
|
||||
ControlAccessibleListener(String name) {
|
||||
controlName = name;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void getName(AccessibleEvent e) {
|
||||
e.result = controlName;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
/* (non-Javadoc)
|
||||
* @see org.eclipse.debug.ui.ILaunchConfigurationTab#isValid(org.eclipse.debug.core.ILaunchConfiguration)
|
||||
*/
|
||||
@Override
|
||||
public boolean isValid(ILaunchConfiguration config) {
|
||||
return fWorkingDirectoryBlock.isValid(config);
|
||||
}
|
||||
|
||||
/* (non-Javadoc)
|
||||
* @see org.eclipse.debug.ui.ILaunchConfigurationTab#setDefaults(org.eclipse.debug.core.ILaunchConfigurationWorkingCopy)
|
||||
*/
|
||||
@Override
|
||||
public void setDefaults(ILaunchConfigurationWorkingCopy config) {
|
||||
config.setAttribute(ICDTLaunchConfigurationConstants.ATTR_PROGRAM_ARGUMENTS, (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
|
||||
public void initializeFrom(ILaunchConfiguration configuration) {
|
||||
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
|
||||
public void performApply(ILaunchConfigurationWorkingCopy configuration) {
|
||||
configuration.setAttribute(
|
||||
|
@ -242,26 +219,17 @@ public class CArgumentsTab extends CLaunchConfigurationTab {
|
|||
return TAB_ID;
|
||||
}
|
||||
|
||||
/* (non-Javadoc)
|
||||
* @see org.eclipse.debug.ui.ILaunchConfigurationTab#getName()
|
||||
*/
|
||||
@Override
|
||||
public String getName() {
|
||||
return LaunchMessages.getString("CArgumentsTab.Arguments"); //$NON-NLS-1$
|
||||
}
|
||||
|
||||
/* (non-Javadoc)
|
||||
* @see org.eclipse.debug.ui.ILaunchConfigurationTab#setLaunchConfigurationDialog(org.eclipse.debug.ui.ILaunchConfigurationDialog)
|
||||
*/
|
||||
@Override
|
||||
public void setLaunchConfigurationDialog(ILaunchConfigurationDialog dialog) {
|
||||
super.setLaunchConfigurationDialog(dialog);
|
||||
fWorkingDirectoryBlock.setLaunchConfigurationDialog(dialog);
|
||||
}
|
||||
|
||||
/* (non-Javadoc)
|
||||
* @see org.eclipse.debug.ui.ILaunchConfigurationTab#getErrorMessage()
|
||||
*/
|
||||
@Override
|
||||
public String getErrorMessage() {
|
||||
String m = super.getErrorMessage();
|
||||
|
@ -271,9 +239,6 @@ public class CArgumentsTab extends CLaunchConfigurationTab {
|
|||
return m;
|
||||
}
|
||||
|
||||
/* (non-Javadoc)
|
||||
* @see org.eclipse.debug.ui.ILaunchConfigurationTab#getMessage()
|
||||
*/
|
||||
@Override
|
||||
public String getMessage() {
|
||||
String m = super.getMessage();
|
||||
|
@ -283,17 +248,11 @@ public class CArgumentsTab extends CLaunchConfigurationTab {
|
|||
return m;
|
||||
}
|
||||
|
||||
/* (non-Javadoc)
|
||||
* @see org.eclipse.debug.ui.ILaunchConfigurationTab#getImage()
|
||||
*/
|
||||
@Override
|
||||
public Image getImage() {
|
||||
return LaunchImages.get(LaunchImages.IMG_VIEW_ARGUMENTS_TAB);
|
||||
}
|
||||
|
||||
/* (non-Javadoc)
|
||||
* @see org.eclipse.debug.ui.AbstractLaunchConfigurationTab#updateLaunchConfigurationDialog()
|
||||
*/
|
||||
@Override
|
||||
protected void updateLaunchConfigurationDialog() {
|
||||
super.updateLaunchConfigurationDialog();
|
||||
|
|
|
@ -38,7 +38,6 @@ import org.eclipse.ui.IFileEditorInput;
|
|||
import org.eclipse.ui.IWorkbenchPage;
|
||||
|
||||
public abstract class CLaunchConfigurationTab extends AbstractLaunchConfigurationTab {
|
||||
|
||||
/**
|
||||
* Returns the current C element context from which to initialize default
|
||||
* settings, or <code>null</code> if none. Note, if possible we will
|
||||
|
@ -60,6 +59,7 @@ public abstract class CLaunchConfigurationTab extends AbstractLaunchConfiguratio
|
|||
}
|
||||
} catch (CoreException e) {
|
||||
}
|
||||
|
||||
if (projectName != null && !projectName.equals("")) { //$NON-NLS-1$
|
||||
IProject project = ResourcesPlugin.getWorkspace().getRoot().getProject(projectName);
|
||||
ICProject cProject = CCorePlugin.getDefault().getCoreModel().create(project);
|
||||
|
@ -115,15 +115,13 @@ public abstract class CLaunchConfigurationTab extends AbstractLaunchConfiguratio
|
|||
return (ICElement)obj;
|
||||
}
|
||||
}
|
||||
if (page != null)
|
||||
{
|
||||
if (page != null) {
|
||||
IEditorPart part = page.getActiveEditor();
|
||||
if (part != null) {
|
||||
IEditorInput input = part.getEditorInput();
|
||||
if (input instanceof IFileEditorInput) {
|
||||
IFile file = ((IFileEditorInput)input).getFile();
|
||||
if (file != null)
|
||||
{
|
||||
if (file != null) {
|
||||
ICElement ce = CoreModel.getDefault().create(file);
|
||||
if (ce == null) {
|
||||
IProject pro = file.getProject();
|
||||
|
@ -150,10 +148,8 @@ public abstract class CLaunchConfigurationTab extends AbstractLaunchConfiguratio
|
|||
ICProjectDescription projDes = CCorePlugin.getDefault().getProjectDescription(cProject.getProject());
|
||||
String buildConfigID = projDes.getActiveConfiguration().getId();
|
||||
config.setAttribute(ICDTLaunchConfigurationConstants.ATTR_PROJECT_BUILD_CONFIG_ID, buildConfigID);
|
||||
|
||||
}
|
||||
config.setAttribute(ICDTLaunchConfigurationConstants.ATTR_PROJECT_NAME, name);
|
||||
|
||||
}
|
||||
|
||||
protected String getPlatform(ILaunchConfiguration config) {
|
||||
|
|
|
@ -16,7 +16,8 @@ Require-Bundle: org.eclipse.core.runtime,
|
|||
org.eclipse.ui.ide,
|
||||
org.eclipse.cdt.examples.dsf.pda,
|
||||
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
|
||||
Export-Package: org.eclipse.cdt.examples.dsf.pda.ui,
|
||||
org.eclipse.cdt.examples.dsf.pda.ui.breakpoints,
|
||||
|
|
|
@ -110,5 +110,18 @@
|
|||
class="org.eclipse.cdt.examples.dsf.pda.ui.viewmodel.VariablePersistableFactory"
|
||||
id="org.eclipse.cdt.examples.dsf.pda.ui.variablePersitableFactory">
|
||||
</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> -->
|
||||
</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 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.debug.service.BreakpointsMediator;
|
||||
import org.eclipse.cdt.dsf.debug.service.BreakpointsMediator2;
|
||||
|
@ -59,6 +60,11 @@ public class PDABreakpointAttributeTranslator implements IBreakpointAttributeTra
|
|||
PDAWatchpoint.MODIFICATION
|
||||
};
|
||||
|
||||
private static final String[] fgCDTWatchpointAttributes = {
|
||||
IBreakpoint.ENABLED,
|
||||
PDAWatchpoint.FUNCTION_NAME,
|
||||
};
|
||||
|
||||
// PDA breakpoints translator doesn't keep any state and it doesn't
|
||||
// need to initialize or clean up.
|
||||
public void initialize(BreakpointsMediator2 mediator) {
|
||||
|
@ -73,6 +79,8 @@ public class PDABreakpointAttributeTranslator implements IBreakpointAttributeTra
|
|||
{
|
||||
if (bp instanceof ICLineBreakpoint) {
|
||||
return getCBreakpointAttributes((ICLineBreakpoint)bp, bpManagerEnabled);
|
||||
} else if (bp instanceof ICWatchpoint) {
|
||||
return getCWatchpointAttributes((ICWatchpoint)bp, bpManagerEnabled);
|
||||
} else {
|
||||
return getPDABreakpointAttributes(bp, bpManagerEnabled);
|
||||
}
|
||||
|
@ -113,6 +121,44 @@ public class PDABreakpointAttributeTranslator implements IBreakpointAttributeTra
|
|||
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)
|
||||
throws CoreException
|
||||
{
|
||||
|
@ -178,7 +224,7 @@ public class PDABreakpointAttributeTranslator implements IBreakpointAttributeTra
|
|||
|
||||
public boolean supportsBreakpoint(IBreakpoint bp) {
|
||||
return bp.getModelIdentifier().equals(PDAPlugin.ID_PDA_DEBUG_MODEL) ||
|
||||
bp instanceof ICLineBreakpoint;
|
||||
bp instanceof ICLineBreakpoint || bp instanceof ICWatchpoint;
|
||||
}
|
||||
|
||||
public void updateBreakpointsStatus(
|
||||
|
|
|
@ -2,7 +2,7 @@ Manifest-Version: 1.0
|
|||
Bundle-ManifestVersion: 2
|
||||
Bundle-Name: %pluginName
|
||||
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-Vendor: %providerName
|
||||
Bundle-Localization: plugin
|
||||
|
|
|
@ -11,7 +11,7 @@
|
|||
<relativePath>../../pom.xml</relativePath>
|
||||
</parent>
|
||||
|
||||
<version>7.0.0-SNAPSHOT</version>
|
||||
<version>7.1.0-SNAPSHOT</version>
|
||||
<artifactId>org.eclipse.cdt.launch</artifactId>
|
||||
<packaging>eclipse-plugin</packaging>
|
||||
</project>
|
||||
|
|
|
@ -8,7 +8,6 @@
|
|||
* Contributors:
|
||||
* QNX Software Systems - Initial API and implementation
|
||||
* Ken Ryall (Nokia) - bug 178731
|
||||
* Anton Gorenkov
|
||||
*******************************************************************************/
|
||||
package org.eclipse.cdt.launch.ui;
|
||||
|
||||
|
@ -45,7 +44,6 @@ import org.eclipse.ui.IFileEditorInput;
|
|||
import org.eclipse.ui.IWorkbenchPage;
|
||||
|
||||
public abstract class CLaunchConfigurationTab extends AbstractLaunchConfigurationTab {
|
||||
|
||||
/**
|
||||
* Returns the current C element context from which to initialize default
|
||||
* settings, or <code>null</code> if none. Note, if possible we will
|
||||
|
@ -122,8 +120,7 @@ public abstract class CLaunchConfigurationTab extends AbstractLaunchConfiguratio
|
|||
return (ICElement) obj;
|
||||
}
|
||||
}
|
||||
if (page != null)
|
||||
{
|
||||
if (page != null) {
|
||||
IEditorPart part = page.getActiveEditor();
|
||||
if (part != null) {
|
||||
IEditorInput input = part.getEditorInput();
|
||||
|
@ -160,7 +157,6 @@ public abstract class CLaunchConfigurationTab extends AbstractLaunchConfiguratio
|
|||
|
||||
}
|
||||
config.setAttribute(ICDTLaunchConfigurationConstants.ATTR_PROJECT_NAME, name);
|
||||
|
||||
}
|
||||
|
||||
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.
|
||||
*
|
||||
* @since 7.0
|
||||
* @since 7.1
|
||||
*/
|
||||
protected Button createVariablesButton(Composite parent, String label, final Text textField) {
|
||||
Button variablesButton = createPushButton(parent, label, null);
|
||||
|
@ -196,7 +192,6 @@ public abstract class CLaunchConfigurationTab extends AbstractLaunchConfiguratio
|
|||
private void handleVariablesButtonSelected(Text textField) {
|
||||
String variable = getVariable();
|
||||
if (variable != null) {
|
||||
// We should use insert() but not append() to be consistent with the Platform behavior (e.g. Common tab)
|
||||
textField.insert(variable);
|
||||
}
|
||||
}
|
||||
|
@ -210,5 +205,4 @@ public abstract class CLaunchConfigurationTab extends AbstractLaunchConfiguratio
|
|||
dialog.open();
|
||||
return dialog.getVariableExpression();
|
||||
}
|
||||
|
||||
}
|
||||
|
|
Loading…
Add table
Reference in a new issue