问题
I write a VSCode Extension for UI5 JavaScript. The most missing Feature is to have IntelliSense for UI5. Using UI5 typings it will work but not in all.
This works:
var testvar1 = new sap.m.Button();
Now i can use IntelliSense in VSCode in the testvar1.
The Problem e.g.:
sap.ui.define([
"sap/ui/core/mvc/Controller"
],
function (Controller) {
"use strict";
return Controller.extend("", {
});
});
In this case there is a Controller variable in the function, this variable is defined with the Namespace before. I search now for a possibility to assign this variable in my Extension with the Namespace. I know this can be done in the AST but i have now idear how to get access to the AST to set:
Controller = sap.ui.core.mvc.Controller
The goal is to have the full IntelliSense now in the variable Controller
I hope it is clear what i want, so far.
回答1:
If you only need to give a type to Controller
, try using jsdocs:
sap.ui.define([
"sap/ui/core/mvc/Controller"
],
function (/** @type {sap.m.Controller} */ Controller) {
...
});
To answer the original question, you can access/modify the AST with a TypeScript server plugin. This is not trivial so I would try to avoid doing this unless you really need to
来源:https://stackoverflow.com/questions/47617153/how-can-i-access-the-ast-that-vscode-creates