-
Notifications
You must be signed in to change notification settings - Fork 27
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Feat: add goto controller's definition from xml view files (#701)
* feat: go to controller's definition from xml view files * fix: adapt failing test * fix: change set * fix: file resolution * fix: sonar cloud issue * fix: lint * fix: add new package to sonar project * fix: refactor for future reuse * fix: typo * fix: sonar properties * fix: sonar issues * fix: review comments * fix: failing test * fix: sonar issue
- Loading branch information
1 parent
e8498f0
commit ceab281
Showing
36 changed files
with
987 additions
and
5 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
--- | ||
"@ui5-language-assistant/vscode-ui5-language-assistant-bas-ext": patch | ||
"vscode-ui5-language-assistant": patch | ||
"@ui5-language-assistant/xml-views-completion": patch | ||
"@ui5-language-assistant/xml-views-definition": patch | ||
"@ui5-language-assistant/xml-views-validation": patch | ||
"@ui5-language-assistant/xml-views-tooltip": patch | ||
"@ui5-language-assistant/language-server": patch | ||
"@ui5-language-assistant/context": patch | ||
--- | ||
|
||
Enable go to controller's definition from XML view file |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Empty file.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
# Contribution Guide | ||
|
||
This package does not have any unique development flows. | ||
Please see the top level [Contribution Guide](../../CONTRIBUTING.md). |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
[](https://www.npmjs.com/package/@ui5-language-assistant/xml-views-definition) | ||
|
||
# @ui5-language-assistant/xml-views-definition | ||
|
||
Logic for goto definition of Language Server Protocol (LSP). | ||
|
||
## Supported scenarios: | ||
|
||
### From XML to controllers' definition: | ||
|
||
It supports dot or object notation for following XML attributes. | ||
|
||
- "controllerName" | ||
- "template:require" | ||
- "core:require" | ||
|
||
It resolves controllers' definition as follows: | ||
|
||
1. It tries to load `<path>.controller.js` | ||
2. It tries to load `<path>.js` | ||
3. It tries to load `<path>.controller.ts` | ||
4. It tries to load `<path>.ts` | ||
|
||
## Usage | ||
|
||
This package only exposes programmatic APIs, import the package and use the exported APIs | ||
defined in [api.d.ts](./api.d.ts). | ||
|
||
## Support | ||
|
||
Please open [issues](https://github.com/SAP/ui5-language-assistant/issues) on github. | ||
|
||
## Contributing | ||
|
||
See [CONTRIBUTING.md](./CONTRIBUTING.md). | ||
|
||
## Licensing | ||
|
||
Copyright 2022 SAP SE. Please see our [LICENSE](../../LICENSE) for copyright and license information. Detailed information including third-party components and their licensing/copyright information is available [via the REUSE tool](https://api.reuse.software/info/github.com/SAP/ui5-language-assistant). |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
export { getDefinition } from "./src/api"; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
const { join } = require("path"); | ||
const defaultConfig = require("../../jest.config"); | ||
|
||
module.exports = { | ||
...defaultConfig, | ||
globals: { | ||
"ts-jest": { | ||
tsconfig: join(__dirname, "tsconfig-test.json"), | ||
diagnostics: { | ||
// warnOnly: true, | ||
exclude: /\.(spec|test)\.ts$/, | ||
}, | ||
}, | ||
}, | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
{ | ||
"name": "@ui5-language-assistant/xml-views-definition", | ||
"version": "0.0.1", | ||
"private": true, | ||
"description": "Definition logic for UI5 XML-Views", | ||
"keywords": [], | ||
"files": [ | ||
".reuse", | ||
"LICENSES", | ||
"lib/src", | ||
"api.d.ts", | ||
"src" | ||
], | ||
"main": "lib/src/api.js", | ||
"repository": "https://github.com/sap/ui5-language-assistant/", | ||
"license": "Apache-2.0", | ||
"typings": "./api.d.ts", | ||
"dependencies": { | ||
"vscode-languageserver": "8.0.2", | ||
"@xml-tools/ast": "5.0.0", | ||
"vscode-languageserver-textdocument": "1.0.1", | ||
"vscode-uri": "2.1.2", | ||
"@ui5-language-assistant/context": "4.0.24", | ||
"@xml-tools/parser": "1.0.7", | ||
"@ui5-language-assistant/binding-parser": "1.0.7" | ||
}, | ||
"devDependencies": { | ||
"vscode-languageserver-types": "3.17.2", | ||
"@ui5-language-assistant/test-framework": "4.0.12" | ||
}, | ||
"scripts": { | ||
"ci": "npm-run-all clean compile lint coverage", | ||
"clean": "rimraf ./lib ./coverage ./nyc_output", | ||
"compile": "yarn run clean && tsc -p .", | ||
"compile:watch": "tsc -p . --watch", | ||
"lint": "eslint . --ext .ts --max-warnings=0 --ignore-path=../../.gitignore", | ||
"test": "jest --ci --forceExit --detectOpenHandles --maxWorkers=1 --coverage=false", | ||
"coverage": "jest --ci --forceExit --detectOpenHandles --maxWorkers=1 --coverage=true" | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
import { Location } from "vscode-languageserver-types"; | ||
import { DefinitionParams } from "vscode-languageserver"; | ||
import { getControllerLocation } from "./controller"; | ||
|
||
/** | ||
* Get definition location(s). This method implements `onDefinition` request of LSP (Language Server Protocol) | ||
* | ||
* @param param definition param | ||
* @returns definition location(s) | ||
*/ | ||
export async function getDefinition( | ||
param: DefinitionParams | ||
): Promise<Location[]> { | ||
const ctrLoc = await getControllerLocation(param); | ||
return [...ctrLoc]; | ||
} |
Oops, something went wrong.