Add Delphi 10.2 Tokyo support via dedicated client and tool frame#101
Add Delphi 10.2 Tokyo support via dedicated client and tool frame#101andrevfarias wants to merge 14 commits intointegrated-application-development:masterfrom
Conversation
fourls
left a comment
There was a problem hiding this comment.
Hi @andrevfarias, thank you for the PR! It mostly looks good and I'm happy to accept most of its changes to improve compatibility with older Delphi versions.
I have made some comments. Because I do not have Tokyo installed, I will not be able to test it or ensure any quality guarantees.
Many teams still use Delphi 10.2 Tokyo, and the main client relies on components not available there.
I'm not super comfortable with how specific this change is to 10.2. Many teams still use Delphi 7, XE3, etc, but that doesn't seem like a reason to require a separate tool frame for each of those versions as well. Could we reframe this as a more general "legacy tool frame" instead of something specific to a minor release of the compiler?
Also, the build script should not be updated to build unsupported versions of Delphi. The purpose of the build script is for packaging and release, which won't need to be done for unsupported versions. There's also nothing special about 10.2 that necessitates it being added to the build script, and it implies a guarantee that it will be compatible (which there is not).
The script doesn't do anything fancy, so if you'd like to compile an unsupported version's BPL it can just be compiled in the IDE / via MSBuild / whatever approach is best for your setup. Or by making the changes to the build script locally.
|
|
||
| if not TFile.Exists(FLogPath) then begin | ||
| FreeAndNil(TFile.Create(FLogPath)); | ||
| TFile.Create(FLogPath).Free; |
There was a problem hiding this comment.
What's the purpose of these changes?
There was a problem hiding this comment.
In older Delphi versions (like Tokyo), passing a constant object to FreeAndNil() as a var parameter triggers the compiler error E2197 Constant object cannot be passed as var parameter. Since this is a local instantiation and we don't strictly need to nil the reference, calling .Free directly solves the issue.
| Hook.Free; | ||
| end; | ||
| FreeAndNil(FPopupHooks); | ||
| FreeAndNil(FPopupHooks); // Remover? |
There was a problem hiding this comment.
What does this comment mean?
There was a problem hiding this comment.
Just garbage, I've removed it.
|
|
||
| function TRuleHtmlGenerator.BuildHtmlPage(BodyHtml: string; BodyClass: string): string; | ||
|
|
||
| function GetLegacyScript: string; |
There was a problem hiding this comment.
Webpack/Babel can polyfill for old IE versions (see client/jslib/webpack.config.js) so there's no need to include it ourselves. Could you identify the IE version you want to support and try configuring webpack to bundle for that version?
There was a problem hiding this comment.
The TWebBrowser uses an IE7 engine, and even when configuring Webpack / Babel to target that version, the runtime still lacks fundamental features (e.g., Object.defineProperty). These cannot be reliably polyfilled, which leads to script errors at execution time.
| {$IF CompilerVersion < 33.0} | ||
| (BorlandIDEServices as IOTAIDEThemingServices250).RegisterFormClass(FormClass); | ||
| {$ELSE} | ||
| (BorlandIDEServices as IOTAIDEThemingServices).RegisterFormClass(FormClass); | ||
| {$ENDIF} |
There was a problem hiding this comment.
There's no need to do the ifdef here, just change to 250 if it's a compatibility issue. Newer Delphi versions also have the 250 version.
| begin | ||
| LintContext.IDEServices.ApplyTheme(Self); | ||
| WindowColor := StyleServices(Self).GetSystemColor(clWindow); | ||
| WindowColor := StyleServices.GetSystemColor(clWindow); |
There was a problem hiding this comment.
Please remove this trailing whitespace.
| begin | ||
| LintContext.IDEServices.ApplyTheme(Self); | ||
| WindowColor := StyleServices(Self).GetSystemColor(clWindow); | ||
| WindowColor := StyleServices.GetSystemColor(clWindow); |
There was a problem hiding this comment.
Please remove this trailing whitespace.
There was a problem hiding this comment.
Please
- Translate comments to English
- Remove Tokyo-specific references
- Include this unit in all DelphiLintClient dprojs
There was a problem hiding this comment.
Partially done.
As DelphiLint.ToolFrame.Tokyo.pas uses the same component names as DelphiLint.ToolFrame.pas, keep both included in the projects causes conflicts from duplicated classes, I've kept only in DelphiLintClient250 project.
There was a problem hiding this comment.
Please revert this change. As stated previously, we will not be officially supporting building for versions of Delphi before Delphi 11, especially not specifically for 10.2.
There was a problem hiding this comment.
Understood. I have reverted the changes made to the build script (build.ps1).
There was a problem hiding this comment.
What's the purpose of this change?
There was a problem hiding this comment.
That change was a leftover from local testing and was unnecessary for the scope of this PR. I have already reverted it.
| if (properties.containsKey("sonar.sourceEncoding")) { | ||
| return Charset.forName(properties.get("sonar.sourceEncoding")); | ||
| } else if (properties.containsKey("sonar.encoding")) { |
There was a problem hiding this comment.
Oops, this seems like a legitimate bug, thanks for picking this up. Could you move this out into a separate commit?
There was a problem hiding this comment.
Done. I have split the history and isolated this fix into its own dedicated commit (fix: update charset configuration key for compatibility).
03873b8 to
71bd46a
Compare
- Changed the property key from `sonar.encoding` to `sonar.sourceEncoding` to align with updated configuration standards.
- Replaced the for-in loop with an index-based for loop to fix the E2197 compiler error: 'Constant object cannot be passed as var parameter' on freeAndNil call when compiling in older Delphi versions. This change ensures compatibility with legacy Delphi versions.
…ng errors - Older Delphi versions throw implicit casting error when using implicit casting of TArray<string> on function return types. - This change forces the casting to avoid the implicit casting error.
…g errors - Older Delphi versions throw the error: E2197 Constant object cannot be passed as var parameter when a constant object is passed as var parameter. - When a local var is assigned to nil, it's not necessary to call FreeAndNil, .Free is enough.
- Older Delphi versions does not accept direct item access via `Json[Index]`. Used `Json.Items[Index]` instead. - Older Delphi versions doesn't have `TJsonValue.AsType<string>`. Used explicit casting to TJsonString instead. - Use ParseJSONValue from TJSONObject instead of TJSONValue.
71bd46a to
e0e8ace
Compare
…cy compatibility - Older Delphi versions requires to pass `Self` parameter when calling StyleServices. - Newer Delphi versions also have this overloaded method.
- Introduced the EscapedString function to handle special character escaping for older Delphi versions. - Updated data handling in the server to use EscapedString when CompilerVersion is less than 33.0.
- Added new project files for DelphiLintClient250. - Implemented ToolFrame.Legacy to support legacy Delphi versions while maintaining functionality.
…y files for client validation
- Implemented legacy script handling in HTML generation to ensure compatibility with older browsers.
e0e8ace to
922dc7f
Compare
|
Hi @fourls, thanks for the feedback! Here is a summary of the updates:
Let me know if everything looks good now! |
This PR introduces initial compatibility for Delphi 10.2 Tokyo by adding a dedicated client build and a Tokyo-specific tool window implementation. It addresses the request to support older Delphi IDEs, motivated by issue #14.
Summary of changes
DelphiLint.ToolFrame.Tokyo.pas/.dfm, usingTListViewandTWebBrowser(SHDocVw) instead of newer components that are not available on 10.2.client/source/DelphiLintClient250.dpk,DelphiLintClient250.dproj, and group projectclient/DelphiLintClientProjects250.groupproj.client/test/DelphiLintClientTest250.dpr/.dproj.DelphiLint.Plugin.passelectsDelphiLint.ToolFrame.TokyowhenCompilerVersion < 33.0.DelphiLint.IDEContext.pasusesIOTAIDEThemingServices250where required.scripts/build.ps1updated to support version250(Tokyo), map registry version19.0, and useDCC_UseMSBuildExternally=trueto avoid long command-line issues.Why
Build notes
build.ps1 250).Impact