![]() |
AW: Neuer FixInsight ist da!
Thank you for your reply.
Regarding excluding code from being checked, you mean like this? Take this:
Delphi-Quellcode:
Do you think it would also be possible to further specify which warning or convention to ignore? In this case, I'd only like to ignore a W519 but lose all the other cool warnings and conventions as well.
unit SomeUnit;
interface type TParent = class procedure someVirtualMethod(); virtual; end; TChild = class(TParent) procedure someVirtualMethod(); override; end; implementation { TParent } procedure TParent.someVirtualMethod(); begin WriteLn('Quack!'); end; { TChild } {$IFNDEF _FIXINSIGHT_} procedure TChild.someVirtualMethod(); begin // No quack at all end; {$ENDIF _FIXINSIGHT_} end. |
AW: Neuer FixInsight ist da!
Zitat:
For using the same technique it would require multiple parses for each rule or including ifdefs into the AST which currently is not the case. A different approach could be ![]() But using attributes for such purpose will lead to W1025 when compiling that code unless you add a unit with dummy attributes. Edit: Ok, maybe a combination of both could work... something like this:
Delphi-Quellcode:
{$IFDEF _FIXINSIGHT_}[SuppressRule(W519)]{$ENDIF}
procedure TChild.someVirtualMethod(); begin // No quack at all end; |
AW: Neuer FixInsight ist da!
Zitat:
We have a similar problem when dealing with string constants and localization tools automagically extracting those from the sources. It is quite common for these tools to accept a special formatted comment to ignore such a constant. If you scan the Delphi source you will find lots of comments like
Delphi-Quellcode:
which are valid for the current line. Perhaps we can have a similar approach for FixInsight warnings.
{ Do not localize }
Delphi-Quellcode:
As the comment lies inside the method implementation the scope should be obvious. Depending on the nature of any rule other intrinsic scopes may be appropriate.
procedure TChild.someVirtualMethod(); { FIXINSIGHT: SuppressRule(W519) }
begin // No quack at all end; |
AW: Neuer FixInsight ist da!
Zitat:
In the end we want to find bad code and not put suppress rule directives all over the place, right? Zitat:
To my knowledge FI works on the generated AST. Anything that is not part of that AST cannot be taken into consideration. |
AW: Neuer FixInsight ist da!
Zitat:
Regarding your second question about ignoring only a specific warning Stefan is right, it's not a trivial task. I'm thinking about implementing this though. Zitat:
Delphi-Quellcode:
It's still not trivial, but I think I can handle this directives in DelphiAST by adding a certan attribute to all syntax nodes between $FIOFF and $FION. Not in DelphiAST itself of course, but it is possible to inherit it and override a few methods. And as you have mentioned above, attributes is another option.
{$FIOFF W509}
procedure Method; begin end; {$FION W509} |
AW: Neuer FixInsight ist da!
I don't know about this DelphiAST, but what about the other way around? Just parse as you always do. We now have a list of warnings and the line number it occurred on.
So in case the code goes like this
Delphi-Quellcode:
, there is a W519 raised for line 25. Now before outputting our results to the IDE's listbox, let's check line 25 whether it contains a comment with an exclamation mark followed by "W519".
25: procedure TChild.someVirtualMethod();
26: begin 27: // No quack at all 28: end; So if the code is like
Delphi-Quellcode:
, there will be no "false positive".
25: procedure TChild.someVirtualMethod(); //!W519 because FixInsight is smart
26: begin 27: // No quack at all 28: end; |
AW: Neuer FixInsight ist da!
Nice idea :)
|
AW: Neuer FixInsight ist da!
This could even be expanded to the whole unit scope (for example for 3rd party units, where only the first line would have to be modified then):
Delphi-Quellcode:
unit Example; //!W519 (cannot be fixed because of...)
... |
AW: Neuer FixInsight ist da!
Zitat:
|
AW: Neuer FixInsight ist da!
Ab welcher Delphi Version kann man das einsetzen?
Ab welcher Windows Version funktioniert das Tool? @freimatz: Ist das gefixte Tool im Link die Demo- oder die Vollversion? |
Alle Zeitangaben in WEZ +1. Es ist jetzt 05:46 Uhr. |
Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
LinkBacks Enabled by vBSEO © 2011, Crawlability, Inc.
Delphi-PRAXiS (c) 2002 - 2023 by Daniel R. Wolf, 2024-2025 by Thomas Breitkreuz