ui5plugin-parser
An npm library that reads the metadata of the standard SAPUI5 classes and parses a project's own UI5 classes into objects listing their fields, methods, properties, aggregations, associations and events.
Tooling for a UI5 project needs to know what a class declares before it can say anything about it. This library answers that from source: on initialisation it reads the metadata of the standard SAPUI5 classes and parses the projects in the working directory, in JavaScript or, when a tsconfig.json and .ts files are present, in TypeScript. A caller creates the parsers with ParserFactory.createInstances and looks a class up through ParserPool. Settings sit under ui5.ui5parser in package.json or an rc file such as .ui5pluginrc.json: ui5version, excludeFolderPatterns, libsToLoad, additionalWorkspaces, nodeProjects and proxyWorkspaces. It parses and checks nothing: the rules are ui5plugin-linterui5plugin-linterA command-line linter for UI5 projects, run as ui5linter, that checks JavaScript and TypeScript classes, XML views and fragments, and i18n properties files.independent, ui5's and the editor features are ui5pluginui5pluginThe SAPUI5 Extension for Visual Studio Code: completion, definitions, CodeLens, diagnostics, code actions, hover and an XML formatter for UI5 views, controllers and manifest.json.independent, ui5's, the two packages its README names as its users.
Facts
Who is behind it
In the atlas: maintains 3, contributes to 3@iljapostnovsmaintainerMarcello UrbaniContributes to this
In the atlas: maintains 14, contributes to 21@marcellourbani1 contributor
Before choosing this
Conditions
PracticalFunctional boundary
A project nested inside another is not parsed: its README says nested projects are not supported any more. A library installed from npm is read only when it ships its -dbg.js files and manifest.json.
What it declares
Every artifact
- Type
- Package
- Origin
- Independently maintained
As a package
- Where it runs
- does not say
- Distributed through
- npm
Connections
SAPUI5 extension for Visual Studio Code
Command-line linter for UI5 classes, XML views and i18n files
Download
Install
npm add ui5plugin-parserDerived from the package name. No recipe recorded; the README has the configuration.
README
quoted from iljapostnovs/ui5plugin-parser under Apache-2.0, readUI5 Class Parser
Parser package for UI5 based projects
Primarely used by ui5plugin-linter package and Visual Studio Code SAPUI5 Extension
Any support is highly appreciated!
![]()
Summary
Configuration
RC and package.json
Configuration can be done in package.json or in any of rc file types:
.ui5pluginrc.ui5pluginrc.json.ui5pluginrc.yaml.ui5pluginrc.yml.ui5pluginrc.js
For simplicity purposes all examples are written for package.json, but it works the same way for all file types.
Config interface
interface IUI5PackageConfigEntry {
ui5?: IUI5ParserEntry;
}
interface IUI5ParserEntry {
ui5parser?: IUI5ParserEntryFields;
}
interface IUI5ParserEntryFields {
ui5version?: string;
excludeFolderPatterns?: string[];
dataSource?: string;
rejectUnauthorized?: boolean;
libsToLoad?: string[];
additionalWorkspaces?: string[];
nodeProjects?: string[];
proxyWorkspaces?: string[];
}
Config default values
Default package.json or rc file config looks as follows:
{
"ui5": {
"ui5parser": {
// UI5 Version for standard library metadata preload from ui5.sap.com. If no patch level is added, latest patch will be loaded and used.
"ui5version": "1.120",
// Folder GLOB patterns which should be excluded from reading by parser
"excludeFolderPatterns": ["**/resources/**", "**/dist/**", "**/node_modules/**"],
// Source for standard library metadata preload
"dataSource": "https://ui5.sap.com/",
// For HTTP requests to dataSource
"rejectUnauthorized": true,
// List of libraries to be loaded
"libsToLoad": [
"sap.m",
"sap.ui.comp",
"sap.f",
"sap.ui.core",
"sap.ui.commons",
"sap.ui.export",
"sap.ui.layout",
"sap.ui.support",
"sap.ui.table",
"sap.ui.unified",
"sap.ushell",
"sap.tnt",
"sap.suite.ui.microchart"
],
//Handy to add additional workspace paths if e.g. library is outside of CWD. See "Additional workspaces" section for more details
"additionalWorkspaces": ["../MyLibrary"],
//option to tell explicitly where UI5 projects are relative to CWD, useful for CAP projects. See "Proxy workspaces" section for more details
"proxyWorkspaces": ["./MyFEApp1", "./MyFEApp2"],
// This configuration entry tries to parse UI5 project from node_modules folder. Requires "-dbg.js" files and "manifest.json" to be there.
"nodeProjects": ["my-node-library"]
}
}
}
These are default values, which can be overriden.
In case of
libsToLoadandexcludeFolderPatternsall additional values which are added in package.json will be added to the default values, not rewritten.
Parser instantiation logic
Let's introduce two terms which will be used here:
- CWD - current working directory, or the root folder of the project which is opened in the VSCode.
- Workspace - UI5 workspace, or the folder which has
manifest.jsonin it.
--- CWD ---
├── webapp
--- Workspace 1 ---
│ ├── Component.js
│ └── manifest.json
├── library
--- Workspace 2 ---
│ ├── library.js
│ └── manifest.json
└── package.json
The basic way for instantiating the parser looks as follows:
- Read
package.jsoninCWDand use it as a configuration source - Read all
Workspacesand create UI5 Parser instance for it, usingpackage.jsonas configuration source from previous step - If
CWDhastsconfig.jsonand any.tsfiles, it is considered to be TS project. Otherwise it's JS project.
Important! Take in mind that nested projects are not supported anymore, which means that there can be no folders with such structure:
├── webapp
│ ├── library
│ │ ├── library.js
│ │ └── manifest.json
│ ├── Component.js
│ └── manifest.json
The structure which will work as expected:
├── library
│ ├── library.js
│ └── manifest.json
├── webapp
│ ├── Component.js
│ └── manifest.json
Additional Workspaces
If there is a e.g. library outside of the CWD, checkout additionalWorkspaces config for ui5parser.
Example:
├── MyApp (CWD)
│ │ ├── webapp
│ │ │ ├── manifest.json
│ │ │ └── Component.js
│ └── package.json
├── MyLibrary (Outside of CWD)
│ │ ├── src
│ │ │ ├── manifest.json
│ │ │ └── library.js
│ └── package.json
└── tsconfig.json
To make this work, corresponding entry in package.json should be added
"ui5": {
"ui5parser": {
"additionalWorkspaces" : ["../MyLibrary"]
}
}
Proxy Workspaces
There are cases when project is mixed, meaning that one folder may contain many different projects inside, non-ui5 as well. Most frequent case would be CAP project with both backend and frontend in one folder.
Example:
├── frontend
│ ├── webapp
│ │ └── manifest.json
│ ├── package.json (<- this file will be used as configuration source after proxyWorkspaces is configured)
│ └── tsconfig.json
├── backend
│ ├── Whatever.js
│ └── package.json
├── package.json (<- proxyWorkspaces should be configured here)
└── tsconfig.json
To make the parser work only for frontend folder, corresponding entry in package.json should be added
"ui5": {
"ui5parser": {
"proxyWorkspaces" : ["./frontend"]
}
}
What happens is that CWD is replaced with the new path from proxyWorkspaces, so at instantiation stage package.json and tsconfig.json from frontend folder will be used instead of root folder.
Node projects
There are cases when custom projects (e.g. libraries) installed via npm are used, for that purpose nodeProjects configuration entry was created.
Example:
npm install my-custom-library
package.json:
"ui5": {
"ui5parser": {
"nodeProjects": ["my-custom-library"]
}
}
Important! In order to get the project parsed properly, it should have
-dbg.jsfiles andmanifest.json. Configuration will be inherited from main project (project inCWD). In other words, npm packages which were not built properly and have nomanifest.jsonwill not work.
TS vs JS
Initialization
If tsconfig.json is found in the CWD and any .ts files are found in the workspace, parser considers that it's TS project.
tsconfig.json should be located in CWD.
Folder exclusions
For convenience purposes UI5TSParser ignores src-gen folder, because they contain transpiled JS/XML files, which can make the parser to think that source files are there. If build folder name is different, is should be added to excludeFolderPatterns in your package.json. If you are using older tooling with manual babel transpiler which generates webapp folder, it should be added to excludeFolderPatterns as well
How to use
Initialization process reads the metadata of standard SAPUI5 classes and parses all projects in CWD (Current working directory), it's encapsulated into createInstances method. For getting parsers just call it.
const wsFolders = [new WorkspaceFolder("Absolute path to the workspace")];
const parsers = await ParserFactory.createInstances(wsFolders);
Necessary methods for getting information about the classes exists ParserPool class, which works with all parser instances. As an example, to get the parser for custom class, getParserForCustomClass can be used:
const parser = ParserPool.getParserForCustomClass("com.test.any.class");
const UIClass = parser.classFactory.getUIClass("com.test.any.class");
UIClass will have class metadata such as fields, methods, properties, aggregations, associations, events etc.
TS only! For performance reasons TS parser doesn't parse types right away. If you want to load all type info such as method return type, parameter types etc, please use
UIClass.loadTypes()
History
Other 1
Notes
- Downgrade acorn-loose to 8.4.0
Other 2
Notes
- validate TLS connections by default (rejectUnauthorized=true)
- improved proxy support (use custom agent only when not validating TLS connections)
Other 3
Notes
- minor parsing improvements
- default version updated to 1.120
- UI5 version now can be set w/o patch and latest patch will be fetched
Other 1
Notes
- Now as a fallback for TS parsing if no default exported class or object is found, first class declaration is taken as main class in the file which will be parsed
Other 4
Notes
ForOfStatementandAssignmentPatternsupport added- Minor syntax analyser improvements
@ui5model,@abstractjsdoc support for classes added- Classes now have description
Other 5
Notes
- Typescript updated to v5.0.2
- Remove all singletones. Now parser supports multiple parser instances
additionalWorkspacesconfig entry addedproxyWorkspacesconfig entry addedwebappfolder is not automatically excluded for TS projects anymore
Other 2
Notes
- Remove console.log for "Libs are preloaded"
- Add deprecated jsdoc support for class members
Details
Sources
Sources are graph entities: the same page may back several entries, and an unreachable source flags every row that rests on it.
Compatibility and provenance
Contributors
History in the atlas
- Listed on bestofui5.org and not yet in the atlas. Read from the repository README (https://github.com/iljapostnovs/ui5plugin-parser): "Parser package for UI5 based projects"; "Initialization process reads the metadata of standard SAPUI5 classes and parses all projects in CWD"; "UIClass will have class metadata such as fields, methods, properties, aggregations, associations, events etc."; "Primarely used by `ui5plugin-linter` package and Visual Studio Code SAPUI5 Extension"; "nested projects are not supported anymore"; and the npm record for 1.10.1 (Apache-2.0, author Ilja Postnovs). No provides edge: the README describes a parser, and none of the capabilities in the graph is a parsing library. Distribution through npm rests on the registry record alone, since the README gives no install command.
- First seen.
For your agent
- Ref
artifact:iljapostnovs-ui5plugin-parser- JSON
- /artifacts/iljapostnovs-ui5plugin-parser.json
- MCP
- Connecting an agent