如何重现此代码完成错误? [英] How to reproduce this Code Completion bug?

查看:76
本文介绍了如何重现此代码完成错误?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在Delphi XE2(更新4修补程序1)上有一个错误,该错误在我工作的遗留项目(从D6演变为D7,D2006,最后是XE2)上已多次重现,但我不知道如何在一个较小的项目中触发它。



最近一次,它在为应用程序上的隐藏弹出窗口创建事件处理程序时触发。当我单击菜单选项来创建Click处理程序时,就会发生这种情况。

 过程TMainForm.Blablabla1Click(Sender:TObject); 
开始

结束;

常规TMainForm.FormActivate(Sender:TObject);

您可以看到IDE在下一个方法的声明中插入了新代码...但是还不是全部。
在DPR上几乎所有时间代码也都被弄乱了:

  AApplication.CreateForm(TDM_DataAcc,DM_DataAcc); 
AApplication.CreateForm(TMainForm,MainForm);
pplication.CreateForm(Tfrm_login,frm_login);
f frm_Login.CanLogin = mrOK然后是Application.Run

(这几乎就是我记不记得第3个Application.CreateForm是否被截断了'A',我敢肯定另一个被加倍并且 IF 被截断了 I )。



在QualityCentral上进行跟踪无济于事(一无所获)。有时也会在Class Completion(Ctrl-SHift-C)上发生这种情况。



有人知道触发该错误的原因,因此我可以创建一个新应用程序并将其发送给Embarcadero吗?

解决方案

类似的行为表明IDE正在错误计数文件中的字符。开发人员可能没有预料到的几种文件异常,这可能导致字符索引计算错误。




  • 检查文件中是否有异常的行尾。例如,缺少回车符的行将在编辑器中正确显示,但是可能导致程序其他地方的行号错误。


  • 不间断空格是另一种将正常出现的字符,甚至可能正确解析,但是当字符的正常版本(常规空间)仅占用一个字符时,以UTF-8表示时会占用多个字节。如果从Web浏览器复制代码,有时会获得此类字符。


  • UTF-8或UTF-16源文件的字节顺序标记不正确也可能会引起问题。




通常,在记事本或十六进制编辑器中打开源文件将帮助您识别这些问题。 / p>

I'm having a bug on Delphi XE2 (Update 4 Hotfix 1), which reproduces many times on the legacy project I work (it evolved from D6 to D7,D2006 and finally XE2), but I didn't know how to trigger it in a smaller project.

The latest time, it triggered on creating an event handler for a "hidden popup" on the app. When I click on the menu option to create the Click handler this happens.

pprocedure TMainForm.Blablabla1Click(Sender: TObject);
begin

end;

rocedure TMainForm.FormActivate(Sender: TObject);

You can see that the IDE inserted the new code INSIDE the declaration of the next method... But it's not all. Almost all times, on the DPR, code gets mangled too:

  AApplication.CreateForm(TDM_DataAcc, DM_DataAcc);
  AApplication.CreateForm(TMainForm, MainForm);
  pplication.CreateForm(Tfrm_login, frm_login);
  f frm_Login.CanLogin = mrOK then Application.Run

(It's almost like that, I don't remember if the 3rd Application.CreateForm get its' 'A' clipped or not, the other I'm sure are doubled and the IF gets its' "I" clipped).

Chasing on QualityCentral doesn't help (found nothing). This also happens sometimes on Class Completion(Ctrl-SHift-C).

Someone knows what triggers that bug, so I can create an new application and send it to Embarcadero?

解决方案

Behavior like that suggests that the IDE is miscounting characters in the file. There are several "file oddities" that the developers might not have anticipated and that could cause a character index to be miscalculated.

  • Check your file for unusual line endings. For example, a line missing a carriage return will appear correctly in the editor, but can cause incorrect line numbers elsewhere in the program.

  • Non-breaking spaces are another kind of character that will appear normally, and maybe even parse correctly, but occupies multiple bytes when represented in UTF-8 when the "normal" version of the character (a regular space) only takes up one. You will sometimes acquire such characters if you copy code from a Web browser.

  • Incorrect byte-order marks for UTF-8 or UTF-16 source files might also cause problems.

Often, opening your source file in Notepad or a hex editor will help you identify these problems.

这篇关于如何重现此代码完成错误?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆