Giter Site home page Giter Site logo

vscodeui5plugin's Introduction

SAPUI5 Extension

TestAndBuildBadge

Any support is highly appreciated!


Check the blog to get some ideas for developing with TS!


This plugin contains perks for UI5 developers.

Before you start working with the plugin, it will be useful to set formatOnSave setting in VSCode preferences:

"editor.formatOnSave": true

As well it's recommended to install e.g. Prettier extension for JS/TS files formatting. The reason for it is described in Known issues

Make sure that you have excludeFolderPattern property set correctly for ui5parser. This property is critical if you have SAPUI5 libraries or any other sources which should not be parsed in your workspace.


v1.7.0 update

Got new XML errors with ids and event handlers? Check out UI5 Linter Readme.

Have any ideas on how to improve MeaningAssumption variable determination? Create Feature request

Summary


Configuration

VSCode extension is using UI5 Parser and UI5 Linter packages, because of that configuration is splitted into three parts:

  1. UI5 Parser configuration. Contains parser related configuration, e.g. UI5 Version, URL for standard library metadata preload, exclude folder patterns etc. Configuration can be done in package.json or any of rc file types, e.g. .ui5pluginrc.

Important! If ui5parser related entries were changed in the package.json or any other rc file, VSCode should be reloaded manually

  1. UI5 Linter configuration. Contains linting related configuration, e.g. linter exceptions, severity, usage etc. Configuration can be done in package.json or any of rc file types, e.g. .ui5pluginrc.
  2. VSCode preference entries. Contains VSCode specific configuration.
VSCode Preference Description
ui5.plugin.jsCodeLens Should javascript CodeLens be enabled
ui5.plugin.jsReferenceCodeLens Should javascript Reference CodeLens be enabled
ui5.plugin.xmlCodeLens Should xml CodeLens be enabled
ui5.plugin.propertiesCodeLens Should properties CodeLens be enabled
ui5.plugin.signatureHelp Should UI5 Signature Help be enabled
ui5.plugin.moveDefineToFunctionParametersOnAutocomplete Should sap.ui.define class names be moved to function parameters on sap.ui.define autocomplition
ui5.plugin.codeGeneratorStrategy Strategy which should be used for code generation. E.g. you will get 'var' with ES5 strategy and 'let' with ES6 strategy when using override completion items.
ui5.plugin.UMLDiagramGenerationStrategy Which format should be used for UML diagram generation
ui5.plugin.addI18nTextLengthLimitation Should text length be added to i18n text id (e.g. #YMSG,14)
ui5.plugin.textTransformationStrategy Case type which should be used for i18n text id proposal
ui5.plugin.askUserToConfirmI18nId Should user confirm proposed i18n id
ui5.plugin.addInheritedPropertiesAndAggregations Should inherited properties/aggregations be added in XML completion items
ui5.plugin.addTagAttributes Should tag attributes be added in XML completion items
ui5.plugin.addTagAggregations Should tag aggregations be added in XML completion items
ui5.plugin.tsEventModule Event module for Typescript, which will be used when creating event handler from XML
ui5.plugin.tsEventType Event type for Typescript, which will be used when creating event handler from XML. (e.g. type of sap/ui/base/Event is Event).
ui5.plugin.insertManagedObjectModule Module which will be used for automatic insertion on custom class creation
ui5.plugin.insertControllerModule Module which will be used for automatic insertion on custom controller creation
ui5.plugin.xmlFormatterTagEndingNewline Should XML Formatter put tag ending (">", "/>") in newline
ui5.plugin.xmlFormatterSpaceAfterSelfTagEnd Should XML Formatter leave a space between the last attribute and the self tag end ("/>")
ui5.plugin.umlGenerationPath Path for file generated by UI5: Generate UML Class diagram for whole project command. Relative to project folder. Example: ../diagram/ClassDiagram.pu
ui5.plugin.XMLFileInterfacePath Path for file generated by UI5: (TS) Generate types for XML files (id to class mapping) command. Relative to project folder. Example: ./types/ViewFragmentIds.d.ts
ui5.plugin.generateXMLFileInterfacesOnSave Should UI5: (TS) Generate types for XML files (id to class mapping) command be executed on XML file save or not. Works only if ui5.plugin.XMLFileInterfacePath is set. Works only for TS projects.
ui5.plugin.TSODataInterfacesPath Path for file generated by UI5: (TS) Generate interfaces for OData entities command. Relative to project folder. Example: ./types/ODataTypes.d.ts
ui5.plugin.TSODataInterfacesFetchingData URL, username and password for UI5: (TS) Generate interfaces for OData entities command.
ui5.plugin.massTSODataInterfacesFetchingData Array of URL, username and password for UI5: (TS) Generate interfaces for OData entities command (Mass).
ui5.plugin.ERDiagramPath Path for file generated by UI5: Generate ER diagram from metadata.xml command. Relative to project folder. Example: ../diagram/ERDiagram.pu
ui5.plugin.JSTypeDefDocPath Path for file generated by UI5: Generate JS typedef JSDoc from metadata command. Relative to project folder. Example: ./model/ModelTypedef.js
ui5.plugin.globalConfigurationPath Absolute path to global any_file.json configuration file, which is used by UI5 Parser and UI5 Linter. Priority of ui5 config determination: local package.json -> global any_file.json -> default value. Example: C:\\Users\\MyUser\\Documents\\ui5config.json
ui5.plugin.idGenerationFormula Formula for id generation.
ui5.plugin.eventHandlerGenerationFormula Formula for event handler name generation.
ui5.plugin.generateIdsCommandData Data for ui5plugin.generateIds command. Contains array of classes to be excluded from ID generation and a flag if IDs should be generated for Elements as well, or for Controls only
ui5.plugin.bulkExportToi18nCommandData Data for ui5plugin.bulkExportToi18n command. Contains data about which proprties should be exported to i18n.only

Completion Items

XML

XML Completion Items for UI5 Controls.

Related preference entries:
ui5.plugin.addInheritedPropertiesAndAggregations
ui5.plugin.addTagAttributes
ui5.plugin.addTagAggregations
ui5.plugin.idGenerationFormula
_ui5.plugin.eventHandlerGenerationFormula

XMLCompletionItems
XML Completion Items for properties, aggregations, associations and events
DynamicXMLCompletionItems

JS/TS

sap.ui.define

Strings for import in sap.ui.define are provided.
UIDefine

Control ID Completion Items

IDs from the corresponding view of the controller are provided for view.byId or controller.byId method
GetView

Dynamic Completion Items

Completion items which are generated dynamically depending on current variable type or method return value type. Trigger character - dot.
DynamicCompletionItems

Manifest.json

Schema for manifest.json properties is provided.

ManifestCompletionItems


Method Definitions

Definitions for custom methods are provided.

Hotkey: Ctrl + Left Click

Definition


XML Event Handler Definitions

Definitions for event handlers are provided.

Hotkey: Ctrl + Left Click

Definition


CodeLens

CodeLens for Internalization Texts (translations), overriden methods, event handlers and member references is provided DynamicCompletionItems

Related preference entries:
ui5.plugin.jsCodeLens
ui5.plugin.jsReferenceCodeLens
ui5.plugin.xmlCodeLens
ui5.plugin.propertiesCodeLens


XML Diagnostics

See UI5 Linter for reference

DynamicCompletionItems


JS/TS Diagnostics

See UI5 Linter for reference

DynamicCompletionItems


Properties (i18n) Diagnostics

See UI5 Linter for reference


Code Action Provider

Code Actions for UI5 modules import and inserting non-existent methods in .js/.ts files are provided.
Code Actions for creating event handlers in controllers from xml views/fragments are provided.
Code Action for renaming event handlers from xml views/fragments is provided.

Hotkey: Alt + Enter

CodeActionsProvider CreateMethodCodeActionsProvider

Helpful for TS! Check out ui5.plugin.tsEventType preference entry. Handy if UI5 Version 1.115.1+ is used, because the preference entry can be changed to {tsEvent}, in such case the correct event will be added automatically. Example: ListBase$SelectionChangeEvent will be generated, if Create method action will be selected on non existant event handler in XML view sap.m.List -> selectionChange event

Image

Image

Related preference entries:
ui5.plugin.tsEventModule
ui5.plugin.tsEventType


JS and XML Hover Provider

Information on hover is provided.

HoverProvider


XML Formatter

XML Formatter is available.

XMLFormatter

Related preference entries: ui5.plugin.xmlFormatterTagEndingNewline
ui5.plugin.xmlFormatterSpaceAfterSelfTagEnd


JS/TS Rename Provider

Rename provider for js/ts is provided.
The provider renames all references to the class for JS projects, and all references for the views/fragments for both TS/JS projects.

JSRenameProvider


Commands


Move sap.ui.define to parameters

Hotkey: F5

Related preference entries: ui5.plugin.moveDefineToFunctionParametersOnAutocomplete

UIDefine


Export to i18n

Set your position to the string you want to export to i18n.properties file and execute command. Works both in XML and JS files.

Info! If there is no selection, whole string will be exported. If there is a selection, only the selected part of the string will be exported.

this.getBundle() method which returns ResourceBundle should be defined in Controller/BaseController

Related preference entries:
ui5.plugin.askUserToConfirmI18nId
ui5.plugin.addI18nTextLengthLimitation
ui5.plugin.textTransformationStrategy

Hotkey: F4

ExportToI18n


Export to i18n (bulk)

Open view or fragment and execute command. Works for XML files only.

Important! There is no info provided by SAP regarding which property should be exportable to i18n, that is why it is not possible to fully automate this process. This command exports only properties, which are configured to be exported. If there are some properties which are not exported, but should be, it is possible to adjust ui5.plugin.bulkExportToi18nCommandData VSCode preference entry. If you find yourself editing the preference entry, please open a ticket in github and share what was added, so it could be included into default value and work for everyone.

Related preference entries:
ui5.plugin.bulkExportToi18nCommandData

BulkExportToI18NCommand


Switch View/Controller

Goes to view from controller and to controller from view
If somebody uses MVC, the command actually switches between Model (Default model, which is set as this.getView().setModel(oModel) in the controller) View and Controller

For TS projects it is possible to add @ui5model JSDoc to the class, which should have a class name of the model to which the command will switch to. It will improve the performance issue, because reading type of default model might take seconds. Example:

/**
 * My Controller JSDoc
 * @ui5model {com.test.mvc.master.model.MyMasterModel}
 */

Hotkey: F3

SwitchViewController


Insert Custom Class name

Inserts the class name into current position

Hotkey: F6

InsertCustomClassNameCommand


Clear Cache

Clears cache with SAPUI5 lib metadata


UML Class Diagram generation

UML Class diagram generates for the project of the currently opened file.

Command name: UI5: Generate UML Class diagram for whole project

Also it is possible to generate ER diagram for opened metadata.xml file.

There are two ways to generate ER diagram:

  • Open metadata.xml file, execute command UI5: Generate ER diagram from metadata.xml
  • Execute command UI5: Generate ER diagram from metadata.xml and enter url to metadata.xml

It is possible to select in preferences which type of diagram to generate: DrawIO or PlantUML.
However, DrawIO is not supported anymore.

Recommended VSCode extensions:
DrawIO: hediet.vscode-drawio-insiders-build
PlantUML: jebbs.plantuml

UML Diagram example:
UML.png

ER Diagram example:
ERDiagram.png Related preference entries:
ui5.plugin.umlGenerationPath


JSDoc typedef generation from metadata

There is a possibility to generate typedef JSDocs from metadata

There are two ways to generate typedefs:

  • Open metadata.xmlfile, execute command UI5: JSDoc typedef generation from metadata
  • Execute command UI5: JSDoc typedef generation from metadata and enter url to metadata.xml

Related preference entries:
ui5.plugin.JSTypeDefDocPath

GenerateJSDocTypedef.gif


(TS) Generate interfaces for XML files (id to class mapping)

There is a possibility to generate mapping TS interfaces from control id to control type

Related preference entries:
ui5.plugin.XMLFileInterfacePath
ui5.plugin.generateXMLFileInterfacesOnSave

GenerateODataInterfaces.png


(TS) Generate interfaces for OData entities

There is a possibility to generate TS interfaces for OData entities

There are two ways to generate interfaces:

  • Open metadata.xml file, execute command UI5: (TS) Generate interfaces for OData entities
  • Execute command UI5: (TS) Generate interfaces for OData entities and enter url to metadata.xml

Related preference entries:
ui5.plugin.TSODataInterfacesPath
ui5.plugin.TSODataInterfacesFetchingData

GenerateXMLToIdInterfaces.png


(TS) Generate interfaces for OData entities (Mass)

Works the same as previous command, but can be used for multiple OData models at once. ui5.plugin.massTSODataInterfacesFetchingData preference entry should be configured for this command to work.

Related preference entries:
ui5.plugin.massTSODataInterfacesFetchingData


Generate ids for all elements in view or fragment

Command, which generates IDs for elements in views and fragments. To generate ids, open a view or fragment and execute command.

IDGenerationCommand

Related preference entries:
ui5.plugin.idGenerationFormula
ui5.plugin.generateIdsCommandData


Automatic template insertion

Inserts initial text for .js, .ts and .xml files
Extends "sap/ui/core/mvc/Controller" if file name ends with .controller.js/.controller.ts and "sap/ui/base/ManagedObject" if file name ends with .js/.ts

Hint! sap/ui/core/mvc/Controller can be changed to e.g. com/my/app/BaseController using ui5.plugin.insertManagedObjectModule preference entry

Related preference entries:
ui5.plugin.insertControllerModule
ui5.plugin.insertManagedObjectModule
> AutomaticTemplates


Automatic class name and class path renaming

Extension listens for .js/.ts file creation event (rename technically is file deletion and creation) and replaces all occurrences of class name to the new one
AutomaticClassNameReplacingOnRename


UI5 Explorer

Custom UI5 Explorer view in VSCode panel is available

  1. For JS/TS files tree view contains fields and methods
    JSTreeView

    Coloring for methods is based on lines count and references count.
    > Red color appears if there are more than 100 lines in one method
    > Orange color appears if there are more than 50 lines in one method or there are 0 references (reference count is ignored if method is overriden)
    > Green color appears for the rest of the cases

  2. For XML files tree view contains class tag list
    XMLTreeView


UI5 Project Data

Custom UI5 Project Data view in VSCode panel is available

It represents the data about the project, like UI5 Version, config path etc. It makes easier to troubleshoot the config related issues.

View is not updated automatically, in order to do that, refresh button on the top right corner should be pressed.

UI5ProjectData


Hotkeys

Hotkey Command
Alt + Enter Quick Fix Action
F3 Switch View/Controller
F4 Export string to i18n
F5 Move sap.ui.define imports to parameters
F6 Insert custom class name

Assumptions

  • File starts with sap.ui.define (JS)
  • Your class body is in AnyUI5Class.extend("name", {here}); (JS)
  • You have manifest.json with App ID
  • App ID (Component name) and i18n paths are defined in manifest.json
  • File is without syntax errors
  • Name of the UI5Class is written accordingly to file path. (E.g. "/src/control/Text.js" => "anycomponentname.control.Text")
  • You have an access to https://ui5.sap.com for standard lib metadata preload

Proxy

If HTTP_PROXY or HTTPS_PROXY environment variables are set, https://ui5.sap.com will be requested using the proxy.


Known issues

acorn-loose

acorn-loose is used as JS parser. It has issues if you have mixed spaces and tabs. Example:

function() {
	 var oModel = this.getModel();
	var asd;
}

There is an unnecessary space before var oModel and acorn is parsing it incorrectly. As a result - the file will not be parsed as expected and you might not get JS completion items and get errors in xml views regarding wrong values for event handlers.
Keep your code clean, it will help you to have the plugin working correctly :)
It's highly recommended to set formatting on save in your VS Code preferences, it will help to avoid such issues.

"editor.formatOnSave": true

Standard VSCode JS Formatter is not handling all formatting issues. hookyqr.beautify extension did, but it got deprecated. It's highly recommended to install some kind of formatter, e.g. Prettier, and use as JS formatter.

"[javascript]": {
	"editor.defaultFormatter": "<YourFormatter>"
}

ui5.sap.com damaged JSON response

For some reason ui5.sap.com sometimes might return damaged JSON when requesting standard library metadata. As a result, it is possible to get such error as:
UIFiveError
To solve it, please run UI5: Clear cache command and reload VSCode.


Things to consider using TS

  1. If any .ts files are found and tsconfig.json is found, project is considered to be TS project
  2. src-gen folder is automatically excluded by extension if it's TS project. If build folder has different name, it should be added to folder exclusions in UI5 Parser configuration.
  3. Folder with builded resources should be added to exclusions of ui5parser. Check excludeFolderPatterns in package.json.
  4. Not all linters work for TS, because TS has a lot out of the box features. E.g. Wrong field/method linter works only for JS, because TS has it's own syntax analysis for that.
  5. ts-morph is used as TS parser and it has some drawbacks. When using typechecker to get type e.g. of the field or return type of the method, ts-morph might hang up for about ~10s, which is not great. However, types are crucial for Reference CodeLens/Linters, specifically for fields in order to be able to distinguish them in views/fragments. As a workaround for performance issues, typechecker is not used to get field types. Because of that only simple structure is allowed.

Examples which should work as expected:

export default class Random {
  formatterInstance = new Formatter(),
  formatterObject = Formatter
}

At the same time type detection will work if the type is specifically written, e.g.

formatter: Formatter = ...
  1. Disabling TS standard reference code lens should be considered. This extension contains its own reference code lens, which includes references to views and fragments.

Extension recommendations

"yaml.schemas": {
    "https://raw.githubusercontent.com/iljapostnovs/VSCodeUI5Plugin/master/schema/packageSchema.json": [
        ".ui5pluginrc.yaml",
        ".ui5pluginrc.yml"
    ]
}
  • XML to get simple syntax linting

vscodeui5plugin's People

Contributors

carlosorozco88 avatar dependabot[bot] avatar iljapostnovs avatar jeremies avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar

vscodeui5plugin's Issues

Not Working on Mac Os

Hi,

i tried to use the extension on mac os, but on windows it works fine.

the intelisense not working on mac os vs code

image

thank you for this extension.

Unable to load plugin in VScode

Hi,

this problem sounds a little stupid but I cannot use this plugin in vscode. when i press F5 or other shortcuts, it will pop up a window below.

image

I am not sure what the "source folder" means, but I do have a manifest.json in the opened folder. i tried to move this file around in different folders, since it's originally in the subfolder of my project. But it does not work finally.

would you provide any hints? like how the plugin detect the manifest.json file. Thanks.

Incorrect custom control metadata processing (events)

Describe the bug
if a custom ui5 control has events clause in its metadata and event name is entered as identifier (not as a string literal) then UI5 extension gives error "Error parsing : Cannot read property '0' of undefined".
The root cause location is src/classes/UI5Classes/UI5Parser/UIClass/CustomUIClass.ts:1229 (function _fillEvents)
if metadata event is defined like this:

{
   "cancel": {}
}

then the eventNode.key.type value will be "Literal" and in that case the actual event name will be in eventNode.key.value. Currently the extension is using eventNode.key.name in any case. And when we have key of Identifier an exception occurs at line 971 function _fillEventMethods.

In our project we have both variants and we can't change everything as there are too many files, also it is a correct syntax.

After the exception the extension stops working, any command results in error: command 'ui5plugin.switchBetweenVC' not found

To Reproduce
Create a simplest custom control and define and event in metadata, for example:

{
   "someEvent": {}
}

Expected behavior
As we are using correct syntax for event the extension should process them correctly.

Desktop (please complete the following information):

  • OS: macOS

Extension causes high cpu load

Hello,
It's been a few days that I am not able to use the extension anymore.
It causes everything else to not start and spend a lot of system ressources without endind.

iljapostnovs.ui5plugin-unresponsive.cpuprofile.txt

  • Issue Type: Performance
  • Extension Name: ui5plugin
  • Extension Version: 0.12.33
  • OS Version: Windows_NT x64 10.0.19042
  • VS Code version: 1.55.2

Best regards

Not working on Fiori Apps with the official Wizard

Hello,
my partner and I are not able to use the plugin with auto code completion and stuff...

we started an sap fiori application with the official wizard from the SAP Fiori Tools...
Then i switched in the plugin settings from src to webapp...but i have no clue why i got no code completion :(
Also F3 is not working switching from controller to view....

Any idea if we doing something wrong?

Cheers & Thanks!

In XML View less completion

Hi ,
I want to recommend a useful suggestion. When I autocomplete UI5 control in XML view. It completes many elements inside controls. I attached the screen . It reduces our speed when we are writing many controls. Is there an option to prevent the generation of default aggregations. Such as customData,dependents,dragDropConfig,layoutData,tooltip .

In-XML-View-less-completion-

XML diagnostics: event handlers with parameters cause linting errors

Describe the bug
Wherever I have event handlers with parameters in my XML views, the XML linter throws error "Invalid attribute value".

To Reproduce
In an XML view, use an event handler with parameters. E.g.

<Input
  id="nameTextArea"
  value="{ path: 'fields>Name', type: '.bindingTypes.typeString', constraints: { minLength: 1 } }"
  change=".onCheckName(${$parameters>/value})"
/>

Expected behavior
The linter should not be confused by event handlers with parameters.

Screenshots
image

Desktop (please complete the following information):

  • OS: Win10

Wrong folder scan when searching for xml view controller

Describe the bug
Working on a project that has a "webapp" and a "dist" folder, when editing an XML View, the plugin warns an error on the event handlers (like "press='.onButtonPress'") because it is searching the controller in the "dist" folder (that is not constantly updated) instead of the "webapp" folder.
Using the "Quick fix"option creates a new "empty" controller with the correct event handler but in the "dist" folder, instead of opening the existing controller in the "webapp/controller" folder.

Expected behavior
It sould be nice to be able to specify the "scanned" folder in the settings letting the user to choose the "main" project folder ("dist" or "webapp") where to search the project files (controllers, views, fragments etc.)

Invalid value being reported

Hi,

Incorrect issues reported by the extension for the XML files for below valid settings

<m:Link text="{ItemCnt}" press="onItemPressed"

Invalid valuepress="onItemPressed"(UI5plugin)


<m:SearchField id = "SearchTable" search=".onSearch" 

Invalid valuesearch=".onSearch"(UI5plugin)


<Title xmlns="sap.m" text="{userinfo>/Name}"

Invalid attribute nametext="{userinfo>/Name}"(UI5plugin)

VS Command: Export to i18n: Find i18n File specified in manifest

Describe the bug
VS Command: Export to i18n
If multiple reuse Components are used in one repo with multiple manifest files and i18n folders, only the base i18n folder and file are found and exported to.

To Reproduce
Build an app with the following file structure:

webapp

components
>> controller
>> model
>> view
>> i18n
>> manifest.json
>> component.js
controller
model
view
i18n
mainfest.json
component.js

Expected behavior
If i use the command: Export to i18n I expect that the nearest i18n File is used. The closest from my current view.
Comment used > FileSearcher goes up the folder chain to "view" > searches for sibling folder i18n > uses file inside this folder

or:

The same as above, only searches for the component.js manifest file and lookup the key for the i18n file.

Switch View/Controller doesn't work

When you have the controllerName with another attribute in a view the command "Switch View/Controller" doesn't work.

For example in this view doesn't work:

<mvc:View
	controllerName="demo.walkthrough.controller.Detail" xmlns="sap.m"
	xmlns:mvc="sap.ui.core.mvc"
	xmlns:wt="demo.walkthrough.control">

Does not work when having multiple folders in workspace

Does not work when having multiple folders in workspace. For instance, I'm having app A folder and, app B folder under 1 workspace.

To Reproduce
Steps to reproduce the behavior:

  1. Defined source folder in my workspace setting according to glob syntax as multiple "webapp" folders are in the workspace.
    1

Invalid Value (UI5build)

Hello Ilja,

got a similar error as in closed issue #37. Code is simple:

<Image src="./images/advmagna_trans.png"/>

Errormessage is:
{ "resource": "/c:/Development/webapp/view/App.view.xml", "owner": "XML", "code": "UI5plugin", "severity": 8, "message": "Invalid value", "source": "src=\"./images/advmagna_trans.png\"", "startLineNumber": 12, "startColumn": 36, "endLineNumber": 12, "endColumn": 69 }

Application works fine and image is displayed correct.

And another piece of code:
<Button id="helloDialogButton" icon="sap-icon://world" text="{i18n>openDialogButtonText}" press="onOpenDialog" class="sapUiSmallMarginEnd"/>

Errormessage is:
{ "resource": "/c:/Development/webapp/view/HelloPanel.view.xml", "owner": "XML", "code": "UI5plugin", "severity": 8, "message": "Invalid value", "source": "press=\"onOpenDialog\"", "startLineNumber": 11, "startColumn": 17, "endLineNumber": 11, "endColumn": 37 }

Thanks and regards,

Andre

Methods from extended "Base" JS not found in XML linting

Login.controller.js:

sap.ui.define([
	"./BaseController"
], function (BaseController) {
	"use strict";
	return BaseController.extend("my.namespace.controller.Login", {
		onPressLogin: function () {onPressLogin: function () {
....

BaseController.js:

sap.ui.define([
	"sap/ui/core/mvc/Controller",
], function (Controller) {

	"use strict";

	return Controller.extend("my.namespace.controller.BaseController", {
		
		onPressNavBack: function () {
			var oHistory = sap.ui.core.routing.History.getInstance();
			var sPreviousHash = oHistory.getPreviousHash();

Yields:

Invalid value press="onPressNavBack"(UI5plugin)

in a XML with "Login" controllerName, so i guess the parser can't resolve the BaseController but only parses "Login.controller.js".

How to activate plugin in workspace?

Hi,
I was having trouble using plugin , so i followed the steps mentioned in this closed Issue #36 .
I created a project MyProject>src added all other folders with manifest.json in it. Now the plugin is working fine as expected.
However, when i move this project in workspace (using add folder to workspace , or Create folder under main UI5 folder) Plugin stops to work.

Can you guide me how to use the plugin in workspace? i tried changing the src folder in settings, but it didn't help.

Thanks & Regards.

View Id selection in Controller

Hello ,

Thanks your plugin , It is very useful for VSCode users.. But I have a issue. I cant select id from View
What is the reason ? Have a good day.

Medya1

XML validator reports error when using a static handler

Describe the bug
When using a static method of a utility class as a handler within an xml view, it is not recognized. The application runs fine, though.

To Reproduce
Steps to reproduce the behavior:

  1. Create a class with a static method.
  2. Load the class in your Component.js
  3. Use the stqatic method as handler in an xml view
  4. An error is reported although the method is existent.

Expected behavior
Only non-existent static methods of a helper class should be reported.

Screenshots
XML View validation

Desktop (please complete the following information):

  • OS: Ubuntu

Multi-Version Support + Version specific Linting (XML)

1.60 is fine as default - maybe you could allow switching to 1.71 in config (option is already there, but you mentioned the scheme to be incompatible). I think older versions are not needed anymore.

Would it be possible to do version specific XML linting?

E.g. mark "" as invalid / red underline when running 1.60 because it's only supported in >=1.62 (exact version doesn't matter, just "not available with current version")

Or is this beyond the scope of this plugin?

False issue report with different control event handlers in XML view file

Describe the bug
While editing files in VSCOde UI5plugin reports an "Invalid value" error in XML view file for different control events and/or properties:
In my xml view file it reports some of the "press" events in different controls (e.g. RowActionItem, ObjectStatus).
image

Also it reports "Invalid value" inside commented parts like below:
image

How to reproduce
The effect is not stable - probably depends somehow on the file size.

Expected behavior
The plugin should not analyse text inside comments between . It should not report false issues, in my case the event declaration is correct, the handler exists.

Desktop (please complete the following information):

  • OS: macOS
  • VSCode: 1.50.1
  • UI5Plugin: v0.10.0
  • UI5 version - 1.73.1

XML invalid attr name

Is it possible turn on XML UI5 validation for XMLView except metadata.xml?
I tried the combination of setting but unsuccessfully.

image

invalid type of ui5.version

There was set default value of the plugin. Now I can set empty string then the issue is solved. I tried reinstall the plugin but no change. It seems that it's happened after VSC today's update.

image

Fragment defined in XML view doesn't read controller from View

Describe the bug
Error messages in fragment.XML displayed for attribute press (Invalid attribute value) . I believe reason is, that controller is not correctly recognized and therefore list of available function is missing.

To Reproduce
Just open attached project and see errors in fragment XMLs

Expected behavior
Fact is, that XML fragment could be included to several views. So I believe it is necessary to obtain list of all views, where is current fragment used and display for press event
functions of controllers of listed views

Desktop (please complete the following information):

  • OS: Windows 10 Pro 64 bit

Project attachment
Project example:
UI5 VSCodeUI5Plugin.zip

Commands dont work

Hi, i cant get the whole extension to work.

i alway get errors in the following pattern:

command 'ui5plugin.exportToi18n' not found
command 'ui5plugin.insertCustomClassName' not found
command 'ui5plugin.clearCache' not found

src is set to 'webapp'
version is set to 1.60.1 (like in our system, where the app is deployed)

my folder structure looks like this
image

XML files: Namespace marked as unused but it is used

Hi,

i have a namespace that is only used inside an xml tag. Because of that the plugin mark the namespace as unused. This is not true.

Example:

<mvc:View xmlns:core="sap.ui.core" xmlns:mvc="sap.ui.core.mvc" xmlns="sap.m" xmlns:smartTable="sap.ui.comp.smarttable"
xmlns:table="sap.ui.table" xmlns:smartFilterBar="sap.ui.comp.smartfilterbar"
xmlns:html="http://www.w3.org/1999/xhtml"
xmlns:semantic="sap.m.semantic" xmlns:l="sap.ui.layout" xmlns:customData="http://schemas.sap.com/sapui5/extension/sap.ui.core.CustomData/1">

......

<smartTable:SmartTable id="employee_table" customData:p13nDialogSettings='{filter:{visible:false}}' />

In this example the plugin mark the "xmlns:customData="http://schemas.sap.com/sapui5/extension/sap.ui.core.CustomData/1" as unused. If i remove the namespace then the xml file could not rendered.

Thanks and Regards

Haunted

XML Formatter corrupts expand / collapse behaviour

Hello İlya,

I wonder why XML formatter convert this:

<core:FragmentDefinition
	xmlns="sap.m"
	xmlns:core="sap.ui.core">
	<Dialog
		contentHeight="36rem"
		verticalScrolling="false"
		horizontalScrolling="false"
		showHeader="false"
		stretch="{device>/system/phone}">
		<Text text="blabla"/>
	</Dialog>
</core:FragmentDefinition>

to this:

<core:FragmentDefinition
	xmlns="sap.m"
	xmlns:core="sap.ui.core"
>
	<Dialog
		contentHeight="36rem"
		verticalScrolling="false"
		horizontalScrolling="false"
		showHeader="false"
		stretch="{device>/system/phone}"
	>
		<Text text="blabla"/>
	</Dialog>
</core:FragmentDefinition>

That behaviour messes up the collapse / expand structure and i think looks ugly. Is this standard? Or maybe i catched a bug here.

collapse

Thank you very much for this tool, it really adds some more fun to the development experience.

BR,
İlker

Support (line-based) disabling of xml and js rules

As there are inevitably false positives (at least in my projects), it would be nice if there where the possibility to disable rules at least line based.

For a first version it would be enough to switch off xml or js linting entirely for the line.

Feature request: add TypeScript support (*controller.ts)

Hi and first let me thank you for your awesome work!

We are trying to move our UI5-project to TypeScript, but this extension seems to work only with *.controller.js-files.
Is it possible to also consider *.controller.ts-files for these functions?

  • Jump between controller and view
  • Jump from XML Event Handler to the controller
  • Rename View and controller in parallel

Code completion is not important for us, because we're using @sapui5/ts-types.

Switch View/Controller selects controller from /dist subfolder (not from webapp subfolder)

Describe the bug
Very good feature but when you have /dist subfolder with minified sources then it starts selecting files from there. We have a Multi target application for Cloud Foundry and before deployment we have a build process which creates /dist subfolder.
I put "webapp" value to the ui5.plugin.src variable, however the extension selects files from /dist folder after executing command "Switch View/Controller"

To Reproduce
If you don't have a dist subfolder in your project you can temporary copy all the contents of webapp folder and create /dist subfolder.

Steps to reproduce the behavior:

  1. Open existing xml view from webapp subfolder with existing controller file
  2. Execute command "UI5: Switch View/Controller"
  3. The extension most probably would open the controller file from /dist subfolder

Expected behavior
The extension should only take into account ui5.plugin.src folder when looking for the controller/view fles.

Desktop (please complete the following information):

  • OS: macOS
  • Extension version: v0.9.7
  • VSCode version: 1.49.3

Can't Switch Controller/View

Hello!
First of all, let me say that i like your extension, you did a very good job!

the bug:
I tried to use the switch command, and it doesn't work.
in addition, i tried to autocomplete the byId in the controller, and it doesnt work too.

controller:
`
sap.ui.define(["sap/ui/core/mvc/Controller"], function (Controller) {
"use strict";

return Controller.extend("nststproj.controller.vw", {});

});
`

view:
<mvc:View xmlns:html="http://www.w3.org/1999/xhtml" xmlns:mvc="sap.ui.core.mvc" xmlns="sap.m" controllerName="nststproj.controller.vw" displayBlock="true"> <App> <pages> <Page title="{i18n>title}"> <content> <Text text="{i18n>appDescription}" id="__text4"/> </content> </Page> </pages> </App> </mvc:View>

How to handle global and local valirables?

Describe the bug
In a controller, if we have define a global variable to store a context object, how in the local method we can have an autocompletion for it?

To Reproduce
Steps to reproduce the behavior: demo.controller.js

sap.ui.define([
	"sap/ui/core/mvc/Controller",
	"sap/m/MessageToast",
	"sap/m/Label",
	"sap/m/ComboBox"
], function (Controller,
	MessageToast,
	Label,
	ComboBox) {
	"use strict";

	return Controller.extend("demo.controller.Demo", {
		oService: null,
		oContextBtn1: null,
               
                ...
		handlePressButton1: function (oEvent) {
			this.oContextBtn1= oEvent.getSource().getBindingContext();
		},

		handlePressButton2: function (oEvent) {
			this.oContextBtn1.<do_autocomplet_here>
		},
                ...
}

I have tried to use JSDoc in the global variable but it seams not working.

** What I expect **

...
return Controller.extend("demo.controller.Demo", {
		oService: null,
/** @type sap.ui.model.ContextBinding */
		oContextBtn1: null,
               
                ...
		handlePressButton1: function (oEvent) {
			this.oContextBtn1= oEvent.getSource().getBindingContext();
		},

		handlePressButton2: function (oEvent) {
			this.oContextBtn1.<do_autocomplet_here>
		},
                ...
}

For instance:
image

Regards,

Include Timeout for manifest.json scan

Hi, first of all let me say thank you for this great extension.

I sometimes work with an 2 years old multi target application. When I open it your extension tries to scan all manifest.json files, which takes up to 10 minutes. It also blocks code completion, code highlighting and the native GIT integration. Would be nice to include a simple timeout setting for the extension, because it took me hours to recognize where the error comes from.

Load UI5 from local path/server

Hi,

the URL to SAPUI5-Libraries is hard coded in the URLBuilder. Is it possible to pass this URL(https:// and locale file://) as an plugin-parameter like the UI5-Version?

I have no network connection in my environment. Because of that i have to store all files localy on my system.

If other requests are generated in the plugin then it would be nice to override the URL too.

Thanks and Regards

Haunted

XML Diagnostics doesn't work well

When you have the controllerName with another attribute in a view the XML Diagnostics doesn't work well.

For example in this view doesn't work well:

<mvc:View
	controllerName="demo.walkthrough.controller.Detail" xmlns="sap.m"
	xmlns:mvc="sap.ui.core.mvc"
	xmlns:wt="demo.walkthrough.control">

sap.ui.define import ignore quotes

Hello!
When i try to import sap.ui.define class, if i write double quotes at the beginning, it doesn't ignore in the autocomplete, and the import gets messy

example:
image
image

Thanks a lot!

JS Code Suggestion List showing irrelevant items

Describe the bug
The JS code suggestion/completion feature (Ctrl + Spacebar) is showing irrelevant methods, properties for "this" variable

To Reproduce
Steps to reproduce the behavior:

Clone https://github.com/Maruthi-H/flexible-column-layout-SAPUI5.git
Open /webapp/controller/ Detail.controller.js
Go to onInit property line 15 (empty line)
Type in this. and hit (Ctrl + Spacebar)
It only lists "Keywords"

Expected behavior
It should show all properties, methods, events pertaining to this only. Instead it appears it is showing more irrelevant items than it should and the icon/legend before the item in the list is showing 'abc' or text??

Screenshots
image

Desktop (please complete the following information):

image

Additional context
Add any other context about the problem here.

Project attachment
If applicable, Project example for issue reproduction

Feature Request: Handle/Ignore self signed ssl certificates

Hello,

i want to use the plugin in an environmente without internet connection. Because of that i asked for the additional property to configure the sapui5 url. This propertie was added and work perfectly for my local http server. Thank you very much.

But now we try to setup a central HTTPS-Server to serve the SAPUI5-SDK. The problem is that this server has self signed ssl certificates and no http connector. Because of that i get the error "unable_to_verify_leaf_signature".

I set the NODE_EXTRA_CA_CERT environment parameter and the VSCode parameter like " --ignore-certificate-errors" but this doesnt solve the problem. It seems that the VSCode plugins ignore the settings.

Now i looked into the code and saw that the request-promise module is used.

Can you add an additional parameter to the options of "request-promise":

rejectUnauthorized: true/false set via vscode-plugin-property (see https://levelup.gitconnected.com/how-to-resolve-certificate-errors-in-nodejs-app-involving-ssl-calls-781ce48daded)

A better solution will be to add the custom ssl certificates to the trust chain, but this is more complex. If vscode don't pass this to the plugin then the value stored in the environment variable NODE_EXTRA_CA_CERT.

Thanks and Regards

Haunted

XML formatter and single quotes

Describe the bug
It looks like the xml formatter removes every property wrapped in single qoutes.
For example it transforms

<mvc:View
	controllerName='test'
	xmlns:mvc="sap.ui.core.mvc"
>
	<A value='{x>y}'/>
</mvc:View>

to

<mvc:View xmlns:mvc="sap.ui.core.mvc">
	<A>
		<A/>
	</mvc:View>

To Reproduce
Steps to reproduce the behavior:

  1. Create a view/fragment
  2. Replace all " with '
  3. Format

Expected behavior
Replace ' with '"' and format the file as usual.

Desktop:

  • OS: ubuntu, latest VS Code

Completion / Intellisense for XML attributes

Great plugin!

Since you already have the full signature of XML elements (displayed when auto-completing XML elements):

<Button
									activeIcon=""
									enabled="true"
									icon=""
									iconDensityAware="true"
									iconFirst="true"
									text=""
									textDirection="Inherit"
									type="Default"
									width=""
									blocked="false"
									busy="false"
									busyIndicatorDelay="1000"
									busyIndicatorSize="Medium"
									fieldGroupIds="[]"
									visible="true"
								>

would it be possible to offer attribute auto-completion / intellisense for elements when you are editing inside a tag?

E.g.

<Button t...

Would offer "text" and "textDirection" as suggestion instead of all allowed xml elements.

Regex too Large && Architecture Question

Hi Ilja,

First of all: Impressive how much work is within this extension. Really a lot of parsing code :-)
I have two issues atm:
(1) I can not really run your plugin with bigger JS files. A RegEx too large is triggered.
grafik
calls (and causes exception)
grafik

(2) I see you are doing a full parsing of the file in the registerCompletionItemProvider callback of vs-code. What I can not find is any kind of delta parsing, which is causing pretty bad performance (probably related to #45 ).

See: getInstance, instantiating a new class:
grafik

Are there any plans of a delta-parsing architecture? If not, for higher performance, you might also offer a minimal version which is just reading the sap.ui.define stuff to get standard auto complete (w/o user code). Alternative :full parsing of the current file only on save (or similar).

two questions:
(3) Is there any reason, why you are parsing custom files on your own (instead of e.g. taking esprima ( https://github.com/jquery/esprima ), or acorn, which even has a "loose" mode ( https://github.com/acornjs/acorn/tree/master/acorn-loose ). It is not only about performance but also especially about stability (where such well established tools are ofc pretty good).

(4) Are you aware of https://github.com/SAP/ui5-typescript/tree/master/demos/demo-js (as alternative approach for auto-code-completion)? This basically uses jsdoc / ts type definitions for auto-complete.

Thanks again for your work,
Timo

Dynamic Code Completion is not working for "this"

Describe the bug
The JS code suggestion/completion feature (Ctrl + Spacebar) is missing methods, properties for "this" variable

To Reproduce
Steps to reproduce the behavior:

  1. Clone https://github.com/kbitson/northwind-sapui5.git
  2. Open /webapp/controller/ ProductList.controller.js
  3. Go to onInit property line 15 (empty line)
  4. Type in this. and hit (Ctrl + Spacebar)
  5. It only lists "Keywords"

Expected behavior
It should show all properties, methods, events pertaining to this. One of which is, for example, a method called getOwnerComponent or getView

Screenshots
image

Desktop (please complete the following information):

  • OS: Window 10
    image

Additional context
Settings for plugin
image

Project attachment
If applicable, Project example for issue reproduction

Readme file update

Could you please share your sapui5 project folder structure and your sapui5 Extention module settings in the readme file?

Thank you

XML completion when comment

Describe the bug
Hi after a sapui5 sample copy, I found a weird issue when there is a comment on line, the completion helper doesn't work.

To Reproduce
Steps to reproduce the behavior:

  1. Copy code below (at the end of ticket)
    code
  2. Try suggestion (ctrl + space) on GridList
    Issue
  3. Remove <!-- Don't shrink below minimum size. Fill space if available. -->
  4. Try suggestion (ctrl + space) on GridList
    resolve

Expected behavior
A fix.

Desktop (please complete the following information):

  • OS: Windows 11
  • VSCode: v1.57.1
  • VSCodeUI5Plugin: v0.12.62

Thank you for the work.

Code example:
<c:FragmentDefinition xmlns="sap.m" xmlns:c="sap.ui.core" xmlns:f="sap.f"> <VBox > <f:GridList id="gridList" headerText="GridList header" items="{/items}"> <VBox class="sapUiSmallMargin"> <layoutData> <FlexItemData growFactor="1" shrinkFactor="0" /> <!-- Don't shrink below minimum size. Fill space if available. --> </layoutData> <Title text="{title}" wrapping="true" /> <Label text="{subtitle}" wrapping="true" /> </VBox> <f:GridListItem> </f:GridListItem> </f:GridList> </VBox> </c:FragmentDefinition>

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.