OmniPascal is now able to resolve symbols in with statements. There are a few bugfixes too: – DocumentSymbolProvider is faster in units with overloaded methods – DocumentSymbolProvider works better in units with attributed types – Parser doesn’t fail on external constants
After quite a long time there’s a new version available. There are two new features helping you to stay focused:
1. Symbol creation suggestions
Type the name of a new variable, field or method and use it would have already been declared. When you’re done place the cursor inside the name. OmniPascal will try to find possible declarations for the new symbol. You only need to pick one from the lightbulb.
2. Automatic uses suggestions
Type the name of the class or function you want to use. If the name can’t be resolved in the current scope a lightbulb pops up offering you to add the corresponding unit automatically. No need to add it manually or perform a global search just to find out where it is declared.
How does it work?
On startup the workspace will be indexed. OmniPascal (partially) will parse all pascal files and create an in-memory-index of all symbols in the global scope. With this index OmniPascal can provide uses suggestions almost instantly. The first run may take longer as it creates a file cache so that future starts are faster. You can choose whether you want to have indexed – the workspace – or the entire search path including system units.
As a side effect of the new symbol index the “Go to Symbol in Workspace”-feature has also been implemented with this release. You can jump to any indexed symbol by just typing its name.
ChangeLog
– Automatic declaration of variables, fields and methods – The new setting “omnipascal.symbolIndex” defines the locations to be indexed – Implemented workspace symbol provider (working on the new symbol index) – Automatic uses suggestion – The new setting “omnipascal.usesListStyle” defines how new uses entries are being added to the uses sections (one item per line or multiple items per line) – The new setting “omnipascal.namingConventionString” defines whether the String type is being offered as “String” or “string” in code completion and hints – Code completion on type names offers static accessible symbols only – Improved parser speed – tasks.json generated when loading a project is now version 2.0.0 – Bugfix: Method calls with negative constant literals sometimes resolved to unsigned integer types instead of signed types – Bugfix: Failed to load projects where a property was declared multiple times within the same property group – Bugfix: Generated Lazarus build scripts contain workaround to nothing-to-do-bug
This release brings a lot of improvements regarding understanding of language features as well as bugfixes. Read the complete change log:
Enhancement: Resolving calls to overloaded methods works much better now. In previous releases calls to overloaded methods were resolved to the first method that could be called with the given amount of arguments. Now OmniPascal takes the types of the arguments into account.
Enhancement: Added support for methods with generic parameters and basic type inference
Change: Types and methods appear with generic parameters in code completion
Enhancement: When a code completion item with generic parameters is selected then the first generic parameter is marked and can be changed immediately. You can jump to the next generic parameter using tab
Enhancement: Go-to-definition works (as good as possible) on method calls even when the amount of arguments doesn’t match the method’s signature
Change: Go-to-definition performed on a parameter now jumps to the method’s declaration if possible instead of the implementation
Enhancement: The parser is much more tolerant with FreePascal source files. It no longer crashes on keywords like generic, specialization and constref. Code completion works much better in FPC project.
Enhancement: Code completion works on variables of a generic constrained type
Enhancement: All classes implicitly inherit from System.TObject. All interfaces implicitly inherit from System.IInterface. In the past Calls to SomeObject.Free could only be resolved if the object’s class inherits implicitly from TObject.
Enhancement: Code completion items have more different symbols now based on their kind
Enhancement: Code completion items are ordered by relevance. In the past they were ordered alphabetically
Change: Minor changes of symbols shown in the list of document sybols
Enhancenment: Default namespaces are loaded from DPROJ files
Enhancement: Values of scoped enums no longer appear in general code completion
Bugfix: Automatic regeneration of build scripts didn’t work on Windows when the loaded project file changed
Bugfix: Parser crashed when attempting to include a file with BOM header
Bugfix: Go-to-definition of a symbol defined in an included file didn’t work
Bugfix: Method calls like “read()” or “write()” are no longer displayed as keywords (at least when followed by round brackets)
Bugfix: Calls to full qualified type members are now resolved properly
Bugfix: When a pointer to a record type was declared before the record then the record’s members didn’t appear in code completion when triggered for a variable of the pointer type.
Bugfix: Unit’s created via the lightbulb’s quickfix “Create new unit” were displayed with an error saying the unit name was wrong.
Bugfix: Automatic interface implementation no longer adds include files to uses
Bugfix: External methods didn’t appear in code completion
Bugfix: OmniPascal did become very slow when huge files with a lot of overloaded methods (like System.SysUtils) were opened in VSCode
Bugfix: Creating warnings for missing method implementations was very slow when a file had a lot of overloaded methods
Bugfix: Indexed access on arrays returned from methods didn’t work
Bugfix: Generic type parameters no longer appear in the list of document symbols
Bugfix: Correct handling of visibility sections in record types
Bugfix: Removed squiggly lines for unresolvable uses entries coming from an included files. They showed up as ghost erros in areas without matching text.
Bugfix: Generic type parameters did show up in derived classes’ code completion
Bugfix: The Result variable has now the correct type inside anonymous functions
Improved performance for code completion and symbol resolving. Much better performance of multi threaded operations.
OmniPascal has finally arrived on Mac and Linux! All the features you know from the Windows version are now available also on Unix like operating systems. These are:
Code completion
Go to declaration
Outlining
Automatically implement methods and interfaces
Add units to uses without scrolling
Load search path from project files
Auto generate build and run scripts from Lazarus and Delphi* projects for compiler integration into VSCode
Please keep in mind that the built in Pascal parser has support for Delphi syntax only. So you won’t see great support for ObjectPascal source files using a different dialect. That may change in the future.
*Build scripts for Delphi projects work on Windows only
Please ensure your system allows execution of software from any location!
If you have any problems getting started then please create a bug report, ask on StackOverflow or create a comment under this blog post.
Since this is the first release of OmniPascal for Mac and Linux it’d be a surprise if everything was working right from start.
Release notes
First release of OmniPascal for Mac and Linux (64 bit)
Change: Generated build and test tasks now run in VSCode’s new terminal runner. That fixes the bug of infinite test runs when the application is waiting for user input via Read/ReadLn.
Enhancement: The project file picker now also lists .dproj and .lpi files
Bug fix: The project file picker was incomplete when opened right after starting the editor
Enhancement: Improved recognition of file encoding when no BOM is present
Bug fix: sometimes OmniPascal forgot the where Delphi is installed
Bug fix: Code completion now works in DUnitX tests
Bug fix: Interface implementations via resolution clauses in generic types were not recognized
Bug fix: Occasionally wrong missing interface implementation warning for derived classes where the base type implements an interface in the private section in a different file
You are now able to load a project file in Visual Studio Code. You can either click the new OmniPascal project indicator in the status bar or execute the new command OmniPascal: Load project. Pick a .dpr, .dpk, .lpr or .lpk file to open it. When it’s done you will see the currently loaded project file in the status bar.
The search path will be adjusted automatically when you open a project file.
If the new setting omnipascal.createBuildScripts is set to true (it’s false by default) then a tasks.json file and a .bat file will be generated as soon as a project is loaded or the currently loaded project file changes. The generated tasks.json defines both a build task and a test task. The build task will simply compile the loaded project while the test task will start the compiled application with the run parameters defined in the .dproj or .lpi file. If there is no .dproj or .lpi file for the project then OmniPascal won’t create a build script. So there are no auto generated build scripts for old Delphi projects.
The generated build scripts rely on MSBuild for Delphi projects and LazBuild for Lazarus projects. OmniPascal needs to know the location of these applications in order to work properly.
The path to MSBuild is defined in the setting omnipascal.msbuildPath. If no path is defined OmniPascal will try to find the path by itself.
The path to LazBuild is be defined in omnipascal.lazbuildPath.
Changes in the OmniPascal settings are not reflected on the fly. You need to restart Visual Studio Code or execute the command Reload Window when you change settings!
IMPORTANT CHANGES
– The settings namespace used for OmniPascal is no longer objectpascal but it’s omnipascal. You need to change the settings in Visual Studio Code. For example: The setting objectpascal.delphiInstallationPath has to be changed to omnipascal.delphiInstallationPath.
– The path to the FreePascal source files is no longer stored in objectpascal.delphiInstallationPath. It’s now stored in omnipascal.freePascalSourcePath.
– FreePascal users need to set omnipascal.defaultDevelopmentEnvironment to FreePascal. The default value is Delphi.
Change log
Features
– Ability to load a project file
– Automatically adjust search path when opening a project file (loaded from .dproj and .lpi files)
– Automatic creation of tasks.json and a build script when loading a project that has a corresponding .dproj or .lpi file
– If DelphiInstallationPath is not defined in the settings then OmniPascal looks for the most recent Delphi installation path itself
Bugfixes
– Fixed visibility of symbols defined in System.pas
– Aliases of full qualified types are now handled properly
– Fixed possible stack overflow when working with a generic class defined in the implementation section
– Fixed random crashes
– Parameterless calls to WriteLn, Write, ReadLn and Read can now be resolved
– Outlining in files with syntax errors works better
– Hints for constants of empty strings are now correct
– Implementations of overloaded methods could not be found when an alias for a parameter type is used in the implementation while the declaration uses the original type name
– Fixed internal error when code completion was requested for objects of a type that could not be resolved
– Fixed broken syntax highlighting for Self, Result and some keywords.
New features:
– Execute Add unit to uses in order to add a unit to a uses clause without navigating to the top. Open the command palette (by pressing F1 or CTRL+SHIFT+P) and type “Add unit to uses”. Select the uses clause and a list of all available units will appear. Select the one you want and press enter. The command is also bound to ALT+U
– Automatic implementation of interfaces adds missing units to the uses clause
– Member of typed pointers can be resolved
Bugfixes:
– Creation of errors and warnings does no longer stop working after a while
– Constants in classes are now resolved properly
– Indexed access on constant resolves now to the definition of that constant / constant array
– Fixed random crashes
Notable changes:
– General performance improvements. Especially startup and code completion are much faster.
Features:
– Members of type casted identifiers can be resolved
– Code completion works even when working with type casts
– Basic data types like Integer or String appear in code completion
– Added support for Delphi Intrinsic Routines for Windows 32 platform
– True, False and Nil now appear in code completion
– Added support for pointer types
Bugfixes:
– Names of nested types in generic classes couldn’t be resolved in method implementations
– Names of nested strict private types can be resolved
– Code completion list doesn’t grow anymore when triggered multiple times in classes which inherit from a specialized generic class
– Fixed occasional crashes of OmniPascalServer.exe when editing code with multiple cursors
– Calls to overloaded methods weren’t always resolved correctly based on the parameter count. (Resolving calls to overloaded methods still doesn’t work when multiple versions of a method accept the same amount of parameters)
– Members of items in generic arrays can be resolved
– Name resolving and code completion for symbols defined in the implementation section now works in initialization and finalization section