IceCold
IceCold

Reputation: 21154

Delphi XE shows at least 200 errors but the program compiles just fine

My brand new Delphi XE shows hundreds of errors in 'Structure' panel. It shows errors like 'Undeclared FileExists at line 130' or 'Undeclared Create at line 242'. Even if it shows those errors, the program compiles just fine.

I also see that code insight is not always working. When I move the cursor over a variable, the cursor starts to flicker and no pop-up appears. Other times, it just highlight some units in red and it says the it cannot find them.

There are tricks to fix all these issues?


Update/Pseudo-fix:
I have found that restarting the IDE helps for a while.
I really help that one day Embarcadero will release Delphi ST (from STable).
:)

Upvotes: 12

Views: 4759

Answers (6)

NeoPOS
NeoPOS

Reputation: 136

Copy and pasting the pas file into Notepad, clearing the pas file, saving, closing the IDE, opening the IDE then copying from notepad and pasting back to the pas file worked for me.

Upvotes: 0

Nihat Erim inceoğlu
Nihat Erim inceoğlu

Reputation: 66

We noticed why problems occur. If there are some invalid invisible chars exist in code, this shows as error. These invalid chars sometime occurs when you copy some text and paste in delphi editor. Then, sometimes delphi paste text with invalid chars!

enter image description here

First you should copy all errored text and paste it on notepad++. enter image description here

You will see that all text you copied will not be pasted as well. You will see that corrupted text. You should look at code pasted, determine which code pasted as text. You should look which code could you see on notepad as pasted last char.

enter image description here

here we can see on picture captured: " RoutePatternObject); " so after these chars some invalid characters occur here but we can not see!

So we select these text area after " ; " character. Then delete and retype deleted codes again!

enter image description here

All red underline signatures will disappear!

enter image description here

Upvotes: 2

Alex T
Alex T

Reputation: 415

It appears that much of the Error-Insight problems go away if you keep your library entries up to date.

This is was once pointed out by someone AGES ago on problem report for an earlier Delphi version and no-one seems to have picked up on it. If error-insight encounters a non-existent file in the LIBRARIES list it appears to just stop looking any further - leaving those annoying red-line squiggles everywhere! Trouble was, that problem report had so many entries everyone seems to keep missing that solution!

Go to Tools-Options and find the LIBRARY tab. Go through the lists and eliminate every entry that is ABSOLUTE but INVALID. You probably can and initially should leave any that have variables in them like $(BDSLIB) even if invalid, but definitely start by removing invalid ones that are declared without variables (which is what I mean by absolute). If you are gung-ho and just let Delphi auto-delete the invalid ones, all those with "unfulfilled" variables will disappear too - and that will break many things (this is another Delphi bug discussed elsewhere in this forum I believe). You may also have to repeat this with the Project-Options libraries, but be more circumspect here if the project came from someone else!

If that doesn't do the job immediately, then use the appropriate options tab to toggle the Error-Insight checkbox off and then back on again (closing the options dialog each time). That should get rid of any cached stuff, if such exists.

Deleting just some invalid entries worked for me on Delphi XE4.

Upvotes: 2

Kapytanhook
Kapytanhook

Reputation: 856

I have had the same errors before and i asked the same question, this was the reply: From another post:

You did not make a mistake. The problem is that the there are three compilers in XE2 (like in previous versions of Delphi): the real compiler (which works fine), the Code Insight compiler (which is faster), the Error Insight compiler (which must be even more faster), and the syntax highlighting parser (which is the fastest).

XE2 introduced a number of features that made the normal compiler slower, and gave the Code Insight and Error Insight compilers a bit of trouble. First of all, we have the new targets: Win32, Win64 and OSX which cause the search paths to be different for each target (see $PLATFORM directive), as well as build configuration, although there is only one "Library path" for each PLATFORM (and not for the build configurations).

The second complexing factor is the dotted unit names (scoped unit names) that were introduced. Windows is no longer Windows, but Winapi.Windows.

My guess is that these two additional complexing factors cause problems for the Code Insight and Error Insight compilers. Note that the real compiler still works. But the Error Insight shows incorrect errors, and the Code Insight doesn't always work for these units.

You could try to explicitly add them to the project again (in which case the full path will be used, like you mention in your question on stack overflow as well).

What I found out was:

  1. 99% of the errors are due to edited files not being save right (including references)
  2. If you add profiles Save your .dpr, .dproj, .pas, .dfm files (save unit, save project)
  3. If all fails a save + restart will usually fix it
  4. For older projects delete the .res file, it has botched paths, Delphi will recreate it.

(Sorry for the bad initial post, Just got a Stackoverflow account, was not allowed to edit it. I hope this will suffice)

Upvotes: 0

Ondrej Kelle
Ondrej Kelle

Reputation: 37211

For me it usually helps to close the project and re-open it; the structure errors disappear.

Upvotes: 4

Mason Wheeler
Mason Wheeler

Reputation: 84550

Yeah, CodeInsight and ErrorInsight are known to have lots of problems. They've gotten a bit better each version for a while now, but there's still a lot to be done. Andreas Hausladen, who's probably the smartest guy in the Delphi community, has done a lot of poking around in the IDE internals, and he says they have race condition-based bugs that probably can't be fixed without a total rewrite.

If these fake errors are giving you trouble, you can probably disable them, as Ken mentioned in his comment.

Upvotes: 9

Related Questions