~ubuntu-branches/debian/sid/eclipse-cdt/sid

« back to all changes in this revision

Viewing changes to results/plugins/org.eclipse.cdt.ui.tests/ui/org/eclipse/cdt/ui/tests/refactoring/rename/RenameFunctionTests.java

  • Committer: Package Import Robot
  • Author(s): Jakub Adam
  • Date: 2011-10-06 21:15:04 UTC
  • mfrom: (1.1.4)
  • Revision ID: package-import@ubuntu.com-20111006211504-8dutmljjih0zikfv
Tags: 8.0.1-1
* New upstream release.
* Split the JNI packages into a separate architecture dependent
  package and made eclipse-cdt architecture independent.
* Install JNI libraries into multiarch aware location
* Bumped Standards-Version to 3.9.2.

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
/*******************************************************************************
2
 
 * Copyright (c) 2005, 2009 Wind River Systems, Inc.
3
 
 * All rights reserved. This program and the accompanying materials
4
 
 * are made available under the terms of the Eclipse Public License v1.0
5
 
 * which accompanies this distribution, and is available at
6
 
 * http://www.eclipse.org/legal/epl-v10.html
7
 
 *
8
 
 * Contributors:
9
 
 *    Markus Schorn - initial API and implementation 
10
 
 *******************************************************************************/
11
 
package org.eclipse.cdt.ui.tests.refactoring.rename;
12
 
 
13
 
import java.io.StringWriter;
14
 
 
15
 
import junit.framework.Test;
16
 
import junit.framework.TestSuite;
17
 
 
18
 
import org.eclipse.core.resources.IFile;
19
 
import org.eclipse.ltk.core.refactoring.Change;
20
 
import org.eclipse.ltk.core.refactoring.RefactoringStatus;
21
 
 
22
 
public class RenameFunctionTests extends RenameTests {
23
 
 
24
 
    public RenameFunctionTests(String name) {
25
 
        super(name);
26
 
    }
27
 
    public static Test suite(){
28
 
        return suite(true);
29
 
    }
30
 
    public static Test suite( boolean cleanup ) {
31
 
        TestSuite suite = new TestSuite(RenameFunctionTests.class); 
32
 
 
33
 
        if (cleanup) {
34
 
            suite.addTest( new RefactoringTests("cleanupProject") );    //$NON-NLS-1$
35
 
        }
36
 
        return suite;
37
 
    }
38
 
    
39
 
    public void testFunctionNameConflicts() throws Exception {
40
 
        createCppFwdDecls("cpp_fwd.hh"); //$NON-NLS-1$
41
 
        createCppDefs("cpp_def.hh"); //$NON-NLS-1$
42
 
        StringWriter writer = new StringWriter();
43
 
        writer.write("#include \"cpp_fwd.hh\"   \n"); //$NON-NLS-1$
44
 
        writer.write("#include \"cpp_def.hh\"   \n"); //$NON-NLS-1$
45
 
        writer.write("int v1(); int v2(); int v3();  \n"); //$NON-NLS-1$
46
 
        writer.write("static int s1();          \n"); //$NON-NLS-1$
47
 
        writer.write("static int s2();          \n"); //$NON-NLS-1$
48
 
        writer.write("void f(int par1){         \n"); //$NON-NLS-1$
49
 
        writer.write("  {                       \n"); //$NON-NLS-1$
50
 
        writer.write("     int w1; v1();        \n"); //$NON-NLS-1$
51
 
        writer.write("  }                       \n"); //$NON-NLS-1$
52
 
        writer.write("}                         \n"); //$NON-NLS-1$
53
 
        writer.write("void class_def::method(int par2) { \n"); //$NON-NLS-1$
54
 
        writer.write("  {                        \n"); //$NON-NLS-1$
55
 
        writer.write("     int w2; v2();         \n"); //$NON-NLS-1$
56
 
        writer.write("  }                        \n"); //$NON-NLS-1$
57
 
        writer.write("}                          \n"); //$NON-NLS-1$
58
 
        writer.write("static void class_def::static_method(int par3) { \n"); //$NON-NLS-1$
59
 
        writer.write("  {                        \n"); //$NON-NLS-1$
60
 
        writer.write("     int w3; v3();         \n"); //$NON-NLS-1$
61
 
        writer.write("  }                        \n"); //$NON-NLS-1$
62
 
        writer.write("}                          \n"); //$NON-NLS-1$
63
 
        String contents = writer.toString();
64
 
        IFile cpp= importFile("test.cpp", contents ); //$NON-NLS-1$
65
 
        
66
 
        writer = new StringWriter();
67
 
        writer.write( "static int static_other_file();     \n" ); //$NON-NLS-1$        
68
 
        importFile( "other.cpp", writer.toString() ); //$NON-NLS-1$
69
 
 
70
 
 
71
 
        int offset1= contents.indexOf("v1"); //$NON-NLS-1$
72
 
        int offset2= contents.indexOf("v2"); //$NON-NLS-1$
73
 
        int offset3= contents.indexOf("v3"); //$NON-NLS-1$
74
 
        
75
 
        // conflicting renamings
76
 
        RefactoringStatus status= checkConditions(cpp, offset1, "w1");  //$NON-NLS-1$
77
 
        assertRefactoringError(status, "A conflict was encountered during refactoring.  \n" +
78
 
                        "Type of problem: Shadowing  \n" +
79
 
                        "New element: w1  \n" +
80
 
                        "Conflicting element type: Local variable"); //$NON-NLS-1$
81
 
        status= checkConditions(cpp, contents.indexOf("par1"), "v1");  //$NON-NLS-1$ //$NON-NLS-2$
82
 
        assertRefactoringError(status, "A conflict was encountered during refactoring.  \n" +
83
 
                        "Type of problem: Shadowing  \n" +
84
 
                        "New element: v1  \n" +
85
 
                        "Conflicting element type: Global function"); //$NON-NLS-1$
86
 
        status= checkConditions(cpp, offset1, "par1");  //$NON-NLS-1$
87
 
        assertRefactoringError(status, "A conflict was encountered during refactoring.  \n" +
88
 
                        "Type of problem: Shadowing  \n" +
89
 
                        "New element: par1  \n" +
90
 
                        "Conflicting element type: Parameter"); //$NON-NLS-1$
91
 
        status= checkConditions(cpp, offset1, "extern_var");  //$NON-NLS-1$
92
 
        assertRefactoringError(status, "A conflict was encountered during refactoring.  \n" +
93
 
                        "Type of problem: Redeclaration  \n" +
94
 
                        "New element: extern_var  \n" +
95
 
                        "Conflicting element type: Global variable"); //$NON-NLS-1$
96
 
        status= checkConditions(cpp, offset1, "var_def");  //$NON-NLS-1$
97
 
        assertRefactoringError(status, "A conflict was encountered during refactoring.  \n" +
98
 
                        "Type of problem: Redeclaration  \n" +
99
 
                        "New element: var_def  \n" +
100
 
                        "Conflicting element type: Global variable"); //$NON-NLS-1$
101
 
        status= checkConditions(cpp, offset1, "enum_item");  //$NON-NLS-1$
102
 
        assertRefactoringError(status, "A conflict was encountered during refactoring.  \n" +
103
 
                        "Type of problem: Redeclaration  \n" +
104
 
                        "New element: enum_item  \n" +
105
 
                        "Conflicting element type: Enumerator"); //$NON-NLS-1$
106
 
 
107
 
        status= checkConditions(cpp, offset2, "w2");  //$NON-NLS-1$
108
 
        assertRefactoringError(status, "A conflict was encountered during refactoring.  \n" +
109
 
                        "Type of problem: Shadowing  \n" +
110
 
                        "New element: w2  \n" +
111
 
                        "Conflicting element type: Local variable"); //$NON-NLS-1$
112
 
        status= checkConditions(cpp, offset2, "par2");  //$NON-NLS-1$
113
 
        assertRefactoringError(status, "A conflict was encountered during refactoring.  \n" +
114
 
                        "Type of problem: Shadowing  \n" +
115
 
                        "New element: par2  \n" +
116
 
                        "Conflicting element type: Parameter"); //$NON-NLS-1$
117
 
        status= checkConditions(cpp, offset2, "extern_var");  //$NON-NLS-1$
118
 
        assertRefactoringError(status, "A conflict was encountered during refactoring.  \n" +
119
 
                        "Type of problem: Redeclaration  \n" +
120
 
                        "New element: extern_var  \n" +
121
 
                        "Conflicting element type: Global variable"); //$NON-NLS-1$
122
 
        status= checkConditions(cpp, offset2, "var_def");  //$NON-NLS-1$
123
 
        assertRefactoringError(status, "A conflict was encountered during refactoring.  \n" +
124
 
                        "Type of problem: Redeclaration  \n" +
125
 
                        "New element: var_def  \n" +
126
 
                        "Conflicting element type: Global variable"); //$NON-NLS-1$
127
 
        status= checkConditions(cpp, offset2, "enum_item");  //$NON-NLS-1$
128
 
        assertRefactoringError(status, "A conflict was encountered during refactoring.  \n" +
129
 
                        "Type of problem: Redeclaration  \n" +
130
 
                        "New element: enum_item  \n" +
131
 
                        "Conflicting element type: Enumerator"); //$NON-NLS-1$
132
 
 
133
 
        status= checkConditions(cpp, offset3, "w3");  //$NON-NLS-1$
134
 
        assertRefactoringError(status, "A conflict was encountered during refactoring.  \n" +
135
 
                        "Type of problem: Shadowing  \n" +
136
 
                        "New element: w3  \n" +
137
 
                        "Conflicting element type: Local variable"); //$NON-NLS-1$
138
 
        status= checkConditions(cpp, offset3, "par3");  //$NON-NLS-1$
139
 
        assertRefactoringError(status, "A conflict was encountered during refactoring.  \n" +
140
 
                        "Type of problem: Shadowing  \n" +
141
 
                        "New element: par3  \n" +
142
 
                        "Conflicting element type: Parameter"); //$NON-NLS-1$
143
 
        status= checkConditions(cpp, offset3, "extern_var");  //$NON-NLS-1$
144
 
        assertRefactoringError(status, "A conflict was encountered during refactoring.  \n" +
145
 
                        "Type of problem: Redeclaration  \n" +
146
 
                        "New element: extern_var  \n" +
147
 
                        "Conflicting element type: Global variable"); //$NON-NLS-1$
148
 
        status= checkConditions(cpp, offset3, "var_def");  //$NON-NLS-1$
149
 
        assertRefactoringError(status, "A conflict was encountered during refactoring.  \n" +
150
 
                        "Type of problem: Redeclaration  \n" +
151
 
                        "New element: var_def  \n" +
152
 
                        "Conflicting element type: Global variable"); //$NON-NLS-1$
153
 
        status= checkConditions(cpp, offset3, "enum_item");  //$NON-NLS-1$
154
 
        assertRefactoringError(status, "A conflict was encountered during refactoring.  \n" +
155
 
                        "Type of problem: Redeclaration  \n" +
156
 
                        "New element: enum_item  \n" +
157
 
                        "Conflicting element type: Enumerator"); //$NON-NLS-1$
158
 
 
159
 
        // renamings depending on scope
160
 
        status= checkConditions(cpp, offset1, "member");  //$NON-NLS-1$
161
 
        assertRefactoringOk(status);
162
 
        status= checkConditions(cpp, offset1, "method");  //$NON-NLS-1$
163
 
        assertRefactoringOk(status);
164
 
        status= checkConditions(cpp, offset1, "static_member");  //$NON-NLS-1$
165
 
        assertRefactoringOk(status);
166
 
        status= checkConditions(cpp, offset1, "static_method");  //$NON-NLS-1$
167
 
        assertRefactoringOk(status);
168
 
        status= checkConditions(cpp, offset2, "member");  //$NON-NLS-1$
169
 
        assertRefactoringError(status, "A conflict was encountered during refactoring.  \n" +
170
 
                        "Type of problem: Shadowing  \n" +
171
 
                        "New element: member  \n" +
172
 
                        "Conflicting element type: Field"); //$NON-NLS-1$
173
 
        status= checkConditions(cpp, offset2, "method");  //$NON-NLS-1$
174
 
        assertRefactoringError(status, "A conflict was encountered during refactoring.  \n" +
175
 
                        "Type of problem: Shadowing  \n" +
176
 
                        "New element: method  \n" +
177
 
                        "Conflicting element type: Method"); //$NON-NLS-1$
178
 
        status= checkConditions(cpp, offset2, "static_member");  //$NON-NLS-1$
179
 
        assertRefactoringError(status, "A conflict was encountered during refactoring.  \n" +
180
 
                        "Type of problem: Shadowing  \n" +
181
 
                        "New element: static_member  \n" +
182
 
                        "Conflicting element type: Field"); //$NON-NLS-1$
183
 
        status= checkConditions(cpp, offset2, "static_method");  //$NON-NLS-1$
184
 
        assertRefactoringError(status, "A conflict was encountered during refactoring.  \n" +
185
 
                        "Type of problem: Shadowing  \n" +
186
 
                        "New element: static_method  \n" +
187
 
                        "Conflicting element type: Method"); //$NON-NLS-1$
188
 
//        lookup inside a static method also returns non-static members
189
 
//        we may want to have a check whether a binding is accessible or not.
190
 
        
191
 
//        status= checkConditions(cpp, offset3, "member");  //$NON-NLS-1$
192
 
//        assertRefactoringOk(status);
193
 
//        status= checkConditions(cpp, offset3, "method");  //$NON-NLS-1$
194
 
//        assertRefactoringOk(status);
195
 
        status= checkConditions(cpp, offset3, "static_member");  //$NON-NLS-1$
196
 
        assertRefactoringError(status, "A conflict was encountered during refactoring.  \n" +
197
 
                        "Type of problem: Shadowing  \n" +
198
 
                        "New element: static_member  \n" +
199
 
                        "Conflicting element type: Field"); //$NON-NLS-1$
200
 
        status= checkConditions(cpp, offset3, "static_method");  //$NON-NLS-1$
201
 
        assertRefactoringError(status, "A conflict was encountered during refactoring.  \n" +
202
 
                        "Type of problem: Shadowing  \n" +
203
 
                        "New element: static_method  \n" +
204
 
                        "Conflicting element type: Method"); //$NON-NLS-1$
205
 
 
206
 
        // renamings conflicting with global stuff.
207
 
        status= checkConditions(cpp, offset1, "func_proto");  //$NON-NLS-1$
208
 
        assertRefactoringError(status, "A conflict was encountered during refactoring.  \n" +
209
 
                        "Type of problem: Redeclaration  \n" +
210
 
                        "New element: func_proto  \n" +
211
 
                        "Conflicting element type: Global function"); //$NON-NLS-1$
212
 
        status= checkConditions(cpp, offset1, "func_proto_ov");  //$NON-NLS-1$
213
 
        assertRefactoringError(status, "A conflict was encountered during refactoring.  \n" +
214
 
                        "Type of problem: Redeclaration  \n" +
215
 
                        "New element: func_proto_ov  \n" +
216
 
                        "Conflicting element type: Global function"); //$NON-NLS-1$
217
 
        status= checkConditions(cpp, offset1, "func_def");  //$NON-NLS-1$
218
 
        assertRefactoringError(status, "A conflict was encountered during refactoring.  \n" +
219
 
                        "Type of problem: Redeclaration  \n" +
220
 
                        "New element: func_def  \n" +
221
 
                        "Conflicting element type: Global function"); //$NON-NLS-1$
222
 
        // would be good to see an error here
223
 
        status= checkConditions(cpp, offset1, "func_def_ov");  //$NON-NLS-1$
224
 
        assertRefactoringError(status, "A conflict was encountered during refactoring.  \n" +
225
 
                        "Type of problem: Redeclaration  \n" +
226
 
                        "New element: func_def_ov  \n" +
227
 
                        "Conflicting element type: Global function"); //$NON-NLS-1$
228
 
        status= checkConditions(cpp, offset2, "func_proto");  //$NON-NLS-1$
229
 
        assertRefactoringError(status, "A conflict was encountered during refactoring.  \n" +
230
 
                        "Type of problem: Redeclaration  \n" +
231
 
                        "New element: func_proto  \n" +
232
 
                        "Conflicting element type: Global function"); //$NON-NLS-1$
233
 
        status= checkConditions(cpp, offset2, "func_proto_ov");  //$NON-NLS-1$
234
 
        assertRefactoringError(status, "A conflict was encountered during refactoring.  \n" +
235
 
                        "Type of problem: Redeclaration  \n" +
236
 
                        "New element: func_proto_ov  \n" +
237
 
                        "Conflicting element type: Global function"); //$NON-NLS-1$
238
 
        status= checkConditions(cpp, offset2, "func_def");  //$NON-NLS-1$
239
 
        assertRefactoringError(status, "A conflict was encountered during refactoring.  \n" +
240
 
                        "Type of problem: Redeclaration  \n" +
241
 
                        "New element: func_def  \n" +
242
 
                        "Conflicting element type: Global function"); //$NON-NLS-1$
243
 
        // would be good to see an error here
244
 
        status= checkConditions(cpp, offset2, "func_def_ov");  //$NON-NLS-1$
245
 
        assertRefactoringError(status, "A conflict was encountered during refactoring.  \n" +
246
 
                        "Type of problem: Redeclaration  \n" +
247
 
                        "New element: func_def_ov  \n" +
248
 
                        "Conflicting element type: Global function"); //$NON-NLS-1$
249
 
        status= checkConditions(cpp, offset3, "func_proto");  //$NON-NLS-1$
250
 
        assertRefactoringError(status, "A conflict was encountered during refactoring.  \n" +
251
 
                        "Type of problem: Redeclaration  \n" +
252
 
                        "New element: func_proto  \n" +
253
 
                        "Conflicting element type: Global function"); //$NON-NLS-1$
254
 
        status= checkConditions(cpp, offset3, "func_proto_ov");  //$NON-NLS-1$
255
 
        assertRefactoringError(status, "A conflict was encountered during refactoring.  \n" +
256
 
                        "Type of problem: Redeclaration  \n" +
257
 
                        "New element: func_proto_ov  \n" +
258
 
                        "Conflicting element type: Global function"); //$NON-NLS-1$
259
 
        status= checkConditions(cpp, offset3, "func_def");  //$NON-NLS-1$
260
 
        assertRefactoringError(status, "A conflict was encountered during refactoring.  \n" +
261
 
                        "Type of problem: Redeclaration  \n" +
262
 
                        "New element: func_def  \n" +
263
 
                        "Conflicting element type: Global function"); //$NON-NLS-1$
264
 
        status= checkConditions(cpp, offset3, "func_def_ov");  //$NON-NLS-1$
265
 
        assertRefactoringError(status, "A conflict was encountered during refactoring.  \n" +
266
 
                        "Type of problem: Redeclaration  \n" +
267
 
                        "New element: func_def_ov  \n" +
268
 
                        "Conflicting element type: Global function"); //$NON-NLS-1$
269
 
 
270
 
        // renamings that are ok.
271
 
        status= checkConditions(cpp, offset1, "class_fwd");  //$NON-NLS-1$
272
 
        assertRefactoringOk(status);
273
 
        status= checkConditions(cpp, offset1, "struct_fwd");  //$NON-NLS-1$
274
 
        assertRefactoringOk(status);
275
 
        status= checkConditions(cpp, offset1, "union_fwd");  //$NON-NLS-1$
276
 
        assertRefactoringOk(status);
277
 
        status= checkConditions(cpp, offset1, "class_def");  //$NON-NLS-1$
278
 
        assertRefactoringError(status, "A conflict was encountered during refactoring.  \n" +
279
 
                        "Type of problem: Shadowing  \n" +
280
 
                        "New element: class_def  \n" +
281
 
                        "Conflicting element type: Constructor"); //$NON-NLS-1$
282
 
        status= checkConditions(cpp, offset1, "struct_def");  //$NON-NLS-1$
283
 
        assertRefactoringOk(status);
284
 
        status= checkConditions(cpp, offset1, "union_def");  //$NON-NLS-1$
285
 
        assertRefactoringOk(status);
286
 
        status= checkConditions(cpp, offset1, "enum_def");  //$NON-NLS-1$
287
 
        assertRefactoringOk(status);
288
 
        status= checkConditions(cpp, offset1, "typedef_def");  //$NON-NLS-1$
289
 
        assertRefactoringOk(status);
290
 
        status= checkConditions(cpp, offset1, "namespace_def");  //$NON-NLS-1$
291
 
        assertRefactoringOk(status);
292
 
        status= checkConditions(cpp, offset1, "st_member");  //$NON-NLS-1$
293
 
        assertRefactoringOk(status);
294
 
        status= checkConditions(cpp, offset1, "un_member");  //$NON-NLS-1$
295
 
        assertRefactoringOk(status);
296
 
 
297
 
        status= checkConditions(cpp, offset2, "class_fwd");  //$NON-NLS-1$
298
 
        assertRefactoringOk(status);
299
 
        status= checkConditions(cpp, offset2, "struct_fwd");  //$NON-NLS-1$
300
 
        assertRefactoringOk(status);
301
 
        status= checkConditions(cpp, offset2, "union_fwd");  //$NON-NLS-1$
302
 
        assertRefactoringOk(status);
303
 
        status= checkConditions(cpp, offset2, "class_def");  //$NON-NLS-1$
304
 
        assertRefactoringError(status, "A conflict was encountered during refactoring.  \n" +
305
 
                        "Type of problem: Shadowing  \n" +
306
 
                        "New element: class_def  \n" +
307
 
                        "Conflicting element type: Constructor"); //$NON-NLS-1$
308
 
        status= checkConditions(cpp, offset2, "struct_def");  //$NON-NLS-1$
309
 
        assertRefactoringOk(status);
310
 
        status= checkConditions(cpp, offset2, "union_def");  //$NON-NLS-1$
311
 
        assertRefactoringOk(status);
312
 
        status= checkConditions(cpp, offset2, "enum_def");  //$NON-NLS-1$
313
 
        assertRefactoringOk(status);
314
 
        status= checkConditions(cpp, offset2, "typedef_def");  //$NON-NLS-1$
315
 
        assertRefactoringOk(status);
316
 
        status= checkConditions(cpp, offset2, "namespace_def");  //$NON-NLS-1$
317
 
        assertRefactoringOk(status);
318
 
        status= checkConditions(cpp, offset2, "st_member");  //$NON-NLS-1$
319
 
        assertRefactoringOk(status);
320
 
        status= checkConditions(cpp, offset2, "un_member");  //$NON-NLS-1$
321
 
        assertRefactoringOk(status);
322
 
 
323
 
        status= checkConditions(cpp, offset3, "class_fwd");  //$NON-NLS-1$
324
 
        assertRefactoringOk(status);
325
 
        status= checkConditions(cpp, offset3, "struct_fwd");  //$NON-NLS-1$
326
 
        assertRefactoringOk(status);
327
 
        status= checkConditions(cpp, offset3, "union_fwd");  //$NON-NLS-1$
328
 
        assertRefactoringOk(status);
329
 
        status= checkConditions(cpp, offset3, "class_def");  //$NON-NLS-1$
330
 
        assertRefactoringError(status, "A conflict was encountered during refactoring.  \n" +
331
 
                        "Type of problem: Shadowing  \n" +
332
 
                        "New element: class_def  \n" +
333
 
                        "Conflicting element type: Constructor"); //$NON-NLS-1$
334
 
        status= checkConditions(cpp, offset3, "struct_def");  //$NON-NLS-1$
335
 
        assertRefactoringOk(status);
336
 
        status= checkConditions(cpp, offset3, "union_def");  //$NON-NLS-1$
337
 
        assertRefactoringOk(status);
338
 
        status= checkConditions(cpp, offset3, "enum_def");  //$NON-NLS-1$
339
 
        assertRefactoringOk(status);
340
 
        status= checkConditions(cpp, offset3, "typedef_def");  //$NON-NLS-1$
341
 
        assertRefactoringOk(status);
342
 
        status= checkConditions(cpp, offset3, "namespace_def");  //$NON-NLS-1$
343
 
        assertRefactoringOk(status);
344
 
        status= checkConditions(cpp, offset3, "st_member");  //$NON-NLS-1$
345
 
        assertRefactoringOk(status);
346
 
        status= checkConditions(cpp, offset3, "un_member");  //$NON-NLS-1$
347
 
        assertRefactoringOk(status);
348
 
        
349
 
        // file static stuff
350
 
        status= checkConditions(cpp, contents.indexOf("s1"), "s2"); //$NON-NLS-1$ //$NON-NLS-2$
351
 
        assertRefactoringError(status, "A conflict was encountered during refactoring.  \n" +
352
 
                        "Type of problem: Redeclaration  \n" +
353
 
                        "New element: s2  \n" +
354
 
                        "Conflicting element type: File static function"); //$NON-NLS-1$
355
 
 
356
 
        status= checkConditions(cpp, contents.indexOf("s1"), "static_other_file"); //$NON-NLS-1$ //$NON-NLS-2$
357
 
        assertRefactoringOk(status); 
358
 
    }
359
 
    
360
 
    public void testFunctionsPlainC() throws Exception {
361
 
        createCFwdDecls("c_fwd.h"); //$NON-NLS-1$
362
 
        createCDefs("c_def.h"); //$NON-NLS-1$
363
 
        StringWriter writer = new StringWriter();
364
 
        writer.write("#include \"c_fwd.h\"   \n"); //$NON-NLS-1$
365
 
        writer.write("#include \"c_def.h\"   \n"); //$NON-NLS-1$
366
 
        writer.write("int v1(); int v2(); int v3();  \n"); //$NON-NLS-1$
367
 
        writer.write("int func_proto();         \n"); //$NON-NLS-1$
368
 
        writer.write("static int s2();          \n"); //$NON-NLS-1$
369
 
        writer.write("void func_def(){         \n"); //$NON-NLS-1$
370
 
        writer.write("     int w1; v1();        \n"); //$NON-NLS-1$
371
 
        writer.write("}                         \n"); //$NON-NLS-1$
372
 
        String contents = writer.toString();
373
 
        IFile cpp= importFile("test.c", contents ); //$NON-NLS-1$
374
 
        
375
 
        int offset1= contents.indexOf("func_proto"); //$NON-NLS-1$
376
 
        Change change= getRefactorChanges(cpp, offset1, "xxx");  //$NON-NLS-1$
377
 
        assertTotalChanges(2, change);
378
 
 
379
 
        offset1= contents.indexOf("func_def"); //$NON-NLS-1$
380
 
        change= getRefactorChanges(cpp, offset1, "xxx");  //$NON-NLS-1$
381
 
        assertTotalChanges(2, change);
382
 
    }
383
 
        
384
 
 
385
 
    public void testFunctionNameConflictsPlainC() throws Exception {
386
 
        createCFwdDecls("c_fwd.h"); //$NON-NLS-1$
387
 
        createCDefs("c_def.h"); //$NON-NLS-1$
388
 
        StringWriter writer = new StringWriter();
389
 
        writer.write("#include \"c_fwd.h\"   \n"); //$NON-NLS-1$
390
 
        writer.write("#include \"c_def.h\"   \n"); //$NON-NLS-1$
391
 
        writer.write("int v1(); int v2(); int v3();  \n"); //$NON-NLS-1$
392
 
        writer.write("static int s1();          \n"); //$NON-NLS-1$
393
 
        writer.write("static int s2();          \n"); //$NON-NLS-1$
394
 
        writer.write("void f(int par1){         \n"); //$NON-NLS-1$
395
 
        writer.write("     int w1; v1();        \n"); //$NON-NLS-1$
396
 
        writer.write("}                         \n"); //$NON-NLS-1$
397
 
        String contents = writer.toString();
398
 
        IFile cpp= importFile("test.c", contents ); //$NON-NLS-1$
399
 
        
400
 
        writer = new StringWriter();
401
 
        writer.write( "static int static_other_file();     \n" ); //$NON-NLS-1$        
402
 
        importFile( "other.c", writer.toString() ); //$NON-NLS-1$
403
 
 
404
 
 
405
 
        int offset1= contents.indexOf("v1"); //$NON-NLS-1$
406
 
        
407
 
        // conflicting renamings
408
 
        RefactoringStatus status= checkConditions(cpp, offset1, "w1");  //$NON-NLS-1$
409
 
        assertRefactoringError(status, "A conflict was encountered during refactoring.  \n" +
410
 
                        "Type of problem: Shadowing  \n" +
411
 
                        "New element: w1  \n" +
412
 
                        "Conflicting element type: Local variable"); //$NON-NLS-1$
413
 
        status= checkConditions(cpp, contents.indexOf("par1"), "v1");  //$NON-NLS-1$ //$NON-NLS-2$
414
 
        assertRefactoringError(status, "A conflict was encountered during refactoring.  \n" +
415
 
                        "Type of problem: Shadowing  \n" +
416
 
                        "New element: v1  \n" +
417
 
                        "Conflicting element type: Global function"); //$NON-NLS-1$
418
 
        status= checkConditions(cpp, offset1, "par1");  //$NON-NLS-1$
419
 
        assertRefactoringError(status, "A conflict was encountered during refactoring.  \n" +
420
 
                        "Type of problem: Shadowing  \n" +
421
 
                        "New element: par1  \n" +
422
 
                        "Conflicting element type: Parameter"); //$NON-NLS-1$
423
 
        status= checkConditions(cpp, offset1, "extern_var");  //$NON-NLS-1$
424
 
        assertRefactoringError(status, "A conflict was encountered during refactoring.  \n" +
425
 
                        "Type of problem: Redeclaration  \n" +
426
 
                        "New element: extern_var  \n" +
427
 
                        "Conflicting element type: Global variable"); //$NON-NLS-1$
428
 
        status= checkConditions(cpp, offset1, "var_def");  //$NON-NLS-1$
429
 
        assertRefactoringError(status, "A conflict was encountered during refactoring.  \n" +
430
 
                        "Type of problem: Redeclaration  \n" +
431
 
                        "New element: var_def  \n" +
432
 
                        "Conflicting element type: Global variable"); //$NON-NLS-1$
433
 
        status= checkConditions(cpp, offset1, "enum_item");  //$NON-NLS-1$
434
 
        assertRefactoringError(status, "A conflict was encountered during refactoring.  \n" +
435
 
                        "Type of problem: Redeclaration  \n" +
436
 
                        "New element: enum_item  \n" +
437
 
                        "Conflicting element type: Enumerator"); //$NON-NLS-1$
438
 
 
439
 
        // renamings conflicting with global stuff.
440
 
        status= checkConditions(cpp, offset1, "func_proto");  //$NON-NLS-1$
441
 
        assertRefactoringError(status, "A conflict was encountered during refactoring.  \n" +
442
 
                        "Type of problem: Redeclaration  \n" +
443
 
                        "New element: func_proto  \n" +
444
 
                        "Conflicting element type: Global function"); //$NON-NLS-1$
445
 
        status= checkConditions(cpp, offset1, "func_def");  //$NON-NLS-1$
446
 
        assertRefactoringError(status, "A conflict was encountered during refactoring.  \n" +
447
 
                        "Type of problem: Redeclaration  \n" +
448
 
                        "New element: func_def  \n" +
449
 
                        "Conflicting element type: Global function"); //$NON-NLS-1$
450
 
 
451
 
        // renamings that are ok.
452
 
        status= checkConditions(cpp, offset1, "struct_fwd");  //$NON-NLS-1$
453
 
        assertRefactoringOk(status);
454
 
        status= checkConditions(cpp, offset1, "union_fwd");  //$NON-NLS-1$
455
 
        assertRefactoringOk(status);
456
 
        status= checkConditions(cpp, offset1, "struct_def");  //$NON-NLS-1$
457
 
        assertRefactoringOk(status);
458
 
        status= checkConditions(cpp, offset1, "union_def");  //$NON-NLS-1$
459
 
        assertRefactoringOk(status);
460
 
        status= checkConditions(cpp, offset1, "enum_def");  //$NON-NLS-1$
461
 
        assertRefactoringOk(status);
462
 
        status= checkConditions(cpp, offset1, "typedef_def");  //$NON-NLS-1$
463
 
        assertRefactoringOk(status);
464
 
        status= checkConditions(cpp, offset1, "st_member");  //$NON-NLS-1$
465
 
        assertRefactoringOk(status);
466
 
        status= checkConditions(cpp, offset1, "un_member");  //$NON-NLS-1$
467
 
        assertRefactoringOk(status);
468
 
        
469
 
        // file static stuff
470
 
        status= checkConditions(cpp, contents.indexOf("s1"), "s2"); //$NON-NLS-1$ //$NON-NLS-2$
471
 
        assertRefactoringError(status, "A conflict was encountered during refactoring.  \n" +
472
 
                        "Type of problem: Redeclaration  \n" +
473
 
                        "New element: s2  \n" +
474
 
                        "Conflicting element type: File static function"); //$NON-NLS-1$
475
 
 
476
 
        status= checkConditions(cpp, contents.indexOf("s1"), "static_other_file"); //$NON-NLS-1$ //$NON-NLS-2$
477
 
        assertRefactoringOk(status); 
478
 
    }
479
 
 
480
 
    public void testMethodNameConflicts1() throws Exception {
481
 
        createCppFwdDecls("cpp_fwd.hh"); //$NON-NLS-1$
482
 
        createCppDefs("cpp_def.hh"); //$NON-NLS-1$
483
 
        StringWriter writer = new StringWriter();
484
 
        writer.write("#include \"cpp_fwd.hh\"   \n"); //$NON-NLS-1$
485
 
        writer.write("#include \"cpp_def.hh\"   \n"); //$NON-NLS-1$
486
 
        writer.write("class Dummy {             \n"); //$NON-NLS-1$
487
 
        writer.write("  int v1(); int v2();     \n"); //$NON-NLS-1$        
488
 
        writer.write("  int member;             \n"); //$NON-NLS-1$
489
 
        writer.write("  int method(int);        \n"); //$NON-NLS-1$
490
 
        writer.write("  int method_samesig();        \n"); //$NON-NLS-1$
491
 
        writer.write("  static int static_method(int);  \n"); //$NON-NLS-1$
492
 
        writer.write("  static int static_member;       \n"); //$NON-NLS-1$
493
 
        writer.write("};                        \n"); //$NON-NLS-1$        
494
 
        writer.write("int Dummy::method(int par1) { \n"); //$NON-NLS-1$
495
 
        writer.write("  {                        \n"); //$NON-NLS-1$
496
 
        writer.write("     int w1; v1();         \n"); //$NON-NLS-1$
497
 
        writer.write("  }                        \n"); //$NON-NLS-1$
498
 
        writer.write("}                          \n"); //$NON-NLS-1$
499
 
        writer.write("static int Dummy::static_method(int par2) { \n"); //$NON-NLS-1$
500
 
        writer.write("  {                        \n"); //$NON-NLS-1$
501
 
        writer.write("     int w2; v2();         \n"); //$NON-NLS-1$
502
 
        writer.write("  }                        \n"); //$NON-NLS-1$
503
 
        writer.write("}                          \n"); //$NON-NLS-1$
504
 
        String contents = writer.toString();
505
 
        IFile cpp= importFile("test.cpp", contents ); //$NON-NLS-1$
506
 
        
507
 
        int offset1= contents.indexOf("v1"); //$NON-NLS-1$
508
 
        int offset2= contents.indexOf("v2"); //$NON-NLS-1$
509
 
 
510
 
        // conflicting renamings
511
 
        RefactoringStatus status= checkConditions(cpp, offset1, "w1");  //$NON-NLS-1$
512
 
        assertRefactoringError(status, "A conflict was encountered during refactoring.  \n" +
513
 
                        "Type of problem: Shadowing  \n" +
514
 
                        "New element: w1  \n" +
515
 
                        "Conflicting element type: Local variable"); //$NON-NLS-1$
516
 
        status= checkConditions(cpp, contents.indexOf("w1"), "v1");  //$NON-NLS-1$ //$NON-NLS-2$
517
 
        assertRefactoringError(status, "A conflict was encountered during refactoring.  \n" +
518
 
                        "Type of problem: Shadowing  \n" +
519
 
                        "New element: v1  \n" +
520
 
                        "Conflicting element type: Method"); //$NON-NLS-1$
521
 
        status= checkConditions(cpp, contents.indexOf("par1"), "v1");  //$NON-NLS-1$ //$NON-NLS-2$
522
 
        assertRefactoringError(status, "A conflict was encountered during refactoring.  \n" +
523
 
                        "Type of problem: Shadowing  \n" +
524
 
                        "New element: v1  \n" +
525
 
                        "Conflicting element type: Method"); //$NON-NLS-1$
526
 
        status= checkConditions(cpp, offset1, "par1");  //$NON-NLS-1$
527
 
        assertRefactoringError(status, "A conflict was encountered during refactoring.  \n" +
528
 
                        "Type of problem: Shadowing  \n" +
529
 
                        "New element: par1  \n" +
530
 
                        "Conflicting element type: Parameter"); //$NON-NLS-1$
531
 
        status= checkConditions(cpp, offset1, "extern_var");  //$NON-NLS-1$
532
 
        assertRefactoringError(status, "A conflict was encountered during refactoring.  \n" +
533
 
                        "Type of problem: Shadowing  \n" +
534
 
                        "New element: extern_var  \n" +
535
 
                        "Conflicting element type: Global variable"); //$NON-NLS-1$
536
 
        status= checkConditions(cpp, offset1, "var_def");  //$NON-NLS-1$
537
 
        assertRefactoringError(status, "A conflict was encountered during refactoring.  \n" +
538
 
                        "Type of problem: Shadowing  \n" +
539
 
                        "New element: var_def  \n" +
540
 
                        "Conflicting element type: Global variable"); //$NON-NLS-1$
541
 
        status= checkConditions(cpp, offset1, "enum_item");  //$NON-NLS-1$
542
 
        assertRefactoringError(status, "A conflict was encountered during refactoring.  \n" +
543
 
                        "Type of problem: Shadowing  \n" +
544
 
                        "New element: enum_item  \n" +
545
 
                        "Conflicting element type: Enumerator"); //$NON-NLS-1$
546
 
 
547
 
        status= checkConditions(cpp, offset2, "w2");  //$NON-NLS-1$
548
 
        assertRefactoringError(status, "A conflict was encountered during refactoring.  \n" +
549
 
                        "Type of problem: Shadowing  \n" +
550
 
                        "New element: w2  \n" +
551
 
                        "Conflicting element type: Local variable"); //$NON-NLS-1$
552
 
        status= checkConditions(cpp, offset2, "par2");  //$NON-NLS-1$
553
 
        assertRefactoringError(status, "A conflict was encountered during refactoring.  \n" +
554
 
                        "Type of problem: Shadowing  \n" +
555
 
                        "New element: par2  \n" +
556
 
                        "Conflicting element type: Parameter"); //$NON-NLS-1$
557
 
        status= checkConditions(cpp, offset2, "extern_var");  //$NON-NLS-1$
558
 
        assertRefactoringError(status, "A conflict was encountered during refactoring.  \n" +
559
 
                        "Type of problem: Shadowing  \n" +
560
 
                        "New element: extern_var  \n" +
561
 
                        "Conflicting element type: Global variable"); //$NON-NLS-1$
562
 
        status= checkConditions(cpp, offset2, "var_def");  //$NON-NLS-1$
563
 
        assertRefactoringError(status, "A conflict was encountered during refactoring.  \n" +
564
 
                        "Type of problem: Shadowing  \n" +
565
 
                        "New element: var_def  \n" +
566
 
                        "Conflicting element type: Global variable"); //$NON-NLS-1$
567
 
        status= checkConditions(cpp, offset2, "enum_item");  //$NON-NLS-1$
568
 
        assertRefactoringError(status, "A conflict was encountered during refactoring.  \n" +
569
 
                        "Type of problem: Shadowing  \n" +
570
 
                        "New element: enum_item  \n" +
571
 
                        "Conflicting element type: Enumerator"); //$NON-NLS-1$
572
 
 
573
 
 
574
 
        status= checkConditions(cpp, offset2, "member");  //$NON-NLS-1$
575
 
        assertRefactoringError(status, "A conflict was encountered during refactoring.  \n" +
576
 
                        "Type of problem: Redeclaration  \n" +
577
 
                        "New element: member  \n" +
578
 
                        "Conflicting element type: Field"); //$NON-NLS-1$
579
 
        status= checkConditions(cpp, offset2, "method");  //$NON-NLS-1$
580
 
        assertRefactoringWarning(status, "A conflict was encountered during refactoring.  \n" +
581
 
                        "Type of problem: Overloading  \n" +
582
 
                        "New element: method  \n" +
583
 
                        "Conflicting element type: Method"); //$NON-NLS-1$
584
 
        status= checkConditions(cpp, offset2, "method_samesig");  //$NON-NLS-1$
585
 
        assertRefactoringError(status, "A conflict was encountered during refactoring.  \n" +
586
 
                        "Type of problem: Redeclaration  \n" +
587
 
                        "New element: method_samesig  \n" +
588
 
                        "Conflicting element type: Method"); //$NON-NLS-1$
589
 
        status= checkConditions(cpp, offset2, "static_member");  //$NON-NLS-1$
590
 
        assertRefactoringError(status, "A conflict was encountered during refactoring.  \n" +
591
 
                        "Type of problem: Redeclaration  \n" +
592
 
                        "New element: static_member  \n" +
593
 
                        "Conflicting element type: Field"); //$NON-NLS-1$
594
 
        status= checkConditions(cpp, offset2, "static_method");  //$NON-NLS-1$
595
 
        assertRefactoringWarning(status, "A conflict was encountered during refactoring.  \n" +
596
 
                        "Type of problem: Overloading  \n" +
597
 
                        "New element: static_method  \n" +
598
 
                        "Conflicting element type: Method"); //$NON-NLS-1$
599
 
    }
600
 
 
601
 
    public void testMethodNameConflicts2() throws Exception {
602
 
        createCppFwdDecls("cpp_fwd.hh"); //$NON-NLS-1$
603
 
        createCppDefs("cpp_def.hh"); //$NON-NLS-1$
604
 
        StringWriter writer = new StringWriter();
605
 
        writer.write("#include \"cpp_fwd.hh\"   \n"); //$NON-NLS-1$
606
 
        writer.write("#include \"cpp_def.hh\"   \n"); //$NON-NLS-1$
607
 
        writer.write("class Dummy {             \n"); //$NON-NLS-1$
608
 
        writer.write("  int v1(), v2(), v3();   \n"); //$NON-NLS-1$
609
 
        writer.write("};                        \n"); //$NON-NLS-1$        
610
 
        writer.write("Dummy d;                  \n"); //$NON-NLS-1$        
611
 
        writer.write("void f(int par1){         \n"); //$NON-NLS-1$
612
 
        writer.write("  {                       \n"); //$NON-NLS-1$
613
 
        writer.write("     int w1; d.v1();      \n"); //$NON-NLS-1$
614
 
        writer.write("  }                       \n"); //$NON-NLS-1$
615
 
        writer.write("}                         \n"); //$NON-NLS-1$
616
 
        writer.write("void class_def::method(int par2) { \n"); //$NON-NLS-1$
617
 
        writer.write("  {                        \n"); //$NON-NLS-1$
618
 
        writer.write("     int w2; d.v2();       \n"); //$NON-NLS-1$
619
 
        writer.write("  }                        \n"); //$NON-NLS-1$
620
 
        writer.write("}                          \n"); //$NON-NLS-1$
621
 
        writer.write("static void class_def::static_method(int par3) { \n"); //$NON-NLS-1$
622
 
        writer.write("  {                        \n"); //$NON-NLS-1$
623
 
        writer.write("     int w3; d.v3();       \n"); //$NON-NLS-1$
624
 
        writer.write("  }                        \n"); //$NON-NLS-1$
625
 
        writer.write("}                          \n"); //$NON-NLS-1$
626
 
        String contents = writer.toString();
627
 
        IFile cpp= importFile("test.cpp", contents ); //$NON-NLS-1$
628
 
        
629
 
        int offset1= contents.indexOf("v1"); //$NON-NLS-1$
630
 
        int offset2= contents.indexOf("v2"); //$NON-NLS-1$
631
 
        int offset3= contents.indexOf("v3"); //$NON-NLS-1$
632
 
        
633
 
        // conflicting renamings
634
 
        RefactoringStatus status= checkConditions(cpp, offset1, "w1");  //$NON-NLS-1$
635
 
        assertRefactoringOk(status);
636
 
        status= checkConditions(cpp, offset1, "par1");  //$NON-NLS-1$
637
 
        assertRefactoringOk(status);
638
 
        status= checkConditions(cpp, offset1, "extern_var");  //$NON-NLS-1$
639
 
        assertRefactoringOk(status); 
640
 
        status= checkConditions(cpp, offset1, "var_def");  //$NON-NLS-1$
641
 
        assertRefactoringOk(status); 
642
 
        status= checkConditions(cpp, offset1, "enum_item");  //$NON-NLS-1$
643
 
        assertRefactoringOk(status); 
644
 
 
645
 
        status= checkConditions(cpp, offset2, "w2");  //$NON-NLS-1$
646
 
        assertRefactoringOk(status); 
647
 
        status= checkConditions(cpp, offset2, "par2");  //$NON-NLS-1$
648
 
        assertRefactoringOk(status); 
649
 
        status= checkConditions(cpp, offset2, "extern_var");  //$NON-NLS-1$
650
 
        assertRefactoringOk(status); 
651
 
        status= checkConditions(cpp, offset2, "var_def");  //$NON-NLS-1$
652
 
        assertRefactoringOk(status); 
653
 
        status= checkConditions(cpp, offset2, "enum_item");  //$NON-NLS-1$
654
 
        assertRefactoringOk(status); 
655
 
 
656
 
        status= checkConditions(cpp, offset3, "w3");  //$NON-NLS-1$
657
 
        assertRefactoringOk(status); 
658
 
        status= checkConditions(cpp, offset3, "par3");  //$NON-NLS-1$
659
 
        assertRefactoringOk(status); 
660
 
        status= checkConditions(cpp, offset3, "extern_var");  //$NON-NLS-1$
661
 
        assertRefactoringOk(status); 
662
 
        status= checkConditions(cpp, offset3, "var_def");  //$NON-NLS-1$
663
 
        assertRefactoringOk(status); 
664
 
        status= checkConditions(cpp, offset3, "enum_item");  //$NON-NLS-1$
665
 
        assertRefactoringOk(status); 
666
 
 
667
 
        // renamings depending on scope
668
 
        status= checkConditions(cpp, offset1, "member");  //$NON-NLS-1$
669
 
        assertRefactoringOk(status);
670
 
        status= checkConditions(cpp, offset1, "method");  //$NON-NLS-1$
671
 
        assertRefactoringOk(status);
672
 
        status= checkConditions(cpp, offset1, "static_member");  //$NON-NLS-1$
673
 
        assertRefactoringOk(status);
674
 
        status= checkConditions(cpp, offset1, "static_method");  //$NON-NLS-1$
675
 
        assertRefactoringOk(status);
676
 
        status= checkConditions(cpp, offset2, "member");  //$NON-NLS-1$
677
 
        assertRefactoringOk(status); 
678
 
        status= checkConditions(cpp, offset2, "method");  //$NON-NLS-1$
679
 
        assertRefactoringOk(status); 
680
 
        status= checkConditions(cpp, offset2, "static_member");  //$NON-NLS-1$
681
 
        assertRefactoringOk(status); 
682
 
        status= checkConditions(cpp, offset2, "static_method");  //$NON-NLS-1$
683
 
        assertRefactoringOk(status); 
684
 
        status= checkConditions(cpp, offset3, "static_member");  //$NON-NLS-1$
685
 
        assertRefactoringOk(status); 
686
 
        status= checkConditions(cpp, offset3, "static_method");  //$NON-NLS-1$
687
 
        assertRefactoringOk(status); 
688
 
 
689
 
        status= checkConditions(cpp, offset1, "func_proto");  //$NON-NLS-1$
690
 
        assertRefactoringOk(status); 
691
 
        status= checkConditions(cpp, offset1, "func_proto_ov");  //$NON-NLS-1$
692
 
        assertRefactoringOk(status); 
693
 
        status= checkConditions(cpp, offset1, "func_def");  //$NON-NLS-1$
694
 
        assertRefactoringOk(status); 
695
 
        status= checkConditions(cpp, offset1, "func_def_ov");  //$NON-NLS-1$
696
 
        assertRefactoringOk(status); 
697
 
        status= checkConditions(cpp, offset2, "func_proto");  //$NON-NLS-1$
698
 
        assertRefactoringOk(status); 
699
 
        status= checkConditions(cpp, offset2, "func_proto_ov");  //$NON-NLS-1$
700
 
        assertRefactoringOk(status); 
701
 
        status= checkConditions(cpp, offset2, "func_def");  //$NON-NLS-1$
702
 
        assertRefactoringOk(status); 
703
 
        status= checkConditions(cpp, offset2, "func_def_ov");  //$NON-NLS-1$
704
 
        assertRefactoringOk(status); 
705
 
        status= checkConditions(cpp, offset3, "func_proto");  //$NON-NLS-1$
706
 
        assertRefactoringOk(status); 
707
 
        status= checkConditions(cpp, offset3, "func_proto_ov");  //$NON-NLS-1$
708
 
        assertRefactoringOk(status); 
709
 
        status= checkConditions(cpp, offset3, "func_def");  //$NON-NLS-1$
710
 
        assertRefactoringOk(status); 
711
 
        status= checkConditions(cpp, offset3, "func_def_ov");  //$NON-NLS-1$
712
 
        assertRefactoringOk(status); 
713
 
        status= checkConditions(cpp, offset1, "class_fwd");  //$NON-NLS-1$
714
 
        assertRefactoringOk(status);
715
 
        status= checkConditions(cpp, offset1, "struct_fwd");  //$NON-NLS-1$
716
 
        assertRefactoringOk(status);
717
 
        status= checkConditions(cpp, offset1, "union_fwd");  //$NON-NLS-1$
718
 
        assertRefactoringOk(status);
719
 
        status= checkConditions(cpp, offset1, "class_def");  //$NON-NLS-1$
720
 
        assertRefactoringOk(status);
721
 
        status= checkConditions(cpp, offset1, "struct_def");  //$NON-NLS-1$
722
 
        assertRefactoringOk(status);
723
 
        status= checkConditions(cpp, offset1, "union_def");  //$NON-NLS-1$
724
 
        assertRefactoringOk(status);
725
 
        status= checkConditions(cpp, offset1, "enum_def");  //$NON-NLS-1$
726
 
        assertRefactoringOk(status);
727
 
        status= checkConditions(cpp, offset1, "typedef_def");  //$NON-NLS-1$
728
 
        assertRefactoringOk(status);
729
 
        status= checkConditions(cpp, offset1, "namespace_def");  //$NON-NLS-1$
730
 
        assertRefactoringOk(status);
731
 
        status= checkConditions(cpp, offset1, "st_member");  //$NON-NLS-1$
732
 
        assertRefactoringOk(status);
733
 
        status= checkConditions(cpp, offset1, "un_member");  //$NON-NLS-1$
734
 
        assertRefactoringOk(status);
735
 
 
736
 
        status= checkConditions(cpp, offset2, "class_fwd");  //$NON-NLS-1$
737
 
        assertRefactoringOk(status);
738
 
        status= checkConditions(cpp, offset2, "struct_fwd");  //$NON-NLS-1$
739
 
        assertRefactoringOk(status);
740
 
        status= checkConditions(cpp, offset2, "union_fwd");  //$NON-NLS-1$
741
 
        assertRefactoringOk(status);
742
 
        status= checkConditions(cpp, offset2, "class_def");  //$NON-NLS-1$
743
 
        assertRefactoringOk(status); 
744
 
        status= checkConditions(cpp, offset2, "struct_def");  //$NON-NLS-1$
745
 
        assertRefactoringOk(status);
746
 
        status= checkConditions(cpp, offset2, "union_def");  //$NON-NLS-1$
747
 
        assertRefactoringOk(status);
748
 
        status= checkConditions(cpp, offset2, "enum_def");  //$NON-NLS-1$
749
 
        assertRefactoringOk(status);
750
 
        status= checkConditions(cpp, offset2, "typedef_def");  //$NON-NLS-1$
751
 
        assertRefactoringOk(status);
752
 
        status= checkConditions(cpp, offset2, "namespace_def");  //$NON-NLS-1$
753
 
        assertRefactoringOk(status);
754
 
        status= checkConditions(cpp, offset2, "st_member");  //$NON-NLS-1$
755
 
        assertRefactoringOk(status);
756
 
        status= checkConditions(cpp, offset2, "un_member");  //$NON-NLS-1$
757
 
        assertRefactoringOk(status);
758
 
 
759
 
        status= checkConditions(cpp, offset3, "class_fwd");  //$NON-NLS-1$
760
 
        assertRefactoringOk(status);
761
 
        status= checkConditions(cpp, offset3, "struct_fwd");  //$NON-NLS-1$
762
 
        assertRefactoringOk(status);
763
 
        status= checkConditions(cpp, offset3, "union_fwd");  //$NON-NLS-1$
764
 
        assertRefactoringOk(status);
765
 
        status= checkConditions(cpp, offset3, "class_def");  //$NON-NLS-1$
766
 
        assertRefactoringOk(status); 
767
 
        status= checkConditions(cpp, offset3, "struct_def");  //$NON-NLS-1$
768
 
        assertRefactoringOk(status);
769
 
        status= checkConditions(cpp, offset3, "union_def");  //$NON-NLS-1$
770
 
        assertRefactoringOk(status);
771
 
        status= checkConditions(cpp, offset3, "enum_def");  //$NON-NLS-1$
772
 
        assertRefactoringOk(status);
773
 
        status= checkConditions(cpp, offset3, "typedef_def");  //$NON-NLS-1$
774
 
        assertRefactoringOk(status);
775
 
        status= checkConditions(cpp, offset3, "namespace_def");  //$NON-NLS-1$
776
 
        assertRefactoringOk(status);
777
 
        status= checkConditions(cpp, offset3, "st_member");  //$NON-NLS-1$
778
 
        assertRefactoringOk(status);
779
 
        status= checkConditions(cpp, offset3, "un_member");  //$NON-NLS-1$
780
 
        assertRefactoringOk(status);
781
 
    }
782
 
    
783
 
    public void testBug72605() throws Exception {
784
 
        StringWriter writer = new StringWriter();
785
 
        writer.write("class Foo {               \n"); //$NON-NLS-1$
786
 
        writer.write("  void m1(int x=0);       \n"); //$NON-NLS-1$
787
 
        writer.write("};                        \n"); //$NON-NLS-1$
788
 
        writer.write("void Foo::m1(int x) {}    \n"); //$NON-NLS-1$
789
 
        String contents = writer.toString();
790
 
        IFile cpp= importFile("test.cpp", contents ); //$NON-NLS-1$
791
 
        
792
 
        int offset =  contents.indexOf("m1") ; //$NON-NLS-1$
793
 
        int offset2=  contents.indexOf("m1", offset+1) ; //$NON-NLS-1$        
794
 
        Change changes = getRefactorChanges(cpp, offset, "z"); //$NON-NLS-1$
795
 
        assertTotalChanges( 2, changes );
796
 
        changes = getRefactorChanges(cpp, offset2, "z"); //$NON-NLS-1$
797
 
        assertTotalChanges( 2, changes );
798
 
    }
799
 
    
800
 
    public void testBug72732() throws Exception {
801
 
        StringWriter writer = new StringWriter();
802
 
        writer.write("class Foo {               \n"); //$NON-NLS-1$
803
 
        writer.write("  virtual void mthd() = 0;\n"); //$NON-NLS-1$
804
 
        writer.write("};                        \n"); //$NON-NLS-1$
805
 
        writer.write("class Moo: public Foo{    \n"); //$NON-NLS-1$
806
 
        writer.write("  void mthd() = 0;        \n"); //$NON-NLS-1$
807
 
        writer.write("};                        \n"); //$NON-NLS-1$
808
 
        String contents = writer.toString();
809
 
        IFile cpp= importFile("test.cpp", contents ); //$NON-NLS-1$
810
 
        int offset =  contents.indexOf("mthd") ; //$NON-NLS-1$
811
 
        offset=  contents.indexOf("mthd", offset+1) ; //$NON-NLS-1$        
812
 
        Change changes = getRefactorChanges(cpp, offset, "z"); //$NON-NLS-1$
813
 
        assertTotalChanges( 2, changes );
814
 
    }
815
 
}