This Bugzilla instance is a read-only archive of historic NetBeans bug reports. To report a bug in NetBeans please follow the project's instructions for reporting issues.

View | Details | Raw Unified | Return to bug 177824
Collapse All | Expand All

(-)a/java.source/src/org/netbeans/modules/java/source/save/DiffFacility.java (-17 / +17 lines)
Lines 61-79 Link Here
61
    public DiffFacility(Collection<Diff> diff) {
61
    public DiffFacility(Collection<Diff> diff) {
62
        this.gdiff = diff;
62
        this.gdiff = diff;
63
    }
63
    }
64
    
64
65
    private static class Line {
65
    private static class Line {
66
        Line(String data, int start, int end) {
66
        Line(String data, int start, int end) {
67
            this.start = start;
67
            this.start = start;
68
            this.end = end;
68
            this.end = end;
69
            this.data = data;
69
            this.data = data;
70
        }
70
        }
71
        
71
72
        @Override
72
        @Override
73
        public String toString() {
73
        public String toString() {
74
            return data.toString();
74
            return data.toString();
75
        }
75
        }
76
        
76
77
        @Override
77
        @Override
78
        public boolean equals(Object o) {
78
        public boolean equals(Object o) {
79
            if (o instanceof Line) {
79
            if (o instanceof Line) {
Lines 82-98 Link Here
82
                return false;
82
                return false;
83
            }
83
            }
84
        }
84
        }
85
        
85
86
        @Override
86
        @Override
87
        public int hashCode() {
87
        public int hashCode() {
88
            return data.hashCode();
88
            return data.hashCode();
89
        }
89
        }
90
        
90
91
        String data;
91
        String data;
92
        int end;
92
        int end;
93
        int start;
93
        int start;
94
    }
94
    }
95
    
95
96
    private static List<Line> getLines(String text) {
96
    private static List<Line> getLines(String text) {
97
        char[] chars = text.toCharArray();
97
        char[] chars = text.toCharArray();
98
        List<Line> list = new ArrayList<Line>();
98
        List<Line> list = new ArrayList<Line>();
Lines 108-127 Link Here
108
        }
108
        }
109
        return list;
109
        return list;
110
    }
110
    }
111
    
111
112
    public List<Diff> makeListMatch(String text1, String text2, int offset) {
112
    public List<Diff> makeListMatch(String text1, String text2, int offset) {
113
        List<Line> list1 = getLines(text1);
113
        List<Line> list1 = getLines(text1);
114
        List<Line> list2 = getLines(text2);
114
        List<Line> list2 = getLines(text2);
115
        Line[] lines1 = list1.toArray(new Line[list1.size()]);
115
        Line[] lines1 = list1.toArray(new Line[list1.size()]);
116
        Line[] lines2 = list2.toArray(new Line[list2.size()]);
116
        Line[] lines2 = list2.toArray(new Line[list2.size()]);
117
        
117
118
        List<Difference> diffs = new ComputeDiff<Line>(lines1, lines2).diff();
118
        List<Difference> diffs = new ComputeDiff<Line>(lines1, lines2).diff();
119
        for (Difference diff : diffs) {
119
        for (Difference diff : diffs) {
120
            int delStart = diff.getDeletedStart();
120
            int delStart = diff.getDeletedStart();
121
            int delEnd   = diff.getDeletedEnd();
121
            int delEnd   = diff.getDeletedEnd();
122
            int addStart = diff.getAddedStart();
122
            int addStart = diff.getAddedStart();
123
            int addEnd   = diff.getAddedEnd();
123
            int addEnd   = diff.getAddedEnd();
124
            
124
125
            char type = delEnd != Difference.NONE && addEnd != Difference.NONE ? 'c' : (delEnd == Difference.NONE ? 'a' : 'd');
125
            char type = delEnd != Difference.NONE && addEnd != Difference.NONE ? 'c' : (delEnd == Difference.NONE ? 'a' : 'd');
126
126
127
            // addition
127
            // addition
Lines 134-147 Link Here
134
                        delStart < lines1.length ? lines1[delStart].start + offset : (lines1.length != 0 ? lines1[lines1.length-1].end + offset : offset)
134
                        delStart < lines1.length ? lines1[delStart].start + offset : (lines1.length != 0 ? lines1[lines1.length-1].end + offset : offset)
135
                        : lines1[delEnd].end + offset,
135
                        : lines1[delEnd].end + offset,
136
                        builder.toString()));
136
                        builder.toString()));
137
                
137
138
            }
138
            }
139
139
140
            // deletion
140
            // deletion
141
            else if (type == 'd') {
141
            else if (type == 'd') {
142
                gdiff.add(Diff.delete(lines1[delStart].start + offset, lines1[delEnd].end + offset));
142
                gdiff.add(Diff.delete(lines1[delStart].start + offset, lines1[delEnd].end + offset));
143
            }
143
            }
144
            
144
145
            // change
145
            // change
146
            else { // type == 'c'
146
            else { // type == 'c'
147
                if (addEnd-addStart>delEnd-delStart) {
147
                if (addEnd-addStart>delEnd-delStart) {
Lines 185-191 Link Here
185
        }
185
        }
186
        return null;
186
        return null;
187
    }
187
    }
188
    
188
189
    public List<Diff> makeTokenListMatch(String text1, String text2, int currentPos) {
189
    public List<Diff> makeTokenListMatch(String text1, String text2, int currentPos) {
190
        TokenSequence<JavaTokenId> seq1 = TokenHierarchy.create(text1, JavaTokenId.language()).tokenSequence(JavaTokenId.language());
190
        TokenSequence<JavaTokenId> seq1 = TokenHierarchy.create(text1, JavaTokenId.language()).tokenSequence(JavaTokenId.language());
191
        TokenSequence<JavaTokenId> seq2 = TokenHierarchy.create(text2, JavaTokenId.language()).tokenSequence(JavaTokenId.language());
191
        TokenSequence<JavaTokenId> seq2 = TokenHierarchy.create(text2, JavaTokenId.language()).tokenSequence(JavaTokenId.language());
Lines 203-209 Link Here
203
            lastId2 = seq2.token().id();
203
            lastId2 = seq2.token().id();
204
            list2.add(new Line(data, seq2.offset(), seq2.offset() + data.length()));
204
            list2.add(new Line(data, seq2.offset(), seq2.offset() + data.length()));
205
        }
205
        }
206
        if (lastId1 != null && lastId1 == lastId2 && lastId1 == JavaTokenId.LINE_COMMENT) {
206
        if (lastId1 != null && lastId1 == lastId2 && (lastId1 == JavaTokenId.LINE_COMMENT || lastId1 == JavaTokenId.WHITESPACE)) {
207
            list1.remove(list1.size() - 1);
207
            list1.remove(list1.size() - 1);
208
            list2.remove(list2.size() - 1);
208
            list2.remove(list2.size() - 1);
209
        }
209
        }
Lines 215-221 Link Here
215
            int delEnd   = diff.getDeletedEnd();
215
            int delEnd   = diff.getDeletedEnd();
216
            int addStart = diff.getAddedStart();
216
            int addStart = diff.getAddedStart();
217
            int addEnd   = diff.getAddedEnd();
217
            int addEnd   = diff.getAddedEnd();
218
            
218
219
            char type = delEnd != Difference.NONE && addEnd != Difference.NONE ? 'c' : (delEnd == Difference.NONE ? 'a' : 'd');
219
            char type = delEnd != Difference.NONE && addEnd != Difference.NONE ? 'c' : (delEnd == Difference.NONE ? 'a' : 'd');
220
220
221
            // addition
221
            // addition
Lines 229-240 Link Here
229
                        : lines1[delEnd].end),
229
                        : lines1[delEnd].end),
230
                        builder.toString()));
230
                        builder.toString()));
231
            }
231
            }
232
            
232
233
            // deletion
233
            // deletion
234
            else if (type == 'd') {
234
            else if (type == 'd') {
235
                gdiff.add(Diff.delete(currentPos + lines1[delStart].start, currentPos + lines1[delEnd].end));
235
                gdiff.add(Diff.delete(currentPos + lines1[delStart].start, currentPos + lines1[delEnd].end));
236
            }
236
            }
237
            
237
238
            // change
238
            // change
239
            else { // type == 'c'
239
            else { // type == 'c'
240
                StringBuilder builder = new StringBuilder();
240
                StringBuilder builder = new StringBuilder();
Lines 249-255 Link Here
249
                gdiff.add(Diff.insert(currentPos + (delEnd == Difference.NONE ? lines1[delStart].start : lines1[delEnd].end),
249
                gdiff.add(Diff.insert(currentPos + (delEnd == Difference.NONE ? lines1[delStart].start : lines1[delEnd].end),
250
                        builder.toString()));
250
                        builder.toString()));
251
            }
251
            }
252
                    
252
253
        }
253
        }
254
        return null;
254
        return null;
255
    }
255
    }
(-)a/java.source/test/unit/src/org/netbeans/api/java/source/gen/GuardedBlockTest.java (-28 / +102 lines)
Lines 107-113 Link Here
107
107
108
/**
108
/**
109
 * Regression tests for guarded exceptions.
109
 * Regression tests for guarded exceptions.
110
 * 
110
 *
111
 * @author Pavel Flaska
111
 * @author Pavel Flaska
112
 */
112
 */
113
public class GuardedBlockTest extends GeneratorTestMDRCompat {
113
public class GuardedBlockTest extends GeneratorTestMDRCompat {
Lines 119-124 Link Here
119
    public static NbTestSuite suite() {
119
    public static NbTestSuite suite() {
120
        NbTestSuite suite = new NbTestSuite();
120
        NbTestSuite suite = new NbTestSuite();
121
//        suite.addTestSuite(GuardedBlockTest.class);
121
//        suite.addTestSuite(GuardedBlockTest.class);
122
        suite.addTest(new GuardedBlockTest("testInsertMethodBeforeVariablesBug177824"));
122
        suite.addTest(new GuardedBlockTest("testAddMethodAfterVariables"));
123
        suite.addTest(new GuardedBlockTest("testAddMethodAfterVariables"));
123
        suite.addTest(new GuardedBlockTest("test119048"));
124
        suite.addTest(new GuardedBlockTest("test119048"));
124
        suite.addTest(new GuardedBlockTest("test119962"));
125
        suite.addTest(new GuardedBlockTest("test119962"));
Lines 127-133 Link Here
127
        suite.addTest(new GuardedBlockTest("testComplex186754"));
128
        suite.addTest(new GuardedBlockTest("testComplex186754"));
128
        return suite;
129
        return suite;
129
    }
130
    }
130
    
131
131
    /**
132
    /**
132
     * We need our own data loader to use guarded blocks.
133
     * We need our own data loader to use guarded blocks.
133
     */
134
     */
Lines 156-168 Link Here
156
        cacheFolder.mkdirs();
157
        cacheFolder.mkdirs();
157
        IndexUtil.setCacheFolder(cacheFolder);
158
        IndexUtil.setCacheFolder(cacheFolder);
158
    }
159
    }
159
    
160
161
    /**
162
     * #177824: Guarded Exception
163
     */
164
    public void testInsertMethodBeforeVariablesBug177824() throws Exception {
165
166
        String source =
167
            "package test;\n" +
168
            "\n" +
169
            "import java.awt.event.ActionEvent;\n" +
170
            "import java.awt.event.ActionListener;\n" +
171
            "\n" +
172
            "public class Guarded1 implements ActionListener {\n" +
173
            "    \n" +
174
            "    private void fooActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_fooActionPerformed\n" +
175
            "    }//GEN-LAST:event_fooActionPerformed\n" +
176
            "\n" +
177
            "    // Variables declaration - do not modify//GEN-BEGIN:variables\n" +
178
            "    private javax.swing.JButton jButton1;\n" +
179
            "    // End of variables declaration//GEN-END:variables\n" +
180
            "}\n";
181
182
        testFile = new File(getWorkDir(), "Test.java");
183
        TestUtilities.copyStringToFile(testFile, source);
184
        DataObject dataObject = DataObject.find(FileUtil.toFileObject(testFile));
185
        EditorCookie editorCookie = ((GuardedDataObject) dataObject).getCookie(EditorCookie.class);
186
        Document doc = editorCookie.openDocument();
187
        String golden =
188
            "package test;\n" +
189
            "\n" +
190
            "import java.awt.event.ActionEvent;\n" +
191
            "import java.awt.event.ActionListener;\n" +
192
            "\n" +
193
            "public class Guarded1 implements ActionListener {\n" +
194
            "    \n" +
195
            "    private void fooActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_fooActionPerformed\n" +
196
            "    }//GEN-LAST:event_fooActionPerformed\n" +
197
            "\n" +
198
            "    public String toString() {\n" +
199
            "    }\n" +
200
            "\n" +
201
            "    // Variables declaration - do not modify//GEN-BEGIN:variables\n" +
202
            "    private javax.swing.JButton jButton1;\n" +
203
            "    // End of variables declaration//GEN-END:variables\n" +
204
            "}\n";
205
206
        JavaSource src = getJavaSource(testFile);
207
        Task<WorkingCopy> task = new Task<WorkingCopy>() {
208
209
            public void run(WorkingCopy workingCopy) throws IOException {
210
                workingCopy.toPhase(RESOLVED);
211
                CompilationUnitTree cut = workingCopy.getCompilationUnit();
212
                TreeMaker make = workingCopy.getTreeMaker();
213
                ClassTree clazz = (ClassTree) cut.getTypeDecls().get(0);
214
                MethodTree newMethod = make.Method(
215
                        make.Modifiers(Collections.<Modifier>singleton(Modifier.PUBLIC)),
216
                        "toString",
217
                        make.Type("java.lang.String"),
218
                        Collections.<TypeParameterTree>emptyList(),
219
                        Collections.<VariableTree>emptyList(),
220
                        Collections.<ExpressionTree>emptyList(),
221
                        make.Block(Collections.<StatementTree>emptyList(), false),
222
                        null // default value - not applicable
223
                );
224
                ClassTree copy = make.insertClassMember(clazz, 2, newMethod);
225
                workingCopy.rewrite(clazz, copy);
226
            }
227
        };
228
        src.runModificationTask(task).commit();
229
        editorCookie.saveDocument();
230
        String res = TestUtilities.copyFileToString(testFile);
231
        assertEquals(golden, res);
232
    }
233
160
    /**
234
    /**
161
     * #90424: Guarded Exception
235
     * #90424: Guarded Exception
162
     */
236
     */
163
    public void testAddMethodAfterVariables() throws Exception {
237
    public void testAddMethodAfterVariables() throws Exception {
164
        testFile = new File(getWorkDir(), "Test.java");
238
        testFile = new File(getWorkDir(), "Test.java");
165
        TestUtilities.copyStringToFile(testFile, 
239
        TestUtilities.copyStringToFile(testFile,
166
            "package javaapplication5;\n" +
240
            "package javaapplication5;\n" +
167
            "\n" +
241
            "\n" +
168
            "import java.awt.event.ActionEvent;\n" +
242
            "import java.awt.event.ActionEvent;\n" +
Lines 181-187 Link Here
181
        DataObject dataObject = DataObject.find(FileUtil.toFileObject(testFile));
255
        DataObject dataObject = DataObject.find(FileUtil.toFileObject(testFile));
182
        EditorCookie editorCookie = ((GuardedDataObject) dataObject).getCookie(EditorCookie.class);
256
        EditorCookie editorCookie = ((GuardedDataObject) dataObject).getCookie(EditorCookie.class);
183
        Document doc = editorCookie.openDocument();
257
        Document doc = editorCookie.openDocument();
184
        String golden = 
258
        String golden =
185
            "package javaapplication5;\n" +
259
            "package javaapplication5;\n" +
186
            "\n" +
260
            "\n" +
187
            "import java.awt.event.ActionEvent;\n" +
261
            "import java.awt.event.ActionEvent;\n" +
Lines 199-205 Link Here
199
            "    public void actionPerformed(ActionEvent e) {\n" +
273
            "    public void actionPerformed(ActionEvent e) {\n" +
200
            "    }\n" +
274
            "    }\n" +
201
            "}\n";
275
            "}\n";
202
        
276
203
        JavaSource src = getJavaSource(testFile);
277
        JavaSource src = getJavaSource(testFile);
204
        Task<WorkingCopy> task = new Task<WorkingCopy>() {
278
        Task<WorkingCopy> task = new Task<WorkingCopy>() {
205
279
Lines 216-229 Link Here
216
                        Collections.<VariableTree>singletonList(
290
                        Collections.<VariableTree>singletonList(
217
                            make.Variable(
291
                            make.Variable(
218
                                make.Modifiers(Collections.<Modifier>emptySet()),
292
                                make.Modifiers(Collections.<Modifier>emptySet()),
219
                                "e", 
293
                                "e",
220
                                make.Identifier("ActionEvent"), 
294
                                make.Identifier("ActionEvent"),
221
                            null)
295
                            null)
222
                        ),
296
                        ),
223
                        Collections.<ExpressionTree>emptyList(),
297
                        Collections.<ExpressionTree>emptyList(),
224
                        make.Block(Collections.<StatementTree>emptyList(), false),
298
                        make.Block(Collections.<StatementTree>emptyList(), false),
225
                        null // default value - not applicable
299
                        null // default value - not applicable
226
                ); 
300
                );
227
                ClassTree copy = make.addClassMember(clazz, newMethod);
301
                ClassTree copy = make.addClassMember(clazz, newMethod);
228
                workingCopy.rewrite(clazz, copy);
302
                workingCopy.rewrite(clazz, copy);
229
            }
303
            }
Lines 240-246 Link Here
240
     */
314
     */
241
    public void test119048() throws Exception {
315
    public void test119048() throws Exception {
242
        testFile = new File(getWorkDir(), "Test.java");
316
        testFile = new File(getWorkDir(), "Test.java");
243
        TestUtilities.copyStringToFile(testFile, 
317
        TestUtilities.copyStringToFile(testFile,
244
            "package javaapplication5;\n" +
318
            "package javaapplication5;\n" +
245
            "\n" +
319
            "\n" +
246
            "public class NewJFrame extends javax.swing.JFrame {\n" +
320
            "public class NewJFrame extends javax.swing.JFrame {\n" +
Lines 255-261 Link Here
255
        DataObject dataObject = DataObject.find(FileUtil.toFileObject(testFile));
329
        DataObject dataObject = DataObject.find(FileUtil.toFileObject(testFile));
256
        EditorCookie editorCookie = ((GuardedDataObject) dataObject).getCookie(EditorCookie.class);
330
        EditorCookie editorCookie = ((GuardedDataObject) dataObject).getCookie(EditorCookie.class);
257
        Document doc = editorCookie.openDocument();
331
        Document doc = editorCookie.openDocument();
258
        String golden = 
332
        String golden =
259
            "package javaapplication5;\n" +
333
            "package javaapplication5;\n" +
260
            "\n" +
334
            "\n" +
261
            "public class NewJFrame extends javax.swing.JFrame {\n" +
335
            "public class NewJFrame extends javax.swing.JFrame {\n" +
Lines 267-273 Link Here
267
            "    }//GEN-LAST:event_jButton1ActionPerformed\n" +
341
            "    }//GEN-LAST:event_jButton1ActionPerformed\n" +
268
            "\n" +
342
            "\n" +
269
            "}";
343
            "}";
270
        
344
271
        JavaSource src = getJavaSource(testFile);
345
        JavaSource src = getJavaSource(testFile);
272
        Task<WorkingCopy> task = new Task<WorkingCopy>() {
346
        Task<WorkingCopy> task = new Task<WorkingCopy>() {
273
347
Lines 293-305 Link Here
293
        System.err.println(res);
367
        System.err.println(res);
294
        assertEquals(golden, res);
368
        assertEquals(golden, res);
295
    }
369
    }
296
    
370
297
    /**
371
    /**
298
     * #119962: Guarded Exception
372
     * #119962: Guarded Exception
299
     */
373
     */
300
    public void test119962() throws Exception {
374
    public void test119962() throws Exception {
301
        testFile = new File(getWorkDir(), "Test.java");
375
        testFile = new File(getWorkDir(), "Test.java");
302
        TestUtilities.copyStringToFile(testFile, 
376
        TestUtilities.copyStringToFile(testFile,
303
            "package test;\n" +
377
            "package test;\n" +
304
            "\n" +
378
            "\n" +
305
            "public class NewJFrame extends javax.swing.JFrame {\n" +
379
            "public class NewJFrame extends javax.swing.JFrame {\n" +
Lines 330-336 Link Here
330
        DataObject dataObject = DataObject.find(FileUtil.toFileObject(testFile));
404
        DataObject dataObject = DataObject.find(FileUtil.toFileObject(testFile));
331
        EditorCookie editorCookie = ((GuardedDataObject) dataObject).getCookie(EditorCookie.class);
405
        EditorCookie editorCookie = ((GuardedDataObject) dataObject).getCookie(EditorCookie.class);
332
        Document doc = editorCookie.openDocument();
406
        Document doc = editorCookie.openDocument();
333
        String golden = 
407
        String golden =
334
            "package test;\n" +
408
            "package test;\n" +
335
            "\n" +
409
            "\n" +
336
            "public class NewJFrame extends javax.swing.JFrame {\n" +
410
            "public class NewJFrame extends javax.swing.JFrame {\n" +
Lines 360-366 Link Here
360
            "    public void actionPerformed(ActionEvent e) {\n" +
434
            "    public void actionPerformed(ActionEvent e) {\n" +
361
            "    }\n" +
435
            "    }\n" +
362
            "}";
436
            "}";
363
        
437
364
        JavaSource src = getJavaSource(testFile);
438
        JavaSource src = getJavaSource(testFile);
365
        Task<WorkingCopy> task = new Task<WorkingCopy>() {
439
        Task<WorkingCopy> task = new Task<WorkingCopy>() {
366
440
Lines 377-390 Link Here
377
                        Collections.<VariableTree>singletonList(
451
                        Collections.<VariableTree>singletonList(
378
                            make.Variable(
452
                            make.Variable(
379
                                make.Modifiers(Collections.<Modifier>emptySet()),
453
                                make.Modifiers(Collections.<Modifier>emptySet()),
380
                                "e", 
454
                                "e",
381
                                make.Identifier("ActionEvent"), 
455
                                make.Identifier("ActionEvent"),
382
                            null)
456
                            null)
383
                        ),
457
                        ),
384
                        Collections.<ExpressionTree>emptyList(),
458
                        Collections.<ExpressionTree>emptyList(),
385
                        make.Block(Collections.<StatementTree>emptyList(), false),
459
                        make.Block(Collections.<StatementTree>emptyList(), false),
386
                        null // default value - not applicable
460
                        null // default value - not applicable
387
                ); 
461
                );
388
                workingCopy.rewrite(clazz, make.addClassMember(clazz, newMethod));
462
                workingCopy.rewrite(clazz, make.addClassMember(clazz, newMethod));
389
            }
463
            }
390
        };
464
        };
Lines 394-400 Link Here
394
        System.err.println(res);
468
        System.err.println(res);
395
        assertEquals(golden, res);
469
        assertEquals(golden, res);
396
    }
470
    }
397
    
471
398
    /**
472
    /**
399
     * #119345: Duplicated initComponents() when trying to rename in
473
     * #119345: Duplicated initComponents() when trying to rename in
400
     * the guarded.
474
     * the guarded.
Lines 539-545 Link Here
539
        DataObject dataObject = DataObject.find(FileUtil.toFileObject(testFile));
613
        DataObject dataObject = DataObject.find(FileUtil.toFileObject(testFile));
540
        EditorCookie editorCookie = ((GuardedDataObject) dataObject).getCookie(EditorCookie.class);
614
        EditorCookie editorCookie = ((GuardedDataObject) dataObject).getCookie(EditorCookie.class);
541
        Document doc = editorCookie.openDocument();
615
        Document doc = editorCookie.openDocument();
542
        String golden = 
616
        String golden =
543
                "package crystalball;\n" +
617
                "package crystalball;\n" +
544
                "\n" +
618
                "\n" +
545
                "import org.jdesktop.application.Action;\n" +
619
                "import org.jdesktop.application.Action;\n" +
Lines 673-679 Link Here
673
                "    // End of variables declaration//GEN-END:variables\n" +
747
                "    // End of variables declaration//GEN-END:variables\n" +
674
                "    \n" +
748
                "    \n" +
675
                "}\n";
749
                "}\n";
676
        
750
677
        JavaSource src = getJavaSource(testFile);
751
        JavaSource src = getJavaSource(testFile);
678
        Task<WorkingCopy> task = new Task<WorkingCopy>() {
752
        Task<WorkingCopy> task = new Task<WorkingCopy>() {
679
753
Lines 694-700 Link Here
694
                mst = (MemberSelectTree) invocation.getArguments().get(0);
768
                mst = (MemberSelectTree) invocation.getArguments().get(0);
695
                mst = (MemberSelectTree) mst.getExpression();
769
                mst = (MemberSelectTree) mst.getExpression();
696
                workingCopy.rewrite(mst.getExpression(), make.Identifier("crystalball"));
770
                workingCopy.rewrite(mst.getExpression(), make.Identifier("crystalball"));
697
                
771
698
                var = (VariableTree) stmts.get(16);
772
                var = (VariableTree) stmts.get(16);
699
                invocation = (MethodInvocationTree) var.getInitializer();
773
                invocation = (MethodInvocationTree) var.getInitializer();
700
                mst = (MemberSelectTree) invocation.getArguments().get(0);
774
                mst = (MemberSelectTree) invocation.getArguments().get(0);
Lines 713-722 Link Here
713
        System.err.println(res);
787
        System.err.println(res);
714
        assertEquals(golden, res);
788
        assertEquals(golden, res);
715
    }
789
    }
716
    
790
717
    public void testRenameTypeParameter125385() throws Exception {
791
    public void testRenameTypeParameter125385() throws Exception {
718
        testFile = new File(getWorkDir(), "Test.java");
792
        testFile = new File(getWorkDir(), "Test.java");
719
        TestUtilities.copyStringToFile(testFile, 
793
        TestUtilities.copyStringToFile(testFile,
720
            "package hierbas.del.litoral;\n" +
794
            "package hierbas.del.litoral;\n" +
721
            "\n" +
795
            "\n" +
722
            "public class MyList {\n" +
796
            "public class MyList {\n" +
Lines 733-744 Link Here
733
            "        return null;\n" +
807
            "        return null;\n" +
734
            "    }\n" +
808
            "    }\n" +
735
            "}\n";
809
            "}\n";
736
        
810
737
        DataObject dataObject = DataObject.find(FileUtil.toFileObject(testFile));
811
        DataObject dataObject = DataObject.find(FileUtil.toFileObject(testFile));
738
        EditorCookie editorCookie = ((GuardedDataObject) dataObject).getCookie(EditorCookie.class);
812
        EditorCookie editorCookie = ((GuardedDataObject) dataObject).getCookie(EditorCookie.class);
739
        Document doc = editorCookie.openDocument();
813
        Document doc = editorCookie.openDocument();
740
        JavaSource src = getJavaSource(testFile);
814
        JavaSource src = getJavaSource(testFile);
741
        
815
742
        Task task = new Task<WorkingCopy>() {
816
        Task task = new Task<WorkingCopy>() {
743
817
744
            public void run(final WorkingCopy workingCopy) throws IOException {
818
            public void run(final WorkingCopy workingCopy) throws IOException {
Lines 1008-1014 Link Here
1008
                ((Environment) this.env).removeSaveCookie();
1082
                ((Environment) this.env).removeSaveCookie();
1009
            }
1083
            }
1010
1084
1011
            @Override 
1085
            @Override
1012
            protected CloneableEditor createCloneableEditor() {
1086
            protected CloneableEditor createCloneableEditor() {
1013
                return new CloneableEditor(this);
1087
                return new CloneableEditor(this);
1014
            }
1088
            }

Return to bug 177824