PeterPanettone 186 Posted October 20 In the Delphi code editor, I would like to convert a selected type name to its fully qualified type name (TMemo -> Vcl.StdCtrls.TMemo). Is this possible with GExperts? It would be nice if there were a GExperts keyboard shortcut to achieve that! 1 Share this post Link to post
PeterPanettone 186 Posted October 20 The Problem: If the type name isn't already in a uses clause, then: The IDE's ToolsAPI can't resolve it (it doesn't know where to find it) RTTI can't help either - RTTI only works with compiled types that exist at runtime You can't get RTTI information for a type that hasn't been compiled into your project yet The Real Challenge: To convert TMemo → Vcl.StdCtrls.TMemo Without it being in the uses clause, you would need to: Search all available units in the library paths Parse each unit's interface section to find where TMemo is declared Build an index/database of TypeName → Unit.TypeName mappings Possible Approaches: 1. Pre-built Database/Index Create a comprehensive index of all VCL/FMX/RTL types Map: TMemo → Vcl.StdCtrls.TMemo Store as a lookup table Problem: Needs updating with each Delphi version 2. Parse Library Source Files Scan all .pas files in RAD Studio's source directories Extract type declarations Build the mapping dynamically Problem: Slow, requires parsing thousands of files 3. Use Delphi's Code Insight Database RAD Studio maintains a code insight database (.dci, .dcpil files) This might contain the information we need Problem: Proprietary format, not officially documented 4. Use the Language Server Protocol (LSP) Newer Delphi versions have LSP support LSP can provide symbol information Problem: Still requires the symbol to be "known" to the project 5. Hybrid Approach Maintain a static lookup table for common VCL/FMX/RTL types Fall back to ToolsAPI for project-specific types that are already in uses Best practical compromise Reality Check: Without the type being in the uses clause, you essentially need to: Know where every type in Delphi is declared (millions of types across all libraries) Build and maintain this knowledge base This is why professional tools like ReSharper for Delphi or ModelMaker invest significant effort into building and maintaining type databases. Practical Solution: For a lightweight IDE expert, the most practical approach would be: // If type is in uses clause → use ToolsAPI to resolve // If type is NOT in uses clause → use static lookup table for common types // Otherwise → prompt user or fail gracefully Share this post Link to post
PeterPanettone 186 Posted October 20 Realistically, how much time would be needed to search all available units in the library paths? RAD Studio 12 typical installation includes: ~2,000-3,000 .pas files in standard library paths VCL: ~500-600 units FMX: ~400-500 units RTL: ~300-400 units Additional libraries (Indy, etc.): ~1,000+ units Parsing Approach: type TMemo = class(TCustomMemo) **Time estimates:** 1. **First-time full scan (cold):** - Read ~3,000 files from disk - Parse/search for type declarations - Build index database - **Estimated time: 5-30 seconds** (depending on disk speed, SSD vs HDD) 2. **Subsequent uses (cached):** - Load pre-built index from disk - **Estimated time: 0.1-1 second** 3. **Smart approach with file monitoring:** - Only re-scan changed files - **Incremental update: <1 second** ## Optimization Strategies: **1. Index Once, Use Many Times:** - Build index at IDE startup (background thread) - Save to disk - Reload on subsequent starts - Update only when files change **2. Multi-threaded Parsing:** - Parse files in parallel - Modern CPUs with 8+ cores could process this very quickly - Could reduce 30 seconds to 5-10 seconds **3. Smart Parsing:** - Only parse "interface" section (ignore implementation) - Use simple regex/text search instead of full parsing - Skip units that don't contain "type" keyword **4. Progressive Enhancement:** - Start with common VCL/FMX types (pre-indexed, instant) - Lazy-load other units on demand - Background thread continues building full index Share this post Link to post
Uwe Raabe 2271 Posted October 20 1 hour ago, PeterPanettone said: Realistically, how much time would be needed to search all available units in the library paths? Perhaps Stefan Glienke may give some answers to that: Introducing Delphi Uses Helper 1 Share this post Link to post
dummzeuch 1763 Posted October 20 RegEx is too slow to use in this kind of text processing (I know, because the GExperts Uses Clause Manager does exactly that for the Identifer tab.) 1 Share this post Link to post
PeterPanettone 186 Posted October 20 (edited) 59 minutes ago, dummzeuch said: RegEx is too slow to use in this kind of text processing (I know, because the GExperts Uses Clause Manager does exactly that for the Identifer tab.) Thanks for the hint. The Uses Clause Manager in GExperts has a lot of Potential. Some time ago, I used its Identifiers tab very often, but now it seems it is no longer capable of finding the declaring unit of the simplest identifiers. Can this be tweaked? Its configuration dialog seems to be broken (even in r4878 !): Also, the general Configuration dialog GUI font size is broken: Edited October 20 by PeterPanettone Share this post Link to post
pyscripter 891 Posted October 20 (edited) 2 hours ago, dummzeuch said: RegEx is too slow to use in this kind of text processing (I know, because the GExperts Uses Clause Manager does exactly that for the Identifer tab.) Are you using precompiled regular expressions with Study and in the recent few versions of Delphi JIT (Since 11.2)? They should be faster than anything else. See pyscripter/Pcre-Jit-Delphi: Improve Delphi's System.RegularExpressions by enabling PCRE JIT compiler https://quality.embarcadero.com/browse/RSP-21733 Edited October 20 by pyscripter Share this post Link to post
PeterPanettone 186 Posted October 21 16 hours ago, pyscripter said: pyscripter/Pcre-Jit-Delphi: Improve Delphi's System.RegularExpressions by enabling PCRE JIT compiler From Instructions: "The script assumes you have Delphi 10.4 installed." Share this post Link to post
PeterPanettone 186 Posted October 21 16 hours ago, pyscripter said: https://quality.embarcadero.com/browse/RSP-21733 Was fixed in 10.3 Rio (?) Share this post Link to post
pyscripter 891 Posted October 21 12 minutes ago, PeterPanettone said: Was fixed in 10.3 Rio (?) As the report says JIT support was added in Delphi 11.2. 17 minutes ago, PeterPanettone said: From Instructions: "The script assumes you have Delphi 10.4 installed." Full instructions: You then need to create the patched System.RegularExpressionsAPI.pas file in the Source directory (it is not in the repository due to licensing restrictions). The PowerShell script PatchRegularExpressionsAPI.ps1 does that. It copies the unit from the Delphi installation direcotry into the Source directory and then applies the patch "RegularExpressionsApi.diff" located in the same directory. Git needs to be accessible from the command line for this to work. The script assumes you have Delphi 10.4 installed. If not, you can manually apply the patch by studying RegularExpressionsApi.diff, which is relatively easy (small number of changes). 1 Share this post Link to post