All Functions and Procedures

Name Unit Description
AddCommand Command.Add

This command adds features to the project like a unit tests project creating a tests subfolder, or adds code documentation capabilities to the project base on pasdoc.

AddCoverageBuildMode Utils.Coverage

Adds the Coverage build mode to a test project, if it does not have it, with the compiler options of the project: the same search paths, so pasc deps keeps them in sync, DWARF 3 debug info, no optimization, no heaptrc, the units in lib/coverage and the executable next to the Default one, with -coverage at the end of its name. Only the new build mode is written, the rest of the file is kept as it is. Returns false if the project already had the build mode.

AddPackageReference Utils.Workspace

Adds a required package with a relative DefaultFilename to a .lpi or .lpk file. The file is changed as text to preserve its formatting. Returns false if the package was already required.

AddSourcePaths Utils.Workspace

Adds the source folders missing from every OtherUnitFiles of a project, in all its build modes, relative to the project and with / as separator. The existing entries are kept, so it only adds. Returns true if the project file was changed.

AnalyzeAdoption Utils.Adopt

Analyzes a project and returns the plan to convert it to a workspace. Nothing is changed.

ApplyAdoption Utils.Adopt

Applies a plan returned by AnalyzeAdoption. Returns the description of each change. Tracked files are moved with git mv to keep their history.

BuildCommand Command.Build

This command uses the lazbuild tool to build the specified project. If one was not provided, try to find one on current directory and builds it.

The purpose of this command is to automate the build process along with the watch command.

The command accepts two build options –debug or –release. The project file must have both modes with these respective names. If no option is passed, the lazbuild tool will run in default mode.

BuildTestProject Command.Test

Builds the test project using lazbuild. The .lpi file with the same name of the project file is preferred if it exists. Returns true if the build succeeded.

BuildTestProject Command.Test

Builds the test project like the other BuildTestProject, and returns in AError the first error of the compiler when the build fails, for a summary.

CheckCommand Command.Check

This command checks every member of the workspace, or the project in the current folder, and its test project: folders with units that are not in the search paths of every build mode, search paths that do not exist, and for a package the units that are not in its files and the files that no longer exist. In a workspace it also checks the modules folder: out of place, missing, or without the modules of boss-lock.json. Each problem is a warning with the line to add or remove, and the exit code is 1 when there is any.

CheckIfUserPressedCtrlC Utils.Shell

 

CheckProject Utils.Check

Checks a project or package and returns one warning per problem found, with the paths relative to ABaseDir. A search path under the modules folder of ABaseDir that does not exist comes with the hint to run pasc deps. Returns empty when there is nothing to fix.

CheckRules Utils.LintRules

Parses a source file with fcl-passrc and returns the findings of the rules. A source that can not be parsed gives a single PL000 note with the reason. The resources of {$R} are ignored, and the includes are searched in the folder of the file.

CheckWorkspace Command.Check

Checks the modules folder of the workspace, then every member and its test project, and outputs one warning per problem. Returns the number of warnings.

CheckWorkspaceModules Utils.Check

Checks the modules folder of a workspace and returns one warning per problem found: a modules folder out of place, under apps, packages or a member, where pasc deps does not install the dependencies; no modules folder at the root while boss.json has dependencies; and modules recorded in boss-lock.json that are not in the modules folder.

CleanCommand Command.Clean

This command recursively from the current path searches for folders named "lib" and "backup" to remove them. However, before removing them, it asks the user for confirmation. Confirmation that can be suppressed if the –force option is given.

CoverageCommand Command.Coverage

This command builds the test project in the current folder, or in its tests subfolder, with the Coverage build mode, runs it under kcov and outputs the coverage of each source file of the project, without the tests and the modules. At the root of a workspace it does the same for every member with a tests folder and outputs the total. The units with code that no test uses are not seen by kcov, so they are listed as warnings. The exit code is 1 when the tests could not run, any of them failed or the coverage is below –min.

CoveragePercent Utils.Coverage

Returns the coverage as a percentage, zero when there are no lines.

DefaultLintConfig Utils.Lint

Returns the default configuration: warnings fail, notes and hints are shown.

DepsCommand Command.Deps

This command runs boss install at the root of the current workspace, even when called inside a member, so the whole workspace has a single boss.json and modules folder. Then it updates the search paths of every member (and its test project) with the source folders of the installed modules, relative to each member.

boss "projects" attribute is not used because boss writes those paths relative to the workspace root, while lazarus resolves them relative to each project file.

DocsCommand Command.Docs

Generates the documentation with pasdoc, by convention: - docs/generate/introduction.txt is the introduction, and conclusion.txt the conclusion; - every other docs/generate/*.txt is an additional page; the command*.txt pages are grouped as Commands in the menu, after the other pages; - the sources are the units in the search paths of the project (.lpi or .lpk) in the current folder, and its main program; at the root of a workspace, of every member; - docs/generate/custom.css, when it exists, replaces the pasdoc stylesheet. The output goes to docs. The exit code is 1 when pasdoc is missing or fails.

FilterBossOutput Utils.Boss

Returns the boss output without ANSI escape sequences. If AFilterDelphi is true the lines produced by the Delphi-only internal tools are also removed, and ANoiseFound returns true if any of them was found.

FilterMemberFiles Utils.Lint

Returns the files that are sources of a member, the ones FilterMemberMessages keeps, each one once.

FilterMemberMessages Utils.Lint

Returns the messages for the sources of a member: files in its folder, not in its lib, backup or modules folders. Each message is returned once, also when two projects of the member compile the same unit. Errors are always kept, wherever they are, because they stop the build.

FindFile Utils.IO

Recursively search for the first file from the specified path. Returns the filename with the full path if it was found.

FindInCodeFile Utils.IO

Returns first ocurrence of text in format line:1 (column is always 1). It is case insensitive search. If not text is found the function returns an empty string.

FindMember Utils.Workspace

Returns the member with the given name, or a member with an empty name if it was not found.

FindProject Command.Build

Checks if specified project exists, if a project file is not provided try to find one on current directory. Returns complete file name if a project is found.

FindProjectFile Utils.IO

From the current directory it tries to locate a lazarus project that contains a specific text. If AText is empty the first project found will be returned. Returns the project file name.

FindSourceFile Utils.IO

From the current directory it tries to locate a source file. Any file with .pas or .pp extension will be considered as source file. Returns the first occurence of a source file. Returns empty if not source file was found.

FindTemplate Utils.Templates

Finds a template by its name, ignoring case. Returns false if there is none.

FindTestProject Command.Test

From the current directory it tries to locate an fpcunit compatible test project, in the current folder or in a tests subfolder. Returns the complete test project file name, or empty if the project does not exist or is not of the expected type.

FindWorkspaceRoot Utils.Workspace

Searches for a workspace manifest from the given directory up to the file system root. Returns the workspace root directory, or empty if the directory is not inside a workspace.

FirstBuildError Command.Test

Returns the first error in the output of lazbuild, the line that explains the failure among the hints and the lazbuild messages, like TestCommandGreet.pas(11,3) Fatal: Can't find unit Command.Interfaces used by TestCommandGreet. The folder of the file and the message number are removed. Returns empty if there is no error.

FormatPercent Utils.Coverage

Formats a percentage with two decimals and a dot, like 94.00%.

GetBuildModesPaths Utils.Check

Returns the search paths of each build mode of a .lpi, or the search paths of a .lpk. A build mode without compiler options of its own uses the ones of the project.

GetCoverageExecutable Utils.Coverage

Returns the complete file name of the executable of the Coverage build mode of a .lpi, or empty if it has no such build mode.

GetFileContent Utils.IO

Get the contents of AFileName in string.

GetJsonFileContentWithOutComments Utils.IO

Get the contents of a JSON AFileName in string. Remove commented lines to make possible do parse its content. Returns JSON content.

GetMemberSourceDirs Utils.Workspace

Returns the folders under the src folder of a member, src included, that have Pascal sources (.pas, .pp or .inc), sorted. lib and backup folders are not included. Returns empty if the member has no src folder.

GetMemberTestProject Utils.Workspace

Returns the .lpi of the test project of a member, or empty if the member has no test project.

GetModulesMissingFromLock Utils.Workspace

Returns the module folders recorded in boss-lock.json that are not in the workspace modules folder. The folder name depends on the boss version (3.x uses github_com_user_repo, older versions the repository name), so a difference means the lock was written by another boss version, and the search paths synced from this machine do not match it. Returns empty without a lock or a modules folder.

GetModuleSourceDirs Utils.Workspace

Returns the complete paths of the source folders of the boss modules installed in the modules folder of the workspace. Like boss, each folder of the "mainsrc" of the module boss.json (separated by ";", or the module root without it) is searched recursively, and every folder with .pas, .pp or .inc files is returned.

GetPackageFiles Utils.Check

Returns the absolute files listed in the Files of a .lpk.

GetPackageReferences Utils.Workspace

Returns the complete file names of the packages required by a .lpi or .lpk file through a DefaultFilename, resolved relative to the file folder.

GetParametersFrom Utils.Shell

Process a raw string and returns an array of strings with the parameters that were separated by spaces, and consider as single parameter a string between double quotes.

GetResource Utils.Resources

Returns a string with the content of the resource file.

GetTemplateNames Utils.Templates

Returns the names of the available templates, separated by commas.

GetTemplates Utils.Templates

Returns the available templates.

GetTestExecutable Command.Test

From the current directory it tries to locate an fpcunit compatible test project that has been previously compiled. Returns complete test file executable name. If the function returns empty, the project does not exist or is not of the expected type.

GetUnitFolders Utils.Check

Returns the folders under the project folder that have units (.pas or .pp), not the project folder itself, which is always searched. Hidden, lib, backup, modules and tests folders are skipped, and so are the folders with a project or package of their own.

GetUnitsNotInReport Utils.Coverage

Returns the units (.pas or .pp) of the given folders, not of their subfolders, that have code but are not in the report: no test uses them, so kcov does not see them and they are not counted. Sorted.

GetWorkspaceMembers Utils.Workspace

Returns the members of the workspace listed in pasc.json. A member pattern is a folder relative to the root, or a folder followed by /* for each of its subfolders. Folders without a .lpk or .lpi file are ignored.

HasBuildMode Utils.Coverage

Returns true if a .lpi has a build mode with the given name, ignoring case.

HasCode Utils.Coverage

Returns true if the source of a unit has code after its implementation: a begin, an asm, an initialization or an include. A unit with only declarations has no line for kcov, even when a test uses it. Comments and strings are skipped.

IgnorePaths Utils.Coverage

Appends to the .gitignore of a folder the paths that git does not ignore yet, when the folder is in a git repository, like /coverage/. The .gitignore is created if needed, and its lines are kept. Returns the lines added.

InstallCommand Command.Install

Shows the recommended way to install pasc on the current platform, and the steps to remove an install made by the previous versions of this command. Nothing is changed, and the exit code is 1, since pasc is not installed by it.

InstallDependencies Command.Deps

Runs boss install for each dependency at the workspace root, then updates the search paths of the members, like the deps command. Returns false, with the boss exit code in ExitCode, if boss failed.

IsFailing Utils.Lint

Returns true if the message makes pasc lint fail: an error, a kind in fail or a number in fail.

IsIgnored Utils.Lint

Returns true if the configuration ignores the message.

IsSuppressed Utils.LintRules

Returns true if the line of the message, or the line above it, has a comment pasc-lint: ignore with the id of the message, like // pasc-lint: ignore PL001, 5024.

LicensesCommand Command.Licenses

Shows the pasc license followed by the third-party notices.

LintCommand Command.Lint

This command builds the project in the current folder and its test project, or at the root of a workspace every member and its test project, and outputs the messages of the compiler for their sources, as file:line:col links. The configuration in pasc.json says which messages are ignored and which ones fail; by default warnings fail. The exit code is 1 when there is a failing message or a project could not be built.

LintKindName Utils.Lint

Returns the name of a kind, like warning.

LintMessageId Utils.Lint

Returns the id of a message as the output shows it: the number of a message of the compiler, like 5093, or the id of a rule, like PL001; empty when there is none.

LoadLintConfig Utils.Lint

Reads the lint configuration of a member from the pasc.json of the workspace:

"lint": { "ignore": [5024, "PL001"], "fail": ["warning", 5091], "rules": { "PL004": { "max": 60 } }, "members": { "web": { "ignore": [5024] } } }

ignore and fail take kinds (error, warning, note, hint), message numbers and ids of rules. rules has the limits of the rules that have one. A member, by name or by folder relative to the root, adds its ignore to the one of the workspace and, when it has fail, replaces it; its rules replace the limits it has. Without pasc.json or lint, the default is returned. Raises an exception for a value that is not a kind, a number or a rule.

NewCommand Command.New

This command creates a freepascal/lazarus project respecting a previously organized folder structure so that it is easier to operate the project in vscode, with git previously initialized and ready to work with boss dependency manager.

With –workspace it creates a workspace instead: a repository with multiple apps and internal packages. Inside a workspace, –app and –package create its members.

With –template=name it creates the app from a template, with its boss dependencies installed: outside a workspace, a workspace with the app in apps/name; inside one, with –app, the app in the apps folder of the workspace.

OutputError Utils.Output

Outputs a error message in console with color from CommandBuilder theme color.

OutputInfo Utils.Output

Outputs a text in console with color from CommandBuilder theme color.

ParseCompiledFiles Utils.Lint

Parses the output of lazbuild and returns the source files the compiler compiled, from its lines (3104) Compiling file, without the resources. A relative file name is resolved like in ParseCompilerMessages.

ParseCompilerMessages Utils.Lint

Parses the output of lazbuild and returns the messages of the compiler with a file and a position, like file(line,col) Warning: (5093) text. A relative file name is resolved from the last Working Directory that lazbuild wrote, the one of the project or of a package it compiles, or from ABaseDir before the first one. Messages of the linker, the assembler and the resources, numbered from 9000 to 9999, are not about the code and are left out.

PrepareWorkspace Command.Check

Prepares the members of the workspace to be built: adds the src folders of each app to its search paths, then outputs the warnings of CheckWorkspace. Used by pasc build and pasc test before calling lazbuild, so a problem shows up before the first member is built.

ReadCoverageReport Utils.Coverage

Reads the coverage.json written by kcov.

RebasePath Utils.Adopt

Returns the given relative path, of an entry of a project file that was at AOldDir and is now at ANewDir, so that it still points to the same place. Paths that point inside one of the moved folders or files are kept, as they moved together. Lazarus macros are kept.

Registry Command.Add

Registry a add command using the command builder from pascli.

Registry Command.Build

Registry a build command using the command builder from pascli, also sets. options and usage help info.

Registry Command.Check

Registry a check command using the command builder from pascli.

Registry Command.Clean

Registry a clean command using the command builder from pascli, also sets. options and usage help info.

Registry Command.Coverage

Registry a coverage command using the command builder from pascli.

Registry Command.Deps

Registry a deps command using the command builder from pascli.

Registry Command.Docs

Registry a docs command using the command builder from pascli.

Registry Command.Install

Registry a install command using the command builder from pascli, also sets. options and usage help info.

Registry Command.Licenses

Registry the licenses command using the command builder from pascli, also sets usage help info.

Registry Command.Lint

Registry a lint command using the command builder from pascli.

Registry Command.New

Registry a new command using the command builder from pascli.

Registry Command.Test

Registry a test command using the command builder from pascli.

Registry Command.Watch

Registry a watch command using the command builder from pascli.

RunTests Command.Test

Runs the test project found from the current directory and outputs the report. If ABuild is true the test project is built with lazbuild before running. Returns whether the tests ran and how many passed and failed.

RunUserCommandAsRequested Command.Watch

Execute the command requested by the user, it will be passed to IPathWatcher so that it executes it. It is prepared to run the project build and tests as long as there is a respective executable. .

SaveFileContent Utils.IO

Save AContent string in the provided file name.

ShellCommand Utils.Shell

executes a program and returns the output as funciton result and also provide a execution status through AStatus out parameter

SortMembersByDependency Utils.Workspace

Returns the members sorted so that each package comes before the members that require it. Raises an exception if there is a circular reference.

StripAnsi Utils.Boss

Removes ANSI escape sequences (colors and cursor control) from a text.

SyncMemberSources Command.Deps

Adds the folders under src of an app member that have Pascal sources, like the feature folders of the web template, to the search paths of its project, in every build mode, and of its test project. FPC does not search the unit folders recursively, so a new folder would only fail later with "Can't find unit". Packages list their units in the .lpk and are not changed.

SyncModulePaths Utils.Workspace

Replaces, in every OtherUnitFiles of a .lpi or .lpk file, the paths that point to the workspace modules folder by the given module source folders, relative to the file folder. Other paths are kept. The file is changed as text to preserve its formatting. Returns true if the file was changed.

SyncWorkspaceModules Command.Deps

Updates the search paths of every workspace member and of its test project with the source folders of the modules installed by boss.

TestCommand Command.Test

This command searches for a fpcunit test project in the current folder or in a tests subfolder, builds it using lazbuild and runs it. At the end of the execution, an xml file with the same name as the test project is expected to be read. From this reading, a result is generated with the objective of highlighting the tests that failed, formatting the name of the source code file with a line and column in a format that vscode is able to understand and providing the developer with a link for quick navigation through the code.

If a memory leak trace file named heap.trc is found, the command also outputs information with details about the possible memory leaks in a format that vscode can provide easy navigation through the code.

WatchCommand Command.Watch

This command aims to monitor for changes in the current directory. Changes considered are new files, changes to existing files, and file deletions.

The ignored folders are the ones that start with ".", the ones named "lib", "modules", "backup". Ignored files start with ".", with no extension, .exe, .dll and .trc.

Once the change condition is satisfied, the requested commands are executed so that their output is generated in the console.

WriteTemplateFiles Utils.Templates

Writes the files of the template to the app folder, creating the subfolders, with the app name in place of {APPNAME}. Returns the files written.


Generated by PasDoc 1.0.4.