Water . 2293: IDE Bug when Completing classes


(Michael Thuma) #1

Steps to reproduce:
a) Create a class in a module that uses interface and implementation section
b) Add a method
c) Complete the class Crtl + Shift C
d) Rename the method
d1) Don’t remove the old implementation (the method name can no longer be found in the classes interface)
e) complete the class Crtl + Shift C

IDE is no amused but will continue to perform well after pressing Continue … (an exception is thrown)

(marc hoffman) #2

Sorry, but I’ve stopped tarrying to reproduce bug descriptions that make me guess what the bug might be, because it usually ends up with me not reproducing the issue because a step is missing, and going on.a child goose chain assuming what problem I’m lookin for

What exactly goes wrong?

(Michael Thuma) #3

What goes wrong?

The IDE throws an exception.

You declare a method in the interface. Implement it, maybe via completing a class. Change the method signature (name) and complete class. Water throws an exception.

If you delete the methods implementation before completing the class it works.

This sounds litte strange but can happen and I think in very rare cases, but maybe by accident.

(marc hoffman) #4

Ok, what’s the exception? Can I see a concrete testcase?

(Michael Thuma) #5

The Exception

Index was outside the bounds of the array.
at System.String.get_Chars(Int32 index)
at RemObjects.Fire.CodeEditor.FCECanvasCodeSnippet.rangeOfIdentifierAtCursorX____y(Int32 x, Int32 y)
at RemObjects.Fire.CodeEditor.FCECanvasCodeSnippet.makeSoftSelectionAtCursorX____y__expandBeyond(Int32 x, Int32 y, Boolean expandBeyond)
at RemObjects.Fire.CodeEditor.FCECanvasCodeSnippet.makeSoftSelectionForPopup(Boolean expandBeyond)
at RemObjects.Fire.CodeEditor.FCECanvasCodeSnippet.initiatePopupWithMessage____withSoftSelection(String message, Boolean withSoftSelection)
at RemObjects.Fire.CodeEditor.FCECanvasCodeSnippet.initiatePopupWithMessage(String message)
at RemObjects.Fire.CodeEditor.FCECanvasCodeSnippet.refactorCallback______action(FCERefactoringResults results, FCECodeEditorSmartsFeedback feedback, Action`1 action)
at RemObjects.Fire.CodeEditor.FCECanvasCodeSnippet.b__0(FCERefactoringResults results, FCECodeEditorSmartsFeedback feedback)
at RemObjects.Fire.ProjectSystem.TextFile.<>c__DisplayClass82.b__4()
at System.Windows.Threading.ExceptionWrapper.InternalRealCall(Delegate callback, Object args, Int32 numArgs)
at System.Windows.Threading.ExceptionWrapper.TryCatchWhen(Object source, Delegate callback, Object args, Int32 numArgs, Delegate catchHandler)

The Code:

namespace ca;


type TMike = class
method DoSomething: Integer;
method DoSomething2 : integer;


method TMike.DoSomething: Integer;


method TMike.DoSomething2: Integer;



a) I added method DoSomething : Integer;
c) added constructor
d) changed the method’s name to DoSomething2

Complete Class (CRTL + Shift + C). That moment the exception is thrown

method DoSomething was shifted from the public to the private section
and the code for the constructor was not added but the one for the functions name.

(no idea why the sentence above is formatted that way (sorry)

ca.zip (62.1 KB)

(Michael Thuma) #6

Maybe it has something to do with the constructor. Not totally certain about the impact of the constructor keyword or just the presence of a second method.

Class completion also works if I add the sole constructor keyword before and after the method name. I do have the impression that if no implementation of the procedure can be found even such an error prone case is handled the correct way.

In the just normal case changing a methods name and completing a class works. Both implementations can be found. One remains and the the new is added.

Anyway existing declarations are moved to the private section. In this specific test case it’s method DoSomething. In the case the thread is about one method whose signature did not change was moved to the privat section. (irrc).

(marc hoffman) #7

Doesn’t repro here —which is the entire realism I’m being anal out his this is being reports. Please send me an exact project that reproduces this, and the exact position in code where you invoke Complete Class.


(Michael Thuma) #8

No Problem. Added the most minimalist case

Open the file (maybe add it to a command line solution).
Move to the line method DoSomething
Complete Class
-Should work
Change the name of DoSomething to DoSomething2
Excepetion should occur

a) Code completion for constructor fails even in case of no exception (could be the origin)
b) method DoSomething completed correctly
c) After modifying methods’s Name to DoSomething2 the Water IDE creates the implementation for DoSomething2 and
c1) adds the declaration of DoSomething to the private section (ok that makes sense now, but I didn’t expect that)
d) don’t get confused, also methods deleted (both interface and implementation) can show up in the private section.

Codefile3.pas (173 Bytes)

(Michael Thuma) #9

Another funny thing happend too but not this time, just last time and only once. The Delphi IDE tried to open up and crashed with a code fragment in an editor window pretty similar to a part of the class.

I hope the exception you see does origin from Water, but I’m pretty sure it does.